Skip to content

πŸ› reviewer: carry the operator decision across consecutive base refreshes - #15780

Merged
hivecommons-hive[bot] merged 9 commits into
v5from
scanner/fix-15766
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 9 commits into
v5from
scanner/fix-15766

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Two App base refreshes landing before any gate read the PR left the decided head two hops back, so the carry refused and the operator had to re-decide. The carry now walks back up to 5 consecutive refreshes; each hop goes through the unchanged per-hop verification (App author/committer, base-branch parent, identical diff), and a broken hop or exceeding the bound refuses.

Closes #15766

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

…shes

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 30, 2026
@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 Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

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

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

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

PR Title Relation Files
#15748 πŸ› [reviewer] park PRs at 085 Needs decision when the fixer exhausted its attempts same files src/docs/hive-merge.md
#15812 πŸ› automerge: hold same-issue PRs across lanes until a decision is recorded same files src/docs/hive-merge.md
#15757 ✨ Auto-merge hive-authored superseding PRs without operator decision same files src/docs/hive-merge.md

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The multi-hop walk is sound, but it regresses the existing "fetch the merge commit once" contract and that is why test (rest 4/4) is red on this head.

Finding (high) β€” src/pkg/github/pr_decision_base_refresh.go:97-115: three GetCommit calls per evaluation when the carry is refused.
headIsBaseRefreshChainOf first calls headIsBaseRefreshOf(oldHead, newHead) (one GetCommit of newHead, line 119). When that returns false, the loop fetches newHead again (line 102) and then hop 0 calls headIsBaseRefreshOf(parent, cur=newHead), which fetches it a third time β€” plus a second compareAllFiles(base, newHead). The existing test asserts exactly one fetch and fails with merge commit fetched 3 times across three gates, want once (memoised) for the base refresh that changed the diff and merge by a person cases (automerge_decision_carry_test.go:129, CI job test (rest 4/4) run 41070077850). The positive case passes only because the single-hop check short-circuits.

Note hop 0 with parent == oldHead is the single-hop check, so the up-front call is redundant: dropping it and having the loop fetch each commit once β€” e.g. splitting headIsBaseRefreshOf into a variant that takes the already-fetched *gh.RepositoryCommit β€” restores one GetCommit for the one-hop case and gives N fetches for N hops. The parent == oldHead early exit also means that when the head's first parent is already oldHead and the hop check failed, the walk cannot succeed and should stop rather than re-verify.

Docs (low) β€” src/docs/hive-merge.md:222-224 still defines the one exception as "a merge commit authored by the App whose parents are the decided head and a commit on the base branch". With this change the decided head may be up to baseRefreshMaxHops first-parent merges back; the paragraph and the changelog fragment now disagree.

Everything else I checked holds: each hop re-runs the full per-hop verification (App author, merge-base of base...cur equals the other parent, identical file set), so "diff unchanged" is transitive along the chain; the depth bound of 5 is reached exactly by the depth bound reached case and refused at 6; the result is still memoised per (oldHead, newHead) via Known.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The multi-hop walk is logically sound, but it regresses the existing API-budget test and CI is red because of it. One change needed before this can land.

Correctness β€” test (rest 4/4) failure is caused by this diff
src/pkg/github/automerge/automerge_decision_carry_test.go:129 fails with merge commit fetched 3 times across three gates, want once (memoised). Mechanism, from src/pkg/github/pr_decision_base_refresh.go at f83090c:

  1. headIsBaseRefreshChainOf (:96-116) first calls headIsBaseRefreshOf(oldHead, newHead), which does GetCommit(newHead) (:120) β€” fetch #1.
  2. When that returns false (every head that is not a refresh: an author push, a person's merge, a refresh that changed the diff), the loop at :101-103 calls GetCommit(cur=newHead) again β€” fetch #2.
  3. It then calls headIsBaseRefreshOf(parent, cur) (:105), which does GetCommit(cur) a third time β€” fetch #3 β€” before the compare fails.

The memo in HeadIsBaseRefreshOf (:62-72) still dedupes across gates, so the three gates are fine; the problem is that a single evaluation of the common negative case now costs 3 commit lookups instead of 1. The BaseRefreshRepos doc comment at :32-33 ("one commit lookup and two three-dot compares per new head") also no longer describes the code.

Suggested shape: fetch each commit once and thread it through β€” e.g. split headIsBaseRefreshOf into a fetch step and a commitIsBaseRefreshOf(commit, parentSHA, …) step, and have the chain walk reuse the commit it already has for cur. For a non-merge head (len(Parents) != 2) the first fetch already settles it, so the walk should not re-fetch. Then update the :32-33 comment to state the per-hop cost.

What I verified is correct

  • Every hop is re-validated with the full single-hop check (App author/committer, merge-base of baseRef...cur equals the other parent, identical changed-file set), so diff equality is transitive back to oldHead and a content commit anywhere in the chain refuses (TestDecisionCarrierRefusesChainBrokenByContentCommit pins this).
  • Walking Parents[0] is the right choice for App update-branch merges; a swapped-parent commit fails closed rather than open.
  • parent == cur and empty-SHA guards prevent a loop; baseRefreshMaxHops = 5 bounds the API spend.
  • Matches #15766 exactly; changelog fragment is well-formed.

coverage and test are red downstream of the same failure, so I did not triage them separately.

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

The chain walk ran the single-hop check, then re-fetched the new head
at hop 0, then fetched it a third time inside that hop's check, so a
refused carry hit GetCommit three times and the automerge memoisation
test failed. Walk the first-parent chain once, pass the fetched commit
into the per-hop check, and keep the decided head accepted in either
parent position. Document the multi-hop carry in hive-merge.md.

Hive-Fix-Attempt: 1/6

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: ci-maintainer <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 30, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks correct to me.

Read pr_decision_base_refresh.go at 55209c3 plus the callers of HeadIsBaseRefreshOf and the update-branch path that produces these commits:

  • The intermediate-hop assumption that the PR head is first parent (headIsBaseRefreshChainOf, pr_decision_base_refresh.go:105-108) holds: refreshes come from GitHub's update-branch (automerge_adoption_recovery.go:227-232), which merges base into the PR branch, so first-parent is always the PR head. The first hop keeps the either-position tolerance, so nothing that carried before stops carrying.
  • Per-hop mergeIsBaseRefreshOf still requires App author, merge-base(baseRef, cur) == the non-PR parent (:150-152), and identical three-dot file set β€” so an App-authored merge that changes content fails sameChangedFiles, and a human merge fails the login check. A content commit that is not a merge fails the parent-count check at :101. Test TestDecisionCarrierRefusesChainBrokenByContentCommit and the broken-hop cases at hop 1/2/3 cover each of these.
  • prev == cur guard at :109 prevents a self-parent loop; the walk is bounded by baseRefreshMaxHops.

One info note, not a defect: each hop runs compareAllFiles(base, prev) and the next hop runs compareAllFiles(base, prev) again as its "new" side, so an n-hop chain costs ~2n+1 compares rather than n+1. Bounded at 5 and cached per (old,new) key, so fine as is.

Docs (hive-merge.md) and changelog fragment are updated in step.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed β€” no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed β€” no findings from this perspective.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the walk at src/pkg/github/pr_decision_base_refresh.go:98-119 against the tree at merge-base 1279311 and the callers that produce refreshes. Looks correct to me.

What I verified:

  • Every hop still goes through the full single-hop check: mergeIsBaseRefreshOf (pr_decision_base_refresh.go:126-160) requires App author (CommitByGitHubLogin), the non-walked parent to equal merge-base(baseRef, cur), and sameChangedFiles between baseRef...prev and baseRef...cur. Diff identity is therefore transitive down to the decided head, and a 1-parent content commit anywhere in the chain fails the len(Parents) != 2 guard at :103.
  • The hive's refreshes are created via gh.UpdateBranch (src/pkg/dashboard/api_repo_item_decision.go:782, rebase_merge_followthrough.go:113, automerge_adoption_recovery.go:219), which merges base into head with the PR head as first parent β€” so following Parents[0] on intermediate hops (:108) matches how these commits are actually built. A merge with the parents reversed is refused (merge-base would equal the first parent, not the second), which is the conservative direction.
  • Tests cover depth bound, bound+1, a non-App hop at each position, and a content commit mid-chain; changelog.d/fixed-… prefix is one the fragment guard accepts.

One informational note, not a defect: each hop re-runs compareAllFiles for prev, which the next iteration fetches again as cur, so a 5-hop chain costs 5 GetCommit + 10 compares before the result is cached under (oldHead,newHead). Bounded by baseRefreshMaxHops, so fine as-is; memoising the per-SHA compare would halve it if this ever shows up in rate-limit logs.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read headIsBaseRefreshChainOf and mergeIsBaseRefreshOf (src/pkg/github/pr_decision_base_refresh.go:92-160) against the v5 single-hop version and the caller in carryOverBaseRefresh (:245-262). The walk is fail-closed at every step: each hop must be a two-parent commit (:104-106), authored by the App (:130), with the non-walked parent equal to merge-base(baseRef, cur) (:150-152) and an identical three-dot file set (:157); a content commit anywhere in the chain has one parent and ends the walk, and the prev == cur / empty-parent guards (:111) stop a degenerate loop. The Known cache keys on (oldHead,newHead), so a chain result is cached like a single hop. Tests cover 2 hops, the bound, bound+1, a non-App hop at each position, and a content commit mid-chain. Looks correct to me.

Two non-blocking notes:

  • src/pkg/github/pr_decision_base_refresh.go:32-33 β€” the BaseRefreshRepos doc comment still says "one commit lookup and two three-dot compares per new head"; it is now up to baseRefreshMaxHops lookups and twice that many compares.
  • :145 / :154 β€” on a multi-hop chain the baseRef...prev compare run at hop k is re-run as the baseRef...cur compare at hop k+1 (same ref pair), so a 5-hop carry costs 10 paginated compares where 6 would do. Harmless at today's volume (one carry per decided PR, cached), just noting it in case the walk ever gets hot.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read headIsBaseRefreshChainOf / mergeIsBaseRefreshOf against v5 (9941482) and walked the chain by hand. The walk is sound and fails closed; looks correct to me.

Verified:

  • Each hop is fetched once and must itself be an App-authored merge whose non-PR parent is the merge-base with baseRef and whose three-dot file set equals its first parent's (src/pkg/github/pr_decision_base_refresh.go:99-116, 126-160). Because equality is checked hop-to-hop, diff(newHead) == diff(oldHead) holds transitively when the walk returns true.
  • Intermediate hops always follow the first parent; the "either parent position" tolerance applies only when oldHead is one of the current commit's parents. A refresh merge whose first parent is on the base branch would make the walk step onto base commits and fail the merge-base check β€” fail-safe, not a false carry.
  • prev == cur and the single-parent content commit in TestDecisionCarrierRefusesChainBrokenByContentCommit both return false at the parent-count check; the depth bound test at baseRefreshMaxHops+1 confirms the cap.
  • BaseRefreshChecker cache key is still (number, oldHead, newHead), so a chain is evaluated once per decided/new head pair.

Info (non-blocking): each hop calls compareAllFiles for both cur and prev, and prev's compare at hop k is exactly cur's compare at hop k+1. A 5-hop chain costs 5 commit reads + 10 compares where 6 compares would do; threading prevFiles through the loop would halve it. Bounded, cached, and rare, so fine to land as-is.

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

@hivecommons-hive hivecommons-hive Bot removed the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added the stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) label Oct 30, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed β†’ 050-review-pending: required-check-pending:Sign-off survives the squash

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read src/pkg/github/pr_decision_base_refresh.go at 2781c1d end to end. The multi-hop walk is sound and each hop is verified with the unchanged single-hop predicate; looks correct to me.

  • Each hop compares baseRef...cur against baseRef...prev (both against the base tip), so file-set equality is transitive down the chain: diff(newHead) == diff(hop1) == … == diff(oldHead).
  • A content commit anywhere in the chain fails the len(Parents) != 2 check on the next GetCommit, and a non-App author fails CommitByGitHubLogin β€” both covered by TestDecisionCarrierRefusesChainBrokenByContentCommit and the broken hop in refreshChain.
  • prev == cur and baseParent == oldHead guards prevent a self-loop or a degenerate merge from passing.
  • Cost is bounded at 5 GetCommit + 10 compares per new head and cached by (oldHead, newHead).

One info-level nit, not blocking: the doc comment on headIsBaseRefreshChainOf says the either-parent tolerance for oldHead applies to "the first hop", but the oldHead == second check runs on every iteration. The behaviour is strictly more permissive-but-still-verified (the merge-base check still has to hold), so this is a comment/code mismatch rather than a defect.

Per #15766 the scope is exactly the multi-hop carry; the 5-hop bound is an engineering choice the issue left open and the chosen value is reasonable.

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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 30, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 60d2e33 into v5 Oct 30, 2026
75 of 77 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15766 branch October 30, 2026 16:26
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#15780c38dede` sha256:02bb0d837363d65a779445e49619980a063b42e1b685c4577981fae10154307d β€” download from the dashboard or `hivectl review evidence #15780`.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off 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.

Review backlog (correctness): Base-refresh carry is single-hop: two App refreshes before any gate reads the PR are not recognised

0 participants