Repository navigation
State how a test's held process ends, and refuse SIGKILL in the suite - #1798
Merged
Merged
Conversation
PR #1104 held `under_codex`'s fake Codex task with a shell loop polling every 10 ms for a release file only the test body wrote. A test that failed first, or a worker that died, left the loop running for good; on 2026-10-04, 154–170 of them ran at once on one Mac at load 200–440. "A process the suite starts ends with the run" said only which fixture owns each resource, and the change took its process from `spawn`. Two reviewers then read that ownership as a guarantee, and one approved the merge. The section now states the property itself: a process ends on every way out of its test, including a worker that dies before teardown, because many runs share one machine. A held process blocks on a pipe the worker holds, as `session_process` does, never on a file the test has yet to write, and a test ends a process with SIGTERM or by closing that pipe, not SIGKILL. It names the check that catches a violation: fail the test right after the start and look for survivors. In an A/B on Codex reviewing #1104 in a checkout at its base, the rule didn't change how often a review caught the leak (4/6 each), but every review that caught it with the rule asked for a pipe hold (4/4), and none without it did (0/4; they asked for a `finally` release that keeps the poll). On Opus, writing a crash-holder test went from SIGKILL in 3/3 runs to SIGTERM in 3/3, and a session stand-in from blocking on a signal in 2/3 to a pipe in 3/3. A review of a correct pipe-held test drew no false findings in either arm. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
#1774 took the suite's last three `.kill()` calls out. Nothing stopped the next one, and nothing at runtime can see which signal a test sent, so `test_no_test_ends_a_process_with_sigkill` reads `tests/*.py` for `Popen.kill()`, `signal.SIGKILL`, and a shell `kill -9` or `kill -KILL`. It passes on the current tree and names the line for each of the three forms planted in a scratch test. The process-lifetime section of tests/AGENTS.md cites it beside the rule. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Oct 5, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The worker-death guarantee in tests/AGENTS.md is broader than the fixture it recommends. spawn calls _retire only after its yield, during fixture teardown. If a worker exits before teardown, a child such as the sleep 600 process used by test_a_spawned_process_ends_with_what_it_started has no worker-held pipe or other exit link and can keep running. Because the new guidance tells authors to use spawn for child processes, it preserves the cleanup assumption this PR aims to correct. Please either make spawned children end on worker death or scope the guarantee to processes that have a worker-held exit mechanism, and say which kind future tests need.
…gnal 9 Review on #1798 found two gaps: - The guidance said a test's process ends when its worker dies, but `spawn` ends children only at teardown, which a dead worker never runs. The section now says what covers each case: teardown ends a child and its group on a pass, failure or interrupt, and a process that would otherwise run on after a worker dies carries its own link to the worker, the session claim for a page server and the worker's pipe for a held process. - The SIGKILL guard passed `os.kill(pid, 9)`, `os.killpg(group, 9)` and `send_signal(9)`. It now flags signal 9 passed to any of them, and still passes a liveness probe such as `os.kill(pid, 0)`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1774 removed the polling loop that held
under_codex's fake Codex task, and every SIGKILL intests/. This change tells the next author the rule that loop broke, and adds a test so the suite rejects SIGKILL again.The loop came from a
tend-ci-fixrun that opened #1104. The section "A process the suite starts ends with the run" intests/AGENTS.mdonly said which fixture owns each resource. The change did take its process fromspawn, and two reviews read that as proof of cleanup: "the fixture closes surviving processes on failure".spawnonly ended the runner, though, so its shell survived.tests/AGENTS.mdnow states the property itself, as checks you can run:spawn's teardown ends a child and its group on a pass, failure or interrupt. A worker that dies runs no teardown, so a process that would otherwise run on carries its own link to the worker: the session claim for a page server, the worker's pipe for a held process.session_processdoes. It never polls for a file the test body has yet to write.pgrep -fl <tmp_path>. On the pre-End held test processes with their test, and shorten Claude Code title requests #1774 tree that finds the leaked shell; on End held test processes with their test, and shorten Claude Code title requests #1774 it finds nothing.test_no_test_ends_a_process_with_sigkillreadstests/*.pyand fails onPopen.kill(),signal.SIGKILL, signal 9 passed tokill,killpgorsend_signal, or a shellkill -9/kill -KILL. Each form planted in a scratch test made it fail, naming the line, andos.kill(pid, 0)still passes.I scored the guidance with and without the new text:
finallythat keeps the poll)The guidance doesn't make a reviewer notice the leak more often. What stops it now is #1774's change to
spawn; the guidance shapes how the fix is written.