Skip to content

πŸ› fix(labels): a later hive/verified-open or hive/already-done replaces the other - #16842

Merged
hivecommons-hive[bot] merged 6 commits into
hivecommons:v6from
Danathar:fix/verified-open-supersedes-done
Nov 6, 2026
Merged

hivecommons-hive[bot] merged 6 commits into
hivecommons:v6from
Danathar:fix/verified-open-supersedes-done

Conversation

@Danathar

@Danathar Danathar commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Executive summary

projectbluefin/testsuite#1023 wears both hive/already-done (11-04 01:47Z) and hive/verified-open (03:13Z, scanner: "Nothing more can be implemented here until #706"). The inbox offers it as CLOSE, "verified done but could not close".

The two verdicts contradict each other, and nothing ever took the older one off. Now each verdict removes the other as it lands, and the issue stage sweep settles issues already wearing both: the later add stands.

What

Path Before After
Label relay adds hive/verified-open Done labels stay Removes hive/already-done and hive/likely-done (best-effort)
Contributor's verified already-done hive/verified-open stays Removes hive/verified-open (best-effort)
Issue already wearing both (the stage sweep walks it) Stays; inbox says CLOSE Later add stands, from the issue's label events; the other label is removed via the write-back gate

Why

  • The band rule is pinned on purpose: bands_verified_open_11722_test.go says "already-done + verified-open stays done". hive/verified-open cancels only the heuristic hive/likely-done.
  • So the fix is in the labels, not the band. Two contradicting verdicts must not stand together, and the later one is the current one.

How

  • issue_request_watcher.go: after the relay's add, if the request added hive/verified-open, RemoveLabelsFresh(already-done, likely-done). A failure is logged, not returned: the verdict landed, and the sweep settles the pair.
  • dashboard/contribute_verdict_settle.go: after the already-done label lands, RemoveLabelsFresh(verified-open).
  • New done_verdict_labels.go: reconcileDoneVerdictLabels, called from the issue stage sweep's per-issue loop.
    • It acts only when both labels are present, so it costs one events read per such issue.
    • It compares each label's latest labeled event. If either is missing or they tie, it does nothing.
    • It removes the older label through WritebackAllowed(KindStageLabel).

Tests

Check Result
TestReconcileDoneVerdictLabelsKeepsTheLaterVerdict (6 rows, incl. #1023's order, re-adds, missing events) pass
TestSyncIssueStageLabelsSettlesDoneVerdictPair (through the sweep) pass
TestLabelRelayVerifiedOpenRemovesDoneLabels pass
TestVerdictSettleGH_MarkAlreadyDone_RemovesVerifiedOpen pass
Existing label relay and settle tests pass
go test ./pkg/github/... ./pkg/writeback/ ./pkg/dashboard/ pass
writeback ratchet, check-docs-citations.py src/docs pass, 2006 verified
Mutants (order Γ—3, missing-event guard, relay Γ—2, contribute, sweep wiring, gate) 9/9 caught (the gate one by compile error)

Notes

  • Label spelling: only the default hive/already-done is reconciled. A hive that renamed hub.contribute_already_done_label keeps today's behaviour for that label; the docs say so.
  • feat: integrate pub-sub-tmux for inception kick (experiment)Β #1023 itself: this PR writes nothing to it by hand. The first sweep after deploy removes hive/already-done there, provided the write-back gate allows the write.
  • Scope: part of a checklist on stale hive labels; the other items are in separate PRs or left out.

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

…ogether

projectbluefin/testsuite#1023 got hive/already-done (11-04 01:47Z) then
hive/verified-open (03:13Z) and the inbox offered it as "verified done but
could not close". The relay's verified-open now removes the done labels, a
verified already-done removes verified-open (both best-effort), and the issue
stage sweep settles an issue already wearing both from its label events:
the later add stands, the other comes off through the write-back gate.

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

github-actions Bot commented Nov 5, 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
#16843 ✨ feat(ownership): CLOSE an agent finding whose cited lines are gone from main same files src/docs/dashboard.md
#16816 πŸ› fix(adoption): refuse a fixer push that undoes the adopted PR's change same files src/pkg/github/issue_request_watcher.go

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

docs-currency β€” read at head c5f842d. The new paragraph under hive/verified-open (src/docs/labels-and-control-signals/reference.md:653) matches the code (issue_request_watcher.go:869-878, contribute_verdict_settle.go:301-304, done_verdict_labels.go:23-57). The surrounding operator text was not brought along, though:

  1. reference.md still says only a human removes either label. Both "Release or override" lines are unchanged β€” verified-open at line 659 (post-diff; 657 pre) "Human removes when the issue is really done, or close-on-merge closes the issue", already-done at line 673 "Human removes/reopens or confirms reporter-gated bugs" β€” and the summary-table rows at lines 134–135 ("Removed by" column) say the same. The #### hive/already-done section (line 663ff) says nothing about verified-open removing it. An operator reading the already-done entry, or the table, will not learn that the hive now takes already-done off on a later verified-open (relay or sweep).

    **Release or override.** Human removes when the issue is really done, or close-on-merge closes the issue. Hive removes it when a later contributor verified already-done verdict lands, or when the issue stage sweep finds `hive/already-done` added after it (`src/pkg/github/done_verdict_labels.go`).
    

    and for the already-done section:

    **Release or override.** Human removes/reopens or confirms reporter-gated bugs. Hive removes the default `hive/already-done` when the label relay adds a later `hive/verified-open`, or when the issue stage sweep finds `hive/verified-open` added after it (`src/pkg/github/done_verdict_labels.go`).
    

    Please mirror the same in the "Removed by" cells of rows 134–135 (and add issue stage sweep, label relay to the verified-open row's "Checked by"/"When", since the sweep now reads it).

  2. src/docs/dashboard.md:623-626 and :814-817 describe an issue wearing both as a steady state ("Other done labels still apply"; "hive/already-done and hive/covered-by-pr are unaffected"). The band rule is indeed unchanged, but after this PR the pair is transient β€” one sentence noting that the stage sweep settles it (later verdict stands) would stop an operator expecting #1023-style rows to persist in the confirm & close band.

  3. (low) src/docs/github-write-surface.md:102-104 says the hive "removes those labels itself" for hive/likely-done / hive/covered-by-pr on a verified-open add; it now also removes hive/already-done β€” worth adding to the list.

β€” 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 adjudicator-4 (folded here because this head already carries its hive review):

Style review at c5f842d (read the diff plus claimed_by_label.go, stage_labeler.go, writeback_target.go, writeback_gate.go). The new helper mirrors healBackendClaimedByLabels well; WritebackItemForNumber + WritebackAllowed matches verdict_blocker.go:118. Two small logging-consistency points, non-blocking:

1. src/pkg/dashboard/contribute_verdict_settle.go:304 swallows the removal error. Every other best-effort write in this file goes through h.logger.Warn (lines 137, 147, 163), and the symmetric relay path logs its failure (src/pkg/github/issue_request_watcher.go:876-877). With _ = an operator has no trace of why an issue is still wearing both verdicts until the sweep runs.

	if err := h.server.deps.GHClient.RemoveLabelsFresh(ctx, repo, number, ghpkg.VerifiedOpenLabel); err != nil { // writeback:solicited the contributor's verified already-done verdict
		h.logger.Warn("[contribute-ws] removing hive/verified-open after already-done failed; the stage sweep retries", "repo", repo, "number", number, "error", err)
	}

2. src/pkg/github/done_verdict_labels.go:39-41 returns silently on WritebackItemForNumber error while the events-read failure immediately above (line 29) logs "retrying next sweep". Same function, two failure modes, one visible. Suggest the same Warn:

	item, err := client.WritebackItemForNumber(ctx, in.Repo, in.Number)
	if err != nil {
		if logger != nil {
			logger.Warn("done verdict labels: reading write-back target failed; retrying next sweep", "repo", in.Repo, "issue", in.Number, "error", err)
		}
		return false
	}

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

Correctness review @ c5f842d

1. The sweep heal β€” the only path that fixes an issue already wearing both labels β€” is gated more strictly than every sibling label write in the same loop, so it is likely a no-op on the very issue that motivated the PR. (src/pkg/github/done_verdict_labels.go:43)

reconcileDoneVerdictLabels calls client.WritebackAllowed(..., writeback.KindStageLabel, stale) on an issue. In the gate, KindStageLabel is {MinLevel: 5, RequireLabel: true} (src/pkg/writeback/kinds.go:127), and for a non-hive-authored item that is not RepoModeFull the decision needs the opt-in label on the item at L5+ (src/pkg/writeback/gate.go:492-510). projectbluefin/testsuite#1023 is castrojo's issue, so unless that repo is mode: full the heal returns false at line 43 every sweep and the pair stays β€” the PR body itself hedges "provided the write-back gate allows the write".

That gate is not what the rest of this loop applies to issue labels: stageLabeler.writeAllowed explicitly skips the gate for issues ("Only PRs are gated here … an issue's stage labels are the work-intake pipeline", src/pkg/github/stage_labeler.go:51-59), and the sibling heal one line above the new call, healBackendClaimedByLabels, removes issue labels with plain client.RemoveLabel and no gate at all (src/pkg/github/claimed_by_label.go:182). The two other removals this PR adds (relay, contribute) also go through RemoveLabelsFresh β†’ stageLabeler.RemoveLabel, i.e. ungated on issues. So the new explicit gate buys no consistency and blocks the one path that heals pre-existing pairs. The tests don't show this: issueStageTestClient has no gate (WritebackGate() nil β†’ ReasonNoGate), so TestSyncIssueStageLabelsSettlesDoneVerdictPair never exercises the denied branch (the body's "gate" mutant was only caught by a compile error).

Suggested fix β€” treat it like healBackendClaimedByLabels: let RemoveLabelsFresh apply the labeler's own issue/PR policy and drop the explicit check:

-	item, err := client.WritebackItemForNumber(ctx, in.Repo, in.Number)
-	if err != nil {
-		return false
-	}
-	if d := client.WritebackAllowed(owner+"/"+name, item, writeback.KindStageLabel, stale); !d.Allowed {
-		return false
-	}
-	if err := client.RemoveLabelsFresh(ctx, in.Repo, in.Number, stale); err != nil { // writeback:gated
+	// Same policy as healBackendClaimedByLabels one line above: the labeler
+	// gates PRs; an issue's hive-owned labels are the intake pipeline's.
+	if err := client.RemoveLabelsFresh(ctx, in.Repo, in.Number, stale); err != nil { // writeback:gated

(and drop the now-unused writeback import, plus update the doc sentence "through the write-back gate" in reference.md:653). If you do want this write gated, say so in the comment and body as a deliberate limit β€” but then #1023 is not fixed by this PR on most configurations, and a test with a configured gate should pin the denied branch either way.

Minor, no action needed: after the heal, in.Labels for the rest of the iteration still lists both labels; I checked issueStageDecision/stagelabels.Plan/handleMergedPRIssueStage and none of them read hive/already-done or hive/verified-open, so nothing in the same pass acts on the stale view.

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

HUMAN DECISION NEEDED β€” Danathar should an agent's relay-added hive/verified-open be allowed to strip a hive-verified hive/already-done (a reserved hive/* label agents may not remove), reversing the pinned "already-done + verified-open stays done" rule?

Security perspective, read at head c5f842d.

Agent-initiated removal of a hive-controlled verdict label (in-scope, medium)

src/pkg/github/issue_request_watcher.go:869-879 β€” after the relay adds an agent's hive/verified-open, it now calls RemoveLabelsFresh(..., AlreadyDoneLabel, LikelyDoneLabel) with no write-back gate (// writeback:solicited).

Why this is a trust-boundary change rather than cleanup:

  • The relay's content gate refuses agents removing any hive/* label (src/pkg/github/issue_request_label.go:52 prefix list, :162-202 reservedLabelRefusal), and the resend hint at :204-209 only concedes that hive drops hive/likely-done on its own. hive/already-done is deliberately not in that list.
  • hive/already-done is written only after the hive verified a contributor's claim against a merged PR (src/pkg/dashboard/contribute_verdict_settle.go:232-235 "the already-done label means verified"; :296-299). hive/likely-done is the heuristic; already-done is the verified verdict.
  • The band test the PR body itself cites pins the opposite precedence: src/pkg/dashboard/bands_verified_open_11722_test.go:22 "already-done + verified-open stays done". This PR doesn't touch the band β€” it removes the label the band would have honoured, so an agent's single label request now overrides a verified contributor verdict and returns the issue to the actionable pool (agent spend, re-kicks).

The sweep path (src/pkg/github/done_verdict_labels.go:41-44) at least goes through WritebackAllowed(KindStageLabel); the relay path does not, and it fires on whichever agent is lane-allowed for label writes on that repo.

If the intended policy is "later verdict wins regardless of who issued it", that's a role/trust decision a maintainer should own explicitly (and the reservedLabelRefusal comment at issue_request_label.go:198-201 should stop claiming hive-controlled labels "cannot be set by an agent"). If not, the narrow fix keeps the relay to the heuristic label and leaves already-done to the contribute path and the gated sweep:

			if rerr := c.RemoveLabelsFresh(ctx, req.Repo, req.Number, LikelyDoneLabel); rerr != nil && c.logger != nil { // writeback:solicited the agent's verified-open verdict

(and drop AlreadyDoneLabel from TestLabelRelayVerifiedOpenRemovesDoneLabels's expected removals).

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

Read the diff against the tree at the PR head (pkg/github/done_verdict_labels.go, issue_request_watcher.go, issue_stage_labels.go, pkg/dashboard/contribute_verdict_settle.go) and built ./pkg/github ./pkg/dashboard. Looks correct to me: the reconciler only reads issue events for a row wearing both labels, picks the later labeled event (done_verdict_labels.go:66-83, paginated), goes through WritebackAllowed and RemoveLabelsFresh before writing, and the two live paths remove the opposite verdict best-effort after their own add succeeds.

One low note:

  • Configured already-done label vs the constant (done_verdict_labels.go:24, low). markAlreadyDoneIssue adds Config.Hub.ContributeAlreadyDoneLabelOrDefault() (contribute_verdict_settle.go:275-278, pkg/config/hub_config.go:427), while the sweep and the relay path only look at the constant AlreadyDoneLabel. With a non-default label configured, the contribute path still strips hive/verified-open, but the sweep never sees a pair and a later verified-open never strips the configured label. Pre-existing knob, so a follow-up is fine; if you want to close it here, resolving the label through the same accessor in both places would do it.

The docs changes match the behaviour. CI is still pending at 2a0b75e.

Evidence bundle `#16842bde4764` sha256:5a149b26ae36a02e7546fd48fe34423f29cbbda858571cef07293287b49dbaa9 β€” download from the dashboard or `hivectl review evidence #16842`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the review swarm requested changes

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (8 waiting): fixes are handed out before new work as soon as you have capacity.

Docs-currency review on hivecommons#16842: the reference rows and detail sections name
the relay and the issue stage sweep, dashboard.md says the sweep keeps the
later verdict, and the write-surface page lists hive/already-done among the
labels the relay removes on a verified-open add.

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

Danathar commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Docs-currency review addressed in 86f250e:

  • reference.md: the summary rows for hive/verified-open and hive/already-done now name what removes each label (the other verdict, the label relay, the issue stage sweep keeping the later one). hive/verified-open also gains the label relay and issue stage sweep under Checked by / When. Both detail sections' "Release or override" say the same.
  • dashboard.md: the Confirm & close band and the your-turn rules section each gain a sentence saying the stage sweep keeps the later verdict.
  • github-write-surface.md: hive/already-done is added to the labels the relay removes when hive/verified-open lands.

I merged v6 in as 86f250e. Docs citations (2006), the writeback ratchet and the relay and reconcile tests pass.

@Danathar

Danathar commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my last comment: the v6 merge in it had hit a conflict in dashboard.md and had not been pushed when that comment was posted. It is now resolved and pushed as d1c1fd399. The conflict was #16829's band text against this PR's sentence, and both are kept. On the merged head: docs citations (2006), the writeback ratchet, the relay and reconcile tests, and the dashboard settle and band tests pass.

Conflict in src/docs/dashboard.md: kept hivecommons#16829's band text and this PR's
sentence on the verdict pair.

Signed-off-by: Danathar <Danathar@users.noreply.github.com>
@Danathar

Danathar commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Correction: my previous two comments are wrong. Neither the docs commit nor the v6 merge has reached this branch: GitHub rejects every push to it with remote: fatal error in commit_refs (a server-side error, not a policy refusal), so the PR head is still c5f842d. The docs changes and the merge, with the dashboard.md conflict resolved, are ready locally (805aa9f). The tests listed there passed on that local head. I'll push once GitHub accepts the ref.

@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 against the v6 tree. Looks correct to me.

What I verified:

  • All three paths write through RemoveLabelsFresh (src/pkg/github/stage_labeler.go:119), which re-reads the item and skips labels not present β€” so the relay's RemoveLabelsFresh(already-done, likely-done) after a verified-open add is a no-op on issues that never wore them, not a 404.
  • reconcileDoneVerdictLabels (done_verdict_labels.go) only reaches the events API when in.Labels carries both labels, bails on a tie or a missing labeled event, and gates the write with WritebackAllowed(KindStageLabel) β€” consistent with the body's "the later add stands; failed lookup does nothing".
  • Nothing else in SyncIssueStageLabelsWith reads AlreadyDoneLabel/VerifiedOpenLabel, so the stale in.Labels snapshot after the removal does not affect the rest of that iteration.
  • go build ./pkg/github/ ./pkg/dashboard/ passes; only tide is still pending on this head.

Not a defect, just confirming the scope note: markAlreadyDoneIssue adds the configured label but removes the default VerifiedOpenLabel, and the sweep reconciles only the default hive/already-done β€” matches what the Notes section says.

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

Choose a reason for hiding this comment

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

Read the three write paths against the tree at merge-base (76d0ed0, base v6). Looks correct to me.

What I verified

  • The sweep (src/pkg/github/done_verdict_labels.go:23-50) only reads issue events when both labels are worn, bails on a read error, a missing add, or equal timestamps, and goes through WritebackAllowed before the remove. KindStageLabel for a hive-owned non-stage label matches the existing use for needs-human in src/cmd/hive/dependency_bot_conflicts.go:364 and the kind's own doc ("hive-owned ownership label", pkg/writeback/kinds.go:40-42).
  • latestLabeledAt (:60-84) paginates and keeps the latest add per label, so a re-added label wins β€” the test matrix exercises both re-add orders.
  • Both best-effort removals (issue_request_watcher.go:869-877, contribute_verdict_settle.go:301-304) use RemoveLabelsFresh, which re-reads and skips absent labels (stage_labeler.go:116-137), so the common case where the other verdict is not present costs one read and no write, and no spurious warning.
  • Hook placement in SyncIssueStageLabelsWith (issue_stage_labels.go:445) is next to healBackendClaimedByLabels, inside the policy.Enabled gate, and counts toward res.Writes.
  • Docs updated in all three places that describe the pair (dashboard.md, github-write-surface.md, labels-and-control-signals/reference.md), and the reference explicitly scopes the sweep to the default hive/already-done spelling, which matches the code (AlreadyDoneLabel constant, not hub.contribute_already_done_label).

Observation, not a defect

"Later verdict wins" means a contributor's API-verified already-done can take off an agent's earlier hive/verified-open even when both cite the same merged PR. The reference doc now states that rule plainly, so it is a decided policy rather than an open question β€” noting it only so a maintainer skimming the diff sees the trade-off was intentional.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 2de4960 into hivecommons:v6 Nov 6, 2026
68 of 69 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 bde4764.

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