Skip to content

πŸ› fix(adoption): refuse a fixer push that undoes the adopted PR's change - #16816

Merged
hivecommons-hive[bot] merged 4 commits into
hivecommons:v6from
Danathar:fix/fixer-revert-guard
Nov 6, 2026
Merged

hivecommons-hive[bot] merged 4 commits into
hivecommons:v6from
Danathar:fix/fixer-revert-guard

Conversation

@Danathar

@Danathar Danathar commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Executive summary

On projectbluefin/utah#1091 (fork thatguywob, maintainer_can_modify), the PR removes 25 resolved entries from baselines/triage.toml (projectbluefin/utah@b6734c2). The adopted fixer (scanner) pushed projectbluefin/utah@a75a567 at 2026-11-03 21:10:13Z, re-adding all 25. That left a docs-only diff (+10). At 21:10:35Z it posted "hive/awaiting-ci: CI pending β€” sweep will merge when green". Only the reviewer caught it, at 21:42Z. The right move was to wait for projectbluefin/utah#1074, which the PR body and the hive's own review both named as the dependency.

This PR checks every hive push on an in-place adopted PR against the PR's own change before the hive takes it as its head. The check: the PR's diff against its base must still carry at least half of the lines the PR changed at the contributor's head the adoption started from. Every push is judged against that same head, so a push on top of a refused one stays refused and a chain of pushes cannot erode the change. A push that fails is refused:

  • The PR parks at stage/085-needs-decision with reason adoption-fixer-reverts-pr and one "Fixing CI would undo this PR's change" note.
  • The contributor lane refuses to merge that head.
  • The awaiting-ci note never promises a merge before the check has passed.

What

When Before After
Hive push keeps the PR's change (a normal fix) Head taken as the hive's; 074 Unchanged
Hive push keeps less than half of the PR's changed lines Head taken; merges when green 085 adoption-fixer-reverts-pr, one note naming kept/total lines, lane refuses that head; a new push re-checks
Hive push not checked yet (or diff unreadable) Admitted if the head was recorded Lane refuses contributor-lane:adoption-intent-pending; re-read next sweep
Agent posts hive/awaiting-ci: … sweep will merge when green on an unchecked or refused head Posted as written Rewritten: "the hive first checks that this push keeps the PR's own change…" / "the sweep will not merge this head…"
Activity monitor row β€” Caption "fixing CI would undo this PR's change…"; decision question names the options
Scanner policy (in-place adoption clause) May push fixer commits Same, but a fix must keep the PR's change; if CI can pass only by undoing it, park with needs-human instead

Why

  • The fixer's push goes straight to the fork branch with git push; scanner-automerge.md allows that on stage/074-adopted-by-hive. The push-branch relay only publishes same-repo branches, so there is no pre-push hook to intercept. The hive does see the push in settleInPlaceAdoption, which takes a head as the hive's only after this pass. The contributor lane's adoption admission (adoptedHeadOwnedByHive) only admits that exact head. Checking there is therefore checking before anything merges.
  • "sweep will merge when green" is a status note the policy prescribes. The relay posted it 22 s after the push, before any check could run.

How

  • automerge/automerge_adoption_intent.go (new):
    • judgeAdoptionIntent turns each file's patch into a multiset of +/- lines, or one unit for a file with no patch, then counts how many units of the pre-push diff survive in the post-push diff.
    • adoptedPushIntent reads both diffs with three-dot compare/<base>...<head>, so a base merge is not counted.
    • A diff of 300 files or more is not judged and the push stands.
    • checkAdoptedPushIntent judges against Record.IntentBaseHead(): the new AdoptedIntentHead, set in MarkAdoptedInPlace, or AdoptedHead for older records.
      • Pass: MarkAdoptedHead.
      • Fail: MarkAdoptionEscalated(LaneReasonAdoptionFixerReverts), then the note (once per head), then MarkAdoptedHead, so a failed post is retried.
      • Unreadable diff: nothing is marked.
    • adoptionIntentGate is the lane refusal.
  • automerge_contributor_adopt.go: both "advanced by the hive" branches (App-linked commit, recorded hive push) call the check. The escape keeps this escalation until the head moves, like copy-failed, and stale-red recovery never clears it.
  • automerge_contributor_lane.go: the gate runs right after the closing-contradiction gate, before any admission path.
  • github/issue_request_status_notes.go: adoptedAwaitingCINote reads the stage record and the PR head, only for an awaiting-ci note on an in-place adopted PR. It rewrites only a hive push: recorded push evidence or a commit GitHub links to the App. An author's push keeps the note.
  • stagelabels.LaneReasonAdoptionFixerReverts; dashboard caption and decision text.

Tests

Test Covers
TestJudgeAdoptionIntent utah#1091 shape (10/35 kept β†’ refused), normal fix (35/35), base merge, all reverted, half kept, binary file, 300-file cap
TestAdoptedFixerPushThatRevertsPRIsRefused one note, 085, record escalated, lane gate refuses; second sweep holds without a second note
TestAdoptedRecordedHivePushThatRevertsPRIsRefusedOnce same via the recorded-push path; a re-check after a restart does not re-post
TestAdoptedFixerPushThatKeepsPRIsAllowed normal fix: no writes, head taken, gate open
TestAdoptedFixerPushIntentUnreadableHoldsMerge compare error β†’ head unconfirmed, gate pending; retry confirms
TestTrySweepContributorLanePRAdoptedByHiveAdmission (+2 rows) refused head not merged even for a trusted author; unchecked hive head waits
TestAdoptedFixerPushOnTopOfRefusedHeadStaysRefused a push on top of a refused head is still refused, judged against the contributor's head
TestAdoptedFixerPushChainCannotErodeChange 60% kept passes; the next push (12/35 overall) is refused
TestAdoptedFixerRevertsSurvivesStaleRedRecovery stale-red rerun on the refused head; refusal and lane gate hold
TestIntentBaseHead baseline survives hive pushes; older records fall back to AdoptedHead
TestAwaitingCINoteOnAdoptedPRWaitsForIntentCheck pending / refused / checked rewrites; other notes and unadopted PRs untouched
TestStageTrackerAdoptionFixerRevertsSaysWhy caption, decision question, humanized reason
Mutants (17 + 7 for the review fixes) 23 caught; 1 equivalent (Own > 0 is implied by Kept*2 < Own)
go test github/..., stagelabels, policies, writeback, dashboard pass
check-docs-citations.py src/docs, writeback ratchet, gofmt pass

Notes

  • Not fixed: the contradictory 21:13:29Z note. "head a75a56730dd8 has not moved for 2m and the hive has nothing it can push: adoption-stalled:fork-rehome-refused … cannot finish it on the fork's own branch" came three minutes after the App pushed to that branch. It means a re-home was attempted on a75a567 and refused (ForkRehomeRefused on that head), but which re-home reason fired, and why, isn't readable from the PR alone. I didn't guess at a fix. With this change that head would have parked at 085 for the revert first.
  • Threshold: "most of the PR's own hunks" is implemented as "less than half of the changed lines survive", counted per line rather than per hunk. It is not configurable; say if you want it to be.
  • Duplicates: no open PR covers this; the only v5-only commit in these files is πŸ› fix(automerge): only re-sign the hive's own commits in in-place DCO repairΒ #16698 (DCO repair), which is unrelated.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

projectbluefin/utah#1091: the adopted fixer re-added the 25 triage entries
the PR removed (a75a567), leaving a docs-only diff, and announced "sweep
will merge when green".

- automerge: each hive push on an in-place adoption is checked before the
  head is taken; if the PR's three-dot diff keeps less than half of the
  lines it changed, park 085 (adoption-fixer-reverts-pr) with one note and
  refuse the head in the contributor lane; unchecked heads wait
  (contributor-lane:adoption-intent-pending).
- relay: an awaiting-ci note on an unchecked or refused adopted head no
  longer promises a merge.
- dashboard caption/decision text; scanner policy tells the fixer to park
  instead of pushing such a commit.

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 5, 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 danathar 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

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

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

PR Title Relation Files
#16688 🌱 Forward-merge v5 into v6 (2 commits) same files src/docs/labels-and-control-signals/stage-labels.md
src/pkg/github/automerge/automerge_contributor_adopt.go
src/pkg/github/automerge/automerge_contributor_adopt_test.go
src/pkg/stagelabels/store.go

@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 automerge_adoption_intent.go, both call sites in settleInPlaceAdoption (automerge_contributor_adopt.go:1979-1995), the lane gate at automerge_contributor_lane.go:1410, the escapeStalledAdoption branch at :2310, and adoptedAwaitingCINote at head 49a7da8. Looks correct to me.

What I checked specifically:

  • The check cannot be skipped by the push-time path: MarkHivePushedHead (automerge_contributor_adopt.go:1504, automerge_adoption_recovery.go:269) never sets AdoptedHead, so a hive-pushed head still satisfies obs.HeadSHA != prev.AdoptedHead at :1972 and reaches checkAdoptedPushIntent.
  • Failure ordering: on a revert, MarkAdoptionEscalated precedes the note and MarkAdoptedHead follows it, so a failed post re-enters next sweep (head still unmarked) and AdoptionEscalationNoted prevents a second note once it lands. adoptionIntentRefused keys on AdoptEscalatedHead == head, so an author push clears the refusal without a store reset.
  • CompareCommits is the three-dot endpoint, so a base merge the hive pushes contributes no +/- units and passes as the body says. prChangeUnits skips +++/--- headers and only reads line[0] after the empty check.

One thing a maintainer may want to be aware of, not a defect: the 50% line-retention rule compares against the last judged hive head, so a fixer that legitimately rewrites the PR's approach (same goal, different lines) also parks at 085. That matches the body's intent ("a fix must keep the PR's change"), just noting it is a content heuristic rather than a semantic one.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor
49a7da8

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

Hive flagged this PR (author @Danathar, head 49a7da888f38) 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 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

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

Read this against v6; looks correct to me, and the body's three claims all have code behind them.

What I verified

  • Wiring: settleInPlaceAdoption no longer marks a hive-pushed head as adopted directly; both the recorded-push and App-commit branches now return checkAdoptedPushIntent (automerge_contributor_adopt.go:1980-1996 on this head). MarkAdoptedHead is only called after the judgement (automerge_adoption_intent.go:146,163), so an unreadable diff leaves AdoptedHead behind the push and adoptionIntentRefused returns adoption-intent-pending (:179-181) β€” the lane gate at automerge_contributor_lane.go:1410 then refuses it. Next sweep re-enters via prev.HivePushedHead(obs.HeadSHA) and re-judges. Nothing is lost on the deferral.
  • Baseline stability: MarkAdoptedInPlace now sets AdoptedIntentHead (store.go:1609), IntentBaseHead() prefers it and falls back to AdoptedHead for pre-field records (store.go:1439-1444); hive pushes only move AdoptedHead. So the compare is always base…contributor-head vs base…pushed-head, and a refused head can't become the baseline. TestAdoptedFixerPushChainCannotErodeChange pins that.
  • AdoptionEscalationNoted(head, reason) and postAdoptionEscalationNote exist on v6 with these signatures (store.go:1519, automerge_contributor_adopt.go:2107); the note is posted once and the head is taken only after it posts.
  • Stale-red recovery: the release at automerge_contributor_adopt.go:2319 is skipped for this reason, and the escape returns Escalated:true for it alongside the two existing content-verdict reasons (:2342). TestAdoptedFixerRevertsSurvivesStaleRedRecovery covers it.
  • Dashboard caption/question and the awaiting-ci note rewrite (issue_request_status_notes.go:63-88, hooked at issue_request_watcher.go:783) are present as the body says.

Two open questions on the heuristic, not defects β€” stating them so whoever merges knows the false-positive shape:

  1. prChangeUnits keys on path + sign + TrimSpace(text) (automerge_adoption_intent.go:45-58). A fixer commit that legitimately rewrites most of the PR's own added lines β€” a lint fix that renames an identifier across a 10-line addition, or wraps long lines β€” drops Kept below half and parks the PR at 085 with a "undoes this PR's change" note that will read as wrong to the author. Nothing merges that shouldn't, so this is conservative, but it may generate 085 noise on small PRs. Reindentation is already handled by the trim.
  2. If the base lands the same change independently (another PR removes the same baseline entries) and the hive rebases, the three-dot diff shrinks for a legitimate reason and this fires too. Arguably parking a now-redundant PR for a human is the right outcome, so I'd leave it β€” just noting the message won't describe what happened.

No action needed on either; the change does what it says and the tests fail without it.

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

Security perspective (head 49a7da8) β€” one in-scope gap in the new refusal.

The fixer-reverts hold can be cleared by stale-red recovery, after which the refused head is admissible. checkAdoptedPushIntent records the refusal only as MarkAdoptionEscalated(…, LaneReasonAdoptionFixerReverts) and then calls MarkAdoptedHead(key, obs.HeadSHA) (src/pkg/github/automerge/automerge_adoption_intent.go:125-139). Both lane gates key off that escalation record: adoptionIntentRefused returns the refusal only while rec.AdoptionEscalated(head) && AdoptEscalatedReason == LaneReasonAdoptionFixerReverts, and its pending branch is skipped once rec.AdoptedHead == headSHA (automerge_adoption_intent.go:155-163).

In escapeStalledAdoption, the recovery block runs before the new hold you added at automerge_contributor_adopt.go:2310: when the head is stalled red and recoverStaleRedAdoption attempts a recovery, it calls store.ClearAdoptionEscalation(key) for any reason (automerge_contributor_adopt.go:2284-2294). recoverByRerun re-runs CI on the same head (automerge_adoption_recovery.go:238-239), so the head does not move. After that: escalation cleared, AdoptedHead == head, HivePushedHead(head) true β†’ adoptionIntentRefused returns "", and adoptedHeadOwnedByHive (automerge_contributor_lane.go:621-631, rec.AdoptedInPlace() && rec.Adopted(headSHA)) admits the reverted head as soon as the rerun is green. The escape edit at :2310 says the hold lasts "until the head moves", but this path releases it on the same head.

Suggested fix β€” keep the recovery release from touching a fixer-reverts verdict (it is a verdict on the head's content, not a CI state):

		if recovery := c.recoverStaleRedAdoption(ctx, store, key, obs, rec); recovery.Attempted {
			if rec.AdoptionEscalated(obs.HeadSHA) && rec.AdoptEscalatedReason != stagelabels.LaneReasonAdoptionFixerReverts {
				store.ClearAdoptionEscalation(key)
				c.info("stage labels: adoption escalation released for recovery; back to adopted-by-hive", "repo", obs.Display, "pr", obs.Number, "head", obs.HeadSHA, "was", rec.AdoptEscalatedReason, "recovery", recovery.Reason)
			}
			return adoptionEscape{}, 0, nil
		}

(or move the LaneReasonAdoptionFixerReverts short-circuit from :2310 above the recovery block at :2284). A test row in TestAdoptedFixerPushThatRevertsPRIsRefused that drives a stalled-red + rerun recovery on the refused head and asserts the lane still refuses would pin it.

No injection or trust-boundary issues in the new code paths otherwise: the note interpolates only SHAs and integer counts, the lane change is purely additive refusal, and the compare calls use the hive's own base ref/head SHA.

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

docs-currency (delta re-review at adc32cb) β€” approve from this perspective.

The delta's docs track the code: changelog.d/fixed-adopted-fixer-reverts-pr.md and src/docs/labels-and-control-signals/stage-labels.md:1054-1072 now name the contributor-head baseline (adopted_intent_head, matching the JSON tag at src/pkg/stagelabels/store.go:93), the chain/stacked-push rule, the stale-red carve-out (automerge_contributor_adopt.go:2319-2322) and the hive-push-only note rewrite (issue_request_status_notes.go:82 / hivePushedAdoptedHead).

One operator-facing doc the PR does not touch still describes the lane admission without the new gate:

  • src/docs/hive-merge.md:884-898 ("Adopted by the hive" admission) says the head "exactly the head the hive adopted or pushed (AdoptedHead)" is admitted and "every other gate below still applies", but the new refusal runs before admission (automerge_contributor_lane.go:1408-1412 β†’ adoptionIntentRefused, automerge_adoption_intent.go:154-165) and neither contributor-lane:adoption-intent-pending nor adoption-fixer-reverts-pr appears anywhere in that file. An operator reading the merge doc to explain a held adopted PR will not find either reason. Suggested addition after the auto_merge: false sentence:
    (default on). Every other gate below still applies. A head the hive pushed
    is admitted only after the intent check in `automerge_adoption_intent.go`
    has taken it: until then the lane refuses it as
    `contributor-lane:adoption-intent-pending`, and a push that kept fewer than
    half of the PR's changed lines is refused as `adoption-fixer-reverts-pr`
    (the PR sits at `stage/085-needs-decision`; see stage-labels.md).

Prior findings (not this perspective): the baseline-erosion items at automerge_adoption_intent.go:116-136 are fixed via Record.IntentBaseHead(); the stale-red release at automerge_contributor_adopt.go:2291 is fixed (:2319); the GetCommit-error path at automerge_contributor_adopt.go:1985-1991 still calls MarkAdoptedHead without the intent check.

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

Correctness re-review at adc32cb (delta vs 49a7da8; the rest of the delta is the v6 merge).

Previous findings: the refused-head-becomes-baseline issue is fixed (stagelabels/store.go:1439,1609; automerge_adoption_intent.go:115, covered by TestAdoptedFixerPushOnTopOfRefusedHeadStaysRefused / TestAdoptedFixerPushChainCannotErodeChange). The recovery-clears-refusal issue is fixed at the record level (automerge_contributor_adopt.go:2322) but see (2) below. The GetCommit-error bypass is still present (1).

1. (still present) A transient GetCommit error admits an unrecorded hive push without the intent check β€” src/pkg/github/automerge/automerge_contributor_adopt.go:1985-1990. On error the code calls store.MarkAdoptedHead(key, obs.HeadSHA), so AdoptedHead == head, adoptionIntentRefused returns "" (automerge_adoption_intent.go:154-163: the head is neither escalated nor in HivePushedHeads), and the next sweep returns early at :1976 (obs.HeadSHA == prev.AdoptedHead). The check never runs for that head. Fixer pushes go straight to the fork via git push (per the PR body), so this is the live path for utah#1091-style pushes. Leaving the head unmarked keeps the adoption live (AdoptionLive does not depend on the head) and re-reads it next sweep, exactly like the unreadable-diff branch at automerge_adoption_intent.go:117-120:

	if err != nil {
		// Unknown pusher: keep the adoption as it is and re-read next sweep;
		// the head is not taken until its pusher, and its intent, are known.
		c.warn("stage labels: adopted head changed; pusher unknown, attribution deferred", "repo", obs.Display, "pr", obs.Number, "head", obs.HeadSHA, "error", err)
		return 0, nil
	}

2. (new) The recovery sweep still reports the refused head as not escalated, so the label flaps 085 β†’ 074 β†’ 085 β€” automerge_contributor_adopt.go:2318-2326. When recoverStaleRedAdoption returns Attempted the branch now (correctly) skips ClearAdoptionEscalation for LaneReasonAdoptionFixerReverts, but still falls through to return adoptionEscape{}, 0, nil. The caller (automerge_stage_labels.go:1267-1279) had already set verdict.Stage = AdoptedByHive and only overrides on esc.Escalated, so the rerun sweep writes stage/074 on a head the record refuses; the next sweep (already-attempted, automerge_adoption_recovery.go:203-206) returns Escalated and writes 085 again. HoldsEscalation does not catch this (it excludes owned-rank verdicts, stageengine/derive_pr.go:366). TestAdoptedFixerRevertsSurvivesStaleRedRecovery (automerge_adoption_intent_test.go:322-331) checks the record and gate but not h.addedLabels(), unlike :143.

 		if recovery := c.recoverStaleRedAdoption(ctx, store, key, obs, rec); recovery.Attempted {
+			if rec.AdoptionEscalated(obs.HeadSHA) && rec.AdoptEscalatedReason == stagelabels.LaneReasonAdoptionFixerReverts {
+				// A fixer-reverts refusal is a verdict on the head's content, not
+				// its CI: the rerun cannot restore the PR's change, so the PR
+				// stays at 085 while it runs.
+				return adoptionEscape{Escalated: true, Reason: stagelabels.LaneReasonAdoptionFixerReverts}, 0, nil
+			}
-			if rec.AdoptionEscalated(obs.HeadSHA) && rec.AdoptEscalatedReason != stagelabels.LaneReasonAdoptionFixerReverts {
+			if rec.AdoptionEscalated(obs.HeadSHA) {
 				store.ClearAdoptionEscalation(key)

and add to the recovery test after the second observe: if strings.Contains(strings.Join(h.addedLabels(), ","), "stage/074") { t.Fatalf(...) }.

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

Intent-alignment re-review at adc32cb (delta from 49a7da8; the v6 merge noise was skipped, only the fix commit was judged).

Fixed since last head: refused push becoming the next baseline (store.go:1439-1444 IntentBaseHead, set in MarkAdoptedInPlace at store.go:1609, never touched by MarkAdoptedHead at store.go:1646); stale-red recovery clearing the fixer-reverts refusal (automerge_contributor_adopt.go:2322). Both covered by TestAdoptedFixerPushOnTopOfRefusedHeadStaysRefused, TestAdoptedFixerPushChainCannotErodeChange, TestAdoptedFixerRevertsSurvivesStaleRedRecovery.

Still present β€” the body's "every hive push is checked before the hive takes it as its head" has one hole. src/pkg/github/automerge/automerge_contributor_adopt.go:1985-1990: when GetCommit fails on a head that has no recorded push (the direct git push case the body describes β€” nothing calls MarkHivePushedHead for it), the head is MarkAdoptedHead'd without checkAdoptedPushIntent. The lane then admits it as the hive's head, and the new docs line "Until the check has passed, the lane refuses the head as contributor-lane:adoption-intent-pending" (stage-labels.md) does not hold for that sweep. Pre-existing line, but the PR's contract now depends on it. Suggested fix β€” leave the head unmarked so the next sweep re-reads it, matching the unreadable-diff branch at automerge_adoption_intent.go:116-119:

	if err != nil {
		// Unknown pusher: leave the head unconfirmed so the lane holds it
		// (adoption-intent-pending) and the next sweep re-reads the commit.
		c.warn("stage labels: adopted head changed; pusher unknown, intent check deferred", "repo", obs.Display, "pr", obs.Number, "head", obs.HeadSHA, "error", err)
		return 0, nil
	}

Minor: MarkYielded (store.go:1684-1689) and ClearAdoption (store.go:2121-2125) reset every other adoption field but not the new AdoptedIntentHead. Harmless today because settleInPlaceAdoption gates on AdoptedInPlace() and MarkAdoptedInPlace overwrites it, but add r.AdoptedIntentHead = "" to both for consistency.

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

Style re-review at adc32cb (delta since 49a7da8; the ~180-file delta is almost all the v6 rebase β€” only the adoption-intent files were judged).

Previous findings: the refused-head-becomes-baseline pair (correctness/intent-alignment, automerge_adoption_intent.go:116/136) is fixed by Record.IntentBaseHead() (stagelabels/store.go:1439-1445, set in MarkAdoptedInPlace at :1609). The stale-red recovery clear (intent-alignment/security, automerge_contributor_adopt.go:2291) is fixed at :2322. The GetCommit-error path admitting a hive head without the intent check (correctness, automerge_contributor_adopt.go:1985-1991) is still present β€” unchanged in this delta, left to that perspective.

One advisory on the new guard, not blocking:

automerge_contributor_adopt.go:2319-2325 β€” the fixer-reverts exclusion lives in the wrong place for this file's idiom. The existing content-verdict refusal (adoptionWorkflowRefusedReason) is pinned out of recovery at the candidate check, automerge_adoption_recovery.go:80-82, so no update-branch/rerun is ever issued for it. The new refusal instead lets recoverStaleRedAdoption run (the test at automerge_adoption_intent_test.go TestAdoptedFixerRevertsSurvivesStaleRedRecovery asserts one rerun fires) and then skips the clear in the caller. That spends an update-branch or rerun on a head the comment itself says "cannot restore the PR's change", and an update-branch merge commit on a fork head becomes a new hive push that is re-judged and earns a second fixer-reverts note. Matching the existing idiom removes the caller-side special case:

--- a/src/pkg/github/automerge/automerge_adoption_recovery.go
+++ b/src/pkg/github/automerge/automerge_adoption_recovery.go
@@ -77,7 +77,10 @@ func adoptionRecoveryCandidate(obs stageObservation, rec stagelabels.Record) bool {
-	if rec.AdoptionEscalated(obs.HeadSHA) && rec.AdoptEscalatedReason == adoptionWorkflowRefusedReason {
+	// Verdicts on the head's content: a rerun or rebase cannot change them.
+	if rec.AdoptionEscalated(obs.HeadSHA) && (rec.AdoptEscalatedReason == adoptionWorkflowRefusedReason || rec.AdoptEscalatedReason == stagelabels.LaneReasonAdoptionFixerReverts) {
 		return false
 	}
--- a/src/pkg/github/automerge/automerge_contributor_adopt.go
+++ b/src/pkg/github/automerge/automerge_contributor_adopt.go
@@ -2319,7 +2319,4 @@
-			// A fixer-reverts refusal is a verdict on the head's content, not
-			// its CI: a rerun or rebase cannot restore the PR's change, so the
-			// recovery never releases it.
-			if rec.AdoptionEscalated(obs.HeadSHA) && rec.AdoptEscalatedReason != stagelabels.LaneReasonAdoptionFixerReverts {
+			if rec.AdoptionEscalated(obs.HeadSHA) {

(and flip the test's len(h.adopt.reruns) != 1 to != 0.)

Evidence bundle `#16816b4171e9` sha256:4dfc3bd4660398669f51a9560324e406cc2b3c70b32e2eccd935e98d2fb8cba5 β€” download from the dashboard or `hivectl review evidence #16816`.

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

Read at b4171e9 against the v6 tree (store helpers, settleInPlaceAdoption, escapeStalledAdoption, the contributor-lane gate). This looks correct to me; the body matches the diff. Two low-severity edge cases a maintainer may want to weigh, neither blocking.

What I verified

  • checkAdoptedPushIntent ends with MarkAdoptedHead on both pass and refusal, so the next sweep short-circuits at automerge_contributor_adopt.go:1973 (obs.HeadSHA == prev.AdoptedHead) and does not re-judge or re-post; MarkAdoptedHead (store.go:1636) does not touch AdoptEscalatedHead, so the refusal survives. On a failed note post the head stays unmarked and HivePushedHead re-enters the check next sweep β€” the retry the comment promises is real.
  • escapeStalledAdoption returns Escalated for LaneReasonAdoptionFixerReverts before the re-home branch (automerge_contributor_adopt.go:2342), so a refused head cannot escape via supersession, and the recovery block at :2319 explicitly keeps it.
  • Judging against IntentBaseHead() rather than the previous hive head closes the "chain of small cuts" hole; TestAdoptedFixerPushChainCannotErodeChange covers it.
  • go build of pkg/github/..., pkg/stagelabels, pkg/dashboard is clean at this head; CI is green apart from tide.

Low β€” a base merge after upstream lands the same change reads as a revert (automerge_adoption_intent.go:85, :64-72)
Both compares are three-dot, so each uses its own merge-base. If v6 independently lands the hunks this PR makes (e.g. another PR removes the same triage.toml entries) and the hive then pushes a base-sync merge commit, v6...before still shows the PR's lines (old merge-base) while v6...after no longer does (new merge-base). Kept drops to ~0 and the head is refused with a note saying the hive's push "undoes this PR's change", when the push was a plain base sync and the PR became redundant upstream. Routing it to 085 is probably still the right outcome, but the note's stated cause is wrong in that case. The unchanged diff (a base merge) row at automerge_adoption_intent_test.go:52 only models a merge that does not move the diff. Consider wording the note to cover "or the base already carries it", or checking before's hunks against v6 itself before calling it a revert.

Low β€” ---/+++ skip also drops real content lines (automerge_adoption_intent.go:51)
GitHub's files[].patch starts at @@, so the header guard never fires on a header; what it does drop is any removed line whose content begins with -- (SQL/Lua comments, --flag lines in docs or scripts) and any added line beginning with ++. It is symmetric, so it only undercounts Own, but a PR that is mostly removing --flag lines from a doc could reach Own == 0 and the guard would never engage. Dropping the two HasPrefix checks (or anchoring them to line index 0 of the patch) would be enough.

Not a defect, just a note: the other compare call sites in this package wrap ctx with hgithub.WithRESTCaller for attribution (automerge_adoption_recovery.go:194, automerge_bot_takeover.go:124); the new one passes ctx bare, as :1931 in the adopt file does.

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

Review asks:

  • the review swarm requested changes

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.

Danathar and others added 2 commits November 5, 2026 19:13
Signed-off-by: Danathar <Danathar@users.noreply.github.com>
…eep the refusal through recovery

Review findings on hivecommons#16816 at 49a7da8:
- ci-maintainer/adjudicator: a refused head became the next check's
  baseline. Record.AdoptedIntentHead (set in MarkAdoptedInPlace,
  IntentBaseHead falls back to AdoptedHead) is the baseline for every push.
- adjudicator-2: stale-red recovery cleared any escalation; it no longer
  clears adoption-fixer-reverts-pr.
- reviewer: the awaiting-ci rewrite now needs a hive push (recorded or
  App-linked commit); an author's push keeps its note.

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

Danathar commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Fixed all three findings from the status comment at 49a7da8, in adc32cba (v6 merged in first, 36bc861, no force-push):

  1. The refused head became the next push's baseline (ci-maintainer, medium; adjudicator). A new Record.AdoptedIntentHead is set in MarkAdoptedInPlace to the contributor's head, and IntentBaseHead() falls back to AdoptedHead for older records. checkAdoptedPushIntent now judges every hive push against that head, and the note names it. Tests:
    • TestAdoptedFixerPushOnTopOfRefusedHeadStaysRefused: a push on top of a75a567 is still refused.
    • TestAdoptedFixerPushChainCannotErodeChange: a push keeping 60% passes; the next, at 12/35 overall, is refused.
    • TestIntentBaseHead covers the fallback.
  2. Stale-red recovery cleared the refusal (adjudicator-2). Recovery no longer clears an adoption-fixer-reverts-pr escalation; it can still re-run CI. Test: TestAdoptedFixerRevertsSurvivesStaleRedRecovery drives a re-run on the refused head, and the record and lane gate still refuse it.
  3. The awaiting-ci rewrite fired on author pushes (reviewer, low). The rewrite now requires a hive push. That means rec.HivePushedHead(head) or a commit GitHub links to a hive account. Requiring HivePushedHead alone would have missed the utah#1091 case, because that note was posted 22 s after the push, before any stage pass had recorded it. TestAwaitingCINoteOnAdoptedPRWaitsForIntentCheck now covers an author push (note unchanged), an App-linked push and a recorded push.

Mutants for these fixes: 7 of 7 caught. The suites pass: pkg/github/..., stagelabels, policies, writeback, dashboard. Docs, changelog and PR body are updated.

@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 automerge_adoption_intent.go in full, the three call sites (settleInPlaceAdoption, escapeStalledAdoption, evaluateContributorLanePR), Store.MarkAdoptedInPlace/MarkAdoptedHead/IntentBaseHead, and adoptedAwaitingCINote, at head adc32cb on top of v6. go build ./pkg/github/... ./pkg/stagelabels ./pkg/dashboard and gofmt are clean; CI on the head is green apart from tide.

The guard does what it says, and the fail-safe paths hold. Verified:

  • Both hive-advance branches in settleInPlaceAdoption (automerge_contributor_adopt.go:1981, :1994) now defer MarkAdoptedHead to checkAdoptedPushIntent, so an unreadable compare leaves the head unmarked; adoptedHeadOwnedByHive admits only AdoptedHead, and adoptionIntentRefused returns adoption-intent-pending for a recorded hive push that is not yet AdoptedHead. Nothing merges a head the check has not passed.
  • On refusal the escalation is recorded before the note and MarkAdoptedHead runs only after the note posts, so a failed post is retried next sweep and the second sweep (AdoptionEscalationNoted) does not re-post. The stale-red recovery exclusion and the escapeStalledAdoption hold both key on LaneReasonAdoptionFixerReverts, so the 085 park survives reruns.
  • prChangeUnits skips +++/--- headers, @@ lines and \ No newline, counts a patch-less file as one unit per status, and judgeAdoptionIntent takes min(n, now[unit]) per multiset key β€” a moved hunk is kept, a reworded one is not, which is the intended "lines" semantics the body describes.
  • Three-dot CompareCommits(base, head) means a base merge in the fixer push is not counted against the PR (adoptedPushIntent).

One baseline gap (low), worth a look:

AdoptedIntentHead is set only in MarkAdoptedInPlace (stagelabels/store.go:1609). But settleInPlaceAdoption keeps the adoption and advances AdoptedHead on a head the hive did not push in three places β€” commit lookup failed (automerge_contributor_adopt.go:1989), adoption_strict_attribution off (:1998), and no repo push evidence yet (:2003) β€” without touching AdoptedIntentHead. In those configurations an author who pushes to their own adopted PR (say, splitting half the change out to a separate PR, as the hive's own notes often ask) leaves the baseline at their original head; the next hive fix push is then judged against a diff the author already narrowed and can be refused as adoption-fixer-reverts-pr for lines the hive never removed. Under strict attribution with repo evidence this cannot happen (an author push yields and a re-adoption resets the baseline), so the default is safe. If the intent is "the contributor's latest head", refreshing AdoptedIntentHead alongside AdoptedHead on those three non-hive paths closes it; TestIntentBaseHead covers the hive-push case but not an author advance.

Threshold being non-configurable is fine by me for a first cut; the body states it plainly.

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

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

Review asks:

  • the review swarm requested changes

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

@hivecommons-hive
hivecommons-hive Bot merged commit 6e7992b into hivecommons:v6 Nov 6, 2026
68 of 69 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at b4171e9.

@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 scanner-automerge.md policy edit (fixer must keep the PR's change; park with needs-human when CI can pass only by undoing it) β€” it touches hive policy text, which a maintainer signs off rather than the hive.

The code looks correct to me; the only thing left is a maintainer sign-off on the policy text.

What I verified against the tree at b4171e9:

  • src/pkg/github/automerge/automerge_contributor_adopt.go:1980-1996 β€” both hive-push branches of settleInPlaceAdoption now go through checkAdoptedPushIntent instead of MarkAdoptedHead directly. The early return at :1973 (obs.HeadSHA == prev.AdoptedHead) still fires on later sweeps because checkAdoptedPushIntent calls MarkAdoptedHead after escalating (automerge_adoption_intent.go:150), so a refused head is judged once and the note cannot repost (AdoptionEscalationNoted, store.go:1535).
  • automerge_adoption_intent.go:161-172 β€” adoptionIntentRefused keys off AdoptEscalatedReason == LaneReasonAdoptionFixerReverts, and escapeStalledAdoption (automerge_contributor_adopt.go:2321-2325, :2342) now excludes that reason from both the stale-red release and the reason-cleared path, so nothing I could find clears the refusal short of a new head. The gate is wired before any admission path in evaluateContributorLanePR (automerge_contributor_lane.go:1408-1411).
  • store.go:1606-1609 β€” AdoptedIntentHead is set only in MarkAdoptedInPlace and never touched by MarkAdoptedHead (:1636-1649), so the baseline really is the contributor's head for the life of the adoption; IntentBaseHead falls back to AdoptedHead for pre-existing records, which means those (and only those) remain judged push-over-push until they re-adopt. That seems like an acceptable transition.
  • automerge_adoption_intent.go:88-94 β€” three-dot CompareCommits with PerPage: 300 matches the compare API's 300-file ceiling, and judgeAdoptionIntent refuses to judge at >= 300 rather than scoring a truncated list.
  • issue_request_status_notes.go:63-86 β€” the awaiting-ci rewrite only runs for the awaiting-ci key on a record that AdoptedInPlace(), and leaves the body untouched on any API error, so it cannot alter other notes.
  • src/policies/scanner-automerge.md and src/pkg/policies/defaults/scanner-automerge.md are byte-identical after the edit.

One observation, not a defect: prChangeUnits (automerge_adoption_intent.go:44-60) matches lines by exact (trimmed) text, so a fixer push that reformats or rewrites most of a very small PR's lines will read as a revert and park at 085. That is the conservative direction, and the note tells the person what happened, so I would leave it.

I could not run go test on this host; the hub/agent/rest shards and patch-coverage are green on this head.

Routing rather than confirming outright only because the diff edits hive policy text; the edit narrows what the fixer may do, and the author is an approver.

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

hivecommons-hive Bot pushed a commit that referenced this pull request Nov 7, 2026
…the reviewer approves it (#17000)

The undo guard (#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.


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>
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant