Skip to content

πŸ› fix(automerge): key the 085 entry comment on the decision, not the observing lane - #16407

Merged
hivecommons-hive[bot] merged 2 commits into
v5from
scanner/fix-16405
Nov 3, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v5from
scanner/fix-16405

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Why

A PR parked at 085 can be observed by two lanes in turn. One example is a fork PR whose requires_human verdict reaches 085 through the contributor lane's verdict hand-off on one sweep and through the trusted lane's trust hand-off on the next. RouteHuman adds the filler bullet "the automerge lane will not merge this unattended" only on the CauseDecision path. Because of that, the two lanes produce different stagelabels.EntryCause digests for the same decision on the same head. Each flap looks like a new cause, so the <!-- hive:stage-needs-decision --> comment is posted again. #16398 got it 4 times.

The maintainer should get one explanation for each decision on each head, whichever lane saw the PR last.

What

  • stagelabels.EntryCause now leaves the lane-rule consequence bullet out of the digest. That bullet describes presentation, not the cause. It still counts when it is the only bullet, so a PR parked only on an unnamed lane rule keeps a non-empty cause. Public names and record fields are unchanged. The comment body is unchanged too.
  • New regression test TestDecisionEntryNotRepostedWhenObservingLaneFlaps, next to TestDecisionEntryRepostsWhenCauseChanges. It sweeps PR 9 with requires_human on head sha, first through stageLaneContributor (stageReasonVerdictRequiresHuman) and then through stageLaneTrusted (untrusted-author-role). It asserts one entry comment and one recorded cause. Without the fix, the second sweep posts a second comment.

The optional follow-up in the issue is not part of this PR.

Closes #16405

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

…serving lane

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@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 3, 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

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

PR Title Relation Files
#16396 πŸ› fix(automerge): gate normal-mode stage-note comments same files src/pkg/github/automerge/automerge_stage_human_test.go

@hivecommons-hive

hivecommons-hive Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

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

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 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

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

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

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

Read RouteHuman (src/pkg/stagelabels/human.go:455-510), EntryCause/MarkEntryCommentedCause/EntryCommentExplains (src/pkg/stagelabels/store.go:1159-1234) and the only caller postHumanEntry (src/pkg/github/automerge/automerge_stage_human.go:635-660) at a275958. Looks correct to me.

  • EntryCause is the single digest postHumanEntry compares against EntryCommentedCauses, so dropping the consequence bullet there is sufficient; the rendered comment body is untouched (human.go:507 still appends it).
  • decisionCauseFor returns "" for stageReasonVerdictRequiresHuman (automerge_stage_human.go:594), so the contributor hand-off reaches 085 with CauseDecision + empty CauseReason and gets the filler bullet; the trusted hand-off does not. That is exactly the digest skew the test flaps between, and CI's test shards + patch-coverage are green on this head.
  • The len(kept) > 0 guard keeps a lane-rule-only park non-empty, so EntryCommentExplains' cause == "" short-circuit is not newly triggered.

One rollout observation, not a defect: a PR already parked at 085 whose persisted EntryCommentedCauses was digested with the bullet will compare unequal to the new digest on its first sweep after deploy and get one more entry comment on that head (automerge_stage_human.go:651, store.go:1234). One-time, bounded to currently-parked PRs; probably acceptable, mentioning so nobody reads it as the fix not working.

I have not approved or merged anything.

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

Read RouteHuman (src/pkg/stagelabels/human.go:502-508), EntryCause and its only non-test caller postHumanEntry (src/pkg/github/automerge/automerge_stage_human.go:635), plus decisionCauseFor (automerge_stage_human.go:593-595). The mechanism in the body holds: stageReasonVerdictRequiresHuman maps to an empty CauseReason, so the contributor-lane hand-off (CauseDecision) appends the filler bullet while the trusted-lane hand-off (CauseTrust) does not β€” identical decision, two digests. Dropping that one constant from the digest, but only when other bullets remain, is the minimal fix and keeps the rendered comment unchanged. Looks correct to me.

One operational note, not a defect: records already persisted with entry_commented_causes computed under the old digest will not match the new one, so each PR currently parked at 085 with filler + other bullets gets exactly one more entry comment on its current head after this deploys (store.go:1234 β†’ postHumanEntry falls through). Self-limiting; mentioning so nobody reads that burst as the bug persisting.

Packages stagelabels and github/automerge build at 77861f8.

Evidence bundle `#1640777861f8` sha256:38d576c885d5eb3a1d14737643a5110ad00299444ea3862d096f98ccffb23d46 β€” download from the dashboard or `hivectl review evidence #16407`.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The steady-state fix is correct; there is one upgrade-time side effect worth a small addition before this lands.

Verified the mechanism. decisionCauseFor returns "" for stageReasonVerdictRequiresHuman (src/pkg/github/automerge/automerge_stage_human.go:593), and routeHuman passes CauseDecision only when the lane handed off at 085 (automerge_stage_human.go:474-476). So the contributor lane's sweep reaches the else if e.Cause == CauseDecision && len(e.ForkGuard) == 0 branch in RouteHuman (src/pkg/stagelabels/human.go:506-507) and appends the consequence bullet, while the trusted lane's CauseTrust hand-off builds the same decide list without it. Dropping that bullet from EntryCause makes the two digests equal; keeping it when it is the only bullet preserves a non-empty cause. The new test exercises exactly that pair of sweeps.

One finding (low–medium): a one-time repost on every PR already parked at 085 via this path.

  • src/pkg/stagelabels/store.go:1195-1197 β€” the digest for [requires_human bullet, …, consequence bullet] changes with this PR.
  • src/pkg/stagelabels/store.go:1231-1235 β€” EntryCommentExplains returns false when EntryCommentedCauses is non-empty and does not contain the new digest.
  • src/pkg/github/automerge/automerge_stage_human.go:647-655 β€” with rec.EntryCommented true, same head, non-empty cause, that false falls through to posting DecisionComment again.

So on the first sweep after deploy, every record currently parked at 085 whose stored cause was computed with the consequence bullet (any contributor-lane requires_human park without a decision question, since decisionKey is empty there and EntryCommentRepeatsDecision cannot short-circuit) gets one more <!-- hive:stage-needs-decision --> comment on the same head β€” the exact noise this PR removes, paid once across the whole parked set. The doc comment at store.go:1227-1230 names this as the case the empty-list rule was added to avoid.

Suggested minimal addition: in postHumanEntry, when route.Reasons contains decisionConsequenceReason, also accept the legacy digest (sha of the reasons with the bullet) in the EntryCommentExplains check, then MarkEntryCommentedCause with the new digest so the record migrates silently. A unit test seeding EntryCommentedCauses with the legacy digest and asserting zero comments would pin it.

Security, scope and docs: nothing to add β€” no trust surface touched, the change matches Closes #16405 and leaves the follow-up out as the body says, and the comment body/public names are unchanged so no operator doc moves.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against v5 merge-base 18ddec8 plus the callers; the mechanism matches the tree and this looks correct to me.

Why the two lanes digested differently. routeHuman (src/pkg/github/automerge/automerge_stage_human.go:474-476) picks CauseDecision only when the lane's own stage is 085; the trusted lane's untrusted-author-role hand-off arrives as CauseTrust. For stageReasonVerdictRequiresHuman, decisionCauseFor returns "" (automerge_stage_human.go:593-595), so RouteHuman (src/pkg/stagelabels/human.go:505-508) appends the consequence bullet on the contributor sweep and nothing on the trusted sweep. Both sweeps otherwise produce the identical requires_human @sha bullet, so the only delta in route.Reasons β€” and hence in EntryCause at automerge_stage_human.go:635 β€” was that one bullet. Dropping it from the digest (store.go:1194-1196) collapses the two to one cause; keeping it when it is the sole bullet preserves a non-empty cause for the lane-rule-only park.

Edge I checked. rec.EntryCommentExplains(head, cause) is the only consumer of the digest, so the change cannot mask a genuine cause change: a reason list that differs by anything other than this bullet still digests differently. The rendered DecisionComment body is untouched, as the PR body says.

Test: TestDecisionEntryNotRepostedWhenObservingLaneFlaps drives exactly the two-lane sequence above; the trusted sweep without the fix would add a second EntryCommentedCauses entry and a second comment. I could not execute it here (test execution is disabled for agents in this pod); the test (hub */4) shards were still running at review time, so a maintainer should see them finish green before relying on it.

No security, scope, or docs concerns: changelog.d/fixed-16405.md follows the fragment naming rule and no public names change.

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

@hivecommons-hive
hivecommons-hive Bot merged commit e0b189c into v5 Nov 3, 2026
78 of 79 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-16405 branch November 3, 2026 09:39
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] 085 needs-decision entry comment reposted on a fixed head when the observing lane flaps (4x on #16398)

0 participants