Skip to content

πŸ› writeback: a 2xx with no prior refusal no longer moves the backfill cut-off - #18846

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/writeback-cutoff-needs-prior-refusal
Nov 17, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/writeback-cutoff-needs-prior-refusal

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

The write-back backfill guard froze the stage labels of every older PR and issue on a repository the hive had always been able to write to.

NoteWriteOutcome set the repository's writable_at on the first successful write it heard about, even when no 403/404 had ever come before it. Only a few writers report outcomes, so that first success could come days after the hive started labelling the repository. The backfill cut-off then jumped to that moment, and every item created before it counted as "pre-existing", including items carrying a stage label the hive itself had written.

With this change, writable_at is set only by a 2xx that follows a 403/404, as the docs and the field comment already say. A writable_at set the old way is cleared at startup.

What happened

On projectbluefin (Eastern times):

  • projectbluefin/utah-packages: the cut-off was 11-16 3:29 AM.
  • projectbluefin/utah, projectbluefin/actions and projectbluefin/common show the same pattern. The hive labelled PRs well before each cut-off, and those labels have been frozen since, so the PRs show stale 074/090/100/071 labels.

Cause

  • NoteWriteOutcome (src/pkg/writeback/gate.go, the 2xx case) stamped WritableAt whenever it was empty, without checking LastForbidden.
  • backfillCutoff takes the later of first_seen and writable_at. backfillBlockedLocked refuses unsolicited writes on anything created before that, stage labels included.
  • Only these writers report outcomes through Client.noteWritebackOutcome: code scanning, the dependency-bot rebase, the sentinel sweep, the shared-CI tracker edit and workflow auto-approval. Stage labels, comments and reviews don't.
  • The guard was added in πŸ› Write-back containment: per-kind gate for every unsolicited GitHub write, with backfill guardΒ #15122, "so a newly-writable repo never back-fills onto pre-existing PRs". The docs say writable_at is the first 2xx after 403/404s. The only test covered 403 then 2xx.

What changed

  • NoteWriteOutcome: a 2xx sets WritableAt only when it is empty and a 403/404 has been recorded. A repository that never refused a write keeps writable_at empty, so first_seen alone is the cut-off. Once set, WritableAt still never moves.
  • Repair at startup (repairBackfillCutoffs):
    • A stored record with writable_at set and no last_forbidden was stamped by the old rule.
    • Its writable_at and its pre_existing set are cleared, with one log line per repository: writeback: cleared writable_at <t> on <repo> (no 403/404 before it); backfill cut-off is first_seen <t>. The repaired file is saved.
    • Items that really predate first_seen are refused and counted again the next time a write reaches them.
  • Status: /api/status writeback.repos[].writable is now true for a repository that never refused a write. It is false only while a 403/404 has had no 2xx after it. Previously it was false until one of the rare reporting writers succeeded.
  • Docs: the "Backfill guard" section of docs/operator-reference/sweeps-and-operations.md gains a sentence on this. There is also a changelog fragment.

Not in this PR

  • Ambiguous records: a record where a 403/404 came after its writable_at is left as it is. Only the last refusal is stored, so a real gain of write followed by a later refusal can't be told apart from an old-rule stamp followed by a refusal. If such a repository is still frozen, an operator can check last_forbidden in /data/metrics/writeback.json and see which writer got the 403/404. It may be a different permission than label write.
  • Who reports outcomes: unchanged. Neither is the meaning of backfill: false for items that really predate first_seen.
  • Keeping the hive's own stage labels current on pre-existing items: a separate question.
  • Admin-MCP parity, a known gap:
    • The dashboard toggle writeback.unsolicited.backfill (writebackBackfill, accepted by PUT /api/config/governor/features) has no admin-MCP write.
    • governor.feature_settings doesn't list it in boolFeatureFields, and writeback.kind_policy accepts only kinds.
    • Turning backfill on widens unsolicited writes, so it needs its own widening disclosure. Left for a follow-up.

Tests

src/pkg/writeback/writeback_test.go:

  • TestBackfillCutoffMovesOnlyAfterARefusal:
    • 2xx with no refusal: the cut-off stays first_seen, the item is allowed, writable is true and writable_at is empty;
    • a 403 then reads not writable;
    • a 2xx after it moves the cut-off and refuses the older item with backfill-off.
  • TestBackfillCutoffRepairOnLoad:
    • a stored old-rule record is repaired on load: the item after first_seen is allowed, pre_existing and the banner are gone, and the repair is logged once and persisted (a second load logs nothing);
    • a record with a 403/404 before its writable_at keeps its cut-off.
  • The existing TestBackfillGuardAndPersistence (403, then 201, then 200) and the legacy-state-file tests are unchanged and still describe the behavior.

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

… cut-off

NoteWriteOutcome stamped writable_at on the first 2xx it was told about,
whether or not a 403/404 came first. Only a few writers report outcomes
(code scanning, the dependency-bot rebase, the sentinel sweep, the
shared-CI tracker edit, workflow auto-approval), so on a repo the hive
had labelled for days the first one to succeed moved the cut-off to that
moment and the guard froze every older item's stage labels.

Stamp writable_at only on a 2xx after a 403/404, as the docs and the
field comment already say. At load, clear a writable_at with no
last_forbidden (stamped by the old rule) and the items it refused.
RepoStatus.Writable now reads true for a repo that never refused a write.

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

@github-actions

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
#18848 πŸ› writeback: let the hive move a stage label it applied on a PR older than the backfill cutoff same files src/docs/operator-reference/sweeps-and-operations.md
src/pkg/writeback/gate.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
hivecommons-hive Bot merged commit df34f28 into hivecommons:v6 Nov 17, 2026
81 of 82 checks passed
@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 `#188467e0df85` sha256:eab8152d1868ddf3103dca590be91c1ca7de20ebdaa90d5c954b49991b93d1d1 β€” download from the dashboard or `hivectl review evidence #18846`.

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