acpmux: host protocol 2 receipts for fenced lines (#23322 a3 fence, part 3 of 5)

Merged
TE
25d ago
+321-26

What (#23322 a3 fence, part 3 of 5: host protocol 2 receipts)

It builds on 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."

#25538 (#23322 a3) landed as 3e72956265, part 1 (#25804) as 9cd4a013e3 and part 2 (#26176) as e519622e1a. Review 40 on it found that its family gate was released before the write (3) and that a blocked transport could stall an MDM off push forever (4). This stack of five PRs closes both. Each one lands on its own, in order:

  1. the fence for a direct agent;
  2. the fence for a hosted agent;
  3. host protocol 2 receipts;
  4. family messages;
  5. ancestor answers.

This PR moves the agent host protocol from 1 to 2 (agent_host/).

  • A fenced line asks for a receipt. The host's own stdin writer logs it back (_acpmux/host_written) once every line of the message is written to the harness. It logs written: false if the harness's stdin closed first.
  • The receipt is a logged entry, so it reaches this controller or the next one exactly once. A receipt from a previous daemon is ignored, because receipts carry random high bits.
  • A receipting host's line settles only by its receipt or its host's end, never by its request's answer (part 2).
  • Older peers keep the old behaviour. A host or daemon on protocol 1 negotiates 1 and keeps part 2's rule: no receipt, so a fenced line settles only when its host ends. receipt is skipped when unset, so an older host parses a 2-daemon's frames as before.

With MDM unset, nothing changes: only fenced lines ask for receipts.

Risk: the protocol version goes up. A daemon and a host from different builds meet at 1. A host with no resumed controller logs its receipts like any entry.

Tests

tests/agent_host.rs:

  • a_fenced_line_settles_once_the_harness_has_it, with a harness that reads nothing for 3 s;
  • a_fenced_line_keeps_its_receipt_across_a_new_connection;
  • a_fenced_line_to_a_protocol_1_host_is_not_counted_written;
  • an_older_controller_gets_no_frame_it_does_not_know;
  • a_fenced_line_to_a_closed_stdin_settles.

Red: run 40423902319 ("a fenced line settled before its harness read it") and run 40426525534.

Green at 416d32d44f (run 40494474228), the same patch before parts 1 and 2 landed:

  • fmt and clippy clean;
  • agent_host 21/21 four times;
  • lib 1387/1388, with only base's own_servers_run_under_the_daemon_prefix;
  • session_pool 26/26 and durable_agents 61/61;
  • hub_integration 507/508. The one failure is the known flake stop::a_cancel_ends_an_honouring_agents_turn_within_the_budget, which passed 13/13 three times alone in run 40428833322.

Rerun at this head (632ac1cad6), run 40503119581: fmt and clippy clean; lib 1422/1423 and session_pool 25/26 (only base reds own_servers_run_under_the_daemon_prefix and pooled_sessions_end_with_the_daemon_and_after_a_crash); agent_host 21/21; durable_agents 70/70; hub_integration 510/510; full_access_managed passes.

Review

An independent Codex reviewer (gpt-6-astra, xhigh) gave SHIP at 416d32d44f (review 87, round 6). This head is that patch rebased onto parts 1 and 2 with no change. Earlier rounds found nothing of T2's own; the inherited findings were fixed in parts 1 and 2.

No capture: no UI changes.

Agent session: agent session

šŸ¤– Generated with Claude Code