Skip to content

openRepoShape --doctor: a TERM or HUP sent to the command alone removes its clone of the standard while shape-doctor.py is still running from it, so the doctor finishes over a deleted standard, and no test holds what an interrupted run leaves #680

Closed

Description

@brettheap

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.

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;
      • wait returns >128 on a trapped signal and must be repeated to collect the child's status.
  • Update the comment at :668-673. No README, AGENTS.md or --help text states this behaviour, so nothing else changes, docs/cli.md included.

  • Keep Git Bash green. run_doctor also runs under Git Bash in CI: tests-git-bash (.github/workflows/tests.yml:227) runs tests/test_openreposhape_command.py, whose test_the_doctor_checks_its_clone_out_at_the_ref_in_force reaches 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.py writes 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 origin through run_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

  1. added this to the v1.1.0 milestone on Oct 16, 2026
  2. brettheap commented on Oct 16, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-10-16T13:04:26Z, for #680

    Logged in lanes/log/openRepoShape-3.md at acdb015aac74354acbda0bcd4add9191783fec90.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#680:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#680"`, kept where the row or its body names `#680`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `680` as a whole token:
       none
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions