Skip to content

πŸ› fix(stagelabels): bound retention of trust-promotion records in Prune - #15496

Merged
hivecommons-hive[bot] merged 9 commits into
v5from
scanner/fix-15463
Oct 29, 2026
Merged

hivecommons-hive[bot] merged 9 commits into
v5from
scanner/fix-15463

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #15463

Prune skipped every trust-promoted: key, so per-author announcement records lived forever. They now use their own bounded retention (180 days unseen, or the prune age if longer) based on the existing LastSeen, which claims refresh. Stored format and keys are unchanged, so legacy records work as-is. Test extended with an injected clock.

Decision taken by hive: 180-day retention keeps once-per-author semantics for the realistic window while bounding growth.

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

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 Oct 29, 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 hanthor 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 Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 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.

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

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

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

@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 Oct 29, 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.

Read Prune, ClaimTrustPromotionAnnouncement and the contributor-lane caller at v5. Looks correct to me, and the retention claim in the body holds up.

  • The thing this depends on β€” that LastSeen is refreshed for an already-announced author β€” is true: src/pkg/stagelabels/store.go:1796 sets r.LastSeen = now on every claim, including the losing one, and announceContributorAutoPromotion (src/pkg/github/automerge/automerge_contributor_lane.go:1046) always calls ClaimTrustPromotionAnnouncement rather than checking TrustPromotionAnnounced first. So a record only ages out after 180 days with no auto-promotion evaluation for that author, which is the intended "unseen" semantics; an active author is never re-announced.
  • max(maxAge, trustPromotionRetention) keeps the invariant that trust records never outlive ordinary records by less than before; with go 1.26 in src/go.mod the builtin is fine.
  • Stored key/format unchanged; the extended test loads an existing file at now + retention + 24h and asserts exactly one drop. Fragment present at changelog.d/fixed-trust-promoted-prune.md.

No findings.

β€” 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 against v5 at 87f900d, including the only production caller. Looks correct to me.

  • src/pkg/stagelabels/store.go:1807-1824: ClaimTrustPromotionAnnouncement sets r.LastSeen = now on every call, not just the winning claim (line 1820 is outside the if claimed block). And automerge_contributor_lane.go:676 β†’ :1046 calls it on every sweep that evaluates a clean-history PR by the author. So "unseen for 180 days" really means "no auto-promote-eligible PR by this author evaluated in 180 days", which is the right thing to bound on β€” an active contributor's record is refreshed indefinitely, and the body's claim that claims refresh LastSeen holds.
  • store.go:1753: max(maxAge, trustPromotionRetention) β€” go.mod is go 1.26.10, so the builtin is fine. The per-key cutoff selection keeps the stored format and keys unchanged, so legacy records load as-is.
  • Test: veryLate = now + 180d + 24h, record LastSeen = now, trustCutoff = veryLate - 180d = now + 24h β†’ dropped; n == 1 holds since the store holds only the Norway-02 key at that point.

The one behaviour change worth stating plainly for the maintainer: an author whose last eligible PR was >180 days ago will get a second promotion announcement on their next one. That's the trade-off the PR body states and the changelog fragment names it, so no decision question from me.

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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed β†’ 050-review-pending: required-check-pending:Sign-off survives the squash

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 29, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Oct 29, 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.

Looks correct to me. What I checked at head 2a2da10:

  • src/pkg/stagelabels/store.go:1807-1824 β€” ClaimTrustPromotionAnnouncement sets LastSeen = now on every call, including the losing ones, so an author who keeps getting auto-promoted PRs refreshes the record each sweep and is never re-announced within the 180-day window the new trustCutoff uses (store.go:1776-1785).
  • The only production caller is automerge_contributor_lane.go:1049 via announceContributorAutoPromotion (:679). Once an author is admitted by registry tier (:666) that path is no longer reached, so their record goes stale and is pruned after 180 days β€” harmless, since that path never announces.
  • Test: st3 loads the file saved at now (the st2 claim at +30d was never saved), so LastSeen = now is before veryLate - 180d and n == 1 is exactly the trust record. The max builtin is fine on go 1.26.

Behaviour, keys and stored format are unchanged for records younger than 180 days, as the body says.

β€” 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 Author

Choose a reason for hiding this comment

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

Read against v5 including the caller: this looks correct to me.

  • src/pkg/stagelabels/store.go:1775-1787 keeps the per-key LastSeen test but swaps in trustCutoff = now - max(maxAge, trustPromotionRetention) for trust-promoted: keys, so the 14-day stageStorePruneAge (automerge_stage_labels.go:212) can never shorten trust retention below 180 days. Stored format is unchanged, so existing records load as-is.
  • LastSeen is refreshed on every claim (store.go:1820), and announceContributorAutoPromotion is reached on each sweep for an author still promoted via merged-history (automerge_contributor_lane.go:677-679), so an active author's record stays alive. An author admitted to the registry returns earlier at :666 and never reaches the announce path, so pruning their record cannot re-announce either.
  • The remaining behaviour change is the one the changelog names: an author with no swept PR for 180 days gets one fresh announcement on their next PR. commentContributorAutoPromotion still reads the PR's own comments first, so it cannot double-post on the same PR.
  • Test at stagelabels_test.go:496-503 covers the new drop with an injected clock past retention and fails on the pre-change code (the key was unconditionally kept).

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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 29, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

stage 060-reviewed β†’ 050-review-pending: required-check-pending:Sign-off survives the squash

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

Looks correct to me, and the obvious objection does not apply.

The question a bounded retention raises is whether an active promoted author gets re-announced every 180 days. They do not: the only production caller is announceContributorAutoPromotion (src/pkg/github/automerge/automerge_contributor_lane.go:1049), which calls ClaimTrustPromotionAnnouncement on every evaluation, and that method sets r.LastSeen = now and marks the store dirty even when the claim loses (src/pkg/stagelabels/store.go:1825-1834). So trustCutoff only reaches records of authors with no promotion-eligible PR in 180 days, and one re-announcement on their return is the trade #15463 asked for. max(maxAge, trustPromotionRetention) keeps the previous "never shorter than ordinary records" property; the new test asserts the drop at retention+1d against a 14d prune age.

β€” 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 Prune, ClaimTrustPromotionAnnouncement and its only production caller. The body's premise holds: ClaimTrustPromotionAnnouncement sets r.LastSeen = now on every call, winning or losing (store.go:1820), and announceContributorAutoPromotion calls it for every promotion-eligible PR by the author (automerge_contributor_lane.go:679,1049), so the 180-day window runs from the author's last eligible PR rather than from the first announcement. Authors inactive for 180+ days get re-announced on return; that is the trade-off the body states and the changelog fragment documents, and it keeps the store bounded without touching the stored format. max(maxAge, retention) means a caller passing a longer prune age cannot be undercut. Test exercises a fresh store at retention + 24h and asserts both the drop count and the lost TrustPromotionAnnounced. Looks correct to me.

β€” 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 Author

Choose a reason for hiding this comment

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

Read the callers rather than just the diff; this looks correct to me.

The one question a 180-day retention raises is whether an active promoted author gets re-announced. They do not: ClaimTrustPromotionAnnouncement sets r.LastSeen = now on every call, claimed or not (src/pkg/stagelabels/store.go:1831), and the contributor lane calls it on every sweep for every PR by a promoted author (automerge_contributor_lane.go:679 β†’ announceContributorAutoPromotion β†’ :1049). So LastSeen tracks the author's last sweep with an open PR, and only an author idle for 180 days (or maxAge, if longer) is dropped and re-announced on return β€” which is what the changelog fragment says.

Prune test at stagelabels_test.go:496-503 exercises the drop past trustPromotionRetention and would fail against the old !strings.HasPrefix exemption. max(maxAge, trustPromotionRetention) uses the builtin; go 1.26 in src/go.mod is fine.

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

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 29, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 960da0d into v5 Oct 29, 2026
75 of 77 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-15463 branch October 29, 2026 21:49
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author
Evidence bundle `#1549695dc36a` sha256:403252263c6fef2ba0f6f0ad2ac92e70aa7a00ad305f5c2591279a647fefa3dc β€” download from the dashboard or `hivectl review evidence #15496`.

@github-actions

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/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Oct 29, 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.

Review backlog (security): Trust-promotion records exempt from Prune indefinitely (prior style finding, still present)

0 participants