Skip to content

πŸ› writeback: let the hive move a stage label it applied on a PR older than the backfill cutoff - #18848

Merged
hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/backfill-hive-applied-stage
Nov 17, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
hivecommons:v6from
Danathar:fix/backfill-hive-applied-stage

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

When the write-back gate's backfill guard covers a pull request, it refuses every stage-label write on it, and that includes moving or removing a stage label the hive put there itself. The label then stays at a stage the hive no longer believes, while the hive's own comments and dashboard track another one.

This PR lets the hive keep its own stage label current on such a PR. Only the backfill guard is lifted. The opt-in label, level, pause, repo mode and own_only still apply, and a stage label a person applied is left alone.

It follows the two exceptions already merged for the same reason:

What happened

These are on projectbluefin, times Eastern. Each label below was applied by hivecommons-hive[bot], per the PR timeline.

Cause

What changed

Gate (writeback/gate.go, writeback/kinds.go)

  • New item fact HiveAppliedStage, read only for stage_label.
  • With the fact set, the gate skips the backfill guard and decides the item as one the guard does not cover. If that allows the write, the reason is the new hive-applied-stage. If it refuses, the refusal is the usual one (for example needs-label without the opt-in label).
  • New Gate.BackfillHolds asks the guard's question without recording the item as pre-existing. So asking it, or a write allowed through the fact, does not add to the "N existing PRs were left untouched" banner.

Stage labeler (github/stage_labeler.go, new github/stage_label_hive_applied.go)

  • Before a stage write on a PR, the labeler asks BackfillHolds. Only when the guard would hold the write and the PR carries a stage/* label does it read the PR's timeline.
  • The fact is true when the newest labeled event of every stage/* label on the PR names one of the hive's own accounts: its App bot, an extra hive bot login, or ai_author. This is the same identity test the blocked sweep and park re-check use.
  • The answer is memoised per PR and stage-label set for 30 minutes. A PR the guard holds costs one timeline read per label change, not one per sync.
  • I chose the timeline actor over the cheaper "the stage store has a record" proxy that was offered. The store also holds records for PRs whose labels a person set, so the proxy could have let the hive overwrite a maintainer's stage label.

085 escalation note (automerge_writeback.go, automerge_contributor_adopt.go)

  • withStageMoveFact asks the gate with the same fact, through an optional transport hook that the client implements.
  • Without this, once the labeler starts moving the label, the note would still say "the write-back gate keeps its labels off this PR".

Docs and changelog

  • The backfill guard section of docs/operator-reference/sweeps-and-operations.md now lists the three hive-applied exceptions.
  • A changelog fragment.

Related

#18846 (prompt 14, also from the projectbluefin follow-up) fixes why projectbluefin's cutoff moved in the first place: a 2xx with no earlier refusal. This PR covers what remains after that fix. A cutoff can still move legitimately, for example when the App loses and regains write access, and a PR the hive labelled before then would freeze the same way. The two PRs don't touch the same code: that one changes NoteWriteOutcome, this one changes the decision.

Not in this PR

Tests

  • writeback/hive_applied_stage_test.go:
    • a table over old/new PR Γ— fact stated or not Γ— kind: stage_label on an old PR with the fact is allowed as hive-applied-stage; without the fact it is refused backfill-off; a comment kind or needs_decision_comment ignores the fact; a new PR is decided as before; the default policy still wants the opt-in label after the guard;
    • pause, repo mode off / issues-only, labels-only, project membership, own_only, level unset, and below and at the kind's floor;
    • BackfillHolds records nothing and is false for an opted-in item; an allowed move is not counted as a backfill skip, and a refusal still is.
  • github/stage_label_hive_applied_test.go runs the real stage labeler against a fake GitHub and a real gate:
    • the hive's own 100 on an old PR is replaced by 085, with nothing held and nothing counted;
    • a person's stage label is left alone and held backfill-off;
    • a newer PR is decided with no timeline read;
    • an old PR's timeline is read once across syncs, and again past the TTL;
    • a table checks the actor rule (re-applied by a person, re-applied by the hive, one of two labels a person's, no labeled event, no stage label).
  • automerge_stage_move_suppressed_test.go: on an old PR the note announces the move unchanged when the stage label is the hive's, and keeps the backfill-off wording when it is a person's. A newer PR does not ask for the fact, and nothing is recorded as suppressed. The existing note tests pass a context.

Only gofmt -l was run locally (AGENTS.md bans local go test/go build/go vet); this PR's CI is the test run.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

… than the backfill cutoff

The backfill guard refused every stage-label write on a PR created before
the repo's cutoff, so a stage label the hive itself had put there froze at
a stage the hive no longer believed (projectbluefin/utah-packages#1148 at
stage/100-merge-queue while not queued, projectbluefin/utah#1274 at 074
while tracked at 085).

The stage labeler now states Item.HiveAppliedStage when every stage/*
label on such a PR was last applied by one of the hive's own accounts
(one timeline read, only for a PR the guard would hold, memoised per label
set). For KindStageLabel the gate then skips the backfill guard and
nothing else (reason hive-applied-stage), following the hive-applied-block
(hivecommons#17991) and hive-applied-park (hivecommons#18051) exceptions. The 085 escalation
note asks with the same fact so it describes the move as it happens.

Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 17, 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 17, 2026
The five lines this branch adds to client.go moved RankActionableIssues
from 5588 to 5593; scale-envelope.md now cites 5593-5603 so the docs
citation check finds the AgeMinutes anchor again.

Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
@github-actions

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

PR Title Relation Files
#18842 πŸ› base red: remember the base's red checks and read new heads from them same files src/pkg/github/client.go
#18667 πŸ› automerge: refuse an unsigned squash only where the repo requires DCO same files src/pkg/github/client.go
#18833 πŸ› issue stage labels: take has-open-pr off once no open PR links the issue same files src/docs/operator-reference/sweeps-and-operations.md

@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Evidence bundle `#18848ff0be49` sha256:fa2c835e023337ebe8df71a65f5578b79462d995a9185b15295b1cc7683b2e77 β€” download from the dashboard or `hivectl review evidence #18848`.

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant