Skip to content

🐛 fix(fork-guard): the 085 comment on a fork PR names the current head after a rebase and says an earlier run does not cover it - #17373

Merged
hivecommons-hive[bot] merged 3 commits into
hivecommons:v6from
Danathar:fix/v6-fork-canary-rebase
Nov 9, 2026

Conversation

@Danathar

@Danathar Danathar commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

When a fork PR is parked at 085 because a check only a maintainer can run (the fork Canary) is red, the hive's 085 comment asks the maintainer to run it "for head <sha>". Since #16814 the park carries onto new heads without leaving 085, but the comment was only written once per stage visit, so after a rebase it kept naming an old head. Now the comment is rewritten in place for each new head, and it says plainly that a run on an earlier head does not cover this one, even with the same patch. The hive still does not carry a Canary proof across heads: that stays the repository's call, and the safety reasoning is below.

What went wrong

projectbluefin/utah-packages#917 (fork PR from kylerankin):

  • 11-07 17:05Z: @hanthor dispatched the fork Canary on 8d7a655 (run 42394558743, success).
  • The head then moved several times. Among them: ef16e09 (hive merge of main), 429adc6 (author rebase), bc96eb8 and ee80fbe (hive merges of main), and finally 82ef790 (author rebase, 11-09 04:59Z). Each new head turned the Canary red again.
  • The PR's own patch is byte-identical on all of them. git patch-id --stable of each head's diff against its merge base is d17c30f6730b… for 8d7a655, ef16e09, 429adc6, ee80fbe and 82ef790.
  • The 085 comment was last edited 11-08 06:09Z and still says "run or approve it for head ee80fbe". The head has been 82ef790 since 11-09 04:59Z, with no stage change in between, so the comment was never refreshed.

Root cause. postHumanEntry (src/pkg/github/automerge/automerge_stage_human.go) returns early when the entry comment was already posted this visit and EntryCommentedHead differs from the current head. Before #16814 a new fork head always fell out of 085 and back, which started a new visit. Now it stays at 085, so a head-bound ask goes stale.

Why the proof is not carried on patch-id equality

The fork Canary exists because it builds and publishes from fork code with the repository's credentials, so a pass has to prove the exact code that ran. Two things rule out carrying it in the hive:

  1. The code under test changed. A rebase with the same patch still sits on a newer base. Between 8d7a655's base (e9f555d) and 82ef790's base (ff2affe), main changed .github/workflows/canary-read-only.yml, tools/generated_sources.py, config/buildroot-image, config/buildroot-lock.json and .packit.yaml. That is the pipeline itself. The Canary never ran that tree.
  2. It is not the hive's check. The red Canary is utah-packages' own workflow, and branch protection requires it. The hive cannot turn it green, and it must not treat a red required check as passed. fix(canary): carry a fork's Canary proof across clean merges of main that change no pipeline path projectbluefin/utah-packages#900 (open) already adds carry-over in the repository's own Canary Decide step, for clean merges of main that change no pipeline path. Even under that rule, this rebase would not carry, because of point 1.

So the right hive change is to tell the maintainer the truth on the current head.

What changes

  • A fork-guard 085 park whose comment was written for another head is now rewritten in place for the new head. It is an edit, so nobody is notified, and nothing changes for other 085 causes.
  • The fork-guard ask now adds: "A run that passed on an earlier head does not cover <head>, even when the change itself is the same: a rebase or a merge of the base changes the code the check runs. The check's own failure message on this head says what to run." (On utah-packages that message names the "Canary for a fork pull request" workflow, the PR number and the head commit.)
  • The stage-labels doc row for fork-guard: and a changelog fragment describe both.

Files

  • src/pkg/github/automerge/automerge_stage_human.go: postHumanEntry rewrites a stale fork-guard entry comment.
  • src/pkg/github/automerge/automerge_fork_guard_carry.go: new forkGuardEntryStale predicate.
  • src/pkg/stagelabels/human.go: the extra sentence in the fork-guard ask.
  • src/docs/labels-and-control-signals/stage-labels.md, changelog.d/fixed-fork-guard-card-new-head.md.

Tests

Not run locally (AGENTS.md); CI is the verdict.

  • TestForkGuardEntryCommentFollowsNewHead replays fix: contribute page Docker/local mode + HTTP copy fallback #917. The 085 comment is posted for 8d7a655. A new head 82ef790, which keeps the carried guard, must edit that comment to name 82ef790, with no second comment. A repeat pass on the same head must not edit it again. On v6 tip the second pass returns early, so there is no edit and the test fails.
  • TestForkGuardEntryStale covers the predicate: stale on a new head, not stale for the same head, another 085 cause, a non-085 route, or a record that has never commented. It does not compile on tip.
  • TestRouteHumanForkGuard pins the new wording for one check and for two. It fails on tip because the sentence is missing.

Refs #16814, projectbluefin/utah-packages#917, projectbluefin/utah-packages#900

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

A fork PR parked at 085 on a fork-guarded check (the fork Canary) keeps its
park across new heads since hivecommons#16814, but the entry comment was written once
per stage visit and never for a new head within it. On
projectbluefin/utah-packages#917 the maintainer's Canary passed on 8d7a655,
the author rebased the byte-identical patch onto a newer main (82ef790),
and the comment still asked for a run on an earlier head.

The comment is now rewritten in place (no notification) for each new head
while the fork-guard park stands, and the ask says a run on an earlier head
does not cover this one even with the same patch, because a rebase or a
merge of the base changes the code the check runs. Whether an earlier run
carries over stays the repository's decision (its Canary workflow); the
hive does not carry it.

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 9, 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 danathar 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 9, 2026

@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 postHumanEntry at 4042321 on v6. forkGuardEntryStale (automerge_fork_guard_carry.go:91) only fires when the record's commented head differs from the current one on a fork-guard 085 park, and the rewrite path ends in MarkEntryCommentedCause (automerge_stage_human.go:830), which sets EntryCommentedHead to the new head (stagelabels/store.go:1299), so the next visit on the same head is quiet again — no edit-every-pass loop. The rewrite goes through the existing findOwnEntryComment edit-in-place branch (#16433), so no new comment is created and nobody is re-notified. The !rec.EntryCommented guard added to the else if keeps the previously-implicit condition explicit now that the first branch can be skipped. Looks correct to me.

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

@github-actions

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

@hivecommons-hive

hivecommons-hive Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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

Reviewed by reviewer — no findings.

Reviewer notes

Read against v6, following the new headBound flag through postHumanEntry. Looks correct to me.

  • With forkGuardEntryStale true, both early returns are bypassed and control reaches the existing edit-in-place path (findOwnEntryComment → EditComment, automerge_stage_human.go), which then calls store.MarkEntryCommentedCause(key, obs.HeadSHA, cause). That moves EntryCommentedHead to the new head, so the next visit on the same head is not stale again — one rewrite per head, not one per sweep.
  • forkGuardEntryStale requires EntryCommentedStage == NeedsDecision && EntryCommentedHead != "", which implies EntryCommented, so the added !rec.EntryCommented guard on the else if is exactly what keeps the "already explained" shortcut from swallowing the head-bound case. Not redundant.
  • If the hive's own comment is gone (or the list fails), the fallthrough posts a fresh entry — the same behaviour the Issue-side comment churn: claim/release ledger, needs-decision upsert, reviewer no-findings suppression #16433 path already has for any rewrite.
  • RouteHuman wording only changes when ShortSHA(e.Head) is non-empty, so the generic "approve the run" sentence for a head-less evidence is untouched.

No findings. I have not approved or changed anything.

Evidence bundle `#17373ed28b10` sha256:78c6b0d6fd42b5fc404c7a1bdb6f5bc3831f53193a484416526bb3fc7d5bcd0e — download from the dashboard or `hivectl review evidence #17373`.

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

Correctness review at head 4042321. The fix traces cleanly: ForkGuardStage puts fork-guard:<checks> into verdict.Reason → obs.Reason (automerge_stage_labels.go:1066-1068) before postHumanEntry, so forkGuardEntryStale (automerge_fork_guard_carry.go:91-97) fires on a new head within the visit, and the in-place edit then calls MarkEntryCommentedCause (automerge_stage_human.go:835) which advances EntryCommentedHead, so the repeat pass is a no-op. Test harness supports the asserted path (stageAPI.reset() keeps issueComments; commentEdits is cumulative). CI was still pending when I read it.

One low, non-blocking note:

Fallback when the hive's own 085 comment is not found posts a fresh comment per new head. postHumanEntry only edits when findOwnEntryComment returns non-nil (automerge_stage_human.go:825); on nil (comment deleted by a maintainer, AppBotLogin empty, or a transient list error, which findOwnEntryComment deliberately reads as "none", automerge_stage_human.go:847-873) it falls through to CreateComment (automerge_stage_human.go:837). Before this PR a new head inside the 085 visit posted nothing; now each author push on a still-red fork PR creates a notifying comment in that fallback. If you want the "edit notifies nobody" guarantee to hold strictly for the head-bound rewrite:

 	if existing := c.findOwnEntryComment(ctx, obs, stagelabels.EntryCommentMarker(route.Stage)); existing != nil {
 		...
 		return 0, nil
 	}
+	if headBound {
+		// The head-bound rewrite is an edit or nothing: without the hive's
+		// own comment to rewrite, do not post a new one per head.
+		store.MarkEntryCommentedCause(key, obs.HeadSHA, cause)
+		return 0, nil
+	}
 	if _, _, err := c.gh.Issues.CreateComment(ctx, obs.Owner, obs.Repo, obs.Number, &gh.IssueComment{Body: gh.Ptr(body)}); err != nil {

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

@hivecommons-hive
hivecommons-hive Bot merged commit 4668c30 into hivecommons:v6 Nov 9, 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 ed28b10.

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