Repository navigation
Description
Summary
The firstmate watcher (bin/fm-watch.sh) silently dies on Linux, stalling the liveness beacon and causing firstmate to miss all supervision wakes (signal, stale, check, heartbeat) — finished crewmates, blockers, and merge polls go unnoticed until a human pokes firstmate.
Root cause
fm-watch.sh and fm-guard.sh read file mtimes with a macOS-first fallback:
m=$(stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null)On Linux, stat -f means filesystem stat, not file stat. Worse, it writes a partial filesystem dump to stdout before failing:
$ stat -f %m state/.last-watcher-beat
stat: cannot read file system information for '%m': No such file or directory
File: "state/.last-watcher-beat"
ID: da98a548f32c5af5 Namelen: 255 Type: ext2/ext3
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 11786498 Free: 4446196 Available: 4442100
Inodes: Total: 6029376 Free: 5497462
Because the first command writes the dump to stdout, the || fallback's correct output (stat -c %Y, the epoch) gets appended to that garbage. The arithmetic then chokes on the stray token — e.g. the word File is read as an unset variable — and set -u aborts the script.
This is why the || fallback pattern is fundamentally broken here, not a simple bug: the primary command succeeds-enough-to-pollute-stdout, so the fallback both runs and is too late.
Repro
Run the watcher on Linux and watch it die on the first cycle that touches a file mtime:
bin/fm-watch.sh: line 50: File: unbound variable
bin/fm-watch.sh: line 99: [: : integer expression expected
bin/fm-watch.sh: line 122: ID: da98a548f32c5af5 Namelen: 255 Type: ext2/ext3: No such file or directory
state/.last-watcher-beat then freezes and fm-guard.sh (same stat -f bug, line 26) can't even warn correctly.
Impact
- The watcher exits mid-cycle instead of running its loop, so the beacon goes stale.
- Every supervision wake is missed:
done:/blocked:/needs-decision:status writes from crewmates, stale-pane detection, merge-poll checks, and heartbeats. - firstmate only notices when a human happens to send a message and trigger a state check. Observed in practice: three finished scout tasks sat unrelayed for ~2 hours.
- The buggy watcher also littered the repo root with junk files (
Blocks: Total…,Inodes:…) created from the stray stat output.
Fix
Detect the platform once (uname) and pick the correct stat form via helpers, instead of the broken try-fallback. macOS format %z:%Fm preserved unchanged so macOS behavior is untouched; only the Linux path changes.
bin/fm-watch.sh— addstat_mtime/stat_sighelpers; use them inage_ofandscan_signals.bin/fm-guard.sh— addstat_mtime; use it for the beacon age check.
Verified on Linux: the watcher now runs its loop cleanly (was crashing on the first cycle), the beacon stays fresh, and shellcheck bin/*.sh (CI-enforced) passes.
Branch: fix/watcher-linux-stat-portability. PR to follow via git push no-mistakes.
Activity
fix(bin): portable stat so watcher survives Linux (kunchenguid#28)
kboyd12 commentedon Aug 6, 2026
Retired on the captain's decision, 2026-08-06, following the board triage of that date.
This is one of four prior dashboard framings (#16, #21, #26, #19) that the approved 2026-08-05 design work supersedes. #350 names them as "prior framings of this page, to fold in or close", and the captain has chosen to close.
Specifically: #350 argues against keying a dashboard off role at all, since capabilities resolve as a union across held roles and role-keying would reintroduce what #203 removed — which contradicts #16's premise directly. The Stitch-template framing in #21 is superseded by the three 2026-08-05 design studies. #26 and #19 are absorbed by that cluster plus #217 and the Project Detail epics #177–#181.
Nothing here is lost: a closed issue stays readable, and the live successors are #350, #217, #328 and #177–#181. Reopen if a requirement here turns out to have no successor.
test: lock in kunchenguid#3285 shapes 1, 2, and 4 as executable proof (…
scrub public fork of captain-private PII and add CI leak-guard (kunch…
Close Company porting gaps: verify, machine-local warn, and manifest (k…
feat(bin): add opt-in meeting intake with call recorder and Anarlog s…