Skip to content

🐛 fix(automerge): a maintainer keeps role/trusted when the hive merges main into their approved PR - #16993

Merged
hivecommons-hive[bot] merged 5 commits into
hivecommons:v6from
Danathar:fix/role-label-pr-author
Nov 7, 2026
Merged

hivecommons-hive[bot] merged 5 commits into
hivecommons:v6from
Danathar:fix/role-label-pr-author

Conversation

@Danathar

@Danathar Danathar commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

A maintainer trusted through auto-promotion (five clean merged PRs, registry profile still newcomer) dropped to role/newcomer after the hive merged main into their PR. The cause is not the merge commit's author. The cause is the admission route. A person's Approve carried onto the hive's merge commit (or the hive's in-place adoption) admits the head, and that route returned before the auto-promotion check, so the role label fell back to the raw registry tier. The role now comes from the author's standing on every route.

What went wrong

  • projectbluefin/utah#1132 (hanthor): the hive's log shows contributor-lane admitted … reason=contributor-lane:auto-promoted at 05:09 and 05:10Z (role trusted). At 05:10:49 hanthor's typed approve was recorded. The hive then merged main (head 235d779), and at 05:11:35 logged decision carried over base refresh. Every sweep after that logged reason=contributor-lane:operator-approval. At 05:13:52 the stage pass wrote role=newcomer (-role/trusted +role/newcomer). The approval is still carried, so it stays newcomer.
  • projectbluefin/utah-packages#893: the flip to newcomer came from an operator-approval admission at 20:45:10Z on the old head 9e6f438, before the hive's merge commit. At 20:48 the head was the merge commit 0b9c721, the approval did not carry over this time, the lane went back to auto-promoted, and the label returned to trusted at 20:49. One code path gave two answers depending on which admission route matched first. No second code path was racing.

The role was never read from the newest commit's author. The trusted-author lane never sees hanthor here. Only the contributor lane does, and its admitContributor sets ObservedTier from observedRegistryTier(author) on the adoption and operator routes, skipping the merged-history ratchet that the normal route runs.

What changes

  • The adoption and operator routes in admitContributor now record authorStandingTier. That is the registry tier, or trusted when the tier is below require_tiers and the author's clean merged history would auto-promote them. It reads the same history the normal route reads every sweep.
  • That read posts no promotion announcement and never fails admission. A failed read keeps the registry tier, which is the old behaviour.
  • The eligibility check for the ratchet (configured, not revoked, not a bot, not the App) is now one helper, autoPromotionEligible, and both callers use it.

Files

  • src/pkg/github/automerge/automerge_contributor_lane.go: the two routes, plus the new autoPromotionEligible and authorStandingTier helpers.
  • src/pkg/github/automerge/automerge_contributor_role_standing_test.go: new test.
  • changelog.d/fixed-role-label-author-standing.md

Tests

TestAdmitContributorHeadRoutesKeepAuthorStanding covers five cases:

  • an approval carried onto the hive merge commit keeps trusted
  • a hive-owned in-place adopted head keeps trusted
  • a short history still shows newcomer
  • a revoked author is never promoted
  • a tier already in require_tiers needs no history read

On v6 tip the first two fail (ObservedTier = "newcomer", want "trusted") and the three control cases pass. With the fix, all five pass. Ran go test in full for ./pkg/github/automerge/, ./pkg/stagelabels/ and ./pkg/stageengine/..., plus go vet and gofmt.

Refs projectbluefin/utah#1132

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…dmissions

The contributor lane's adoption and operator-approval routes admit a PR's
head and return before the clean-merged-PR auto-promotion check, so they
recorded the author's raw registry tier as the role. When the hive merged
main into an auto-promoted maintainer's PR and carried their approval onto
the merge commit, the PR went role/trusted -> role/newcomer
(projectbluefin/utah#1132; utah-packages#893 flipped and back as the
approval stopped matching the head).

Both routes now record authorStandingTier: the registry tier, or trusted
when the author's clean merged history would promote them. The read posts
no announcement and a failed read keeps the registry tier. The ratchet's
eligibility check is shared as autoPromotionEligible.

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

@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 admitContributor and the two head-scoped routes against 8325a54d; the fix is correct and matches what the author route already records.

Mechanism verified. admitContributor (src/pkg/github/automerge/automerge_contributor_lane.go:666-680) returns from the adopted-head and operator-approval routes before the merged-history ratchet at :687-696, and both used observedRegistryTier(author) — the raw profile — for ObservedTier, which feeds the role/* label. The author's own route sets ObservedTier: "trusted" on a clean history (:694). authorStandingTier (:768-783) reproduces exactly that outcome: tier in RequireTiers → unchanged; otherwise same autoPromotionEligible gate (revoked / [bot] / App login, :752-760, extracted verbatim from the old inline condition) and the same contributorCleanMergedHistory call with the same need/hive-wide args. A history read error degrades to the registry tier instead of failing admission, which is the right asymmetry — admission already happened by a head-scoped route and the label is cosmetic. go build ./pkg/github/automerge/ passes.

Cost: this adds a contributorCleanMergedHistory walk on head-scoped admissions, but only for authors below require_tiers and only where the author route would have walked anyway, so it is not a new class of API traffic.

One info note, not a defect: the author route also calls ClearTrustPromotion(author) when history.Reason == contributorHistoryReasonDemoted (:696-700); authorStandingTier does not. The label is still correct (falls back to the registry tier), and the store is cleared the next time the author route runs, so I would not hold the PR for it — just noting the two paths are no longer perfectly symmetric.

Test table covers operator and adopted routes, short history, revoked, and in-require_tiers. Looks correct to me.

— hive: agent=reviewer-2 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 (folded here because this head already carries its hive review):

Read the change against v6 (src/pkg/github/automerge/automerge_contributor_lane.go) and its callers. Looks correct to me.

  • The two head-scoped routes (adoptedHeadOwnedByHive at :675, operatorAdmission at :678) previously returned observedRegistryTier(author) before the ratchet at :688 ran, which is exactly the path that produced role/newcomer for an auto-promoted author. authorStandingTier (:770) now computes the same thing the author route records at :694 (ObservedTier: "trusted" on history.Clean), so the label no longer depends on which route admitted the head.
  • autoPromotionEligible (:752) is a faithful extraction of the old inline gate; the added empty-author short-circuit was already a no-op inside contributorCleanMergedHistory (:851 returns Reason: "disabled" for an empty author).
  • A failed history read on the head routes keeps the registry tier and never fails admission (:784-787); the author route still returns its auto-promote-history error as before. Labelling on the head routes deliberately skips announceContributorAutoPromotion/ClearTrustPromotion, which the new test pins (comments == 0).
  • RoleFromTier (stagelabels.go:595) maps "trusted" to RoleTrusted only when require_tiers contains it — same dependency the existing author route already had, so no new behaviour there.
  • Cost: one PullRequests.List per sweep for an approved/adopted head whose author is below require_tiers, the same shape the author route already pays each sweep.

Test TestAdmitContributorHeadRoutesKeepAuthorStanding covers both routes, short history, revoked, and a tier already in require_tiers. CI test/coverage/patch-coverage are green on eec1832.

stage 080-awaiting-merge-admission → 072-returned-to-contributor: check-failure

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

Conclusion: looks correct to me. Verified against the v6 base, not the body.

  • automerge_contributor_lane.go:679 (v6) is the condition autoPromotionEligible extracts — AutoPromoteAfterMergedPR > 0, not revoked, not [bot], not the App login — reproduced exactly, plus a harmless empty-author guard. The author route's behaviour is unchanged.
  • automerge_contributor_lane.go:686 (v6) is where the author route records ObservedTier: "trusted" after a clean history; authorStandingTier returns the same value under the same history.Clean test, so a head-scoped admission (adoption at adoptedHeadOwnedByHive, or operatorAdmission) now labels the author the way their own route would have. That is the mechanism behind the utah#1132 flip, and this closes it.
  • The short-circuit tier != "" && policy.RequireTiers[tier] (RequireTiers map[string]bool, line 205) avoids the history read for authors already at an admitted tier, and a failed read falls back to the registry tier via c.debug rather than failing admission — the right failure mode for a label-only computation.
  • Deliberately not done here, and correctly so: authorStandingTier does not announce a promotion or call ClearTrustPromotion on demotion; those stay with the author route, which still runs on the author's own heads.

Cost note (info): head-scoped admissions for sub-tier authors now do one contributorCleanMergedHistory read per cycle, the same read the author route already performs, so no new class of API traffic.

The test file sets up both routes and asserts role/trusted survives a hive merge-of-main with a carried approval; it fails on v6 since the old code returned observedRegistryTier there. No security or scope concerns. I have not approved or changed anything.

Evidence bundle `#169932eabd89` sha256:36ab85fe82774601e6394f0c1152afa7411fa229bff980c0ae9c94dbf4e2d582 — download from the dashboard or `hivectl review evidence #16993`.

@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

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

No conflicting open PRs or same-file overlaps were found.

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 aba19043ed0c. A repository maintainer with Actions write can re-run failed jobs at https://github.com/hivecommons/hive/actions/runs/42385296970 . 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

Copy link
Copy Markdown
Contributor

Needs a decision, not a merge:

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.

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.

Looks correct to me. Read automerge_contributor_lane.go on v6 (the PR base), not just the diff.

  • Mechanism confirmed: on v6 admitContributor returns at line 667 (adopted head) or 670 (operator Approve) with ObservedTier: c.observedRegistryTier(author) — the raw registry tier — while the auto-promotion that yields ObservedTier: "trusted" only runs at line 679-686, after both early returns. noteStageRole at line 1421 turns that tier into the role/* label, so a hive-pushed merge commit that carried a person's approval really does flip an auto-promoted author back to role/newcomer. The diagnosis in the body matches the code.
  • authorStandingTier reproduces what the author's own route would have recorded: registry tier if it is already in require_tiers, else "trusted" iff contributorCleanMergedHistory is clean, else the registry tier. It deliberately does not call announceContributorAutoPromotion or ClearTrustPromotion — labelling stays side-effect-free, and the test asserts comments == 0.
  • autoPromotionEligible is a behaviour-preserving extraction of the v6:679 condition. The added author == "" short-circuit matches the old outcome too: contributorCleanMergedHistory (line ~804) already returned Reason: "disabled", Clean: false for an empty author.
  • Test covers both head-scoped routes plus the short-history, revoked, and already-trusted cases.

One cost note, not a defect: head-admitted PRs by below-tier authors now trigger a PullRequests.List(state=closed, per_page=100) per sweep (contributorCleanMergesInRepo, v6:847-849; more in hive-wide scope) that previously only ran on the author's own route. That is the same read the un-admitted path already makes, so it is a modest increase; if the lane's sweeps are REST-budget-sensitive, caching the clean-history answer per author per sweep would be the natural follow-up.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@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 diff against the tree at v6 and the callers of admitContributor. This looks correct to me.

What I checked:

  • admittedRegistryTier (automerge_contributor_lane.go:639-656) already filters to RequireTiers, and the claim-marker path (:1251-1260) only admits a tier in RequireTiers, so the only routes that could record a sub-tier ObservedTier for an author whose clean history would promote them were the two head-scoped early returns at :674-679. The fix targets exactly those.
  • authorStandingTier (:767-781) short-circuits on a RequireTiers tier and on autoPromotionEligible == false, so revoked/bot/App authors never reach contributorCleanMergedHistory. The revoked case is pinned by the new test.
  • The extracted autoPromotionEligible preserves the four conditions of the inlined predicate it replaces (configured, not revoked, not [bot], not the App login); the added empty-author guard is harmless since contributorCleanMergedHistory already returned disabled for it (:851).
  • The head route swallows a history read error and keeps the registry tier, while the author route still fails admission on the same error (:689-690). That asymmetry is intentional per the comment and reasonable: labelling should not block an admission a person already made.
  • Cost note, not a defect: a head-route PR whose author sits below require_tiers now costs one PullRequests.List(closed, 100) per sweep (contributorCleanMergesInRepo, :889), plus the hive-wide search when the own-repo count is short. That is the same read the author route already does every sweep, so no new order of cost.

Test fails on v6 tip for the two head-route cases (ObservedTier = "newcomer"), which matches the body.

— 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

Choose a reason for hiding this comment

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

Read admitContributor, contributorCleanMergedHistory and the role-label consumer at 2eabd89. Looks correct to me, and it does not widen admission.

  • Only ObservedTier changes on the adoption and operator routes (automerge_contributor_lane.go:675,678); AdoptedHead/OperatorLogin and the admission Reason are untouched, and the label is derived downstream at :1465 via RoleFromTier(claim.ObservedTier, …). So this is label consistency, not a new trust grant: authorStandingTier can only return "trusted" under the same autoPromotionEligible + history.Clean conditions the author route already requires at :687-694.
  • autoPromotionEligible is a faithful extraction of the old inline condition at :687; the added TrimSpace(author) == "" guard is behaviour-neutral because contributorCleanMergedHistory already returns Reason: "disabled" for an empty author (:851-854).
  • A failed history read returns the registry tier rather than an error (:775-778), so a flaky PullRequests.List cannot turn an admitted head into a skip. Good.
  • The new test exercises both head routes through the real stagelabels store (NoteAdmission / MarkAdoptedInPlace) and asserts no promotion comment is posted.

One info-level note, not a defect: on the author route a contributorHistoryReasonDemoted result calls ClearTrustPromotion(author) (:696-699) so a later re-promotion is announced again; authorStandingTier does not, so a demotion first observed on a head-scoped route keeps the stale "announced" record until the author route next runs. Cosmetic (only affects whether the promotion comment is re-posted), and the author route runs on the next sweep without a carried approval anyway.

Cost note: the two head-scoped routes now make the same merged-history reads the author route already makes each sweep (one PullRequests.List per repo, plus the hive-wide search when enabled), only for authors below require_tiers. That matches the body's "reads the same history the normal route reads every sweep".

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1

@hivecommons-hive
hivecommons-hive Bot merged commit 981fe66 into hivecommons:v6 Nov 7, 2026
67 of 68 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 2eabd89.

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