Skip to content

fix(bin): retain startup network completions and deliver them through recovery - #7613

Open
kesslerio wants to merge 17 commits into
kunchenguid:mainfrom
kesslerio:fix/5378-startup-network-wake-receipt
Open

kesslerio wants to merge 17 commits into
kunchenguid:mainfrom
kesslerio:fix/5378-startup-network-wake-receipt

Conversation

@kesslerio

@kesslerio kesslerio commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • The deferred startup network worker now commits each finished run to a private per-generation record under state/.startup-network-results/<generation>/ (report, optional timings, status written last as the completion boundary) before publication, and runs a lock-free retention pass that keeps the current generation, queued generations, and a small name-only look-back window.
  • Publication, wake enqueue, and delivery are generation-fenced under the startup lock: actionable results queue startup-network:<generation> wakes backed by state/.startup-network-wake-receipts/<generation> enqueue receipts, contended publication keeps the immutable completion for later recovery instead of claiming findings are readable, and recover/prune modes expose that path.
  • Shared supervision now counts deferred startup work (live worker, unsettled retained completion, or unhandled startup wake row) as supervision need, and the existing owned watcher runs a bounded recovery attempt each cycle; docs, the bootstrap diagnostics skill, and the operational home layout are updated to match.

Risk Assessment

✅ Low: Generation fencing, retained completion recovery, receipt handling, and pruning follow the approved contracts; no concrete material defects were substantiated.

Testing

Four live scenarios (late actionable delivery, late clean silence, supervision need before and after acknowledgement, and adversarial retention/starvation) were driven end-to-end against the real startup-network stage, wake queue, drain, guard, and prune in disposable lab homes with the real bootstrap probe against a stand-in gh network client; all passed. The five focused suites that cover this change also pass. No TUI harness primary was required: this change's surface is the scripted startup-network delivery path, which was exercised directly rather than only through its tests.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A user starts a session whose startup network check is still running when the digest drains; once it finishes late and is actionable, supervision receives a durable `check: startup-network:<generation… ✅ pass live Lab home + real bin/fm-startup-network.sh start/harvest/report + real bin/fm-bootstrap.sh probe with a slow failing gh: scenario-a-harvest-midflight.txt, scenario-a-report-generation.txt, `s…
After that wake is handled and acknowledged, the row is consumed, recover/prune/a second drain re-enqueue nothing because the wake receipt suppresses producer replay, and the current generation's… ✅ pass live scenario-a-drain-ack.txt (ack-through 1 + recovery generation consumed the row to 0 bytes) followed by recover --generation, prune, second drain leaving the queue empty and the result director…
A user's late clean startup success enqueues no captain-facing wake, while its retained result still reads as a silent success ✅ pass live Second lab home with a slow silent-success gh: no .wake-queue file, no receipt, clean:&lt;generation&gt; settled marker, scenario-b-report.txt shows (silent - no problems found)
While late startup work is unhandled or its wake is undelivered, the guard reports the home still needs supervision; after the drain acknowledges it and the result settles, the guard reports no need ✅ pass live scenario-a-guard-before-drain.txt (banner + queued wakes pending, needed from the startup obligation) vs. silent bin/fm-guard.sh after ack
Adversarial: a retention pass must never delete the current generation, a queued generation (or its receipt/wake row), or the newest three generations, while deleting older settled and incomplete gene… ✅ pass live scenario-c-before-results.txt / scenario-c-after-results.txt / scenario-c-after-receipts.txt / scenario-c-after-queue.txt; kept 1200.1.1 (queued, still readable via `scenario-c-queued-report.t…
Adversarial: seventy newer incomplete completions cannot hide three older settled results, and repeated retention passes stay bounded and idempotent, leaving only the three-generation look-back window ✅ pass live Seeded 70 incomplete + 3 older settled (100/200/300) then three real prune runs: pass 1 deleted all three old settled results (74→10), pass 2 reached 3, pass 3 unchanged — `scenario-d-after-pass1.tx…
Evidence: Consolidated live-scenario transcript (commands, outputs, lab setup, teardown)

Source: Consolidated live-scenario transcript (commands, outputs, lab setup, teardown)

# Live validation log - fix/5378-startup-network-wake-receipt

Driver: disposable `bin/fm-lab-home.sh create` lab homes under /tmp, driven with the
real `bin/fm-startup-network.sh` (start/run/harvest/report/prune/recover),
`bin/fm-wake-drain.sh`, and `bin/fm-guard.sh` from this worktree. The only stand-in is
the external `gh` network client on PATH; bootstrap is the real `bin/fm-bootstrap.sh`
run in its `FM_BOOTSTRAP_NETWORK=only` probe phase.

## Scenario A - a late actionable startup check still reaches supervision

Fixture: disposable `gh` sleeps 8s then fails (`gh: authentication required`), so the
deferred gh-auth probe finishes AFTER the session-start drain.

1. `bin/fm-startup-network.sh start --locked 0 --harvest-pid 999999999` returned 0
   immediately; status recorded `state=running`.
2. The drain ran while the check was still in flight (`harvest --pid 999999999`):
IN PROGRESS - the deferred network checks have not finished yet.
NOT yet confirmed: GitHub authentication.
Started 0s ago, bounded at 120s.
Only a FAILED or otherwise actionable result arrives as a `check: startup-network:<generation>` wake; a clean success stays silent.
The durable result is readable on demand with {run-worktree}/bin/fm-startup-network.sh report; until it finishes, treat none of it as confirmed.

3. On completion, the retained result, the generation-scoped wake row and its receipt:
   - `state/.startup-network-results/<generation>/{report,status}` retained
   - `.wake-queue` row: `check  startup-network:<generation>`
   - `state/.startup-network-wake-receipts/<generation>`
4. `report --generation <generation>` (on demand, after the drain):
completed off the startup path in 8s: GitHub authentication.
NEEDS_GH_AUTH
These ran AFTER the sections above were composed, so re-read any record a line here names.
TIMINGS - where the deferred network checks spent their time (ms):
  phase       gh-auth                                    start=+92      elapsed=8007
  stage       network-checks probe                       start=+29      elapsed=8079
  slowest: stage network-checks probe 8079ms, phase gh-auth 8007ms

5. Supervision was told the home still needs watching while that result was undelivered
   (`bin/fm-guard.sh`, needed=true because of the startup obligation):
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  X-mode relay polling needs supervision, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  After draining queued wakes, repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e {run-worktree}/.pi/extensions/fm-primary-turnend-guard.ts -e {run-worktree}/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.

6. The durable drain presented the generation-scoped wake to the session:
1794694864	1	check	startup-network:1794694856.3463441.999999999	check: startup-network: deferred startup network checks finished (done); read them with {run-worktree}/bin/fm-startup-network.sh report --generation 1794694856.3463441.999999999
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3464134.1794694864.J74j5u
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.

7. Acknowledging consumed the row; a repeated `recover`, `prune`, and second `drain`
   re-enqueued nothing (the receipt suppresses producer replay) and the current
   generation's result stayed retained. The guard then printed no supervision need.

## Scenario B - a late clean success stays silent but is retained

Disposable `gh` sleeps 6s then succeeds silently. Mid-flight drain:
IN PROGRESS - the deferred network checks have not finished yet.
NOT yet confirmed: GitHub authentication.
Started 0s ago, bounded at 120s.
Only a FAILED or otherwise actionable result arrives as a `check: startup-network:<generation>` wake; a clean success stays silent.
The durable result is readable on demand with {run-worktree}/bin/fm-startup-network.sh report; until it finishes, treat none of it as confirmed.

After completion: no `.wake-queue` file at all, no receipt, result retained with a
`clean:<generation>` settled marker, guard silent. `report`:
completed off the startup path in 6s: GitHub authentication.
(silent - no problems found)
TIMINGS - where the deferred network checks spent their time (ms):
  phase       gh-auth                                    start=+111     elapsed=6006
  stage       network-checks probe                       start=+40      elapsed=6089
  slowest: stage network-checks probe 6089ms, phase gh-auth 6006ms

## Scenario C - retention keeps the current, queued, and look-back generations

Seeded into the delivered lab home: settled generations 1000..1900, a queued generation
1200.1.1 with its receipt and queue row, an incomplete 0600.1.1, a symlink 0500.1.1 to a
directory outside the results root, and a foreign `not-a-generation` name.
`bin/fm-startup-network.sh prune` then:

before:
0500.1.1
0600.1.1
1000.1.1
1100.1.1
1200.1.1
1300.1.1
1400.1.1
1500.1.1
1600.1.1
1700.1.1
1794694856.3463441.999999999
1800.1.1
1900.1.1
not-a-generation
after:
1200.1.1
1794694856.3463441.999999999
1800.1.1
1900.1.1
not-a-generation
receipts after (current, queued, look-back kept; deleted generations' receipts removed):
1200.1.1
1794694856.3463441.999999999
1800.1.1
queue after (queued row untouched):
golden	1	check	startup-network:1200.1.1	check: startup-network: deferred checks finished
The symlinked entry's link is gone while its target still holds `DETACHED TARGET CONTENT`;
the foreign name and the incomplete-record rules match the approved contract, and a second
pass changed nothing. The queued generation stays readable for its consumer:
completed off the startup path in 1s: the deferred network checks.
ACTIONABLE_1200
These ran AFTER the sections above were composed, so re-read any record a line here names.

## Scenario D - incomplete backlog never starves older results, and each pass is bounded

Seeded 70 newer incomplete completion directories plus 3 older settled ones (100/200/300).
Pass 1: `old_settled_present=0` (all three old settled results deleted on the first pass),
74 entries -> 10. Pass 2: 10 -> 3. Pass 3: unchanged 3 (look-back window only):
1794694901.3497779.999999998
2068.1.1
2069.1.1

## Focused suites run as the change's own regression evidence

- tests/fm-startup-network.test.sh (all assertions passed, incl. retention matrix,
  bounded-pass, start-never-scans, return-without-holding-stdout, watcher recovery)
- tests/fm-wake-queue.test.sh (startup receipt ownership, interruption, clean-refusal)
- tests/fm-turnend-guard.test.sh (startup obligation survives receipt until ack)
- tests/fm-claude-stop-autoarm.test.sh, tests/fm-cursor-primary.test.sh
Evidence: Scenario A: digest drain while the check is still running (generation-scoped pending guidance)

Source: Scenario A: digest drain while the check is still running (generation-scoped pending guidance)

IN PROGRESS - the deferred network checks have not finished yet.
NOT yet confirmed: GitHub authentication.
Started 0s ago, bounded at 120s.
Only a FAILED or otherwise actionable result arrives as a `check: startup-network:<generation>` wake; a clean success stays silent.
The durable result is readable on demand with {run-worktree}/bin/fm-startup-network.sh report; until it finishes, treat none of it as confirmed.
Evidence: Scenario A: retained late result read via report --generation

Source: Scenario A: retained late result read via report --generation

completed off the startup path in 8s: GitHub authentication.
NEEDS_GH_AUTH
These ran AFTER the sections above were composed, so re-read any record a line here names.
TIMINGS - where the deferred network checks spent their time (ms):
  phase       gh-auth                                    start=+92      elapsed=8007
  stage       network-checks probe                       start=+29      elapsed=8079
  slowest: stage network-checks probe 8079ms, phase gh-auth 8007ms
Evidence: Scenario A: guard reports supervision needed while the startup wake is undelivered

Source: Scenario A: guard reports supervision needed while the startup wake is undelivered

●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  X-mode relay polling needs supervision, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  After draining queued wakes, repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e {run-worktree}/.pi/extensions/fm-primary-turnend-guard.ts -e {run-worktree}/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
Evidence: Scenario A: durable drain presents the generation-scoped startup wake

Source: Scenario A: durable drain presents the generation-scoped startup wake

1794694864	1	check	startup-network:1794694856.3463441.999999999	check: startup-network: deferred startup network checks finished (done); read them with {run-worktree}/bin/fm-startup-network.sh report --generation 1794694856.3463441.999999999
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3464134.1794694864.J74j5u
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
Evidence: Scenario B: late clean success stays silent and readable

Source: Scenario B: late clean success stays silent and readable

completed off the startup path in 6s: GitHub authentication.
(silent - no problems found)
TIMINGS - where the deferred network checks spent their time (ms):
  phase       gh-auth                                    start=+111     elapsed=6006
  stage       network-checks probe                       start=+40      elapsed=6089
  slowest: stage network-checks probe 6089ms, phase gh-auth 6006ms
Evidence: Scenario C: results and receipts after retention (current/queued/look-back kept, older removed)

Source: Scenario C: results and receipts after retention (current/queued/look-back kept, older removed)

1200.1.1
1794694856.3463441.999999999
1800.1.1
1900.1.1
not-a-generation
Evidence: Scenario C: queued wake row untouched by retention

Source: Scenario C: queued wake row untouched by retention

golden	1	check	startup-network:1200.1.1	check: startup-network: deferred checks finished
Evidence: Scenario D: incomplete backlog drained, final look-back window only

Source: Scenario D: incomplete backlog drained, final look-back window only

1794694901.3497779.999999998
2068.1.1
2069.1.1
Evidence: Focused startup-network suite (all assertions passed)

Source: Focused startup-network suite (all assertions passed)

ok - fm-startup-network: retention bounds completed results and keeps every live obligation
ok - fm-startup-network: the worker's reservation prune retires older generations
ok - fm-startup-network: the session-start call never scans retained results
ok - fm-startup-network: the retention pass is bounded per call and resumes on the next
ok - fm-startup-network: incomplete backlog drains oldest-first
ok - fm-startup-network: abandoned running records cannot borrow a reused PID
ok - fm-startup-network: live startup-only work requires supervision and clean/dead/invalid records settle
ok - fm-startup-network: diagnostic timing-copy failure preserves completed delivery
ok - fm-startup-network: concurrent root creation cannot strand the current worker
grep: /tmp/fm-startup-network-tests.aiGByD/reservation-during-recovery/home/state/.wake-queue: No such file or directory
ok - fm-startup-network: successor reservation fences a recovery already waiting to publish
ok - fm-startup-network: explicit report generations refuse missing or unsafe artifacts
ok - fm-startup-network: existing watcher delivers after publication, queue and nested marker contention without another startup
grep: /tmp/fm-startup-network-tests.aiGByD/stale-retained/home/state/.wake-queue: No such file or directory
ok - fm-startup-network: retained stale results cannot replace successors or prevent fresh checks
grep: /tmp/fm-startup-network-tests.aiGByD/retained-publication-failure/home/state/.wake-queue: No such file or directory
ok - fm-startup-network: failed publication retains completed findings for idempotent recovery
ok - fm-startup-network: wait fails when no deferred stage publishes before its deadline
ok - fm-startup-network: start returns immediately and never holds the caller's stdout open
ok - fm-startup-network: exactly one of the digest and the wake reports each actionable result
ok - fm-startup-network: a claimant crash after publication still surfaces the result
ok - fm-startup-network: publication failure retains findings and wakes only after recovery
ok - fm-startup-network: silent and explicitly informational successes never queue a main-blocking wake
ok - fm-startup-network: an actionable state=done report still queues a wake
ok - fm-startup-network: deferred invalid secondmate markers produce durable wakes
ok - fm-startup-network: manual callers cannot forge mutation authority
ok - fm-startup-network: an aggregate bound turns a wedged sweep into an actionable line
ok - fm-startup-network: an abandoned run reports as needing a rerun, never as in progress forever
ok - fm-startup-network: locked requests supersede in-flight probe-only workers
ok - fm-startup-network: a second start never launches a competing worker
ok - fm-startup-network: start atomically reserves the generation harvest observes
ok - fm-startup-network: a new lock owner gets a distinct worker generation
ok - fm-startup-network: fleet-lock takeover cannot overlap a mutating sweep
ok - fm-startup-network: timing records share one origin so their offsets form a timeline
ok - fm-startup-network: timings are durable and printed only on demand
ok - fm-startup-network: a timed-out run still publishes the partial timings it recorded
ok - fm-startup-network: the timing artifact cannot carry a command line or forge records
grep: /tmp/fm-startup-network-tests.aiGByD/held-lock/home/state/.wake-queue: No such file or directory
grep: /tmp/fm-startup-network-tests.aiGByD/held-lock/home/state/.wake-queue: No such file or directory
ok - fm-startup-network: a held publish lock ends the worker inside its budget with a failed-rerun record
# fm-startup-network.test.sh: all assertions passed
Evidence: Focused wake-queue suite incl. startup receipt tests

Source: Focused wake-queue suite incl. startup receipt tests

ok - branch grant release lock acquisition: failure
ok - branch grant deactivate lock acquisition: failure
ok - branch grant activate lock acquisition: failure
ok - branch grant publish lock acquisition: failure
ok - branch grant release lock acquisition: success
ok - branch grant deactivate lock acquisition: success
ok - branch grant activate lock acquisition: success
ok - branch grant publish lock acquisition: success
ok - startup append serializes concurrent producers and refuses symlink receipt evidence
ok - startup consumer receipts are limited to actor-owned rows through the presented cutoff
ok - startup receipts require a real row and clean results cannot enqueue
ok - startup append interruption remains once-only after consumer acknowledgement
ok - startup receipt failure leaves the owned row intact and retryable
ok - startup producer repairs a surviving row before consumption without changing its sequence
ok - startup generation append remains once-only after real drain and acknowledgement
ok - an abandoned same-process lock hold is reclaimed; a parent's live hold is not
ok - a lock wait returns within its bound once its directory is removed
ok - without BASHPID a subshell cannot release or reclaim its parent lock and owns its own hold
ok - bounded acquire hands ownership to the waiting caller after contention
ok - presentation lock waits are bounded and retriable without weakening acknowledgement atomicity
ok - malformed presentation locks report acquire failure instead of contention
tests/wake-helpers.sh: line 346: 3585205 Killed                     PATH="$dir/fakebin:$PATH" FM_FAKE_NOW_FILE="$dir/now" FM_HOME="$dir" FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$dir/state" FM_FAKE_TMUX_WINDOW='firstmate:fm-mate' FM_SECONDMATE_WAKE_STALL_SECS=1 FM_SECONDMATE_LIVENESS_SECS=99999999 FM_POLL=1 FM_SIGNAL_GRACE=0 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$dir/watch-$leg.out" 2> "$dir/watch-$leg.err"
tests/wake-helpers.sh: line 346: 3586138 Killed                     PATH="$dir/fakebin:$PATH" FM_FAKE_NOW_FILE="$dir/now" FM_HOME="$dir" FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$dir/state" FM_FAKE_TMUX_WINDOW='firstmate:fm-mate' FM_SECONDMATE_WAKE_STALL_SECS=1 FM_SECONDMATE_LIVENESS_SECS=99999999 FM_POLL=1 FM_SIGNAL_GRACE=0 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$dir/watch-$leg.out" 2> "$dir/watch-$leg.err"
tests/wake-helpers.sh: line 346: 3589059 Killed                     PATH="$dir/fakebin:$PATH" FM_FAKE_NOW_FILE="$dir/now" FM_HOME="$dir" FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$dir/state" FM_FAKE_TMUX_WINDOW='firstmate:fm-mate' FM_SECONDMATE_WAKE_STALL_SECS=1 FM_SECONDMATE_LIVENESS_SECS=99999999 FM_POLL=1 FM_SIGNAL_GRACE=0 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$dir/watch-$leg.out" 2> "$dir/watch-$leg.err"
ok - foreign secondmate queue alerts once per no-progress episode without age-only or cascade noise
ok - declared external-wait pause rows do not feed secondmate wake-loop escalation
ok - a reprovisioned queue generation starts a fresh no-progress interval
ok - an active turn defers the secondmate stall escalation without cancelling it
ok - a long-lived mate mid-turn is not a stall, but a queue frozen past the busy bound still alarms
ok - a proven-idle leftover row is rung so the child home can drain without a parent alarm
ok - TERM stops a watcher blocked in the drain-ring idle capture and runs its cleanup
ok - busy panes defer without a ring and unknown panes keep the parent alarm
ok - a leftover row that survives a proven-idle ring still surfaces as a genuine stall
ok - secondmate stall markers reject symlinks without touching their targets
ok - stall publication acknowledgement closes the pre-marker crash window
ok - empty prefix mate cleanup preserves another mate's stall receipt
ok - self-announced appends suppress only their own bytes and fail toward waking
ok - separate self-announced answers after a fold stay owned; worker decisions and later lines still wake
ok - an unreadable status still reads as unreported, with or without owned growth
ok - a worker resolved in fold lag still wakes after this home's close
ok - owned growth suppresses the wake without hiding the turn-ended annotation
ok - historical annotations replay nothing already announced and keep everything new
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3642131.1794695066.hwuDHv
ok - concurrent append plus drain preserves durable records through acknowledgement
ok - signal written while no watcher runs is caught on next run
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3667308.1794695076.bOn3ws
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 2s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  After draining queued wakes, repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-turnend-guard.ts -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - stale wake is queued before suppressor state is advanced
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3669135.1794695078.huQpKr
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 1s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  After draining queued wakes, repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-turnend-guard.ts -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - a not-provably-working stale wake is queued before its suppressor is advanced
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3671038.1794695079.HjLt9r
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 registered custom check(s), but no live watcher process holds this home lock (last beat: 1s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  After draining queued wakes, repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-turnend-guard.ts -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - registered custom check output is queued before cadence suppression
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3672893.1794695080.RmFO0f
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 registered custom check(s), but no live watcher process holds this home lock (last beat: 1s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  After draining queued wakes, repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-turnend-guard.ts -e /tmp/fm-wake-tangle-root.CSaM0o/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - multi-line check output wakes as one line matching its queued row
ok - concurrent drains replay until one post-handling acknowledgement consumes records
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 4 --recovery-generation 3675658.1794695082.PgD2wn
ok - drain collapses obvious duplicate heartbeat and signal records
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 3 --recovery-generation 3676338.1794695083.Ruspk0
ok - drain presents every distinct payload from one check and collapses identical repeats
ok - drain asserts watcher liveness: warns on a lapse, stays silent for a live watcher with a fresh beacon
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 8 --recovery-generation 3677781.1794695084.4xe5Qt
ok - structural signal enrichment is separate, deduped, home-local, and tier-zero for other wakes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 13 --recovery-generation 3678830.1794695085.E2TGVU
ok - every readable unread status line is annotated in full while invalid status files preserve their raw wakes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3680581.1794695087.TJPhIr
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 3680581.1794695087.TJPhIr
ok - slow annotation releases the append lock and a deleted status file fails open
ok - a branch-actor scoped ack never swallows an unacked main-owned row, and main's later drain sees exactly what remains
ok - branch drain and acknowledgement keep their published grant when ps cannot inspect the host
ok - main drain and acknowledgement exclude an active branch grant
ok - a branch-actor acknowledgement commits secondmate stall receipts for exactly its granted rows
ok - a branch-held row raises no queued-wake warning for main, and the same row is presented and acknowledged once the grant clears
0
ok - a queue that cannot be counted keeps the queued-wake alarm up
ok - structurally unusable rows are retired by main alone, leaving every remaining row presentable and acknowledgeable
ok - branch grant cannot take a row already claimed by main
ok - main's acknowledgement leaves a row that arrived after its drain for whichever actor takes it next
ok - actor ownership filtering precedes same-key deduplication
ok - main reclaims rows granted to an exited branch owner
ok - a branch-actor drain with no eligible-row snapshot refuses loudly instead of draining nothing
ok - a repeat branch acknowledgement after its own ack consumed the grant says the grant was already consumed
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation existing
ok - wake append publishes atomic recovery evidence before durable rows
ok - recovery mint and delivery log avoid sibling $()
ok - wake queue: large sequences advance and acknowledge as exact digit-only decimals
ok - wake drain: generation-less legacy wakes are adopted and acknowledged
ok - a handover undoes only the downtime its own stop published over an acknowledged episode
ok - wake drain: a stale acknowledgement cannot retire or consume a newer recovery episode
ok - wake drain: an acknowledgement that consumes nothing says so and names the exact command for the current wake
ok - wake drain: a branch acknowledgement that consumes nothing names the exact command for its granted wake
ok - wake drain: recovery acknowledgement failures are explicit and retryable
ok - interruptions preserve durable rows until post-handling acknowledgement
ok - fm_wake_queue_prune_task: prunes wakes for target task without touching other tasks
ok - drain rotates scratch files an interrupted drain left under the queue lock
ok - watch liveness: a dead secondmate is relaunched once, ledgered, and quiet afterwards
ok - watch liveness: a missing secondmate endpoint is relaunched without a pre-kill
ok - watch liveness: one tick relaunches every dead mate, queues a row each, and wakes once
ok - watch liveness: alive and ambiguous endpoints are probed, logged, and never touched
ok - watch liveness: the cadence marker gates probing and survives across legs
ok - watch liveness: the attempt bound parks a flapping mate once and a live probe rearms a full budget
ok - watch liveness: a failed auto-relaunch wakes once with its cause and is ledgered
ok - watch liveness: an unwritable or unreadable relaunch ledger refuses to kill or spawn
ok - watch liveness: a per-mate error keeps scanning, recovers later mates, and still wakes
ok - watch liveness: an outcome that could not be queued surfaces as an error, not a wake
ok - watch liveness: a mate mid-episode under the shared liveness lock is skipped entirely
ok - watch liveness: an unreachable remote secondmate is probed, preserved, and never failed over

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A user starts a session whose startup network check is still running when the digest drains; once it finishes late and is actionable, supervision receives a durable `check: startup-network:<generation… ✅ pass live Lab home + real bin/fm-startup-network.sh start/harvest/report + real bin/fm-bootstrap.sh probe with a slow failing gh: scenario-a-harvest-midflight.txt, scenario-a-report-generation.txt, `s…
After that wake is handled and acknowledged, the row is consumed, recover/prune/a second drain re-enqueue nothing because the wake receipt suppresses producer replay, and the current generation's… ✅ pass live scenario-a-drain-ack.txt (ack-through 1 + recovery generation consumed the row to 0 bytes) followed by recover --generation, prune, second drain leaving the queue empty and the result director…
A user's late clean startup success enqueues no captain-facing wake, while its retained result still reads as a silent success ✅ pass live Second lab home with a slow silent-success gh: no .wake-queue file, no receipt, clean:&lt;generation&gt; settled marker, scenario-b-report.txt shows (silent - no problems found)
While late startup work is unhandled or its wake is undelivered, the guard reports the home still needs supervision; after the drain acknowledges it and the result settles, the guard reports no need ✅ pass live scenario-a-guard-before-drain.txt (banner + queued wakes pending, needed from the startup obligation) vs. silent bin/fm-guard.sh after ack
Adversarial: a retention pass must never delete the current generation, a queued generation (or its receipt/wake row), or the newest three generations, while deleting older settled and incomplete gene… ✅ pass live scenario-c-before-results.txt / scenario-c-after-results.txt / scenario-c-after-receipts.txt / scenario-c-after-queue.txt; kept 1200.1.1 (queued, still readable via `scenario-c-queued-report.t…
Adversarial: seventy newer incomplete completions cannot hide three older settled results, and repeated retention passes stay bounded and idempotent, leaving only the three-generation look-back window ✅ pass live Seeded 70 incomplete + 3 older settled (100/200/300) then three real prune runs: pass 1 deleted all three old settled results (74→10), pass 2 reached 3, pass 3 unchanged — `scenario-d-after-pass1.tx…
  • FM_STARTUP_NETWORK_CASES=… was avoided; ran bash tests/fm-startup-network.test.sh in full (exit 0, all assertions passed)
  • bash tests/fm-wake-queue.test.sh (exit 0)
  • bash tests/fm-turnend-guard.test.sh (exit 0)
  • bash tests/fm-claude-stop-autoarm.test.sh (exit 0)
  • bash tests/fm-cursor-primary.test.sh (exit 0)
  • Live lab A: bin/fm-startup-network.sh start --locked 0 --harvest-pid 999999999 with a slow failing gh, harvest --pid 999999999 mid-flight, completion, then report --generation, bin/fm-guard.sh, bin/fm-wake-drain.sh, --ack-through 1 --recovery-generation …, recover, prune, second drain
  • Live lab B: slow silent-success gh, mid-flight harvest, completion, report, bin/fm-guard.sh
  • Live lab C: seeded settled/queued/incomplete/symlink/foreign result directories plus a queued startup wake row, then bin/fm-startup-network.sh prune twice and report --generation 1200.1.1
  • Live lab D: seeded 70 incomplete newer completions plus 3 older settled ones, then three bin/fm-startup-network.sh prune passes
  • Teardown: both fm-lab-home.sh lab homes removed with rm -rf, no fm-startup-network/fm-watch/gh fixture processes left, git status --short clean
⚠️ **Document** - 1 info
  • ℹ️ bin/fm-supervision-lib.sh:38 - The supervision-need source inventory is still restated outside its owner: the authoritative list in bin/fm-supervision-lib.sh's header is repeated in docs/turnend-guard.md (invariant bullet and 'Supervision need' list) and in two docs/architecture.md sentences, so this branch's new startup-work input had to be added to all of them. A follow-up could reduce the guard and architecture mentions to a pointer at the owner so future inputs cannot drift between copies; it is out of scope for this phase because it restructures operator and maintainer-architecture prose beyond this change.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Issues

Closes #5378

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio for picking up #5378. Delivering a completed startup result exactly once without waiting for another startup is a real gap. I read head 89220fff against main 3847411b (0 behind).

What I checked:

  • Completed generations are written status-last under state/.startup-network-results/<gen>, and the shared read-side state now lives in bin/fm-startup-network-lib.sh.
  • Wake appends record a per-generation receipt under state/.startup-network-wake-receipts/, and fm-wake-drain.sh commits receipts on ack.
  • Each fm-watch.sh cycle now runs fm-startup-network.sh recover (capped at 5s) when an unsettled completed generation exists. fm-supervision-lib.sh also counts pending startup work or unhandled startup rows as "supervision needed".
  • No .github, credential or new network paths, and I have no security concerns. The attestation matches this head. CI is green except serial 2, which hit the known 30-minute cancel (fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255), and I reran it (run 39634546264).

Contract-class (mine): new-default. On main, a retained completion waits for a later startup, which #5528 chose on purpose. With this tip, the default watcher cycle runs a new recovery step, and the default supervision status gains a new "needed" reason. Those are new default-on behaviors, not a repair of an already-specified path. So this goes to Kun as merge-or-leave, not auto-merge.

How this relates to #6889: #6889 (also yours) is a standing captain hold. It touches the same bin/fm-startup-network.sh retention and delivery path, and its body leaves "eventual delivery without another startup and deduplication" to #5378. This PR is that #5378 work, but it's built on main rather than on #6889, and the two conflict textually (docs/configuration.md, tests/fm-startup-network.test.sh). They also retain results in two different ways: #6889 holds pending reports for a later startup, and this one recovers them from the watcher. So Kun should decide on them together, and I'll put them in front of him as a pair.

VISION.md, rule by rule

  • One captain, one interface: aligns (an actionable wake arrives once, sooner).
  • Authority is explicit and never inferred: aligns.
  • Scripts own the mechanics, agents own the judgment: aligns.
  • A restart is a non-event: aligns. The result stays durable, and the obligation is retired by its ack record.
  • Delegation with a spine: cannot tell yet. See the second ask below.
  • The fleet outlives any vendor: aligns.
  • Scope: Kun's call, together with fix: retain and retry deferred startup network results #6889.

Two warm asks (waiting on you):

  1. Could you say how you mean this to land next to fix: retain and retry deferred startup network results #6889? Should it stack after fix: retain and retry deferred startup network results #6889, replace it, or land on its own if fix: retain and retry deferred startup network results #6889 is left? If one supersedes the other, a line in each body would help Kun.
  2. All three "live" rows point at the fixture suites. When you have a moment, could you drive it in a real home? Hold the publication or wake lock past the worker's budget, release it without starting a new session, and show the running watcher delivering the wake once and the receipt clearing on ack. Please post that trace here, or re-raise through git push no-mistakes with it. We won't run our own live test.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Live-home validation of the held-lock recovery (maintainer ask)

The remaining ask was to drive the deferred startup network recovery in a real home: hold the publication or wake lock past the worker's budget, release it WITHOUT starting a new session, and show the running watcher delivering the wake once and the receipt clearing on ack. The three prior "live" rows pointed at fixture suites; this run used bin/fm-live-lab.sh and nothing else - a real lab main home, real tmux, a real Claude primary, a real gated worker keeping the fleet live, and the real stop-hook-armed bin/fm-watch.sh doing every delivery. Head under test: 89220fff. No product defect surfaced; no code change on this branch beyond what is already here.

Environment fidelity

  • bin/fm-live-lab.sh up --harness claude --worker built the disposable home at /tmp/fmlab.FLPJdE from this branch's tree (89220fff), verified by the lab's own readiness checks: ok primary, ok probe (the model answered the probe turn), ok trust, ok mirror, ok host: supervision host pid 92806, ok watcher: live watcher with a fresh beacon (pid 331519, bash /tmp/fmlab.FLPJdE/home/bin/fm-watch.sh), ok worker: lab444c1f165b7a-worker parked on .../gate.
  • The home's real bin/fm-session-start.sh ran normally: its own deferred stage completed clean (state=done generation=1793428978.56160.43731 phases=probe,sweeps, (silent - no problems found)).
  • Every scenario call below ran from the lab home's own bin/ with FM_HOME at the lab home. The session lock was owned by the primary (pid 39547) for the whole scenario and its owner line was byte-unchanged after recovery: no new session was started for any part of it.

Scenario (controlled run)

Staged with start --locked 0 --harvest-pid 4194303 (verifiably dead harvest pid: the crashed-session-start stand-in) under FM_STARTUP_NETWORK_TIMEOUT=8, while a disposable holder seized state/.startup-network.lock through the production lock helper before the detached worker's first acquire.

  1. Worker budget held past, completion retained unpublished. Worker pid 2918097; retained record state/.startup-network-results/1793430004.2917895.4194303/status:

    state=failed  rc=124  started=1793430004  finished=1793430012
    

    (the full 8-second aggregate budget spent against the held lock) and the retained report:

    NETWORK_CHECKS: the deferred check worker gave up because .../state/.startup-network.lock was still held by pid 2917891 at its deadline, so GitHub authentication may be incomplete; rerun .../bin/fm-startup-network.sh run --locked 0 once that lock is released
    
  2. Under the hold, nothing delivered and supervision stayed engaged:

    • fm-startup-network.sh report printed NETWORK_CHECKS: completed findings retained pending publication or delivery.
    • the watcher (pid 331519) was alive and polling throughout (state/.last-watcher-beat advancing every cycle; sampled across the hold window);
    • the same bounded recover --generation <gen> the watcher runs returned rc=124 (refused) while the lock was held, leaving the result retained;
    • fm_startup_supervision_pending returned 0 (pending contract active);
    • state/.wake-queue had exactly 0 rows for this generation and .startup-network-wake-receipts/ had no receipt for it.
  3. Released at 00:00:31 by kill -TERM of the holder (the holder releases via fm_lock_release; the lock directory disappeared; no session was started). The operator then performed no recover/harvest/start call at all.

  4. Running watcher delivered the wake exactly once. At 00:00:41 (the watcher's next 15s cycle), watcher pid 331519's own recover child published the retained completion and enqueued the durable wake:

    1793430041  7  check  startup-network:1793430004.2917895.4194303  check: startup-network: deferred startup network checks finished (failed); read them with .../fm-startup-network.sh report --generation 1793430004.2917895.4194303
    

    with .startup-network-wake-receipts/1793430004.2917895.4194303 written, the dead claim record removed, no .startup-network.delivered marker (wake path, not inline), and the shared status promoted to state=failed rc=124 report_published=1. Over the next 60 seconds (four more watcher polls, watcher alive throughout) the row count for the generation stayed exactly 1: the receipt suppressed producer replay.

    An earlier uncontrolled release of the same scenario (harness shell timeout killed the holder) delivered identically through the same watcher: row seq 6 for generation 1793429763.2468488.4194303 - two independent contention episodes, two watcher-driven single deliveries.

  5. Ack through the real consumption path. bin/fm-wake-drain.sh (no args) presented both rows and emitted:

    WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 7 --recovery-generation 2834298.1793429943.vyzrXE
    

    Running that exact command returned 0 and cleared the rows from the durable queue (state/.wake-queue gone):

    • row count for the scenario generation after ack: 0; queue empty across a further 40s of watcher polls - no redelivery;
    • fm_startup_result_settled <state> <gen> returns 0, so the watcher's per-poll recover now short-circuits and stops;
    • the completion stays durable and readable: fm-startup-network.sh report --generation <gen> still prints the finished result with its rerun guidance.

One precision note on the ask's wording: in this design the queue row clears on ack, while the receipt - written by the watcher under the queue lock at enqueue, and committed for the consumer's own rows at ack through fm_wake_commit_startup_receipts_through - persists afterward as the replay guard. That persistence is what makes delivery exactly-once across watcher polls and keeps an acked generation permanently settled; "cleared on ack" is observable on the row and the pending-delivery obligation, not on the receipt file itself.

Full transcript

Driver phases ran as separate commands (pre-flight wait for the real stage to settle, stage, hold evidence, release + monitor, drain + ack); complete timestamped output attached. Full transcript:


[2026-10-30@23:51:21] === PREFLIGHT: wait for the home's real session-start deferred stage to settle
[2026-10-30@23:51:21]     real session-start stage record: state=done generation=1793428978.56160.43731 phases=probe,sweeps

[2026-10-30@23:51:21] === watcher premise (real supervision cycle, armed by the home's stop hook)
[2026-10-30@23:51:21]     watcher pid=331519 alive=yes beacon=2026-10-30 23:51:16.780439684
331519 bash /tmp/fmlab.FLPJdE/home/bin/fm-watch.sh

[2026-10-30@23:51:21] === home session lock owner (must stay unchanged through the scenario)
session lock line-1=39547
  39547 Fri Oct 30 23:42:51 2026 claude --setting-sources project,local --model sonnet --effort medium --permission-mode auto

[2026-10-30@23:51:21] === state baseline
[2026-10-30@23:51:21]     $ env FM_HOME=/tmp/fmlab.FLPJdE/home bash /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh report
completed off the startup path in 3s: GitHub authentication, dead-secondmate relaunch, secondmate convergence, pending handoff delivery, project clone refresh with its drift reporting, and inactive terminal-outcome reconciliation.
(silent - no problems found)
TIMINGS - where the deferred network checks spent their time (ms):
  phase       gh-auth                                    start=+335     elapsed=830
  phase       secondmate-liveness                        start=+1172    elapsed=5
  phase       secondmate-sync                            start=+1180    elapsed=34
  phase       handoff-delivery                           start=+1220    elapsed=1
  clone       sync notes                                 start=+2309    elapsed=15
  phase       fleet-sync                                 start=+1171    elapsed=2020
  stage       network-checks probe_sweeps                start=+40      elapsed=3174
  slowest: stage network-checks probe_sweeps 3174ms, phase fleet-sync 2020ms, phase gh-auth 830ms
[2026-10-30@23:51:21]     -> rc=0 (report before staging)

[2026-10-30@23:51:21] === queue baseline
(no wake-queue)
total 12
drwx------ 3 art users 4096 Oct 30 23:43 .
drwxr-xr-x 8 art users 4096 Oct 30 23:51 ..
drwx------ 2 art users 4096 Oct 30 23:43 1793428978.56160.43731
(no receipts dir)
(no publish lock dir)
[2026-10-31@00:00:04]     harvest-claim pid is 4194303 (verifiably dead): a crashed session-start stand-in

[2026-10-31@00:00:04] === STAGE attempt 1: clear any stale worker, arm the pre-warmed holder on the claim gate, start --locked 0 (worker budget 8s, publish bound 8s)
[2026-10-31@00:00:04]     $ env FM_STARTUP_NETWORK_TIMEOUT=8 FM_SESSION_START_TIMEOUT=8 FM_HOME=/tmp/fmlab.FLPJdE/home bash /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh start --locked 0 --harvest-pid 4194303
[2026-10-31@00:00:04]     -> rc=0 (start --locked 0 --harvest-pid 4194303)
[2026-10-31@00:00:04]     new generation=1793430004.2917895.4194303 worker pid=2918097 (shared status state=running); holder is gated on the claim write and races onto the publication lock

[2026-10-31@00:00:13] === STAGED: the worker's 8s budget was spent against the publication lock held by pid 2917891 (retained, unpublished)
[stage]     GEN=1793430004.2917895.4194303
[stage]     WORKER_PID=2918097
[stage]     HOLDER_PID=2917891
[stage]     DEADPID=4194303
[stage]     STAGE_STARTED=1793430004
[stage]     STAGE_FINISHED=1793430012

[2026-10-31@00:00:13] === retained completion record
[stage]     state=failed
[stage]     phases=probe
[stage]     locked=0
[stage]     started=1793430004
[stage]     rc=124
[stage]     generation=1793430004.2917895.4194303
[stage]     finished=1793430012
[stage]     report_published=1
[stage]     claim_deadline=1793430020

[2026-10-31@00:00:13] === retained report (the contention line names the held lock and holder pid)
[stage]     1:NETWORK_CHECKS: the deferred check worker gave up because /tmp/fmlab.FLPJdE/home/state/.startup-network.lock was still held by pid 2917891 at its deadline, so GitHub authentication may be incomplete; rerun /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh run --locked 0 once that lock is released

[2026-10-31@00:00:17] === HOLD EVIDENCE: worker budget spent, completion retained unpublished, publication lock held by pid 2917891
[2026-10-31@00:00:17]     $ cat /tmp/fmlab.FLPJdE/home/state/.startup-network.status
state=running
pid=2918097
started=1793430004
locked=0
phases=probe
generation=1793430004.2917895.4194303
lock_pid=39547
[2026-10-31@00:00:17]     -> rc=0 (shared status)
[2026-10-31@00:00:17]     $ cat /tmp/fmlab.FLPJdE/home/state/.startup-network-results/1793430004.2917895.4194303/status
state=failed
phases=probe
locked=0
started=1793430004
rc=124
generation=1793430004.2917895.4194303
finished=1793430012
report_published=1
claim_deadline=1793430020
[2026-10-31@00:00:17]     -> rc=0 (retained status)
[2026-10-31@00:00:17]     $ cat /tmp/fmlab.FLPJdE/home/state/.startup-network-results/1793430004.2917895.4194303/report
NETWORK_CHECKS: the deferred check worker gave up because /tmp/fmlab.FLPJdE/home/state/.startup-network.lock was still held by pid 2917891 at its deadline, so GitHub authentication may be incomplete; rerun /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh run --locked 0 once that lock is released
[2026-10-31@00:00:17]     -> rc=0 (retained report)
[2026-10-31@00:00:17]     $ env FM_HOME=/tmp/fmlab.FLPJdE/home bash /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh report
NETWORK_CHECKS: completed findings retained pending publication or delivery.
completed off the startup path in 8s: GitHub authentication.
The stage itself did not finish cleanly (failed) - the NETWORK_CHECKS line below names what to rerun.
NETWORK_CHECKS: the deferred check worker gave up because /tmp/fmlab.FLPJdE/home/state/.startup-network.lock was still held by pid 2917891 at its deadline, so GitHub authentication may be incomplete; rerun /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh run --locked 0 once that lock is released
These ran AFTER the sections above were composed, so re-read any record a line here names.
[2026-10-31@00:00:17]     -> rc=0 (report (retained pending publication))
[2026-10-31@00:00:17]     $ cat /tmp/fmlab.FLPJdE/home/state/.startup-network.claim
1793430004.2917895.4194303	4194303
[2026-10-31@00:00:17]     -> rc=0 (claim record (dead harvest pid))

[2026-10-31@00:00:17] === deliver marker (expect none)
(no delivered marker)

[2026-10-31@00:00:17] === watcher is alive and polling: pid=331519 alive=yes beacon=2026-10-31 00:00:05.002387630

[2026-10-31@00:00:17] === queue has no row for the staged generation yet
1793429943\t6\tcheck\tstartup-network:1793429763.2468488.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793429763.2468488.4194303$
[2026-10-31@00:00:17]     row count for startup-network:1793430004.2917895.4194303 = 0

[2026-10-31@00:00:17] === no receipt yet
total 12
drwx------  2 art users 4096 Oct 30 23:59 .
drwxr-xr-x 10 art users 4096 Oct 31 00:00 ..
-rw-------  1 art users   27 Oct 30 23:59 1793429763.2468488.4194303

[2026-10-31@00:00:17] === supervision pending contract
[2026-10-31@00:00:17]     $ lib fm_startup_supervision_pending "$STATE"
[2026-10-31@00:00:17]     -> rc=0 (fm_startup_supervision_pending)

[2026-10-31@00:00:17] === the same bounded recover the watcher runs is refused while the lock is held (operator call, bounded 2s; last operator recover before release)
[2026-10-31@00:00:17]     $ env FM_HOME=/tmp/fmlab.FLPJdE/home bash /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh recover --generation 1793430004.2917895.4194303 2
[2026-10-31@00:00:19]     -> rc=124 (recover under contention)
[2026-10-31@00:00:19]     publish lock dir now:
lrwxrwxrwx 1 art users 63 Oct 31 00:00 /tmp/fmlab.FLPJdE/home/state/.startup-network.lock -> /tmp/fmlab.FLPJdE/home/state/.startup-network.lock.owner.gf69tF

[2026-10-31@00:00:19] === timing proof
[2026-10-31@00:00:19]     worker pid=2918097 dead=yes; holder pid=2917891 alive=yes
[hold]     2917891 Sat Oct 31 00:00:04 2026       00:14 bash /tmp/opencode/5378-live-lab/holder.sh /tmp/fmlab.FLPJdE/home/state/.startup-network.lock 240 /tmp/fmlab.FLPJdE/home/state/.startup-network.claim

[2026-10-31@00:00:19] === session lock owner unchanged
session lock line-1=39547
  39547 Fri Oct 30 23:42:51 2026 claude --setting-sources project,local --model sonnet --effort medium --permission-mode auto

[2026-10-31@00:00:31] === RELEASE: kill the holder (no new session is started for any part of the recovery)
session lock line-1=39547
  39547 Fri Oct 30 23:42:51 2026 claude --setting-sources project,local --model sonnet --effort medium --permission-mode auto
[2026-10-31@00:00:31]     $ kill -TERM 2917891
[2026-10-31@00:00:31]     -> rc=0 (kill holder)
(no publish lock dir)
[2026-10-31@00:00:31]     $ bash -c ! kill -0 2917891 2>/dev/null
[2026-10-31@00:00:31]     -> rc=0 (holder gone)

[2026-10-31@00:00:31] === WATCHER DELIVERY MONITOR (operator performs no recover/harvest from here on)

[2026-10-31@00:00:41] === WAKE DELIVERED by the running watcher

[2026-10-31@00:00:41] === queue now
1793429943\t6\tcheck\tstartup-network:1793429763.2468488.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793429763.2468488.4194303$
1793430041\t7\tcheck\tstartup-network:1793430004.2917895.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793430004.2917895.4194303$
[2026-10-31@00:00:41]     row count for startup-network:1793430004.2917895.4194303 = 1

[2026-10-31@00:00:41] === receipt
total 16
drwx------ 2 art users 4096 Oct 31 00:00 .
drwxr-xr-x 9 art users 4096 Oct 31 00:00 ..
-rw------- 1 art users   27 Oct 30 23:59 1793429763.2468488.4194303
-rw------- 1 art users   27 Oct 31 00:00 1793430004.2917895.4194303

[2026-10-31@00:00:41] === claim removed
(claim file removed)

[2026-10-31@00:00:41] === no inline delivered marker (wake path, not inline)
(no delivered marker)

[2026-10-31@00:00:41] === shared status now
state=failed
pid=2984216
started=1793430004
finished=1793430041
rc=124
locked=0
phases=probe
generation=1793430004.2917895.4194303
lock_pid=39547
report_published=1
[2026-10-31@00:00:41]     delivery beacon at discovery: 2026-10-31 00:00:41.006094986

[2026-10-31@00:00:41] === EXACTLY-ONCE OBSERVATION: 60s of ordinary watcher polls after delivery
[2026-10-31@00:01:41]     watcher pid=331519 alive=yes beacon=2026-10-31 00:01:27.566716506
[2026-10-31@00:01:41]     row count for startup-network:1793430004.2917895.4194303 = 1 (must be exactly 1)
receipt file present (suppresses producer replay)
1793429943\t6\tcheck\tstartup-network:1793429763.2468488.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793429763.2468488.4194303$
1793430041\t7\tcheck\tstartup-network:1793430004.2917895.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793430004.2917895.4194303$

[2026-10-31@00:01:52] === PRESENT: main actor drains the durable wake queue (bin/fm-wake-drain.sh, no args)
[2026-10-31@00:01:52]     $ env FM_HOME=/tmp/fmlab.FLPJdE/home bash -c bash "$1/fm-wake-drain.sh" > "/tmp/opencode/5378-live-lab/drain.out" 2>&1; rc=$?; cat "/tmp/opencode/5378-live-lab/drain.out"; exit $rc _ /tmp/fmlab.FLPJdE/home/bin
1793429943	6	check	startup-network:1793429763.2468488.4194303	check: startup-network: deferred startup network checks finished (failed); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh report --generation 1793429763.2468488.4194303
1793430041	7	check	startup-network:1793430004.2917895.4194303	check: startup-network: deferred startup network checks finished (failed); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh report --generation 1793430004.2917895.4194303
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 7 --recovery-generation 2834298.1793429943.vyzrXE
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
[2026-10-31@00:01:54]     -> rc=0 (drain)

[2026-10-31@00:01:54] === QUEUE ROW BEFORE ACK
1793429943\t6\tcheck\tstartup-network:1793429763.2468488.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793429763.2468488.4194303$
1793430041\t7\tcheck\tstartup-network:1793430004.2917895.4194303\tche\
ck: startup-network: deferred startup network checks finished (failed\
); read them with /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh re\
port --generation 1793430004.2917895.4194303$

[2026-10-31@00:01:54] === ACK: run the exact generation-bound acknowledgement the drain emitted
[2026-10-31@00:01:54]     acknowledging: fm-wake-drain.sh --ack-through 7 --recovery-generation 2834298.1793429943.vyzrXE
[2026-10-31@00:01:54]     $ env FM_HOME=/tmp/fmlab.FLPJdE/home bash /tmp/fmlab.FLPJdE/home/bin/fm-wake-drain.sh --ack-through 7 --recovery-generation 2834298.1793429943.vyzrXE
[2026-10-31@00:01:54]     -> rc=0 (ack through)

[2026-10-31@00:01:54] === AFTER ACK: the row clears on ack; the receipt stands as the replay guard; the completion is settled
[2026-10-31@00:01:54]     row count for startup-network:1793430004.2917895.4194303 = 0 (must be 0)
(no wake-queue)

[2026-10-31@00:01:54] === receipt persists
total 16
drwx------ 2 art users 4096 Oct 31 00:00 .
drwxr-xr-x 9 art users 4096 Oct 31 00:01 ..
-rw------- 1 art users   27 Oct 30 23:59 1793429763.2468488.4194303
-rw------- 1 art users   27 Oct 31 00:00 1793430004.2917895.4194303
[2026-10-31@00:01:54]     $ lib fm_startup_result_settled "$STATE" "1793430004.2917895.4194303"
[2026-10-31@00:01:54]     -> rc=0 (completion settled (watcher stops recovering))
[2026-10-31@00:01:54]     $ env FM_HOME=/tmp/fmlab.FLPJdE/home bash /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh report --generation 1793430004.2917895.4194303
completed off the startup path in 8s: GitHub authentication.
The stage itself did not finish cleanly (failed) - the NETWORK_CHECKS line below names what to rerun.
NETWORK_CHECKS: the deferred check worker gave up because /tmp/fmlab.FLPJdE/home/state/.startup-network.lock was still held by pid 2917891 at its deadline, so GitHub authentication may be incomplete; rerun /tmp/fmlab.FLPJdE/home/bin/fm-startup-network.sh run --locked 0 once that lock is released
These ran AFTER the sections above were composed, so re-read any record a line here names.
[2026-10-31@00:01:55]     -> rc=0 (report still readable)

[2026-10-31@00:01:55] === NO REDIVERY: 40s of watcher polls after ack
[2026-10-31@00:02:35]     row count = 0; watcher pid=331519 alive=yes
(no wake-queue)

[2026-10-31@00:02:35] === session lock owner unchanged (no session was started during recovery)
session lock line-1=39547
  39547 Fri Oct 30 23:42:51 2026 claude --setting-sources project,local --model sonnet --effort medium --permission-mode auto

Out of scope observations (not defects in this change)

  • fm-live-lab.sh up --worker reports fail treehouse: new ~/.treehouse entries: notes-3d7028 even though TREEHOUSE_ROOT points into the lab root: the worker worktree pool resolves to ~/.treehouse/notes-3d7028. Pre-existing behavior shared by other labs' runs on this host (several older pools are present), unrelated to Bug: startup-network wakes can be delayed or duplicated after lock contention #5378; this run's pool was removed after teardown, the lab warned rather than touching it by design.
  • The first up attempt reached "not ready" only because the Claude harness hit its host-side usage limit mid-probe; the retry after the window passed everything above. Host condition, not repo behavior.
  • During staging, a --locked 0 request correctly reused a still-running probe worker via single-flight (worker_covers_request), matching the header contract; the driver cleared stale workers between scenario attempts rather than working around it.

Status

Re-raised through no-mistakes (push to the gate remote at unchanged head 89220fff; daemon runs shows running fix/5378-startup-network-wake-receipt 89220fff 2026-10-31 00:05). No commits changed; the maintainer's live-home ask is now covered by a real-home trace rather than a fixture suite.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio for the real-home trace. It covers the live ask I made on 10-21. In a real lab home with the real watcher, you held the publication lock past the worker's 8s budget, and the completion stayed on disk without being published. After the lock was released, with no new session and no operator recover, the running watcher enqueued exactly one row for that generation. The row count stayed at 1 across later polls, the ack cleared the row, and fm_startup_result_settled stopped the per-poll recover. Thanks also for the note on the receipt: it stays after the ack as the replay guard, and only the row and the delivery obligation clear. That reads right to me.

Closes #5378 is right. This is the eventual, deduplicated delivery that issue tracks, with a receipt for each generation and recovery through the ordinary watcher. Contract-class (my own read): new-default, unchanged: the default watcher cycle gains a recovery step and supervision gains a new "needed" reason.

This is waiting on you for one thing: how this lands next to #6889 (my ask 1 from 10-21). #6889 is your other PR on the same retention path and still has a standing captain hold. Its body leaves "eventual delivery without another startup and deduplication" to #5378, which is this PR. Should this one stack after #6889, replace it, or land on its own if #6889 is left? One sentence in each body is enough, and then I'll put the two in front of Kun as a pair.

The CONFLICTING state is ours to fix on a merge word, so please don't rebase for us. The Behavior portable serial 2 row is the known 30-minute cancel, not your code. A fresh run follows the conflict fix.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Behavior portable serial 2 is the 30-minute job cap, and it reproduces on the merge-base

No action requested — this corroborates the triage note above, and adds one thing worth knowing before any rerun.

Both attempts on 89220fff were cancelled by the workflow's timeout-minutes: 30, not by a test:

attempt job window result
1 119341409963 16:24:57 → 16:55:15 (30m18s) cancelled
2 119402976713 18:26:45 → 18:57:04 (30m19s) cancelled

Attempt 1 is decisive: tests/fm-supervision-host.test.sh passed — FM_TEST_END ... exit=0 duration_ms=1692096 — consuming 28.2 of the 30 minutes. The shard had already started a sixth script when the cap hit, and its five finished members summed to 29.7 minutes. Attempt 2 ran the same file first, printed 75 ok and zero not ok, and the cap hit after its final test.

The cause is the packer's hint, not the suite. At this head bin/fm-test-run.sh carries tests/fm-supervision-host.test.sh 789123 against a measured 1,692,096 ms (2.14x under), with PORTABLE_SERIAL_SHARDS=9 and PORTABLE_SERIAL_MAX_WEIGHT_MS=1200000, so no packing keeps that shard inside the 30-minute tier.

Base comparison. On the merge-base 3847411b — which contains none of this PR's changes — run 39618934309 cancelled the same shard at the same cap: Behavior portable serial 2, 15:10:47 → 15:41:11 (30m24s), after starting tests/fm-supervision-host.test.sh at 15:11:07 and never finishing it. Its timing artifact is the only one of that run's nine lane artifacts that is missing. Head and base fail identically, at the same shard and the same file, so the diff is not the cause; the one product file it shares with the host loop, bin/fm-supervision-lib.sh, only adds a block that runs when startup-network evidence already exists, and the fixture homes here have none.

Current main already fixed this class: e92eaf01 (2026-10-26) split the supervision-host suite into four serial members, and docs/fm-test-portable-shards.md records the single file overrunning the 30-minute cap in run 39765114423. A rerun of this exact head will time out again for the same reason; a run after the conflict fix inherits the split and should be clean.

For the record, this is not the fm_lock_acquire_wait_bounded deadline race: no lock-wait deadline appears anywhere in these logs.

@kesslerio
kesslerio force-pushed the fix/5378-startup-network-wake-receipt branch from 89220ff to d513b2f Compare November 2, 2026 22:40
@kesslerio kesslerio changed the title fix: reliably deliver deferred startup network results fix(startup): retain and receipt deferred network check results through recovery Nov 2, 2026
@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable defects remain.

Reviews (4) · Last reviewed commit: "no-mistakes(document): Align docs with s..." · Reviewed by Greptile

Comment thread bin/fm-startup-network.sh Resolved
@kesslerio

Copy link
Copy Markdown
Contributor Author

Re-raised on current main at head d513b2f4; the CONFLICTING state is gone (mergeable: true).

Rebase. All four commits replayed onto 9224c902. The only conflict was tests/fm-wake-queue.test.sh, where main's test_branch_grant_requires_lock_acquisition invocation and this branch's startup receipt block landed at the same point; both are kept. Patch equivalence against 89220fff is exact: the removed-line set is byte-identical, and the added-line set is identical plus one blank separator. No commits dropped, no scope change. This head now inherits main's e92eaf01 split of fm-supervision-host.test.sh, which is what removed the 30-minute-cap cancellation of Behavior portable serial 2.

Your ask 1 (#6889) is answered in the body: this lands on its own, carrying the eventual-delivery and deduplication layer that #6889's body leaves to #5378. It neither stacks on nor replaces #6889.

Checks on this head. Full suite fails as expected for an outside fork - FM_CI_FULL is false, no lane failed or was cancelled, and the job only ran its go-ahead step. Greptile Review fails on its P2 about unbounded retention of settled .startup-network-results generations; that is a real limitation of this design and I am leaving it as follow-up rather than widening scope on a rebase-only re-raise. Both were approved explicitly at the gate with that reasoning, so the pipeline ended passed-with-override rather than a clean pass.

Local evidence on the rebased head: fm-startup-network, fm-wake-queue, fm-claude-stop-autoarm, fm-cursor-primary, fm-turnend-guard, fm-supervision-host, fm-supervision-host-drain and fm-watch-arm all exit 0; bin/fm-lint.sh exits 0 with ShellCheck 0.11.0 and actionlint 1.7.12.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio for the clean re-raise and the clear answer on #6889. Landing this on its own, as the eventual-delivery and dedup layer #6889 leaves to #5378, is clear, and I'll present it to Kun that way. Thanks also for the serial-2 analysis. It matches what we see.

At head d513b2f4 against main 60f95dfa: it merges cleanly, the attestation binds this head with every step completed, the quick checks pass, and the live table is 11/12 (the 12th is the structural rebase check). Closes #5378 is right. The red Full suite row is our label gate, not your code. Contract-class: new-default (unchanged). The default watcher cycle gains a recovery step, and supervision gains a new "needed" reason.

Waiting on you for one thing: the Greptile P2 on bin/fm-startup-network.sh ("Old reports accumulate forever"). I'd like this fixed in this PR rather than left as a follow-up. On main, startup results live in a fixed set of shared files. This PR's per-generation directories are new, and nothing ever removes them, so every startup on every home leaves one behind for good. That growth is new with this change, and since this is default-on it would reach every captain. A small bounded prune is enough, for example dropping settled or superseded generations except the newest, and never removing one that still has an unreceipted or queued wake. Add a test that pins the "never prune a generation a queued wake still references" case. Please reply on or resolve the thread when it's done.

After that, this goes to Kun as a pair with #6889. Nothing else is needed from you.

VISION: One captain aligns (deduplicated, eventual delivery, no double wake). Authority aligns. Scripts own the mechanics aligns. Restart is a non-event aligns (this is the durability fix #5378 asks for). Delegation with a spine aligns (live evidence at head). Vendor aligns. Scope: Kun's call together with #6889.

@kesslerio kesslerio changed the title fix(startup): retain and receipt deferred network check results through recovery fix(bin): retain and deliver deferred startup network completions Nov 2, 2026
Comment thread bin/fm-startup-network.sh Resolved
@kesslerio
kesslerio force-pushed the fix/5378-startup-network-wake-receipt branch from a57179f to 1ac4359 Compare November 3, 2026 00:37
@kesslerio kesslerio changed the title fix(bin): retain and deliver deferred startup network completions fix(bin): retain startup network results until generation-scoped wake delivery Nov 3, 2026
@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 3, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio, the retention pass is exactly what I hoped for, and moving it off the session-start path after Greptile's second note was the right call. At 1ac43595 the pass never removes the current generation, a queued generation or the newest three. It is bounded, it doesn't follow symlinks, and your 12 live scenarios show each of those. The attestation binds this head with every step completed, Greptile is 5/5 with every thread resolved, and on a merge with main tests/fm-startup-network.test.sh passes locally (35 ok, 0 not ok). Contract-class: new-default (unchanged). I've started the full suite. If it's green, this goes to Kun together with #6889 as a merge decision, so from there it's waiting on Kun, not you. Nothing more is needed from you.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio, the full suite is green on 1ac43595 (all 22 jobs). Every gate holds on this head. The attestation binds it with every step completed, the 12 live retention scenarios plus the earlier delivery table cover it, Greptile is 5/5 with every thread resolved, and it merges cleanly with main. Contract-class: new-default. The default watcher cycle gains a startup-network recovery step, and supervision-needed gains a startup reason. So this is now waiting on Kun, not you, as a merge-or-leave decision presented together with #6889. Nothing more is needed from you.

Rockets: none (on this PR, #5378 or #6889).

@kesslerio

Copy link
Copy Markdown
Contributor Author

Friendly queue ping @kunchenguid — portfolio state as of Nov 9, all author-side work landed:

If a bulk full-ci label pass on the clean batch is easier than serial sweeps, all of them are ready for it. Happy to sequence however suits you.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for the ping @kesslerio. Nothing has changed on your side. This is still waiting on Kun's decision, not on you.

On the red Full suite row: it comes from the Nov 3 synchronize run (41554153508), which ran before the full-ci label, so only the label gate ran. The labelled run on this same head (41572827229) passed all 22 jobs. Nothing failed in your code.

Contract-class: new-default, unchanged. It goes to Kun as a merge-or-leave decision together with #6889. The green full run is from Nov 3 and main has moved 56 commits since. So on a merge word we'll run a fresh full suite first, and the 30-minute serial-2 fix is already in main. The bulk full-ci request is noted. Labelling is paced on our side, and main's own CI is red right now on an unrelated upstream Pi change (#8325), so new full runs wait for that fix first.

Every session start reserves a generation and retains its completion under
state/.startup-network-results/<generation>/, and the wake receipt adds a second
per-generation file, so a long-lived home kept one report directory per start
forever - unlike the fixed set of shared files this state replaced.

prune_results() now runs under the publication lock when a generation is
reserved and when one settles. A generation survives while anything can still
act on it: the current shared-status generation, a generation named by a queued
startup-network wake row, and the newest RESULT_KEEP_UNSETTLED unsettled
generations, which is the grace window for a run that died before settling.
Everything else is settled or fenced by a successor, so its directory and wake
receipt are removed. Malformed, incomplete, and symlinked entries are declined
rather than followed or deleted.

The same pass is exposed as `prune` for an operator and for the tests.
cmd_start ran the retention scan while holding the publication lock, before
launching the worker, so every session start paid for a scan of whatever the
home had accumulated - and each entry cost several reads plus its own awk over
the whole wake queue.

The detached worker now owns the pass, running it under the same publication
lock once it has made or verified the reservation, so the digest that launches
the stage never waits for it. One pass reads the queued generation keys once
instead of once per entry, and examines at most RESULT_PRUNE_MAX entries, so a
home that keeps accumulating exceptions cannot turn cleanup into its own
startup tax; leftovers are picked up by the next pass.
@kesslerio
kesslerio force-pushed the fix/5378-startup-network-wake-receipt branch from 1ac4359 to 8adb8e6 Compare November 14, 2026 22:40
@kesslerio kesslerio changed the title fix(bin): retain startup network results until generation-scoped wake delivery fix(bin): retain startup network completions and deliver them through recovery Nov 14, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio for re-raising on current main. I checked head 8adb8e6e against main 427056c4 (0 behind, merges cleanly).

What changed: the series is rebased onto 427056c4 with one new docs commit (8adb8e6e). It adds deferred startup work to the supervision-need lists in docs/architecture.md, docs/turnend-guard.md and docs/watcher-continuity.md, and says branch acknowledgement records the startup receipt, which matches the retention design. I read the full diff. It has no workflow, CI-config, credential or network changes.

Gates on this head:

  • The no-mistakes attestation binds 8adb8e6e, every step completed and none skipped.
  • The labelled full run 43649306697 passed all 22 jobs, Full suite included. That is the fresh full run I said we'd need before a merge word.
  • Greptile scores 5/5 on this head, and there are no unresolved threads. Closes #5378 is right.

Contract-class: new-default, unchanged. The default watcher cycle gains a recovery attempt for retained startup results without an opt-in. That makes this Kun's merge-or-leave decision, together with #6889. It is waiting on Kun's decision, not on you. Nothing more is needed from your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: startup-network wakes can be delayed or duplicated after lock contention

2 participants