Repository navigation
fix(watch): stop two supervision wake loops on idle panes - #4
Merged
Merged
Conversation
Bug 1 - expired declared-pause recheck loop. A crew whose status still declares paused, but whose authoritative current-state read flickered to `none`, escaped to surface_nonterminal_stale, which both surfaced un- throttled and wiped the durable .paused-resurfaced-<key> throttle, so the recheck re-fired on essentially every watcher cycle (observed at pause ages 3604/4202/4469/4598s). Now only an authoritative `working` verdict cancels a still-declared pause: pause_state_class maps any other verdict (paused, or a transient none) to a throttled recheck, the first-sight stale path routes through it too, and surface_nonterminal_stale no longer deletes the resurface throttle. The recheck now surfaces at most once per PAUSE_RESURFACE_SECS, durably, surviving restarts and re-declaration. Bug 2 - idle-pane footer animation defeats stale dedupe. A fully idle pane still redraws its context-meter sparkline, so the raw capture hashed differently every poll and re-surfaced the same quiet pane ~every 20s. The staleness hash is now taken over the capture with animated chrome (Block Elements / Braille glyphs) stripped byte-wise under LC_ALL=C, so a footer-only redraw dedupes while any meaningful content change still changes the hash. Works identically for the tmux and herdr plain-text capture paths; window_is_busy still reads the raw capture. Adds test-level repros of both loops (fail before, one-surface-then- silence after) and updates docs/architecture.md.
…in strip_animated_chrome
7hoenix
added a commit
that referenced
this pull request
Jul 20, 2026
…internal clones (#5) * feat(spawn): harden no-mistakes internal clones against unattended-credential hangs The no-mistakes pipeline commits and pushes inside its own internal clone at ~/.no-mistakes/repos/<hash>.git, which fm-sign-lib's per-worktree override never reaches. That clone inherits the operator's global git config, so on a machine like the captain's it hits two unattended-hostile settings that block autonomous validation runs: - Surface 3: global commit.gpgsign=true drives a GUI signer no autonomous run can click, hanging every pipeline commit. - Surface 4: a global url."[email protected]:".insteadOf=https://github.com/ rewrites plain-HTTPS network ops to SSH (same GUI agent), and the default macOS credential chain (osxkeychain) hangs when the keychain is locked. Both were recovered manually on ark PR kunchenguid#337 and dotfiles PR #4 with the same dodge. This automates it: bin/fm-nm-clone-config.sh locates the internal clone via the project's own no-mistakes remote (hash-independent) and scopes, repo-local to that clone only, commit/tag.gpgsign=false plus, when SSH routing is detected, the username-form origin URL + reverse insteadOf + gh credential helper. The operator's global config, the no-mistakes install, and every project clone are never touched. Timing: applied at spawn time (fm-spawn.sh, the deterministic firstmate-owned guarantee, where fm-sign-lib already lives) and re-applied by a ship-brief line right before /no-mistakes (the internal clone can be created mid-run, after spawn). Both applications are idempotent. Every piece is a graceful no-op on a machine without the problem: no no-mistakes remote, no global gpgsign, no insteadOf, or no gh each shrink the work to nothing without error. Tests simulate a fake global config + internal clone + project with a curated PATH-shimmed gh, covering the full dodge, gh-absent username fallback, clean machine, non-gated repo, no-resolvable-username, and idempotency. * no-mistakes(test): isolate host git signing config and skip absent-shellcheck in tests * no-mistakes(document): add fm-nm-clone-config.sh to scripts.md toolbelt catalog
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
Fix two watcher wake-loop bugs in the supervision damping machinery (bin/fm-watch.sh + bin/fm-classify-lib.sh), both reproduced live on 2026-07-13 causing sustained loops that repeatedly interrupted the primary firstmate.
Bug 1 - expired declared-pause recheck loop: a crew whose status still declares paused, but whose authoritative current-state read (fm-crew-state.sh via crew_absorb_class) momentarily flickered to 'none' (a bounded no-mistakes probe timing out, a mis-attributed stale run), escaped into surface_nonterminal_stale, which both surfaced un-throttled AND deleted the durable .paused-resurfaced- throttle, so the recheck re-fired on essentially every watcher cycle (observed at pause ages 3604/4202/4469/4598s). Design decision: mirror the away-mode daemon's already-correct 'create-if-absent marker, reset-on-surface, once per PAUSE_RESURFACE_SECS' pattern. Concretely: (a) pause_state_class now maps ANY non-working verdict for a still-declared pause to a throttled paused recheck - only an authoritative 'working' verdict cancels the declared pause; (b) the first-sight stale path routes through pause_state_class instead of crew_absorb_class so a paused crew's transient 'none' never reaches surface_nonterminal_stale (for a non-paused crew the two are identical, so ordinary stopped-crew surfacing is unchanged); (c) surface_nonterminal_stale no longer deletes .paused-resurfaced- (belt-and-suspenders; that marker is owned by handle_paused_stale and cleared only by a genuine unpause via clear_pause_state). Requirement kept: a forgotten pause DOES still recheck once per window, durably, surviving watcher restarts and crew re-declaration.
Bug 2 - idle-pane footer animation defeats stale dedupe: a fully idle claude crew pane still redraws its context-meter sparkline, so the raw capture hashed differently every poll, defeating the .stale- dedupe and firing a fresh stale wake ~every 20s. Fix: hash the capture with animated chrome stripped. strip_animated_chrome removes exactly two Unicode blocks that never appear in real conversation/code - Block Elements (U+2580-259F sparkline bars) and Braille Patterns (U+2800-28FF dot spinners) - byte-wise under LC_ALL=C, reading the whole capture as one record (RS=NUL) so it is byte-exact and adds no trailing newline (a glyph-free capture hashes identically to the old raw path, preserving existing seeded-hash tests). It works identically for the tmux and herdr plain-text capture paths (both feed fm_backend_capture plain text - no tmux-vs-herdr split). It normalizes ONLY the hash input; tail40 stays raw for window_is_busy, and any meaningful content change still changes the hash, so real staleness detection is not weakened.
Constraints honored: provably-working crews stay absorbed, secondmate pane exemption preserved, demand-deep-inspection escalation still works. Extended the existing tests/fm-watch-triage.test.sh with two regression tests (test-level repro of both loops: fail before, one-surface-then-silence after) rather than a new runner. Updated docs/architecture.md 'Event-driven supervision' (the owning doc). fm-lint.sh green; watch-triage/daemon/watcher-lock/pi-watch/checkpoint suites green.
What Changed
bin/fm-watch.shso a still-declared pause whose authoritative state momentarily flickers to non-working now routes throughpause_state_classand stays throttled to once per resurface window; only a genuineworkingverdict cancels the pause, andsurface_nonterminal_staleno longer deletes the durable.paused-resurfaced-<key>marker, ending a loop that re-fired every watcher cycle.strip_animated_chrometo normalize only the hash input by removing Block Elements and Braille glyphs (context-meter sparklines and spinners) via a byte-exactperl -0777slurp with a rawcatfallback when perl is absent, so an otherwise-idle pane no longer defeats the.stale-<key>dedupe;tail40stays raw for busy detection and real content changes still change the hash.tests/fm-watch-triage.test.shwith two regression tests reproducing both loops (fail on base, one-surface-then-silence after) and updated the "Event-driven supervision" section ofdocs/architecture.md.Risk Assessment
✅ Low: Well-bounded supervision-damping fix with a consistent return-contract change across all call sites, correct UTF-8 byte-range stripping, a safe perl-absent fallback, and matching regression tests; both prior-round findings are already incorporated.
Testing
The pre-run baseline of all tests/*.test.sh already passed; I additionally exercised the two new regression tests directly against both the base and target versions of bin/fm-watch.sh, confirming each bug reproduces on base (expired-pause raw stale wake, and idle-pane sparkline defeating the stale dedupe) and is resolved on target, and captured a CLI transcript showing strip_animated_chrome makes animated footer frames hash identically while preserving real-content and glyph-free byte-exact hashing. Full fm-watch-triage suite (35 tests) is green and the worktree was left clean.
Evidence: Fail-before: bug 1 (expired-pause loop) reproduced on base fm-watch.sh
not ok - expired-pause recheck was not the throttled paused recheck: stale: test:fm-forgottenEvidence: Fail-before: bug 2 (animated footer defeats dedupe) reproduced on base fm-watch.sh
not ok - a footer-only sparkline redraw defeated the stale dedupe and re-surfaced an idle paneEvidence: strip_animated_chrome hashing demo (footer frames dedupe, real change still surfaces)
frame A stripped = e5ad72cf0a99c5347963ca0e45b4d3aa frame B stripped = e5ad72cf0a99c5347963ca0e45b4d3aa <- IDENTICAL -> dedupes, no wake loop real-change stripped = 4d72e3d56db89de0eb019934c0944b13 <- DIFFERENT -> still surfaces glyph-free: raw = stripped = d4e90a60011b924e32b32f117468f9f4Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (2) ✅
bin/fm-watch.sh:193- strip_animated_chrome relies onRS="\0"to read the whole capture as one byte-exact record, but on macOS BSD awk (this environment, awk 20200816)"\0"is an empty string, which puts awk into PARAGRAPH MODE: it splits on blank lines, collapses blank-line runs, and drops the trailing newline. Verified live: a glyph-free captureline1\n\nline2\nhashes DIFFERENTLY through this function than through the raw path (9acd21... vs ce8bc0...), directly contradicting the comment's 'hashes identically to the old raw path' invariant. The primary idle-animation dedupe still functions because the transform is applied consistently on every poll (hash comparisons are stripped-vs-stripped internally), so no meaningful staleness is missed - but the documented byte-exact/one-record guarantee is false on the target platform, and any future test or code that seeds a raw-computed hash with blank-line content will silently break. The two new regression tests pass only because their captures contain no blank lines and no trailing-newline sensitivity. Recommend a byte-exact whole-input strip that doesn't depend on RS, e.g.LC_ALL=C perl -pe 's/\xe2\x96[\x80-\x9f]//g; s/\xe2[\xa0-\xa3][\x80-\xbf]//g'(perl -p preserves record separators exactly, last-line included).🔧 Fix: replace awk RS slurp with byte-exact perl -0777 in strip_animated_chrome
1 warning still open:
bin/fm-watch.sh:195- strip_animated_chrome (bin/fm-watch.sh:195) calls perl unconditionally on the per-window-per-poll hot path, breaking the codebase's own convention of guarding perl withcommand -v perlplus a non-perl fallback (fm-crew-state.sh:207, fm-bearings-snapshot.sh:165, run_check at :451). The script sets onlyset -u(no pipefail), so at :768printf '%s' "$tail40" | strip_animated_chrome | hash_paneswallows a missing-perl exit 127 and hash_pane hashes empty input. If perl is absent, every window yields the identical empty-string md5 every poll, .hash-/.stale- markers always match, and stale/wedge detection is silently defeated with no error surfaced. Add a graceful fallback that passes the capture through raw when perl is unavailable (degrades to the old raw-hash behavior rather than collapsing detection).🔧 Fix: guard strip_animated_chrome perl call with raw cat fallback
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-watch-triage.test.shon target commit - all 35 tests pass includingtest_expired_pause_rechecks_once_per_window_not_loopandtest_animated_footer_does_not_defeat_stale_dedupeRan target test file against BASEbin/fm-watch.sh(swapped ingit show 1e67e2b:bin/fm-watch.sh): bug 1 test fails withnot ok - expired-pause recheck was not the throttled paused recheck: stale: test:fm-forgottenRan the animated-footer test against BASE source in isolation: fails withnot ok - a footer-only sparkline redraw defeated the stale dedupe and re-surfaced an idle paneProduct-level CLI transcript ofstrip_animated_chrome/hash_pane: two footer frames (▁▃▅▇ vs ▇▅▃▁) hash identically after stripping, a real body change changes the hash, and a glyph-free capture hashes identically stripped-vs-rawConfirmedgit status --porcelainclean after restoring temporarily-swapped source/test files✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.