Repository navigation
🐛 fix(prstatus): only edit hive-owned status comments - #16347
Conversation
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[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 |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: pushed 85f5af3 — pkg/github fakes now stamp the App bot as comment author (the six rest-3/4 failures were fixtures returning authorless comments, which the new Own-only writer rightly treats as foreign). CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. Review findings from Correctness review (head 8a597d3) 1. CI Fix: have Otherwise the writer change itself reads correct: create path merges foreign bodies ( Review findings from Conclusion: looks correct to me. Read Verified:
One thing worth knowing (info, not a defect): |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
There was a problem hiding this comment.
Docs currency (read at head 8a597d3)
src/pkg/prstatus/writer.go:58-59— the opening sentence ofWrite's godoc still says it creates the comment "only when the item has none", while the paragraph this PR added to the same doc (writer.go:69-71) and the new create path (writer.go:79-89, covered byTestWriteCreatesOwnedCommentWhenOnlyForeignStatusExists) now create a hive-owned comment whenever no hive-authored status comment exists, even if a foreign one does. The doc comment contradicts itself. Suggested: "creating a hive-owned comment only when the item has no hive-authored one".- Same stale rule is repeated in the callers' docs and the package doc, none touched by this PR:
src/pkg/github/pr_status_comment.go:12-13and:21("created only when the PR has none" / "merged into the oldest"),src/pkg/github/automerge/automerge_stage_labels.go:1490-1491, andsrc/pkg/prstatus/prstatus.go:11("merges duplicate status comments into the oldest"). One-line rewording each to "oldest hive-authored".
Code and changelog fragment look consistent with #16345; this is doc-only.
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
CI triage —
Why.
So after the first create, Fix (test-only, two lines). Give the fake-created comments a bot author, matching the existing fixture at // pr_status_comment_test.go:42
cm := map[string]any{"id": 100 + s.creates, "body": body["body"], "user": map[string]any{"login": "hive-app[bot]", "type": "Bot"}}
// review_evidence_read_test.go:258
out = append(out, map[string]any{"id": i + 1, "body": c, "user": map[string]any{"login": "hive-app[bot]", "type": "Bot"}})
Worth adding while here: one Not pushing: this is the scanner lane's branch. 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Read src/pkg/prstatus/writer.go in full at 333081f and built the package. The fix does what #16345 asks and I found no defect; one side-effect worth knowing about below.
Verified
- Edit target is now
ownStatus(status)[0](writer.go:104-108), so a third-party comment carrying the status marker can no longer be rewritten with the App token even when it is the oldest.ErrStatusCommentGonestill fires when no owned comment exists after reconcile, so the retry path's contract is unchanged. - Create path (
writer.go:79-91): when the only status comments are foreign, the new owned comment is seeded withMerge(foreign bodies...)thenUpsert(key, text).Mergeis first-wins by section key (writer.go:240-253), so after thatreconcilealways merges with the owned body first and foreign sections only fill missing keys — idempotent, no edit when nothing changed (editCompareAndRetryreturns early onnext == base,writer.go:183). reconcile(writer.go:129-162): oldest owned is the merge target; the delete loop already had the!c.Ownguard, so foreign comments are never deleted. Covered by the existingTestWriteNeverDeletesForeignStatusCommentplus the two new tests.
One behavioural note (low, not a blocker)
Because a foreign status comment is now permanently left in place and re-merged on every Write with >1 status comment, a section the hive deletes (Upsert(cur, key, "")) is re-added on the next Write if the foreign comment still carries that key — reconcile runs before the Upsert in the same call (writer.go:94-103), so the removal holds within one Write but not across two. This already happened before the PR when the foreign comment was newer than the owned one, so it is not a regression introduced here; it just now also applies when the foreign one is oldest. Acceptable trade-off versus rewriting someone else's comment, but if removals need to stick, reconcile could skip merging from !c.Own comments after the initial create.
Looks correct to me. Not approving (reviewer lane); I have changed nothing.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
prstatus now edits only hive-owned status comments, so the pkg/github fakes must return the authenticated App as the comment user the way GitHub does; without it every created comment read as foreign and the next write created again. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read src/pkg/prstatus/writer.go at 8ade32b together with both Forge adapters. The change does what #16345 asks and I found no defect; looks correct to me.
What I verified
Writenow picksownStatus(status)[0]as the edit target (writer.go:104-108) and, when no owned comment exists, creates one seeded withMerge(foreign bodies…)(writer.go:84-89). Thereconcilethat follows the create re-lists, finds the new comment asown[0], computesMerge(cur, foreign)which equalscur(the create already folded those sections in), soeditCompareAndRetryreturns(false, nil)and the foreign comment is skipped by the existing!c.Ownguard (writer.go:152-154). No second edit, no delete of the pasted comment.reconcilewith mixed ownership (writer.go:132-145) still merges foreign sections into the oldest owned comment and only deletes owned duplicates, matching theComment.Owndoc atwriter.go:15-18that the pre-PR code did not honour.- Create-spam risk is not real: both adapters classify the App's own comments as
Ownfrom theBottype /[bot]suffix alone, independent of config —pr_self_authorization.go:58viahiveAuthoredLogin, andpr_approve_command.go:30viaIsPersonLoginfor the engine forge (automerge_stage_labels.go:1520). So after one create the nextWriteedits, it does not create again. TestWriteEditsOldestOwnedNotForeignStatusCommentfails on the base tree (therestatus[0]is the foreign comment and gets rewritten), so the test covers the behaviour change. Theuseradditions to the threepkg/githubfixtures are what real GitHub payloads carry; without them those tests would fall into the create path.
Note (info, pre-existing, not a blocker): "owned" here means "not a person" — any [bot] account's status marker (another hive's App, for instance) is still an edit/delete target, since Own is computed by IsPersonLogin/isHumanAuthor rather than by comparing to appBotLogin. That is the semantics the field already had before this PR; the changelog line's "hive-authored" slightly overstates it. Fine to leave as is or tighten in a follow-up.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #16345
A status-marker comment authored by a third party could become the hive's edit target when it was the oldest, and the hive would rewrite its body with the App token. The writer now edits only comments it owns and creates its own when none exists, merging from foreign status comments but leaving them in place (and never deleting them).
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88