Skip to content

πŸ› fix: park fork-guard-only heads instead of nudging and adopting them - #16845

Merged
hivecommons-hive[bot] merged 1 commit into
v5from
fix/fork-guard-nudge
Nov 6, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v5from
fix/fork-guard-nudge

Conversation

@hanthor

@hanthor hanthor commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

The fork-guard park (#14273) only knew the head the last CI-enriched
enumeration classified. Every new head of a fork PR red only on its fork
guard (a required Canary that cannot run on forks) therefore read as plain
red CI first: stage 072, a "Failing checks: Canary" nudge to the author,
and after the grace an adoption, until the next enumeration parked it at
085 again.

  • Remember the guard's checks on the PR's stage record; a fork head the
    enumeration has not classified yet whose every red check (from the
    head's check digest) is one the guard refused before is read as the
    same guard and goes straight to the 085 park.
  • The contributor nudge drops fork-guard checks and is skipped when
    nothing else is red.
  • Automatic adoption refuses a head whose only blocker is the guard; an
    explicit maintainer adopt-supersede request still goes through.

Evidence: projectbluefin/utah-packages#869 (nudge then 085 on every
head, adopted in place at a head already parked on the guard) and #862
(adopted despite the fork guard, ~10 heads, 14 needs-decision posts).

Found by auditing why hive stalls on projectbluefin/utah and projectbluefin/utah-packages. One concern per PR; sibling PRs from the same audit cover the other root causes.

Verification: gofmt -l clean. Tests were not run locally, per AGENTS.md; CI is the verdict.

The fork-guard park (#14273) only knew the head the last CI-enriched
enumeration classified. Every new head of a fork PR red only on its fork
guard (a required Canary that cannot run on forks) therefore read as plain
red CI first: stage 072, a "Failing checks: Canary" nudge to the author,
and after the grace an adoption, until the next enumeration parked it at
085 again.

- Remember the guard's checks on the PR's stage record; a fork head the
  enumeration has not classified yet whose every red check (from the
  head's check digest) is one the guard refused before is read as the
  same guard and goes straight to the 085 park.
- The contributor nudge drops fork-guard checks and is skipped when
  nothing else is red.
- Automatic adoption refuses a head whose only blocker is the guard; an
  explicit maintainer adopt-supersede request still goes through.

Evidence: projectbluefin/utah-packages#869 (nudge then 085 on every
head, adopted in place at a head already parked on the guard) and #862
(adopted despite the fork guard, ~10 heads, 14 needs-decision posts).

Signed-off-by: James Reilly <jreilly1821@gmail.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 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 5, 2026
@github-actions

github-actions Bot commented Nov 5, 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 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 three gates at the head. Auto-adoption refuses a guard-only head at src/pkg/github/automerge/automerge_contributor_adopt.go:666 only when neither requested nor forced, so the maintainer adopt-supersede path is intact as the body says. foldForkGuard (automerge_stage_sharedci.go:82) carries the guard forward only when every red check in the head's own digest is one the recorded guard refused β€” a head with any other red check keeps the author-facing route. The nudge drops guard checks and returns before posting when nothing else is red (automerge_contributor_nudge.go:291). Builds. Looks correct to me.

One note, not a defect: Store.NoteForkGuard (src/pkg/stagelabels/store.go:2234) returns early when the key has no record, and foldForkGuard runs before the record is created for a PR the store has never seen. So the very first sweep that classifies a brand-new fork PR as guard-only does not persist the checks; the next sweep with fresh evidence does. The current head is parked by the enumeration regardless, so the only window is a head pushed between those two sweeps. Same pattern as NoteAdoptDiffFence, so probably fine to leave.

Also: I see no changelog.d/ fragment in this diff, unlike the sibling PRs (#16846–#16849) β€” worth adding one if the fragment guard runs on v5.

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

@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 ci-maintainer (folded here because this head already carries its hive review):

Style/maintainability pass at head 91d5ace. The new fold follows the existing idioms (foldRecordedDecision in-place mutation of list, Note* store shape, fork-guard helpers co-located in automerge_stage_sharedci.go), so nothing blocking. One advisory:

Remembered guard has no clearing path β€” src/pkg/stagelabels/store.go:2234 (NoteForkGuard) only ever writes ForkGuardChecks; nothing resets it. foldForkGuard (automerge_stage_sharedci.go:83-89) returns early on fresh positive evidence but treats an empty policy answer as "head not classified yet", so once a PR is remembered as guarded, a later enumeration that classifies a head as not a guard (e.g. the repo rewrote the Canary workflow and it now fails for real) cannot override the memory: every head red only on Canary keeps parking at 085 instead of being handed back. Since a fork guard refuses every head, a known-green digest is reliable evidence the guard is gone β€” cheapest fix is to clear the record there:

 	summary, known := c.headChecks(ctx, tracker, key, *o, now)
-	if !known || len(summary.Red) == 0 {
+	if !known {
+		return
+	}
+	if len(summary.Red) == 0 {
+		store.NoteForkGuard(key, nil) // guard gone: the head is green
 		return
 	}

with NoteForkGuard accepting an empty checks as a clear (drop the len(checks) == 0 early return and keep the slices.Equal no-op). Not a blocker for this PR; fine as a follow-up if preferred.

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

Intent alignment (read at head 91d5ace): the diff does what the body says. foldForkGuard runs ahead of resolveStage (src/pkg/github/automerge/automerge_stage_labels.go:901) and stageengine.ForkGuardStage parks on o.ForkGuardChecks (src/pkg/stageengine/derive_pr_classify.go:741-755), so the carried evidence does reach the 085 verdict; the adopt refusal is gated on !requested && !forced (automerge_contributor_adopt.go:666), matching the "explicit adopt-supersede still goes through" claim. No unrelated scope.

One low, non-blocking note: Record.ForkGuardChecks is write-only. Store.NoteForkGuard (src/pkg/stagelabels/store.go:2234-2244) only ever sets it, and foldForkGuard (automerge_stage_sharedci.go:93-99) cannot tell "policy has not classified this head yet" from "policy classified it and found no guard" (ForkGuard returns nil for both, automerge_stage_labels.go:161-168). If a remembered check (e.g. Canary) later goes red on this PR for a genuine reason β€” the workflow starts running on forks β€” the head keeps parking at 085 as fork-guard:Canary for the PR's lifetime. Parking is the safe side to fail on, so this is fine to land as is; worth a sentence in the Record field comment so the next reader knows the memory is sticky by design.

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

Correctness review of 91d5ace (read the diff plus automerge_stage_sharedci.go, derive_pr_classify.go, stagelabels/store.go, cmd/hive/stage_shared_ci.go; go build clean, CI green). The fix does what the body says; one advisory edge case.

Carried guard evidence cannot be contradicted by fresh evidence for the same check name (src/pkg/github/automerge/automerge_stage_sharedci.go:84-98, :116-120). foldForkGuard carries when the policy answers nil, but stageForkGuard (cmd/hive/stage_shared_ci.go:84-90) returns nil both for a head the enumeration has not seen and for a head it classified as not-a-guard. So once Record.ForkGuardChecks = [Canary], a later fork head where Canary actually ran and failed for a real reason (the workflow was changed to run on forks, or the run was approved) is still parked at 085 with "a maintainer must push this branch", and the author is never nudged; nothing ever clears the memory except a differently named red check or the head moving into the base repo. Narrow, and it lands human-facing, so not blocking β€” but worth a guard: let the policy distinguish "known, not a guard" from "unknown head" and skip the carry in the former case, e.g.

--- a/src/pkg/github/automerge/automerge_stage_sharedci.go
+++ b/src/pkg/github/automerge/automerge_stage_sharedci.go
@@ func (c *Engine) foldForkGuard(
 	if o == nil || o.Merged || o.HeadRepo == "" || headInBaseRepo(*o) {
 		return
 	}
+	// The enumeration classified this head and found no guard: fresh
+	// evidence outranks the memory.
+	if c.stagePolicy.ForkGuardKnown != nil && c.stagePolicy.ForkGuardKnown(o.Owner+"/"+o.Repo, o.Number, o.HeadSHA) {
+		return
+	}

with ForkGuardKnown backed by stageSharedCILookup(...).ok (it already matches on head at stage_shared_ci.go:103).

Minor: NoteForkGuard is a no-op on a missing record (src/pkg/stagelabels/store.go:2239) and foldForkGuard runs before store.Observe creates it (automerge_stage_labels.go:901), so a brand-new PR's first guard-parked pass stores nothing; harmless unless the head moves before the next pass.

Evidence bundle `#1684591d5ace` sha256:ae83f9d4c1bcc4888c12326f94af533d666efc7f8131abc0a951a1e69ea8c45d β€” download from the dashboard or `hivectl review evidence #16845`.

@hivecommons-hive
hivecommons-hive Bot merged commit f0d3f1a into v5 Nov 6, 2026
82 of 86 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the fix/fork-guard-nudge branch November 6, 2026 00:06
@github-actions

github-actions Bot commented Nov 6, 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

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