Repository navigation
Make the shell suite's wrapper stop the suite's process group on a timeout, interrupt, TERM or hangup, pin the launcher precedence of lane <name> with launchers the suite names, and say what the pty driver comment counts - #217
Merged
Merged
Conversation
…darwin and one on Linux whose two jobs both went red, not seven Copilot read "five on darwin, then both Linux jobs of #61's `ready` run" as seven runs. #107 names six: five `tests-macos` runs and one Linux run, 37124906535, in which both the `tests` and `tests-no-submodule` jobs failed. The count was right and the wording was ambiguous; this changes a comment only. Closes #147 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… names itself, so no host's lclaude can be picked #143's eight false reds were already gone: c1bac0d exports PCLAUDE before the `lane` cases, which pins the launcher seam to the suite's fake. What was never added is a case for the rule that applies when the seam is unset, which is `lclaude`, else `pclaude`. Three cases now, each on a PATH of its own: * both launchers present, the pclaude directory FIRST, so the rule is shown to prefer a name and not a position: lclaude runs, once; * every directory holding an lclaude taken out of PATH (the a17 section's way of making a word absent, and on a workstation the directory the real one is in): pclaude runs with the same argv; * PCLAUDE set explicitly, with an lclaude on PATH: PCLAUDE wins. Each was checked against a throwaway slice of the suite on a host that has workBenches' /usr/local/bin/lclaude, and each goes red under the matching mutation of `lane`'s launcher() (order swapped, seam ignored, fallback dropped). Closes #143 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…launcher-precedence cases (harness + mutation checked), #142 item 3 test file written; left: apply the start_new_session/killpg fix in tests/test_lane_helpers_suite.py, run the new pytest file red-then-green under the lock, push CI watch, open the PR The new tests/test_lane_helpers_suite_timeout.py is unrun: its first run was queued behind other lanes on the pytest lock and was stopped before it started. The wrapper in tests/test_lane_helpers_suite.py is still the unfixed subprocess.run. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ess group when the wrapper gives up, so a timeout leaves no orphan `sleep` subprocess.run(timeout=) killed the bash it started and nothing under it, and the suite's EXIT trap does not run on a SIGKILL, so the liveness fixture's `sleep` (longer than TIMEOUT_SECONDS on purpose, #83) and every later fixture's were orphaned for up to 70 minutes. The suite now runs under Popen(start_new_session=True), and any exception out of communicate() - the timeout, and a Ctrl-C, which a session of its own no longer receives from the terminal - kills the group with os.killpg before it propagates. tests/test_lane_helpers_suite_timeout.py drives the wrapper's own test function against a stand-in suite that starts a `sleep 600` and hangs: on the old wrapper the timeout and interrupt tests fail with that sleep still running (2 failed, 2 passed); the green-suite and red-suite tests pin that the footer check and the transcript on failure are unchanged. Refs #142 (item 3) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 22 hours and 51 minutes by commenting |
Reviewer's GuideThe PR hardens the shell-suite wrapper against orphaned descendants by killing a dedicated process group, adds regression tests for timeout/interruption and output handling, pins the lane launcher precedence with host-independent shell cases, and corrects the related CI-run comment. File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
… on the timeout, TERM before KILL, and clean up in the tests that watch it Review of the session change found that moving the suite out of tests/run.sh's process group opened a new way to orphan the fixture `sleep`: run.sh's `kill -TERM -- -<pgid>` and a terminal's hangup now reach pytest alone, pytest has no handler for either, and the suite's bash dies on its dead pipe with its TERM trap never run. On main the suite shared the group and its trap cleaned up. The wrapper's call is now run_in_own_group(): for as long as it waits it installs a TERM and a HUP handler, where the disposition is still the default (a nohup'd run keeps ignoring a hangup), which stops the suite's group and then lets the signal take pytest as it would have. The timeout and a Ctrl-C stop the group the same way. stop_group sends TERM first and waits up to ten seconds (run.sh's own grace) for the suite's trap to remove its sandbox, then KILLs what is left. The comment no longer claims the group is everything the suite started: the pty driver's children are session leaders of their own. The new tests signal the runner's own group the way run.sh does (TERM and HUP) and assert no `sleep` survives, that the TERM trap ran, that a TERM-deaf group is killed after the grace, and that an ignored hangup stays ignored. The tests' own cleanup no longer depends on the wrapper working: a fixture kills a leaked `sleep`, and the SIGINT sender is gated on an Event so it cannot fire after the wrapper has returned. Refs #142 (item 3) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…er-precedence cases, and check the exit code of the PCLAUDE case The `lane` launcher is `$PCLAUDE`, else lclaude, else pclaude, else claude-profile, else a refusal with 2. The cases covered the first three; two more now cover the last two, on a PATH where the suite's own pclaude (in fakebin, beside the fake tmux, ps and pgrep) is replaced by links to everything else in that directory, and where every directory holding one of the three words is taken out. The PCLAUDE case also asserts the exit code. Checked in the throwaway slice of the suite, on a host with the real /usr/local/bin/lclaude: dropping the claude-profile fallback, and letting `claude` itself be found, each turn the matching cases red. Refs #143 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The Windows job collected tests/test_lane_helpers_suite_timeout.py and died with `AttributeError: module 'signal' has no attribute 'SIGHUP'`: the parametrize decorator names the signal at import, before the module-wide Windows skip can apply. SIGHUP is now read with getattr, and the module imports with the attribute removed (checked by deleting it from `signal` and importing). Refs #142 (item 3) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… finish inside run.sh's own, and note a TERM or hangup instead of raising from its handler The delta check of the signal handling found two edges and a window. * A SIGINT during the grace left child.wait() with a KeyboardInterrupt before the KILL stage, so a suite that ignores TERM was orphaned: TERM then Ctrl-C, and Ctrl-C twice, both ended the runner with the suite's `sleep` still running. stop_group now ignores SIGINT until it is done, and the KILL is in a `finally` as well. * GROUP_TERM_GRACE equalled the ten seconds tests/run.sh's stop_group gives its own group, which is really about 10.7 (fifty polls of 0.2 s and a `ps` each), so a delay on pytest's side let run.sh KILL pytest mid-stop. It is five now, and the comment says why. * A handler that raised also raised inside Popen(), after the fork and before `child` was bound, leaving the suite with nobody to stop it. The handlers now only note the signal; the wait is made in half-second slices that look for one, a signal that comes as the suite finishes is not swallowed, and the signal is sent again with its default action after the group is stopped. The new test sends a deaf suite's runner a TERM, or a Ctrl-C, and a Ctrl-C inside the grace, and asserts no `sleep` survives. The tests' `ps` check is now a probe that skips the module where `ps -o stat= -p` cannot answer, rather than one that passes by finding nothing. Refs #142 (item 3) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…during the TERM grace lets a slow trap finish The wrapper now waits in half-second slices, and the TimeoutExpired it re-raised was the last slice's, so a 5400 s CI timeout would have read "timed out after 0.4 seconds". It is raised again with the bound that was passed and the output and stderr gathered so far, and a test asserts the bound, the message and the partial transcript. Nothing pinned stop_group's SIGINT ignore: with it removed the KILL in the `finally` still prevents an orphan, but a Ctrl-C in the grace cuts short the cleanup of a suite that does answer TERM, slowly. A stand-in whose TERM trap takes two seconds now has to finish writing its marker through a Ctrl-C. Refs #142 (item 3) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…second trap inside the three-second grace The stand-in's TERM trap took two seconds against a three-second grace, and the marker landed 2.1 to 2.5 s after the TERM, so about a second of scheduler delay would have failed it. The trap now takes one second, which roughly doubles the margin and still leaves the Ctrl-C landing mid-trap, and the comment says where the Ctrl-C lands rather than where the trap is. Refs #142 (item 3) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This was referenced Oct 18, 2026
This was referenced Oct 19, 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.



Three test-suite hygiene fixes, none of them touching a shipped command.
What was wrong
tests/test_lane_helpers_suite.pyran the 45-minute shell suite undersubprocess.run(..., timeout=), which kills only the bash it started. The suite'sEXITtrap does not run on that SIGKILL, so the liveness fixture'ssleep(longer thanTIMEOUT_SECONDSon purpose) and every later fixture's were orphaned for up to 70 minutes. Items 1 and 2 of PR #83 Copilot rounds 12-13, filed under the two-round cap: lane-start launches past a failed set-row-state, request-handoff's self-window fence reads the @id alone, the liveness fixture outlives the wrapper's timeout #142 await rulings and are not touched.tests/test_lane_helpers.shsaid "five on darwin, then both Linux jobs of claim --force takes over a dead lane's hold; lane-end --retire ends a duplicate holder #61'sreadyrun". tests-macos: the pty driver's 60s bound is the same 60s asacquire_lock, so a quietlane_pickchild is SIGKILLed and reported as a wrong exit code #107 names six runs: fivetests-macosand one Linux run (37124906535) whose two jobs both went red.lanecases fail on any workstation with workBenches'lclaudeinstalled: #129's lclaude-first launcher finds the host's, not the sandbox's #143: the launcher rule has no case. The symptom (eightlanecases going red on a workstation with workBenches'/usr/local/bin/lclaude) was already fixed byc1bac0d(Amendment 19: a closed or dormant lane leaves the listing, one sweep retires a repository's dormant rows on a word, and a retired position is never reissued #93), which addedexport PCLAUDE="$SANDBOX/fakebin/pclaude"before thelanecases;git log -S'export PCLAUDE="$SANDBOX/fakebin/pclaude"' -- tests/test_lane_helpers.shnames only that commit. What was never added is a case for the rule that applies when that seam is unset:lclaude, elsepclaude(lane,launcher(), lines 617-619).What changed
tests/test_lane_helpers_suite.pyrun_in_own_group(): the suite runs underPopen(start_new_session=True), and the timeout, a Ctrl-C, and a TERM or hangup to pytest stop its process group (stop_group: TERM, up to 5 s for the suite's own TERM trap to remove its sandbox, then KILL)tests/test_lane_helpers_suite_timeout.pytests/test_lane_helpers.shlclaude,pclaude,claude-profile, no launcher,$PCLAUDE), in thelane <name>section straight after CASE 2tests/test_lane_helpers.shA session of its own is not the group
tests/run.shstops, so a group TERM and a hangup now reach pytest alone, and pytest has no handler for either (the independent review reproduced the orphanedsleepon the first head of this PR).run_in_own_groupinstalls one for as long as it waits, only where the disposition is still the default, so anohup'd run keeps ignoring a hangup. The handler only NOTES the signal and the wait is made in half-second slices that look for it, because a handler that raised would also raise insidePopen(), after the fork and before the child is bound; a signal that arrives as the suite finishes is not swallowed; and after the group is stopped the signal is sent again with its default action restored, so the process ends as it would have.stop_groupignores Ctrl-C until it is done (a Ctrl-C during the grace used to skip the KILL and orphan a suite that ignores TERM) and sends the KILL from afinally. The grace is 5 s, not the 10tests/run.shgives its own group (really about 10.7 s: fifty polls of 0.2 s and apseach), so this stop finishes inside run.sh's and run.sh never KILLs pytest mid-stop. A timeout is raised again with the bound that was passed and the output gathered so far, so a CI log reads "timed out after 5400 seconds" and not the last half-second slice's. The pty driver's children are session leaders of their own and are outside the group; each is bounded by that driver's own silence limit.The
lanecases use fake launchers in directories of their own: with bothlclaudeandpclaudeon PATH and thepclaudedirectory FIRST,lclauderuns (so the rule is shown to prefer a name, not a PATH position); with every directory holding anlclaudetaken out of PATH (the a17 section's own idiom),pclauderuns; with neither,claude-profile; with none of the three,lanerefuses with 2 and runs nothing; and with$PCLAUDEset and anlclaudeon PATH,$PCLAUDEwins. Each asserts the whole logged line, so it also proves exactly one launcher ran.Other writers may add cases to
tests/test_lane_helpers.shin other sections; this PR inserts only at the two ranges above.Tests
tests/test_lane_helpers_suite_timeout.pypoints the wrapper'sSUITEat a stand-in script that starts asleep 600, answers TERM with a trap as the suite does, and hangs. The timeout and the interrupt: thesleepmust be gone (a zombie does not count) and the trap must have run. A stand-in that ignores TERM must be KILLed after the grace. The signal tests runrun_in_own_groupin a process of their own, in a group of its own, astests/run.shruns pytest, and signal that group with TERM and with HUP the waystop_groupdoes: nosleepsurvives, the trap ran, and the runner ends by the signal it was sent. A hangup the run was ignoring stays ignored. A TERM, or a Ctrl-C, followed by a Ctrl-C inside the grace of a suite that ignores TERM must not orphan it. A timeout reports the bound it was given, and the partial transcript comes with it. A Ctrl-C inside the grace lets a suite whose TERM trap takes a second finish writing its marker (a one-second trap in a three-second grace, so a loaded bench has about two seconds of margin). A green stand-in and a red one pin that the footer check and the printed transcript are unchanged. The tests' own cleanup does not depend on the wrapper working: a fixture kills a leakedsleep, the SIGINT sender is gated on an event, and the module is skipped whereps -o stat= -pcannot answer.signalhas noSIGHUP(tests-windowsonce died collecting it, run 38465043600, because a decorator named it; no Windows job remains in CI, ci: run the test suite on Linux only #227, so this was checked by deletingSIGHUPfromsignaland importing).LANES_*andTMUX*unset (trap 16), atd798d70(the branch merged with main ata41adb6):python3 -m pytest tests/test_lane_helpers_suite_timeout.py tests/test_repo_hygiene.py -qgives 201 passed in 25.55 s. The two newest tests (the timeout bound, and the slow-trap test, whose stand-in trap takes one second inside the three-second grace) passed 10 runs in a row. With the SIGINT ignore removed fromstop_groupthe slow-trap test is red (1 failed, 11 passed), and against the previous round's wrapper (06a2cd6) the timeout-bound test is red (1 failed, 11 passed). Earlier rounds, at799dbc6: 162 passed; the Ctrl-C-in-the-grace test red against97a1e16; and against mutants of the wrapper (no handlers installed, 4 failed; a handler installed even over an ignored hangup, 1 failed; no TERM stage before the KILL, 4 failed; no stop of the group when a signal was noted, 4 failed).lanecases were run in a throwaway slice oftests/test_lane_helpers.sh(the suite's header and fakes, the repoA11 fixtures, thelanesection through the new cases; about 30 s) on a host that has the real/usr/local/bin/lclaude: 10 new assertions pass. Each goes red under its matching mutation oflauncher(): order swapped,$PCLAUDEignored,pclaudefallback dropped,claude-profilefallback dropped,claudeitself let in. The full 45-minute shell suite was not run locally; CI's Linuxtestsandtests-no-submodulejobs are its record.97a1e16and run 39094913000 at06a2cd6were green (testsandtests-no-submodule). The run at the current headd798d70is run 39113489411.Closes #143
Closes #147
Refs #142 (item 3)
🤖 Generated with Claude Code
Summary by Sourcery
Prevent shell-suite process leaks and lock down launcher precedence while correcting the related CI-run documentation.
New Features:
lane <name>across environment overrides and fallback launchers.Bug Fixes:
Enhancements:
Tests: