Files
buzz/crates
Duncan 768b334609 fix(pool): close return/report ordering race on Failed path
Replace the three-condition discarded_failed predicate (which required
last_acked_effort_gen == Some(g) — false in the return→report race) with
a single unconditional rule: any returned worker whose last_effort_result
is Some(Failed) invalidates its sessions regardless of generation state,
value equality, or whether resolve_effort_report has already run.

Rationale: a Failed application means session_set_config_option rejected
the pick; the live session ran at the agent default, not the requested
value. The session is stale in both orderings — no gate state is needed.
Worst case is one redundant session re-creation when the rollback target
equals the default.

Two new regression tests cover both orderings:
- test_failed_worker_return_before_report_invalidates_session (the race):
  return_agent runs while generation is unresolved; session must still be
  invalidated; pre-fix this test fails at the sessions.is_empty() assert.
- test_failed_worker_report_before_return_invalidates_session (normal path):
  resolve_effort_report fires first (pre-prompt); return_agent follows;
  session still invalidated; no second ack emitted.

Both tests assert: failed session empty, exactly one terminal failure ack
with the correct nonce, pool state (desired=low/committed=low) matching ack.

F1 tests extended through resolution: after the invalidation assert, the
high→medium→high and repeated-clear tests now perform the next claim and
simulate a resolve_effort_report, asserting exactly one terminal ack
carrying the newest nonce and persistence-eligible pool state.

Minor 2: fix 4 remaining stale doc-comment references in pool.rs (~1282,
~1378) and lib.rs (~8145, ~8470) that still named create_session_and_apply_
model as the final-ack source; updated to PoolEvent::EffortReport →
resolve_effort_report.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-08-06 23:04:41 -04:00
..