Skip to content

fix(source-control): bind lane reviews run after the newest retarget - #17703

Merged
kyle-sexton merged 3 commits into
mainfrom
fix-base-retargeted-binding
Nov 20, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix-base-retargeted-binding

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Refs: #15410

Summary

The babysit merge gate held every retargeted pull request forever as evidence-unbound: base-retargeted. babysit_merge.py passed base_changed=True when the timeline held any base_ref_changed event, and bind() then unbound every lane. GitHub retargets each upper stack layer to main when the layer below merges, so every such layer stuck, and nothing re-ran the reviews: the review lanes do not run on edited, and the whole-review request fired only for rerun-not-allowed. This PR delivers the part of #15410's merge lane that lets a retargeted layer's reviews bind again.

Fix

Design choice: retarget-time binding plus a whole-review request. The owner decided it (Q116 A). Owner, verbatim: "go w/ recommendations and then /session-flow:handoff". The row is at https://github.com/melodic-software/architecture/blob/6c602e74e88329895c98221aaefa8fef1f60d9a6/docs/owner-decisions.md#L282.

  • bind() takes retargeted_at, the newest base_ref_changed time, in place of the bool. A lane binds only on runs created after it, every link of the review chain included (a pre-retarget link reports base-retargeted, not incremental-gap). A review against the old base never counts; a re-run keeps its run's creation time, so it never counts as later. An unreadable event time unbinds as evidence-error.
  • Lane-source pull requests (main-run reviews) take the same cutoff on the binding verdict's run, so a pre-retarget verdict never binds.
  • A blocking security finding a pre-retarget review left open still carries (_carried_blocking keeps reading every run).
  • babysit_whole_review requests one whole review for a lane unbound as base-retargeted, as for rerun-not-allowed, under the same caps: once per head, MAX_TOGGLES per pull request, one per sweep, and the running-jobs and rate-limit floors. The pr-pipeline convention's whole-review paragraph says so.

Known limits: a head that already has a recorded whole-review request (for example for a refused re-run) gets no second one after a retarget; it waits for a push or a person, as the per-head cap intends. A lane-source pull request retargeted without a push stays held as lane-source-changed, as it was held before (then as base-retargeted): pr-review-main.yml's already-reviewed check calls _main_bound without the cutoff, so it skips the new review. Closing that needs the workflow to read the retarget time, a decision for the owner.

Verification

Touched suites pass locally with python3 -m unittest: test_babysit_review_evidence, test_babysit_whole_review and test_babysit_lane_binding_wiring (383 tests), plus test_babysit_merge, test_babysit_verify_evidence, test_babysit_lane_reviews and test_babysit_gh_lane_run_carry (678 tests). scripts/check-affected.sh --tests: 18 checks passed; scripts/check-line-citations.py clean. New tests cover a retarget then a later whole review binding, a pre-retarget run not binding, a pre-retarget chain root reporting base-retargeted, a pre-retarget main-run verdict not binding, the carried blocking count, an unreadable time, the newest event's time reaching bind(), and the whole-review request firing for base-retargeted under its caps. The live timeline of melodic-software/pr-pipeline-sandbox#400 carries created_at on its base_ref_changed event, the field the gate reads; lane runs come from the listing and main-run records from actions/runs/{id}, both of which carry created_at.

Left out: the shell and node suites check-affected.sh --tests left to CI past its 120-second budget.

Related

Remaining

🤖 Generated with Claude Code

kyle-sexton and others added 3 commits November 20, 2026 16:58
Claim commit: the changelog fragment. The fix follows.

Refs: #15410

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The merge gate passed base_changed=True for any pull request whose
timeline held a base_ref_changed event, and bind() then unbound every
lane for good. GitHub retargets each upper stack layer to main when the
layer below merges, and nothing re-ran its reviews, so every such layer
stayed held.

bind() now takes retargeted_at, the newest retarget's time. A lane binds
only on runs created after it, every link of its review chain included,
and the main-run path applies the same cutoff to its binding verdict. A
pre-retarget blocking finding still carries. An unreadable time unbinds
as evidence-error. A lane unbound as base-retargeted requests one whole
review under the existing caps, as a refused re-run does.

Refs: #15410

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The whole-review paragraph said no unbound reason but
rerun-not-allowed requests one; base-retargeted now does too.

Refs: #15410

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 20, 2026 22:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T22:23:10.270627Z bdf752e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdf752e50b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed bdf752e50bbd5dc1b6eb1b9a337f3ea5c62f807c: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #17703 (bind lane reviews run after the newest retarget)

No security issues found. I read all 9 changed files in full.

What I checked

This PR narrows a merge hold in trusted-path modules: babysit_review_evidence.py, babysit_merge.py and babysit_whole_review.py. The base-retargeted hold is not one of the owner's named friction holds, so I judged it like any other merge hold.

  • The old rule. Any base_ref_changed event left every lane unbound, permanently.
  • The new rule. A lane binds only on runs whose created_at is strictly later than the newest retarget, and this applies to every link of the review chain (_bound_record, _link, _skip_target). A PR is let through only after a fresh review, created after the retarget, comes back clean at the head. That keeps the purpose of the hold: a review of a diff against the old base never counts.

Fail-closed paths

I checked each path that could let a PR through on bad input. All of them fail closed:

  • Retarget times in _retargeted_at. A missing, unparsable or mixed naive/aware time makes max(..., key=datetime.fromisoformat) raise TypeError/ValueError, which returns "". If every time is naive, _time (babysit_review_evidence.py L2146-L2154) returns None. Both cases raise Unbound("evidence-error") in bind().
  • Run times in _created_after. A run with no created_at, or one that cannot be parsed, returns False, so it does not bind.
  • Ties. The comparison is a strict >, so a run created in the same second as the retarget does not bind.
  • Re-runs. A re-run keeps its run's creation time, so it never counts as later.
  • Pre-retarget chain links. These now re-raise base-retargeted rather than falling through to incremental-gap. They stay unbound either way.
  • Lane-source PRs (_main_bound). A missing record["run"] raises a KeyError that the caller's except Exception catches, so the lane stays unbound. The max over findings and CRITICAL findings still covers every counted record, pre-retarget ones included, so an older finding cannot be cleared.
  • Blocking findings carry over. _carried_blocking (babysit_review_evidence.py L1025-L1050) still calls _resolve without the cutoff, so a blocking security finding left by a pre-retarget review still holds. With a carried finding, wanted returns False (the test test_a_retargeted_security_lane_carrying_a_blocking_finding).

Whole-review request

NEW_RUN_CLEARS adds base-retargeted to the reasons that request a whole review. The request uses the existing mechanism (a draft/ready toggle with the lane token) under the same caps as before: once per head, MAX_TOGGLES per PR, one per sweep, plus the rate floors. The change does not widen the token's scope, who is trusted, or what untrusted text reaches a lane.

Residual note (not counted as a finding)

Binding rests on the run's created_at, not on the base the run's event carried. If GitHub were slow to create a run for an event from before the retarget, a review of the old base could bind. I could not check how the external review workflow builds its diff. I found no actor or impact that reaches this under the owner's threat model, so it is noted, not reported.

Spend

A retargeted PR may now trigger one more whole-review run of both review lanes. This uses subscription/API usage only; it is not a billing change.

critical-findings: 0

@github-actions github-actions Bot 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.

claude-review: 1 inline finding(s) on bdf752e50bbd5dc1b6eb1b9a337f3ea5c62f807c; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed bdf752e50bbd5dc1b6eb1b9a337f3ea5c62f807c: read 9 of 9 changed file(s); 1 finding(s), 1 as inline comments.

Code review: bind lane reviews run after the newest retarget

The change replaces the base_changed flag with retargeted_at, the time of the newest base_ref_changed event. With it, review evidence binds only on lane runs, and on main-run verdicts, created strictly after that time. A pre-retarget link in a review chain now reports base-retargeted instead of incremental-gap, and base-retargeted joins rerun-not-allowed as a reason that triggers a whole-review request.

I traced the following and found no correctness defect in them:

  • Run choice. _bound_record picks the newest run by _run_order (created_at, then id), so a run created after the retarget always wins over older ones at the same head.
  • Re-runs. A re-run keeps its run's created_at, so it never counts as created after the retarget.
  • Unreadable times. _retargeted_at turns a missing time, a malformed time, or a mix of naive and aware times into "". bind() then gives evidence-error because _time needs an aware timestamp. from datetime import UTC already requires Python 3.11 or later, so fromisoformat accepts the Z suffix.
  • Main-run records. Records from collect_main_reviews keep the full actions/runs/{id} object, created_at included. _main_bound reads record["run"] only after _main_review_counted has checked that it is a Mapping.
  • Carried security findings. _carried_blocking still calls _resolve without after, so a pre-retarget security finding keeps holding, as the PR states.
  • Main-run path. pr-require-checks.yml runs in full on an edited event that carries changes.base. That start makes pr-review-main produce a verdict after the retarget, which backs the PR's note on lane-source pull requests.
  • Old argument. No caller still passes base_changed. The only remaining uses are in frozen eval fixtures.

Blocking: the merge gate's review-evidence check now accepts more, and no spec allows it. This is the inline finding on babysit_review_evidence.py:483. Before, the gate bound no lane on any retargeted pull request. Now it binds lanes on runs created after the retarget. That is a loosening of kind 9 under "Fail a change that loosens a check". The PR only references #15410 and closes no issue, so no trusted spec text names the change. The design itself looks sound.

No closing issue is in the PR context, so there were no acceptance criteria to check. The PR context, prior-findings and rule files held no embedded instructions to this lane. The author's claimed test runs (383 + 678 tests, check-affected.sh) are author-claimed and unverified; this lane ran nothing.

Spend note: the new whole-review request draws on prepaid lane usage, at most one extra pair of review runs per retargeted head and two per pull request (the existing caps). It is not a hold.

Loosened checks would be marked: fail (default: the prompt had no loosened_check_verdict: or loosened_check_patterns: line); patterns: 0. The prompt had no loosened_check_decision_record: line either, so the owner-decision citation requirement was not checked.

Verifier dropped 0 of 1 candidates.

@kyle-sexton kyle-sexton added the do-not-merge Hard merge gate: do not merge while applied. label Nov 20, 2026
@kyle-sexton

Copy link
Copy Markdown
Member Author

Held by session 971c6bd4 for the owner's decision. This changes what the merge gate trusts: a retargeted pull request's reviews count again once they run after the newest retarget. The claude-review thread on this pull request asks for owner text naming that change. The question is with the owner now.

@kyle-sexton

Copy link
Copy Markdown
Member Author

@kyle-sexton kyle-sexton removed the do-not-merge Hard merge gate: do not merge while applied. label Nov 20, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 63c0892 Nov 20, 2026
175 of 177 checks passed
@kyle-sexton
kyle-sexton deleted the fix-base-retargeted-binding branch November 20, 2026 23:14
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant