acpmux: a pooled agent an off passed by while it was claimed is neither restored nor handed out (#23322, review 69)

Merged
TE
25d ago
+122-2

What (#23322, review 69 finding 1)

The coordinator's order for review 69's finding on the pool: "give a claimed entry the off count from when it was claimed, and refuse to restore it or hand it out if an off happened since."

The decision on #23322: "an MDM-managed value is an upper bound the user can't override. If MDM sets allowFullAccess=false, Full access is unavailable and the mode menu says "Managed by your organization". If MDM is unset, nothing changes."

An off push's drain ends only ready pool entries. A pooled agent a chat had claimed when the off began, then the off was unset, could still be restored to the pool (pool_return_claimed) or handed to the chat (pool_take_claimed_for), though it started under the old bound.

Now pool_claim reads MDM's off (OffLatch) before the entry leaves the pool, so an off that comes and goes while the claim checks the entry (out of both the ready and the claimed entries) counts too, and keeps it with the entry (Pooled::claim). OffLatch::began says whether an off began since, even if an unset followed. A claimed entry an off passed by is neither restored nor handed out: it ends, and the chat starts cold. With MDM unset nothing changes: the off count never moves.

An off that begins after the take's check, while the agent is handed to the chat, is #26034's: the push ends what runs in full access once the chat has it (it waits for the chat's start under the spawn lock), and the unset waits for that push.

Its base is feat-cmux-next, where #26034 (b1) has merged.

Tests (session_pool):

  • a_pooled_agent_claimed_as_an_off_began_is_not_taken_after_an_unset (debug seam ACPMUX_TEST_POOL_CLAIM_OFF_FILE: an off begins and is unset after the claim took the entry out of the pool, before its liveness check). Red at ff35e5d972, run 40474012651: fails 2 of 2.
  • a_pinned_pooled_agent_taken_as_an_off_comes_and_goes_ends (debug seam ACPMUX_TEST_POOL_TAKE_OFF_FILE: an off is pushed and unset as the chat takes the agent): the guard for review finding 2. It passes on #26034 alone.

Green at b1cdad9ecc, run 40474012355: fmt, clippy -D warnings, both tests 3 of 3, session_pool 28/28, full_access_managed 2/2, durable_agents 66/66, lib 1349/1350 (only base's red agent_tools::tests::own_servers_run_under_the_daemon_prefix).

Rebased onto feat-cmux-next after #26034 merged, with the same patch: green at 2205dd558d, run 40503077296: fmt, clippy, lib (only base's red agent_tools::tests::own_servers_run_under_the_daemon_prefix), durable_agents 70/70, full_access_managed 2/2, session_pool 28/28, web_mode_current 13/13, hub_integration 510/510.

Part of the split of #25539; the other two review-69 findings get their own PRs.

Risk: low. Pool claims only, and only after an MDM off began. Size: about 115 changed lines.

No capture: no UI changes.

Review: review 1 (at abc90fc6e7) said BLOCK; both findings answered above; review 2 passed (SHIP) at b1cdad9ecc with this same patch. Review 3 (Codex gpt-6-astra xhigh) passed (SHIP) at 2205dd558d, on the merged b1. Its out-of-scope finding (the teardown prefilter and a pooled agent whose full access is only in its session/new answer) is a follow-up.

Agent session: agent session

šŸ¤– Generated with Claude Code