fix(watcher): preserve PR-check wakes before suppression#52
Closed
tommy230 wants to merge 4 commits into
Closed
Conversation
Checks were the only wake source whose suppression lived inside an opaque script: an edge-triggered check advanced its own .babysit-*.seen marker before the print could become a wake, so a lost stdout (timeout / concurrent run / crash) permanently swallowed the transition. This is the root cause of the missed PR #3095 merge (see data/fm-git-events-s8/report.md): the .cli-printing-press-3095.seen sidecar advanced to MERGED but no check wake was ever emitted. Port the kunchenguid#29 enqueue-before-suppress invariant to checks: 1. Watcher-side suppression (bin/fm-watch.sh). The check always prints its current state (idempotent); the watcher dedups against .seen-check-<name> and calls fm_wake_append (durable queue) BEFORE advancing the marker. A crash between detect and suppress leaves the wake in the queue (recovered next turn) and the marker un-advanced (re-detected next cycle). A lost check wake is now impossible - exactly the guarantee signals enjoy. 2. Backward-compatible with old edge-triggered checks: empty stdout never produces a wake, so they keep their quiet behavior. 3. Catch-all backstop: force-escalate any .babysit-*.seen sidecar showing a terminal state (MERGED/CLOSED) the watcher never delivered a wake for. Catches a swallowed transition within one sweep; deduped via .escalated-<sidecar> so each terminal state fires at most once. Tests (tests/fm-wake-queue.test.sh): - test_check_wake_survives_lost_delivery: the #3095 regression - a check wake survives a simulated crash between enqueue and suppress (queue recovery + re-detection). - test_check_dedup_suppresses_repeats: identical repeated output wakes once. - test_catch_all_escalates_swallowed_transition: a self-suppressed check whose sidecar shows MERGED is force-escalated within one sweep. AGENTS.md: the check contract now documents the stateless "always print current state" form as preferred, and .seen-check-*/.escalated-* join the enqueue-before-suppress marker list. shellcheck clean; all 14 wake-queue tests + 5 spawn-batch tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
The transcript is mostly omitted, but the visible context indicates the developer wanted work continued on PR or issue #34 by restoring its fixed branch and running it through a fork-aware no-mistakes validation flow. They expected the agent to operate under Firstmate rules: avoid direct project writes, use delegated work where appropriate, preserve unlanded work, and validate through the configured pipeline before reporting readiness.
What Changed
Risk Assessment
✅ Low: Captain, the change is well-bounded to watcher check wake dedup/catch-all cleanup behavior, with matching teardown cleanup and focused regression coverage; I did not find material merge-blocking risks.
Testing
Exercised the CLI-facing PR-check watcher flow end to end plus the targeted shell suites for crash recovery, enqueue-before-suppress, repeat deduping, catch-all escalation, and teardown marker cleanup; all checks passed and the final worktree status was clean.
Evidence: fm-wake-queue targeted test transcript
Evidence: fm-teardown targeted test transcript
Evidence: manual PR-check/watch/drain transcript
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.
bash tests/fm-wake-queue.test.sh 2>&1 | tee /var/folders/kg/vqcvwwlx3xs4wblm4wpvpkz00000gn/T/no-mistakes-evidence/01KVTN33M520MFG54DMN8E78EB/fm-wake-queue.test.logbash tests/fm-teardown.test.sh 2>&1 | tee /var/folders/kg/vqcvwwlx3xs4wblm4wpvpkz00000gn/T/no-mistakes-evidence/01KVTN33M520MFG54DMN8E78EB/fm-teardown.test.logManual end-to-end smoke with fakegh pr viewreturningMERGED: ranbin/fm-pr-check.sh,bin/fm-watch.sh,bin/fm-wake-drain.sh, then reran the watcher on the same terminal state to verify no duplicate wake was queued; transcript at/var/folders/kg/vqcvwwlx3xs4wblm4wpvpkz00000gn/T/no-mistakes-evidence/01KVTN33M520MFG54DMN8E78EB/manual-pr-check-lossless.transcript.git status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.