acpmux: a lane started from a session is linked to it, and the link ends when either closes
A session that an agent starts from inside its own session (acpmux new|run from its shell, a local session/new with its caller token) is now linked to the session that started it. The lane carries the tag lane.reportsTo with its parent's exact id. The link the daemon keeps is what counts; editing the tag changes nothing.
- A run tied to its connection (
--ephemeral) is no lane. A session the person starts has no parent. - A session is never linked under itself or its own descendant. The parent walk is bounded at 16 hops, and a refusal at that bound logs a warning.
- A parent that closed while its child was starting is never linked: the check runs under the same lock that close takes.
- When either end closes or is purged, its links are retired.
Why: this is the first half of lane reports (a lane tells the session that started it when each turn ends, like a Claude subagent's parent hears when it stops). The reports themselves come in the follow-up PR on top of this.
Split from #24365 (Leo: keep PRs under ~800 lines). This part adds 317 lines. The reports follow in two more PRs on top: building and delivering them, then the report-only turn rule.
Tests (huge-blue, own CARGO_TARGET_DIR):
cargo fmt -p acpmux --check: clean.cargo check -p acpmux --tests: no errors or warnings.cargo test -p acpmux --test lane_reports: 3/3. Removing the closed-parent check makes one of them fail.cargo test -p acpmux --lib -- lane_reports: 1/1 (closed parent never linked, a parent's close retires the link, no link under a descendant).
Changelog
- acpmux: a session started from inside another session is linked to it (tag
lane.reportsTo), and the link ends when either session closes.
Agent session: agent session