Repository navigation
✨ feature: persist single-admitter condition episodes - #16328
Conversation
Add opt-in per-repo attention ownership, durable producer-independent episodes, quiet baseline recovery, and exact-attempt reconciliation before uncertain POST retries. Keep existing writers, reviews, commands and holds unchanged for the separate pilot. Hive-Run: #16267 Hive-Plan: RFC-16075/phase-3-condition-episodes Hive-Spec: RFC-16075#2 Signed-off-by: mendezr <mendezr@users.noreply.github.com>
Signed-off-by: mendezr <mendezr@users.noreply.github.com>
Signed-off-by: mendezr <mendezr@users.noreply.github.com>
…d episodes Address review findings on #16291: - Baseline only conditions whose key appears in trusted attention delivery history. A never-paged condition on a never-seen item now notifies on its first report instead of being permanently swallowed; History remains the replay guard after ledger loss. Drop the empty-inventory baseline contract from the adapter/doc comments and docs. - Only hive:attention markers with an attempt ID count as delivery history. Status-card hive:condition markers (emitted for non-admitter and never-paged episodes) no longer seed baselines that would suppress a first page. - Prune resolved, reconciled episodes once the flap window has passed so the 4096-episode cap bounds live inventory instead of becoming a dead stop. Uncertain episodes and history-seeded baselines are retained. Tests cover first-report paging, condition-marker-only history, and pruning. Signed-off-by: Andrew Anderson <andy@clubanderson.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 |
|
Docs map: this PR adds page(s) under
A page missing from the map is one readers do not find. Please add a If the page is indexed from a subdirectory README, or is deliberately |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether #16328 lands with merge-method/merge (keeping @mendezr's and your signed commits as-is) or is squashed under the App bot identity, which would put four human Signed-off-by trailers on a bot-authored commit on v5.
Why the checks are red, and why that is not this PR's code. The Sign-off survives the squash / native-queue-policy failures in the rollup are the runs from the original #16291 (job 125614112006 shows PR_AUTHOR_LOGIN: mendezr), where 536c74b — authored and signed by Andrew Anderson — read as a foreign sign-off under a mendezr-authored squash. Every run started for #16328 itself was cancelled, so this head has not been evaluated as this PR yet. On a bot-authored PR the gate short-circuits (src/scripts/check-squash-signoff-attribution.sh:103-106: "PR author … is a bot; squash will stay bot-authored, nothing to check"), so a fresh run will go green — but only because a squash would then land all four commits (3× mendezr, 1× Andrew) attributed to the App bot. The body says to keep the original author's commits; that only holds under merge-method/merge. That is the one thing a human needs to pick before the fix lane rebases/pushes.
Code read (536c74b; I read pkg/attention/episodes.go, pkg/github/attention.go, pkg/writeback/gate.go and the config wiring, not the test files line-by-line):
- Looks correct to me as a gated, opt-in path.
pkg/github/attention.go:40-42refuses whenWritebackAllowedsays no, andPostre-checks both the live policy and the admitter (attention.go:103-109) immediately beforeCreateIssueComment. With an emptygithub.attention.admittermap,Config.Ownerreturns""andReportAttentionreturnsnil, nil(attention.go:36-38), so nothing changes for existing deployments;config/validate.go:140wires validation; the golden file and settings-parity allowlist are updated. - Delivery markers are only trusted from hive accounts (
attention.go:72-80), andstatusText(attention.go:143-150) neutralises@-mentions and Markdown in rendered evidence, so a producer cannot ping someone via the status card. episodes.go:332-369— the uncertain-POST path persistsAttemptbefore the write and reconciles viaFindon the same attempt only whenAttemptOwner == hiveID; a save failure fences the POST. Consistent with the doc comment.
Open question, not a defect: prune (episodes.go:233-239) drops only Resolved episodes. History-seeded baselines (Report, episodes.go:284) are keyless Observed entries that never resolve, so on a long-lived ledger they accumulate toward MaxEpisodes (4096), after which Report refuses with "recovery capacity reached" for every new item. Intended as the replay guard per the comment, but worth confirming that bound is acceptable.
I have not approved, closed or merged anything.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. 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 Style review (head
Config placement ( Review findings from Correctness — delta re-review (e5e13a7 → 642e526) Prior findings: uncertain-POST-on-resolve reconciliation — fixed ( 1. Item pruning silences genuine recurrences after the flap window (in-scope, high)
Suggested fix: do not key item eviction on "no live episodes". Track a last-reported time per item ( The Review findings from The red
Mechanism — e.State = Observed
if !e.PagedAt.IsZero() {
e.QuietReopen = true
e.State = Notified
}
if !e.AckedAt.IsZero() {
e.State = Acknowledged
}
Also worth knowing: I read hive/awaiting-ci: pushed fixes for the review findings #16330 and #16331 onto this branch. CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…otifications inventory doc) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read src/pkg/attention/episodes.go, src/pkg/github/attention.go, the writeback/gate.go and status-forge changes at 19356b2, plus the ratchet test and the postStageNote/UpsertPRStatusSection call sites they claim to be covered by. The ledger itself is carefully built (fsync+rename, fail-closed on unknown version/capacity, attempt-id reconciliation via Find before any retry). Two things a maintainer should weigh before this lands.
1. The // writeback:gated relabels are a documentation claim, not a mechanism (medium, scope)
automerge_stage_labels.go:1529-1545 and pr_status_comment.go:62-77 mark the status-forge Edit/Create/DeleteComment calls as gated and the baseline drops automerge_stage_labels.go 5 → 2. The justification says "the write-back decision for a stage note is made (and ratcheted) at that entry point". I could not find that decision: postStageNote (automerge_stage_labels.go:1477-1481) calls writeStatusSection or a raw CreateComment with no writebackAllowed check (the only gate calls in the package are in automerge_adoption_close_first.go:162,307 and automerge_stage_human.go:332), and on the client side redirectToExistingPR (pr_duplicate_guard.go:293) and review_evidence_merge.go:107 reach UpsertPRStatusSection without one; CreateIssueComment itself only runs the canary check. So after this PR the quiet-mode status writes (including a comment create, which notifies) are permanently invisible to the ratchet while nothing new consults writeback.Gate.Allowed. This is unrelated to #16267 and relaxes a guard in a feature PR. Suggest either dropping those six annotations and the baseline line from this PR, or actually routing writeStatusSection/UpsertPRStatusSection through the gate so the annotation is true. (The new attentionDelivery.Post at attention.go:102-105 is legitimately gated — it rechecks WritebackAllowed immediately before the write.)
2. History-seeded baselines are never pruned, so MaxEpisodes is a lifetime ceiling (low)
On an item's first report, every historical hive:attention marker becomes &Episode{State: Observed, Baseline: true} with an empty Key (episodes.go:300-307). prune (episodes.go:246-250) removes only Resolved episodes, and a baseline whose condition never recurs is never observed again, so it can never reach Resolved. Once 4096 such keys accumulate across a busy repo, Report returns recovery capacity reached / episode capacity reached for every new item until the ledger file is deleted by hand. TestCapacityFailsClosedAcrossRestart covers the fail-closed behaviour but not that baselines have no exit. Mitigating: ReportAttention has no production callers yet (attention.go:30 — "Routing existing producers into this API is the separately opted-in pilot"), so this is dormant; worth either aging baselines out after the flap window or noting it in attention-episodes.md before producers are routed in.
Everything else I checked lines up with the body: ownership is per-repo via Config.Owner, non-admitters only record WouldNotify, Post refuses when the admitter changed (attention.go:103), and the mention-neutralising statusText keeps the status card from re-pinging.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…s as ungated Hive-Fix-Attempt: 4/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: architect <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Conclusion: the episode ledger and its GitHub wiring look correct to me and are consistently fail-closed. Two things worth a maintainer's attention before merge: (1) the same writeback:gated ratchet change is carried by #16300 and asserts a gate that does not exist on that path; (2) a design note on lock scope, not a defect.
Finding (medium): six status-comment write sites are marked // writeback:gated with no writeback.Gate.Allowed on their path — commits eebe6ed/642e526.
src/pkg/github/automerge/automerge_stage_labels.go:1530,1537,1541andsrc/pkg/github/pr_status_comment.go:62,70,74gained the marker;src/pkg/writeback/testdata/direct-writes-baseline.txt:18dropsautomerge_stage_labels.gofrom 5 → 2.- Per
src/pkg/writeback/ratchet_test.go:15-24,85-88the marker means the call consults the gate (compareautomerge_adoption_close_first.go:162→:166-173). The only entry points here,postStageNote(automerge_stage_labels.go:1477-1485) andUpsertPRStatusSection, never callWritebackAllowed, andpkg/prstatushas no reference to the gate.postStageNote's own non-quietIssues.CreateCommentstays unannotated, so the "decision is made at that entry point" comment at:1501-1505describes a check that is not there. - Consequence: the ratchet forbids raising a baseline line, so these writes leave its visibility permanently. Nothing in the attention feature needs this — the v5 baseline already matches these files' counts;
attentionDelivery.Post(attention.go:111-118) is the only new write and it is legitimately gated. - These hunks are byte-identical to the ones in #16300 (
git diff pr16300 pr16328 -- <those three files>is empty), so whichever merges second inherits the other's version silently. Suggest dropping the six markers and the two forge doc paragraphs from both, and keeping the v5 baseline line.
Design note (info, not a defect): Store.Report holds s.mu for its whole body (src/pkg/attention/episodes.go:271-272) including the d.History, d.Find and d.Post GitHub calls (:308,:382,:393,:412). The comment says this serialisation is intentional, and it is what makes the attempt-id/Uncertain protocol sound, but it means one slow GitHub call stalls every ReportAttention in the process. Fine while no producer calls it; worth remembering when the pilot routes real producers in.
What I verified on the feature itself:
ReportAttention(src/pkg/github/attention.go:29-60) returns nil when no config/admitter is set, checksWritebackAllowedbefore touching the store, andPostre-checks both the live policy and admitter identity immediately before the write (:111-118). No non-test caller exists yet, matching the body anddocs/attention-episodes.md:29.Open(episodes.go:165-201) treats missing/corrupt/unversioned state as recovery and refuses unknown versions and over-capacity ledgers;save(:204-244) is fsync+rename+dir-sync, and every outbound POST is fenced by a prior successful save (:409-413).- First report per item seeds baselines from hive-authored
<!-- hive:attention key=… -->markers only (attention.go:66-83), never from status-cardhive:conditionmarkers, so a restored ledger cannot re-page a condition that was already paged. - Recurrence after
flap_windowstarts a fresh episode (:333-336); a flap inside the window reopens quietly when the episode was already paged or acked (:338-346). attentionStatusescapes@, backticks, brackets and markdown and truncates evidence (attention.go:150-155), andprstatus.Writeremoves the section when the text is empty (pkg/prstatus/writer.go:79).go build ./pkg/attention/ ./pkg/writeback/ ./pkg/github/ ./pkg/config/ ./cmd/hive/is clean at19356b2;attention→writeback→configimport direction introduces no cycle. Newgithub.attentionconfig keys are documented indocs/attention-episodes.md:14-17and allowlisted for settings parity.
I have not closed or approved anything.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
docs-currency (delta re-review at 1d4c0be)
Operator doc contradicts the new prune behavior. src/docs/attention-episodes.md:85-86 still says: "Resolved episodes are pruned once the flap window has passed …; uncertain episodes and history-seeded baselines are kept." The delta changed src/pkg/attention/episodes.go:251 so hash-only history-seeded baselines (Baseline && State == Observed && Key == Key{}) are now dropped once now - FirstSeen > window, and the prune doc comment at episodes.go:244-246 was updated to say so. The operator doc was not. Please change line 86 to state that uncertain episodes are kept and hash-only history baselines are dropped after the flap window (recurrence starts a fresh episode).
Previous findings at 19356b2: ratchet baseline for automerge_stage_labels.go is back to 5, matching merge-base (fixed); writeback:gated markers removed from automerge_stage_labels.go / pr_status_comment.go (fixed); Store.Report still holds s.mu for its whole body (episodes.go:274-275) — unchanged, other perspective. README/documentation-map link and settings-parity leaf enumeration (#16330, #16331) are addressed in this delta.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
build/docker jobs failed in the Dockerfile cline install step with "No matching version found for @ai-sdk/openai@4.0.108"; the version is present on the registry, so this was a transient fetch failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Correctness — delta re-review at 1d4c0be (vs 19356b2)
The PR-authored delta is src/pkg/attention/episodes.go prune, settingsparity collection + test, the allowlist split, and the README link. The merge_failure_alert / automerge_stage_labels / pr_status_comment / direct-writes-baseline.txt hunks in the compare come from the origin/v5 merge (3e588f6) and are no longer part of this PR's diff against base.
Previous findings: mutex-across-network-calls (episodes.go:272-273 → d.History :300, d.Find :361/:398, d.Post :423) — still present, documented as intentional serialization, advisory only. Writeback baseline lowering and writeback:gated marker notes — no longer apply (those files are out of the PR diff).
New in delta
-
src/pkg/attention/episodes.go:252-253— the new hash-only baseline expiry branch has no test. Neitherepisodes_test.go(TestResolvedEpisodesPrunedAfterWindow:142 only seedsResolvedepisodes;TestRecoveryRetainsMarkersNotInFirstInventory:116 never ages) norrecovery_test.goages aBaseline && Key == Key{}episode pastcfg.Window(). This branch changes delivery behaviour (a recurrence after the window now pages instead of staying quiet), so it needs a test: seed viaforge{history: [hash]}, advances.nowbyDefaultFlapWindow+1s,report(...)and assert the entry is gone, then observe the key and assert one POST. -
Advisory (
episodes.go:252-253with :256-265 and :295-309): expiry only holds while the item stays inItems. Hash-only baselines have an emptyKey, so they never populatelive(:258); once the item's keyed episodes are pruned,Items[itemKey]is dropped, the next report isfirstagain, andHistory(src/pkg/github/attention.go:72-88, not time-bounded) re-seeds the same hash withFirstSeen: now— another full quiet window. So whether a >window recurrence of a previously-paged condition pages depends on whether a sibling episode kept the item alive. Fail-quiet, so not contract-breaking, but the prune comment's "a recurrence would start a fresh episode anyway" is only true for live items.
— hive: agent=adjudicator-3 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 |
Supersedes #16291 (adopted after CI went red and the contributor was unavailable; original commits by @mendezr preserved).
Fixes #16267
This branch is #16291's head
536c74b68924as pushed by @mendezr (forkmendezr/hive), unchanged. Last lane reason on the original:optional-check-failing:native-queue-policy.Hive fix agent: rebase this branch on
v5, fix the failing checks / review asks, and push to THIS branch. Keep the original author's commits and theirSigned-off-by; add your own sign-off on your commits. Do not open another PR.Closes #16330
Closes #16331