acpmux: under MDM's off, a left host is judged by what its log says it reported (#23322 b2)
What (part b2 of #23322, split out of #25539)
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."
Under MDM's off, #26034 ends an agent the predicate counts in full access, a host a restart left included. What a saved chat says of its modes can be older than what its harness last reported: the daemon saves the chat only at some points, so after a crash or a reload a host may run in a full-access mode the saved chat does not show. This piece reads the left host's log back.
Hub::reported_by_left_host reads the log from the host's newest host_started: the answers to the session's own start (session/new, load, resume; a fork's answer describes the new chat, so it does not count), its set_mode and set_config_option answers, and its own current_mode_update and config_option_update records (a load's .replay ones too; a subagent's are skipped, as on_update skips them live). The read is strict (Store::scan_strict): every record from there, one seq after another, each one whole. A log that cannot be read, has no host_started, or lost a record (a torn or malformed line) says nothing, so under MDM's off the host counts as in full access. Once a read finds no full access, what this daemon keeps is complete, so the log is read once per host (FloorState::left_host_read, cleared at each host_started). Host records that cannot be read do not prove the host gone, so the log is read then too.
With MDM unset nothing changes: the read runs only under MDM's off.
Its base is feat-cmux-next, where #26034 (b1) has merged. On the rebase, scan_strict's reader parses with base's new parse_record (#26144), as scan now does; nothing else in the patch changed.
Tests (durable_agents; red at 8666f3c545, run 40471495655: 10 of 10 fail on #26034): a host that moved itself into full access (a mode with none declared) ends at the next daemon and at a later push, also while the host records cannot be read (ACPMUX_TEST_HOST_RECORDS_FAIL_FILE); a subagent's mode does not hide the session's; the saved chat's older modes or options do not hide what the host reported; a log that cannot be read (debug seam ACPMUX_TEST_LEFT_HOST_SCAN_FAILS), lost a record, or ends in a torn record; a mode reported during a load; a fork's answer.
Review 2 fix (red at d6898039fb, run 40508613384: both fail): durable_agents a_left_host_whose_log_reads_back_empty_ends_under_mdm_off (debug seam ACPMUX_TEST_LEFT_HOST_SCAN_EMPTY: the read back finds no record, as when the log's segments could not be listed) and lib store::permission_tests::a_strict_read_fails_when_the_log_cannot_be_listed (the events dir is not a directory). A read back that never reached the host's start now proves nothing (the host ends), and a strict read fails when it cannot list the log's segments, where scan reads none.
Green at d2bd91edf4, run 40508613373: fmt, clippy, durable_agents 81/81, full_access_managed 2/2, web_mode_current 13/13, hub_integration 510/510, lib and session_pool only base's reds. Earlier greens: 49819e61fd (run 40503077258), 14a74b07fa (run 40471495914).
Review 2 (Codex, at 49819e61fd) blocked: an empty strict pass counted as proof of no full access, and segments() lists none when the events dir cannot be read. Fixed above.
Follow-ups, each its own PR: review 69's finding 2 (keep left_host_read only when the host records were readable) is stacked on this one; then b3 (a left host's replay judged before its agent is handed out), b4 (options a bare set_config_option answer took), b5 (agents whose host link stopped).
Risk: medium. It ends running agents, only under MDM's forced off. Size: about 680 changed lines, 365 of them tests.
No capture: no UI changes.
Review: review 1 passed (SHIP) at 14a74b07fa. Review 2 blocked (fixed above); review 3 (Codex gpt-6-astra xhigh) passed (SHIP) at d2bd91edf4.
Agent session: agent session
š¤ Generated with Claude Code