Repository navigation
Description
Goal: openRepoShape --doctor never removes its clone of the standard while the doctor is still running from it, and a test holds what an interrupted run leaves.
Filed by lane openRepoShape-3 on Brett Heap's word of 2026-10-16T12:24:41Z ("give #460 to lane 3").
What happens. This is the bash launcher openRepoShape at the repository root. The package's openRepoShape (src/openreposhape/cli.py) keeps one clone per commit in a cache and never removes it, so it does not have this.
-
Installed, with no checkout beside it,
--doctorclones the standard into$TMPDIR/openRepoShape-doctor.XXXXXXXXand armstrap 'rm -rf -- "$WORKDIR"' EXIT. It runsshape-doctor.pyas a foreground child and disarms the trap only after the child returns, keeping the clone for the NEXT lines (openRepoShape --doctor, the form AGENTS.md names first and the one--installgives a person, prints every NEXT command as a path into its temporary clone of the standard, which its EXIT trap deletes before the person can paste the command, so each one fails withcan't open file; and it refuses--jsonand--placement-plan, which AGENTS.md's doctor steps 7 and 4 use #500). -
A TERM or HUP sent to the command's own shell alone (
kill <pid>of the launcher) ends bash at once. bash runs the EXIT trap, and the clone is removed while the doctor is still running from it. The doctor was not signalled, so it goes on over a standard that is gone, and the "kept at" line is never printed. -
Measured at d4a7fab with the installed launcher (one file, nothing beside it), over a stub standard whose
shape-doctor.pyblocks for 10 s. Signals were sent by recorded PID:signal sent to clone 0.6 s later child 0.6 s later bash exit the child at its end TERM bash alone gone running -15 its own file gone HUP bash alone gone running -1 its own file gone INT bash and child gone ended -2 killed TERM bash and child gone ended -15 killed HUP bash and child gone ended -1 killed The last three rows are the stated behaviour: "a run interrupted mid-way … printed no report; both leave nothing behind" (
openRepoShape:668-673). The first two are the defect, and it predates openRepoShape --doctor: the installed form keeps the clone of the standard it ran from and names it on the report's last line, so a NEXT line pasted after the command has exited runs instead of dying withcan't open file, and it hands--jsonand--placement-plan <file>on toshape-doctor.pyinstead of refusing them (#500) #510. -
No test pins the interrupted rows. Lane 4's verification of openRepoShape --doctor: the installed form keeps the clone of the standard it ran from and names it on the report's last line, so a NEXT line pasted after the command has exited runs instead of dying with
can't open file, and it hands--jsonand--placement-plan <file>on toshape-doctor.pyinstead of refusing them (#500) #510 found that a mutant skipping the cleanup passed every test. Neithertests/test_shape_doctor.pynortests/test_openreposhape_command.pysends a signal. -
The NEXT-lines test covers a drifted project only.
test_the_installed_doctors_next_lines_run_after_it_has_exited(tests/test_shape_doctor.py:2658-2705) is the only test that runs NEXT lines after the command exits. Since shape-doctor.py, NOT A SHAPE ROOT on a git repository: print both ways in, as AGENTS.md says, and add--orgto the adopt line when there is noorigin#545, a plain git repository gets three NEXT lines naming files in the kept clone:adopt-project.py plan --source … --project …;setup.sh --org <your-org> --project …;- the
machinerow'ssetup-project.py --preflight.
No test runs them from the installed form.
Where it is (d4a7fab, unchanged at 879d804):
openRepoShape:189-203:workdir, with the trap at :201.openRepoShape:625-711:run_doctor. The child is at :655-659, the disarm at :701-702 and the comment at :668-673.tests/test_shape_doctor.py:2583-2607(installed,run_installed) and :2658-2705.
The change:
-
The shell outlives the doctor child. Trap TERM, HUP and INT around the child so that the EXIT trap never runs while the child is alive. Then act on how the child ended:
- a doctor that ran to its end keeps and names the clone, as now;
- a doctor ended by the signal leaves nothing, as now.
Exit 128 + the signal number.
-
Two ways to do it. The writer chooses one and says why.
- (a) Keep the child in the foreground, and have the trap only record the signal. bash defers a trapped signal until a foreground child exits, so a TERM to the shell alone lets the unsignalled doctor finish, and its report and clone stand.
- (b) Run the child in the background with
wait, forwarding the signal. This stops promptly, but it has costs:- a non-interactive bash gives a background child stdin from /dev/null, so it needs an explicit
<&0; - it starts the child with SIGINT and SIGQUIT ignored, so Python raises no KeyboardInterrupt and the trap must forward TERM, not INT;
waitreturns >128 on a trapped signal and must be repeated to collect the child's status.
- a non-interactive bash gives a background child stdin from /dev/null, so it needs an explicit
-
Update the comment at :668-673. No README, AGENTS.md or
--helptext states this behaviour, so nothing else changes,docs/cli.mdincluded. -
Keep Git Bash green.
run_doctoralso runs under Git Bash in CI:tests-git-bash(.github/workflows/tests.yml:227) runstests/test_openreposhape_command.py, whosetest_the_doctor_checks_its_clone_out_at_the_ref_in_forcereaches it with a stub doctor. It must stay green.
Tests. POSIX only, under WINDOWS_SKIP like the installed-doctor tests.
- Interrupted runs. Use a stub standard whose
shape-doctor.pywrites a marker and blocks. Start the installed command in its own session, wait for the marker, and signal by recorded PID:- INT, TERM and HUP to the shell and the child: the clone is gone, there is no "kept at" line, and the exit is 128 + the signal. This kills the mutant that skips the cleanup.
- TERM and HUP to the shell alone: the clone exists for as long as the child runs, and the end state is the one the chosen design states.
- A plain repository's NEXT lines. Beside the drifted test, run a plain git repository with an
originthroughrun_installed, and check that:- every path a NEXT names under the kept clone exists after the command exits;
- each line that needs no placeholder, pasted, does not die with
can't open file; - the
setup.sh … <your-org>line is checked for its path only.
From #460, #460 (comment) (L6, L7, L8)
🤖 Generated with Claude Code
Activity
brettheap commentedon Oct 16, 2026
CLAIMED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-10-16T13:04:26Z, for #680
Logged in
lanes/log/openRepoShape-3.mdatacdb015aac74354acbda0bcd4add9191783fec90.The three reads (lane-collision-protocol Rule 1):