acpmux: under MDM's forced off, approve-all is refused and runs as ask (#23322 a3)
What (part a3 of #23322)
This is part a3 of #23322 (sessions.allowFullAccess under MDM). a1 has landed (33db0036d6), and this branch is rebased onto feat-cmux-next with it.
Findings (3) and (4) of review 40, the bounded write fence, are in the stacked PR #25685 and land right after this one. That PR holds the family gate until the agent's transport has written the message or answer, and an off push waits at most 5 s before it cuts what is still unwritten. This PR has findings (1) and (2).
It builds the decision on #23322, quoted word for word:
"#23322 (sessions.allowFullAccess under MDM), decided: 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. This only narrows access, so it needs no call from Leo."
Approve-all is the policy form of full access. Under MDM's forced off:
- A stored approve-all runs as
ask(policy_for). That covers config.jsonpermissionPolicy, a preset, a profile default, or a session set before the push. The person rule reads the policy as stored (stored_policy_for), so it doesn't treat such a session as asking. session/new,_acpmux/set_policyand_acpmux/set_default_policyrefuse approve-all withfull_access_off(refuse_full_access_policy).vm_host_peer_approvesno longer starts a peer's session approve-all.- #25214's guard approval reads MDM's off again at the decision, under the prompt's locks.
- Every push of the off waits on each session's
permissionslock (full_access_turned_off), so no approve-all decision made after any push returns uses the old bound. A second push of an off already stored waits too (review 26); only the push that turned it off drains the pool. - A family message or answer checked under the old bound reaches its agent before an off push returns (review 33). A family gate (
family_gate, a tokioRwLock) is held (read) from a family prompt's last check (family_dispatch_check) to its write, from a family steer's check to its write (a steer is now checked again, as a dispatched prompt is), and from an ancestor's answer'sreceiver_checkto its delivery. An off push takes it (write) once the off is stored, so it waits for those, and a message checked after it is checked under the off. - A family message that fails over (the agent hit a usage limit) is checked again under the family gate before it is resent to the fallback, with the gate held through that write (review 40, finding 1). Before, the resend repeated only
check_dispatch, which does not compare sender and receiver. - The automatic continuation of a family message's cut turn carries the message's sender (
fromin itsauto_resumeprovenance), andsubsession_guard::is_familytreats it as a family message. So it is checked at dispatch and under the gate on every attempt (review 40, finding 2). Before, an off push during the retry wait let the continuation run unchecked. - Sub-session checks rank a stored approve-all as
askunder the off (effective_policy, review 26):receiver_check,family_dispatch_checkand policy inheritance compare policies as they answer, so an approve-all parent can't message an approve-edits child that would approve edits the parent must ask about.
With MDM unset, nothing changes, including the person's own off. approve_all_allowed is !full_access_managed_off(). Before #23322, the person's own sessions.allowFullAccess never capped a policy, and it still doesn't.
Tests
-
tests/full_access_managed.rs:full_access_managed_off(used by threeBOUNDcases) now also checks thatset_policy approve-allis refused;- a new case, "MDM unset: the person's own off leaves approve-all as it was". This was finding 8 of the review rounds: the first restructure capped approve-all under the person's own off too.
-
remote_sandboxunit test:vm_host_peer_approvesnever approves under MDM's off. -
Red at a9f522f526 (a1's code with these tests, run 40370561655). The three
BOUNDcases fail on the approve-all check:- "MDM off is an upper bound over the person's on";
- "a forced value that is not true is off";
- "the off holds across a restart, and unsetting it restores full access".
-
Green at 74d42a5d96 (run 40370560983). fmt and clippy are clean, the full suite runs,
full_access_managedpasses,remote_sandboxpasses 9/9, andhub_integrationfull_accesspasses 14/14. The base reds are the same as a1's. -
Review 26 round (rebased on a1 e70c3d8): two unit tests in
full_access_bound,under_an_mdm_off_approve_all_ranks_as_ask_between_sessionsandevery_off_push_waits_for_an_ask_deciding_under_the_old_bound(a second push while a test holds a session's permission lock must not return). Red at 90a8c1d975 (run 40377848513: both fail). Green at ab4d684028 (run 40377849003: fmt and clippy clean, lib 1102/1104,full_access_managedpasses,full_access_bound4/4). The lib reds are base'sown_servers_run_under_the_daemon_prefixandcli::run::launch::tests::a_launched_session_never_gets_ask_user_question, which passed on head and base when rerun. That run's fullhub_integrationhad two failures (prompt_supersede::a_prompt_queued_before_a_restart_is_still_replaced,presence::the_people_in_one_chat_are_bounded); three more full runs at this head pass 491/491 each (run 40380339781), andstalled_turn::a_turn_counts_from_its_prompt_being_writtenfailed once in three on a1 alone (run 40380339477), so these are load flakes. -
Review 33 round: two unit tests in
full_access_bound.an_off_push_waits_for_a_family_message_checked_under_the_old_boundpauses a family prompt between its check and its write (a test-only seam) and pushes the off: the push must not return.a_family_steer_after_an_off_push_is_checked_againchecks an approve-all parent against an approve-edits child, pushes the off, then steers the message into the child's running turn: it must be refused. Red at 34893551c3 (run 40386740481) and 76b9e3d448 (run 40387113582: both fail). The permission-barrier test now holds its lock on its own thread, not across awaits (noawait_holding_lockallow). Green at 2c32cc8689 (runs 40387273291 and 40387274479: fmt and clippy clean, lib 1105/1106 with only base'sown_servers_run_under_the_daemon_prefix,full_access_managed,subsessions_delivery1/1,send_steer5/5,hub_integration491/491). -
Review 40 round (rebased onto
feat-cmux-nextwith a1 landed; the rebased review-33 head is 44120d4b34): two unit tests infull_access_bound, on a stand-in agent that fails over to itself and continues a cut turn after 1 s.a_family_message_that_fails_over_is_checked_again_before_its_resendsends "slow-limit" from an approve-all parent to an approve-edits child, pushes the off after the first write, and the limit comes a second later: the resend must be refused.the_continuation_of_a_family_message_is_checked_againcuts a family turn with a transport error, pushes the off while the continuation waits: it must be skipped as refused. Red at 9f977e0466 (run 40406421774: both end inturn_end). Green at 72f51d06e7 (run 40406528668: fmt and clippy clean, lib 1160/1161 with only base'sown_servers_run_under_the_daemon_prefix,full_access_managed57/57,subsessions_delivery1/1,hub_integration497/497,send_steer5/5,durable_agents1/1).
| Review 40 | Finding | Where |
|---|---|---|
| (1) | The failover resend skipped the family check | here: checked again under the gate before the resend |
| (2) | An automatic continuation lost the family sender | here: the continuation carries from and is checked on every attempt |
| (3) | The gate was released at enqueue, before the write | #25685 |
| (4) | A blocked transport could stall an off push forever | #25685 |
No capture: no UI changes.
Review: a fresh Codex gpt-6-astra xhigh review gave SHIP at 72f51d06e7e6ab56f425a1ddc56241070459e426 (review 40 findings 1-2 fixed; findings 3-4 are #25685).
Agent session: agent session
š¤ Generated with Claude Code