acpmux: admit a new session only while this host has room (1/3 of #24281)

Merged
TE
11d ago
+811-4

Summary

Part 1 of 3 of #24281, split to stay under about 800 changed lines. The code and tests are #24281's at da7658bf (which had an independent Codex SHIP there), with only the cut points chosen.

About 25 Codex reviewers started with a raw acpmux new over reach went around lane-place's cap of 12, filled huge-blue's disk and pushed its load to 50-80. Every new session goes through the daemon's create, so the daemon now refuses one when:

  • ~/.cache/worktree-reclaim/under-floor exists (the disk is under its free-space floor), or
  • this host's live sessions are at lanes.max_lanes for this machine in the fleet registry (FLEET_REGISTRY, else ~/.ssh/config.d/fleet-registry.json, else leo-workspace's machines/fleet-registry.json).

What is checked:

  • In this part: session/new (no adopt, or an adopt that may fork), session/fork and the composer's aside (_acpmux/ask).
  • Never checked: sends, resumes, restarts, side chats, handoff targets and adopts that never fork.

How it behaves:

  • An admitted create counts as live until it ends, so concurrent creates at the cap cannot all pass.
  • A create refused while another create holds its name says the name is taken, so new --reuse takes the winner.
  • _meta.acpmux.forceAdmit, from this host's socket or app only, admits past a refusal. So does the person's own new chat. Both are logged.
  • With no registry, or no lanes entry for this machine, every create is admitted, so acpmux outside the fleet is unchanged.

What each later part adds:

  • Part 2: the CLI side (--force-admit on new, fork and new --parent, exit 5 on a refusal), sub-session starts, and the CLI integration tests (tests/admission.rs, tests/admission_subsessions.rs).
  • Part 3: adopts. An adopt of a conversation a session holds attaches and needs no room. One whose holder ends first asks for room. Concurrent adopts of one conversation converge (admit_adopt, NewRequest::attach_only, tests/admission_adopt.rs).

Testing

Run on huge-blue with a scratch HOME, because this host's own under-floor flag is set and the daemon would otherwise read it:

  • cargo test -p acpmux --lib: 981 passed, 30 failed. Base 2815ee94 fails the same 30 here (temporary-folder, store-permission and TUI tests that depend on this host's TMPDIR) and passes 972. The 9 extra passes are the new hub::admission tests.
  • cargo test -p acpmux --test hub_integration: the same failures as base, plus stalled_turn::a_turn_counts_from_its_prompt_being_written once. It then passed 4 of 4 reruns.
  • subsessions, agent_tools, local_app_trust_gate, remote_guard and session_env pass.
  • send_attach_family and remote_guard_modes fail the same way on base.
  • cargo fmt --check and cargo clippy -p acpmux --all-targets -- -D warnings pass.

Observed / Not run

  • Observed: the runs above.
  • Not run here: the CLI integration tests of the refusal itself. They land with part 2, because they drive --force-admit and exit 5.

Changelog

Added: acpmux refuses a new agent session while its host's disk is under its free-space floor or the host is at its fleet lane cap; --force-admit overrides

Proof

No capture: daemon-only change.

Checklist

  • Behavior changes have added or updated tests, or Testing says why not

Risk: high (session admission policy). It lands on an independent review receipt at the head.

šŸ¤– Generated with Claude Code

Agent session: agent session


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