0171: Retained child ownership for application-test supervision
Status: Accepted — M18.10 / AT-02a prerequisite
Context
Application tests require bounded preparation, execution and pipe completion, including descendants which retain a pipe after the direct child exits. The existing interpreter supervisor reaps with try_wait before a later group kill. Its numeric group identity may then be reused. A PID file or registry cannot repair this without a lifetime and retirement protocol.
Decision
The application-test coordinator exclusively owns each direct Child. Observe terminal status with waitid(EXITED|NOHANG|NOWAIT), retaining the unreaped child and its kernel PID reservation. Signal only a still-owned group, and reap only after checked group cleanup. Never construct this authority from arbitrary PIDs or signal after reaping. Keep exit codes distinct from terminating signals.
Use pinned rustix process APIs for safe waitid and group signalling without project Rust unsafe. Use nonblocking UnixStream endpoints and cancellable, joined stdin/stdout/stderr workers. A caller supplies one absolute execution deadline and an explicit combined capture limit. Exceeding the limit is a failure, never a successful truncated capture. A separate bounded cleanup interval must establish quiescence and reap the direct child; uncertainty is reported separately and must prevent the next stage/case.
While the leader is retained, inspect the owned group's live members through the fixed system ps utility with a clean environment, bounded output and deadline. Ignore terminal zombies when checking quiescence; never signal PIDs from enumeration. Retain/reap the trusted ps child too. This is an execution ownership guarantee, not a security boundary against deliberate group escape.
Attempt group cancellation before each enumeration. On macOS, retain EPERM as a pending error: it is acceptable only after terminal direct-child status and a checked zombie-only group; any live member keeps the error. The host probe matches XNU killpg1, whose group filter excludes zombies and returns EPERM with no signalable members. Never reinterpret arbitrary permission errors or Linux EPERM as successful cleanup. Enumeration must include the retained leader.
Consequences
The first module is test-only and covers one inherited group. AT-02b must own nested Harness-created groups before AT-02c wires real app workers. Existing interpreter/driver/native semantics stay unchanged in this prerequisite. A successful observation requires status plus all IO workers completed before the completion/deadline decision; cleanup uncertainty cannot become an app observation. Drop provides bounded best effort, not acceptance evidence.
The ps dependency can fail or hit its own bound; fail cleanup explicitly in that case. No Linux qualification is inferred from macOS checks. Suppressing inner groups, reaping before cancellation and append-only PID registries are rejected. This decision does not freeze the later private completion/TR payload.