Skip to content

Fix POSIX isolated-module capture drain after leader exit - #4779

Merged
Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
JoyboyBrian:brian/isolated-posix-pipe-drain
Oct 23, 2026
Merged

Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
JoyboyBrian:brian/isolated-posix-pipe-drain

Conversation

@JoyboyBrian

@JoyboyBrian JoyboyBrian commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

A successful isolated unittest can finish while its ordinary POSIX child/grandchild still holds the runner's capture pipes. Previously, communicate waited for pipe EOF before finally could clean that same process group: the default unlimited invocation waited indefinitely, and a finite budget converted the already-completed OK module to timeout 124. A real macOS fixture reproduced the difference by changing only descendant stdout/stderr inheritance (redirected: success in 0.067 s; inherited: rejected at the 3 s deadline).

This repair recognizes an exited POSIX leader before the deadline, invokes the existing owned-group cleanup, then drains the original captured buffers with a bounded two-second cleanup wait. Actual exit status and the successful-unittest completion receipt remain required. Elapsed deadlines and cancellation retain priority; a newly observed late exit cannot become success.

This deliberately supersedes the old test_completed_receipt_with_open_child_pipe_still_times_out expectation. Completed modules now have the same cleanup policy whether ordinary descendants close their pipes or inherit them, matching #2906's closed-pipe POSIX case and #4683's Windows owned-job lifecycle. Proof-relevant subprocesses must still be joined by their tests and propagate their failures. Deliberately detached descendants are outside the owned-process-group contract; cleanup/drain failure never reports PASS. No frozen scientific source, selected frontier, Windows implementation or acceptance pin changes.

Validation on macOS 27.0 arm64 / CPython 3.12.2:

  • Focused inherited test_isolated_test_*.py: 50 cases, 27 pass / 23 platform skips, 11.697 s at the follow-up. Together with the ten new cases: 60 total, 37 pass / 23 skips.
  • The final CI-discoverable module passes ten new cases in normal and optimized modes. The initial nine-case body also passed through the actual isolated run_modules entry (8.499 s).
  • Real child/grandchild readiness and native kqueue exit observations cover success with a queued module, failed unittest, zero exit without completion, joined work, exact 200 KB stdout / 100 KB binary stderr, live-leader timeout, SIGINT cancellation and omitted group cleanup. Two deterministic clock controls check deadline precedence, including a valid completion receipt with the exit poll itself crossing the deadline. The previous ordering reports code 0 in this controlled case; the follow-up correctly returns 124 by observing exit before reading the deadline clock. Linux uses retained pidfds but is unrun locally.
  • Complete existing registered compatibility hooks isolated-test-bytecode and isolated-descendant-bytecode pass (6.313 s / 22.600 s), preserving their original source/cache differentials and controls.
  • git diff --check passes; only the four scoped files change. Author and committer are JoyboyBrian.

Hosted CI for exact public head 8d00967e3942cfd85e19f30e72ea9f5e68bc8f7b has completed with three successful checks and one inherited metadata failure. The Ubuntu plan/onboarding job actually ran all ten new test_research_isolated_test_posix_pipes cases and each passed, including Linux pidfd observation, timeout/cancellation, output preservation and both deadline controls (Ubuntu 24.04.5 / CPython 3.12.15; overall 356 tests, OK (skipped=11), 132.207 s). Both selected bytecode compatibility package jobs also passed.

The sole failing isolated-runner-successor job stops before replay at working source drift: certificates/selected-result.json. This exact failure was independently reproduced with python3.12 -B scripts/research_package.py --package research/isolated-runner-successor --check-only using the exact canonical base 624de9dc66858af0945e5f8a0942488d62280d43 checker, metadata and input files, with an isolated Git HEAD at that base. The unchanged package pin is bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129; both base and PR head have selected-result SHA-256 6fe0a099b89aa2aed796a13c3a21dafc63f3388ebf397464e44e0451893b9375. The package directory and selected-result file are unchanged by this PR. Its runner pin ef5035e6… also already differs from base c2ba0ce2…. This historical admission obligation remains open; no frozen pin or acceptance list was refreshed, and CI is not fully green. No full repository, historical or mathematical suite was rerun.

Exact reproduction commands, base hashes, policy scope and open questions are in docs/research/isolated-test-posix-pipes.md. Base is canonical 624de9dc66858af0945e5f8a0942488d62280d43, priority revision 7. Canonical investigation and scope update.

Credit Nick Petalas (#2906 at 52b7b3f6cd3f12e34c2451c291a85fe9d1eff996), Mihir Srivastava (#4683 at 02d43658b948db1922a23369b1fa2ba9bc4f8f58), ywz65, Paul Romeo, Aaron Wang/navinor, Douglas Colkitt and retained contributors. Both nearest predecessor PRs were live-verified merged. Prepared by JoyboyBrian with substantial OpenAI Codex assistance; no independent human review. Apache-2.0. This is verifier lifecycle tooling, not a new kappa or scientific admission.

Final scoped overlap checkpoint: 299 open PRs at 2026-10-22 19:49:09 UTC, 3,721 Discussion records at 19:49:58 UTC, and all 6,319 in-scope local notes. Queries for run_isolated_tests.py, inherited capture, pipe EOF, POSIX isolated and captured pipe returned the own claim, coordinator pointer and credited predecessor scopes; no additional same-boundary repair was found in this coverage. Remote pagination and local inventory were complete; offline-staleness caveats remain. Root refreshed canonical main at this submission checkpoint and reported it unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants