Problem
Draft PR #252 proved that process-group killing alone cannot guarantee cleanup of arbitrary detached descendants, while cached PID cleanup is identity-unsafe because PIDs can be reused. Frequent synchronous process-table scans also distort timeouts, and the current head/tail capture can corrupt valid under-limit results.
Goal
Design the narrowest portable containment contract that guarantees bounded caller return and never risks killing unrelated processes. Prefer explicit platform primitives (for example Windows Job semantics where available), a trusted-child/process-group boundary, or a disposable helper/sandbox boundary. Do not claim arbitrary detached-descendant containment without enforceable proof.
Done criteria
- No process-name or stale numeric-PID killing.
- Bounded return with inherited-pipe regressions.
- Exact byte-safe UTF-8/output truncation and terminal-result preservation.
- Timeout normalization shared between parent/worker.
- Clear supported/unsupported containment states and fail-closed classification.
- Independent process-safety review before merge.
Supersedes the current implementation direction in #250/PR #252. Coordination: levineam/clawd#1249.
Problem
Draft PR #252 proved that process-group killing alone cannot guarantee cleanup of arbitrary detached descendants, while cached PID cleanup is identity-unsafe because PIDs can be reused. Frequent synchronous process-table scans also distort timeouts, and the current head/tail capture can corrupt valid under-limit results.
Goal
Design the narrowest portable containment contract that guarantees bounded caller return and never risks killing unrelated processes. Prefer explicit platform primitives (for example Windows Job semantics where available), a trusted-child/process-group boundary, or a disposable helper/sandbox boundary. Do not claim arbitrary detached-descendant containment without enforceable proof.
Done criteria
Supersedes the current implementation direction in #250/PR #252. Coordination: levineam/clawd#1249.