Skip to content

fix(bin): stop note: status lines from clearing wedge markers - #10

Merged
alandomio merged 7 commits into
mainfrom
fm/supervision-note-verb-wedge-guard
Sep 3, 2026
Merged

alandomio merged 7 commits into
mainfrom
fm/supervision-note-verb-wedge-guard

Conversation

@alandomio

Copy link
Copy Markdown
Owner

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.sh gains status_is_nonterminal_progress_verb, one shared predicate owning the nonterminal verb set (working, note, resolved, captain-held, plus the built-in and configured FM_CLASSIFY_PAUSED_VERB / FM_CLASSIFY_RESOLVE_VERB / FM_CLASSIFY_CAPTAIN_HELD_VERB values, matched additively). status_is_captain_relevant now delegates to it and reuses status_is_terminal_verb, so a note: line whose free text contains a legacy trigger (merged, PR ready, …) is no longer captain-relevant, while done/needs-decision/blocked/failed and genuine legacy bare lines with no leading verb keep their existing classification.
  • Both wedge guards in bin/fm-supervise-daemon.sh — classify_stale and handle_wake's _clear_wedge logic — drop their local verb case enumerations and call the shared predicate instead, so the three sites can no longer drift apart and a note: 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.
  • Regression tests cover the fix and the unification: a note: line containing merged is neither captain-relevant nor terminal in classify_stale, and its wedge marker survives handle_wake and re-escalates via housekeeping; done/needs-decision/blocked/failed are asserted captain-relevant directly; a bare legacy merged line stays captain-relevant; and a dedicated test pins the shared predicate's membership plus each verb override, including a paused: case proving pause classification and pause-marker behavior are unchanged by merging paused into the shared set. docs/architecture.md records the predicate as the single owner; docs/configuration.md documents 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 note exclusion 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 literal resolved: 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

==============================================================
 BEFORE the fix - base commit 7583d6d
==============================================================

[00:00] captain is AFK; worker window sess:fm-wishlist-w2 is under daemon supervision.
        worker appends its own status line:
          note: CANDIDATE - upstream already merged the same fix

[00:00] daemon wake #1 (signal: the status file changed)
        classify_signal -> escalate|wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix
        possible-wedge marker: ABSENT  (no hang timer running for this worker)

[00:04] worker has produced nothing since. daemon wake #2 (stale: sess:fm-wishlist-w2)
        classify_stale  -> self|stale + terminal (already escalated by signal): note: CANDIDATE - upstream already merged the same fix
        possible-wedge marker: ABSENT  (no hang timer running for this worker)

[00:08] still nothing. daemon wake #3 (stale: sess:fm-wishlist-w2, status unchanged)
        classify_stale  -> self|stale + terminal (already escalated by signal): note: CANDIDATE - upstream already merged the same fix
        possible-wedge marker: ABSENT  (no hang timer running for this worker)

[00:12] >4 min of silence. housekeeping rechecks the worker pane (idle).
        escalation buffer now holds:
          | wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix

[00:13] daemon flushes the digest into the captain's supervisor pane.

--------------------------------------------------------------
WHAT THE CAPTAIN ACTUALLY RECEIVES IN THEIR PANE:
--------------------------------------------------------------
  ⁣FIRSTMATE_OP: v1 away-supervisor: Supervisor escalate (       1 event(s)): wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix (pre-read; re-arm not needed — watcher daemon-managed)

RESULT: the hung worker is NEVER surfaced as a possible wedge.


==============================================================
 AFTER the fix - target commit d12c9c0
==============================================================

[00:00] captain is AFK; worker window sess:fm-wishlist-w2 is under daemon supervision.
        worker appends its own status line:
          note: CANDIDATE - upstream already merged the same fix

[00:00] daemon wake #1 (signal: the status file changed)
        classify_signal -> self|routine signal: wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix
        possible-wedge marker: ABSENT  (no hang timer running for this worker)

[00:04] worker has produced nothing since. daemon wake #2 (stale: sess:fm-wishlist-w2)
        classify_stale  -> self|transient stale (sess:fm-wishlist-w2): note: CANDIDATE - upstream already merged the same fix
        possible-wedge marker: PRESENT (worker still being aged for a hang)

[00:08] still nothing. daemon wake #3 (stale: sess:fm-wishlist-w2, status unchanged)
        classify_stale  -> self|transient stale (sess:fm-wishlist-w2): note: CANDIDATE - upstream already merged the same fix
        possible-wedge marker: PRESENT (worker still being aged for a hang)

[00:12] >4 min of silence. housekeeping rechecks the worker pane (idle).
        escalation buffer now holds:
          | stale persisted 500s (possible wedge): sess:fm-wishlist-w2

[00:13] daemon flushes the digest into the captain's supervisor pane.

--------------------------------------------------------------
WHAT THE CAPTAIN ACTUALLY RECEIVES IN THEIR PANE:
--------------------------------------------------------------
  ⁣FIRSTMATE_OP: v1 away-supervisor: Supervisor escalate (       1 event(s)): stale persisted 500s (possible wedge): sess:fm-wishlist-w2 (pre-read; re-arm not needed — watcher daemon-managed)

RESULT: the hung worker IS surfaced as a possible wedge.
Evidence: Captain-visible escalation, before vs after (excerpt)
BEFORE (base 7583d6d)
classify_signal -> escalate|wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix
possible-wedge marker: ABSENT
classify_stale -> self|stale + terminal (already escalated by signal): note: ...
possible-wedge marker: ABSENT
CAPTAIN PANE: Supervisor escalate (1 event(s)): wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix
RESULT: the hung worker is NEVER surfaced as a possible wedge.

AFTER (target d12c9c0)
classify_signal -> self|routine signal: wishlist-w2.status: note: CANDIDATE - upstream already merged the same fix
classify_stale -> self|transient stale (sess:fm-wishlist-w2): note: ...
possible-wedge marker: PRESENT (worker still being aged for a hang)
CAPTAIN PANE: Supervisor escalate (1 event(s)): stale persisted 500s (possible wedge): sess:fm-wishlist-w2
RESULT: the hung worker IS surfaced as a possible wedge.
Evidence: Classification matrix over the real worker status vocabulary, before vs after

Source: Classification matrix over the real worker status vocabulary, before vs after

BEFORE - base commit 7583d6d

CONFIG OVERRIDE  | STATUS LINE THE WORKER WROTE               | DAEMON VERDICT
-----------------+--------------------------------------------+-----------------
-                | done: PR https://x/y/pull/1                | captain-relevant
-                | needs-decision [key=q1]: pick A or B       | captain-relevant
-                | blocked: no perms on the deploy key        | captain-relevant
-                | failed: build broke on arm64               | captain-relevant
-                | working: stage 2 setup complete            | self-handled   
-                | working: rebased onto merged #76           | self-handled   
-                | resolved [key=q1]: captain picked A        | self-handled   
-                | captain-held [key=q1]: tracked by captain  | self-handled   
-                | paused: waiting on upstream review         | self-handled   
-                | note: plain informational update           | self-handled   
-                | note: CANDIDATE - upstream already merged it | captain-relevant
-                | note: PR ready checks green in branch      | captain-relevant
-                | merged                                     | captain-relevant
-                | PR ready https://x/y/pull/2                | captain-relevant
FM_CLASSIFY_RESOLVE_VERB=closed | resolved: upstream merged the patch        | self-handled   
FM_CLASSIFY_RESOLVE_VERB=closed | closed: upstream merged the patch          | captain-relevant
FM_CLASSIFY_PAUSED_VERB=holding | holding: merged upstream, awaiting review  | self-handled   


AFTER - target commit d12c9c0

CONFIG OVERRIDE  | STATUS LINE THE WORKER WROTE               | DAEMON VERDICT
-----------------+--------------------------------------------+-----------------
-                | done: PR https://x/y/pull/1                | captain-relevant
-                | needs-decision [key=q1]: pick A or B       | captain-relevant
-                | blocked: no perms on the deploy key        | captain-relevant
-                | failed: build broke on arm64               | captain-relevant
-                | working: stage 2 setup complete            | self-handled   
-                | working: rebased onto merged #76           | self-handled   
-                | resolved [key=q1]: captain picked A        | self-handled   
-                | captain-held [key=q1]: tracked by captain  | self-handled   
-                | paused: waiting on upstream review         | self-handled   
-                | note: plain informational update           | self-handled   
-                | note: CANDIDATE - upstream already merged it | self-handled   
-                | note: PR ready checks green in branch      | self-handled   
-                | merged                                     | captain-relevant
-                | PR ready https://x/y/pull/2                | captain-relevant
FM_CLASSIFY_RESOLVE_VERB=closed | resolved: upstream merged the patch        | self-handled   
FM_CLASSIFY_RESOLVE_VERB=closed | closed: upstream merged the patch          | self-handled   
FM_CLASSIFY_PAUSED_VERB=holding | holding: merged upstream, awaiting review  | self-handled   


CELLS THAT CHANGED (unified diff, before -> after)

--- /tmp/matrix-before.txt	2026-09-03 12:49:39.801309661 +0200
+++ /tmp/matrix-after.txt	2026-09-03 12:49:39.942837422 +0200
@@ -10,10 +10,10 @@
 -                | captain-held [key=q1]: tracked by captain  | self-handled   
 -                | paused: waiting on upstream review         | self-handled   
 -                | note: plain informational update           | self-handled   
--                | note: CANDIDATE - upstream already merged it | captain-relevant
--                | note: PR ready checks green in branch      | captain-relevant
+-                | note: CANDIDATE - upstream already merged it | self-handled   
+-                | note: PR ready checks green in branch      | self-handled   
 -                | merged                                     | captain-relevant
 -                | PR ready https://x/y/pull/2                | captain-relevant
 FM_CLASSIFY_RESOLVE_VERB=closed | resolved: upstream merged the patch        | self-handled   
-FM_CLASSIFY_RESOLVE_VERB=closed | closed: upstream merged the patch          | captain-relevant
+FM_CLASSIFY_RESOLVE_VERB=closed | closed: upstream merged the patch          | self-handled   
 FM_CLASSIFY_PAUSED_VERB=holding | holding: merged upstream, awaiting review  | self-handled   
Evidence: Only-changed cells in the classifier matrix (before -> after)
- note: CANDIDATE - upstream already merged it | captain-relevant
+ note: CANDIDATE - upstream already merged it | self-handled
- note: PR ready checks green in branch | captain-relevant
+ note: PR ready checks green in branch | self-handled
- FM_CLASSIFY_RESOLVE_VERB=closed | closed: upstream merged the patch | captain-relevant
+ FM_CLASSIFY_RESOLVE_VERB=closed | closed: upstream merged the patch | self-handled

Unchanged (identical in both trees): done:, needs-decision:, blocked:, failed: -> captain-relevant;
working:, working:+merged, resolved:, captain-held:, paused:, plain note: -> self-handled;
legacy bare `merged` and `PR ready https://x/y/pull/2` -> captain-relevant;
literal `resolved:` under FM_CLASSIFY_RESOLVE_VERB=closed -> self-handled;
`holding:` under FM_CLASSIFY_PAUSED_VERB=holding -> self-handled.
Evidence: Red-before / green-after proof for the three regression tests

Source: Red-before / green-after proof for the three regression tests

Red-before / green-after proof for the note: wedge regression tests.

Method: a scratch copy of the branch tree with bin/fm-classify-lib.sh and
bin/fm-supervise-daemon.sh reverted to base commit 7583d6d (new tests, pre-fix
source). Each test script aborts on its first failure, so the three behavioral
regression tests were driven one at a time.

--- RED (new tests, pre-fix source) ------------------------------------------

$ bash tests/fm-watch-triage.test.sh   # test_classifier_primitives
not ok - note: free-text merged wrongly recognized as captain-relevant

$ bash tests/fm-daemon.test.sh         # test_stale_note_transient_self_handles
not ok - note: with merged free text was not classified transient: escalate|stale + terminal status: note: CANDIDATE - upstream already merged the same fix

$ bash tests/fm-daemon.test.sh         # test_afk_nonterminal_note_merged_keeps_wedge_aging
not ok - nonterminal note: treated as already-escalated terminal: self|stale + terminal (already escalated by signal): note: CANDIDATE - upstream already merged the same fix

--- GREEN (same tests, branch source d12c9c0) --------------------------------

$ bin/fm-test-run.sh tests/fm-daemon.test.sh
ok - paused: reaches the pause action before either daemon site's nonterminal-verb case, so merging it into the shared predicate changes nothing observable
ok - note: verb is never treated as terminal by classify_stale, even with free-text merged
ok - AFK nonterminal note:+merged keeps wedge aging and re-escalates at bound
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=44572

$ bin/fm-test-run.sh tests/fm-watch-triage.test.sh
ok - classifier primitives: keyed decisions and activity phases, captain relevance, window-to-task, and overrides
ok - status_is_nonterminal_progress_verb is the single shared predicate for all three call sites
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=329554
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)

#!/usr/bin/env bash
# End-to-end overnight-AFK scenario for the "note: ... merged ..." supervision hole.
#
# Drives the REAL bin/fm-supervise-daemon.sh functions (sourced, main loop skipped)
# against a real state dir, exactly as the away-mode daemon does at runtime:
#   1. worker writes a nonterminal `note:` whose free text contains "merged"
#   2. daemon takes the signal wake for that status write
#   3. worker hangs; daemon takes two stale wakes for the unchanged line
#   4. time passes past FM_STALE_ESCALATE_SECS; housekeeping rechecks the idle pane
#   5. the escalation digest is injected into the captain's supervisor pane
#
# Usage: note-wedge-scenario.sh <repo-tree-root> <label>
set -u
ROOT=$1; LABEL=$2
WIN="sess:fm-wishlist-w2"
TASK="wishlist-w2"
KEY="$TASK"
NOTE='note: CANDIDATE - upstream already merged the same fix'

dir=$(mktemp -d "${TMPDIR:-/tmp}/fm-note-wedge-XXXXXX")
state="$dir/state"; fakebin="$dir/fakebin"
mkdir -p "$state" "$fakebin"
sent="$dir/captain-pane-received.log"; : > "$sent"
worker_pane="$dir/worker-pane.txt"; printf 'idle prompt $\n' > "$worker_pane"
composer="$dir/captain-composer.txt"
printf '╭─────╮\n│ >   │\n╰─────╯\n' > "$composer"

cat > "$fakebin/tmux" <<'SH'
#!/usr/bin/env bash
set -u
COMPOSER="$FM_FAKE_COMPOSER"; WORKER="$FM_FAKE_WORKER_PANE"
write_composer() {
  text=$1; width=$((${#text} + 4)); border=; i=0
  while [ "$i" -lt "$width" ]; do border="${border}─"; i=$((i + 1)); done
  printf '╭%s╮\n│ > %s │\n╰%s╯\n' "$border" "$text" "$border" > "$COMPOSER"
}
target_of() { t=""; while [ "$#" -gt 0 ]; do case "$1" in -t) t="${2:-}"; shift 2; continue ;; esac; shift; done; printf '%s' "$t"; }
case "${1:-}" in
  display-message)
    for a in "$@"; do case "$a" in *cursor_y*) printf '1\n'; exit 0 ;; esac; done
    for a in "$@"; do [ "$a" = "-p" ] && printf 'fakepane\n'; done
    exit 0 ;;
  list-windows) printf '%s\n' "$FM_FAKE_TMUX_WINDOW"; exit 0 ;;
  capture-pane)
    shift; t=$(target_of "$@")
    case "$t" in
      "$FM_FAKE_TMUX_WINDOW"*) cat "$WORKER" 2>/dev/null ;;
      *) cat "$COMPOSER" 2>/dev/null ;;
    esac
    exit 0 ;;
  send-keys)
    shift; text=""; is_enter=0; lit=0
    while [ "$#" -gt 0 ]; do
      case "$1" in
        -t) shift ;; -l) lit=1 ;; Enter) is_enter=1 ;;
        *) [ "$lit" = 1 ] && text="$1" ;;
      esac
      shift
    done
    if [ "$is_enter" = 1 ]; then printf '[SUBMIT]\n' >> "$FM_FAKE_SENT"; write_composer ""
    elif [ "$lit" = 1 ]; then printf '%s\n' "$text" >> "$FM_FAKE_SENT"; write_composer "$text"; fi
    exit 0 ;;
esac
exit 1
SH
chmod +x "$fakebin/tmux"

export FM_TEST_DAEMON_SOURCED=1
# shellcheck source=/dev/null
. "$ROOT/bin/fm-supervise-daemon.sh"

export PATH="$fakebin:$PATH"
export FM_STATE_OVERRIDE="$state" FM_HOME="$dir"
export FM_FAKE_TMUX_WINDOW="$WIN" FM_FAKE_WORKER_PANE="$worker_pane"
export FM_FAKE_COMPOSER="$composer" FM_FAKE_SENT="$sent"
export FM_SUPERVISOR_BACKEND=tmux FM_SUPERVISOR_TARGET="firstmate:0"
export FM_STALE_ESCALATE_SECS=240 FM_ESCALATE_BATCH_SECS=90
export FM_INJECT_CONFIRM_SLEEP=0.05 FM_WEDGE_ALARM_CHANNEL=off
afk_enter "$state" >/dev/null 2>&1

say() { printf '%s\n' "$*"; }
marker_state() {
  if [ -e "$state/.subsuper-stale-$KEY" ]; then say "        possible-wedge marker: PRESENT (worker still being aged for a hang)"
  else say "        possible-wedge marker: ABSENT  (no hang timer running for this worker)"; fi
}

say "=============================================================="
say " $LABEL"
say "=============================================================="
say ""
say "[00:00] captain is AFK; worker window $WIN is under daemon supervision."
say "        worker appends its own status line:"
say "          $NOTE"
printf '%s\n' "$NOTE" > "$state/$TASK.status"
say ""
say "[00:00] daemon wake #1 (signal: the status file changed)"
d=$(classify_signal "$state/$TASK.status" "$state")
say "        classify_signal -> $d"
handle_wake "signal: $state/$TASK.status" "$state"
marker_state
say ""

say "[00:04] worker has produced nothing since. daemon wake #2 (stale: $WIN)"
d=$(classify_stale "$WIN" "$state")
say "        classify_stale  -> $d"
handle_wake "stale: $WIN" "$state"
marker_state
say ""

say "[00:08] still nothing. daemon wake #3 (stale: $WIN, status unchanged)"
d=$(classify_stale "$WIN" "$state")
say "        classify_stale  -> $d"
handle_wake "stale: $WIN" "$state"
marker_state
say ""

say "[00:12] >4 min of silence. housekeeping rechecks the worker pane (idle)."
if [ -e "$state/.subsuper-stale-$KEY" ]; then
  echo $(( $(date +%s) - 500 )) > "$state/.subsuper-stale-$KEY"
fi
housekeeping "$state" >/dev/null 2>&1
say "        escalation buffer now holds:"
if [ -s "$state/.subsuper-escalations" ]; then sed 's/^/          | /' "$state/.subsuper-escalations"
else say "          | (empty)"; fi
say ""

say "[00:13] daemon flushes the digest into the captain's supervisor pane."
: > "$sent"
if escalate_flush "$state" >/dev/null 2>&1; then :; fi
say ""
say "--------------------------------------------------------------"
say "WHAT THE CAPTAIN ACTUALLY RECEIVES IN THEIR PANE:"
say "--------------------------------------------------------------"
if [ -s "$sent" ]; then grep -v '^\[SUBMIT\]$' "$sent" | sed 's/^/  /'
else say "  (nothing - the captain is never told this worker is wedged)"; fi
say ""
if grep -q 'possible wedge' "$sent" 2>/dev/null; then
  say "RESULT: the hung worker IS surfaced as a possible wedge."
else
  say "RESULT: the hung worker is NEVER surfaced as a possible wedge."
fi
rm -rf "$dir"
Evidence: Reproducer: classifier matrix harness (takes a tree root)

Source: Reproducer: classifier matrix harness (takes a tree root)

#!/usr/bin/env bash
# Runs the REAL status_is_captain_relevant() from a given tree over the status
# vocabulary a worker can actually write, so the before/after tables can be
# diffed cell by cell. Env prefix column shows configured-verb overrides.
set -u
ROOT=$1
# shellcheck source=/dev/null
. "$ROOT/bin/fm-classify-lib.sh"

row() {  # <env-assignment-or-"-"> <status line>
  local envs=$1 line=$2 verdict
  if [ "$envs" = "-" ]; then
    if status_is_captain_relevant "$line"; then verdict="captain-relevant"; else verdict="self-handled   "; fi
  else
    if env "$envs" bash -c '. "$0/bin/fm-classify-lib.sh"; status_is_captain_relevant "$1"' "$ROOT" "$line"; then
      verdict="captain-relevant"; else verdict="self-handled   "; fi
  fi
  printf '%-16s | %-42s | %s\n' "${envs}" "$line" "$verdict"
}

printf '%-16s | %-42s | %s\n' "CONFIG OVERRIDE" "STATUS LINE THE WORKER WROTE" "DAEMON VERDICT"
printf '%-16s-+-%-42s-+-%s\n' "----------------" "------------------------------------------" "----------------"
row - 'done: PR https://x/y/pull/1'
row - 'needs-decision [key=q1]: pick A or B'
row - 'blocked: no perms on the deploy key'
row - 'failed: build broke on arm64'
row - 'working: stage 2 setup complete'
row - 'working: rebased onto merged #76'
row - 'resolved [key=q1]: captain picked A'
row - 'captain-held [key=q1]: tracked by captain'
row - 'paused: waiting on upstream review'
row - 'note: plain informational update'
row - 'note: CANDIDATE - upstream already merged it'
row - 'note: PR ready checks green in branch'
row - 'merged'
row - 'PR ready https://x/y/pull/2'
row FM_CLASSIFY_RESOLVE_VERB=closed 'resolved: upstream merged the patch'
row FM_CLASSIFY_RESOLVE_VERB=closed 'closed: upstream merged the patch'
row FM_CLASSIFY_PAUSED_VERB=holding 'holding: merged upstream, awaiting review'

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ bin/fm-classify-lib.sh:140 - Simplification in the function this change rewrote: status_is_captain_relevant re-enumerates done|needs-decision|blocked|failed inline at line 140, duplicating status_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 is if [ -z &#34;${FM_CAPTAIN_RE+x}&#34; ] &amp;&amp; status_is_terminal_verb &#34;$line&#34;; then return 0; fi, which also makes the verb local 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 bare status_is_terminal_verb call 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 literals resolved and captain-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 line closed: fixed after upstream merged the patch is 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, matches merged, 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=1 at fm-supervise-daemon.sh:1271 - the exact wedge-never-re-escalates failure this change fixes for note. 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 declined residual-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 literals resolved/captain-held in status_is_nonterminal_progress_verb with override-ONLY expansions (&#34;${FM_CLASSIFY_RESOLVE_VERB:-$FM_CLASSIFY_RESOLVE_VERB_DEFAULT}&#34;, &#34;${FM_CLASSIFY_CAPTAIN_HELD_VERB:-...}&#34;). 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 literal resolved: {how it cleared} (contrast the same brief's $PAUSED_VERB interpolation on the adjacent lines, which DOES honor the paused override), bin/fm-captain-hold.sh:832 appends literal captain-held [key=$key]: tracked by $keys, and bin/fm-pending-reply-lib.sh:1007 appends literal resolved [key=%s]: .... Concrete failing sequence with FM_CLASSIFY_RESOLVE_VERB=closed and a worker following the brief: line resolved: 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 matches merged -> status_is_captain_relevant true. classify_stale (bin/fm-supervise-daemon.sh:388) skips the transient guard, no seen marker yet, so it prints escalate|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 was working|resolved|captain-held|&#34;${FM_CLASSIFY_PAUSED_VERB:-...}&#34;, 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 - keep resolved|captain-held (or &#34;$FM_CLASSIFY_RESOLVE_VERB_DEFAULT&#34;|&#34;$FM_CLASSIFY_CAPTAIN_HELD_VERB_DEFAULT&#34;) alongside the override expansions, and add the matching assertion (FM_CLASSIFY_RESOLVE_VERB=closed status_is_nonterminal_progress_verb &#34;resolved: x&#34; 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 &#34;${FM_CAPTAIN_RE+x}&#34; ], 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=&#39;custom-verb:&#39; status_is_captain_relevant &#34;done: x&#34; 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: resolved and captain-held appear as literals AND as override expansions, while the paused verb appears ONLY as ${FM_CLASSIFY_PAUSED_VERB:-...} with no literal paused. That asymmetry is correct - bin/fm-brief.sh:302 hardcodes literal resolved: and bin/fm-captain-hold.sh:832 hardcodes literal captain-held [key=...], whereas the same brief interpolates $PAUSED_VERB for 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 literal paused for symmetry; doing so would change classification for override-configured homes (with FM_CLASSIFY_PAUSED_VERB=holding, a literal paused: ... merged line 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 with bin/fm-classify-lib.sh + bin/fm-supervise-daemon.sh reverted to base 7583d6d, new tests kept — test_classifier_primitives, test_stale_note_transient_self_handles, and test_afk_nonterminal_note_merged_keeps_wedge_aging each fail on the pre-fix source
  • Manual 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 pane
  • Manual before/after classification matrix invoking the real status_is_captain_relevant from both trees over 17 worker status lines, including FM_CLASSIFY_RESOLVE_VERB=closed and FM_CLASSIFY_PAUSED_VERB=holding override 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.
  • ℹ️ The user intent requires the residual gap (an unrecognized leading verb-like token whose free text also matches a legacy trigger, e.g. 'wip: rebased onto merged refactor(skills): move trigger-time procedure out of AGENTS.md into on-demand skills #76') to be noted in the PR description as a known, separately-filed follow-up. That surface is a PR body, not tracked project documentation, so this phase deliberately did not write it; flagging so the outer executor's PR phase carries it. No repository documentation change is appropriate for it - per the placement policy it would be task/incident evidence, not a doc-owner fact.

🔧 Fix: document resolve and captain-held verb overrides
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio 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).
@alandomio
alandomio merged commit 3099370 into main Sep 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant