Repository navigation
π fix: stabilize same-head stage verdicts and suppress reversals - #16881
Conversation
Canonicalize actionable reviewer verdicts independently of the prior stage. Bound repeated label writes with a 15-minute same-head reversal guard, using the actual writer outcome rather than pre-observed legacy store state. Hive-Run: hivecommons#16880 Hive-Plan: stage-reconciler-idempotence-and-anti-flap Hive-Spec: hivecommons#16880#recommendation-1-2 Signed-off-by: mendezr <mendezr@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
|
@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. Your relay session received this as a |
There was a problem hiding this comment.
Read the diff against v5 at merge-base 8b5a160, plus stagelabels/store.go (ObserveProgress), stagelabels/enforce.go (Outcome, applyPlan) and the legacy caller in github/automerge/automerge_stage_labels.go. The change looks correct to me; one low-severity side effect worth knowing about.
Looks correct
derive_pr_classify.go:592-604β dropping the prior-070/same-head precondition makesPreserveNormalizedFixingStagea pure function of current evidence, andFixingStage(obs)(line 328) picks 070/071/072 by lane/author kind instead of hard-coding 070. Explicit decisions stay human-owned becauseprstage.NormalizeReviewVerdictwon't returnchanges_requestedfor them.reconciler.go:170-176β arming the guard only fromout.Removedon a successful, non-gated write is the right source: a hint-no-op write leavesRemovedempty (enforce.goapplyPlan), so idle sweeps never arm or extend it.suppressStageFlap(writer.go:31-52) releases on new head, 15-min expiry andTerminal, and the test covers all three.
Low: Store EnteredAt/History churn under the legacy pre-observe path
automerge_stage_labels.go:1180 calls store.Observe(key, verdict.Stage, β¦) before ReconcileBatch. When the engine then suppresses the reversal, reconciler.go:157 calls ObserveProgress(key, last.to, β¦), so each suppressed sweep flips the Store stage twice. Because ObserveProgress treats any prev.Stage != stage as a stage entry (store.go:722-728, 760), every sweep resets EnteredAt, ReasonChangedAt, EntryCommented/StallCommented, and appends two hops to History. Consequence: for the 15-minute window the dwell/stall clock (store.go:2573-2580 reads EnteredAt) restarts every sweep and the record's history shows an AβBβA pair per sweep even though labels never moved. The regression and entry comments are head-keyed (automerge_stage_labels.go:1460-1466, automerge_stage_human.go:646-660) so I don't see a repost risk β this is bookkeeping noise, not a wrong label. TestReconcilerSuppressesSameHeadStageReversal asserts rec.Stage but not EnteredAt, so it wouldn't catch it. A cheap fix would be to skip the restore when prev.Stage == last.to already, or to have the legacy sweep stop pre-observing; either is fine as a follow-up.
Open note (by design, not a defect): the guard also delays a legitimate same-head reversal within 15 minutes β e.g. a maintainer answering a decision right after the PR entered 085 waits up to one window before 085β070 is written. Seems like an acceptable trade for the flap it stops, just worth stating in the changelog or #16880.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Keep unchanged-head flap suppression scoped to unchanged CI, review and adoption evidence. Do not block adoption release, escalation recovery or a check rerun turning green. Ignore prior stage and display outputs so legacy pre-observation still cannot defeat the guard. Signed-off-by: mendezr <mendezr@users.noreply.github.com>
There was a problem hiding this comment.
Read the tree at 41f3c4f, not just the diff. The change looks correct to me; one low-severity trade-off worth knowing about, no blockers.
Normalization fix β src/pkg/stageengine/derive_pr_classify.go:592-604: RequiresHumanStage (line 578) already normalizes before deciding 085, so the only way a raw requires_human that normalizes to changes_requested reached 085 was the lane reason path, and the old guard only undid it when a prior 070 on the same head existed β i.e. the stage depended on which sweep wrote last. Dropping the history gate and returning FixingStage(obs) makes both the engine path (derive_pr.go:239-252, obs.AuthorKind set at line 238) and the legacy pass (automerge_stage_labels.go:915-934, AuthorKind set at 915) produce the same 07x stage from the same evidence. PreserveStageOnStaleDecisionAnswer keeps its hadPrev gate, so the "no prior" case cannot wrongly park at 085.
Flap guard β reconciler.go:153-160 runs before Store.ObserveProgress, and the suppressed path restores last.to. I checked the legacy consumer that worried me: postHumanEntry (automerge_stage_human.go:632) returns early when rec.Stage != route.Stage, so a suppressed 070β085 reversal does not post a needs-decision entry comment for a label that was never written. Arming only from stagelabels.Current(out.Removed) (reconciler.go:170-175) correctly ignores first-labelling and gated writes.
Trade-off to be aware of (low) β writer.go:44-46 compares stages only, not reasons. If the hive wrote 070β085 and within 15 min a trusted human answers the decision on the same head, the derived 070 (reason=decision-answered) is the exact inverse and is suppressed until the window expires; the PR body lists only new head / timeout / terminal as releases, so this is by design, but it delays fixer dispatch by up to 15 min in that one human-driven case. Not a defect; a one-line follow-up could exempt StageReasonDecisionAnswered if that latency matters.
Built ./pkg/stageengine ./pkg/github/automerge and type-checked the new tests locally (the suite itself runs in CI). Changelog fragment is named per changelog.d/README.md.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Correctness delta re-review (read Previous findings
Delta ( One narrowing to be aware of (low): the snapshot keeps β hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from Style/maintainability review (read at head
Minor: the changelog fragment says reversals are suppressed "for 15 minutes", but Review findings from Intent alignment vs #16880 (read at head
Limit of this review: I could not confirm that #16607's own flap goes through the normalized-fixing path (its verdict is an explicit decision request, which Review findings from Read the diff against the v5 tree at Root cause matches the fix. Reversal guard is narrow and correctly placed. Downstream readers of Changelog fragment stage 095-pre-merge-soak β 060-reviewed: untrusted-author-role Evidence bundle `#168810384cb3` sha256:19ba997b283842e67213fc3f6f2923fc5f732bc6d010c6120ddfb6dd712ee11b β download from the dashboard or `hivectl review evidence #16881`. |
|
Ready for a human merge: verdict approved @0384cb3, 61/61 checks green, DCO yes, soak 10m0s elapsed. Blocked only by The hive never approves on your behalf: |
|
Merged by hive contributor-lane auto-merge: CI green for β₯10m, reviewer verdict approve, @mendezr holds the trusted tier in this hive's contributor registry. |
β¦85 PR to 080 (#17012) projectbluefin/utah-packages#917 (fork PR, approve verdict, fork-guarded red required Canary, head 7e52182c0 unchanged) went 085 -> 080 -> 085 about 15 times on 2026-11-07. Each 080 came from a contributor-lane pass refused the destination-merge lock ("destination merge already in progress", another sweep was evaluating a PR into the same base). The lane records that as base-refresh:merge-guard with the error, so the observation is Err, and ClassifyStage's errored-lane branch ran before the hand-off check that #16819 added: approve verdict + no CI reason = a weak 080. The 080 seated the red PR at a merge train's front until the next evaluated pass. The refusal is now no stage opinion whether or not the lane reports an error. The reversal guard (#16881) and the dampener (#16980) on v6 tip do not stop this shape: the replay test fails on tip at the first refusal. Also corrects two stale derive_pr_classify.go citations in the stage-engine docs. 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>
Summary
Fixes #16880
requires_humannormalization independent of the previous stage. Identical current remediation evidence now selects the same author-kind-appropriate fixing stage whether the previous record was 070, 085, or absent. Explicit decision requests, policy-owned human verdicts, and risk escalations retain the existing human-decision checks.stage flap suppressed, and refuses the inverse transition without writing labels. Failed/gated writes do not arm it; no-op and suppressed sweeps do not extend the window. A new head, timeout, or terminal decision releases it.Regression coverage
Validation and scope
gofmt -lon changed Go files: clean.git diff --check: clean.AGENTS.md; CI is the test verdict.β hive: backend=pi model=openai/gpt-6.1-sol
π Hive Agent:
contributor| SHA:41f3c4fce