Skip to content

πŸ› fix(automerge): a carried approval needs the hive's own first sighting of the commit - #16839

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/approval-carryover-first-seen
Nov 5, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/approval-carryover-first-seen

Conversation

@Danathar

@Danathar Danathar commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Executive summary

Follow-up to #16817, which merged before this change. It applies Doug's decision on the adjudicator's HUMAN DECISION (review 5792808876): keep the base-merge carry-over, but close the backdating gap.

Before this, a carried approval's date fallback trusted the commit's committer date, which the pusher chooses. It now also requires that the hive had listed that commit as the PR's head at or before the review's submitted_at. Each head's first listing is persisted. A commit with no listing on record is unknown, so nothing carries by date for it (fail closed).

What

Case #16817 Now
Review GitHub reports on a non-merge head counts counts (unchanged)
Review on an earlier commit, head = diff-preserving base merges to it carried carried (unchanged)
Review moved onto a merge-only head, content dated and first listed before it carried carried
Same, content first listed after the review (backdated push) carried refused
Same, no listing on record (e.g. before the upgrade) carried refused; the person approves the head again
Merge head (not a base merge), backdated, listed after the review counted refused

How

  • head_sightings.go (new): HeadSightings persists repo#pr@sha β†’ first listing as pr-head-sightings.json in the stage state directory. It writes once per new head and keeps entries for 180 days. TestMain points the shared record at a temp dir.
  • openPullRequests, the listing every lane sweeps, records each listed head (sightHeads).
  • contentPredates in automerge_review_head_binding.go: the date fallback for a merge head and for each walked ancestor requires both the commit date and the first listing to be at or before submitted_at.
  • Unchanged: a non-merge head's review (πŸ› fix(automerge): an approving review counts only for the content it approvedΒ #16817 finding 2) and the base-merge walk to the reviewed commit.

Tests

Test Covers
TestApprovalBindsToApprovedContent (12 rows) new: backdated content push under a later base merge refused; legitimate carry-over with first listing before the review accepted; unknown first listing refused; backdated non-base merge head refused; merge head approved after its listing accepted
TestHeadSightingsPersistFirstSeen first listing kept across re-sightings and a reload; openPullRequests records listed heads
Mutants 7/7 caught (sighting requirement, unknown handling, merge-head and ancestor date checks, listing hook, first-write-wins, save)
go test ./pkg/github/automerge/..., go build ./... pass
check-docs-citations.py src/docs 2006 verified

Notes

  • The listing time is the hive's own clock at its sweep, which is never earlier than the push. A legitimate approval typed between a push and the next sweep carries nothing by date. The walk to the reviewed commit and a non-merge head still work, so the cost is a re-approval only on GitHub-moved reviews.
  • Upgrade: heads listed before this ships have no record, so a GitHub-moved review onto a merge head made before the upgrade is not carried by date, as decided.
  • The docs (hive-merge.md) and a new changelog fragment describe the rule. πŸ› fix(automerge): an approving review counts only for the content it approvedΒ #16817's fragment is unchanged.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…ing of the commit, not just its date

Doug's decision on the adjudicator's HUMAN DECISION on hivecommons#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.

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>
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16835 πŸ› fix(close-on-merge): a Refs-only PR never closes the issue it references same files src/docs/hive-merge.md

@hivecommons-hive hivecommons-hive 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.

Read the diff against merge-base 91ba1dde together with the walk it changes. This looks correct to me, and it does close the gap the #16817 decision named.

What I verified:

  • automerge_review_head_binding.go:143-149 (contentPredates) now requires both commitDate ≀ submitted_at and a recorded first sighting ≀ submitted_at; a sha with no record returns false. Both call sites (:106 for a merge head, :128 for each walked ancestor) use it; the non-merge-head short-circuit at :106 is unchanged, as the body says.
  • The scenario I was worried about β€” approver clicks Update branch and approves within seconds, before the next sweep lists the new merge head M β€” is rescued: contentPredates(M) fails on the sighting, but the loop at :116-133 walks to the prior head B, which was sighted long before, and returns carried. So no regression for the common human flow.
  • Memoisation in reviewReachesHead (:86-93) remains sound: sightings are recorded in openPullRequests (automerge_forgestate.go:265-267) before the review gate runs in the same sweep, and FirstSeen is write-once, so a memoised answer cannot later flip.
  • head_sightings.go: write-once per key under mu, tmp+rename save, 180-day prune only on change; TestMain redirects the shared record to a temp dir so tests do not touch /data.
  • go build ./pkg/github/automerge/ passes at e5bddfd; CI green apart from tide pending.

One residual window, by design per your table ("no listing on record β†’ refused"), worth knowing operationally: if content commit B and the base merge M arrive in the same push and the approval lands before the next sweep, B is never sighted as a head, so that approval is refused for good (memoised); the approver's second approval counts once a sweep has listed M. Not a defect β€” just the cost of fail-closed β€” and hive-merge.md already says so in substance.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

hivecommons-hive Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Hive status β€” updated in place; edits do not notify. Full history is in the Activity Monitor.

Review findings from quality (folded here because this head already carries its hive review):

Test review (quality lane) β€” read at head e5bddfd. The fix is pinned: "backdated content push under a later base merge" (date 11-03, review 11-04, first sighting 11-05) passes the old !submitted.Before(commitDate) check and is refused only by contentPredates, so it fails without this diff; "first sighting unknown" covers the pre-upgrade fail-closed path, and TestHeadSightingsPersistFirstSeen covers reload + case-folding + openPullRequests recording.

One branch has no test: the headSightingsRetention prune in Sight (drops entries older than 180d, only on a changed write). A two-line addition to TestHeadSightingsPersistFirstSeen β€” sight old at first, then sight a new head at first + 181d and assert FirstSeen(old) is false while a sighting at first + 179d keeps it β€” would lock the boundary; as written, an off-by-sign there (e.g. at.Sub(now)) would pass CI. Non-blocking.

Evidence bundle `#16839e5bddfd` sha256:c6805ca29d26c3ac1b2ce4c929a7856e8412ff64f3520f4b5d2451c9e6cc9d85 β€” download from the dashboard or `hivectl review evidence #16839`.

@hivecommons-hive
hivecommons-hive Bot merged commit f2d924d into hivecommons:v6 Nov 5, 2026
71 of 74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant