Skip to content

Tracker: CODESTYLE.md > Python #4100

Closed

Description

@ptr727

Per-unit tracker for findings raised against this canonical unit by a carrying repository's review, per pr-review-conduct Merge Gate item 3.

Findings

  • Bound the wait after terminate() on a Popen child, with a kill() fallback. Raised by CodeRabbit on Resync the Instruction Set and Carried Skills With the Hub NxWitness#685, against the carried CODESTYLE.md "Interrupts in Python" at line 132, carried at the hub's main 2d0f8901. In the reviewer's words: "The rule waits without a bound after terminate(). A child that ignores SIGTERM can keep the script from printing its interrupt line or exiting with 143/130." It proposes wait(timeout=...), then kill() and a second wait on subprocess.TimeoutExpired. It notes that "Interrupts in Shell" has the same unbounded wait, which Bash cannot time out directly.

    • Not judged here. The carrier declined it under outcome 2, since the text is the hub's to change.
  • Install a SIGINT handler explicitly rather than relying on Python's default. Raised by CodeRabbit on Resync the Instruction Set and Skills Tree With the Hub PlexCleaner#1259, against the carried CODESTYLE.md "Interrupts in Python" first bullet, carried at the hub's main 009d3e5e. Python raises KeyboardInterrupt on SIGINT only where the parent did not start it with SIGINT ignored. A non-interactive shell starts a background command that way, so a script following the rule ignores SIGINT and skips its cleanup and its exit 130. It proposes that the entry point install handlers for both signals with signal.signal, each recording the signal and raising KeyboardInterrupt.

    • Not judged here. The carrier declined it under outcome 2, since the text is the hub's to change.
  • The bounded-wait finding above was raised again by CodeRabbit on Resync the Instruction Set and Skills Tree With the Hub PlexCleaner#1259, against the same bullet carried at 009d3e5e, again naming the Shell wait as well.

  • State the __enter__ window in the cleanup bullet. Raised by CodeRabbit on Promote Develop: Hub Resync to 009d3e5e and the .NET SDK Line PlexCleaner#1261, against the carried CODESTYLE.md "Interrupts in Python" bullet "What the script holds is released by with blocks and finally clauses as the exception unwinds", carried at 009d3e5e. A KeyboardInterrupt raised inside __enter__, after a resource is acquired and before the method returns, skips __exit__, so a lock or temporary path can stay held. It proposes limiting the claim to after __enter__ returns and naming the window as uncovered.

    • Not judged here. The carrier declined it under outcome 2, since the text is the hub's to change.

🤖 Generated with Claude Code

Activity

  1. ptr727 commented on Nov 20, 2026

    @ptr727
    OwnerAuthor

    Decision triage, 2026-11-19. Which of the three CodeRabbit findings against CODESTYLE.md "Interrupts in Python" should become rule text: bound the wait after terminate(), install a SIGINT handler even where SIGINT was inherited as ignored, and state the __enter__ window?

    Each finding was raised by a carrying repository and declined there under outcome 2, since the text is the hub's. None is judged yet. They are three separate sub-decisions, answered together here so they agree with each other and with the two Shell findings on #4218. The proposed test for all five: a gap a script closes cheaply becomes rule text, a gap no script can close is stated in one sentence where it changes what the sender of a signal does, and anything else is declined under GOVERNANCE.md "Trust Boundaries and Hardening Effort".

    Finding 1: bound the wait after terminate(), with a kill() fallback

    1. Accept for Python, leave Shell unchanged (recommended). The cleanup bullet becomes terminate(), then wait(timeout=...), such as 10 seconds, then kill() and wait() on subprocess.TimeoutExpired. It is the documented subprocess idiom and costs three lines. Once Decide Whether the Python Interrupt Rule Routes SIGINT Through the SIGTERM Handler and Passes Over a Later Signal #4146 lands, a second Ctrl-C is passed over by the script, so a child that ignores SIGTERM can be escaped only by a SIGKILL to the script, which skips every finally and leaves locks and temporary paths behind. The Shell wait stays unbounded, since Bash has no timed wait and a watchdog is another child to stop.
    2. Accept for both languages. Shell gains a watchdog that sends SIGKILL after a bound. That adds a background process to every trap, and the trap itself grows harder to get right.
    3. Decline for both. A child that ignores SIGTERM is rare in the fleet's scripts, and the hang is visible. This keeps the rule shorter but leaves the SIGKILL escape above as the only way out.

    Finding 2: install a SIGINT handler even where SIGINT was inherited as ignored

    1. Decline, and have Decide Whether the Python Interrupt Rule Routes SIGINT Through the SIGTERM Handler and Passes Over a Later Signal #4146's rule text say that an inherited ignored SIGINT stays ignored (recommended). A non-interactive shell starts a background child with SIGINT ignored on purpose, and "Interrupts in Shell" already stops such a child with SIGTERM for that reason. The hub's own scripts written since Let the Prose Gate Choose a Commit's Diff Base, Pair Code Spans as Markdown Does, and Re-Raise Hook Interrupts #4145 keep that choice. Each installs its SIGINT handler only where signal.getsignal(signal.SIGINT) is still default_int_handler. Bash cannot override an inherited ignore at all, so this keeps both languages on one behaviour: a stop meant to reach such a script sends SIGTERM. Tracker: CODESTYLE.md > Shell #4218 finding 1 recommends stating that once, in the general "Interrupts" section.
    2. Accept: install the SIGINT handler unconditionally. This overrules the parent's choice. It also contradicts the code the Decide Whether the Python Interrupt Rule Routes SIGINT Through the SIGTERM Handler and Passes Over a Later Signal #4146 decision was written from, which would then need changing in every script that already follows it.

    Finding 3: state the __enter__ window

    1. Decline under "Trust Boundaries and Hardening Effort" (recommended). The window lies between an acquisition inside __enter__ and its return. Every with statement in CPython has it, and no rule a script can follow closes it short of masking signals around each acquisition. The chance of a Ctrl-C landing inside it is very small, and stating it would change nothing a script author does.
    2. Accept: limit the bullet's claim to after __enter__ returns, and name the window as uncovered. This is accurate and costs one sentence, but it adds a caveat to a bullet that prescribes a mechanism rather than promising an outcome.

    Evidence:

    Effect on work in flight: No open pull request touches the section. The #4146 change edits the same two bullets, so findings 1 and 2 belong in that one pull request, which also regenerates .agents/skills/python-codestyle/SKILL.md through scripts/build_dist.py. Accepting finding 1 makes hub_fetch_run.py and secrets_sync.py follow-up work when each is next edited, per "A script takes this rule when it is created or next edited". Accepting finding 2 instead would make every script listed above follow-up work.

  2. added
    decision
    on Nov 20, 2026
  3. ptr727 commented on Nov 20, 2026

    @ptr727
    OwnerAuthor

    Maintainer's answer, 2026-11-19 (decision triage): option 1 on each finding. Finding 1 accepted for Python only: terminate(), then wait(timeout=...), then kill() and wait() on TimeoutExpired. The Shell wait stays unbounded. Finding 2 declined, and the rule text states that a SIGINT inherited as ignored stays ignored. Finding 3 declined under "Trust Boundaries and Hardening Effort". This is now work, and it belongs in the same pull request as #4146 and #4218, which edit the same bullets.

  4. removed
    decision
    on Nov 20, 2026
  5. ptr727 commented on Nov 20, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim (2026-11-19 attended run, round 1, group 2): branch burndown/interrupt-signal-rules.

    Issues: #4146, #4100, #4218.

    Predicted file set:

    • CODESTYLE.md
    • host-setup/agent-safety/global_rules.py
    • tests/test_global_rules.py
    • scripts/docker_lint.py
    • tests/test_docker_lint.py

    Generated from those: the include regions in .agents/skills/python-codestyle/SKILL.md and .agents/skills/shell-codestyle/SKILL.md, and their .github/skills and .claude-plugin copies and source digests.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions