Repository navigation
fix(watcher): never surface orphaned .status/.turn-ended/.check.sh signals - #326
indrasantosa wants to merge 4 commits into
Conversation
…gnals fm-teardown.sh removes a task's .status, .turn-ended, .check.sh, and .meta together in one rm -f, so a live task always has a matching state/<id>.meta. scan_signals() and the check.sh sweep had no such check, so any marker file that outlives its .meta (e.g. a harness turn-end hook whose command line baked in the absolute state path before teardown ran, still firing if its process outlives teardown's best-effort backend kill) got surfaced as an actionable "signal:" wake forever, resetting the heartbeat backoff every cycle. Skip and best-effort remove any *.status/*.turn-ended/*.check.sh with no matching .meta before it ever reaches classification, so an orphan can never wake firstmate regardless of what keeps touching it. Several existing watcher tests created .status/.turn-ended fixtures with no .meta (harmless before this change, since nothing checked for one); updated them to add a .meta fixture so they keep exercising live-task behavior instead of accidentally becoming orphan-absorb cases.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6366ee95e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [ ! -e "$STATE/$task.meta" ]; then | ||
| triage_log "absorbed orphan signal (no state/$task.meta): $f" | ||
| rm -f "$f" 2>/dev/null || true | ||
| continue |
There was a problem hiding this comment.
Filter orphan statuses from the afk daemon scan
Captain, this guard only runs inside the child watcher’s signal scan. In away mode the supervising daemon still has its own housekeeping catch-all (bin/fm-supervise-daemon.sh's scan_captain_relevant_statuses loop) that scans every state/*.status without requiring matching .meta; an orphan ghost.status containing done: is still added to .subsuper-escalations as a catch-all scan if housekeeping sees it, so the promised “never surfaced, even under afk” behavior is not upheld. Please apply the same meta filter to the daemon catch-all path (or the shared scanner) before relying on this guarantee.
Useful? React with 👍 / 👎.
The no-mistakes push pipeline pushes commits and edits the PR description as separate steps, so a synchronize-triggered run can still see the pre-pipeline draft body via the frozen webhook event payload and fail even though the pipeline's marker lands moments later. Fetch the current body via `gh pr view` instead of trusting github.event.pull_request.body.
|
Superseded by #468 (rebased onto current main + extended to close the afk-daemon catch-all gap Codex flagged). |
…cally (captain-approved)
…ut waiting for the TTL (kunchenguid#326) * test(bin): pin that a changed fleet starts a status-bar refresh without waiting for the TTL * no-mistakes(review): Read frame clock after priming cache in fleet refresh test * no-mistakes(ci): Root cause: the check failed on 46ae35b, which already reads the frame clock after priming the cache, so the earlier mtime race is ruled out. The first assertion (known=1) passed, so the cached reading's signature and stamp were good. The refresh still started because fm_status_cache_read in bin/fm-status-cache-lib.sh rejects every cache on Linux. Its helper fm_status_file_mtime runs `stat -f %m "$1" || stat -c %Y "$1"`. GNU stat treats -f as filesystem mode and %m as a file name: it prints a filesystem dump for "$1", then exits nonzero. The fallback's epoch is appended after that dump inside the same $(...), so the value never parses. Every cached reading on Linux therefore looks stale, and every frame starts a refresh. The repo already warns about this pattern in bin/fm-supervise-daemon.sh. Invariant: a portable stat helper returns only the requested number, under both BSD and GNU stat. Sites: fm_status_file_mtime and fm_status_file_size in bin/fm-status-cache-lib.sh. Their consumers are fm_status_cache_read (fleet and Codex caches), the claim-stamp fallback in fm_status_claim_refresh, and fm-codex-session-metrics-lib.sh. Fix: both helpers now branch on `uname`, using `/usr/bin/stat -f` on Darwin and `stat -c` elsewhere. This is the same approach as fm-lock-lib.sh and fm-classify-lib.sh. A short comment explains why. No test changes. Verification: - Ran with a fake GNU-like stat and uname reporting Linux at the front of PATH. The original helper returned mtime=[] and size=[], and a just-written cache read as STALE. The fixed helper returned the correct mtime and size, and the cache read as fresh. - On macOS: tests/fm-fleet-status-lib.test.sh exits 0 with 23 ok, including "a changed fleet starts a refresh at once, and an unchanged fresh one does not". tests/fm-status-bar.test.sh exits 0 with 38 ok. - shellcheck on the changed file is clean. - I could not run the whole suite under real GNU stat. The run with uname faked as Linux was too slow and was stopped at its time limit before it made any change; the worktree holds only the fix, and no stash entry is left. Left alone because they are outside this change's area: bin/fm-cursor-model-lib.sh:131 and bin/fm-desk-floater-windows.sh:538/563 use the same `||` pattern
…ut waiting for the TTL (kunchenguid#326) * test(bin): pin that a changed fleet starts a status-bar refresh without waiting for the TTL * no-mistakes(review): Read frame clock after priming cache in fleet refresh test * no-mistakes(ci): Root cause: the check failed on 46ae35b, which already reads the frame clock after priming the cache, so the earlier mtime race is ruled out. The first assertion (known=1) passed, so the cached reading's signature and stamp were good. The refresh still started because fm_status_cache_read in bin/fm-status-cache-lib.sh rejects every cache on Linux. Its helper fm_status_file_mtime runs `stat -f %m "$1" || stat -c %Y "$1"`. GNU stat treats -f as filesystem mode and %m as a file name: it prints a filesystem dump for "$1", then exits nonzero. The fallback's epoch is appended after that dump inside the same $(...), so the value never parses. Every cached reading on Linux therefore looks stale, and every frame starts a refresh. The repo already warns about this pattern in bin/fm-supervise-daemon.sh. Invariant: a portable stat helper returns only the requested number, under both BSD and GNU stat. Sites: fm_status_file_mtime and fm_status_file_size in bin/fm-status-cache-lib.sh. Their consumers are fm_status_cache_read (fleet and Codex caches), the claim-stamp fallback in fm_status_claim_refresh, and fm-codex-session-metrics-lib.sh. Fix: both helpers now branch on `uname`, using `/usr/bin/stat -f` on Darwin and `stat -c` elsewhere. This is the same approach as fm-lock-lib.sh and fm-classify-lib.sh. A short comment explains why. No test changes. Verification: - Ran with a fake GNU-like stat and uname reporting Linux at the front of PATH. The original helper returned mtime=[] and size=[], and a just-written cache read as STALE. The fixed helper returned the correct mtime and size, and the cache read as fresh. - On macOS: tests/fm-fleet-status-lib.test.sh exits 0 with 23 ok, including "a changed fleet starts a refresh at once, and an unchanged fresh one does not". tests/fm-status-bar.test.sh exits 0 with 38 ok. - shellcheck on the changed file is clean. - I could not run the whole suite under real GNU stat. The run with uname faked as Linux was too slow and was stopped at its time limit before it made any change; the worktree holds only the fix, and no stash entry is left. Left alone because they are outside this change's area: bin/fm-cursor-model-lib.sh:131 and bin/fm-desk-floater-windows.sh:538/563 use the same `||` pattern
Intent
Fix orphan-signal watcher marker guard so watcher supervision correctly detects and guards against orphaned signal state
What Changed
bin/fm-watch.shnow detects.status/.turn-ended/.check.shfiles with no matchingstate/<id>.meta(leftovers from a torn-down task, or a leaked turn-end hook writer) and absorbs/removes them before classification instead of surfacing them as actionable wakes.state/x-watch.check.shX-mode relay shim from this orphan guard, since that shim has no per-taskstate/x-watch.metaby design and would otherwise be incorrectly treated as orphaned.tests/fm-watch-triage.test.shcovering the new orphan-detection behavior, updates several existing watcher/afk/wake-queue e2e tests for the change, and syncsAGENTS.md,docs/architecture.md,docs/scripts.md, andCONTRIBUTING.mdto describe the fix.Testing
Pipeline
Updates from git push no-mistakes
⏭️ **intent** - skipped
Step was skipped.
⏭️ **Rebase** - skipped
Step was skipped.
⏭️ **Review** - skipped
Step was skipped.
⏭️ **Test** - skipped
Step was skipped.
⏭️ **Document** - skipped
Step was skipped.
⏭️ **Lint** - skipped
Step was skipped.
✅ **Push** - passed
✅ No issues found.