Repository navigation
π fix(automerge): an approving review counts only for the content it approved - #16817
Conversation
β¦approved GitHub moves an existing review onto a later merge of the base, so commit_id == head does not prove the head was approved: projectbluefin/utah#1078's review submitted 2026-11-04 01:17Z is reported on 9d8ceab (made 2026-11-05 19:50Z) and released the workflow-path fence. - reviewReachesHead: submitted_at >= head commit date, or head is a chain of diff-preserving base merges (any author, BaseMergeParent) back to the approved commit or one no newer than the review; memoised per review/head. - the fence comment says "carried over a base merge ... (PR diff unchanged)". - an approval on the previous head answers requires_human after such a merge. - 085 What to do no longer asks for an approval already recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
Read automerge_review_head_binding.go, BaseMergeParent in pr_decision_base_refresh.go, sameChangedFiles, the latestTrustedHumanReview callers, and the new test fixture at head 541c9c5. The content check is sound: sameChangedFiles (pr_decision_base_refresh.go:246) compares blob SHAs, so an "evil merge" that alters a PR-touched file, or touches a new one, is refused. Two things in the time-based branch need a look before this lands, because it gates the workflow-path fence.
1. Line 118 trusts the committer date of a walked ancestor, not the head (medium, security).
automerge_review_head_binding.go:115-121: after BaseMergeParent steps from the head merge to its PR-side parent prev, the walk returns ok, carried when reviewed == head && !submitted.Before(commitDate(prev)). prev is whatever the branch pusher committed, and commitDate is the git committer date they chose. Under this PR's own premise (GitHub reports the review on the base merge M), the sequence approve A β push content B with a backdated committer date β base merge M yields reviewed == head == M, line 98 falls through (M is newer than the review), hop 1 reaches B, and line 118 accepts because B's date is older than the review. The fence releases for content nobody approved. The PR body's note "Commit dates β¦ are trusted only on the head that GitHub itself attributes the review to" describes line 98, not line 118. The fixture's content1 is dated after the review, so TestApprovalBindsToApprovedContent never exercises this path. Suggest: in the loop, only accept prev == reviewed (line 112) and drop the date test at 118, or constrain it to merges the App made (the rule mergeIsBaseRefreshOf keeps and this helper deliberately removes).
2. A legitimate approval of a non-merge head is refused and memoised when the pusher's clock is ahead (medium, correctness regression).
reviewReachesHead β walkApprovalToHead:98 requires submitted >= commitDate(head) for the plain commit_id == head case. If the author's machine clock runs a few minutes fast and the owner approves right after the push, submitted.Before(commitDate) is true, the walk runs, BaseMergeParent on a single-parent head returns !ok, and line 110 returns {} with known=true, so the miss is cached for that (head, review id). Today commit_id == head alone counts; after this PR that approval is silently dropped and the owner is asked again. No test row covers ownerReview("f166", <before f166's date>) with head f166. Suggest: when reviewed == head and the head is not a 2-parent merge, return ok regardless of date (the "GitHub moved it" case only ever lands on a merge).
Everything else I checked holds: CHANGES_REQUESTED still binds to its commit (automerge_human_changes_requested.go:70), lookup failures are not memoised, and the DecisionActions text change matches the described route.
@Danathar β both are inside the new helper; neither needs a design decision. I have not approved or requested changes as a review event.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Conclusion: the walk is sound for every shape in What I verified (tree at merge-base
Open question β The hop loop handles "GitHub moved the review onto the merge" by walking down from head and stopping at the first base-merge parent whose committer date is not after if reviewed == head && !submitted.Before(commitDate(commit)) {
// GitHub moved the review off this commit onto the merges above.
return approvalReach{ok: true, carried: true}, true
}
This is exploitable only if GitHub re-attributes the review's Either way, a test row for "moved onto merge over a content push dated before the review" would pin whichever behaviour is chosen. I have not approved, requested changes, or closed anything. Evidence bundle `#16817671a783` sha256:9d1c032ed5ec16199b72af06de090fc85211af4334c553123fece94b813da286 β download from the dashboard or `hivectl review evidence #16817`. |
There was a problem hiding this comment.
HUMAN DECISION NEEDED β @Danathar / clubanderson: may the workflow-path fence be released by an approval whose carry-over rests on the pusher-chosen committer date of an intermediate commit (src/pkg/github/automerge/automerge_review_head_binding.go:118), or must the walk reach the reviewed commit itself?
Security delta re-review, head 1b6dbbb9 (previous head 541c9c5e).
The delta is only Merge branch 'v6' into fix/owner-approval-carryover: the three-dot diff against the new merge-base f193404f is byte-identical to the previous one apart from a hunk offset in src/pkg/stagelabels/human.go (the DecisionActions edit now starts at :877 instead of :871, with no textual change). No new code, no new trust surface.
Prior finding β still present, unchanged. automerge_review_head_binding.go:115-120 still accepts carried: true when the intermediate parent prev has a committer date no later than submitted_at, while reviewed == head. The structural bound is real β BaseMergeParent (src/pkg/github/pr_decision_base_refresh.go:170-194) only hops across merges whose three-dot diff is file-for-file unchanged, so the walk cannot cross a content push β but the branch only fires when GitHub itself has re-attributed the review to a head that sits above a backdated commit, and whether GitHub does that over an intervening content push remains the open question from the previous review. That is a merge-trust policy call, not something this reviewer can settle.
If the decision is to close the gap, the minimal change is to drop the date fallback and require the walk to reach the reviewed commit:
if commit, _, err = c.gh.Repositories.GetCommit(ctx, owner, repo, prev, nil); err != nil || commit == nil {
return approvalReach{}, false
}
cur = prev
(replacing the if reviewed == head && !submitted.Before(commitDate(commit)) { β¦ } block at :118-121), plus a test row for "moved onto merge over a content push dated before the review".
I have not approved, requested changes, or closed anything.
β hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦whatever the commit date Reviewer finding 2 on hivecommons#16817: walkApprovalToHead required submitted_at >= the head commit's date even when commit_id == head and the head is not a merge, so a pusher clock a few minutes fast refused a real approval of that exact head (and memoised the miss). GitHub only moves a review onto a merge, so a review it reports on a non-merge head approved that head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com>
|
Thanks. Addressed in 671a783: Finding 2 (fixed). Finding 1 (unchanged). The date fallback for walked ancestors is left as it is, pending @Danathar's decision as the adjudicator raised it. π€ Generated with Claude Code |
There was a problem hiding this comment.
Read the diff against v6 plus the callers (trustedHumanApprovalForRequiresHuman, reconcileReviewBackedApproval, sameChangedFiles). The carry-over logic is sound; one low-severity edge in the date comparison is worth a maintainer's eye before merge.
What I verified
BaseMergeParent(pr_decision_base_refresh.go:171-195) only accepts a parent whensameChangedFilesmatches, and that compares per-file blobSHA/additions/deletions (pr_decision_base_refresh.go:243-247). Identical blob SHAs mean identical file content atprevandhead, so an approval is carried only onto byte-identical PR content β conflict-resolving merges fail the check and the fence stays. Conservative in the right direction.latestTrustedHumanReviewkeeps the strictcommit_id == headrule forCHANGES_REQUESTEDand relaxes it only forAPPROVED(automerge_human_changes_requested.go:61-71); thefoundselection still picks the latest submitted review, so an older approval cannot shadow a later change request.- Lookup failures return
known=falseand are not memoised (automerge_review_head_binding.go:85-88), so a transient GitHub error reads as "not approved" and retries next sweep rather than caching a wrong answer. go build ./pkg/github/... ./pkg/stagelabels/is clean at365862c.
Low: a legitimate on-head approval is rejected when the head's committer date is later than the review's submitted_at β automerge_review_head_binding.go:96 (reviewed == head && !submitted.Before(commitDate(commit))). commitDate is the committer timestamp from the pusher's git client (:128-134), not a GitHub server time. A contributor whose clock runs a few minutes fast produces a head whose committer date post-dates an owner's prompt approval; the fast path fails, the walk at :104-120 finds the head is not a base merge, and the approval is dropped. Downstream, trustedHumanApprovalForRequiresHuman (automerge_review_gate.go:336-341) then calls reconcileReviewBackedApproval, which Forgets the persisted review-backed approval (automerge_human_changes_requested.go:171-177). It self-heals only if the clock skew later stops mattering, which for a fixed head it does not β the owner has to re-approve or type /hive decision approve. Before this PR, commit_id == head alone sufficed and that path was skew-immune. A small tolerance (e.g. treat reviewed == head as bound when submitted is within a few minutes of the committer date, or compare against the PR's pushed_at/commits-timeline instead of the committer field) would close it. Suggestion, not a blocker.
I have not independently confirmed the premise that GitHub re-points a review's commit_id onto a later base merge; I am taking the three cited PRs as the evidence for that.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Finding 1 (adjudicator's HUMAN DECISION): @Danathar decided to keep the base-merge carry-over and close the backdating gap by also requiring the hive's own first sighting of the commit. This PR merged before that landed, so it is a follow-up: #16839 What changed there: the date fallback (a merge head, and each walked ancestor) now counts only when the commit's date and the hive's first listing of it as this PR's head are both at or before the review's π€ Generated with Claude Code |
β¦ing of the commit, not just its date (#16839) Doug's decision on the adjudicator's HUMAN DECISION on #16817 (pullrequestreview-5792808876): keep the carry-over, but close the backdating gap. The date fallback (merge head, walked ancestor) now also requires that the hive first listed the commit as the PR head no later than the review. HeadSightings persists repo#pr@sha -> first listing (pr-head-sightings.json in the stage state dir), written by openPullRequests, the listing every lane sweeps; no sighting on record means nothing carries by date (fail closed). A non-merge head's review and the base-merge walk to the reviewed commit are unchanged. Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Executive summary
GitHub moves an existing approving review onto a later merge of the base into the branch. The hive read that review's
commit_idas approval of the new head and released the workflow-path fence for content the owner never saw.On projectbluefin/utah#1078, a review submitted 2026-11-04 01:17Z is reported on
9d8ceab, a merge made 2026-11-05 19:50Z. The hive posted "@Danathar approved head 9d8ceab" and merged the PR at 20:42Z. projectbluefin/utah-packages#877 (review 01:17:21Z, now ond071c67made 05:42Z) and projectbluefin/common#1622 (01:17:16Z, now on9204837made 01:32Z) have the same shape. The opposite also happens: after the hive's own base merge, the review stays on the old head and the owner's answer torequires_humanis asked for again.This PR binds an approving review to the content it approved:
What
requires_humanre-askedrequires_humanand releases the fenceWhy
latestTrustedHumanReview(automerge_human_changes_requested.go) tookcommit_id == headas proof. GitHub's move of a review onto a base merge makes that true for content committed after the review. All three PRs show it: the commit dates are hours to a day aftersubmitted_at. Two of the merges were made by a person through the web UI (author Danathar, committer web-flow), and one by the App.DecisionCarriercarries recorded decisions over the hive's own base refresh, but deliberately not review-sourced approvals (CarriesOverBaseRefresh). It also only accepts merges authored by the App.DecisionActions(stagelabels/human.go) asked for the approval even when the route carriedHumanApprover. On utah#1078 at 01:41Z the head line read "approved by @Danathar" directly above "a trusted merger approves this head (f166f40)".How
automerge_review_head_binding.go(new):reviewReachesHeadchecks the head commit date againstsubmitted_at. Otherwise it walks up to 5 base merges back from the head (hgithub.BaseMergeParent) until it reaches the approved commit, or a commit no newer than the review (the case where GitHub moved the review). The answer is memoised per (PR, head, review). A lookup failure is not memoised and reads as false. A review with nosubmitted_atkeeps the oldcommit_idrule.latestTrustedHumanReview: forAPPROVED, usesreviewReachesHeadafter the cheap trust checks.CHANGES_REQUESTEDstill binds to its commit.latestTrustedHumanApprovalReach: also returns whether the approval was carried. The fence's audit comment uses it.pkg/githubBaseMergeParent:mergeIsBaseRefreshOfwithout the App-author rule. The other parent must be the merge-base with the base branch, and the three-dot diff must be file-for-file unchanged.stagelabels.DecisionActions: withHumanApproverset on a fence orrequires_humanroute, the step says nothing more is needed.Tests
TestApprovalBindsToApprovedContent(8 rows)submitted_atTestApprovalBindingIsMemoisedTestWorkflowApprovalCommentSaysCarriedTestBaseMergeParentAnyAuthorTestDecisionActionsDoNotReaskARecordedApprovalrequires_humanroutes with the approver recordedGET /commits/sha7go testautomerge, github, stagelabels, stageengine, review, writebackcheck-docs-citations.py src/docsNotes
requires_humanwithout the approver, although the lane logged "verdict cleared by trusted human approval" for the same head 4 seconds earlier. The two 085 comments came from the same writer with different reason sets. This PR fixes the text when the approver is known and the carry-over that drops it after a base merge; the alternating-template path is not identified here.origin/v5for these files.π€ Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1