Skip to content

πŸ› fix(adoption): take a review-asked fix the undo guard refused once the reviewer approves it - #17000

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/undo-guard-approved-adoption
Nov 7, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/undo-guard-approved-adoption

Conversation

@Danathar

@Danathar Danathar commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

The undo guard from #16816 parks an adopted PR at 085 when a hive push keeps less than half of the PR's changed lines. That is right for a CI fix that "passes" by undoing the PR. It is wrong when the hive adopted the PR for the review's requested changes and the review asked for part of the change to go. Then the push is the fix. With this change, a review-asks adoption whose push the guard refused is released once the reviewer approves that exact head. The approve is read on every sweep, so a park posted before the verdict arrived is lifted when it does. An adoption for red CI never takes this path, approve or not, so the utah#1091 hole stays closed.

What went wrong

On projectbluefin/utah-packages#943 the PR marked two packages wontfix. The review (07:53Z) asked for both to stay pending. CI was not red, so the hive returned the PR for the review asks alone and adopted it in place at 10:04Z. Its push eed6933 dropped both wontfix entries and rewrote the guidance, which left 2 of the PR's 20 changed lines. At 10:14Z the guard posted "Fixing CI would undo this PR's change … The hive will not merge eed6933" and moved the PR to stage/085-needs-decision.

Two things combined:

One correction to the original report: the 10:19Z review on eed6933 is not an approve. It marks all three earlier findings fixed ("The earlier objections are resolved"), but it raises one new docs finding (wrong source-package name) and ends "1 perspective requested changes". So #943 itself would still sit at 085 with this change. The change makes the approve count when it comes; it does not treat a change request as an approve.

What changes

  • At in-place adoption, the stage record notes adopted_for_review when the PR was returned for the review swarm's requested changes and CI is not red.
  • When the guard finds that a hive push drops most of the change, it checks whether the record says adopted_for_review and whether the reviewer's verdict on that exact head is approve. If both hold, the head is taken as the hive's, with no park and no note.
  • If the park is already in place, each stage pass checks the same two things and clears it when they hold. The contributor lane's gate checks them too, because it can run before the stage pass.
  • With any other verdict, or with no verdict yet, the park holds as before. A CI adoption is never released.
  • Scanner policy (both copies): one clause saying that when the review asked for part of the change to be dropped, doing so is the fix and the hive takes the head once the reviewer approves it.
  • Stage-labels doc and a changelog entry.

Files

  • src/pkg/github/automerge/automerge_adoption_intent.go: adoptedForReview, reviewApprovedFixerRevert, releaseApprovedFixerRevert, the push-time check and the lane gate.
  • src/pkg/github/automerge/automerge_contributor_adopt.go: record the review-asks cause at in-place adoption.
  • src/pkg/github/automerge/automerge_stage_labels.go: release check after settleInPlaceAdoption.
  • src/pkg/stagelabels/store.go: AdoptedForReview field, MarkAdoptedForReview, reset in MarkAdoptedInPlace.
  • src/policies/scanner-automerge.md, src/pkg/policies/defaults/scanner-automerge.md, src/docs/labels-and-control-signals/stage-labels.md, changelog.d/fixed-adopted-review-fix-undo-guard.md.

Tests

New in automerge_adoption_intent_review_test.go, with a #943-shaped diff (2 wontfix lines plus 18 doc lines, then a push that keeps 2 of 20):

Test On v6 tip With this PR
TestAdoptedReviewFixThatDropsChangeIsReleasedByApprove FAIL pass
TestAdoptedReviewFixApprovedBeforeCheckIsNotParked FAIL pass
TestAdoptedReviewFixWithoutApproveStaysParked pass pass
TestAdoptedCIFixThatRevertsPRStaysRefusedWhenApproved pass pass
TestAdoptedForReview n/a (new) pass

Mutants: dropping the AdoptedForReview condition fails the CI-adoption test, and disabling the stage-pass release fails the release test. The existing #16816 tests all pass unchanged.

Full packages run: pkg/github/automerge, pkg/stagelabels, pkg/policies/..., pkg/writeback, pkg/github, pkg/stageengine/..., plus go vet, gofmt and check-docs-citations.py.

Notes

  • No follow-up note when a park is released. The PR moves off 085 and can merge, but the earlier "will not merge" note stays as written. Adding a note would mean a new notification write site; say if you want one.
  • Records adopted before this deploy have no adopted_for_review, so a park already in place (including fix: use SendKick for inception kicks β€” eliminates 32% failure rateΒ #943) is not released by an approve. Those need a person, as today.
  • Only the review swarm's approve counts. A trusted human's GitHub approval on the head does not release the park in this change.

Refs #16816

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…the reviewer approves it

The undo guard (hivecommons#16816) parks an in-place adopted PR at 085 when a hive
push keeps less than half of the PR's changed lines. On
projectbluefin/utah-packages#943 the hive adopted the PR for the review
swarm's requested changes, and its push dropped the two wontfix entries
exactly as the review asked. The guard parked it, and the park held until
the head moved, so a later verdict was never read.

An in-place adoption now records whether it was taken for the review
asks with CI not red (adopted_for_review). For such an adoption a push
the guard would refuse is taken once the reviewer's verdict on that
exact head is approve: at the push check, in the contributor lane gate,
and on each stage pass, which releases a park posted before the verdict
arrived. An adoption for red CI (the utah#1091 shape) stays refused even
with an approve, and any other verdict keeps the park.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
Signed-off-by: Danathar <Danathar@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 7, 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 Nov 7, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • check-failure

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 (3 waiting): fixes are handed out before new work as soon as you have capacity.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

native-queue-policy red here (TypeError: isCosmeticLabelFlip is not a function) is a shared incident affecting every PR based on v6, not this diff: #17003. The step added by #16952 on v5 requires a symbol v6's .github/scripts/native-queue-policy.cjs does not export yet; the forward-merge #16997 brings it over. No action needed on this branch β€” the check will pass on re-run once #17003 closes.


🐝 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

@hivecommons-hive

Copy link
Copy Markdown
Contributor
402272a

ℹ️ Sentinel notice β€” informational; author is trusted (owner), merge is not blocked

Hive flagged this PR (author @Danathar, head 402272abdf94) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation β€” a maintainer should confirm the change is intended before it merges.

  • sensitive_path β€” changes 2 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • src/pkg/policies/defaults/scanner-automerge.md
    • src/policies/scanner-automerge.md

Hive did not add the sentinel-alert label because this author is trusted. The finding remains recorded for audit and the dashboard Security tab; set sentinel.trusted_authors_block: true to require the blocking label for trusted authors too.

@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 the hive review swarm's own approve (not a human's) may release the fixer-undoes-PR guard on a contributor PR the hive adopted for review asks.

The code does what the body says; the question I cannot settle is a trust-policy one.

Correctness β€” read against the v6 tree, looks right

  • automerge_adoption_intent.go:121-125 short-circuits the refusal only when intent.Reverts() and reviewApprovedFixerRevert holds; :165-170 requires AdoptedInPlace() && AdoptedForReview, so a red-CI adoption (utah#1091) can never take this path β€” MarkAdoptedInPlace (store.go:1620) resets the flag and adoptContributorPR:918-920 sets it only when adoptedForReview(obs) (not red, changes-requested reason). MarkAdoptedHead (store.go:1661-1674) does not touch AdoptedForReview or AdoptedIntentHead, so the baseline stays the original adopted head and the chain-of-cuts protection from #16816 is intact.
  • The release is wired on all three readers of the refusal: the push check, the stage pass (automerge_stage_labels.go:1258) and the lane gate (adoptionIntentGate:230-234), so approve-before-push and approve-after-park both resolve without a second note. go build passes; the new test file covers both orderings, the CI-adoption exclusion and non-approve verdicts.

The policy question

reviewApprovedFixerRevert reads contributorLaneVerdictFor(...).Approved (automerge_contributor_lane.go:1319), which is the hive review swarm's verdict, folded with any recorded human decision. In the #943 shape the chain is therefore: hive reviewer requests changes β†’ hive fixer pushes a commit keeping 2 of the contributor's 20 lines β†’ hive reviewer approves β†’ hive merges under the contributor's PR. No person is in that loop, and the existing guard text in stage-labels.md says stale-red recovery "never releases the refusal" precisely because dropping most of a contributor's change was meant to be a human call. If that is acceptable when the adoption was for review asks, this is fine to land as-is. If the intent is that only a human approve releases it, the check should be narrowed to the recorded-decision path (withRecordedDecision) rather than .Approved. I have not closed or blocked anything.

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

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

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

PR Title Relation Files
#17010 πŸ› fix(unpark): a re-parked owner step recommends /hive done, not the /hive approve that looped same files src/pkg/policies/defaults/scanner-automerge.md
src/policies/scanner-automerge.md

…doption

Signed-off-by: Danathar <Danathar@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor

The hive's GitHub App lacks actions: write, so it cannot rerun shared ci for head 402272abdf94. A repository maintainer with Actions write can re-run failed jobs at https://github.com/hivecommons/hive/actions/runs/42385890245 . Alternatively, the App owner can request Actions read and write for this recovery installation and its owner must accept the update. This is a CI recovery permission block, not a source-code failure or merge approval. Hive retries after its bounded permission cooldown; no alternate credential is selected. Hive will resume automatically once the step is done; this label and note clear themselves.

@hivecommons-hive

hivecommons-hive Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

  • the reviewer swarm returned requires_human @007d631
  • the review found: the intent-alignment review flags insecure behaviour
  • reviewer summary: intent-alignment requires human: Delta re-review 402272a -> 007d631. The only new commit is a merge of v6 (v5 top-up 🌱 Forward-merge v5 into v6 (82 commits, manual: conflicts)Β #16997) into the branch; the effective PR diff against its base is byte-identical at both heads (same 7 files, same hunks, only line offsets moved). Merge resolution checked: the PR's releaseApprovedFixerRevert hook in automerge_stage_labels.go:1277 sits correctly after settleInPlaceAdoption alongside v6's new code, and v6's πŸ› fix(automerge): prevent stage reconciler oscillation on needs-decision PRsΒ #16980 needs-decision dampener (stageengine/derive_pr.go:322 skips when pass.AdoptionLive; derive_pr_classify.go:673 bails on an approve verdict) does not re-park a released head. Intent: title/body say the park lifts 'once the reviewer approves'; implementation reads contributorLaneVerdictFor(...).Approved (automerge_adoption_intent.go:169, automerge_contributor_lane.go:1319), i.e. the hive review swarm's verdict, which matches the author's description of fix: use SendKick for inception kicks β€” eliminates 32% failure rateΒ #943. No scope creep; changelog/docs/policy edits match the code. Prior finding [security] automerge_adoption_intent.go:169 'Undo guard releasable by hive swarm approve': STILL PRESENT, code unchanged at this head; it is the trust/merge-policy question (hive push + hive approve releases a revert of most of a contributor's PR) that keeps the whole-PR verdict at requires_human. No new findings from this perspective; no new comment posted since the human decision was already surfaced at the prior head.
  • reviewer summary: security requires human: Delta re-review 402272a..007d631 (security). The delta is a single merge commit bringing v6 (86 upstream commits, incl. 🌱 Forward-merge v5 into v6 (82 commits, manual: conflicts)Β #16997) into the branch; the merge commit's diff against its v6 parent e1bad50 is byte-identical to the PR diff (9 files, 415 lines), so no PR-file content changed and no conflict resolution introduced new code. Upstream commits touched other automerge files but not reviewApprovedFixerRevert's inputs (contributorLaneVerdictFor / withRecordedDecision unchanged in meaning). Prior finding [security] automerge_adoption_intent.go:169 'Undo guard releasable by hive swarm approve' is STILL PRESENT (now line 170) and unchanged; verdict for the whole PR stays requires_human. No new security findings in the delta; no comment posted to avoid duplicating the prior head's note.
  • reviewer summary: style requires human: Delta re-review at 007d631 (previous head 402272a). The only new commit is 'Merge v6 (v5 top-up 🌱 Forward-merge v5 into v6 (82 commits, manual: conflicts)Β #16997) into fix/undo-guard-approved-adoption'; its second parent is the merge-base e1bad50, so the PR's effective diff is the same nine files and their content is byte-identical to the previous head. Merge resolution checked: releaseApprovedFixerRevert call sits after settleInPlaceAdoption in automerge_stage_labels.go:1266-1268 and MarkAdoptedForReview follows MarkAdoptedInPlace in automerge_contributor_adopt.go:926-928; all referenced symbols (adoptionWaitFor, verdictBlocks, contributorLaneVerdictFor, LaneReasonAdoptionFixerReverts) resolve at head and CI is fully green. No new style/convention/readability findings in the delta. Prior finding status: [security] automerge_adoption_intent.go:169 'Undo guard releasable by hive swarm approve' β€” still present, unchanged (reviewApprovedFixerRevert still returns contributorLaneVerdictFor(...).Approved); that in-scope finding keeps the whole-PR verdict at requires_human. No comment posted from this perspective to avoid duplicating it.
  • the automerge lane will not merge this unattended

Head: verdict requires_human @007d631, 60/60 checks green, DCO yes, soak 0s of 10m0s.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed. An ordinary contributor cannot release their own PR.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

Updated 2026-11-07 16:17 UTC.

hivecommons-hive Bot pushed a commit that referenced this pull request Nov 7, 2026
… CI incident is withdrawn (#17007)

The 072 nudge goes out the moment a contributor PR goes red ("the hive
will not merge it until the head changes"). The scanner's [shared-ci]
incident marker can land minutes later. The stage pass then moved the
PR to 050, but the nudge stayed as posted and the head's nudge count
stayed at 1. Seen on hivecommons/hive #16993, #16995, #17000 and
#17001: nudged for native-queue-policy about ten minutes before they
were deferred to incident #17003.

- When the pass reads a nudged head's red as shared-ci-incident:<n> or
  base-branch-red:<checks>, edit the hive's own nudge comments for that
  head in place to say it was withdrawn, and forget the nudge
  (Store.WithdrawNudge), so a genuine return to 072 is nudged afresh.
- After an incident closes as completed, keep a PR deferred to it until
  the rerun sweep stamps hive-shared-ci-rerun-<n> (at most 30 minutes),
  so the head is not handed back in the gap before the re-run.
- Name the head's red checks in the nudge when the CI gate's reason is
  a bare token such as check-failure (a base with no required checks).

Refs #17003, #12606, #12253


Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

Signed-off-by: Danathar <Danathar@users.noreply.github.com>
Co-authored-by: Danathar <Danathar@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

@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 gate and the store code it leans on at 007d631; the change looks correct to me and the two packages build.

What I verified

  • The erosion guard from #16816 is intact: MarkAdoptedHead (stagelabels/store.go:1744-1757) never touches AdoptedIntentHead, so after an approve-release the next hive push is still judged against the contributor's original head, not the narrowed one.
  • MarkAdoptedForReview (store.go:1713) only sets the flag when AdoptedIntentHead == head and the adoption is in-place, and MarkAdoptedInPlace resets it to false (store.go:1703); a CI adoption can't inherit it. adoptedForReview (automerge_adoption_intent.go:153) returns false whenever adoptionWaitFor(obs).red, which is the utah#1091 shape.
  • Approved is review.Artifact.HasAggregateApproval (automerge_review_gate.go:50), i.e. every perspective on that exact head, not a single reviewer's object. No verdict β†’ not approved β†’ still parked.
  • releaseApprovedFixerRevert is called every sweep from ApplyStageLabels (automerge_stage_labels.go:1267) right after settleInPlaceAdoption, so an approve landing after the park is picked up on the next tick; adoptionIntentGate (:230) covers the lane running before that tick.

One note for the deploy, not a defect: AdoptedForReview is written only inside adoptContributorPR (automerge_contributor_adopt.go:927). Records adopted before this field existed β€” including projectbluefin/utah-packages#943, the PR this fixes β€” load with it false, so they stay parked until the adoption is re-taken or the head moves. If you expect #943 itself to release on upgrade, it won't; it will need a re-adoption or a manual decision.

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

@hivecommons-hive

hivecommons-hive Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Read the intent check, the stage pass and the lane gate at 007d631. Looks correct to me, and the scope matches the body: red-CI adoptions never take the new path.

  • adoptedForReview (automerge_adoption_intent.go:153-158) requires !adoptionWaitFor(obs).red and a changes-requested reason or verdictBlocks(obs.Detail); it is only set right after MarkAdoptedInPlace (automerge_contributor_adopt.go:926-929), and MarkAdoptedInPlace resets AdoptedForReview=false (store.go:1703) so a re-adoption for red CI cannot inherit it. MarkAdoptedForReview checks AdoptedIntentHead == head, which MarkAdoptedInPlace has just set, so the flag lands.
  • Release is keyed on contributorLaneVerdictFor(...).Approved for the exact head (automerge_adoption_intent.go:170), which folds in a recorded human decision via withRecordedDecision (automerge_contributor_lane.go:1323-1331). Three entry points agree: push time (:121), each stage pass via releaseApprovedFixerRevert after settleInPlaceAdoption (automerge_stage_labels.go:1267), and the lane gate (:231) for the pass-ordering race the comment names. After ClearAdoptionEscalation the head is still unmarked, so the next intent check re-runs and now takes the approved branch with MarkAdoptedHead β€” no second note.
  • automerge_adoption_intent_review_test.go covers all four quadrants (release after approve, approve before check, no approve stays parked, CI adoption stays refused when approved).

One observation for the record, not a defect: the release trusts the review-swarm's approve on the narrowed head. The body argues that explicitly (the reviewer judged the narrowed diff), and the hole it widens is bounded to adoptions the review itself asked for, so I'm not asking anyone to decide it β€” just naming it.

Evidence bundle `#17000007d631` sha256:7c57804f9c8b27e88ee0089d53197d6171ff83e0063466cbcdc1bb084c675c73 β€” download from the dashboard or `hivectl review evidence #17000`.

@hivecommons-hive
hivecommons-hive Bot merged commit 3d7e6be into hivecommons:v6 Nov 7, 2026
67 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant