Repository navigation
π Edit claim ledger, needs-decision and sentinel comments in place; suppress reviewer-lane no-findings reviews - #16434
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. @clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. Review findings from Correctness β delta re-review at 6075c46 (vs 697fd41). The delta fixes two of the prior findings; CI on this head (run 41672539466) still fails in Prior findings: New on this head (both are the PR's own gates, not pre-existing failures):
Review findings from One verified gap worth fixing before this lands, otherwise the in-place-edit design reads sound to me. (Also: the PR is currently The claim-ledger upsert will edit a stranger's comment on an identity-unknown hive β medium.
Low / non-blocking: the sentinel reuse picks the hive's first I read the sentinel path against Review findings from Read the tree at 83bf59f ( One finding worth fixing before this lands: The ledger edit is not idempotent under retry, and the retry drops the human notice β medium.
Cheap fix: Non-blocking:
|
There was a problem hiding this comment.
Security perspective β head 697fd41
Ledger upsert trusts any comment author when the hive cannot name its accounts, and re-emits that comment's history verbatim.
src/pkg/github/issue_marker_comment.go:48 selects the comment to edit with c.markerAuthorTrusted(cm.GetUser()), which (label_approval.go:436-441) returns true for every author when knowsOwnAccounts() is false. The sentinel path in this same PR deliberately refuses that fallback (sentinel_sweep.go:704 β if !posted && c.knowsOwnAccounts(), "never rewrites a comment the PR author may have forged"), and the 085/090 upsert requires an App login (automerge_stage_human.go:723-726). The claim ledger is the odd one out: on a PAT hive that cannot reach /user, a stranger's comment containing <!-- hive:issue-claim-ledger --> is PATCHed by the hive (issue_marker_comment.go:70), destroying that user's comment.
The render step compounds it: claims.LedgerComment (src/pkg/claims/ledger_comment.go:62-65) feeds the previous body through ParseLedgerHistory (:97-121), which only trims the - bullet, and writes the lines back out unchanged (:83-87). Only the new line is scrubbed of <!-- (:188). A forged ledger whose history contains - <!-- hive:claim who=evil β¦ --> is thus re-emitted under hive authorship β a second marker in a comment issueclaim.Latest and humanClaimReleased (claimed_by_label.go:101, trusted-author gated) will now believe.
Suggested fix β match the sentinel's rule and sanitize on read:
--- a/src/pkg/github/issue_marker_comment.go
+++ b/src/pkg/github/issue_marker_comment.go
@@ -45,7 +45,10 @@ func (c *Client) EditIssueMarkerComment(ctx context.Context, repo string, number int, marker string, render func(previous string) string) (IssueMarkerCommentResult, error) {
var existing *gh.IssueComment
- for _, cm := range comments {
- if cm == nil || !strings.Contains(cm.GetBody(), marker) || !c.markerAuthorTrusted(cm.GetUser()) {
+ // Only a comment the hive can verify as its own is edited; an
+ // identity-unknown hive posts fresh, as the sentinel does.
+ for _, cm := range comments {
+ if cm == nil || !c.knowsOwnAccounts() || !strings.Contains(cm.GetBody(), marker) || !c.isHiveAccount(cm.GetUser()) {
continue
}--- a/src/pkg/claims/ledger_comment.go
+++ b/src/pkg/claims/ledger_comment.go
@@ -114,7 +114,8 @@ func ParseLedgerHistory(body string) []string {
if !strings.HasPrefix(line, ledgerLinePrefix) {
continue
}
- if line = strings.TrimSpace(strings.TrimPrefix(line, ledgerLinePrefix)); line != "" {
+ line = strings.ReplaceAll(strings.TrimPrefix(line, ledgerLinePrefix), "<!--", "")
+ if line = strings.TrimSpace(line); line != "" {
lines = append(lines, line)
}
}Update the issue_marker_comment.go:29-33 doc comment accordingly. Nothing else from this perspective: the 085/090 upsert, sentinel rewrite and CleanReview (rejects any body with <!--, no_findings.go:47) look sound.
β hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the tree at 697fd41 (base 9c62646): the ledger renderer, EditIssueMarkerComment, the claimswire.go hooks, the humanClaimReleased reconciler, trySentinelPR, postHumanEntry, CleanReview and the watcher. The design holds up β one marker per ledger body keeps issueclaim.Latest/ParseMarker/ParseReleaseMarker reading the same thing, and CleanReview refusing any body with <!-- keeps decision/redundant markers posting. Both red checks, however, are caused by this diff (both are green on the base commit).
1. src/pkg/review/no_findings_test.go:45 β does not compile (golangci-lint typecheck). PerspectiveReport has no own field Findings; it is promoted from the embedded outputschema.AgentReport (src/pkg/review/review.go:125), and Go composite literals cannot set promoted fields. The element type is also outputschema.Finding, not PerspectiveFinding (review.go:324). CleanReview itself compiles because len(r.Findings) reads through the embedding; only the test literal is wrong. Nest it: AgentReport: outputschema.AgentReport{Findings: []outputschema.Finding{{β¦}}}.
2. src/pkg/github/automerge/automerge_stage_human.go:688 β second comment-list call per 085/090 entry breaks the read-budget invariant (test rest 1/4). findOwnEntryComment calls c.listIssueComments on every postHumanEntry. TestAdoptionMarkerWithClosedCopyReadopts (automerge_adoption_orphan_test.go:243) and TestAdoptionMarkerSettledOrAbsentIsNotRecovered (:324) assert exactly one comment read per observation β the adoption-marker read β and now see 2. That assertion is guarding API spend on every PR the engine parks, so I would not relax it; reuse the comments the adoption read already fetched for this observation (or thread a per-observation comment cache) rather than listing again.
3. Low β src/pkg/claims/ledger_comment.go:124 LedgerMentions is a substring match. strings.Contains(lower, "@"+holder) makes @bob match a ledger that only names @bobby, so a first-time human holder with a prefix login gets no notifying comment (the only email they would receive, since the edit notifies nobody). A word-boundary check, or matching the exact rendered forms mention(c)/ledgerName(c), fixes it.
Also worth a look: humanClaimReleased (claimed_by_label.go:107) sets ledgerReleasedHuman = humanClaimKind(rel.Kind) when the ledger's current state is a release and ignores the history in that branch, so a human β agent takeover β agent release sequence reads as "not released" until the next agent claim rewrites the ledger. I could not construct a path where ApplyClaimedByLabel runs against that intermediate state (it is only consulted on an agent claim, which rewrites the ledger first in the same queue), so this is an open question rather than a defect.
Verdict: changes requested for 1 and 2; both are small. I have not changed anything.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
CI triage β head
|
There was a problem hiding this comment.
Correctness β delta re-review at 1edafe2 (delta: claimswire_budget_test.go, claimswire_relaunch_test.go only)
Delta is sound: the new TestClaimHooks_ClaimLedgerEditsOneCommentPerIssue ordering assertions (edited[0] = release, edited[1] = re-claim) are safe because hooks run through the per-issue claimEffectQueue (src/cmd/hive/claimswire.go:119-135, :295). Prior finding "claim-hook tests not updated for ledger default" is fixed β cmd/hive passes in CI at this head.
Two prior in-scope findings are still present and still fail CI at this head (run 41674127367: pkg/claims and pkg/github FAIL):
-
src/pkg/claims/comments.go:121β release prose carries the raw reason;TestLedgerCommentTakeoverAndMarkerHygienefails.releaseCommentAtsanitizes the reason inside the marker but writes it verbatim into the π prose, so a reason of<!-- hive:claim who=evil β¦ -->puts a second<!-- hive:claimprefix into the ledger body (ledger_comment_test.go:110-112expects 0).ledgerHistoryLinealready strips<!--(ledger_comment.go:180); the prose line needs the same.fmt.Fprintf(&b, "π Claim by %s released (%s).", mention(c), strings.Join(strings.Fields(strings.ReplaceAll(strings.ReplaceAll(reason, "<!--", ""), "-->", "")), " ")) -
src/pkg/github/issue_marker_comment.go:60βEditIssueMarkerCommentmissing fromnotificationWriteSites;TestNotificationWriteSitesInventoryfails. The create path callsCreateIssueCommentBudgetedfrom a new method with no inventory entry (notification_write_sites.go:22-32listsUpsertIssueMarkerCommentonly). Add the passthrough entry and the matching row insrc/docs/notifications.md(next to line 482):"github.(*Client).UpsertIssueMarkerComment": {Class: NotificationClassStatus, Passthrough: true}, + "github.(*Client).EditIssueMarkerComment": {Class: NotificationClassStatus, Passthrough: true},| `github.(*Client).UpsertIssueMarkerComment` | `status` | passthrough wrapper; attributed to its caller | +| `github.(*Client).EditIssueMarkerComment` | `status` | passthrough wrapper; attributed to its caller |
β hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦uppress reviewer-lane no-findings reviews Issue-side comment churn (#16433): hive:claim/hive:release transitions now maintain one per-issue claim-ledger comment edited in place (github.notifications.claim_ledger, default on) that every existing marker reader still parses; the needs-decision/ready entry comment is rewritten with an Updated line on re-entry; a new push rewrites the hive's existing sentinel comment instead of stamping the PR again; and in quiet mode a reviewer-lane review that narrates "no findings" with an approving, finding-free verdict is recorded and folded into the hive:status comment instead of being submitted. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦r vs legacy mode Signed-off-by: Andrew Anderson <andy@clubanderson.com>
β¦er openers out of ledger release prose Signed-off-by: Andrew Anderson <andy@clubanderson.com>
83bf59f to
e632061
Compare
β¦ paths Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 38a9ff9. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
There was a problem hiding this comment.
Read the tree at 38a9ff9 (base af4ad99): the three edit-in-place paths, their marker readers, and the claims write hooks. The core compatibility argument holds and I found no correctness defect; two low-severity notes below.
Marker compatibility β verified. issueclaim.Latest (src/pkg/issueclaim/issueclaim.go:300-330) picks the claim by the marker's own StartedAt/until= and matches releases by identity + at=, never by comment position, so an in-place-edited ledger that is old by created_at still reads correctly. The ledger body carries exactly one hive:claim/hive:release marker (ledger_comment.go:59-70; TakeoverComment adds hive:preempt, which Latest ignores) and history lines strip <!--. The sentinel keeps the exact-head findOwnMarkerComment read for sentinelClearedByMaintainer (sentinel_sweep.go:691-708), only widening to the prior-head comment behind knowsOwnAccounts(). The 085/090 upsert only rewrites a comment whose author equals the App login (automerge_stage_human.go:719-727). The claims hooks run ledger-then-label synchronously inside one queue.run closure, so humanClaimReleased sees the freshly edited ledger when an agent claim reconciles the human label.
Low β ledger edit is not idempotent under retry (src/cmd/hive/claimswire.go:273, src/pkg/claims/ledger_comment.go:63). The comment says "a PATCH that lands twice is the same body", but LedgerComment(previous, event) re-parses the history from previous and appends the event again, so a retry after a successful edit (e.g. the follow-up CreateIssueCommentBudgeted for a human notice fails retryably inside the same run) duplicates the history line and, for takeovers, re-posts LedgerDisplacedNotice (claimswire.go:337 ignores previous). Consequence is cosmetic plus one possible duplicate ping; a dedupe of the last history line, or runOnce for the notice POST, would close it.
Low β identity-unknown fallback edits any author's comment (src/pkg/github/issue_marker_comment.go:49,71). markerAuthorTrusted returns true for every author when knowsOwnAccounts() is false, and unlike the sentinel path (sentinel_sweep.go:704, which refuses to reuse a prior comment in that state) the ledger then EditComments whichever comment carries <!-- hive:issue-claim-ledger --> β an App with issues:write can edit anyone's comment, so a forged marker from a PR author gets overwritten with the ledger. The docstring acknowledges the fallback and the forged-author case is covered by TestEditIssueMarkerCommentIgnoresForeignAuthorAndEmptyBody only for the identity-known case. Narrow window (needs a hive that cannot resolve its own login), but gating the edit branch on knowsOwnAccounts() and falling back to a fresh POST would match the sentinel's rule in the same PR.
Body matches the diff: all four numbered changes, the claim_ledger knob, docs, allowlist and changelog fragment are present. Looks correct to me with the two notes above; neither blocks.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦ent-per-PR alert v5 #16434 (#16433) rewrites the hive's existing sentinel comment for a new head instead of posting a second one. The v6-only clearance carry-over tests still asserted a fresh second comment; align them with the same expectation #16434 applied to the other re-alert tests. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Fixes #16433
An audit of the last 48h (2026-11-03) shows the hive still posts 1264 comments/48h (7.5 bot : 1 human). The PR-side churn was fixed by #15876 / #15919; the remaining top offenders are issue-side and are re-posts that carry no information the previous comment lacked. This PR edits them in place.
Before (48h window)
hive:claim+hive:releaselease_revoked88,holding_agent_relaunched47) append a release+claim pair each time; 19 items got 2β3 claimshive:stage-needs-decisionre-postshive-sentinelreviewer/reviewer-2Changes
pkg/claims/ledger_comment.go,cmd/hive/claimswire.go,pkg/github/issue_marker_comment.go). One comment per issue marked<!-- hive:issue-claim-ledger -->, PATCHed on every claim / takeover / release: current state (the samehive:claim/hive:release/hive:preemptmarker and text the standalone comments carried) plus a collapsed history of the last 8 transitions. First claim creates it; a human holder the ledger has never named still gets one notifying comment, as does a displaced human on a takeover. Knobgithub.notifications.claim_ledger(defaulttrue;falserestores a comment per transition). The ledger carries exactly one machine marker soissueclaim.Latestand everything on it keep working unchanged;issueclaim.ReleasegainedKindand theclaimed-bylabel reconciler reads the ledger history for "did the human let go".automerge_stage_human.go,stagelabels/human.go).postHumanEntryfinds the hive's own existing entry comment for the stage and rewrites it with anUpdated <ts>line; a stranger's comment carrying the marker is never edited.sentinel_sweep.go). A new head rewrites the hive's existing sentinel comment instead of posting a second one. Only a comment the hive can verify as its own is reused (identity-unknown hives still post fresh, as the clearance recorder already does). Tests that asserted one comment per head were updated accordingly.review/no_findings.go: CleanReview,review_request_watcher.go). In quiet mode a body that says "no findings" whose verdict report approves with an empty findings list and asks for no decision is suppressed like the one-line acknowledgement; the verdict and reviewer notes land in thehive:statuscomment as areview-findings:<agent>section. Bodies with a hive marker, a decision request or a non-approving verdict still post.Docs:
operator-reference/sweeps-and-operations.md(notification mode section + new claim-ledger section),settings_parity_allowlist.txt, changelog fragment.Marker consumers kept compatible
issueclaim.Latest/ParseMarker/ParseReleaseMarker(claim recovery, dashboard contribute claims, contributor lane),github.humanClaimReleased(claimed-by label sweep),hive:preempton takeovers,sentinelClearedByMaintainer/recordSentinelClearance(exact-head sentinel read unchanged).No
time.Sleepin the new tests;gofmt -lclean. CI is the verdict per AGENTS.md.