Repository navigation
fix(bin): stop re-waking main for inactive outcomes already presented as branch outcomes - #7306
andersmoldin wants to merge 5 commits into
Conversation
…presentation The inactive-outcome scan only honored its own presented receipts, so a done or failed ship whose PR main had already presented and acknowledged through the branch outcome store (mark-processed) still woke main with an inactive terminal outcome awaiting captain presentation. fm-branch-outcome.sh gains a read-only processed-covers query, and a main home with a branch outcome store records such an outcome as presented instead of waking main. A changed terminal state, an outcome recorded before the PR existed, an outcome main only read, another task or PR, and an unreadable store still wake main.
…escan via lock-free coverage read
|
Speaking as Kun's firstmate (OSS triage, not the captain). Welcome, and thank you @andersmoldin — repeated inactive-outcome wakes for an already-presented PR are exactly the kind of noise we want gone. I read tip Contract-class: restore (my own check). The existing inactive-reconcile + branch-outcome path already marks outcomes presented and expects one captain presentation. VISION.md, rule by rule
Security review before approving fork CI: no workflow, secret, or network changes. I approved CI Outcome: waiting-ci. This isn't waiting on you. If CI comes back green on this head and main tip CI is healthy, it can auto-merge as a restore. |
Intent
Firstmates retrospektiv 2026-10-14, punkt 4 som den lades fram: "Upprepade aviseringar om PR:er som redan var presenterade. Vad hände: "Inactive terminal outcome awaiting captain presentation" kom för PR 141, 144, 148, 151 och fler, trots att jag redan hade visat dem för dig. Varje avisering kostade en tur och ett meddelande till dig. Rättning: när huvudsessionen har presenterat ett utfall bör det markeras som presenterat, till exempel med
fm-branch-outcome.sh mark-presented <id>, så att aviseringen inte kommer igen."Molle om punkt 4: "Jag vet inte om det finns några inställningar för firstmate, men det är ganska babbligt just nu. Om jag har missat ett par meddelanden är det väldigt mycket att läsa ikapp." Efter att
/quietvisat sig inte behövas (övervakningssessionen håller redan rutinhändelser borta) och firstmate rekommenderat att rätta upprepningen: "Vi testar retro 4."Exempel ur dagens kö (väckningsrader som main fick):
check inactive-outcome:<hash> inactive terminal outcome awaiting captain presentation: child=aslan-ikon-beskuren state=done pr=https://github.com/andersmoldin/aslan-private/pull/151, som kom efter att supervision-host redan levererat ett BRANCH OUTCOME för samma PR (seq 348) som main hade presenterat och markerat medbin/fm-branch-outcome.sh mark-processed --through 348. Samma sak föraslan-coach-mcpfelPR 141 ochaslan-b09-tavlaPR 144.What Changed
bin/fm-branch-outcome.sh processed-covers --task <id> --state done|failed [--pr <url>]query. It exits 0 and prints the seq when the newest processed captain outcome for the task still covers its terminal outcome. "Covers" means three things: the status file identity is unchanged, the latest event and the event at the recorded endpoint both have the same terminal state, and the PR URL appears there as a whole word. Legacy rows without provenance, and a store, cursor or marker that is unreadable or out of order, count as not covered.bin/fm-inactive-reconcile.shscan now runsprocessed-coversbefore queueing an "inactive terminal outcome awaiting captain presentation" wake. The query runs within the scan's remaining timeout and only when a branch outcome store exists. If it reports covered, the scan moves the pending receipt to.presentedand queues no wake. If the query times out, the scan tries again next time. A newpresented <fingerprint>query reports whether an outcome is already presented, either through its receipt or through a covering processed branch outcome.bin/fm-wake-drain.shnow removes inactive-outcome rows from the printed output whenpresentedreports them as already presented. These rows stay inside the acknowledged range, so--ack-throughstill consumes them.docs/supervision-host.mddescribes both behaviors.Risk Assessment
Testing
Jag körde den riktade testfilentests/fm-inactive-reconcile.test.sh, och alla tester gick igenom, även de tre nya. Sedan körde jag fem live-scenarier med de riktiga skripten mot ett eget labbhem (fm-lab-home.sh). Labbet hade en privat tmux-socket med ett riktigt fönster för barnet, och den riktiga busy-state-skrivaren (fm-busy-event.sh). Därför rapporterade den riktigafm-crew-state.sh"state: done" för PR 151. Barnet hetteaslan-ikon-beskuren, med samma PR-URL som i intentet. - Vanliga ordningen: när PR:en var kvitterad före skanningen köade skanningen ingen väckning, och utfallet markerades som presenterat. - Skanning före kvittens: när väckningen redan låg i kön hölls den undan vid tömningen. Det gällde både vid tömning direkt eftermark-processedoch efter en omskanning. Den vanliga--ack-throughförbrukade ändå raden, och en andra tömning visade ingenting. - Adversariella fall: ett utfall som bara var läst, och ett nyttfailed:efter ett kvitteratdone:, gav fortfarande avisering. - Baslinje: samma sekvens mot bascommiten 0397cb2b gav aviseringen för den redan presenterade PR 151 i båda ordningarna. Det finns inget grafiskt gränssnitt, så evidensen är CLI-transkript. Labbhem, tmux-servrar och temporära filer togs bort efteråt, och worktree:n är ren.Evidence: Live: kvitterad PR före skanning ger ingen väckning
Source: Live: kvitterad PR före skanning ger ingen väckning
Evidence: Live: köad väckning hålls undan vid omedelbar tömning och förbrukas av ack
Source: Live: köad väckning hålls undan vid omedelbar tömning och förbrukas av ack
Evidence: Live: köad väckning hålls undan efter omskanning
Source: Live: köad väckning hålls undan efter omskanning
Evidence: Live adversariellt: läst men inte kvitterat utfall avviseras fortfarande
Source: Live adversariellt: läst men inte kvitterat utfall avviseras fortfarande
Evidence: Live adversariellt: nytt failed:-utfall efter kvitterat done: avviseras
Source: Live adversariellt: nytt failed:-utfall efter kvitterat done: avviseras
Evidence: Baslinje 0397cb2: felet återskapat (kvittens före skanning)
Source: Baslinje 0397cb2b: felet återskapat (kvittens före skanning)
Evidence: Baslinje 0397cb2: felet återskapat (skanning före kvittens, omedelbar tömning)
Source: Baslinje 0397cb2b: felet återskapat (skanning före kvittens, omedelbar tömning)
Evidence: Labbdrivare som användes för alla live-scenarier
Source: Labbdrivare som användes för alla live-scenarier
Evidence: Riktad testfil, logg
Source: Riktad testfil, logg
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-branch-outcome.sh:315- Simplification:status_provenance_coversaccepts the PR in two places:names_pr "$covered_event" "$pr" || names_pr "$summary" "$pr". The second path checks the branch's free-text summary, which an LLM writes, and is a separate way for an outcome to count as covered. The intent's examples (PR 141/144/151) are PR-ready ship outcomes, and their covered status event is the mode'sdone: PR <url> …line, which already names the PR. The narrower form is to accept only the covered event (names_pr "$covered_event" "$pr"). The summary path is needed only if real covered events can name the PR in another form, for examplePR #151. If they can't, remove it so that suppressing a wake never depends on prose.bin/fm-inactive-reconcile.sh:582- Simplification: the newpresented_via=branch-outcome:<seq>receipt field is extra audit metadata. The intent only requires the outcome to be marked presented so the wake doesn't repeat, andmark_presentedalone does that. Nothing readspresented_via; only the new test asserts it. Recommended remedy: drop the field (and the matching header text at bin/fm-inactive-reconcile.sh:69-71,77, plus the test assertion) unless you want it kept as evidence.🔧 Fix applied.
2 warnings still open:
bin/fm-inactive-reconcile.sh:582- Simplification: the newpresented_via=branch-outcome:<seq>receipt field is extra audit metadata. The intent only requires the outcome to be marked presented so the wake doesn't repeat, andmark_presentedalone does that. Nothing readspresented_via; only the new test asserts it. Recommended remedy: drop the field (and the matching header text at bin/fm-inactive-reconcile.sh:69-71,77, plus the test assertion) unless you want it kept as evidence.bin/fm-inactive-reconcile.sh:576- A wake that was queued before main ran mark-processed still reaches main. Concrete sequence: (1) The child writesdone: PR …/pull/151. (2) supervision-host appends captain seq 348. (3) Main is busy or the captain is away for more than FM_INACTIVE_RECONCILE_SECS (900 s), so 348 is still unprocessed when the scan runs. processed-covers exits 1, and the scan queuesinactive-outcome:<fp>(bin/fm-inactive-reconcile.sh:584-587). (4) Main presents 348 and runsmark-processed --through 348. (5) On the next scan the pending record is found again (ensure_record returns the existing .pending), processed-covers now prints 348, and mark_presented renames the receipt (line 579). Nothing removes the row already in .wake-queue, and fm-wake-drain.sh does not filter inactive-outcome rows by receipt state (no terminal-outcomes/.presented check there). Main still gets 'inactive terminal outcome awaiting captain presentation' for a PR it already presented. Later acknowledge() then finds no .pending and returns 0 (line 676). The change fixes the sequence where the queue entry is written after processing. It does not fix the ordering where the scan runs first, which also fits the intent's wording that the wake 'kom efter' ('came after') the processed seq. Possible remedies: (a) when the covered path finds an existing presentation-phase record, also retire its queuedinactive-outcome:<fingerprint>row, or (b) have the drain drop inactive-outcome rows whose receipt is already .presented. Either one adds a new wake-queue mutation path beyond the stated change, so the remedy needs authorization even though the defect is mechanical. Sibling site: bin/fm-wake-drain.sh:268-272 (acknowledge_inactive_outcomes), the only consumer that currently retires these rows.🔧 Fix applied.
1 warning still open:
bin/fm-wake-drain.sh:1075- Round 2 added this drain-time withhold, as the user prescribed with remedy (b). It still misses the most common ordering of the scan-first case.fm-inactive-reconcile.sh presentedexits 0 only after a later scan has moved the receipt from .pending to .presented (bin/fm-inactive-reconcile.sh:687-693). That move happens only at bin/fm-inactive-reconcile.sh:583-588, and the scan runs at most once per FM_INACTIVE_RECONCILE_SECS (900 s, gated at bin/fm-inactive-reconcile.sh:651). Concrete sequence: (1) The scan queuesinactive-outcome:<fp>while captain seq 348 is read but not processed. fm-watch.sh:2778-2780 then wakes main immediately. (2) Main is mid-turn, presents 348 and runsmark-processed --through 348. (3) The turn ends and the watcher's wake makes main drain within seconds or minutes. No rescan has run yet, so the record is still.pendingwith phase=presentation.presentedreturns 1, and the drain prints 'inactive terminal outcome awaiting captain presentation … pr=…feat(spawn): per-task crewmate model selection (--model) #151' for a PR main just presented. That is exactly the repeat the intent describes. The fix helps only if main leaves the queued wake undrained for at least one full scan cadence after mark-processed, which the immediate watcher wake makes rare. The new regression test (tests/fm-inactive-reconcile.test.sh:210-240) ages the scan marker and rescans before draining, so it passes without covering this ordering. Possible remedy: have the read-onlypresented <fingerprint>query, which fm-inactive-reconcile.sh owns, also report a pending presentation-phase record as presented whenfm-branch-outcome.sh processed-coverscovers its task_id/state/pr. A second option is to trigger a coverage re-check at mark-processed time. Either one extends the drain/receipt contract that round 2 was asked to keep narrow, and the drain-time option would take the branch-outcome lock while the drain holds the wake-queue lock, so the remedy needs a decision. Sibling sites: bin/fm-wake-drain.sh:271-285 (withhold_presented_inactive_outcomes), bin/fm-inactive-reconcile.sh:687-693 (presented), bin/fm-inactive-reconcile.sh:569-588 (the only path that moves a covered record to presented).🔧 Fix applied.
1 info still open:
tests/fm-inactive-reconcile.test.sh:256- Rounds 2–3 added a drain-time withhold (bin/fm-wake-drain.sh:1075, withhold_presented_inactive_outcomes at :271-285, backed byfm-inactive-reconcile.sh presentedat bin/fm-inactive-reconcile.sh:690-704). The tests only check one direction: that a covered row is NOT printed (tests/fm-inactive-reconcile.test.sh:212). No test drains an uncovered inactive-outcome row and asserts that the drain still prints it. test_unprocessed_or_different_branch_outcome_still_presents (:256-316) only counts rows in .wake-queue and never runs the drain. test_main_direct_terminal_presentation_receipt (:328) sends the drain's stdout to /dev/null. A regression that over-withholds would pass the whole suite while silently dropping a real captain notification, for example ifpresentedreturned 0 for any pending record with phase=presentation, or if the awk key match were broadened. Today's code is correct: a read-only outcome yields processed=0, an empty ROW, and exit 1, so the row is printed. Smallest fix: in test_main_direct_terminal_presentation_receipt, and in the 'branch-read-only' case at :257-263, capture the drain's stdout and assert it contains 'awaiting captain presentation' for pull/1.✅ **Test** - passed
✅ No issues found.
bash tests/fm-inactive-reconcile.test.sh(riktad testfil, inklusive de tre nya testerna: processed-branch-outcome, wake-queued-before-processing withheld, unprocessed/different outcome still presents)Live:live-lab-driver.sh <worktree> processed-first: lab-FM_HOME viabin/fm-lab-home.sh create, barnfönster på privattmux -L fm-lab, idle-tillstånd viabin/fm-busy-event.sh arm, riktigafm-crew-state.sh→fm-branch-outcome.sh append/mark-read/mark-processed→fm-inactive-reconcile.sh scan --startup→fm-wake-drain.sh→--ack-throughLive:live-lab-driver.sh <worktree> scan-first-drain-now(skanna, mark-processed, töm direkt utan omskanning)Live:live-lab-driver.sh <worktree> scan-first-rescan(skanna, mark-processed, omskanning, töm)Live, adversariellt:live-lab-driver.sh <worktree> read-only(utfallet läst men inte kvitterat) ochfailed-after(nytt failed:-utfall efter kvitterat done:)Baslinje: samma drivare motgit archive 0397cb2bförprocessed-firstochscan-first-drain-now✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary
processed-coversmeans: newest processed captain branch outcome for the task, status file identity unchanged, latest status event and latest event through the outcome'sstatusEndpointboth have the same terminal verb, and that covered event names the recorded PR as a whole word.Evidence
processed-first- done ship withdone: PR …/pull/1 checks green, captain branch outcome appended,mark-read,mark-processed; inactive scan still queuedinactive-outcome:<fp>"awaiting captain presentation" (redtest_processed_branch_outcome_counts_as_presented).After: no wake, receipt
.presented; also green when main drains before any rescan (scan first,mark-processed, drain at once: no "awaiting captain presentation" line, ack still consumes the row).failed, PR-ready line after a processed pre-validation handoff, another task,/pull/10vs/pull/1, an outcome that never named the PR, unreadable store.tests/fm-inactive-reconcile.test.shgreen;tests/fm-branch-supervision.test.shandtests/fm-afk-return.test.shgreen; ShellCheck 0.11.0 clean on every changed script.Merge Danger
Door: two-way
Additive read-only query and a drain filter; reverting restores the previous repeat wakes.
Blast Radius: supervision-wakes
A wrongly covered outcome would hide one inactive-outcome wake for a PR main already acknowledged as a branch outcome; every unreadable or ambiguous read falls back to waking main.