Skip to content

fix(bin): refuse unavailable backend adapters before sourcing - #5382

Merged
kunchenguid merged 4 commits into
kunchenguid:mainfrom
Lakescape:codex/fm-backend-adapter-precheck-20260923
Sep 23, 2026
Merged

kunchenguid merged 4 commits into
kunchenguid:mainfrom
Lakescape:codex/fm-backend-adapter-precheck-20260923

Conversation

@Lakescape

Copy link
Copy Markdown
Contributor

Intent

Nate wants First Mate cleaned up and current while preserving unlanded work. Port only the proven missing backend-adapter readable-file precheck from preserved local commit 1151849 onto current upstream, with executable regression proof; do not change OMP posture, raw-launch policy, Orca composite-ID policy, dirty worktrees, session ownership, or merge authority. Keep this one narrow safety slice and report exact gates.

What Changed

  • Updates fm_backend_source to resolve the adapter path once and reject missing or unreadable backend adapter files before dot-sourcing them.
  • Adds a focused regression that verifies unavailable adapters fail nonzero, preserve the EXIT-trap failure status, and stop lifecycle continuation.
  • Adds targeted FM_TEST_ONLY support for the backend suite and runs the adapter-file regression in CI under stock /bin/bash, expecting the two backend precheck cases.

Risk Assessment

⚠️ Medium: The change is narrow and appears to preserve the intended fail-closed behavior, but the newly introduced precheck can make the exact protected failure mode silent on real caller paths.

Testing

Targeted validation passed: stock macOS /bin/bash 3.2 exercised the new missing and unreadable adapter regression, the CLI transcript demonstrates the end-user shell failure mode without lifecycle continuation, the workflow YAML consumer test passed, and the full fm-backend subject passed after hermetic test-harness fixes; no UI artifact was applicable because this is shell/CI behavior.

Evidence: Stock Bash adapter precheck regression after fixes

Source: Stock Bash adapter precheck regression after fixes

cwd: ~/.no-mistakes/worktrees/90205a2052fe/01M36BTMYFKG32ZXJEPC36VSQ2
head: 37d9831f5ae4d8c2cb80c34ede6c376a04da3a15
status:
 M tests/fm-backend.test.sh
command: /bin/bash --version | head -1
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin25)

command: FM_TEST_ONLY=test_backend_source_requires_adapter_file FM_TEST_BASH=/bin/bash /bin/bash tests/fm-backend.test.sh
ok - fm_backend_source: missing adapter fails before lifecycle continuation
ok - fm_backend_source: unreadable adapter fails before lifecycle continuation
command_exit=0
Evidence: CLI behavior demo for missing/unreadable adapter precheck

Source: CLI behavior demo for missing/unreadable adapter precheck

cwd: ~/.no-mistakes/worktrees/90205a2052fe/01M36BTMYFKG32ZXJEPC36VSQ2
head: 37d9831f5ae4d8c2cb80c34ede6c376a04da3a15
status:
 M tests/fm-backend.test.sh
shell: GNU bash, version 3.2.57(1)-release (arm64-apple-darwin25)

control: existing tmux adapter loads and exposes fm_backend_tmux_capture
adapter_loaded=tmux

precheck cases through fm_backend_source under set -e:
case=missing shell_exit=1 trap_status=1 continuation=absent stderr=
case=unreadable shell_exit=1 trap_status=1 continuation=absent stderr=
Evidence: Backend subject test after hermetic harness fixes

Source: Backend subject test after hermetic harness fixes

cwd: ~/.no-mistakes/worktrees/90205a2052fe/01M36BTMYFKG32ZXJEPC36VSQ2
head: 37d9831f5ae4d8c2cb80c34ede6c376a04da3a15
status:
 M tests/fm-backend.test.sh
command: bin/fm-test-run.sh tests/fm-backend.test.sh
FM_TEST_BEGIN 2026-09-23T05:54:32Z tests/fm-backend.test.sh family=backend-dispatch expected_gate_skip=none
ok - fm_backend_name: FM_BACKEND env > config/backend > default tmux
ok - fm_backend_detect: no markers -> undetected, HERDR_ENV=1 -> herdr, $TMUX -> tmux, CMUX_WORKSPACE_ID -> cmux, nested combinations resolve innermost-first
ok - fm_backend_detect: falls back to __CFBundleIdentifier=com.cmuxterm.app when CMUX_WORKSPACE_ID is absent (signal bundle-id; foreign bundle ids rejected)
ok - fm_backend_detect: the cmux fallback signals are macOS-only (inert on a non-Darwin uname)
ok - fm_backend_detect: an inherited cmux bundle id never outranks $TMUX or HERDR_ENV (tmux/herdr-inside-cmux false positive absorbed)
ok - fm_backend_detect: ancestry fallback matches the lsappinfo-resolved (bundle-id) cmux app pid in the parent chain
ok - fm_backend_detect: ancestry fallback matches a bundle-shaped cmux comm path at any install location when lsappinfo cannot resolve a pid
ok - fm_backend_detect: ancestry fallback stops undetected at launchd (a reparented tmux server never reaches cmux)
ok - fm_backend_name: a fallback-detected cmux prints a NOTICE naming the fallback signal; the primary-marker notice is unchanged
ok - fm_backend_name: verified Herdr and tmux stay silent while experimental cmux remains loud
ok - fm_backend_name: an explicit FM_BACKEND or config/backend setting always wins over runtime auto-detection, including an ambient cmux marker
ok - fm_backend_validate: implemented adapters accepted, unknown and blocked codex-app backends refused loudly
ok - zsh: fm_backend_source recognizes known backends and rejects unknown ones
ok - bash: fm_backend_source recognizes known backends and rejects unknown ones
ok - fm_backend_source: missing adapter fails before lifecycle continuation
ok - fm_backend_source: unreadable adapter fails before lifecycle continuation
ok - fm_backend_validate_spawn: all implemented lifecycle backends are spawn-supported
ok - fm_meta_get / fm_backend_of_meta: read last key=value and default backend to tmux
ok - fm_backend_resolve_selector: session:window literal, exact task id first, legacy fm-<id> label fallback, ad hoc bare name via tmux list-windows
ok - fm_backend_of_selector: exact task ids, legacy fm-<id> labels, and matching explicit targets inherit metadata backend
ok - fm-send.sh: explicit tmux targets are verified; text types once and submits with Enter
ok - fm-peek.sh: capture-pane invocation and output are byte-identical old vs new
ok - fm-spawn.sh: a project reached through a symlinked prefix (e.g. macOS /tmp -> /private/tmp) does not trip the isolation guard's false refusal
ok - fm-teardown.sh: treehouse return remains compatible while tmux cleanup uses exact selectors
ok - fm-spawn.sh --backend bogus is refused loudly
ok - fm-spawn.sh --backend codex-app is refused
ok - fm-spawn.sh honors FM_BACKEND and refuses an unimplemented value loudly
ok - fm-spawn.sh: an explicit --backend tmux resolves silently and writes no backend= (missing means tmux)
ok - fm-spawn.sh: explicit --backend tmux wins over an ambient HERDR_ENV=1 auto-detect marker
ok - fm-spawn.sh: auto-detect resolves nested tmux-in-herdr to tmux and stays silent end to end
FM_TEST_END 2026-09-23T05:55:09Z tests/fm-backend.test.sh exit=0 duration_ms=37598 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=37652
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=1 duration_ms=37598 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-backend.test.sh duration_ms=37598
command_exit=0
Evidence: CI workflow semantic contract test

Source: CI workflow semantic contract test

cwd: ~/.no-mistakes/worktrees/90205a2052fe/01M36BTMYFKG32ZXJEPC36VSQ2
head: 37d9831f5ae4d8c2cb80c34ede6c376a04da3a15
command: bin/fm-test-run.sh tests/fm-ci-workflow.test.sh
FM_TEST_BEGIN 2026-09-23T05:49:44Z tests/fm-ci-workflow.test.sh family=unclassified expected_gate_skip=none
ok - CI matrices cover every executable serial lane and canonical lint root exactly once
ok - a newer push to one PR supersedes that PR's in-flight CI
ok - distinct PRs get distinct concurrency groups
ok - every main push keeps its own group and is never cancelled
ok - every ci.yml job carries a finite timeout
ok - every ci.yml job belongs to one of the three timeout tiers
ok - fast tier jobs share one 5 minute tripwire
ok - normal tier jobs share one 30 minute budget
ok - Herdr keeps a 20 minute step tripwire under a 75 minute job backstop
FM_TEST_END 2026-09-23T05:49:47Z tests/fm-ci-workflow.test.sh exit=0 duration_ms=3050 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=3107
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=3050 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-ci-workflow.test.sh duration_ms=3050

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ⚠️ tests/fm-backend.test.sh:538 - The required regression proof is Bash-3.2-specific, but this new case invokes plain bash -c, so on the normal Ubuntu/modern-Bash lanes the test can pass before the fix because Bash 5 already exits nonzero for the missing dot-source path. The existing stock macOS Bash CI job does not run tests/fm-backend.test.sh, so no source-owned gate currently forces this new case through the affected Bash 3.2 shell. Pin this case to the stock-Bash path in that lane, or add a focused FM_TEST_ONLY hook and invoke it from the existing macOS stock-Bash job.

🔧 Fix: Gate backend precheck under stock Bash
1 warning still open:

  • ⚠️ bin/fm-backend.sh:624 - The new adapter precheck returns failure for a known-but-missing or unreadable adapter without printing any diagnostic. A concrete caller path is fm-spawn.sh: after fm_backend_validate_spawn &#34;$BACKEND&#34; succeeds, fm_backend_source &#34;$BACKEND&#34; || exit 1 exits silently when the tracked adapter file is absent or unreadable. Since this change is specifically protecting missing backend prerequisites, emit a stderr refusal naming the adapter before returning.
✅ **Test** - passed

✅ No issues found.

  • Verified checkout context for target 37d9831f5ae4d8c2cb80c34ede6c376a04da3a15 against base e7cb23e6a7c4882cea83717a8fa80c2e6d7292d3 and inspected the changed surface: .github/workflows/ci.yml, bin/fm-backend.sh, and tests/fm-backend.test.sh.
  • FM_TEST_ONLY=test_backend_source_requires_adapter_file FM_TEST_BASH=/bin/bash /bin/bash tests/fm-backend.test.sh
  • Manual CLI demo using /bin/bash to source bin/fm-backend.sh, load an existing tmux adapter successfully, then point FM_BACKEND_LIB_DIR at missing and unreadable backends/tmux.sh fixtures under set -e and verify shell_exit=1, trap_status=1, and continuation=absent.
  • bin/fm-test-run.sh tests/fm-ci-workflow.test.sh
  • Diagnostic triage while repairing the backend subject harness: FM_TEST_ONLY=test_spawn_symlinked_project_prefix_avoids_false_refusal /bin/bash tests/fm-backend.test.sh, tasks-axi --version, and tasks-axi hold/update/mv --help.
  • bin/fm-test-run.sh tests/fm-backend.test.sh after the test-harness fixes.
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Suppress intentional child Bash ShellCheck warning
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Read in full (body; no comments/reviews). Inspected tip 484ca54757227f6001c9d1ccab610ef96fb83267 vs main.

Tip vs main: fm_backend_source now refuses a missing/unreadable adapter file before source, so Bash 3.2 cannot enter an EXIT trap with status 0 and continue a destructive lifecycle. ci.yml only adds a stock /bin/bash 3.2 regression invocation for that precheck (plus harness hermetic fixes in the same test file). Unconfigured path: unavailable backend adapters fail closed before sourcing.

VISION (per-rule):

  1. One captain, one interface — aligns (honest failure, no silent continue).
  2. Authority explicit — aligns / N-A.
  3. Scripts own mechanics — aligns.
  4. Restart is a non-event — aligns.
  5. Delegation with a spine — aligns (strengthens refusal).
  6. Fleet outlives vendor — aligns.
  7. Scope — aligns.

Contract-class: restore — existing backend-source contract already required a real adapter; tip closes the Bash 3.2 status-loss hole on that path.

Gates: attestation MATCH. Fork CI/NM 35825127962 / 35825127991 approved this pass after diff review (ci.yml change is test-only; no sudo/pull_request_target/unpinned actions/secrets). Waiting on green checks before merge. No Firstmate flag.

@kunchenguid
kunchenguid merged commit 2efa581 into kunchenguid:main Sep 23, 2026
19 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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

dscott98 added a commit to Simplifying-Cloud/firstmate that referenced this pull request Sep 23, 2026
* feat: cut validation token cost without lowering review rigor

Classify documentation-only changes as direct-PR surfaces on
no-mistakes-prod-only projects, fold small pre-merge follow-ups into
the open task's branch for one validation of the final head, document
the machine-global per-purpose model routing no-mistakes supports
(economical agent_config default with strong review_agents pins and its
unsupported per-step boundary), and pin the repo-side boundary with a
deterministic contract test.

* no-mistakes(review): Prioritize full validation over every lighter delivery category

* no-mistakes(document): Remove machine-specific claims from validation routing documentation

* fix: submit stuck inbox doorbells instead of skipping them (kunchenguid#5374)

* fix(bin): submit our own stuck doorbell instead of skipping every later ring

* no-mistakes(review): Confirm and retry Enter once on stuck-doorbell submit

* no-mistakes(document): Clarify doorbell retry and pending-composer documentation

* docs: state the captain-approved model-routing boundary precisely

Strong models serve review and review fixes; economical models serve all
other validation work and fixes, which is the approved policy rather than
an unsupported claim that difficult non-review fixes get stronger models.

* feat: add opt-in fleet activity ledger (kunchenguid#5375)

* feat(bin): add the opt-in fleet activity ledger

Homes that create config/fleet-ledger get an append-only JSONL file,
state/fleet-ledger.jsonl, recording task.dispatched, task.status,
task.merged, and task.cleaned_up so outside tools can follow a fleet.
With the flag absent each producer does one file test and nothing else.
docs/fleet-ledger.md owns the record contract and its documented limits.

* no-mistakes(review): Record task.status text verbatim after the first colon

* no-mistakes(document): Clarify fleet ledger status and setup documentation

* no-mistakes(ci): Fixed a timing race in tests/fm-pi-branch-extension.test.sh: the replacement-wake test now waits for the prompt to start before releasing it. The focused test passed twice, and git diff --check passed

* fix: validate public follow-up deliverables and wake on rejection (kunchenguid#5352)

* fix(bin): format, validate, and surface public-followup deliverables

brief pre-fills report_path=data/<work-id>/report.md and states the accepted
format of every value it cannot know instead of a bare <value> placeholder.
fm-public-followup-emit.sh refuses a deliverable tasks-axi would refuse, in
both the direct and staged destinations, naming the key, value, and format.
consume records the specific deliverable, outcome, or missing key behind a
tasks-axi refusal, and each refusal wakes the owning home once through the
existing relay poll.

* no-mistakes(review): refuse emits missing a required deliverable in both destinations

* no-mistakes(review): require promised deliverables and keep rejections recoverable

* no-mistakes(review): mirror tasks-axi's canonical pull request URL rule

* no-mistakes(review): keep a rejection wake whose line cannot be read

* no-mistakes(review): key emit-time rules on the promise, not the outcome

* no-mistakes(review): bound deliverable keys and values as tasks-axi does

* no-mistakes(review): state rejection wakes as at-least-once and pin it

* no-mistakes(review): enforce the promised contract tasks-axi holds at emit

* no-mistakes(review): stop inferring a staged promise from its outcome

* no-mistakes(document): Refresh public follow-up documentation

* no-mistakes(ci): Fixed both CI flakes. Watcher cleanup is now installed before singleton acquisition, preventing timeout races from leaving stale locks while preserving recovery-failure evidence. Bearings render fixtures now publish a valid isolated Lavish session store and retire each listener after rendering, eliminating false unowned-source races. Verified with checkpoint stress, fm-watch-checkpoint, fm-watcher-lock, repeated fm-bearings-board-render runs, project lint, syntax checks, and git diff checks

* Revert unrelated CI auto-fix edits to the watcher and bearings board test

The CI step's automatic repair changed bin/fm-watch.sh and
tests/fm-bearings-board-render.test.sh to chase two intermittent CI
failures that also occur on main and are not part of this change. Restore
both files so this branch carries only the public-followup deliverable fix.

* no-mistakes(review): Refuse a repeated --deliverable key at emit argument parsing

* no-mistakes(document): Clarify public-followup validation and rejection-wake documentation

* feat: add Devin CLI crewmate and scout adapter (kunchenguid#5380)

* Add verified Devin CLI worker adapter

* no-mistakes(review): Drop Devin resolver refusal and launch marker

* no-mistakes(review): Verify devin in bootstrap, fold kind rule, update docs

* no-mistakes(document): Document Devin sidecar, resume, and worker-only facts

* no-mistakes(document): Document Devin interrupt, liveness anchor, composer signals

* fix(control): never pair Devin interrupt presses on an idle agent

A fast double Escape on an idle Devin opens its /revert picker, where Enter
reverts file changes. fm-control now sends the second press only after the
first renders Devin's 'esc again to interrupt' armed hint, never sooner than
0.5 s, closes a revert picker a mistimed press opened with one Escape, and
refuses to type the exit command while that picker is open. An unarmed
interrupt reports cancel=not-running and leaves the busy record untouched.

* fix(devin): disable Claude hook import and commit attribution for workers

The per-task Devin config now forces read_config_from.claude=false, so a
worker no longer runs the user's or project's Claude Code hooks (including
Herdr's Claude agent-state hook), and attribution=false, so Devin adds no
Co-Authored-By trailer or Generated-with line to commits and PRs.

* test(devin): extend live guard and record Herdr and revert-picker evidence

The credentialed live guard now fails if an imported Claude Code hook runs,
if the worker's commit carries Devin attribution, if an idle interrupt sends
more than one press or opens the revert picker, or if an open picker lets
exit through or is closed with a revert. The Devin reference, agent-control
doc, and verification records carry the 2026-09-22 tmux and Herdr lab results,
including the Herdr exit refusal.

* no-mistakes(document): Correct Devin documentation links and lifecycle guidance

---------

Co-authored-by: Denis Beliaev <[email protected]>

* fix(bin): recognize passed-with-skips as a passing outcome (kunchenguid#5322)

fm-crew-state classifies the no-mistakes outcome 'passed-with-skips' as
unknown, so a finished worker awaiting merge is re-alerted as stale. The
same blind spot lets fm-teardown's pre-teardown terminal-run check refuse
a legitimate abort race that lands on this outcome.

Map passed-with-skips to done in crew-state resolution, keeping the
skipped publication/CI verification visible in the detail rather than
reporting a clean pass, and recognize it as terminal during teardown.

* fix(bin): refuse unavailable backend adapters before sourcing (kunchenguid#5382)

* fix: refuse missing backend adapter before source

* no-mistakes(review): Gate backend precheck under stock Bash

* no-mistakes(document): Clarify adapter precheck docs

* no-mistakes(lint): Suppress intentional child Bash ShellCheck warning

* test: repair base-red liveness, export-DOM, and wake-queue self-tests (kunchenguid#5338)

* fix(test): repair tmux liveness and calm follow-up loaded_off regressions

Both self-tests fail on untouched main on a host whose coreutils are a
multicall binary and whose Chrome has no pre-warmed profile, and each failure
masks the other's file.

tests/fm-tmux-agent-liveness.test.sh - the stand-in harness processes were
symlinks to the host's `sleep`. A single-purpose `sleep` runs happily under
another name, but a multicall coreutils binary (uutils or busybox) resolves its
applet from argv[0]: `claude-link -> sleep` invoked under the harness name runs
the wrong applet and exits immediately, so no foreground process exists and
every positive case reads not-alive ("last verdict for liveness:agent was
missing (expected alive); title=sh comms=[sh ]"). Build a dedicated spinner as
the stand-in target, exactly the way the version-string case already builds its
executable, and require the fallback target to demonstrably survive the rename
before using it. Every assertion is untouched; the stand-in identity signal is
unchanged (the kernel still records the symlink name as the executable
identity).

tests/fm-calm-pi-extension.test.sh - render_export_dom pinned a brand-new
`--user-data-dir` per attempt. On Google Chrome for Testing 151.0.7922.34 that
pristine profile makes Chrome's first-run initialization never complete: the
browser and its renderers start, but --dump-dom never returns, so all three
bounded attempts end exit=0 timed_out=yes bytes=0 and the DOM assertions never
run ("could not render calm-mode HTML export DOM"). Chrome's own profile
creation under a fresh HOME renders the same document in about a second, so the
helper now gives Chrome a private per-attempt HOME instead of the explicit
profile flag. Each attempt still gets an isolated profile, and every DOM
assertion is unchanged.

Root-cause evidence: a pristine --user-data-dir with `--headless=new
--dump-dom` had not returned after 150s, while the same command with an empty
HOME and no --user-data-dir returned the full DOM in ~1s, and reusing an
already-populated profile also returned it in ~1s. The render failure masked
the rest of the file: with it repaired, the Pi follow-up loaded_off case passes
unmodified against an installed @earendil-works/pi-coding-agent package.

These two failures block downstream validation of every lane on hosts with
multicall coreutils or a fresh Chrome profile.

Verification:
- timeout 300 bash tests/fm-tmux-agent-liveness.test.sh -> exit 0, 16 assertions ok
- timeout 700 bash tests/fm-calm-pi-extension.test.sh -> exit 0, 13 assertions ok,
  including the Pi operational follow-up loaded_off case
- bash -n and shellcheck clean on both touched files
- rest of tests/: bin/fm-test-run.sh --all bounded by timeout 900 completed 17 files with 0 failures (fm-afk-contract.test.sh through fm-backend-herdr-launcher-workspace-e2e.test.sh), then the bound cut off the 18th (fm-backend-herdr-presentation-e2e.test.sh, a real-herdr-gated lab test) with no failure recorded

* fix(test): give wake-queue observation checkpoints the alerting ceiling

tests/fm-wake-queue.test.sh's secondmate stall case runs bounded foreground
watcher checkpoints whose job is to record an observation, with the alerting
checkpoint that follows asserting the stall. A checkpoint's exit publishes a
downtime marker, and the next checkpoint consumes it only by reaching the end of
the watcher's poll loop, where the recovery surfacing runs after the stall tick;
the observation itself is recorded by that same stall tick. On a loaded host a
1s ceiling sits under the cost of that iteration (which includes a pane capture
in the active-turn gate), so the observation was never recorded, the downtime
marker stayed pending, and the alerting checkpoint surfaced
`check: rearm-resurface` instead of the stall it asserts:

  not ok - a foreign queue with no progress did not alert: check: rearm-resurface
  not ok - a frozen reprovisioned queue generation was hidden: check: rearm-resurface

Give the observation checkpoints that feed a later alert the same 4s ceiling the
file already documents for alerting checkpoints. The ceiling is only a bound - a
checkpoint still returns on its first actionable wake - so no assertion is
weakened, and the quiet windows get longer, not shorter.

* no-mistakes(document): docs: correct export-DOM Chrome render root cause

* no-mistakes(review): Isolate Chrome profile on macOS, dedupe tmux CC_BIN lookup

* chore: re-trigger fork workflow approval for triage

---------

Co-authored-by: Captain <[email protected]>
Co-authored-by: kunchenguid <[email protected]>

* fix: keep watcher status classification bounded to new log spans (kunchenguid#5383)

* fix(bin): classify a status span without re-folding the whole log

A watcher poll could take minutes, so its liveness beacon aged past the
guard's 300s grace and the Stop auto-arm reported the watcher down. On the
main home, cycles ended with beacon_age 91-235s while healthy and 534-706s
while the laptop was CPU-starved.

Cause: whenever a newly appended status span held a keyed needs-decision
or blocked line, status_span_first_actionable_record re-read and re-folded
the ENTIRE log to decide whether that opening was still live, forking
several subshells per line. On a remote second mate's mirrored parent
channel (1.2MB, ~2300 lines) that is 13-20k subshells, about 17s per log
per classification when idle, paid by every signal and heartbeat scan.

Nothing regressed recently: subshell counts per classification were
20,272 from kunchenguid#3268 (2026-08-29, which introduced the whole-log fold) and
13,188 from kunchenguid#3753 onward through HEAD. The cost grew with log size, since
parent-channel logs only grow.

Fix: fold only the captured span. An accepted opening does not depend on
earlier lines and only later lines close or supersede it, and every later
line lies inside the span, so the span fold names the same live openings
at a cost bounded by the span. Old and new classification outputs are
byte-identical across 51 span offsets of real-shaped secondmate and ship
logs.

A real-watcher regression test records every read the classification
makes through the span-reader seam and asserts none reaches before the
classified offset; it fails on the old code (5,157 bytes read from
offset 0 to classify an 84-byte span).

* no-mistakes(document): Clarify span classification and watcher regression coverage

* test: close pr-check watcher test gaps (original flake already fixed by kunchenguid#5362 and kunchenguid#4878) (kunchenguid#5381)

* test: fix watcher timing flakes in fm-pr-check-security

The bounded watcher's hang guard now counts only the watcher's own time: a
case marks the intervals where it holds the watcher on injected work or makes
it wait on concurrent work, and those no longer count against its budget. The
budget itself stays at main's sixty seconds. The helper also stops forcing a
one-second per-check timeout, which killed a correct merged poll whenever that
poll took longer than a second, so the watcher only retried it or exited on a
later check's wake without the merge.

The concurrent-publication case pauses the guard while its arming is in
flight, and its task now sorts before the contributions observer the arming
also registers, so the watcher stops on the poll under test before running
that unrelated fleet snapshot. The case also prints the watcher's stderr when
it fails.

The replacement case pauses the guard while the re-arm runs inside the
watcher, runs that injected arming with the fixture root every other arming
here uses, and waits on the replacement merge's process instead of a
two-second cap. Merged-poll runs retire the contributions observer before the
watcher starts, since no case here exercises it.

The returned-descendant case no longer races a four-second sleep or a TERM
landing at an arbitrary point in the watcher's idle loop: its descendant holds
until killed, and a second check in the same cycle witnesses that it was
drained and stops the watcher.

* no-mistakes(ci): Reproduced the intermittent board-render failure. Its Lavish stub listed an open session but omitted the session-state record required by the listener, so the build could race the listener’s exit. Added matching fixture state; the affected suite passed three consecutive runs, and shell syntax and diff checks passed

* Revert "no-mistakes(ci): Reproduced the intermittent board-render failure. Its Lavish stub listed an open session but omitted the session-state record required by the listener, so the build could race the listener’s exit. Added matching fixture state; the affected suite passed three consecutive runs, and shell syntax and diff checks passed"

This reverts commit 6a59859.

* feat: record fleet status immediately and emit PR-ready events (kunchenguid#5385)

* feat: record task.pr_ready in the fleet ledger when a task PR is registered

* feat: record worker status lines in the fleet ledger as they are written

* no-mistakes(review): Keep worker status append failures and pass the resolved config to the ledger

* no-mistakes(review): Resolve relative config override before embedding in worker command

* no-mistakes(document): Clarify fleet ledger status capture timing

* test: synchronize foreign queue stall checks with watcher progress (kunchenguid#5386)

* test: synchronize foreign secondmate stall legs on the watcher's recorded observation

Each leg of test_secondmate_foreign_queue_stall_tracks_progress_and_alerts_once
ran the watcher under a 1s or 4s wall-clock checkpoint, but every later leg
depends on the progress observation the previous leg's watcher recorded. Under
load the watcher was killed before its first stall tick, the observation was
never written, and the next leg treated its own sighting as the first one, so
the stall alert never fired.

Run the watcher directly and end each leg on its observable outcome: the
progress marker recording the expected observation, or the watcher's own first
wake. Also move a comment orphaned above this test back to the drain liveness
test it describes.

* no-mistakes(review): Wait for full stall reset before stopping watcher leg

* test: isolate the bearings render fixture from the shared Lavish store (kunchenguid#5391)

The listener resolves its server from that store before it polls. Without a session for this board, it exits in the gap after the build has already sampled a live claim.

* fix(bin): prune a torn-down task's wake rows at teardown (kunchenguid#5390)

* fix(bin): prune a torn-down task's wake rows at teardown

Prune pending durable wake rows (.wake-queue) for a task when it is torn
down, clearing stale wakes for its target window, signal wakes for its status
or turn-ended files, and task-specific check wakes.

Fixes kunchenguid#3419.
Adjacent to kunchenguid#5252.

- bin/fm-wake-lib.sh: add fm_wake_queue_prune_task
- bin/fm-teardown.sh: call fm_wake_queue_prune_task in cleanup_firstmate_home_children and main teardown
- tests/fm-wake-queue.test.sh: add test_wake_queue_prune_task

* no-mistakes(document): docs: note teardown prunes a task's wake rows

---------

Co-authored-by: Captain <[email protected]>

* test: align portable test expectations with resolved host paths and fixture readiness (kunchenguid#5392)

* Make portable tests match resolved host paths

Summary:
- Match macOS full Node command paths by basename in the Gemini behavior test.
- Mirror symlink-resolved Nix PATH behavior and give the loaded-host race bounded headroom.

Testing:
- bin/fm-lint.sh
- bin/fm-test-run.sh tests/fm-on.test.sh tests/fm-gemini-harness.test.sh tests/fm-procevent.test.sh

Related:
- None

* no-mistakes(review): Mirror production PATH helper rules per directory group in tests

* no-mistakes(test): Wait for orphan runner start marker instead of fixed sleep

* no-mistakes(document): Clarify gemini ancestry test comment for versioned node comm

---------

Co-authored-by: Sandeep Salwan <[email protected]>

* no-mistakes(document): Correct capture inbox ownership reference

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Denis Beliaev <[email protected]>
Co-authored-by: Mickaël Rémond <[email protected]>
Co-authored-by: NATHAN Menkin <[email protected]>
Co-authored-by: blackxwhite88 <[email protected]>
Co-authored-by: Captain <[email protected]>
Co-authored-by: kunchenguid <[email protected]>
Co-authored-by: Sandeep Salwan <[email protected]>
Co-authored-by: Sandeep Salwan <[email protected]>
mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…nguid#5382)

* fix: refuse missing backend adapter before source

* no-mistakes(review): Gate backend precheck under stock Bash

* no-mistakes(document): Clarify adapter precheck docs

* no-mistakes(lint): Suppress intentional child Bash ShellCheck warning
0x7067 added a commit to 0x7067/firstmate that referenced this pull request Sep 27, 2026
…link fix

Extend the kunchenguid#5382 fm_backend_source pre-source guard with a `bash -n`
pre-parse: bash 3.2 + set -e fires the EXIT trap with $? = 0 on a failed
'. file' inside a function, so a present, readable but syntactically
broken adapter would still exit 0 through the same trap. A new
syntax-broken condition in test_backend_source_requires_adapter_file
covers it.

Also apply the fm-muse-harness AMFI symlink fix to the two sibling
suites: tests that cp $(command -v bash) under a fake harness name are
SIGKILLed at exec (rc 137) on macOS, while a symlink resolves to the
signed binary and still presents the renamed name to ps -o comm=.
RooseveltAdvisors pushed a commit to RooseveltAdvisors/firstmate that referenced this pull request Sep 29, 2026
…nguid#5382)

* fix: refuse missing backend adapter before source

* no-mistakes(review): Gate backend precheck under stock Bash

* no-mistakes(document): Clarify adapter precheck docs

* no-mistakes(lint): Suppress intentional child Bash ShellCheck warning