Skip to content

fix(bin): absorb routine secondmate working and paused status appends - #5535

Merged
kunchenguid merged 2 commits into
kunchenguid:mainfrom
karotkriss:fm/fm-up-2959-secondmate-status-absorb
Sep 25, 2026
Merged

kunchenguid merged 2 commits into
kunchenguid:mainfrom
karotkriss:fm/fm-up-2959-secondmate-status-absorb

Conversation

@karotkriss

Copy link
Copy Markdown
Contributor

Intent

Fixes #2959

Every status line a second mate appends is treated as non-absorbable, so routine working: and paused: progress from a healthy second mate wakes the primary model on every append.
Keep surfacing what the primary must read (decisions, blockers, terminal outcomes, explicit parent-directed notes, marked routed replies, and any line whose verb is unknown or whose mate cannot be proven healthy) and absorb unmarked routine progress the way ordinary crew status is absorbed.
This closes upstream issue #2959.

What Changed

  • Add _fm_secondmate_status_new_lines_routine to bin/fm-classify-lib.sh, which reads only the .status lines appended since the watcher's classified position (fm_wake_signal_seen_size) and returns "routine" only when every new non-blank line is an unmarked working: or paused: verb; any decision/blocker/terminal/note:/correlation-marked (corr=) line, unknown verb, or unreadable span keeps surfacing.
  • Wire that helper into signal_crew_provably_working so a kind=secondmate .status signal now defers to the ordinary provably-working absorb for routine progress instead of unconditionally returning 1, stopping healthy-mate working:/paused: appends from waking the primary on every append while unproven mates still surface.
  • Update docs/architecture.md to describe the status stream as absorbable for unmarked routine progress and surfacing for parent-directed content, and expand tests/fm-watch-triage.test.sh coverage for the new absorb/surface split.

Risk Assessment

✅ Low: The change is well-bounded and correct: the routine-absorb path reads only lines new since the aligned classified byte offset, absorbs only working/paused from a provably-working mate, surfaces every marked, terminal, note, or unknown-verb line, and the fix round's narrowing to working+paused matches the intent and round-1 decision with a regression test proving unmarked resolved: still wakes the primary.

Testing

I derived scenarios from the intent and drove each against the real product: the classifier function signal_crew_provably_working() and a real fm-watch.sh watcher subprocess (via the suite's watch_bg harness). A healthy mate's unmarked working/paused progress is absorbed (no exit, no durable wake, suppressor advanced); decisions, blockers, terminal outcomes including an unmarked resolved:, note:, both correlation-marker forms, and any unknown verb surface; a mate that is not provably healthy still surfaces routine progress; an ordinary crewmate is unaffected. A direct 12-case drive of the classifier confirmed the absorb/surface split independently and captured a reviewer-visible transcript. No worktree artifacts left behind; all scenarios passed.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Healthy mate's unmarked routine working:/paused: progress is absorbed and does not wake the primary ✅ pass live test_secondmate_routine_progress_absorbed_then_note_surfaced (real fm-watch.sh subprocess: no exit, empty out, empty .wake-queue, .seen-* advanced) + direct classifier drive routine-work/routine-paus/…
Parent-directed and terminal lines (needs-decision, blocked, done/failed, note, corr-marked, unknown verb) still surface from a busy mate ✅ pass live test_secondmate_status_routine_absorbed_routed_surfaced_classifier + direct drive: needs-dec/blocked/done/note/corr-bracket/corr-bare/unknown-verb = surface
Round-1 decision: an unmarked resolved: line from a healthy mate still wakes the primary ✅ pass live direct classifier drive 'working: routine / resolved: took A' = surface; asserted by the classifier test's resolved case
A mate not proven healthy still surfaces even routine working: progress ✅ pass live direct drive with idle crew-state verdict: unproven-work = surface; classifier test unproven branch
Ordinary (non-secondmate) crewmate status keeps the plain provably-working absorb, unaffected by the mate rule ✅ pass live test_secondmate_status_routine_absorbed_routed_surfaced_classifier crew.meta kind=ship branch
End-to-end watcher: routine progress absorbed, then a later note: from the same busy mate surfaces and is durably queued ✅ pass live test_secondmate_routine_progress_absorbed_then_note_surfaced: watcher exits on the appended note:, prints 'signal: .../mate.status', enqueues it in .wake-queue
Evidence: secondmate absorb/surface behavior transcript

Source: secondmate absorb/surface behavior transcript

HEALTHY mate: working/paused absorbed; resolved/needs-decision/blocked/done/note/corr-marked/unknown-verb all surface. UNPROVEN mate: working surfaces. 12/12 cases matched expectation.

signal_crew_provably_working() driven directly against a kind=secondmate .status
stream (real bin/fm-classify-lib.sh, fake fm-crew-state verdict).
absorb = benign, no primary wake.  surface = primary must read it.

--- HEALTHY mate (provably working) ---
OK   routine-work  expect=absorb  got=absorb  | working: step 2 of 5
OK   routine-paus  expect=absorb  got=absorb  | paused [at=1]: waiting on CI
OK   work+paused   expect=absorb  got=absorb  | working: step 2 / paused: waiting
OK   resolved      expect=surface got=surface | working: routine / resolved: took A   (round-1 fix: unmarked resolved still wakes)
OK   needs-dec     expect=surface got=surface | needs-decision [key=k]: pick
OK   blocked       expect=surface got=surface | blocked [key=k]: need access
OK   done          expect=surface got=surface | done [at=1]: shipped
OK   note          expect=surface got=surface | note: routed reply for parent
OK   corr-bracket  expect=surface got=surface | working [corr=...]: mirror
OK   corr-bare     expect=surface got=surface | resolved corr=... [key=k]: answered
OK   unknown-verb  expect=surface got=surface | shrug: unknown verb

--- UNPROVEN mate (idle / not provably healthy) ---
OK   unproven-work expect=surface got=surface | working: step 3 of 5

All 12 cases matched expectation.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-classify-lib.sh:2462 - The routine-absorb verb set is {working, paused, resolved}, but the User intent names only "unmarked routine working: and paused: progress" as absorbable and lists "terminal outcomes" among what must keep surfacing. Adding resolved (also codified in docs/architecture.md:86 and the tests) is a component the stated intent does not require: a secondmate that self-closes a decision with a bare, unmarked resolved: ... line (the needs-decision already surfaced in a prior, classified span) will now be absorbed and will not wake the primary. It is defensible - the codebase already treats resolved as nonterminal (status_is_captain_relevant, fm-classify-lib.sh:221) and any corr-marked resolved corr=... still surfaces via the *corr=* guard at line 2459 - but it exceeds the intent's named absorb set. Confirm whether unmarked resolved: should absorb, or narrow the arm to working+paused only. The remedy is a scope decision, not a mechanical fix.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Healthy mate's unmarked routine working:/paused: progress is absorbed and does not wake the primary ✅ pass live test_secondmate_routine_progress_absorbed_then_note_surfaced (real fm-watch.sh subprocess: no exit, empty out, empty .wake-queue, .seen-* advanced) + direct classifier drive routine-work/routine-paus/…
Parent-directed and terminal lines (needs-decision, blocked, done/failed, note, corr-marked, unknown verb) still surface from a busy mate ✅ pass live test_secondmate_status_routine_absorbed_routed_surfaced_classifier + direct drive: needs-dec/blocked/done/note/corr-bracket/corr-bare/unknown-verb = surface
Round-1 decision: an unmarked resolved: line from a healthy mate still wakes the primary ✅ pass live direct classifier drive 'working: routine / resolved: took A' = surface; asserted by the classifier test's resolved case
A mate not proven healthy still surfaces even routine working: progress ✅ pass live direct drive with idle crew-state verdict: unproven-work = surface; classifier test unproven branch
Ordinary (non-secondmate) crewmate status keeps the plain provably-working absorb, unaffected by the mate rule ✅ pass live test_secondmate_status_routine_absorbed_routed_surfaced_classifier crew.meta kind=ship branch
End-to-end watcher: routine progress absorbed, then a later note: from the same busy mate surfaces and is durably queued ✅ pass live test_secondmate_routine_progress_absorbed_then_note_surfaced: watcher exits on the appended note:, prints 'signal: .../mate.status', enqueues it in .wake-queue
  • FM_TEST_ONLY=test_secondmate_status_routine_absorbed_routed_surfaced_classifier bash tests/fm-watch-triage.test.sh
  • FM_TEST_ONLY=test_secondmate_routine_progress_absorbed_then_note_surfaced bash tests/fm-watch-triage.test.sh (drives a real fm-watch.sh subprocess)
  • FM_TEST_ONLY=test_secondmate_status_note_surfaced_despite_busy_agent bash tests/fm-watch-triage.test.sh
  • FM_TEST_ONLY=test_secondmate_buried_block_wakes_despite_busy_agent bash tests/fm-watch-triage.test.sh
  • FM_TEST_ONLY=test_self_announced_close_after_fold_still_surfaces_folded_secondmate_lines bash tests/fm-watch-triage.test.sh
  • FM_TEST_ONLY=test_signal_crew_provably_working_classifier bash tests/fm-watch-triage.test.sh
  • Direct drive of signal_crew_provably_working() over 12 status-line cases against real bin/fm-classify-lib.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…replies

Fixes kunchenguid#2959

A kind=secondmate task's status signal was never absorbable, so a healthy
mate's routine working: and paused: appends woke the primary every time.
signal_crew_provably_working now reads the mate's lines new since the
watcher's classified position: a decision, blocker, terminal outcome, note:,
correlation-marked line, or unknown verb still surfaces regardless of busy
evidence, while unmarked working:, paused:, and resolved: fall through to the
same provably-working absorb an ordinary crewmate gets.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: whole thread read (body; linked #2959 + prior stamps). Diff + green CI reviewed against main 3c14a549b7dcea7b0e9ad36611c3a84d62e28b21.

Verdict: merge · contract-class: restore · Firstmate flag: no · closes #2959: yes

Tip check: main signal_crew_provably_working still returns 1 unconditionally for every kind=secondmate .status append. Diff adds _fm_secondmate_status_new_lines_routine absorbing only unmarked working:/paused: since the classified offset when the mate is provably working; decisions/blockers/terminals/note:/corr=/unknown verbs still surface. Narrower than the issue's aspirational resolved: absorb (keeps resolved: waking) — still restores the broken default path titled in #2959.

VISION.md per-rule:

  • One captain / peace of mind: aligns — stops routine secondmate churn from waking primary (token + attention).
  • Authority explicit: aligns — no new autonomy grant.
  • Scripts own mechanics: aligns — deterministic verb/marker read in classify-lib.
  • Restart / Delegation: aligns — event-driven supervision contract restored.
  • Fleet / Scope: aligns — watcher classifier only; no new surface.

CI CLEAN (19 checks). Squash-merging.

@kunchenguid
kunchenguid merged commit 97365aa into kunchenguid:main Sep 25, 2026
19 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @karotkriss — really appreciate you taking the time on this.

mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…kunchenguid#5535)

* fix(bin): absorb routine second-mate progress while surfacing routed replies

Fixes kunchenguid#2959

A kind=secondmate task's status signal was never absorbable, so a healthy
mate's routine working: and paused: appends woke the primary every time.
signal_crew_provably_working now reads the mate's lines new since the
watcher's classified position: a decision, blocker, terminal outcome, note:,
correlation-marked line, or unknown verb still surfaces regardless of busy
evidence, while unmarked working:, paused:, and resolved: fall through to the
same provably-working absorb an ordinary crewmate gets.

* no-mistakes(review): narrow secondmate routine absorb to working and paused
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…kunchenguid#5535)

* fix(bin): absorb routine second-mate progress while surfacing routed replies

Fixes kunchenguid#2959

A kind=secondmate task's status signal was never absorbable, so a healthy
mate's routine working: and paused: appends woke the primary every time.
signal_crew_provably_working now reads the mate's lines new since the
watcher's classified position: a decision, blocker, terminal outcome, note:,
correlation-marked line, or unknown verb still surfaces regardless of busy
evidence, while unmarked working:, paused:, and resolved: fall through to the
same provably-working absorb an ordinary crewmate gets.

* no-mistakes(review): narrow secondmate routine absorb to working and paused
ashkonmousavi added a commit to ashkonmousavi/firstmate that referenced this pull request Sep 26, 2026