test(acpmux): a gated fake agent exits with its daemon

Merged
TE
16d ago
+85-3

A test that stopped its daemon before opening FAKE_START_GATE left the gated fake_agent.py polling forever. It runs in its own process group (process_group(0)), so the daemon's SIGTERM never reached it, and its gate loop never read stdin. machine-mesh counted 257 of them on huge-blue (2026-10-21). The 13 I inspected were all aas-<tag>-<pid>/gate pollers from person_auto_start.rs.

  • fake_agent.py: while it waits at the gate, it selects on stdin. EOF ends it: the daemon is gone, even after a SIGKILL of the test binary. Bytes that arrive first are kept and read after the gate.
  • person_auto_start.rs: the Daemon drop kills a daemon that hasn't stopped within 10 s, so a hung shutdown can't keep its agents' stdin open.
  • New test auto_start_a_gated_agent_exits_with_its_daemon_and_keeps_what_came_first: a gated agent exits when its stdin closes, and an initialize sent before the gate opens still gets its reply.

Test-only; no product code changes.

Changelog

none

Observed / Not run

Observed, on cmux16 (cargo test --locked -p acpmux --test person_auto_start):

  • base fake_agent.py with the new test: FAILED, "a gated agent outlived the stdin of its daemon";
  • head: 15 passed, and no aas-gate agents left afterwards;
  • the other gate users pass on head: hub_integration an_agent_that_never_answers_its_start_fails_with_a_deadline and lib a_prompt_is_accepted_when_recorded_before_the_agent_starts.

Not run: the full acpmux suite (left to CI).

Agent session: cosmic-gray

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes gated fake agents that polled forever after their daemon died, leaving orphan processes behind (257 on huge-blue, 2026-10-21). A gated agent now selects on stdin while waiting at the start gate: stdin EOF ends it, and bytes received early are kept until the gate opens. The test Daemon drop also kills a daemon that won't stop within 10s, so a hung shutdown can't hold its agents' stdin open. Adds a test covering both behaviors. Test-only; no product code changes.