acpmux: a left host's log read is kept only when the host records could be read (#23322, review 69)

Merged
TE
25d ago
+192-16

What (#23322, review 69 finding 2)

The coordinator's order, word for word: "Don't cache left_host_read unless the host records were readable."

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."

#26054 reads a left host's log back once, and then trusts what this daemon keeps (FloorState::left_host_read). A read made while the host records could not be read could still set that flag, so a live host the records could not prove gone was never read back again, and a full access it reported since stayed hidden.

Now the check reads the host records as HostRecords { live, unreadable } (read_host_records) and takes them (runs_full_access_by_records). A session whose own host record cannot be read counts as full access under the off (fail closed: it ends, or stays refused while its end fails), and left_host_read is kept, and trusted, only while the records can be read: otherwise each check reads the log again. A host whose own record cannot be read counts as full access even after a kept read. While the records cannot be read at all, a chat with no agent this daemon hears counts as full access too (host_unknown): a host a restart left may run unadopted with reports in no log, so its end is tried, it stays refused (full_access_end_pending), and it ends once the records can be read. With MDM unset nothing changes.

Stacked on #26054 (this PR's base until it lands; then rebased onto feat-cmux-next).

Tests: lib hub::full_access_bound::tests::a_left_host_read_while_its_records_were_unreadable_is_read_again, a_host_whose_record_cannot_be_read_counts_as_full_access and a_kept_left_host_read_does_not_outlast_readable_records; durable_agents an_unadoptable_host_ends_under_mdm_off_though_its_log_asks (through the real loader's unreadable-record path). Red at 6f441e1f78, run 40480860242: the first, second and fourth fail. Red at 57c56ff694, run 40484533849: the third fails. durable_agents a_host_left_while_the_host_records_cannot_be_read_ends_once_they_can: red at 8f822e9a5c, run 40487168405, fails.

Green at 5d0d548bf1 (rebased onto feat-cmux-next e3a765e893 after #26034, #26035, #26054 and #26052 landed; patch unchanged), run 40533653184: fmt, clippy; lib 1505/1506 with only base's red agent_tools::tests::own_servers_run_under_the_daemon_prefix; durable_agents 85/85, full_access_managed 2/2, session_pool 28/28, web_mode_current 13/13, hub_integration 510/510. Earlier: 01a6ce643a, run 40487168413.

Review 1 (Codex, at be2e33f5b7) blocked: a host's record listed as live was not proof it could be read, since unreadable records are listed too. Review 2 (at f8c9af994f) blocked: a kept read was trusted before the unreadable-record check, so a record that became unreadable later was hidden. Review 3 (at 79955f8266) blocked: with the records unreadable as a whole, a clean log still read as no full access, though a host left unadopted keeps its reports out of the log. All three fixed as above.

Part of the split of #25539.

Risk: low; it only ends more under the off. Size: about 200 changed lines, 125 of them tests.

No capture: no UI changes.

Review: review 4 (Codex gpt-6-astra xhigh) passed (SHIP) at 01a6ce643a; after the rebase, review 5 (Codex gpt-6-astra xhigh) passed (SHIP) at 5d0d548bf1.

Agent session: agent session

šŸ¤– Generated with Claude Code