0172: Retained group witnesses for nested processes
Status: Accepted — M18.13 / AT-02b
Context
ADR0171 reserves process identities through cleanup. Nested Harness process operations create groups outside their caller's group, including native input, plugin, agent-tool and VC launches and interpreter run_input. Killing only the outer worker misses them. Moving actual execution to an unrestricted broker would lose inherited OS sandbox restrictions, parentage and local exec-FD rules.
Decision
Keep actual spawning and waiting local. For each new group, the coordinator spawns a harmless /usr/bin/true leader in a fresh group, retains its Child with NOWAIT, and grants that PGID. The real runtime child joins it in the same session. The coordinator directly owns the retained group witness; the runtime remains the real child's parent and adapts status exactly as before. This refines the AT-02b ownership mechanism in ADR0171; it does not permit arbitrary-PID authority.
Inner failures signal the leased group and reap only the actual local child. Success retains existing background-child behavior until case cleanup. Never retire a witness at an inner return. Final cleanup freezes grants, cancels root and every leased group with all identities retained, inspects the whole set for quiescence, and only then reaps. Sequential per-group retirement is rejected: another launcher could still complete an already-accepted spawn into that group.
Use the private inherited descriptor protocol in
OWNERSHIP-CONTRACT.md. A dedicated C bootstrap
installs descriptor3 child-only and direct-execs the original
worker, with an independent CLOEXEC startup-error channel. A
persistent peeked magic identifies the datagram endpoint even
through clean-environment exec. Concurrent clients use separate
reply descriptors. HRT_APP_SCOPE is an inherited loss marker;
active lost/malformed channels fail before spawning. Fixed native
environment builders forward the marker. No parent global cwd,
environment or descriptor flags change.
Use cached pinned nix0.31.3 safe raw-descriptor message APIs to communicate with the inherited descriptor without adopting ownership or writing Rust unsafe. Rustix receives owned ancillary descriptors and supplies retained process APIs. All framing, ancillary count/type, sizes, byte caps and control deadlines are checked. The broker bounds retained witnesses; protocol/startup failures cannot masquerade as application exits. Actual application completion/TR payload is a separate AT-02c gate and is not selected here.
Consequences
OS sandbox, cwd, environment, executable-descriptor and workspace-parent rules stay local and keep their existing authority. A host probe supports joining retained zombie groups and inherited socketpair messaging under deny network*. It does not qualify Linux or the host's unsupported rooted Seatbelt execution. No broad network permission exception is added.
This is trusted-fixture supervision, not containment against deliberate session creation or removal of all runner controls. Ordinary exec, clean environment exec and a descriptor-closing library with a retained marker remain tracked or fail closed. A local control failure may remain a recoverable inner process error; a broker-observed infrastructure failure never produces a backend capture. The new coordinator remains test-only until the real AT-02c runner consumes it.