Skip to content

πŸ› hold guard: accept a trusted merger's recorded approval of the current head - #15645

Merged
hivecommons-hive[bot] merged 22 commits into
v5from
fix/hold-guard-operator-approval
Oct 30, 2026
Merged

hivecommons-hive[bot] merged 22 commits into
v5from
fix/hold-guard-operator-approval

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #15644

Why

hive#15482 / #15487 / #15489 (base v6) sat behind the sentinel-alert gate; the contributor pushed 6c861c3 while gated. The operator then recorded Approve for that head via the dashboard/spoke API, and the hive removed sentinel-alert for them and admitted the lane (contributor-lane:operator-approval). Six minutes later the hold guard saw snapshot head β‰  current head, consulted only the timeline β€” where the lift is by hivecommons-hive[bot], which LiftCoversCurrentHead/LiftCoversObservedHead reject by design β€” and re-applied hold with a drift comment:

22:55:20 decision: unpark pr=15482 head=6c861c3 mode=approve by=clubanderson
22:57:50 contributor-lane admitted pr=15482 reason=contributor-lane:operator-approval admitted_by=clubanderson head=6c861c3
23:01:27 WARN hold guard: branch moved while hold-gated β€” blocking auto-merge recorded_head=5837b7af current_head=6c861c3
23:01:34 automerge skip pr=15482 reason=label:hold

The stage comment then tells the operator /hive approve does not remove hold, so the approval is silently nullified.

What

enforceHoldGuard now checks the head-scoped decision ledger (review.HumanChangeRequests, written by RecordOperatorPullRequestApproval) before the timeline: an approval recorded against the current head by a trusted merger (trustedMergerFunc) is the fresh review the guard asks for β€” clear the snapshot, no re-hold. An approval on the old head, by someone below the merger tier, or by an unlisted login still takes the drift path.

Tests

go test ./cmd/hive/ -run 'HoldGuard|MergeEligib' green; golangci-lint run ./cmd/hive/... clean on touched files.

…ent head

A dashboard Approve is recorded against the exact head the operator saw,
and the hive then removes the sentinel/hold gate label for them. The hold
guard only read the timeline, where that lift is by the hive's own
account and can never cover the head, so a contributor push during the
gate turned the operator's approval into a re-applied hold label six
minutes later (hive#15482/#15487/#15489).

Consult the head-scoped decision ledger before the timeline: an approval
on the current head by a trusted merger accepts the head; one on an older
head or by an untrusted actor still drifts.

Fixes #15644

Signed-off-by: Andrew Anderson <andy@clubanderson.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 nicholasjackson 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
@github-actions

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.

No conflicting open PRs or same-file overlaps were found.

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

Conclusion: looks correct to me. The new path is narrow, fails closed, and the ledger it reads has the semantics the fix relies on.

What I verified (read on v5 @ 5380ab4 plus this diff):

  • holdGuardOperatorApproval (src/cmd/hive/main_helpers.go:57-74) requires a record for the exact current head, IsApproval(), and trustedMergerFunc(cfg) on the actor. HumanChangeRequests.For (pkg/review/human_change_request.go:213-234) returns the newest entry at that head, and Record (:189-208) drops entries at other heads when a new head is recorded. So: an approval on the pre-push head cannot match; a later change request on the same head supersedes the approval and the guard falls through to the drift path. Both are what the second test asserts.
  • Key alignment: RecordOperatorPullRequestApprovalWith (pkg/github/pr_decision_operator.go:362-391) writes Repo: full (owner/name) and HeadSHA: head fetched at approval time; the guard looks up with fullRepoName(pr.Repo, org) (main_helpers.go:139), which is the same shape. The tests' acme/widgets vs Repo: "widgets" split exercises exactly that.
  • The new branch is placed after the existing continues and before the timeline read, so the previously-accepted cases (human lift after head, same-commit touch) are unchanged, and store.Clear mirrors what those branches already do.

One operational note, not a defect in this diff: the guard still never removes hold (main_helpers.go:232 only adds it), so #15482 / #15487 / #15489, which were already re-held by the old behaviour, will need hold taken off by hand once this merges β€” the fix only prevents the next re-hold.

The Sign-off survives the squash entries show both a cancelled and a passing run; everything else is pending, not red.

β€” 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

Choose a reason for hiding this comment

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

Decision needed: @clubanderson should confirm that a merger-tier dashboard Approve / /hive decision approve on the current head is meant to clear a sentinel-alert drift re-hold with the same weight as a human removing the gate label by hand (holdguard LiftCoversCurrentHead).

Read against the tree at 6e61bef (callers included). The change looks correct to me; the only thing left is a policy confirmation, since this widens what lifts a sentinel/hold gate.

What I verified

  • src/cmd/hive/main_helpers.go:56-73 holdGuardOperatorApproval reads store.For(repo, number, headSHA). review.HumanChangeRequests.For (src/pkg/review/human_change_request.go:213-234) returns the newest record on that exact head, so a later changes_requested decision on the same head wins over an earlier approve, and IsApproval() then fails closed. Record (:184-211) drops entries at other heads, so a push after the approve leaves nothing for For to find.
  • Repo key matches: the guard passes fullRepoName(pr.Repo, org) (main_helpers.go:170, main.go:10501), and both writers record owner/name (src/pkg/github/pr_decision_operator.go:384,492).
  • trustedMergerFunc (src/cmd/hive/merge_eligibility.go:34-45) requires RoleAtLeast(role, RoleMerger) against cfg.Dashboard.AuthorizedUsers; the three negative cases in TestEnforceHoldGuardOperatorApprovalMustCoverCurrentHeadByTrustedMerger map onto old head / sub-merger / unlisted login, which are the three ways the helper can return false besides an empty head.
  • Placement (main_helpers.go:196-208): after the head-unchanged and self-auth-hold short-circuits, before the timeline lookup, so the existing #13603 paths are untouched when no record exists.
  • Body matches diff; Fixes #15644 present; changelog fragment named fixed-… per changelog.d/README.md.

One observation, not a defect. RecordOperatorPullRequestApprovalWith (pr_decision_operator.go:357) records the live head at click time via openPullRequestHeadLabels, not the head rendered in the dashboard. That is pre-existing, but this PR is what makes that record sufficient to clear a sentinel drift re-hold, so a push landing between page render and click would be approved sight-unseen. Same exposure as a human removing the label after the push, so I read it as consistent with the existing LiftCoversCurrentHead trust level β€” flagging only so the owner decides with that in view.

I have not approved or changed anything.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm returned requires_human: it has a question for you, not a fix for the hive
  • the reviewer asked you: @clubanderson should confirm that a merger-tier dashboard Approve / /hive decision approve on the current head is meant to clear a sentinel-alert drift re-hold with the same weight as a human removing the gate label by hand (holdguard LiftCoversCurrentHead).

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@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 this against the tree rather than the diff alone; it looks correct to me and fails closed on every branch.

  • review.HumanChangeRequests.For (src/pkg/review/human_change_request.go:213-234) filters on exact HeadSHA and returns the newest record for that head, so a later /hive decision change request on the same head overrides an earlier Approve rather than the other way round. The extra EqualFold head check in holdGuardOperatorApproval is belt-and-braces on top of that.
  • repo reaching the new check is fullRepoName(pr.Repo, org) (main_helpers.go:174), which is the same owner/name key the decision ledger records under, so the lookup can actually hit.
  • The trust check is the same trustedMergerFunc(cfg) the merge lanes already use as MergerAuthorizer (main.go:2453, 9446, 10047) β€” no new notion of who counts as a merger.
  • Nil config, empty head, nil store, missing record, non-approval kind, untrusted actor all return ("", false) and fall through to the existing timeline path unchanged.

The table test covers the three ways it must not fire (old head, sub-merger tier, unauthorized login). Nothing further from me.

β€” 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

Choose a reason for hiding this comment

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

Decision needed: @clubanderson should confirm the hold guard may treat a decision-ledger approval (recorded against the live PR head at click time, main_helpers.go:63-72 / pr_decision_operator.go:357) by a merger-tier login as equivalent to a human lifting the gate after the current head arrived.

Read main_helpers.go, the new branch in enforceHoldGuard, pkg/review/human_change_request.go and pkg/github/pr_decision_operator.go at 422a9c2. The code does what it says and fails closed; I'm routing only because this relaxes a merge gate.

What I verified:

  • HumanChangeRequests.For (human_change_request.go:213-234) matches item.HeadSHA != head exactly, and Record (:195-209) drops every entry for the PR at other heads, so an approval on the pre-push head cannot cover the new one. The second test's "approval on the old head" case pins this.
  • holdGuardOperatorApproval (main_helpers.go:56-74) additionally requires IsApproval() and trustedMergerFunc(cfg) (merge_eligibility.go:34-45, role β‰₯ merger via AuthorizedRole), so a visitor:read-write or unknown actor never clears the snapshot.
  • The branch runs after the head-unchanged and self-auth-hold checks and before the timeline lift check, so existing paths are untouched; store.Clear mirrors them.

One nuance for the decision, not a defect in this diff: the PR comment says the approval is "recorded against the exact head the person saw", but RecordOperatorPullRequestApprovalWith resolves head from openPullRequestHeadLabels at click time (pr_decision_operator.go:357), not from what the dashboard rendered. A push landing between render and click would be approved under this path. That window already exists for the automerge consumers of the same record; this PR extends it to the hold guard.

β€” 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

Choose a reason for hiding this comment

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

Decision needed: @clubanderson should decide whether an approval the hive carried onto its own copy (carryAdmissionToCopy, recorded on a head the approver never opened) should also satisfy the hold guard, or whether holdGuardOperatorApproval should accept only approvals the person made directly (SourceID == operatorDecisionMarkerID or a /hive decision comment ID).

Read the diff against the tree at c14cdb0. The code does what it says and fails closed; the one thing I would not settle alone is which approval records should count, since this is a merge-gate widening.

Verified

  • main_helpers.go:206-212 sits after the head-unchanged and self-auth-hold branches and before the label-lift timeline, so it only ever adds an acceptance path; every existing path and the drift fallthrough are untouched.
  • holdGuardOperatorApproval (:56-73) requires, in order: non-empty head, a ledger record for exactly (repo, number, head) via HumanChangeRequests.For (review/human_change_request.go:213-233 returns the newest record for that head, so a later changes_requested on the same head wins), IsApproval(), and trustedMergerFunc(cfg)(actor) β€” the same authorizer the merge lanes use (main.go:2453,9446,10047,10092). A new head cannot match an old record, so a push after the Approve falls back to the drift path.
  • The dashboard Approve writer (pr_decision_operator.go:383-394) records Kind: Approve, Actor: actor, HeadSHA: head with head being what the person acted on, which is the case the issue describes.

The question for the owner

A third writer, automerge/automerge_operator_admission.go:119-123 (carryAdmissionToCopy), records a Kind: Approve decision on the hive's copy PR's head with the person's login as Actor, when they approved the adopted contributor PR. With this change that carried record also clears the hold guard on the copy, because nothing in holdGuardOperatorApproval distinguishes a direct approval from a carried one. That is arguably intended (the copy "carries that content unchanged") but it means the guard now trusts a hive-written assertion that two heads have the same content, which is a different proof than "the person approved this head". If that is acceptable, no change needed; if not, filtering on SourceID == operatorDecisionMarkerID or on a non-zero decision comment ID would restrict it to direct approvals.

Not a defect; flagging because the hold guard is a trust surface. I have not changed anything.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm returned requires_human: it has a question for you, not a fix for the hive
  • the reviewer asked you: @clubanderson should decide whether an approval the hive carried onto its own copy (carryAdmissionToCopy, recorded on a head the approver never opened) should also satisfy the hold guard, or whether holdGuardOperatorApproval should accept only approvals the person made directly (SourceID == operatorDecisionMarkerID or a /hive decision comment ID).

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

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

Security β€” delta re-review (head 5fc0756)

The delta since c14cdb0 is only the v5 merge commit; the PR's three files are unchanged. Re-checked the prior finding against the tree:

Carried approvals also lift the hold guard β€” still present in code, reassessed as not exploitable (advisory, non-blocking). holdGuardOperatorApproval (src/cmd/hive/main_helpers.go:66-71) accepts any Kind=approve record for the current head, including the ones carryAdmissionToCopy writes onto a hive copy's head (src/pkg/github/automerge/automerge_operator_admission.go:115-123) β€” a head the approver never looked at. But that record is written exactly once, at copy-PR creation, on the copy's first head (automerge_contributor_adopt.go:975-979), and the guard only consults the ledger on the drift path (main_helpers.go:180-185 clears on head-unchanged first). A hold snapshot on the copy can only be taken at or after that head, so the carried record can lift the guard only if the branch is force-pushed back to its creation SHA. If you want it fail-closed anyway, excluding carried records is a one-liner:

	if !ok || !req.IsApproval() || !strings.EqualFold(strings.TrimSpace(req.HeadSHA), headSHA) || strings.HasPrefix(req.Body, "approve (carried") {

Also noted, not a defect of this PR: the record binds to the live head at click time (src/pkg/github/pr_decision_operator.go:357,386), so the body's "exact head the person saw" holds only when nothing lands between dashboard render and click β€” the same exposure the existing human-lift timeline path already carries.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

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

HUMAN DECISION NEEDED β€” @clubanderson should an approval the hive carried onto its adoption copy (carryAdmissionToCopy) count as the operator's fresh review of the copy's head for the hold guard, or only approvals the person recorded against a head they saw?

Delta re-review (c14cdb0 β†’ 5fc0756): the delta is only Merge branch 'v5'; none of the PR's three files changed, so the one carried finding stands.

Still present β€” carried approvals also lift the hold guard (src/cmd/hive/main_helpers.go:58-74, read at 5fc0756)

holdGuardOperatorApproval accepts any ledger record with IsApproval() whose Actor is a trusted merger and whose HeadSHA equals the current head, and the doc comment calls it "proof the person reviewed the tree on the branch now". But carryAdmissionToCopy (src/pkg/github/automerge/automerge_operator_admission.go:115-128) writes exactly such a record β€” Source: Decision, Kind: Approve, Actor: <admitting merger> β€” against the hive copy's head (automerge_contributor_adopt.go:979: created.GetHead().GetSHA() / resignedTip), a tree the person never opened: it is the contributor's admitted head after the hive's DCO re-sign / force-push onto a replayed open copy (adopt.go "adoption claim replayed an open App PR"). The record carries no marker the guard can use; only Body starts with "approve (carried from #…". So a hold-gated copy whose head the hive moved to the carried SHA gets its snapshot cleared with no re-hold and no drift comment. Exposure is narrow (later fixer commits move the head off the carried SHA, and label:hold itself still blocks the lane), and #15644 does not address carried approvals either way β€” hence the question above rather than a verdict against it.

If carried approvals should not satisfy the guard, a concrete route is to tag them in the ledger and have the guard refuse them:

--- a/src/pkg/review/human_change_request.go
+++ b/src/pkg/review/human_change_request.go
@@ type HumanChangeRequest struct {
 	Kind string `json:"kind,omitempty"`
+	// Carried marks an approval the hive copied from another head on the
+	// person's behalf; the person did not review this head.
+	Carried bool `json:"carried,omitempty"`
--- a/src/pkg/github/automerge/automerge_operator_admission.go
+++ b/src/pkg/github/automerge/automerge_operator_admission.go
@@ func (c *Engine) carryAdmissionToCopy(
-		Body: fmt.Sprintf("approve (carried from #%d head %s)", obs.Number, shortSHA(obs.HeadSHA)), Kind: review.HumanChangeRequestKindApprove, RecordedAt: now,
+		Body: fmt.Sprintf("approve (carried from #%d head %s)", obs.Number, shortSHA(obs.HeadSHA)), Kind: review.HumanChangeRequestKindApprove, Carried: true, RecordedAt: now,
--- a/src/cmd/hive/main_helpers.go
+++ b/src/cmd/hive/main_helpers.go
@@ func holdGuardOperatorApproval(
-	if !ok || !req.IsApproval() || !strings.EqualFold(strings.TrimSpace(req.HeadSHA), headSHA) {
+	if !ok || !req.IsApproval() || req.Carried || !strings.EqualFold(strings.TrimSpace(req.HeadSHA), headSHA) {

plus one table row in TestEnforceHoldGuardOperatorApprovalMustCoverCurrentHeadByTrustedMerger with Carried: true expecting re-hold. If carried approvals should count, say so in the doc comment at main_helpers.go:50-57 and this is approvable from the correctness side.

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

@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 new branch against the ledger it depends on; it looks correct to me and fails closed on every path I could find.

  • src/cmd/hive/main_helpers.go:56-72 holdGuardOperatorApproval: review.HumanChangeRequests.For (src/pkg/review/human_change_request.go:213-233) returns the newest record at the exact head, and Record (:189-210) drops every record for the PR at other heads. So a later CHANGES_REQUESTED on the same head overrides an earlier approval (IsApproval() false β†’ rejected), and any push supersedes the approval entirely. The extra EqualFold on req.HeadSHA is redundant with For's exact match but harmless.
  • The Actor the guard trusts is a GitHub login at all three recording sites: automerge_human_changes_requested.go:107 (SafeGetLogin(approval.GetUser())), pr_decision_operator.go:391 (dashboard actor, head read live via openPullRequestHeadLabels at :357), and automerge_operator_admission.go:120. trustedMergerFunc(cfg) is then applied on top, so an untrusted commenter's /hive decision approve cannot satisfy the guard.
  • Placement at :204-210 mirrors the existing trusted-lift acceptance (store.Clear + info log + continue, :226-240) and runs before the GitHub timeline lookup, so it also works when ghClient is nil.

One interaction worth stating for the record, not a defect: carryAdmissionToCopy (automerge_operator_admission.go:115-123) records a decision-approval on the hive's adopted copy at the copy's head. With this PR that carried record also satisfies the hold guard on the copy, which is consistent with the carry's stated premise (identical content), but it means a human approval on a fork PR now releases the copy's hold without anyone having touched the copy. If that is intended, nothing to change.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

stage 060-reviewed β†’ 050-review-pending: check-pending

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

Decision needed: @hanthor should decide whether a hive-recorded head-keyed approval (dashboard Approve / /hive decision approve) by a trusted merger is sufficient for the hold guard to accept a head that moved while sentinel-alert/hold-gated, replacing the human-performed label lift the guard required until now.

Routing this to a second approver because it changes what the hold guard (#5589) accepts as proof of review on a sentinel-gated PR β€” a trust decision, not a code defect. The author is already an approver in OWNERS; a second approver should sign off.

What I verified in the tree (branch dc665f0):

  • holdGuardOperatorApproval (src/cmd/hive/main_helpers.go:56-74) looks up review.HumanChangeRequests.For(repo, number, headSHA), which returns the newest record for that exact head (src/pkg/review/human_change_request.go:213-227), so an approve followed by a change request on the same head fails closed (IsApproval, :79-81). It then requires trustedMergerFunc(cfg)(actor) (src/cmd/hive/merge_eligibility.go:34-45, dashboard role β‰₯ merger). No record / untrusted actor / empty head β†’ false.
  • The new branch in enforceHoldGuard (main_helpers.go:204-210) runs after the head-unchanged and self-auth-disabled checks and before the timeline-based LiftCoversCurrentHead path, so the existing human-lift logic is untouched when there is no record.
  • Actor is populated with the decision's login in RecordOperatorPullRequestApprovalWith (src/pkg/github/pr_decision_operator.go:351-391). One other writer exists: carryAdmissionToCopy (src/pkg/github/automerge/automerge_operator_admission.go:113-130) records an approve on a hive adoption copy's head on behalf of the person who approved the original β€” same content by construction, and any later merge-from-base push gives the copy a new SHA the record no longer covers. Worth knowing when answering the question above, since under this PR that carried record would also satisfy the hold guard.
  • Builds (go build ./cmd/hive/ OK). Tests TestEnforceHoldGuardOperatorApprovalOnCurrentHeadAcceptsHiveLift / ...MustCoverCurrentHeadByTrustedMerger (hold_guard_test.go:1047, :1080) cover the accept path and the fail-closed paths.

No code findings. The diff matches the body's account of the #15482 timeline.

β€” 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

Choose a reason for hiding this comment

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

HUMAN DECISION NEEDED β€” @clubanderson confirm the merge-trust policy change: enforceHoldGuard now accepts a head-keyed approval from the on-disk decision ledger (src/cmd/hive/main_helpers.go:57-72, :199-209) as the "fresh review" that clears a hold snapshot, bypassing the timeline check.

Delta re-review (b196ac0 β†’ 26663de): the six new commits are three Merge branch 'v5' merges (#15617, #15714, #15582) and touch none of the PR's own files or the hold-guard path (main_sweeps.go delta only changes promotion warn-once logging). The PR's main_helpers.go / hold_guard_test.go / changelog hunks are byte-identical to the previous head.

Previous in-scope finding β€” merge-trust policy change authored by the repository owner (main_helpers.go:199) β€” still present; it is what #15644 asks for, so intent alignment is fine, but the policy itself needs a human sign-off. No new findings from this perspective.

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

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

HUMAN DECISION NEEDED β€” @clubanderson: unchanged since b196ac0 β€” whether the hold guard may trust the on-disk decision ledger (review.HumanChangeRequests) plus trustedMergerFunc as a substitute for a timeline review on the current head (src/cmd/hive/main_helpers.go:44-199) is a merge-trust policy call only a maintainer can own.

Delta re-review (docs-currency) at 26663de: the delta is three Merge branch 'v5' commits (#15582, #15617, #15714); the PR's own files (changelog.d/fixed-hold-guard-operator-approval.md, src/cmd/hive/main_helpers.go, src/cmd/hive/hold_guard_test.go) are byte-identical to the previously reviewed head. Prior findings: still present (code untouched). No new documentation findings β€” src/docs/security-model.md:231 and src/docs/operator-reference.md:1111 remain accurate for the new behavior.

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

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

HUMAN DECISION NEEDED β€” @clubanderson: confirm that a head-keyed Approve in the on-disk decision ledger (review.HumanChangeRequests) by a trustedMergerFunc login is sufficient to clear a hold-guard drift without any forge-side evidence (merge-trust policy).

Delta re-review at 26663de6 (security). The six commits since b196ac0b are v5 merge-ins (#15617, #15714, #15582); none touch src/cmd/hive/main_helpers.go or any trust check added by this PR, and the merged hunks (automerge_stage_labels.go, automerge_merge_commit.go, warn_once_pr.go, prompts.go) introduce no new permission, token, or injection surface. No new findings in the delta.

Prior findings at the new head:

  • [security] src/cmd/hive/main_helpers.go:56-74 (holdGuardOperatorApproval) β€” still present. The guard now short-circuits on store.For(repo, number, headSHA) + trustedMergerFunc before consulting the GitHub timeline (main_helpers.go:130-136). This is the fix #15644 asks for, but it moves the hold guard's trust root from unforgeable forge events to the hive's own on-disk ledger; anyone able to write that ledger (dashboard/spoke API path, or the filesystem) can clear a drift hold for a trusted merger's login. Fails closed on missing/non-approval/untrusted records, so the remaining question is policy, not a bug.
  • [intent-alignment] main_helpers.go merge-trust policy change by the repository owner β€” still present, same human call as above.

β€” 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

Choose a reason for hiding this comment

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

HUMAN DECISION NEEDED β€” @clubanderson whether the hold guard may accept a merger's on-disk decision-ledger approval as the fresh review that clears branch drift (merge/trust policy; unchanged since the prior review).

Correctness, delta re-review (b196ac0 β†’ 26663de): the delta is three Merge branch 'v5' commits (#15617, #15714, #15582). src/cmd/hive/main_helpers.go, src/cmd/hive/hold_guard_test.go and the changelog fragment are blob-identical at both heads, and none of the merged hunks reference enforceHoldGuard, holdGuardOperatorApproval, HumanChangeRequests or trustedMergerFunc. No new correctness findings from the delta.

Prior findings re-checked at 26663de: both still present (the code they cite is unchanged β€” main_helpers.go:44 ledger resolver, main_helpers.go:199-205 early continue on a recorded approval).

β€” 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

Choose a reason for hiding this comment

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

Decision needed: @clubanderson should decide whether a hive-carried approval (carryAdmissionToCopy, automerge_operator_admission.go:116-122, written by the hive with the human's login as Actor) should satisfy the hold guard's new head-scoped approval check, or whether the guard should accept only approvals the person recorded directly against the head.

Read the code first; it does what the body says. holdGuardOperatorApproval (src/cmd/hive/main_helpers.go:57-76) resolves the ledger via review.HumanChangeRequests.For (src/pkg/review/human_change_request.go:213-233), which already filters on exact HeadSHA and returns the newest record, so the extra EqualFold on req.HeadSHA is belt-and-braces, not a gap. The check sits after the head-unchanged fast path and the #5117 self-auth skip (main_helpers.go:178-195) and before the timeline lookup, which is the right order for the #15482 shape: a hivecommons-hive[bot] lift can never cover the head, so the approval record is the only evidence that can. Fails closed on nil cfg/store, empty head, non-approve kind, and untrusted actor via trustedMergerFunc β€” the same authorizer the merge lanes use (main_sweeps.go:818).

One open question for the owner, not a defect: the ledger has three writers of Kind: approve. Two are the person's own act on that head (dashboard//hive decision approve; a GitHub APPROVED review, automerge_human_changes_requested.go:104-109). The third is carryAdmissionToCopy (automerge_operator_admission.go:116-122), where the hive records an approval on a supersede copy's head with Actor: login β€” the human never looked at that head. With this change the hold guard will accept such a head too. That is probably what you want (the copy carries the approved content unchanged), but it widens "a trusted merger approved exactly this head" to "…or the hive carried their approval onto this head", and the hold guard is a trust gate, so I'd rather you say so explicitly than have me assume. If carried approvals should count, a one-line note in the holdGuardOperatorApproval doc comment would close the question.

Tests cover the hive-lift + current-head approval, old-head approval, read-write actor and unlisted actor paths; I could not run them here (go test is disabled on agent pods), CI is still in progress at 5c867d2.

β€” 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

Choose a reason for hiding this comment

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

Decision needed: @clubanderson (as repo owner) should confirm that a head-scoped dashboard//hive decision approve by a trusted merger is meant to satisfy the hold guard outright, bypassing the lift-timeline check, before this merge-policy change lands.

Code read looks correct; routing because this changes the hold guard, which is merge-trust policy, so the policy choice should be a person's signature rather than mine.

What I verified

  • src/cmd/hive/main_helpers.go:57-74 holdGuardOperatorApproval fails closed as described: review.HumanChangeRequests.For (src/pkg/review/human_change_request.go:213) returns only the newest record for the exact (repo, number, head), so a later changes_requested on the same head supersedes an earlier approve (IsApproval() β†’ false); the head is compared again with EqualFold; actor must pass trustedMergerFunc(cfg) β€” the same authorizer the merge lanes use (main.go:2053, main_sweeps.go:818). An approval on the old head cannot match because the ledger is keyed by head.
  • Placement at main_helpers.go:199-210: runs after the head-unchanged fast path and the #5117 self-auth skip, before the timeline consult, and only for PRs that already left the gate (actionable.PRs.Items with a snapshot). So it adds an acceptance path; it removes none.
  • Test src/cmd/hive/hold_guard_test.go covers approve-on-current-head / approve-on-old-head / untrusted actor.

The decision is not whether the code does what the body says (it does) but whether the hive's own decision ledger should count as the fresh review the guard asks for. Today the guard deliberately rejects lifts by the App bot; this makes an operator click upstream of that lift authoritative. That is a reasonable answer to the #15482 trace in the body β€” I just should not be the one who settles it.

Scope note: the #15603 half of this PR (pr_empty_diff_hive_autoclose.go, its test, and changelog.d/fixed-15603-empty-diff-head-age.md) is byte-identical to #15621 (git diff pr15621 pr15645 -- <those files> is empty). Once #15621 merges this PR should rebase to its #15644-only shape; if #15621 is closed instead, this PR carries that fix alone. Not a conflict either way, but worth knowing which one is meant to own #15603.

CI on this head is still in progress (25 checks unconcluded, 30 green, none failed) β€” blocked is the pending state, not a red run.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm returned requires_human: it has a question for you, not a fix for the hive
  • the reviewer asked you: @clubanderson (as repo owner) should confirm that a head-scoped dashboard//hive decision approve by a trusted merger is meant to satisfy the hold guard outright, bypassing the lift-timeline check, before this merge-policy change lands.

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

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

Decision needed: @hanthor should confirm the hold guard may treat a head-exact approval in the hive decision ledger by a trusted merger as sufficient review of a moved head, in place of a human timeline lift.

Read the code; it looks correct to me and fails closed. Routing only because it widens merge-trust policy.

  • src/cmd/hive/main_helpers.go:56-73 reads review.DefaultHumanChangeRequests() β€” the same process-wide store the dashboard Approve writes through RecordOperatorPullRequestApprovalWith (src/pkg/github/pr_decision_operator.go:383-395) with the full API head SHA, so the lookup key matches the enumerated pr.HeadSHA.
  • HumanChangeRequests.For (src/pkg/review/human_change_request.go:213-233) matches head exactly and Record drops entries for other heads, so a push after the approval invalidates it; the extra EqualFold guard in the new helper is redundant but harmless.
  • Refuses on nil cfg/store, non-approval kind, blank head, or an actor trustedMergerFunc rejects β€” /hive decision approve from an untrusted commenter (pr_unpark_decision.go:91-97) cannot clear the hold.
  • The new branch sits before the timeline check in enforceHoldGuard (main_helpers.go:199-210) and otherwise leaves the drift path untouched; the new test exercises the hive-lift timeline that LiftCoversCurrentHead rejects.

Policy point for a maintainer: previously the guard accepted a moved head only on unforgeable GitHub evidence (a human removing the gate label after the head arrived). This adds the hive's own decision ledger as a second source of truth. That is the fix #15644 asks for, but it is a trust-surface change and should be a deliberate choice.

β€” 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

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-4 backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

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

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-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

Reviewed β€” no findings from this perspective.

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

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

Decision needed: @clubanderson should confirm the hold guard may accept a head-keyed dashboard//hive decision Approve by a merger-tier login as the fresh review for a moved head, instead of requiring a human-authored gate lift in the timeline.

Read the change against the tree; the mechanism holds and it fails closed. Routing to a human only because this widens what the hold guard accepts as "reviewed", which is merge-trust policy.

What I verified

  • src/cmd/hive/main_helpers.go:56-73 (holdGuardOperatorApproval): requires a ledger entry for exactly (repo, number, currentHead), IsApproval() true, and trustedMergerFunc(cfg)(actor). review.HumanChangeRequests.For (src/pkg/review/human_change_request.go:213-234) only returns entries whose HeadSHA equals the queried head and picks the newest, so a later change request on the same head overrides an earlier Approve. Record (:189-209) drops entries for other heads, so an Approve on the old head can never match the new one. trustedMergerFunc (src/cmd/hive/merge_eligibility.go:35-45) fails closed on nil cfg / unlisted login / below-merger role.
  • Placement (main_helpers.go:199-210) is after the head-unchanged fast path and before the timeline lift check, so the existing LiftCoversCurrentHead / LiftCoversObservedHead paths are untouched for every PR without a ledger approval; the drift path remains the fall-through.
  • The ledger entry is written by RecordOperatorPullRequestApprovalWith (src/pkg/github/pr_decision_operator.go:383-396) with Kind: approve, the actor login, and the head read live from GitHub at approval time. The dashboard handlers call it only after the role gate, and the guard re-checks the role anyway.
  • Tests exercise both the accepted shape and the three rejections (old head, read-write actor, unlisted actor), swapping the store via the new holdGuardHumanChangeRequests seam.

Open question (not a defect): the recorded head is whatever GitHub reports when the Approve is processed, not necessarily the head rendered in the dashboard when the person clicked. A push racing the click would be approved under this path. The existing timeline path has the same window, so this is not a regression, but worth knowing when reading the new log line.

Body and diff agree; the #15482 log trace in the body matches the code path that was re-holding.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm returned requires_human: it has a question for you, not a fix for the hive
  • the reviewer asked you: @clubanderson should confirm the hold guard may accept a head-keyed dashboard//hive decision Approve by a merger-tier login as the fresh review for a moved head, instead of requiring a human-authored gate lift in the timeline.

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

@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 guard, the ledger and the record producers; the new acceptance path looks correct to me and fails closed where it should.

  • src/cmd/hive/main_helpers.go:57-72 (holdGuardOperatorApproval) looks up store.For(repo, number, headSHA); src/pkg/review/human_change_request.go:213-234 returns only the newest record whose HeadSHA equals the current head exactly, and Record (:104-107) drops entries for the PR at other heads, so an approval on the pre-push head cannot satisfy it. IsApproval() (:79-81) excludes change requests; trustedMergerFunc(cfg) excludes non-merger actors.
  • The record this path consumes is actually written in production: dashboard Approve / /hive decision approve records Source: decision, HeadSHA: head, Actor: actor, Kind: approve at src/pkg/github/pr_decision_operator.go:382-394; a trusted GitHub APPROVED review on the same head is recorded at automerge_human_changes_requested.go:104-110; the adopt-copy carry at automerge_operator_admission.go:118-122 is deliberately bound to the copy's own head with unchanged content. All three are head-scoped approvals by a trusted person, so accepting them here is consistent with their existing meaning.
  • The check sits at main_helpers.go:204-210, after the hive-authored / same-head early-continues and before the timeline read, so it only changes outcome for the exact case in #15644 (hive lifted the label on a human's behalf).

Tests cover the accept case and the three fail-closed cases (old head, below-merger tier, unauthorized actor). Nothing further from me.

β€” 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

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 at f35b154 against v5 7f936ee).

What I verified:

  • holdGuardOperatorApproval (src/cmd/hive/main_helpers.go:57-72) is placed after the head-unchanged and self-auth-disabled branches and before the label-timeline check, so it only runs on a lifted hold whose head moved β€” the case #15644 describes.
  • The store contract holds: HumanChangeRequests.Record drops entries for the same PR at other heads (src/pkg/review/human_change_request.go:196-205), and For matches on exact HeadSHA (:222), so a stale approval on an older head cannot satisfy the guard; the extra EqualFold on req.HeadSHA is belt-and-braces.
  • The dashboard Approve writes Kind: approve with Repo: owner/name and Actor: <login> (src/pkg/github/pr_decision_operator.go:383-392); the guard looks up with fullRepoName(pr.Repo, org) (main_sweeps.go:1873), so the keys line up. Actor is then gated by trustedMergerFunc(cfg), so an approval recorded for an untrusted login is ignored β€” covered by TestEnforceHoldGuardOperatorApprovalMustCoverCurrentHeadByTrustedMerger.

One consequence worth knowing, not a defect: carryAdmissionToCopy (src/pkg/github/automerge/automerge_operator_admission.go:114-125) also records a Kind: approve decision β€” on the hive's copy PR, at the copy's head, under the original approver's login. With this change that carried approval also satisfies the hold guard on the copy. That is consistent with the carried approval's existing meaning ("stands for the content"), but it means the guard now trusts the copy's head was produced faithfully by the adopt path rather than by a human reading it.

β€” 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

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

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-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

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

Reviewed β€” no findings from this perspective.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 390b92d into v5 Oct 30, 2026
72 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/hold-guard-operator-approval branch October 30, 2026 10:08
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#1564585b3ed7` sha256:312ccab5fb1c9748dde2231c739a22b87e872c409789dad446c61022841a47d4 β€” download from the dashboard or `hivectl review evidence #15645`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 85b3ed7.

@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

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.

hold guard re-applies hold over a dashboard Approve when the hive lifted the sentinel gate for the operator

1 participant