Files
buzz/crates
npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67dandTyler Longwell 4719362107 fix(buzz-acp): bind steered-👀 cleanup to exact turn; cover shutdown
Review (Wren) found two correctness gaps in the steered-reaction fix:

1. Generation-reuse race: SteerAckEvent carried only (channel_id,
   event_id), and record_steered_event matched TaskMeta by channel. If
   turn A completed and turn B started on the same channel before A's
   delayed SteerAck::Success arrived, A's steered 👀 attached to B and
   survived until the wrong turn ended. send_steer now returns the
   turn's tokio::task::Id; the ack watcher carries it, and
   record_steered_event matches on the exact task id — a stale id
   refuses to bind (returns false) and the ack arm removes the 👀
   immediately.

2. Graceful shutdown bypassed cleanup: the post-loop drain consumes
   PromptResults directly (never via handle_prompt_result) and aborts
   stragglers, so steered ids held in TaskMeta died with the pool and
   their 👀 went stale. tokio_main now drains all steered ids
   (pool.drain_all_steered_event_ids) as the main loop exits and
   bound-awaits a best-effort removal task before process exit.

The three duplicated cleanup blocks are unified in
spawn_steered_eyes_cleanup. New lifecycle tests observe actual wire
behavior against a relay stub — the kind:5 (NIP-09) deletion e-tagging
the 👀 reaction — for normal completion, panic recovery, the shutdown
drain composition, and late-ack immediate cleanup; the generation race
is pinned at the binding level in pool::tests.

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
2026-07-03 11:10:33 -04:00
..