Skip to content

Hold pr_review.py merge for a Hosted Review Not Registered Yet - #4306

Merged
ptr727 merged 4 commits into
developfrom
burndown/merge-hold-hosted-grace
Nov 20, 2026
Merged

ptr727 merged 4 commits into
developfrom
burndown/merge-hold-hosted-grace

Conversation

@ptr727

@ptr727 ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

pr_review.py merge could land a pull request in the gap after a hosted reviewer was asked and before its check registered. Until the check registers the rollup holds nothing of the review, so a head whose other checks have passed reads ready. This adds the registration grace the maintainer chose on #3814 and refined on #3806: option 1, anchored on the head's push, its last check settling, and its newest review ask, with G = 90s.

  • Settle stamp. check_nodes now records when each check settled. For a CheckRun that is completedAt, which the held query now reads. For a StatusContext it is createdAt once the context is no longer pending.
  • The grace. pr_review_hold.hosted_grace anchors on the latest of three things: the head's push (its earliest suite or check), its last non-hosted check settling, and its newest trusted review ask (@coderabbitai review, @coderabbitai full review, or /review from an owner, member, or collaborator). It runs HOSTED_GRACE = 90 seconds from that anchor.
    • A hosted reviewer's own check, Copilot's included, is left out of the settling, so a finished review never restarts the window.
    • The grace ends early once a CodeRabbit or Qodo check that did not conclude SKIPPED and that began at or after the newest ask is on the head. From then on, that check's existing hold decides. A check older than the ask answered an earlier request, so a re-ask still waits for its own check. A SKIPPED check is CodeRabbit's "automatic reviews are disabled" placeholder, which every head here carries about 10s after the push.
  • wait. On an attested head, the held poll judges the grace only after wait sends its after-checks asks. Where it sent one, it reads the pull request again, because the ask moves the anchor. The CHECKS_PENDING line adds (registration grace until: <time>). A wait that returns 0 with no hosted check on the head prints a note. The note says either that the grace released the merge without a hosted check, or, on a head no local pass covers, that the grace still holds and merge refuses until it ends.
  • merge. The fresh read's unmet refuses an open grace as CHECKS_PENDING, on a line of its own that names when the grace ends. This is separate from the "a hosted review of the head is running" line.
  • Layout. pr_review.py was at 2198 of its 2200-line ceiling, pr_review_checks.py at 449 of 450, and pr_review_side.py at 347 of 350. So the grace, its note, and the CHECKS_PENDING line builder (with _unmet_note) live in a new pure reader, scripts/pr_review_hold.py, which has a 200-line ceiling.
    • The pure helpers side_command, side_asks, head_arrived, and hosted_check moved there from pr_review_side.py, which imports them back.
    • The new module is listed among the readers in the import contract test.
    • No ceiling was raised.
  • Accepted trade-off. The grace is judged apart from held_checks_open's stuck-check read. So on an attested head, a BLOCKED merge with a required check stuck reports 30 for at most the grace's 90 seconds before 44. scripts/README.md says so in the wait paragraph and on the 44 exit row.

Measurement

Read-only reads of the 150 most recently updated merged pull requests in this repository (#4038 to #4300):

Verification

  • python -m unittest discover -s tests: see the CI run. Locally, tests/test_pr_*.py (979 tests) and tests/test_backlog*.py pass, the size ceiling test included.
  • New cases in TestRegistrationGrace cover:
    • the anchor's three sources, with an untrusted ask and a hosted conclusion moving nothing;
    • a SKIPPED check versus any other hosted conclusion;
    • a StatusContext's settle stamp;
    • the open and released notes;
    • the CHECKS_PENDING line;
    • merge's separate refusal line.
  • TestCli cases cover the hold and its release on a held head, and the extra read after a sent ask, which happens only when an ask was sent. Three existing wait fixtures now date their head past the grace.
  • ruff format, ruff check, mypy, and the prose gate are clean. The full unittest discover -s tests run passed locally on the first commit (4559 tests).

Local review

There were three recorded local-strict-review passes. The first raised seven findings and the second raised two, and both rounds' fixes are in this branch. The third raised none. The declined findings are these:

  • Grace ignores the review policy (introduced, declined). On Decide: Which Signal Should Hold pr_review.py merge for a Hosted Review Whose Status Has Not Registered Yet #3814 the maintainer chose a grace that reads no reviewer configuration, with its fixed, bounded delay accepted. A policy can also understate a reviewer that is installed, and reading it would then drop the hold.

  • ASK_BODIES repeats pr_review_policy.COMMANDS (introduced, declined). pr_review_policy imports subprocess, which the reader contract test forbids a pure reader to load.

  • stamp() repeats the formatter in secrets_sync.py (introduced, declined). The same reader contract rules that import out.

  • Skill drift (introduced, reported to the backlog-burndown orchestrator, outside this pull request's files). Two skills still describe the old refusal:

    • .agents/skills/pr-review-conduct/SKILL.md "Merge Gate" item 2 names only a running hosted check as a CHECKS_PENDING refusal.
    • .agents/skills/drive-pr/SKILL.md step 4 next=redrive says a CHECKS_PENDING refusal clears by gh pr checks --watch, which returns at once for a grace refusal.

    The refusal line itself now names the time to run merge again.

Closes on promotion: #3806

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 19, 2026 17:25
A CodeRabbit or Qodo reviewer asked by comment registers its check only
after the ask, so a head whose other checks have passed read ready to
merge in that window. wait and merge now hold for a 90-second
registration grace from the latest of the head's push, its last
non-hosted check settling, and its newest trusted review ask. The grace
ends early once a CodeRabbit or Qodo check that did not skip is on the
head, and a wait returning 0 reports a grace that released with none.

The grace and the CHECKS_PENDING line live in a new reader,
pr_review_hold.py, with the pure ask and arrival helpers moved there
from pr_review_side.py, so every review module stays under its ceiling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A review finished before a re-ask answers the earlier request, so it no
longer ends the grace while the re-asked check is still to register. The
merge refusal names when to run merge again, and the README states the
grace and its modules exactly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An older hosted check can stand on the head while the grace waits for the
one answering a re-ask, so the open-grace note and the merge refusal now
say no check answering the newest push or ask has registered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 20, 2026 01:34
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@ptr727

ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 65ce51dd947cb385f2f41e8745247dbaba01bcd2, the content this pull request carries at that commit against develop, and it recorded 0 findings.

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

An active critical issue can let the merge proceed before the trusted ask’s 90-second grace window expires, and a secondary message inaccurately describes the SKIPPED hosted-check state.

2 open issues
What changed in this PR

This pull request prevents pr_review.py merge from landing a pull request before a requested hosted review check registers by adding a bounded 90-second registration grace.

Changes:

  • Records settlement timestamps for CheckRuns and StatusContexts.
  • Anchors hosted-review grace to the latest push, check settlement, or trusted review request.
  • Integrates grace handling into wait and merge decisions.
  • Extracts shared hold helpers, updates documentation and size contracts, and expands test coverage.
File Description
tests/​test_pr_review.py Adds coverage for registration-grace anchors, hosted-check handling, polling, output, and merge refusal.
tests/​test_pr_review_size.py Adds size-ceiling coverage for the new hold reader module.
scripts/​README.md Documents registration-grace behavior, wait handling, and related exit-code implications.
scripts/​pr_review.py Integrates settlement timestamps and hosted-review grace evaluation into polling and final wait decisions.
scripts/​pr_review_side.py Reuses the centralized review-hold helpers and reports whether a review request was sent.
scripts/​pr_review_hold.py Implements hosted-review grace calculation, hosted-check detection, review-request parsing, and pending-status rendering.
scripts/​pr_review_checks.py Normalizes settlement timestamps for CheckRuns and StatusContexts.
scripts/​pr_review_answers.py Refuses merges while the hosted-review registration grace remains open.

Review effort: Lite

Comment thread scripts/pr_review_hold.py Resolved
Comment thread scripts/pr_review_hold.py Resolved
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.05%. Comparing base (c6b9568) to head (ee41a61).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4306      +/-   ##
===========================================
+ Coverage    79.03%   79.05%   +0.02%     
===========================================
  Files           42       43       +1     
  Lines        15631    15733     +102     
===========================================
+ Hits         12354    12438      +84     
- Misses        3277     3295      +18     
Flag Coverage Δ
python-3.13 79.05% <100.00%> (+0.02%) ⬆️

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 20, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 20, 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.

CodeRabbit posts a SKIPPED check on every head when automatic review is
off, and the grace stays open over it. The notes now speak of a review
check and name each skipped placeholder, so a released grace does not
read as a reviewer that never registered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727

ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

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

@ptr727
ptr727 merged commit 8b8d9b0 into develop Nov 20, 2026
13 checks passed
@ptr727
ptr727 deleted the burndown/merge-hold-hosted-grace branch November 20, 2026 02:03
ptr727 added a commit that referenced this pull request Nov 20, 2026
… an On-Open Ask (#4321)

## Summary

Fixes three findings that promotion PR #4315 drew on the registration
grace #4306 added.

- **A hosted check whose start is unread no longer ends an asked grace**
(#4315 thread `PRRT_kwDOQ5caqM6517DJ`). `CheckRun.startedAt` is
nullable. `since_ask` read a null start as "at or after the newest ask",
so such a CodeRabbit or Qodo check ended the window. That contradicted
the docstring, which ends the window only for a check that began at or
after the ask. Now a null start ends nothing while an ask is on record.
With no ask on record, any hosted check still ends the window, as
before.
- **The push log dates a head pushed again** (#4315 thread
`PRRT_kwDOQ5caqM651p5Y`). `head_arrived` read only the earliest suite or
check on the head. So a push back to a commit checked before read as
that commit's first push. It now takes the later of two stamps. One is
the push-log stamp `pr_review_side.pushed` already reads. The other is
the earliest suite, so the anchor is never earlier than before.
`full_read` attaches the stamp, which covers `wait`'s final read and
`merge`'s gate read. The held poll's registration test attaches it
through `pr_review_side.push_log`. That reader keeps a found stamp per
head for one `wait`, and asks again after a failed or empty read.
`PUSHED_KEY` moves to `pr_review_hold.py`, and `pr_review_side.py`
imports it from there.
- **An on-open ask is read back before the grace is judged** (#4315
thread `PRRT_kwDOQ5caqM651p5b`). `wait` dropped `ask("on-open")`'s
result. Take an attested head whose poll never slept, where the
after-checks phase sent nothing. The grace was then judged on the
snapshot read before the on-open ask. So `wait` could return 0 and say
the grace released the merge. Now a request from either phase forces the
re-read.

Each fix has a test that fails without it.

Closes on promotion: none

## Open findings from the local pass

- `introduced`, `scripts/pr_review_hold.py` `grace_note`: say a hosted
check concluded after an ask with a null `startedAt`. Then the
ended-grace note says no hosted reviewer's check registered, though a
concluded one is in the rollup. This depends on GitHub returning a
concluded check run with no start, which is not shown to occur. The
open-grace line and `merge`'s refusal already say "answering the head's
newest push or review ask". Outcome: declined, since no observed payload
produces the shape.

## Test plan

- `python -m unittest discover -s tests` with `tests/requirements.txt`
(4611 tests, OK)
- `mypy`, `ruff check`, `ruff format --check`
- `scripts/prose_lint.py --diff` against the merge base

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Review timing now better accounts for when commits are pushed and
review requests are sent, reducing the chance that earlier checks are
treated as responses to a newer request.
* Side reviewers may be asked when a pull request opens, with a later
check to avoid sending the same request twice.
* When timing information is unavailable or unreadable, the review
process uses a fallback instead of relying on an invalid timestamp.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ptr727 added a commit that referenced this pull request Nov 20, 2026
…d, and Hub Pin Drift (#4315)

## Summary

Promotes `develop` to `main`. It carries these changes:

- [#4303](#4303) orders
the STANDUP.md seed push, carry commits, and secret hand-over.
- [#4304](#4304) forbids
state-changing probes and routes observed secrets to revocation.
- [#4305](#4305) routes
SIGINT and SIGTERM through one handler, bounds the child wait, and
states two stop paths.
- [#4306](#4306) holds
`pr_review.py merge` for a hosted review not registered yet.
- [#4309](#4309) reads the
branch before the tree so an empty root commit resolves its secrets.
- [#4310](#4310) watches
the merge bot's auto-merge and re-arms a disable GitHub makes.
- [#4311](#4311) counts
untracked files in the dirty stamp and states the session tree bound.
- [#4314](#4314) reports
each caller's hub pin behind the newest release as drift past a 30-day
bound.

Related issues #4308, #4312, and #4313 stay open.

Fixes #1418
Fixes #4137
Fixes #4063
Fixes #4147
Fixes #2598
Fixes #4128
Fixes #4240
Fixes #4229
Fixes #3806
Fixes #4146
Fixes #4100
Fixes #4218
Fixes #4223
Fixes #4228
Fixes #4224

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Repository audits now report outdated reusable-workflow pins as
advisories or drift, with advisory findings kept separate from blocking
issues.
* Merge automation can retry enabling auto-merge after the base branch
settles; unsupported target branches and refused merges are reported as
failures.
* Pull-request checks now account for a brief hosted-review registration
window before reporting checks as pending.

* **Bug Fixes**
* Empty repositories and empty root commits are handled correctly when
resolving repository secrets.
* Long-running tools improve cleanup and signal handling when
interrupted.

* **Documentation**
* Updated guidance for repository setup, review handling, workflow
automation, and safe verification practices.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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