Repository navigation
fix(bin): stop note: status lines from clearing wedge markers - #10
Merged
Merged
Conversation
added 7 commits
September 2, 2026 17:05
status_is_captain_relevant() enumerated working/resolved/captain-held/paused as the only verbs excluded from legacy free-text matching, so a note: line whose prose contained a token like "merged" fell through to the free-text matcher and was classified captain-relevant. Both fm-supervise-daemon.sh wedge guards then treated that as terminal and permanently cleared the worker's possible-wedge marker on every later stale wake of the same unchanged line, so a worker that wrote such a note and then hung was never re-escalated. Introduces one shared predicate, status_is_nonterminal_progress_verb, adds note to it, and has status_is_captain_relevant and both daemon wedge guards call it instead of each keeping its own copy of the verb list. Verified the paused verb's presence in one enumeration and absence in the other two was not a deliberate difference: both daemon call sites already exclude paused/captain-held upstream via status_is_paused_or_captain_held before ever reaching the local check, so merging paused into the shared predicate is provably inert there (confirmed by running the same paused status line through the pre-fix and post-fix code and diffing the output).
…icate as classifier owner
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
Close a fleet-wide supervision hole in firstmate's shared status classifier: a note: status line whose free text happens to contain a legacy trigger token (e.g. 'merged' or 'PR ready') was classified captain-relevant by status_is_captain_relevant() in bin/fm-classify-lib.sh, and the two wedge guards in bin/fm-supervise-daemon.sh (classify_stale and handle_wake's _clear_wedge logic) then treated that as a terminal status and permanently cleared a worker's possible-wedge marker, so a worker that wrote such a note and then hung was never re-escalated. Reproduce the bug with failing tests first, then fix it. Decide between the minimal fix (add note to all three enumerations) versus the root fix (classify a verb-carrying line by verb alone via one shared predicate the three sites call, so a fourth divergence cannot happen) - the root fix is preferred, but first establish from the code whether the existing divergence (fm-classify-lib.sh's old enumeration included the configured paused verb; both fm-supervise-daemon.sh sites did not) was deliberate, since unifying the sets necessarily merges that difference. Do not change classification for done, needs-decision, blocked, or failed - those must remain captain-relevant. Do not break genuine legacy bare lines (no leading verb) matching free text. If the root fix changes behavior for anything beyond note, stop and report rather than widening a defect fix into a behavior change. Add regression tests: a note: line containing 'merged' must not clear a wedge marker and must not be classified captain-relevant; done/needs-decision/blocked/failed remain captain-relevant (direct assertions, not just indirect); a genuine legacy bare line containing 'merged' (no leading verb) remains captain-relevant; and if the three enumeration sites are unified, a test proving they agree, including one for the paused verb specifically proving its behavior is unchanged. A residual gap (an unrecognized leading verb-like token whose free text also matches a legacy trigger, e.g. 'wip: rebased onto merged #76') is confirmed pre-existing and explicitly out of scope for this task - do not attempt to close it, and note it in the PR description as a known, separately-filed follow-up rather than silently leaving it undocumented. Source comments: default none, hard cap three lines strictly enforced, no ticket ids, branch names, or other internal pointers in source - state the durable fact/guarantee instead. Never add an agent name as a commit co-author.
What Changed
bin/fm-classify-lib.shgainsstatus_is_nonterminal_progress_verb, one shared predicate owning the nonterminal verb set (working,note,resolved,captain-held, plus the built-in and configuredFM_CLASSIFY_PAUSED_VERB/FM_CLASSIFY_RESOLVE_VERB/FM_CLASSIFY_CAPTAIN_HELD_VERBvalues, matched additively).status_is_captain_relevantnow delegates to it and reusesstatus_is_terminal_verb, so anote:line whose free text contains a legacy trigger (merged,PR ready, …) is no longer captain-relevant, whiledone/needs-decision/blocked/failedand genuine legacy bare lines with no leading verb keep their existing classification.bin/fm-supervise-daemon.sh—classify_staleandhandle_wake's_clear_wedgelogic — drop their local verbcaseenumerations and call the shared predicate instead, so the three sites can no longer drift apart and anote:line no longer permanently clears a worker's possible-wedge marker; an unchanged idle pane behind such a note ages and re-escalates at the configured bound.note:line containingmergedis neither captain-relevant nor terminal inclassify_stale, and its wedge marker surviveshandle_wakeand re-escalates viahousekeeping;done/needs-decision/blocked/failedare asserted captain-relevant directly; a bare legacymergedline stays captain-relevant; and a dedicated test pins the shared predicate's membership plus each verb override, including apaused:case proving pause classification and pause-marker behavior are unchanged by mergingpausedinto the shared set.docs/architecture.mdrecords the predicate as the single owner;docs/configuration.mddocuments the resolve and captain-held verb overrides and their additive semantics.Known follow-up (out of scope here): an unrecognized leading verb-like token whose free text also matches a legacy trigger (for example
wip: rebased onto merged #76) still classifies as captain-relevant. This gap is pre-existing, separately filed, and deliberately untouched by this change.Risk Assessment
✅ Low: The change collapses three drifting verb enumerations into one shared predicate with no behavior change outside the intended
noteexclusion plus a user-authorized override-honoring widening, every acceptance criterion is source-verifiable and met, and the only findings are two comment-accuracy nits in the changed source.Testing
Ran the two test scripts that own this change (tests/fm-daemon.test.sh, tests/fm-watch-triage.test.sh) — both green — then proved the three behavioral regression tests are red against the pre-fix source, so they genuinely reproduce the reported failure. For product-level evidence I drove the real supervise-daemon functions through the actual overnight-AFK sequence a hung worker produces and captured what the captain receives in their supervisor pane: on base 7583d6d the note: line is escalated once as a terminal status and no possible-wedge marker is ever recorded, so the hang is never re-surfaced; on the branch the wedge marker persists, ages, and housekeeping delivers "Supervisor escalate (1 event(s)): stale persisted 500s (possible wedge): sess:fm-wishlist-w2" into the pane. A before/after classifier matrix confirms the blast radius: only the two note: rows changed, plus
closed:under an FM_CLASSIFY_RESOLVE_VERB override, which is the override-honoring behavior the user explicitly authorized in the round-1 fix instructions; the round-2 concern is empirically closed since literalresolved:stays self-handled while that override is set. This change has no UI, HTML, or rendered surface — it is a background supervision daemon, so the reviewer-visible surface is the captain's pane text, which the transcripts capture verbatim rather than as a summary. Scratch trees and temp logs were removed and the worktree is clean.Evidence: End-to-end AFK scenario: what the captain's pane receives, before vs after
Source: End-to-end AFK scenario: what the captain's pane receives, before vs after
Evidence: Captain-visible escalation, before vs after (excerpt)
Evidence: Classification matrix over the real worker status vocabulary, before vs after
Source: Classification matrix over the real worker status vocabulary, before vs after
Evidence: Only-changed cells in the classifier matrix (before -> after)
Evidence: Red-before / green-after proof for the three regression tests
Source: Red-before / green-after proof for the three regression tests
Evidence: Reproducer: end-to-end AFK wedge scenario harness (takes a tree root)
Source: Reproducer: end-to-end AFK wedge scenario harness (takes a tree root)
Evidence: Reproducer: classifier matrix harness (takes a tree root)
Source: Reproducer: classifier matrix harness (takes a tree root)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-classify-lib.sh:140- Simplification in the function this change rewrote:status_is_captain_relevantre-enumeratesdone|needs-decision|blocked|failedinline at line 140, duplicatingstatus_is_terminal_verb(line 105-113), which the daemon calls two lines away at fm-supervise-daemon.sh:394 and :1271. The change's own thesis is that a verb set must live in one predicate so no site can drift; the terminal set is the one set still copied twice. A behavior-identical collapse isif [ -z "${FM_CAPTAIN_RE+x}" ] && status_is_terminal_verb "$line"; then return 0; fi, which also makes theverblocal dead and removable. The FM_CAPTAIN_RE guard must be kept in place: when FM_CAPTAIN_RE is set the terminal shortcut is deliberately skipped, so a barestatus_is_terminal_verbcall without that guard would change behavior for custom-vocabulary homes. With the guard retained the rewrite is a pure dedup with no observable change under any configuration.bin/fm-classify-lib.sh:123- The new shared predicate honors the paused verb through${FM_CLASSIFY_PAUSED_VERB:-...}but hardcodes the literalsresolvedandcaptain-held, even though the library declares FM_CLASSIFY_RESOLVE_VERB_DEFAULT / FM_CLASSIFY_CAPTAIN_HELD_VERB_DEFAULT (lines 90-92) with the stated purpose that they are "the ONE definition of the verb ... so the vocabulary cannot drift", and eight other sites in this same file honor the overrides (lines 167, 381-382, 433-434, 676-677, 1050-1051, 1121-1122), as does bin/fm-captain-hold.sh:953. Concrete divergence: with FM_CLASSIFY_RESOLVE_VERB=closed, the lineclosed: fixed after upstream merged the patchis a resolution verb to status_open_decisions but an unknown verb to the new predicate, so status_is_captain_relevant falls through to the free-text grep, matchesmerged, and classify_stale takes the terminal escalate path; handle_wake then removes the stale marker and writes the seen marker, and every later stale wake of the same unchanged line hits_clear_wedge=1at fm-supervise-daemon.sh:1271 - the exact wedge-never-re-escalates failure this change fixes fornote. This is pre-existing (the old inline case hardcoded the same two literals) and only reachable when an operator sets an override that docs/configuration.md does not document, so it is not a regression. I am raising it as distinct from the round-1 declinedresidual-verb-carrying-freetext-wedge-hole: that finding was about improvised verbs the library does not know and its remedy was gating the free-text fallback, whereas this is about two verbs the library does own constants for, and the remedy is confined to the changed function (swap the two literals for the constants). Flagged ask-user rather than auto-fix because the remedy, not the defect, needs authorization - the intent says "If the root fix changes behavior for anything beyond note, stop and report rather than widening a defect fix into a behavior change", and honoring the constants does change classification for override-configured homes.🔧 Fix: honor resolve/held verb overrides, reuse terminal-verb predicate
1 warning still open:
bin/fm-classify-lib.sh:123- The latest fix round replaced the literalsresolved/captain-heldin status_is_nonterminal_progress_verb with override-ONLY expansions ("${FM_CLASSIFY_RESOLVE_VERB:-$FM_CLASSIFY_RESOLVE_VERB_DEFAULT}","${FM_CLASSIFY_CAPTAIN_HELD_VERB:-...}"). When an override is set the literal is no longer in the set, but the writers still emit the literal, so the exact wedge-clearing failure this change exists to close is reintroduced. Writers that hardcode the literal regardless of the override: bin/fm-brief.sh:302 briefs every worker to append literalresolved: {how it cleared}(contrast the same brief's$PAUSED_VERBinterpolation on the adjacent lines, which DOES honor the paused override), bin/fm-captain-hold.sh:832 appends literalcaptain-held [key=$key]: tracked by $keys, and bin/fm-pending-reply-lib.sh:1007 appends literalresolved [key=%s]: .... Concrete failing sequence with FM_CLASSIFY_RESOLVE_VERB=closed and a worker following the brief: lineresolved: upstream merged the patch-> status_is_nonterminal_progress_verb false (set is working/note/paused/closed/captain-held) -> status_is_terminal_verb false -> free-text grep matchesmerged-> status_is_captain_relevant true. classify_stale (bin/fm-supervise-daemon.sh:388) skips the transient guard, no seen marker yet, so it printsescalate|stale + terminal status; handle_wake's escalate branch runs stale_marker_remove + mark_escalated_seen. The worker then hangs; every later stale wake of the same unchanged line hits the seen dedupe ->self|stale + terminal (already escalated by signal)-> the*)branch sets _clear_wedge=1 at bin/fm-supervise-daemon.sh:1271 -> stale_marker_remove, so no possible-wedge marker is ever recorded and housekeeping never re-escalates. This is a regression, not pre-existing: at base 7583d6d the case arm wasworking|resolved|captain-held|"${FM_CLASSIFY_PAUSED_VERB:-...}", so the literals were exempt under any override. The new test at tests/fm-watch-triage.test.sh:323-326 asserts only that the override verb IS matched; it never asserts the literal stays matched, so it locks the regression in rather than catching it. Smallest correct remedy inside the changed function: make the arm a SUPERSET - keepresolved|captain-held(or"$FM_CLASSIFY_RESOLVE_VERB_DEFAULT"|"$FM_CLASSIFY_CAPTAIN_HELD_VERB_DEFAULT") alongside the override expansions, and add the matching assertion (FM_CLASSIFY_RESOLVE_VERB=closed status_is_nonterminal_progress_verb "resolved: x"must still be true). Reachability is gated on FM_CLASSIFY_RESOLVE_VERB / FM_CLASSIFY_CAPTAIN_HELD_VERB, which docs/configuration.md does not document (it documents only FM_CLASSIFY_PAUSED_VERB), which is why this is a warning rather than an error. Flagged ask-user because the remedy revises a change the user explicitly prescribed in the round-1 fix instructions, and because it is the remedy - widening the set back to a superset - not the defect that needs authorization; the intent's own guardrail says to stop and report rather than widen a defect fix into a behavior change.🔧 Fix: match literal resolved/captain-held alongside verb overrides
2 infos still open:
bin/fm-classify-lib.sh:130- The rewritten header comment says "Terminal verbs always match", but the code two lines below gates the terminal shortcut on[ -z "${FM_CAPTAIN_RE+x}" ], so with a custom vocabulary configured a terminal verb does NOT match unless the custom regex happens to contain it. tests/fm-watch-triage.test.sh:257 asserts exactly that:FM_CAPTAIN_RE='custom-verb:' status_is_captain_relevant "done: x"must be false. The base comment carried the qualifier ("Verb-aware by default: terminal verbs always match"); the rewrite dropped "by default" and the sentence is now false against a tested behavior. Fix: restore the qualifier, e.g. "Terminal verbs always match unless FM_CAPTAIN_RE replaces the vocabulary". Mechanical and non-user-visible, so auto-fix.bin/fm-classify-lib.sh:116- The comment claims "Configured verbs are additive: writers emit the built-in literal whether or not an override is set", but that is deliberately not uniform in the case arm below:resolvedandcaptain-heldappear as literals AND as override expansions, while the paused verb appears ONLY as${FM_CLASSIFY_PAUSED_VERB:-...}with no literalpaused. That asymmetry is correct - bin/fm-brief.sh:302 hardcodes literalresolved:and bin/fm-captain-hold.sh:832 hardcodes literalcaptain-held [key=...], whereas the same brief interpolates$PAUSED_VERBfor the pause verb, so paused writers honor the override and the other two do not. But the comment states the additive rule as universal, which invites a maintainer to add literalpausedfor symmetry; doing so would change classification for override-configured homes (with FM_CLASSIFY_PAUSED_VERB=holding, a literalpaused: ... mergedline currently reaches the free-text grep and is captain-relevant, and would stop being so). Recommend naming which verbs are additive and why, rather than stating a blanket rule. No code change - flagging the divergence between the stated rule and the deliberate implementation.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-daemon.test.sh— full script green (includes test_stale_note_transient_self_handles, test_afk_nonterminal_note_merged_keeps_wedge_aging, test_paused_unaffected_by_shared_nonterminal_progress_verb)bin/fm-test-run.sh tests/fm-watch-triage.test.sh— full script green (includes test_classifier_primitives with the new failed:/blocked:/note: assertions, and test_status_is_nonterminal_progress_verb_unifies_call_sites)Red-before proof: scratch tree withbin/fm-classify-lib.sh+bin/fm-supervise-daemon.shreverted to base 7583d6d, new tests kept —test_classifier_primitives,test_stale_note_transient_self_handles, andtest_afk_nonterminal_note_merged_keeps_wedge_agingeach fail on the pre-fix sourceManual end-to-end AFK scenario driving the real sourced daemon functions (classify_signal->handle_wake-> stale wakes ->housekeeping->escalate_flush) with a fake tmux backend, run against both base and branch trees, capturing the text injected into the captain's supervisor paneManual before/after classification matrix invoking the realstatus_is_captain_relevantfrom both trees over 17 worker status lines, includingFM_CLASSIFY_RESOLVE_VERB=closedandFM_CLASSIFY_PAUSED_VERB=holdingoverride rows🔧 **Document** - 2 issues found → auto-fixed ✅
docs/configuration.md:693- docs/configuration.md documents FM_CLASSIFY_PAUSED_VERB but not FM_CLASSIFY_RESOLVE_VERB or FM_CLASSIFY_CAPTAIN_HELD_VERB, which this change made newly load-bearing for captain-relevance and wedge classification (they are now additive members of status_is_nonterminal_progress_verb). Both variables pre-date this change and are already read at roughly eight sites in bin/fm-classify-lib.sh plus bin/fm-captain-hold.sh, so this is a pre-existing operator-reference gap rather than staleness this change introduced; closing it means adding two new documented configuration knobs, which is a documentation-surface expansion beyond the scope of this change. Proposed follow-up: document both overrides alongside FM_CLASSIFY_PAUSED_VERB, including the fact that writers (bin/fm-brief.sh, bin/fm-captain-hold.sh, bin/fm-pending-reply-lib.sh) still emit the built-in literals, so an override widens the vocabulary rather than replacing it.🔧 Fix: document resolve and captain-held verb overrides
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.