Visitar URL original
Bound the Review Wait by Its Timeout, End It by SIGTERM With One Line, and Read the Origin Owner Through origin_slug by ptr727 · Pull Request #4168 · ptr727/ProjectTemplate · GitHub
Skip to content

Bound the Review Wait by Its Timeout, End It by SIGTERM With One Line, and Read the Origin Owner Through origin_slug - #4168

Merged
ptr727 merged 3 commits into
developfrom
burndown/wait-bound-interrupt
Nov 13, 2026
Merged

ptr727 merged 3 commits into
developfrom
burndown/wait-bound-interrupt

Conversation

@ptr727

@ptr727 ptr727 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Unfiled defect this run found. pr_review.py wait could run past --timeout and then end with nothing printed.
    • backoff() checked the bound only before each sleep, and the schedule's last delay is 120 seconds. So a wait could overrun its bound by up to that delay plus the reads after it.
    • An outer bound set at or below --timeout then killed it with SIGTERM. The script had no SIGTERM handler, so nothing printed.
    • The fix cuts each clock-bounded sleep to the time left, so no poll sleeps past --timeout. The reads that follow the bound still run, and then the digest and status line print.
    • The entry point now follows CODESTYLE.md "Interrupts in Python":
      • A SIGTERM handler raises KeyboardInterrupt carrying the signal number.
      • The entry point prints pr_review.py: interrupted by <SIGNAL>., flushes, restores the default handler, and re-raises the signal. On Windows it exits 130 instead.
      • SIGINT takes the same path.
    • The combined SIGINT/SIGTERM handler is not adopted, because that is the open decision Decide Whether the Python Interrupt Rule Routes SIGINT Through the SIGTERM Handler and Passes Over a Later Signal #4146.
  • Move pr_review.origin_owner Onto gh_graphql.origin_slug #3890. origin_owner() now gets the owner from gh_graphql.origin_slug() instead of keeping its own copy of the origin-URL regex.
  • Line ceiling. pr_review.py stays under its 2200-line ceiling. Three call sites are reshaped onto fewer lines to make room, and their behavior does not change.
  • pr_merge.py and pr_cleanup.py. Both call backoff() with a finite schedule and no clock, which this change does not affect. Their suites pass unchanged.

Tests

  • test_the_backoff_sleeps_the_schedule_until_the_timeout now expects the seventh sleep to be cut to the 110 seconds left.

  • test_wait_sleeps_no_further_than_its_timeout_and_then_prints_the_digest runs wait --timeout 100 on a fake clock. It asserts that the sleeps stop at 100 seconds rather than 110, and that the digest and status=PENDING print.

  • TestWaitInterrupt runs the script with its interpreter directly, from a copy of the scripts tree whose origin names a constructed owner. A stand-in gh on PATH holds the first read open. The case then sends SIGTERM and asserts three things:

    • The process died by SIGTERM.
    • It printed exactly the one interrupt line.
    • Nothing in its process group survived.

    It uses the process-group helpers in tests/test_pre_commit_hook.py, and it is skipped on Windows.

  • Each new or changed case fails against develop's pr_review.py and passes here. The full suite passes locally: 4162 tests, 11 skipped.

Open findings, local pass edit budget spent

  • introduced, design: scripts/pr_review.py gets to 2198 lines, under its 2200-line ceiling, by reshaping three multi-line calls onto fewer lines rather than by splitting the file along a boundary. The three are origin_owner, _gh_run, and the poll in run_wait. One line of headroom is left.
    • Outcome: declined, with this evidence.
      • The reshaped calls behave the same, and the ceiling is not raised.
      • Splitting the file along a boundary means adding a module. Every new module needs an entry in scripts/README.md, and a peer pull request holds that file this round.
      • So the next change that needs room in pr_review.py does the split, as tests/test_pr_review_size.py asks. The burndown run has been told about it.

Declined findings

Closes on promotion: #3890

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 13, 2026 10:09
… Line

`pr_review.py wait` checked `--timeout` only before each sleep, so its
120-second steps could carry it past the bound, where an outer bound
killed it with nothing printed. Each clock-bounded sleep is now cut to
the time left, and the entry point turns SIGTERM into one line naming
the signal before ending by it.

`origin_owner()` now reads the owner through `gh_graphql.origin_slug()`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The usage text claimed the digest prints at the bound, where only the
poll's sleeps stop there and the reads after it still run. The signal
test now uses the helpers `test_backlog_metrics.py` already imports,
which check the whole process group, and the interrupt line ends with a
period as `backlog_metrics.py`'s does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The usage text promised a death by the signal, which Windows does not
give, since the entry point exits 130 there instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings November 13, 2026 18:54
@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head ec7834b084c65e503ff23550a15a48a7ad44b176, the content this pull request carries at that commit against develop, and it recorded 1 finding.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between da917cd and ec7834b.

Files selected for processing: 2

  • scripts/pr_review.py
  • tests/test_pr_review.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical active finding remains in scripts/pr_review.py: SIGTERM handling can leave the spawned gh child running, causing process leaks and failing the process-group assertion.

1 open issue
What changed in this PR

This pull request bounds pr_review.py polling by --timeout, adds signal-aware interruption reporting, and reuses shared origin parsing.

Changes:

  • Clips clock-bounded backoff sleeps to the remaining timeout while preserving final output.
  • Handles SIGTERM and SIGINT through the interruption path with signal reporting and re-raising.
  • Routes origin_owner() through gh_graphql.origin_slug().
  • Adds timeout and interruption regression coverage.
  • The interrupted subprocess path still requires cleanup of active gh child processes before re-raising.
File Description
tests/​test_pr_review.py Adds regression tests for timeout-bounded polling and interrupted waits, including process-group cleanup assertions.
scripts/​pr_review.py Updates polling bounds, origin-owner parsing, and signal interruption handling.

Review effort: Lite

Comment thread scripts/pr_review.py Resolved
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 48.27586% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.69%. Comparing base (b38e084) to head (ec7834b).
⚠️ Report is 196 commits behind head on develop.

Files with missing lines Patch % Lines
scripts/pr_review.py 48.27% 15 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4168      +/-   ##
===========================================
- Coverage    81.60%   76.69%   -4.92%     
===========================================
  Files           26       41      +15     
  Lines         9070    14300    +5230     
===========================================
+ Hits          7402    10967    +3565     
- Misses        1668     3333    +1665     
Flag Coverage Δ
python-3.13 76.69% <48.27%> (-4.92%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit 8dbea41 into develop Nov 13, 2026
14 checks passed
@ptr727
ptr727 deleted the burndown/wait-bound-interrupt branch November 13, 2026 19:12
ptr727 added a commit that referenced this pull request Nov 13, 2026
… Rules (#4189)

## Summary

Promotes the backlog-burndown rounds and changes from other hub sessions
from `develop` to `main`.

- Hooks and the prose gate: #4132, #4134, #4136, #4145, #4152, #4184.
The Husky hook reads its path list once and diffs a merge against
`MERGE_HEAD`. Interrupts re-raise their signal, a Markdown code span
reads as quoted data, and the gate picks a commit's diff base and
recognizes a conflicted promotion's branch cut from `main`.
- Procedures and carried rules: #4133, #4139, #4141, #4149, #4166,
#4177, #4179, #4183, #4185. Resync, audit and check-this-repo procedure
gaps, code style and shell interrupt rules, review-loop gaps across four
skills, the context and delegation section of `AGENTS.md`, question
rules in governance, the promotion line in pull request bodies,
closing-keyword behavior on promotion, and the history-rewrite premise.
- Review and cleanup tooling: #4138, #4148, #4154, #4156, #4157, #4163,
#4164, #4168, #4174, #4180. Cleanliness reads, parked handoffs, the
backlog report's JSON output, exact inline script pins, trusted inputs,
env-file includes, the bounded review wait, side-reviewer matching, and
a Copilot billing-failure notice read as a refusal.
- Workflow and runbook contract: #4153, #4155, #4169, #4171, #4178,
#4182. The runtime-secrets check, a registry entry and spec references,
the Copilot runbook pointers, credential-free checkout steps, and the
deploy-key and runner wording.
- From other hub sessions: #4159 (a repository's own .NET line under a
fleet default), #4161 (the 1Password CLI as an optional host tool),
#4162 (Codex's Windows installer and one managed opencode copy). These
carry no promotion line.

#4182 carries no promotion line by design, and #4175 holds the split-out
part of #4057's scope. Both #1448 and #4175 stay open.

Fixes #1071
Fixes #1154
Fixes #1391
Fixes #1471
Fixes #1594
Fixes #1620
Fixes #1627
Fixes #1650
Fixes #1801
Fixes #2853
Fixes #3620
Fixes #3668
Fixes #3697
Fixes #3766
Fixes #3787
Fixes #3837
Fixes #3840
Fixes #3842
Fixes #3844
Fixes #3865
Fixes #3882
Fixes #3890
Fixes #3894
Fixes #3912
Fixes #3916
Fixes #3954
Fixes #4014
Fixes #4015
Fixes #4016
Fixes #4043
Fixes #4050
Fixes #4057
Fixes #4058
Fixes #4062
Fixes #4084
Fixes #4097
Fixes #4098
Fixes #4099
Fixes #4104
Fixes #4108
Fixes #4114
Fixes #4115
Fixes #4117
Fixes #4118
Fixes #4119
Fixes #4121
Fixes #4122
Fixes #4123
Fixes #4131
Fixes #4135
Fixes #4140
Fixes #4142
Fixes #4143
Fixes #4144
Fixes #4151

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants