Repository navigation
Conversation
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.
Looks correct to me. Read on head 0fd4bf5 (based on v5 tip 390b92d, i.e. on top of #15645 which #15698 was blocked on β the merge is clean).
What I verified:
- The only writer of a carried approval is
carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:115-123), whoseBodyisfmt.Sprintf("approve (carried from #%d head %s)", β¦)withKind: HumanChangeRequestKindApproveandSource: β¦Decision. There is no structured "carried" field onreview.HumanChangeRequest(src/pkg/review/human_change_request.go:57-75), so the prefix test atsrc/cmd/hive/main_helpers.go:69-73is the only discriminator available without widening the record β and it is what #15698 proposed. - It sits after the head/kind check and before the trusted-merger check, so it only narrows the lift path; ordinary decision approvals (
Body == "approve") and review-event approvals are unaffected. Other consumers of the ledger (the lanes reading a carriedrequires_humanas answered) are untouched. - The new table case
carried approval on the current head(hold_guard_test.go:1086) records a carried body onp1by an owner and asserts the drift path still stands; without the new guard that case lifts the hold, so the test fails without the change.
One maintainability note, not a defect: the producer format string and the consumer prefix now live in two packages with nothing tying them together. If someone reworded the Sprintf in automerge_operator_admission.go:122, the guard would silently start accepting carried approvals again. A shared constant (e.g. exported from review alongside the kinds) would make that drift a compile error; fine as a follow-up if you'd rather keep this PR minimal. The Sign-off survives the squash check shows CANCELLED, which doesn't look related to the diff.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether a carried adoption approval may lift a drifted hold on the hive's copy, or only a direct head-scoped approval may (this PR) β carryAdmissionToCopy's doc says the carried approval "stands for the content" while this guard says it does not.
Conclusion: the code is correct, fail-closed and matches the body's "defense-in-depth, not a practical exploit" framing. I'm routing it rather than calling it done because it changes merge-hold policy, and the two places in the tree now disagree on what a carried approval means.
Verified at head 0fd4bf5 against v5 390b92d88:
- The prefix check
strings.HasPrefix(req.Body, "approve (carried")(src/cmd/hive/main_helpers.go:71) matches the only writer exactly:carryAdmissionToCopyrecordsBody: fmt.Sprintf("approve (carried from #%d head %s)", β¦)atsrc/pkg/github/automerge/automerge_operator_admission.go:122. No other code emits that body. - The check sits after the head/approval match and before the trusted-merger check, so it narrows an existing accept path (
main_helpers.go:204caller) and cannot widen anything. Existing cases inTestEnforceHoldGuardOperatorApprovalMustCoverCurrentHeadByTrustedMergerare unchanged; the new case records the carried body on the current head and expects the drift path to stand, which is the one behaviour the diff adds. - Policy tension worth the maintainer's one-line answer:
automerge_operator_admission.go:111-114andadoptionCarriedApprovalNote(automerge_contributor_adopt.go:1106-1111, "the approval travels with the content") document the carried record as standing for the approved tree, and the copy is opened when the original isconflicting/needs-rebase/DCO-missing (headNotMergeableAsIs,:96-109), i.e. precisely when the fixer will re-author it. This PR says a carried record is never evidence a person reviewed the copy's head. Both are defensible; they should not both be in the tree with contradictory comments.
Suggestion (not a defect): the writer and this reader now share a bare string literal across two packages. If the writer's wording ever changes, this guard silently re-opens. A shared exported constant (e.g. in pkg/review next to HumanChangeRequestKindApprove) used by both sides would make that impossible β small follow-up or fold it in here.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Needs a decision, not a merge:
Head: verdict requires_human @0fd4bf5, 57/57 checks green, DCO yes, soak 17m0s of 30m0s. How to release it:
Clear the cause and the hive re-evaluates on its next pass; the stage moves to |
|
stage 095-pre-merge-soak β 085-needs-decision: contributor-lane:decision-requested |
|
/lgtm Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
|
@hivecommons-hive[bot]: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/approve Posted by @clubanderson from the Hive dashboard; the merge gate decides from here. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hivecommons-hive[bot] 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 |
There was a problem hiding this comment.
Looks correct to me, and it is the hardening #15698 asked for. Read the tree at c110880:
- The only writer of carried approvals is
carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:122), whose body isfmt.Sprintf("approve (carried from #%d head %s)", β¦)β so thestrings.HasPrefix(req.Body, "approve (carried")check atsrc/cmd/hive/main_helpers.go:71matches exactly that record and nothing a person types via the dashboard//hive decision approvepath. The check sits after the head/kind match and before the trusted-merger check, so it fails closed as the doc comment says. - Agreed with the issue that this is defence in depth: the guard only consults the ledger on the drift path (
main_helpers.go:183-185clears a head-unchanged lift first), so a carried record could lift a hold only if the branch returned to its creation SHA. - The new table case (
hold_guard_test.go, "carried approval on the current head") would fail without the change β the actor is in the merger tier and the head matches, so only the body prefix rejects it.
One suggestion, not a defect: the marker now lives as a literal in two packages (automerge_operator_admission.go:122 and main_helpers.go:71). If someone later rewords the carried body, the guard silently goes back to accepting carried approvals with no test catching it (the hold-guard test builds its own body string). Exporting a single constant from pkg/review (e.g. review.CarriedApprovalBodyPrefix) and using it in both places β and in the test β would make that coupling visible. Fine to do as a follow-up.
Changelog fragment security-15698-carried-hold-approval.md matches the <category>-<pr-or-slug>.md rule. Could not run go test in this pod (blocked for agents).
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Traced the path before reading the body. holdGuardOperatorApproval is only consulted from main_helpers.go:204, after the head-unchanged clear at :178-185, so a carried record can only lift a hold when the branch is back on the copy's creation SHA while the hold snapshot names a different head β the force-push-back case #15698 describes. The new guard at main_helpers.go:69-73 closes that exactly as the issue prescribes, and the writer at src/pkg/github/automerge/automerge_operator_admission.go:122 emits "approve (carried from #%d head %s)", so the approve (carried prefix matches today. The new table case fails without the change (same head p1, trusted owner, approval kind) and the three existing cases are unchanged. Looks correct to me.
One maintainability note, not a defect: the writer and the reader are now coupled by a string literal in two different packages with no shared constant. A rewording of the carry body β or a second carry site β would silently reopen the gap, and nothing would fail. If you want to harden it cheaply, export the prefix from review (or mark the record with a dedicated field/Source) and have both sides use it. Fine to land as-is given the issue rates the exposure negligible.
Note for the maintainer: #15698 still carries <!-- hive:blocked-on pr=hivecommons/hive#15645 -->; this PR targets v5 directly, so whichever merges first, the other needs a rebase check on main_helpers.go.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 095-pre-merge-soak β 060-reviewed: check-pending |
|
stage 060-reviewed β 050-review-pending: required-check-pending:build-and-test |
There was a problem hiding this comment.
Looks correct to me, and it is the hardening #15698 specifies verbatim ("exclude bodies prefixed approve (carried"). Read the v5 tree at 57da949:
- The only writer of that body is
carryAdmissionToCopyatsrc/pkg/github/automerge/automerge_operator_admission.go:122:fmt.Sprintf("approve (carried from #%d head %s)", β¦), so the prefix check atsrc/cmd/hive/main_helpers.go:71matches every carried record and nothing else in the tree. - The check sits after the existing head-match and
IsApproval()gates (main_helpers.go:66) and before the trusted-merger check, so the fail-closed order is preserved; direct dashboard //hive decision approverecords still lift as before (TestEnforceHoldGuardOperatorApprovalOnCurrentHeadAcceptsHiveLiftis untouched). - The new table case records the carried body on the current head
p1, which is the one path the old code let through; the other three cases are unchanged.
One suggestion, not a defect: the reader and the writer now agree on a literal in two packages with no shared symbol. An exported prefix constant next to HumanChangeRequestKindApprove in src/pkg/review/human_change_request.go, used by both automerge_operator_admission.go:122 and main_helpers.go:71, would stop a future wording tweak from silently reopening this. Fine to land as-is and do that in a follow-up.
The changelog.d/security-15698-β¦ fragment uses an allowed category prefix. Could not run go test in this pod (blocked for agents).
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Looks correct to me, and it does exactly what #15698 prescribes.
What I verified (v5 tree + diff):
- The only producer of carried approvals is
carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:122), which writesBody: "approve (carried from #%d head %s)"withKind: approve. The newstrings.HasPrefix(req.Body, "approve (carried")check atsrc/cmd/hive/main_helpers.go:71matches that and nothing else β dashboard Approve and/hive decision approverecords keep their bareapprovebody and still lift the hold. - The check sits after the head-match guard and before the trusted-merger check, so it only narrows an already head-scoped lookup; the fail-closed ordering described in the doc comment is preserved.
- The new table case in
hold_guard_test.go:1087records a carried body on the current head (p1) by an owner-tier actor and asserts the re-hold, so it fails without themain_helpers.gochange. The other three cases are unchanged in behaviour.
One suggestion, not a blocker: the "approve (carried" prefix is now a load-bearing magic string in two packages (automerge writes it, cmd/hive matches it). If someone rewords the carry body the guard silently reopens. A shared constant (e.g. review.HumanChangeRequestCarriedPrefix) or a dedicated Source/flag on review.HumanChangeRequest would make that coupling visible. Fine as a follow-up given the issue already chose the prefix approach.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
@mendezr this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Queued in your relay fix queue (4 waiting): fixes are handed out before new work as soon as you have capacity. |
There was a problem hiding this comment.
Looks correct to me. Read the tree at b6dad30, not just the diff:
- The record this guards against is written by
carryAdmissionToCopyatsrc/pkg/github/automerge/automerge_operator_admission.go:122with bodyfmt.Sprintf("approve (carried from #%d head %s)", β¦), so thestrings.HasPrefix(req.Body, "approve (carried")check atsrc/cmd/hive/main_helpers.go:71matches the only producer of that body shape. - The check sits after the
IsApproval()/ head-equality test and before the trusted-merger test, so a carried record now falls through to the existing drift path atmain_helpers.go:211+(gate-lift provenance, then hold). Fail-closed is preserved; nothing else inholdGuardOperatorApproval's single caller (main_helpers.go:204) changes. - Issue #15698 was blocked on #15645; that PR is merged on
v5and this diff applies on top of it cleanly (mergeable: MERGEABLE), so theconflicts-with-open-prlabel looks stale. - The new table case
carried approval on the current headrecords a body-bearing approval on headp1and asserts the hold stands β it fails without the production change.
One non-blocking suggestion: the prefix is now duplicated across two packages as a bare literal. If someone reformats the body in carryAdmissionToCopy, this guard silently stops matching and the hardening quietly disappears. A shared constant (or a review.HumanChangeRequest.IsCarried() helper the writer and reader both use) would make that drift a compile error instead. Fine to land as-is given the issue's own "not exploitable" assessment.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
@mendezr the hive has adopted this PR ( |
|
stage 080-awaiting-merge-admission β 074-adopted-by-hive: optional-check-failing:docker (hive) |
β¦15755) When require_current_base merges the base branch into a hive-authored PR, the new head differs only by the App's merge commit and the PR's diff vs base is unchanged. The operator's recorded decision (approve / queue-merge / adopt / direction) was head-scoped and so was dropped, the reviewer route saw decision_answered=false, and the PR re-parked at stage/085-needs-decision (seen on #15649). Add BaseRefreshChecker / DecisionCarrier in pkg/github: a new head is a base refresh iff it is a two-parent merge commit authored by the App, one parent is the old head, the other is the merge-base with the base branch, and base...old and base...new change the same files with the same patches. Only then is the recorded decision copied to the new head (CarriedFromHead set) and one INFO 'decision carried over base refresh' logged. Applied in the reviewer-verdict fold, the automerge review gate, operator admission and the hold guard's operator-admission path. GitHub review approvals never carry, keeping #15722 intact. Fixes #15751 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Keep copied operator admission from standing in for review of a drifted head. Add regression coverage that requires a re-hold despite a carried approval by a trusted merger. Hive-Run: hivecommons#15698 Hive-Plan: carried-approval-hardening Hive-Spec: hivecommons#15698#exclude-carried-approvals Signed-off-by: mendezr <mendezr@users.noreply.github.com>
b6dad30 to
9b049ae
Compare
β¦ adopted PRs go to the fixer (#15816) * π decide plan: read recorded park reasons, pending CI is not red, adopted PRs go to the fixer The "Let hive decide" preview for #15722 said "make CI green" / "CI is red" of a PR with every check green: GitHub reports mergeable_state "unstable" when any context β the non-required tide included β is pending, and the plan treated anything but clean as red without reading the checks. It also ignored the stage record's reasons (reviewer requires_human, high-risk) and had no notion of a PR the hive adopted in place, so it offered to send the hive's own branch back to the contributor. - delegatedHeadCI inspects the head's checks: red only when one failed, pending while running; Input.CIPending / CIRed() carry that through the policy, ladder, blockers and glossary effect. - gather reads the stage record (reasons, adoption) and the review verdict artifact; the WHY names the recorded park reason. - New rules adopted-fixer / adopted-security-finding: an adopted PR's finding goes to the hive's fixer (no action needed); a security finding stays a person's call, named in full. - Regression test: red CI on a clanker PR routes 072, never 085. Signed-off-by: Andrew Anderson <andy@clubanderson.com> * test: give the adopted-PR plan test its own stage store Signed-off-by: Andrew Anderson <andy@clubanderson.com> --------- Signed-off-by: Andrew Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
Read holdGuardOperatorApproval and both writers of approval records at the reviewed head (5b5346f). This looks correct to me.
automerge_operator_admission.go:123is the only place that writesapprove (carried from #%d head %s), so the prefix test atmain_helpers.go:74catches exactly the adoption carry and nothing else.- The base-refresh carry (
pr_decision_base_refresh.go:297) copies the record body unchanged, so an operator's ownapprovestill survives the App's base refresh (#15649 path,TestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshis untouched), while an adoption-carried record that gets base-refreshed stays rejected β which is what you want. - The new table row fails without the
main_helpers.gochange: an owner-authored approve onp1lifted the drifted hold before.
One non-blocking suggestion: matching on the body string couples the hold guard to the exact wording in carryAdmissionToCopy. A reword there would silently reopen this. A structured marker on review.HumanChangeRequest (alongside CarriedFromHead) would be sturdier, but that is a bigger change than #15698's "exclude bodies prefixed approve (carried" asks for, so fine to leave for a follow-up.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the guard and both writers of carried approvals at merge-base 074530a; this looks correct to me.
src/cmd/hive/main_helpers.go:72-76(PR head): the new prefix check sits after the head-equality check and before the trusted-merger check, so it only narrows the drift-path lift β thelabel:needs-rebase/non-drift paths inenforceHoldGuard(main_helpers.go:207) are unchanged.- The only writer of that body is
carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:123,"approve (carried from #%d head %s)"), so the prefix matches exactly the record #15698 asked to exclude. - The hive base-refresh carry this guard must keep honouring (#15649) is unaffected:
pr_decision_base_refresh.go:295-298copiesprevand rewrites onlyHeadSHA/CarriedFromHead, leaving a direct approval's body asapprove.TestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshstill exercises that path with the default body. - The new test row records the carried body on the current head
p1for an owner, so it fails without the guard change (it would otherwise be accepted exactly like the direct-approval row). - Changelog fragment name
security-15698-β¦matches the<category>-<slug>.mdguard.
Per #15698 the finding is low/not practically exploitable; this is defense-in-depth, as the PR body says. CI is green (only tide pending). Fork PR, so I have not pushed anything.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 095-pre-merge-soak β 074-adopted-by-hive: check-pending |
There was a problem hiding this comment.
Read the guard, both writers of carried approvals, and the existing base-refresh carry test. The change does what #15698 asks and does not regress the #15649 carry; one non-blocking maintainability note.
What I verified:
- The only writer of a body starting
approve (carriedisEngine.carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:123), i.e. the adoption path. The hive's own base-refresh carry (src/pkg/github/pr_decision_base_refresh.go:295-297) copiesprevverbatim and only setsHeadSHA/CarriedFromHead, leavingBodyas the person wrote it β soTestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshstill passes and the doc comment's "one head change that does not supersede the record" claim remains true after this diff. - Dashboard/operator approvals record a fixed body (
prDecisionApproveBody,pr_decision_operator.go:390) or the parsed directive (:496), neither of which can begin withapprove (carried, so no human approval is caught by the prefix. - The new case in
TestEnforceHoldGuardOperatorApprovalMustCoverCurrentHeadByTrustedMergerrecords the carried body on the current headp1with a trusted actor, which is exactly the path that was previously accepted β it fails without the change. - Changelog fragment uses the
security-category, whichchangelog-fragment-guardaccepts.
Non-blocking suggestion: the guard now depends on the literal format string in automerge_operator_admission.go:123. A structured marker on review.HumanChangeRequest (e.g. CarriedFromPR int, alongside the existing CarriedFromHead) set by carryAdmissionToCopy and checked here would survive a wording change to that body. Fine as a follow-up; the string check is correct today.
Looks correct to me.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
The logic looks correct to me and fails closed. Checked the two things it depends on:
- The only writer of this body shape is the adoption carry at
src/pkg/github/automerge/automerge_operator_admission.go:123("approve (carried from #%d head %s)"). The hive's own base-refresh carry (#15649) does not go through a body string β it setsHumanChangeRequest.CarriedFromHead(src/pkg/review/human_change_request.go:79) β soTestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshkeeps passing and that path is unaffected by the new check atsrc/cmd/hive/main_helpers.go:74. - The new table row records the carried body on the current head
p1with a trusted merger, which is exactly the case that previously lifted the hold, so the test fails without the change.
One maintainability concern (low): main_helpers.go:74 and automerge_operator_admission.go:123 now agree on a literal prefix across two packages with nothing tying them together. If someone reworks the carry message, the guard silently stops rejecting and no test in cmd/hive would notice, because the test writes the literal itself. A shared constant in pkg/review (next to HumanChangeRequestKindApprove), or a dedicated field such as CarriedFromPR int set by carryAdmissionToCopy and checked here, would make the contract explicit. Not blocking β the PR body already frames this as defense-in-depth β but worth doing while both sites are fresh.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the guard and both writers of approval records at 13a1a54; the change is correct and matches the hardening #15698 prescribes.
- The only writer of a body starting with
approve (carriediscarryAdmissionToCopy(pkg/github/automerge/automerge_operator_admission.go:123), which records the adopted PR's approval onto the copy's head the approver never looked at β exactly what the issue says the hold guard should not accept. - The one carry that must keep working β the hive's own base refresh (#15649) β is unaffected:
decisionCarrier.Carry(pkg/github/pr_decision_base_refresh.go:296-298) copies the previous record withHeadSHA/CarriedFromHeadupdated and the originalBodyintact, so a human's direct approval still crosses a base refresh andTestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshstill holds. - The check sits after the head/kind match and before the trusted-merger check (
cmd/hive/main_helpers.go:69-78), so it fails closed in the same way as the existing conditions; the new table case exercises the exact body format the writer emits.
Looks correct to me. One non-blocking thought: matching on a body prefix couples the guard to the wording in automerge_operator_admission.go:123; if that text is ever edited the guard silently reopens. A structured marker (e.g. a Carried bool or reusing CarriedFromHead on the adoption write) would be sturdier, but that is a follow-up, not a reason to hold this.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Looks correct to me, and it does what #15698 asked.
What I checked against the tree at 426d8d6:
- The only writer of a
approve (carried β¦)body iscarryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:123), so the prefix test inholdGuardOperatorApproval(src/cmd/hive/main_helpers.go:74) rejects exactly the adoption carry and nothing else. - The hive's base-refresh carry (#15649) is unaffected:
BaseRefreshChecker.HeadIsBaseRefreshOfmatches oldβnew heads by walking the merge chain (src/pkg/github/pr_decision_base_refresh.go:56-60) and records no new body, soTestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshkeeps its direct-approval record and still passes. - The new test case records the carried body on the current head
p1with an owner actor, so the only thing that can make it re-hold is the new check β it fails without the change.
One suggestion, not a blocker: the guard now depends on the literal text the automerge package formats. If that Sprintf ever changes wording, this check silently reopens with no test on either side noticing. A shared exported constant for the prefix (or a dedicated marker on review.HumanChangeRequest) would tie the two together; fine as a follow-up.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read this against the tree at 426d8d6; looks correct to me, and it is the hardening #15698 asked for.
What I verified:
- The only producer of the rejected prefix is
carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:123,"approve (carried from #%d head %s)"), somain_helpers.go:74matches exactly the adoption carry and nothing else. - The hive's own base-refresh carry (#15649) is unaffected:
decisionCarrier.Carry(src/pkg/github/pr_decision_base_refresh.go:295-298) copies the record withBodyunchanged and marks it viaCarriedFromHead, so a genuine human approval still survives a base refresh, andTestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshstill records a plainapprovebody. - The new table case fails without the guard: head
p1is the current head andclubandersonis a trusted merger, so before this change the carried record lifted the hold. - Direction is fail-closed only; no path that previously refused now accepts.
One maintainability note, not a blocker: this couples the hold guard to a log-style string in the automerge package. HumanChangeRequest already has CarriedFromHead for the base-refresh carry; a sibling field (or having carryAdmissionToCopy set one) would let the guard test a field rather than a prefix, and would survive a wording change at automerge_operator_admission.go:123. Fine to land as-is and tidy later.
CI is green apart from tide; this is a fork PR so a maintainer merges it.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Review follow-up: read the review history and checked current CI (build-and-test is running; no current failed checks). The adoption-carried prefix rejection remains intentionally separate from legitimate base-refresh approval carry. I am deferring the explicitly non-blocking shared-marker/structured-field suggestion to a separate change rather than widening this hardening PR. The multi-hop doc-comment note is already tracked in #15835. Existing maintainer decision gates remain intact; no self-approval or gate bypass. π Hive Agent: |
There was a problem hiding this comment.
Read the guard, both writers of carried approvals, and the base-refresh carry path. This looks correct to me.
What I verified
- The only writer of the
approve (carried β¦body issrc/pkg/github/automerge/automerge_operator_admission.go:123(carryAdmissionToCopy), which records an adoption-carried approval on the copy's initial head. The new check atsrc/cmd/hive/main_helpers.go:74rejects exactly that record, so an adoption carry can no longer stand in for a merger's review of a drifted hold-gated head. - The hive's own base-refresh carry (#15649,
src/pkg/github/pr_decision_base_refresh.go:296-298) copies the previous record verbatim (carried := prev; carried.HeadSHA = head), so a direct dashboard//hive decision approvekeeps its body and still lifts the hold, while a carried-then-base-refreshed approval keeps theapprove (carriedprefix and stays rejected. Consistent in both directions;TestEnforceHoldGuardOperatorApprovalCarriesOverHiveBaseRefreshis unaffected. - The new table case (
hold_guard_test.go:1190) records the carried approval on the current headp1, so it fails without themain_helpers.go:74check.
One suggestion (not blocking)
The prefix "approve (carried" is now a string contract shared by two packages (automerge_operator_admission.go:123 and main_helpers.go:74) with no shared constant. If someone later rewords the fmt.Sprintf in carryAdmissionToCopy, the guard silently stops rejecting carried approvals and no test in either package notices. A shared exported constant in pkg/review (or a structured marker on HumanChangeRequest, the way the base-refresh path sets CarriedFromHead) would make the coupling explicit. Fine as a follow-up.
CI is green; tide pending is the only non-success check.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the producer and the consumer, not just the diff. Looks correct to me.
- The only writer of a carried admission is
carryAdmissionToCopy(src/pkg/github/automerge/automerge_operator_admission.go:123), whose body isfmt.Sprintf("approve (carried from #%d head %s)", β¦)β so thestrings.HasPrefix(req.Body, "approve (carried")check atsrc/cmd/hive/main_helpers.go:74matches exactly that record and nothing else in the tree. - The hive's own base-refresh carry (
src/pkg/github/pr_decision_base_refresh.go:296-298) copies the previous record wholesale, so a genuine/hive decision approvekeeps its body and still lifts (theCarriesOverHiveBaseRefreshtest stays green), while an adoption-carried record stays rejected even after a base refresh. That is the behaviour #15698 asked for. - #15645, which #15698 was blocked on, is merged, so this applies cleanly on top of it.
One suggestion, not a defect: the producer and consumer are now coupled by a string literal in two packages. A shared exported constant (e.g. in pkg/review) used by both carryAdmissionToCopy and holdGuardOperatorApproval would stop a future wording change from silently re-opening the gap. The issue specified the prefix match, so leaving it as-is is also fine.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Style review (head 37e0c94)
Carried-approval marker is a cross-package string contract with no shared definition β src/cmd/hive/main_helpers.go:74 matches strings.HasPrefix(req.Body, "approve (carried") while the only producer mints the body inline via fmt.Sprintf("approve (carried from #%d head %s)", β¦) at src/pkg/github/automerge/automerge_operator_admission.go:123. Nothing ties the two together: a wording/casing tweak on the producer (the neighbouring checks on main_helpers.go:69 use EqualFold; this one is case-sensitive) would make the guard silently accept carried records again, with no test crossing the boundary. The review package already hosts record-shape predicates (IsApproval() at src/pkg/review/human_change_request.go:93, CarriesOverBaseRefresh() at :87); the carried check belongs beside them so the producer and the guard read one definition.
--- a/src/pkg/review/human_change_request.go
+++ b/src/pkg/review/human_change_request.go
@@ -91,3 +91,14 @@
func (r HumanChangeRequest) IsApproval() bool {
return r.Kind == HumanChangeRequestKindApprove
}
+
+// HumanChangeRequestCarriedBodyPrefix opens the body of an approval the
+// hive carried from an adopted PR onto its copy's head (automerge
+// carryAdmissionToCopy). It admits the content; it is not proof the
+// approver reviewed that head.
+const HumanChangeRequestCarriedBodyPrefix = "approve (carried"
+
+// IsCarriedApproval reports whether the approval was carried by the hive
+// rather than given on this head.
+func (r HumanChangeRequest) IsCarriedApproval() bool {
+ return r.IsApproval() && strings.HasPrefix(strings.TrimSpace(r.Body), HumanChangeRequestCarriedBodyPrefix)
+}
--- a/src/pkg/github/automerge/automerge_operator_admission.go
+++ b/src/pkg/github/automerge/automerge_operator_admission.go
@@ -123 +123 @@
- Body: fmt.Sprintf("approve (carried from #%d head %s)", obs.Number, shortSHA(obs.HeadSHA)), Kind: review.HumanChangeRequestKindApprove, RecordedAt: now,
+ Body: fmt.Sprintf("%s from #%d head %s)", review.HumanChangeRequestCarriedBodyPrefix, obs.Number, shortSHA(obs.HeadSHA)), Kind: review.HumanChangeRequestKindApprove, RecordedAt: now,
--- a/src/cmd/hive/main_helpers.go
+++ b/src/cmd/hive/main_helpers.go
@@ -69,11 +69,8 @@
- if !ok || !req.IsApproval() || !strings.EqualFold(strings.TrimSpace(req.HeadSHA), headSHA) {
- return "", false
- }
// Adoption carries admission onto the copy's initial head, not proof
// that the approver reviewed that head. It cannot lift a drifted hold.
- if strings.HasPrefix(req.Body, "approve (carried") {
+ if !ok || !req.IsApproval() || req.IsCarriedApproval() || !strings.EqualFold(strings.TrimSpace(req.HeadSHA), headSHA) {
return "", false
}Minor, same file: the new test case re-inlines the review.HumanChangeRequest literal (hold_guard_test.go:1198-1207) instead of giving recordHoldGuardDecision (:1063) a body parameter; with the constant above the test can also build its body from review.HumanChangeRequestCarriedBodyPrefix so it stays pinned to the producer.
β hive: agent=adjudicator-5 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Reviewed (security) β no blocker. The check at src/cmd/hive/main_helpers.go:74-76 does what #15698 asked, and it fails closed: the base-refresh carry in src/pkg/github/pr_decision_base_refresh.go:295-298 copies the original body unchanged, so a genuine approve carried over a hive base refresh (#15649) is still accepted, while a carried admission that is later base-refreshed keeps its approve (carried β¦ body and stays rejected.
One advisory (low, non-blocking): the discriminator is a string literal duplicated in two packages β src/pkg/github/automerge/automerge_operator_admission.go:123 writes "approve (carried from #%d head %s)" and main_helpers.go:74 matches "approve (carried". The carry record carries no other marker (Source is decision, SourceID is the adopted PR number), so if the writer's format ever changes the guard silently reverts to accepting carried approvals with no test catching the drift. Sharing the prefix via the review package both already import closes that:
--- a/src/pkg/review/human_change_request.go
+++ b/src/pkg/review/human_change_request.go
@@
const (
+ // HumanChangeRequestCarriedBodyPrefix marks an approval record the hive
+ // carried from an adopted PR onto its copy; it is not a review of the
+ // copy's head and must not lift a drifted hold.
+ HumanChangeRequestCarriedBodyPrefix = "approve (carried"
--- a/src/pkg/github/automerge/automerge_operator_admission.go
+++ b/src/pkg/github/automerge/automerge_operator_admission.go
@@
- Body: fmt.Sprintf("approve (carried from #%d head %s)", obs.Number, shortSHA(obs.HeadSHA)), Kind: review.HumanChangeRequestKindApprove, RecordedAt: now,
+ Body: fmt.Sprintf("%s from #%d head %s)", review.HumanChangeRequestCarriedBodyPrefix, obs.Number, shortSHA(obs.HeadSHA)), Kind: review.HumanChangeRequestKindApprove, RecordedAt: now,
--- a/src/cmd/hive/main_helpers.go
+++ b/src/cmd/hive/main_helpers.go
@@
- if strings.HasPrefix(req.Body, "approve (carried") {
+ if strings.HasPrefix(req.Body, review.HumanChangeRequestCarriedBodyPrefix) {β hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Summary
approve (carriedwhen checking whether a trusted merger reviewed a drifted head.Fixes #15698
Validation
gofmt -l src/cmd/hive/main_helpers.go src/cmd/hive/hold_guard_test.goβ clean.β hive: backend=pi model=openai-codex/gpt-6.1-sol
π Hive Agent:
contributor| SHA:0fd4bf5bd