acpmux: under MDM's forced off, approve-all is refused and runs as ask (#23322 a3)

Merged
TE
1mo ago
+481-52

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.json permissionPolicy, 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_policy and _acpmux/set_default_policy refuse approve-all with full_access_off (refuse_full_access_policy).
  • vm_host_peer_approves no 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 permissions lock (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 tokio RwLock) 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's receiver_check to 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 (from in its auto_resume provenance), and subsession_guard::is_family treats 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 ask under the off (effective_policy, review 26): receiver_check, family_dispatch_check and 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 three BOUND cases) now also checks that set_policy approve-all is 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_sandbox unit test: vm_host_peer_approves never approves under MDM's off.

  • Red at a9f522f526 (a1's code with these tests, run 40370561655). The three BOUND cases 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_managed passes, remote_sandbox passes 9/9, and hub_integration full_access passes 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_sessions and every_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_managed passes, full_access_bound 4/4). The lib reds are base's own_servers_run_under_the_daemon_prefix and cli::run::launch::tests::a_launched_session_never_gets_ask_user_question, which passed on head and base when rerun. That run's full hub_integration had 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), and stalled_turn::a_turn_counts_from_its_prompt_being_written failed 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_bound pauses 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_again checks 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 (no await_holding_lock allow). Green at 2c32cc8689 (runs 40387273291 and 40387274479: fmt and clippy clean, lib 1105/1106 with only base's own_servers_run_under_the_daemon_prefix, full_access_managed, subsessions_delivery 1/1, send_steer 5/5, hub_integration 491/491).

  • Review 40 round (rebased onto feat-cmux-next with a1 landed; the rebased review-33 head is 44120d4b34): two unit tests in full_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_resend sends "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_again cuts 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 in turn_end). Green at 72f51d06e7 (run 40406528668: fmt and clippy clean, lib 1160/1161 with only base's own_servers_run_under_the_daemon_prefix, full_access_managed 57/57, subsessions_delivery 1/1, hub_integration 497/497, send_steer 5/5, durable_agents 1/1).

Review 40FindingWhere
(1)The failover resend skipped the family checkhere: checked again under the gate before the resend
(2)An automatic continuation lost the family senderhere: 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