Repository navigation
Description
Problem
hive:status is the quiet-mode delivery path (#15876) and the maintainer decision on #16075 says to reuse it for issues and PRs, but first to "provide one authoritative cross-writer admission path and prevent lost sections or duplicate status creation". Today it has three races (analysed on v5 @ae1ffdf in the #16075 thread):
- Lost update.
Client.UpsertPRStatusSection(src/pkg/github/pr_status_comment.go) lists comments to read the status body, computesnext := prstatus.Upsert(prev, key, text), then callsUpsertIssueMarkerComment(src/pkg/github/gfi_forge.go), which lists again and edits tonext. The second read is compared only withnext, never with the first read, so a section another writer added in between is overwritten. - Second writer, no shared serialisation. The automerge engine's
Engine.editStatusSection(src/pkg/github/automerge/automerge_stage_labels.go) edits the same comment from its own read, and creates it from a separate call site. - Duplicate create. When no status comment exists, two writers can both see "not found" and both create one (two notifying comments); later passes edit only the first match, so the second goes stale but stays visible.
Issue-side consolidation (#15966 has three writers on one lifecycle) will hit these far more often than PRs do, so this must land before any issue-side work.
Scope
- One authoritative status-write function (e.g. a
StatusWriterinsrc/pkg/githuborsrc/pkg/prstatus) that everyhive:statuswriter goes through —UpsertPRStatusSection/PostNoteOrFold/PostClaimNoteand the automerge engine'seditStatusSection+ its create site. - Serialise status writes per
(repo, number)within a process. - Compare-and-retry: immediately before
EditComment, re-read the comment; if its body differs from the body the section was computed from, recomputeprstatus.Upserton the fresh body and retry (bounded attempts). - Post-create reconciliation: after creating a status comment, re-list; if more than one comment carries
prstatus.Marker, merge their sections into the oldest and delete the newer ones (deletion only of hive-authored status comments). - No change to which notes are folded, to normal (non-quiet) mode, or to any hold/merge/review behaviour.
Decision taken by hive: cross-instance safety for the status card is achieved by the in-process lock + compare-and-retry + merge-into-oldest reconciliation (status edits do not notify, so a rare transient duplicate self-heals). Cross-instance admission for notifying attention events is a separate, stronger mechanism scoped in the episode child — per the decision, a non-atomic list-before-create check is not treated as attention dedupe.
Acceptance criteria
- All in-tree
hive:statuswriters (client + automerge engine) route through the single writer; no other code path edits/creates aprstatus.Markercomment (grep-checked in a test or lint-style unit test). - Unit test: two concurrent writers upserting different section keys on the same item both survive.
- Unit test: a body changed between read and edit triggers re-read and retry, and the third-party section is preserved.
- Unit test: two status comments present → sections merged into the oldest, newer one deleted, merged body contains every section exactly once.
- Notification tally (
notification_tally.go) still counts created/edited/suppressed correctly. - No new dependency.
Likely files
src/pkg/github/pr_status_comment.go, src/pkg/github/gfi_forge.go, src/pkg/github/automerge/automerge_stage_labels.go, src/pkg/prstatus/prstatus.go, tests alongside.
Evidence
RFC #16075 §1 and §2 ("one authoritative writer or atomic admission per item"); maintainer decision comment on #16075 (2026-11-02, @clubanderson); race analysis in the #16075 thread (point 1).
Part of #16075
— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88
Activity
hivecommons-hive commentedon Nov 2, 2026
🔒 Claimed by @mrbobbytables (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply
/unclaimto release, or/claimto take it over if you outrank the holder.4 remaining items
hivecommons-hive commentedon Nov 2, 2026
🔒 Claimed by agent
scanner(agent on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 2h0m0s without activity and renews while the work continues. Reply/unclaimto release, or/claimto take it over if you outrank the holder.hivecommons-hive commentedon Nov 2, 2026
🔓 Claim by agent
scannerreleased (holding agent relaunched).