Skip to content

feat(bin): add persistent managed-approval failover for Codex and Claude - #6722

Merged
kunchenguid merged 43 commits into
kunchenguid:mainfrom
zestysoft:fm/fm-managed-approvals
Oct 23, 2026
Merged

kunchenguid merged 43 commits into
kunchenguid:mainfrom
zestysoft:fm/fm-managed-approvals

Conversation

@zestysoft

@zestysoft zestysoft commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Intent

The maintainer re-reviewed our pull request: the head went fully green, all 19 checks including the rerun, and their attestation binds it. Then main moved again - another contribution added a new key to the same spawn-script list - so the pull request now conflicts on one line. The maintainer deliberately did not resolve it on our branch, and wrote out the resolution they want: keep both sets of keys, including the new one. We need one clean rebase so they can merge. Pull request: #6722

What that pull request is: "feat: add persistent managed-approval failover for Codex and Claude" (fixes #6716). Both worker runtimes keep their bypass defaults (Claude --dangerously-skip-permissions, Codex --dangerously-bypass-approvals-and-sandbox when the mode file is absent or bypass). It adds an opt-in config/codex-approval-mode (bypass default, approve-for-me) alongside the existing config/claude-permission-mode (bypass default, auto); invalid values refuse before spawn; ships, scouts, secondmates and relaunches honor them; both files are primary-authoritative in secondmate homes; and bin/fm-approval-failover.sh saves the setting and relaunches a worker only after the captain explicitly approves, once firstmate has observed a defeated bypass.

The conflict: the OpenCode 2 contribution (#7336) added opencode_version to the relaunch owned-key list in preserve_relaunch_meta in bin/fm-spawn.sh, the same list this pull request adds approval_mode to. The resolution the maintainer wrote out keeps both keys: ... model effort opencode_version account account_provider busy_gen spawn_gen approval_mode traceparent ....

What Changed

  • bin/fm-spawn.sh now reads a new opt-in config/codex-approval-mode. It can be bypass (the default, which keeps --dangerously-bypass-approvals-and-sandbox) or approve-for-me (which uses --approve-for-me). This works like the existing config/claude-permission-mode. A bad value or an unreadable file stops the spawn before anything is created. Ships, scouts, secondmates and relaunches all use the setting. The chosen mode is saved as approval_mode in the task record. That key is added to the relaunch owned-key list in preserve_relaunch_meta next to opencode_version from main: ... opencode_version account account_provider busy_gen spawn_gen approval_mode traceparent ....
  • New bin/fm-approval-failover.sh apply <task-id>. Firstmate must first see a bypass fail, and the captain must explicitly approve. Then the script writes the fallback setting (approve-for-me for Codex, auto for Claude) with an atomic link, only if no setting file exists yet. It then interrupts and relaunches the worker through fm-control. It refuses for remote workers, for workers that were not launched in bypass, for other harnesses, and when a setting already exists.
  • codex-approval-mode is added to the inheritable config set in bin/fm-config-inherit-lib.sh, so secondmate homes take both mode files from the primary. Docs and skills are updated (docs/configuration.md, docs/scripts.md, docs/verification/runtime-backends.md, harness/secondmate/recovery skills). Tests are added in tests/fm-approval-failover.test.sh, and the spawn-dispatch, secondmate-harness and Codex hook-layer tests are updated.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The rebased branch diff matches the already-green, attested head b0424b6 exactly, except for the one conflicted line. That line in preserve_relaunch_meta (bin/fm-spawn.sh:6187) now reads ... effort opencode_version account account_provider busy_gen spawn_gen approval_mode traceparent ..., which is the maintainer's written resolution. All helpers the new code uses still exist on the new main, and the opencode_version write path (bin/fm-spawn.sh:6221) is untouched. The top merge commit af8d45e has the same tree as e56bd7d, so it only adds history and changes no content.

Testing

First I checked the conflict line against the maintainer's written resolution. Then I ran the real fm-spawn spawn → relaunch flow for an OpenCode worker, a Codex approve-for-me worker and a Claude auto worker, each on its own throwaway FM home with fake tmux and harness binaries. After relaunch, each task record had exactly one opencode_version (OpenCode) or approval_mode (Codex/Claude) line, a fresh spawn_gen, and the unowned captain_note line still there. The Claude relaunch still launched with --permission-mode auto. The four focused spawn, control, secondmate and approval-failover test files all passed, which also covers the Codex launch flags. The code-reading check and the regression suite runs are recorded as untested for live purposes because they were not live drives.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Conflict resolution keeps both keys: owned list contains main's opencode_version and the PR's approval_mode in the maintainer's specified order ⏸️ untested no The prior payload established this only by reading code (bin/fm-spawn.sh:6187 diff against base), not a live drive; the runtime effect is covered by the live relaunch scenarios.
OpenCode worker relaunch: opencode_version recorded at spawn is carried over exactly once (no duplicate, no loss) ✅ pass live relaunch-owned-keys.txt: opencode relaunch exit=0, count opencode_version=1, new spawn_gen, launch still --standalone (2.x)
Codex approve-for-me worker relaunch: approval_mode is rewritten once and stays approve-for-me ✅ pass live relaunch-owned-keys.txt: codex relaunch exit=0, approval_mode=approve-for-me, count approval_mode=1
Claude auto worker relaunch: approval_mode stays auto and the relaunch launch still uses --permission-mode auto ✅ pass live relaunch-owned-keys.txt: claude relaunch exit=0, approval_mode=auto count=1, launch flags --permission-mode auto
Adversarial: a non-owned meta line (captain_note) survives relaunch while owned keys are not duplicated ✅ pass live relaunch-owned-keys.txt: count captain_note=1 and count spawn_gen=1 for all three harnesses
Existing spawn/relaunch/approval-failover/secondmate inheritance behavior unchanged after rebase ⏸️ untested no The prior payload established this only through automated test suites with fake harnesses (focused-tests.log total=4 failed=0), which is regression evidence, not a live product drive.
Evidence: Relaunch owned-key transcript (opencode/codex/claude spawn → relaunch, per-key counts)

Source: Relaunch owned-key transcript (opencode/codex/claude spawn → relaunch, per-key counts)

=== opencode: fresh spawn
spawn exit=0
harness=opencode
opencode_version=2.0.21
spawn_gen=s1792743723.93398.4097
=== opencode: relaunch
warning: /private/var/folders/vm/y9zpsxps43q2cvqmbq1xpqd00000gn/T/fm-spawn-dispatch-profile.uvREbg/scn-opencode/home/data/relaunch-opencode-k9/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned relaunch-opencode-k9 harness=opencode kind=ship mode=no-mistakes yolo=off window=firstmate:fm-relaunch-opencode-k9 worktree=/private/var/folders/vm/y9zpsxps43q2cvqmbq1xpqd00000gn/T/fm-spawn-dispatch-profile.uvREbg/scn-opencode/wt
relaunch exit=0
harness=opencode
opencode_version=2.0.21
spawn_gen=s1792743726.95495.16925
captain_note=keep-me
count opencode_version=1
count approval_mode=0
count spawn_gen=1
count captain_note=1
relaunch launch flags: --standalone 
=== codex: fresh spawn
spawn exit=0
harness=codex
approval_mode=approve-for-me
spawn_gen=s1792743730.97549.6823
=== codex: relaunch
warning: /private/var/folders/vm/y9zpsxps43q2cvqmbq1xpqd00000gn/T/fm-spawn-dispatch-profile.uvREbg/scn-codex/home/data/relaunch-codex-k9/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned relaunch-codex-k9 harness=codex kind=ship mode=no-mistakes yolo=off window=firstmate:fm-relaunch-codex-k9 worktree=/private/var/folders/vm/y9zpsxps43q2cvqmbq1xpqd00000gn/T/fm-spawn-dispatch-profile.uvREbg/scn-codex/wt
relaunch exit=0
harness=codex
approval_mode=approve-for-me
spawn_gen=s1792743733.99363.6465
captain_note=keep-me
count opencode_version=0
count approval_mode=1
count spawn_gen=1
count captain_note=1
relaunch launch flags: 
=== claude: fresh spawn
spawn exit=0
harness=claude
approval_mode=auto
spawn_gen=s1792743741.1217.21684
=== claude: relaunch
warning: /private/var/folders/vm/y9zpsxps43q2cvqmbq1xpqd00000gn/T/fm-spawn-dispatch-profile.uvREbg/scn-claude/home/data/relaunch-claude-k9/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned relaunch-claude-k9 harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-relaunch-claude-k9 worktree=/private/var/folders/vm/y9zpsxps43q2cvqmbq1xpqd00000gn/T/fm-spawn-dispatch-profile.uvREbg/scn-claude/wt
relaunch exit=0
harness=claude
approval_mode=auto
spawn_gen=s1792743749.7636.28320
captain_note=keep-me
count opencode_version=0
count approval_mode=1
count spawn_gen=1
count captain_note=1
relaunch launch flags: --permission-mode auto 
Evidence: Focused spawn/relaunch/approval test run log

Source: Focused spawn/relaunch/approval test run log

FM_TEST_BEGIN 2026-10-23T08:10:42Z tests/fm-approval-failover.test.sh family=unclassified expected_gate_skip=none
ok - codex refuses gate callers before configuration, lease or lifecycle mutation
ok - codex permits disposable lab recovery only through its stock layout
ok - codex publishes a single-linked setting before interrupt and relaunch
error: config/codex-approval-mode already exists; nothing overwritten
ok - codex writes once and relaunches through the lifecycle owner
error: config/codex-approval-mode already exists; nothing overwritten
error: config/codex-approval-mode already exists; nothing overwritten
error: config/codex-approval-mode already exists; nothing overwritten
error: config/codex-approval-mode already exists; nothing overwritten
error: config/codex-approval-mode already exists; nothing overwritten
error: config/codex-approval-mode already exists; nothing overwritten
ok - codex preserves explicit files, invalid values, empty files, links and directories
File exists
error: could not publish config/codex-approval-mode; nothing overwritten
File exists
error: could not publish config/codex-approval-mode; nothing overwritten
File exists
error: could not publish config/codex-approval-mode; nothing overwritten
ok - codex atomically preserves concurrent explicit destinations
ok - codex honors live leases before saving and releases its guard before child control
error: the recorded launch did not use bypass; nothing changed
error: invoke failover in the remote worker owning home
ok - codex needs no detector state and refuses contradictory or remote records
ok - codex keeps the setting while reporting incomplete recovery
ok - claude refuses gate callers before configuration, lease or lifecycle mutation
ok - claude permits disposable lab recovery only through its stock layout
ok - claude publishes a single-linked setting before interrupt and relaunch
error: config/claude-permission-mode already exists; nothing overwritten
ok - claude writes once and relaunches through the lifecycle owner
error: config/claude-permission-mode already exists; nothing overwritten
error: config/claude-permission-mode already exists; nothing overwritten
error: config/claude-permission-mode already exists; nothing overwritten
error: config/claude-permission-mode already exists; nothing overwritten
error: config/claude-permission-mode already exists; nothing overwritten
error: config/claude-permission-mode already exists; nothing overwritten
ok - claude preserves explicit files, invalid values, empty files, links and directories
File exists
error: could not publish config/claude-permission-mode; nothing overwritten
File exists
error: could not publish config/claude-permission-mode; nothing overwritten
File exists
error: could not publish config/claude-permission-mode; nothing overwritten
ok - claude atomically preserves concurrent explicit destinations
ok - claude honors live leases before saving and releases its guard before child control
error: the recorded launch did not use bypass; nothing changed
error: invoke failover in the remote worker owning home
ok - claude needs no detector state and refuses contradictory or remote records
ok - claude keeps the setting while reporting incomplete recovery
ok - codex-approval-mode follows primary values and absence locally and remotely
ok - claude-permission-mode follows primary values and absence locally and remotely
# all fm-approval-failover tests passed
FM_TEST_END 2026-10-23T08:10:50Z tests/fm-approval-failover.test.sh exit=0 duration_ms=8465 gate_skip=false
FM_TEST_BEGIN 2026-10-23T08:10:50Z tests/fm-spawn-dispatch-profile.test.sh family=backend-dispatch expected_gate_skip=none
ok - allowlist=absent preserves the operational floor and filters only when opted in
ok - allowlist=missing-config preserves the operational floor and filters only when opted in
ok - allowlist=enabled preserves the operational floor and filters only when opted in
ok - allowlist=empty preserves the operational floor and filters only when opted in
ok - invalid allowlist names refuse before launch or task publication
ok - inaccessible config with present allowlist refuses before launch or task publication
ok - inaccessible config with absent allowlist refuses before launch or task publication
ok - inaccessible ancestor with present allowlist refuses before launch or task publication
ok - inaccessible ancestor with absent allowlist refuses before launch or task publication
ok - secondmate launch inherits the allowlist for subsequent worker launches
ok - local inheritance preserves the allowlist on source errors and mirrors proven absence
ok - remote inheritance preserves the allowlist on source errors and mirrors proven absence
WORKER-RAN
WORKER-RAN
WORKER-RAN
WORKER-RAN
WORKER-RAN
WORKER-RAN
skip: fish not found (fish pane launch); only a static syntax check ran
ok - launch appends the hooks config while preserving inherited Git credentials in sh, bash and zsh
ok - fm-spawn: actual ship/scout launch commands deliver the worker role contract
ok - no --model/--effort records defaults and types the claude launch instructions
ok - a claude launch publishes the brief as an operational-inbox record and passes only the doorbell
ok - a secondmate claude launch publishes its brief record into the secondmate's own home
ok - a claude spawn whose launch-brief record cannot publish stops with a clear error and sends no launch
ok - non-cursor launches clear inherited Cursor identity markers
ok - relative home overrides ignore CDPATH and become absolute before spawn launch construction
ok - FM_HOME defaults resolve relative paths and preserve absolute spellings
ok - absolute override spellings are preserved in spawn launch paths
ok - unresolvable relative spawn overrides fail with named diagnostics
ok - active crew-dispatch profile requires an explicit harness for ship spawns
ok - active crew-dispatch profile requires an explicit harness for scout spawns
ok - active crew-dispatch profile allows an explicit resolved harness
ok - active crew-dispatch profile allows the legacy positional harness form
ok - active crew-dispatch profile allows the raw launch-command escape hatch
ok - a chained raw launch commits through the AI-trailer strip in every step
ok - claude receives --model and --effort profile flags
ok - codex receives --model and model_reasoning_effort profile flags
ok - codex Luna receives --model and model_reasoning_effort max profile flags
ok - codex omits max for models without the catalog capability
ok - a codex crewmate requests no hook layer and keeps its turn-end signal
ok - a codex secondmate keeps its project hooks and uses automatic approval review
ok - Codex defaults remain bypass; persistent fallback is direct and invalid values refuse
ok - grok receives --model and --reasoning-effort profile flags
ok - grok omits unsupported max reasoning effort
ok - grok omits unsupported xhigh reasoning effort
ok - cursor receives its model-qualified reasoning class and exact task workspace
ok - cursor refuses model ids absent from its resolved binary's live catalog
ok - cursor preserves the requested model when its live catalog is unreachable
ok - opencode receives the model and effort through its config
ok - opencode without an effort keeps the model pin and omits variant
ok - opencode emits the variant for an effort the openai family exposes
ok - opencode omits the variant for an effort outside the model family's list
ok - opencode 1.x keeps the --model flag and the variant-only config
ok - opencode 1.x without an effort keeps its permission-only launch config
ok - opencode probe and launch share the same resolved executable path
ok - opencode with an unparseable version falls back to the 1.x launch path
ok - opencode 2 delivery gate accepts an auto-submitted brief without pressing Enter
ok - opencode 2 delivery gate sends exactly one Enter for a brief left in the composer
ok - opencode 2 delivery gate keeps polling an unknown composer and sends one Enter once it reads pending
ok - opencode 2 delivery gate sends its one Enter at the deadline when the composer only reads unknown
ok - opencode 2 delivery gate fails the spawn when the brief tu

... [5842 bytes truncated] ...

rol: an explicit backend endpoint is never a control target
ok - fm-control: an unrecorded task id is refused
ok - fm-control: a record whose endpoint identity names another task is refused
ok - fm-control: a remotely placed secondmate is refused by placement, not by a metadata complaint
ok - fm-control: interrupt and exit lock before task-state resolution
ok - fm-control: the verb list is closed - no raw keys, arbitrary text, or clear verb
ok - fm-control: resume is refused with the determinism reason and the alternative
ok - fm-control: profile and note flags belong to relaunch only
ok - fm-control exit: an already-stopped agent is idempotent success with no bytes sent
ok - fm-control exit: an unprovable tmux endpoint refuses instead of claiming the agent stopped
ok - fm-control interrupt: refuses when no agent is running rather than keying a shell
ok - fm-control exit: an endpoint whose process cannot be attributed refuses
ok - fm-control exit: a busy agent receives interrupt delivery before the exit command
ok - fm-control exit: an idle agent goes straight to its exit command
ok - fm-control exit: retiring a codex incarnation drops busy_gen with the sidecar
ok - fm-control exit: an already-open background-task picker is not typed into
ok - fm-control exit: the Enter that opens the background-task picker is not followed by a confirming Enter
ok - fm-control exit: a picker that renders after the submit returned is named when the stop wait times out
ok - fm-control interrupt: unconfirmed delivery preserves observed busy state
ok - fm-control interrupt: muse confirms cancellation from its session log
ok - fm-control interrupt: postconditions are revalidated after acknowledgement polling
ok - fm-control exit: an interrupt-stopped agent satisfies the gone-state postcondition
ok - fm-control exit: a stubborn agent reports delivered input and an unconfirmed exit
ok - fm-control interrupt: grok reports delivery without claiming cancellation
ok - fm-control interrupt: grok's idle footer does not confirm cancellation
ok - fm-control: a lifecycle command to a secondmate is unmarked and opens no reply expectation
ok - fm-control's arrival leaves fm-send's from-firstmate marking untouched
FM_TEST_END 2026-10-23T08:25:49Z tests/fm-control.test.sh exit=0 duration_ms=162667 gate_skip=false
FM_TEST_BEGIN 2026-10-23T08:25:49Z tests/fm-secondmate-harness.test.sh family=secondmate expected_gate_skip=none
ok - A1 fm-harness.sh secondmate resolves the fallback chain; crew mode unchanged
ok - fm-harness detects only Cursor Agent CLI's exact invocation marker
ok - C1 fm-harness.sh secondmate-model/secondmate-effort resolve the optional tokens; bare harness stays empty (backward-compat)
ok - D1 fm-harness.sh honors a mate override line for its id and changes nothing else
ok - D2 malformed config/secondmate-harness refuses with its line number on every read verb
ok - D3 a config/secondmate-harness that declares no mate line is never refused
ok - pi-signed identity: authoritative launch selection distinguishes shared wrapper ancestry
ok - harness identity: dash-leading ps command names are basename operands, not options
ok - B1 propagate_inheritable_config: copy, idempotence, convergence, absence-mirror, exclusion, no-op, skip diagnostics
ok - B2 spawn: secondmate runs the secondmate harness; its home inherits declared config
ok - B3 spawn: an absent secondmate-harness falls back to the crew harness (backward-compat)
ok - B4 spawn: no config at all -> own harness and no propagation side effects
ok - B5 spawn: an explicit per-spawn harness arg overrides config/secondmate-harness
ok - B6 spawn: an unverified resolved secondmate harness is refused (guard intact)
skip: cursor executable not resolvable in this environment, so the launch could not be built
ok - B5b spawn: FM_BACKEND wins over inherited config/backend
ok - B5c spawn: explicit --backend wins over FM_BACKEND and inherited config/backend
ok - C2 spawn: a bare harness-only secondmate-harness file launches with no model/effort flag (backward-compat)
ok - C3 spawn: config/secondmate-harness's model token threads --model into the launch and meta
ok - C4 spawn: config/secondmate-harness's model+effort tokens thread into the launch and meta
ok - C10 spawn: a legacy secondmate-harness file still launches on its first line (opt-in scope)
ok - C11 spawn: a declared pin file that is malformed refuses the spawn with its line number
ok - C5 spawn: an explicit --model overrides config/secondmate-harness's model token; the file's effort token still applies
ok - C6 spawn: an explicit --effort overrides config/secondmate-harness's effort token; the file's model token still applies
ok - C7 spawn: an explicit --harness starts with clean model/effort defaults
ok - C8 spawn: an explicit --harness still honors explicit model/effort flags
ok - C9 spawn: secondmate launch pins supervision to its own harness
ok - C9 spawn: the harness fallback chain still resolves with no tokens; crew/scout launches are unaffected by this feature
ok - B7 bootstrap sweep pushes, re-converges, and mirrors absence; never inherits secondmate-harness
ok - B8 bootstrap sweep propagates config even when the home's tracked files are already current
ok - B9 bootstrap sweep defers new inherited config until the home ignores it
ok - B10 bootstrap sweep materializes and inherits the startup-memory default while fast-forwarding
ok - B12b backend inheritance: present values and primary absence converge exactly
ok - C2b spawn: config/claude-permission-mode=auto reaches a Claude secondmate launch
ok - claude secondmate launches cover the parent-home steering inbox in auto and bypass modes
ok - B12c approval modes follow primary values and primary absence
ok - B12c presentation inheritance: the primary default converges on, and only an explicit opt-out propagates off
ok - B11 bootstrap sweep surfaces config propagation failures
ok - B11 bootstrap rereads completed config writes after partial propagation
ok - B12 config-push propagates via shared live discovery, reports items, rereads on change only, and does not fast-forward
ok - B13 config-push reports dirty, non-allowing, and invalid homes without failing warnings-only runs
ok - B14 config-push exits nonzero on real propagation errors
ok - B14 config-push rereads completed config writes after partial propagation
ok - B15 config reread is per-home, exact-byte, ordered, and pointer-only
ok - B16 config reread isolation, ABSENT, generation safety, send failure, and retry
ok - B20 config reread publication failures retain exact generations for retry
ok - B21 config reread instruction-write failures retain exact retry generations
ok - B21 config reread preserves exact bytes when temporary adoption also fails
ok - B21 config reread serializes concurrent propagation and delivery
ok - B22 full config reread retry queues drain before new publication
ok - B23 mixed config reread delivery failures still bound sent history
ok - B26 config reread delivery stops after the oldest failed generation
ok - B17 config reread skips unchanged homes and reads destination post-write bytes
ok - B18 bootstrap config reread path works; spawn flexibility remains defaults-only
ok - B19 bootstrap respawns before inherited-config reread
ok - B25 spawn quarantines stale rereads without blocking relaunch
ok - B24 bootstrap detect-only mode remains filesystem read-only
# all fm-secondmate-harness tests passed
FM_TEST_END 2026-10-23T08:30:03Z tests/fm-secondmate-harness.test.sh exit=0 duration_ms=253918 gate_skip=false
FM_TEST_SUMMARY total=4 failed=0 skipped_gate=0 duration_ms=1161480
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=2 duration_ms=898912 failed=0
FM_TEST_SUMMARY_FAMILY family=secondmate count=1 duration_ms=253918 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=8465 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-spawn-dispatch-profile.test.sh duration_ms=736245
FM_TEST_SLOWEST rank=2 script=tests/fm-secondmate-harness.test.sh duration_ms=253918
FM_TEST_SLOWEST rank=3 script=tests/fm-control.test.sh duration_ms=162667
FM_TEST_SLOWEST rank=4 script=tests/fm-approval-failover.test.sh duration_ms=8465

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Conflict resolution keeps both keys: owned list contains main's opencode_version and the PR's approval_mode in the maintainer's specified order ⏸️ untested no The prior payload established this only by reading code (bin/fm-spawn.sh:6187 diff against base), not a live drive; the runtime effect is covered by the live relaunch scenarios.
OpenCode worker relaunch: opencode_version recorded at spawn is carried over exactly once (no duplicate, no loss) ✅ pass live relaunch-owned-keys.txt: opencode relaunch exit=0, count opencode_version=1, new spawn_gen, launch still --standalone (2.x)
Codex approve-for-me worker relaunch: approval_mode is rewritten once and stays approve-for-me ✅ pass live relaunch-owned-keys.txt: codex relaunch exit=0, approval_mode=approve-for-me, count approval_mode=1
Claude auto worker relaunch: approval_mode stays auto and the relaunch launch still uses --permission-mode auto ✅ pass live relaunch-owned-keys.txt: claude relaunch exit=0, approval_mode=auto count=1, launch flags --permission-mode auto
Adversarial: a non-owned meta line (captain_note) survives relaunch while owned keys are not duplicated ✅ pass live relaunch-owned-keys.txt: count captain_note=1 and count spawn_gen=1 for all three harnesses
Existing spawn/relaunch/approval-failover/secondmate inheritance behavior unchanged after rebase ⏸️ untested no The prior payload established this only through automated test suites with fake harnesses (focused-tests.log total=4 failed=0), which is regression evidence, not a live product drive.
  • git show 8818a804:bin/fm-spawn.sh | grep &#39;split(&#34;window endpoint&#39; compared against the rebased line 6187 (only difference: approval_mode added, opencode_version kept)
  • Scratch scenario script (outside worktree) driving real bin/fm-spawn.sh fresh ship spawn then bin/fm-spawn.sh --relaunch &lt;id&gt; for opencode (2.0.21), codex (config/codex-approval-mode=approve-for-me) and claude (config/claude-permission-mode=auto), counting opencode_version=, approval_mode=, spawn_gen= and a foreign captain_note= line in the task meta after relaunch
  • bin/fm-test-run.sh tests/fm-approval-failover.test.sh tests/fm-spawn-dispatch-profile.test.sh tests/fm-control.test.sh tests/fm-secondmate-harness.test.sh (total=4 failed=0)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Changes default worker approval and permission modes across the system.

The PR appears safe to merge, with the previous finding fully addressed and no new actionable issues.

What we checked:

  • Permanent tests keep the coverage: The permanent suite checks all five scenarios. No tracked caller refers to either deleted script.

Reviews (3) · Last reviewed commit: "fix: remove stray scratch directories fr..."

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks, @zestysoft. The managed-machine evidence is clear and useful. I reviewed this against main 99da16d9. This is waiting on you. The change in its current shape replaces two default permission postures for every home, so I need a few things before it can go anywhere.

What I checked: head f87c44c7 matches the no-mistakes attestation. No workflow files change, and there's no network, secrets, or download-and-run code. On an unconfigured home, bin/fm-spawn.sh now does two things:

  • It defaults CLAUDE_PERMISSION_MODE to auto, so every Claude worker launches with --permission-mode auto instead of --dangerously-skip-permissions.
  • It hard-replaces --dangerously-bypass-approvals-and-sandbox with --approve-for-me in every Codex crewmate, scout, and secondmate launch. That means the workspace-write sandbox with network off, behind model-reviewed approvals.

There is no Codex config to get the old posture back. The latest Greptile summary on this head is 5/5. CI run 37545263122 had one red job, Behavior portable serial 4, failing in tests/fm-remote-reply.test.sh ("the NUL-bearing line was not captured"). That test is unrelated to these files, so I re-ran the failed job (attempt 2).

Contract-class: new-default. The PR calls itself a fix, but the existing specified default was bypass for Claude (documented as "an absent file defaults to bypass") and full bypass for Codex. That default wasn't broken on unmanaged machines. It just doesn't fit company-managed policy. Changing a default-on setting is new-default, so this can never auto-merge. VISION also says new capability "ships as an option to enable, never as behavior that assumes consent."

What's needed from you (either path is fine):

  1. Preferred, which would make this opt-in: keep today's defaults and add a Codex opt-in that mirrors config/claude-permission-mode. For example, a local config/codex-approval-mode with bypass (default) and approve-for-me, refusing any other value before spawn, like the Claude file does. Managed-machine captains then set both files. An opt-in like that, green and attested, is the kind of change I can merge.
  2. If you want to keep the default flip: it becomes a captain decision once it's otherwise ready. Please also (a) give Codex an explicit way back to the old bypass posture, (b) state the minimum codex-cli version that accepts --approve-for-me. As written, any home on an older Codex fails every Codex spawn on an unknown flag, and nothing guards or tests that. And (c) confirm that --permission-mode auto is available wherever Claude workers can run today (all plans and providers). Otherwise the new default would break unconfigured launches.

Either way, push the update through no-mistakes so the attestation matches the new head.

Security FYI (not a blocker by itself): this changes worker permission posture. It's stricter on paper, but approvals become model-reviewed (Codex auto review, Claude's classifier) instead of fixed. Your own verification shows network access granted after an automatic review. That's a posture change the captain should see when deciding.

VISION.md, rule by rule

  • One captain, one interface: aligns on the motive, since unattended workers on managed machines mean fewer stuck approval prompts. But a version or plan mismatch would create new spawn failures on homes where nothing was broken.
  • Authority is explicit and never inferred: does not align as a default flip ("new capability ships as an option to enable"). It would align as an opt-in.
  • Scripts own the mechanics, agents own the judgment: aligns. It's a deterministic launch-flag choice.
  • A restart is a non-event: aligns. Records are unchanged.
  • Delegation with a spine: cannot tell. Workers now get model-reviewed approvals and a network-off sandbox by default, which can stall networked ship steps (push, gh, no-mistakes) behind the reviewer.
  • The fleet outlives any vendor: cannot tell. It binds every Codex launch to a newer CLI flag, with no version check and no fallback.
  • Scope: aligns. Harness launch posture belongs to the command layer.

@zestysoft
zestysoft force-pushed the fm/fm-managed-approvals branch from f87c44c to 7bb15e1 Compare October 7, 2026 18:41
@zestysoft zestysoft changed the title fix: use managed-compatible worker approval modes by default feat(fm-spawn): add managed-approval failover for claude and codex Oct 7, 2026
@zestysoft

Copy link
Copy Markdown
Contributor Author

The revision now preserves both bypass defaults and adds explicit managed-approval settings plus persistent, evidence-based failover. One additional executable regression was found in the Codex approval-modal detector under LC_ALL=C and is being corrected as a follow-up on top of the validated commits. This PR is not ready for merge until that correction has also passed validation.

@zestysoft zestysoft changed the title feat(fm-spawn): add managed-approval failover for claude and codex fix: persist managed approval failover for Codex and Claude Oct 20, 2026
@zestysoft
zestysoft force-pushed the fm/fm-managed-approvals branch from f5e754e to 0500980 Compare October 20, 2026 08:15
@zestysoft zestysoft changed the title fix: persist managed approval failover for Codex and Claude feat: add persistent managed-approval failover for Codex and Claude Oct 20, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you, @zestysoft, for reworking this so both bypass defaults stay as they are. That was the main thing I asked for, and the new config/codex-approval-mode file follows the Claude file's refuse-before-spawn shape well.

I re-read head 05009800 against main a65dceee. No workflow files change, and there's no network, secrets, or download-and-run code. On an unconfigured home, bin/fm-spawn.sh still launches Claude with --dangerously-skip-permissions and Codex with --dangerously-bypass-approvals-and-sandbox. Fixes #6716 checked against the body.

This is waiting on you. Two things are needed:

  1. Live validation (5 of 7). The two scenarios that matter most are still untested: an interactive Codex worker recovered through approve-for-me, and an interactive Claude worker recovered through auto. Could you live-test those two (answer the hook-review and folder-trust prompts yourself as the operator in your lab) and post the evidence, or re-raise through no-mistakes with them driven live? Whichever is easier for you.
  2. CI. Run 39392063349 had two red jobs. Behavior portable serial 5 failed in the remote secondmate lifecycle e2e ("the watcher did not exit on its auto-relaunch wake within the bound"), which looks like a known timing flake outside your files. Behavior portable serial 2 hit the 30-minute job limit. I re-ran the failed jobs once. If either goes red again on your files, please fix it.

Contract-class: new-default (my own read, not the PR's). The launch defaults are preserved, but two parts change what an unconfigured home does:

  • The stuck-crewmate-recovery skill now tells firstmate to run fm-approval-failover.sh apply on its own after it sees a defeated bypass. That writes a lasting worker-permission setting for the whole home (and its secondmates) without the captain's word. VISION says security-sensitive changes need the captain's explicit word. A version that makes firstmate ask the captain first and then run apply would align better.
  • Inheritance for claude-permission-mode changes. Today, removing the primary's file clears it in secondmate homes (primary-authoritative). With this PR, the secondmate keeps its own copy.

So once it's green and fully live-validated, this goes to Kun as a merge-or-leave decision rather than an auto-merge.

VISION.md, rule by rule

  • One captain, one interface: aligns. Fewer workers stuck on managed approval prompts. The failover reports its result instead of going quiet.
  • Authority is explicit and never inferred: does not align as written. firstmate saves a permission posture by itself after it sees a refusal. It would align if apply needed the captain's word.
  • Scripts own the mechanics, agents own the judgment: aligns. Observation is left to the agent and the save/relaunch is a deterministic script with lease, gate and no-overwrite guards.
  • A restart is a non-event: aligns. The setting is durable and relaunch goes through fm-control.
  • Delegation with a spine: cannot tell yet. Interactive recovery isn't live-proven, and the network-off workspace-write sandbox may stall networked ship steps behind the reviewer.
  • The fleet outlives any vendor: aligns. Both vendors are covered through their own exposed flags, with no version emulation.
  • Scope: aligns. Worker launch posture belongs to the command layer.

Security FYI (not a blocker by itself): model-reviewed approvals replace fixed bypass for any home that opts in or fails over.

@zestysoft
zestysoft force-pushed the fm/fm-managed-approvals branch from 0500980 to bea3403 Compare October 20, 2026 16:18
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @zestysoft. This revision addresses both things that made me call it new-default last time. I re-read head bea3403d against main 9d76aa8e.

What changed my read:

  • stuck-crewmate-recovery now says to ask the captain for explicit approval before fm-approval-failover.sh apply, and only to run it after that word. Firstmate no longer self-applies a home-wide permission posture.
  • claude-permission-mode and the new codex-approval-mode are both primary-authoritative again (primary value replaces, primary absence clears). Your live log shows that locally and through the real remote receiver.
  • Unconfigured spawns are unchanged: Claude still launches with --dangerously-skip-permissions, and Codex still launches with --dangerously-bypass-approvals-and-sandbox (absent or bypass). approve-for-me / auto only apply when a home sets the file, and invalid values refuse before spawn. No workflow, network or secret changes.

Contract-class: opt-in (my own read, updated from new-default). VISION.md, rule by rule: One captain aligns. Authority now aligns (the posture change needs the captain's word). Scripts aligns (guarded, deterministic apply). Restart aligns. Delegation is still cannot tell until interactive recovery is proven. Vendor aligns. Scope aligns.

This is waiting on you. Three things:

  1. Rebase. The PR now conflicts with main in .agents/skills/stuck-crewmate-recovery/SKILL.md. That's my doing: fix(skills): keep recovery-skill triggers inside Claude Code's listing budget #7558 just landed and trimmed skill descriptions to fit Claude Code's skill-listing budget (Recovery skill triggers can be dropped when Claude Code's skill listing overflows its budget #7545). Please rebase and keep the new "after observing a defeated Claude or Codex bypass" trigger, but write it in the trimmed description's short style.
  2. Live validation (6 of 8). The two interactive recoveries (Codex via approve-for-me, Claude via auto) are still untested, as your body notes. Please run them on the rebased head, answering the hook-review and folder-trust prompts yourself as the operator, and post the transcripts. Re-raising through no-mistakes with them driven live works too.
  3. CI. On run 39456251169, Behavior portable serial 5 was cancelled at the 30-minute job cap, with every test it finished passing. Everything else is green, including the no-mistakes check. The rebase will give a fresh run, so I didn't re-run it.

Once those are in and CI is green, this can take the opt-in path.

Security FYI (not a blocker): homes that opt in or fail over get model-reviewed approvals instead of a fixed bypass.

@zestysoft
zestysoft force-pushed the fm/fm-managed-approvals branch from bea3403 to 203c630 Compare October 21, 2026 19:59
@zestysoft

Copy link
Copy Markdown
Contributor Author

Both review changes are implemented: permanent failover requires explicit approval, and both approval-mode files follow primary values and primary absence in secondmate homes.
Bypass remains the default.

Interactive recovery was exercised on bea3403d1ad99ea0611e105398f9dc9727ed45d5 with native interactive CLIs and an operator answering consent screens. The normalized excerpts below replace private lab paths with <lab-home> / <worker>; no human command approvals were answered by the driver.

Codex CLI 0.163.0, 2026-10-20:

  • With the mode file absent, the production default-bypass launch stopped at a human shell-command approval for its steering-inbox find.
  • After explicit approval, the real failover command saved config/codex-approval-mode=approve-for-me, interrupted the blocked turn, and relaunched through fm-control (exit 0).
saved config/codex-approval-mode=approve-for-me; approvals use a model reviewer
managed approval failover: <task> relaunched with config/codex-approval-mode=approve-for-me

All seven commands completed successfully. The steering inbox was empty.
• Probe file returned live-recovery-ok.
• Probe status marker appended.
• PR head matched bea3403d1ad99ea0611e105398f9dc9727ed45d5.
• Daemon status: running.
Commands 5–7 succeeded after reviewed escalation. No daemon was started. Stopped.

The seven separate probes were pwd -P, git status --short, create/read a worktree file, append a status marker outside the worktree, read the PR head with gh-axi, and read no-mistakes daemon status. Initial network/socket sandbox denials were followed by successful automatic reviewed escalations; the daemon was only inspected. This proves those operations in this environment, not unrestricted network or external writes. The earlier 0.160.1 verification record separately covers git push --dry-run; this recovery round did not repeat a worker push.

Claude Code 2.1.306, 2026-10-21:

  • The fresh default launch argv contained --dangerously-skip-permissions with no mode file. Managed settings contained permissions.disableBypassPermissionsMode=disable; the native session showed auto mode. The operator accepted folder trust and external imports.
  • This baseline already completed all seven probes. After the approved failover saved config/claude-permission-mode=auto, the production guarded relaunch returned 0. The replacement process argv contained --permission-mode auto, and metadata recorded approval_mode=auto.
  • The hand-built fixture initially lacked brief.md: the first apply saved the setting but refused relaunch. Supplying its existing authorized brief at that expected fixture path and retrying fm-control relaunch completed recovery; no source or consent workaround was made.
Bash(pwd -P) -> <worker>
  Allowed by auto mode classifier
Bash(git status --short) -> ?? live-recovery-probe.txt
Bash(printf 'live-recovery-ok\n' > live-recovery-probe.txt) -> success
cat live-recovery-probe.txt -> live-recovery-ok
Bash(printf 'probe completed\n' >> <lab-home>/state/<task>.probe-status) -> success
  Allowed by auto mode classifier
Bash(gh-axi api repos/kunchenguid/firstmate/pulls/6722 --jq .head.sha --full)
  bea3403d1ad99ea0611e105398f9dc9727ed45d5
  Allowed by auto mode classifier
Bash(no-mistakes daemon status) -> daemon running
  Allowed by auto mode classifier
All 7 commands finished, and none were denied.

The unchanged trust helper used ~/.claude.json and carried the operator's consent from the fresh canonical lab project onto the linked worker. After relaunch, both lab entries had hasTrustDialogAccepted, hasClaudeMdExternalIncludesApproved, and hasClaudeMdExternalIncludesWarningShown set to true. An earlier lab where the operator declined imports was preserved: recovery correctly saved auto but refused to override that decline. No consent record was hand-edited. Both successful lab workers were stopped through fm-control exit, and their fallback settings remained saved.

The Claude result proves durable explicit-auto launch and unattended operation. It is not a command-denial-to-success comparison: managed policy had already selected auto in the successful fresh baseline.

The fresh pipeline rebased the patch onto 83b70ef49e33eff529f574618415997c8ef67518, publishing 203c6308e1a3f4f78ebca23c298174645b34d18c.
git range-diff 3eabd356abc99bdb0c1d2cefc5a1dec4a9fe39c1..bea3403d1ad99ea0611e105398f9dc9727ed45d5 83b70ef49e33eff529f574618415997c8ef67518..203c6308e1a3f4f78ebca23c298174645b34d18c matched all 15 task commits: 13 unchanged patches and two changed patches whose differing hunks are confined to .agents/skills/stuck-crewmate-recovery/SKILL.md description text.
The defeated-Claude-or-Codex-bypass trigger is retained in upstream's trimmed description style; the rebase introduced no runtime or test change to the patch series.

 1:  ceb96a5b =  1:  c1fb1980
 2:  a53fb326 =  2:  8ea83e38
 3:  6a6f3e2f =  3:  b366a4c8
 4:  6867f49e =  4:  3cb81ce1
 5:  9e7f1a52 !  5:  72d19900
 6:  ffd11ca2 =  6:  dbf6c5f7
 7:  4706de5a =  7:  3ecabf5b
 8:  cae52542 =  8:  8591d256
 9:  a35b274f =  9:  85bbc927
10:  93ad5710 ! 10:  35bf3ad2
11:  7f9cae95 = 11:  787a1966
12:  3f94881a = 12:  f72a4cba
13:  2e4f73ef = 13:  a13a8563
14:  95b6bcbc = 14:  7031a2e0
15:  bea3403d = 15:  203c6308

Fresh no-mistakes run 01M5FZWDRH0GVV50DFXZZ5X38S completed passed-with-override, not green CI.
Review, documentation, and lint passed; the Test exception was explicitly approved using the operator-assisted recovery evidence above.
The workflow finished with 17 passed checks, plus these accepted unrelated upstream results:

  • Behavior portable serial 5 failed at the remote-secondmate watcher auto-relaunch bound. The matching timing flake was reported in unrelated upstream runs 39606881836, 39426140356, 39402328270, and 39397132982, and identified as a timing flake by the maintainer.
  • Behavior portable serial 2 was cancelled at the 30-minute job limit inside fm-supervision-host.test.sh, which this patch does not change. This cancellation provides no passing verdict.

The configured CI repair reached its 30-minute budget without committing a source correction or changing test bounds.
Head passed the originally failing watcher assertion locally; base stopped earlier at a ledger timeout, so that local comparison did not establish causality.
The gate was explicitly approved with those limitations preserved, rather than spending another repair budget.
This workflow remains failed/cancelled.
A maintainer re-run of Behavior portable serial 5 and Behavior portable serial 2 on this head is requested.

Full native evidence remains in the private task record: the Codex defeated-bypass viewport, apply/relaunch output, and recovered transcript; the Claude baseline argv and viewport, scoped managed-policy observation, helper trust entries before and after relaunch, and recovered transcript; plus the full range-diff and CI logs.
The excerpts above remove private paths and process identifiers.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you, @zestysoft, for the interactive recovery transcripts and the range-diff. That's exactly the evidence I asked for. The Codex 0.163.0 run shows a default-bypass worker stuck on a command approval, then saved to approve-for-me after explicit approval and relaunched to finish all seven probes. The Claude 2.1.306 run shows the guarded relaunch landing with --permission-mode auto. You were also careful to say the Claude round proves durable auto launch rather than a denial-to-success comparison. I'm counting live validation as done, and your range-diff from bea3403d to 203c6308 (13 unchanged patches, two differing only in the skill description text) carries it onto this head.

What I checked (head 203c6308 vs main 1935d27b): unconfigured spawns are unchanged. Claude still gets --dangerously-skip-permissions and Codex still gets --dangerously-bypass-approvals-and-sandbox when the mode file is absent or bypass, and invalid values refuse before spawn. stuck-crewmate-recovery asks the captain before fm-approval-failover.sh apply, and both mode files are primary-authoritative in secondmate homes. No workflow, network or secret changes. The no-mistakes attestation binds this head.

Contract-class: opt-in (my own read, unchanged). VISION: One captain aligns · Authority aligns (the posture change needs the captain's word) · Scripts aligns · Restart aligns · Delegation now aligns (interactive recovery proven) · Vendor aligns · Scope aligns.

This is waiting on you for one thing: a rebase. Main moved underneath it, and the PR now conflicts with main in bin/fm-spawn.sh (#7633 added the Rex backend and #7631 the Herdr lifecycle-brief refusal there). Because of that, I didn't re-run the cancelled serial 2 job on run 39666356251. The rebase gives a fresh run anyway. Re-raising through git push no-mistakes on current main is ideal. Once it's mergeable, green and attested, this can take the opt-in merge path.

Security FYI (not a blocker, unchanged): homes that opt in, or that the captain approves for failover, run workers under model-reviewed approval instead of full bypass. That's the point of the change, and it stays off unless set.

zestysoft and others added 13 commits October 22, 2026 16:01
…R changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)
tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zestysoft and others added 16 commits October 22, 2026 23:30
…R changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)
tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@zestysoft zestysoft changed the title feat: add persistent managed-approval failover for Codex and Claude feat(bin): add persistent managed-approval failover for Codex and Claude Oct 23, 2026
@zestysoft

zestysoft commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (8818a804) and re-raised through git push no-mistakes. The new head is af8d45ef, and GitHub reports it mergeable.

Owned-key list: resolved exactly as you wrote it. It keeps main's keys, including the new opencode_version, plus approval_mode: … model effort opencode_version account account_provider busy_gen spawn_gen approval_mode traceparent …. Nothing was dropped or reordered.

Commits: the 16 commits of the reviewed series are all present after the rebase. git range-diff shows 12 identical patches. Two differ only in context lines main changed. Two carry the one-line key-list resolution. There is no new work.

One extra merge commit: the no-mistakes private-mirror guard refused to publish a rebased series over the previously published head b0424b60, because every commit id changed. Its documented recover-anchor path did not apply. So I cleared the guard with its other documented path, a tree-preserving -s ours merge of b0424b60 on top of the rebase. The tree is byte-identical to the plain rebase, and the diff against main is unchanged. Nothing was forced. The new run's attestation binds af8d45ef.

CI on af8d45ef: 15 passed, 2 failed, 1 cancelled.

  • Behavior portable serial 3: tests/fm-remote-reply.test.sh, "the NUL-bearing line was not captured". The same assertion fails on main in three separate runs: 39889238764, 39653223250 and 39058990697 (tracked in CI fails fm-remote-reply.test.sh on commits that later pass, and cancels Behavior portable serial 2 at 30 minutes #6790). We're taking no code action on it.
  • Behavior portable serial 5: tests/fm-remote-job.test.sh, "a burst of TERMs after ownership loss left the old worker alive". I could not find this assertion failing in main's recent CI runs, so I can't show it's a main-branch failure, and it may be our change.
    • What the test does: it SIGSTOPs a remote-job worker that has lost its lock to a replacement owner, sends it ten TERMs, then CONTs it, and expects it to exit within 5 seconds. It drives only the remote-job worker scripts. None of them are touched or sourced by this PR.
    • Local runs of just that file, one at a time: it passes 42/42 on this head af8d45ef, and passes 42/42 on main 8818a804. So it doesn't reproduce locally on either side. It also passed in CI on the previous head b0424b60.
  • Behavior portable serial 1: cancelled at the 30-minute job limit, with every printed result passing.

Request: we don't have rights to rerun jobs or merge here. Could you rerun Behavior portable serial 5 and the cancelled Behavior portable serial 1 on the current head af8d45ef (run 39925247469)? We won't push anything new in the meantime, so the head and its attestation stay as they are. Rerun, approve or merge stays your call.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @zestysoft. The rebase onto 8818a804 is exactly right. I compared the bin/ diff of af8d45ef with the green b0424b60, and the only difference is the owned-key line, which now carries both opencode_version and approval_mode. The attestation binds af8d45ef (MATCH, live go 4/6). Contract-class (my own read): opt-in, unchanged, since unconfigured launch flags don't change.

CI on this head is 16/19. Serial 1 hit the 30-minute cap. Serial 3 (fm-remote-reply: "the NUL-bearing line was not captured") and serial 5 (fm-remote-job: "a burst of TERMs after ownership loss left the old worker alive") are timing-sensitive remote tests. They don't touch anything this PR changes, and both were green on b0424b60. I've rerun the failed jobs.

Where it stands: waiting on CI. Nothing is needed from you. If the rerun is green and the head hasn't changed, I'll merge it. If those two remote tests fail again, I'll take a closer look before doing anything.

@kunchenguid
kunchenguid merged commit 64973e3 into kunchenguid:main Oct 23, 2026
34 of 38 checks passed
@kunchenguid

kunchenguid commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

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

Head af8d45ef passed every shard except serial 1, which hit the 30-minute cap with no failing test (a known runner pattern). The attestation binds the head, and the bypass defaults are unchanged: approve-for-me only applies when config/codex-approval-mode asks for it.

prishsu0730 pushed a commit to prishsu0730/firstmate that referenced this pull request Oct 29, 2026
…ude (kunchenguid#6722)

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

* fix: resurface queued wakes from handling successors (kunchenguid#7466)

* fix(bin): resurface wakes appended while a handling successor is parked

The supervision host parks on the handling successor it starts for a wake
its engine handled, and a handling successor never resurfaced recovery, so
a row another script appended during the park (a captain inbox note from
the Basecamp integration) sat queued until an unrelated close - four hours
in the observed case.

A handling successor now records the newest queued sequence at its start
and closes once with the recovery wake while a newer row is still queued;
a newer row already consumed only advances that mark, so the predecessor's
delivered episode is still never re-announced.

Follow-ups, not built here:
- A row appended in the short window between a handled close and its
  successor's start (about a second) is below the successor's mark; if the
  engine handles that close without claiming the row, the row waits for the
  next close. Closing that window needs the host to treat rows left queued
  after a handled attended turn as main's, which is a separate host change.
- After a machine reboot the primary session does not restart on its own,
  so queued wakes wait until it is resumed by hand. Either auto-resume the
  primary session after boot, or alert the owner when the primary session
  is down while wakes are queued.

* no-mistakes(review): Close handling-successor startup wake race

* no-mistakes(test): Stabilize parked-host inbox wake regression timeout

* no-mistakes(document): Clarify handling-successor wake continuity guarantees

* no-mistakes(ci): Stabilized the flaky remote secondmate lifecycle test by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case

* no-mistakes(ci): Fixed flaky concurrent Herdr recovery testing by retrying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices

* no-mistakes(test): Preserve successor wake boundaries across handoffs

* no-mistakes(test): Revert successor boundaries and drain teardown fixture wake

* no-mistakes(test): Notify main when downtime handback publication fails

* no-mistakes(test): Revert downtime handback notification changes

* no-mistakes(document): Correct stale supervision wake routing documentation

* fix(bin): stop the supervision host deadlocking and re-announcing handed-back closes

Two defects in this branch's handling-successor changes surfaced as the
"Behavior portable serial 2" shard hanging at its 30-minute limit.

A TERM that lands while the host settles a handled turn's successor handoff
left the host holding the wake-queue and recovery-marker locks; its exit
cleanup then waited forever on the queue lock it still owned. The cleanup now
releases those locks if this process owns them before releasing its grant.

When an accepted close turns main-only at its turn, the host hands it back and
leaves the successor running, but republished the episode as pending
downtime, so that successor re-announced the same close and exited. The
handback now republishes the episode as already announced; a later durable
append still opens a pending episode the successor recovers.

* no-mistakes(test): Park on successor after handling settlement failure

* no-mistakes(test): Use tab-delimited handled-settlement failure logs

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(bin): preserve accents in pending-reply summaries (kunchenguid#7618)

* fix(bin): keep accented letters in pending-reply request summaries

fm_pending_reply_summarize deleted every byte outside printable ASCII, so a Portuguese summary lost its accents: "não faça a correção" was stored as "no faa a correo". It now removes control characters only. The 120-character cap counts UTF-8 characters from lead bytes, so it never splits a letter under any caller locale, including the C locale.

* no-mistakes(document): Documentar preservação de acentos nos resumos

---------

Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>

* feat: add OpenRouter support for typed dispatch resolution (kunchenguid#7149)

* Add explicit OpenRouter Jev dispatch resolution

* no-mistakes(document): Clarify dispatch documentation and remove stale duplicates

* chore: exclude local Stele binding from PR

* no-mistakes(document): Correct dispatch help and never-send documentation

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct dispatch architecture documentation ownership

* feat(bin): publish lane capacity facts with beat pressure and keyed limits (kunchenguid#6983)

Opt-in: fm-watch.sh publishes state/lane-capacity.json via bin/fm-capacity.sh --publish only while config/lane-capacity exists; adds beat pressure and keyed limits to fm-capacity.sh. Unconfigured fm-capacity output unchanged.

* fix(bin): propagate contribution input assembly failures (kunchenguid#5359)

* fix(bin): transport contribution-input JSON through slurpfile, not argjson

bin/fm-fleet-snapshot.sh --contribution-input passed the full backlog and
task-record JSON to jq through --argjson. A single --argjson argument is
capped by the kernel's MAX_ARG_STRLEN (131072 bytes on Linux), so a large
enough backlog made the kernel refuse to exec jq while the script still
exited 0 with a broken result.

Transport both documents through temporary files and --slurpfile, matching
the pattern the default snapshot path already uses, and propagate a
non-zero exit when that jq invocation fails.

Fixes kunchenguid#5349

* test: narrow contribution-input regression to final assembly failure

The ARG_MAX transport is already fixed on main by kunchenguid#6830, so keep only the regression proving a failing final jq assembly exits non-zero.

* fix: correct Rex secondmate grouping and lifecycle (kunchenguid#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (kunchenguid#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from kunchenguid#5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from kunchenguid#5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from kunchenguid#5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(bin): resolve the tmux container from firstmate's own session, not the most recent group member (kunchenguid#7662)

* fix(bin): resolve the tmux container from the caller's own session, not the most recent group member

* no-mistakes(test): Fall back when the $TMUX session id is stale

* no-mistakes(document): Document tmux container choice under grouped sessions

* fix(bin): read a fully dim Cursor idle placeholder as an empty composer (kunchenguid#7647)

* fix(bin): read a fully dim Cursor placeholder as an empty composer

cursor-agent 2026.10.19 draws the composer glyph and its idle placeholder
as one SGR 2 run with no reverse-video cell, so ghost stripping empties the
row and the empty-content guard returned unknown. Relaunch and exit then
refused on every idle Cursor pane on tmux.

When a styled bare row strips to empty and the plain row is an agent glyph
followed by an anchored idle placeholder, read it empty. Bright typed text,
other dim text, and unstyled rows keep their existing verdicts.

Fixes kunchenguid#7413

* docs(verification): record the fully dim Cursor placeholder verdict and refresh command

* fix(bin): say why away-mode inject deferred and pin named Claude idle composer as empty (kunchenguid#6163)

* fix(bin): recognize a named Claude session's titled composer rule on cursorless backends

`claude -n <name>` right-aligns the session name in the rule above the
composer. Cursorless backends (Herdr) accepted only solid rules, so the
scan saw the lower rule alone, the idle composer read `unknown`, and
away-mode delivery to a named Claude primary deferred until return.

A rule carrying one right-aligned title now opens a separator pair. It
never closes one, the pair it opens counts only over an agent-glyph row,
and it is never a valid Pi pair, so Pi's verdict is unchanged.

The away-mode composer deferral now names which refusal it was:
unsubmitted text, or no composer shape recognized.

* no-mistakes(review): Reword composer deferral reason to cover busy harness

* no-mistakes(ci): ci-3 (Greptile, user chose to fix): The rule that must always hold is that Claude's titled opening rule is accepted for any non-empty session name that doesn't start with a space and doesn't contain the rule glyph `─`, including a multiword name. The only place that check lives is the title `case` in `_fm_composer_titled_rule_row` (bin/fm-composer-lib.sh). It now reads `case "$title" in ''|' '*|*─*) return 1 ;; esac`, as the user asked, and the comment above the function mentions multiword titles. I added regression fixtures to `test_matrix_claude_named_session_titled_rule` in tests/fm-composer-lib.test.sh, next to the existing single-word `Andrew` cases. They use the title `Andrew Chen` and check that an idle composer on herdr reads `empty` and a composer with typed text reads `pending`. Something you should know: the old pattern already accepted a title with a space in the middle. It only rejected a title ending in a space. So the new multiword fixtures also pass against the old code, and the bot's failure scenario did not actually happen for "Andrew Chen". What the fix really changes is that it drops the trailing-space rejection, as instructed. Checks run: tests/fm-composer-lib.test.sh and tests/fm-composer-ghost.test.sh both pass (exit 0, no failures), and `shellcheck -x` is clean on both changed files

* no-mistakes(review): Match unnamed-ghost fixture rule width to the partner rule

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

---------

Co-authored-by: Caleb LeNoir <caleb.lenoir@constructease.com>
Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>
Co-authored-by: Alexandre Custodio <xandy.alexandrec@gmail.com>
Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>
Co-authored-by: Pedro Guimarães <21346846+0x7067@users.noreply.github.com>
Co-authored-by: Konner Moshier <39997550+Moshik21@users.noreply.github.com>
Co-authored-by: Oscar Santis Brante <49914973+osantis@users.noreply.github.com>
Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Kostadin Pop-Kochev <kostadin.popkocev@gmail.com>
Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Tomas Perez <71987424+tomasperezcoscia@users.noreply.github.com>
Co-authored-by: Cameron Aragon <69489633+camaragon@users.noreply.github.com>
Co-authored-by: Brian <bthome@users.noreply.github.com>
(cherry picked from commit 64973e3)
RajeshRajendiran added a commit to RajeshRajendiran/firstmate that referenced this pull request Nov 2, 2026
…watcher, configuration, agy verification, teardown test resolved) (#28)

* test(herdr): bound the piped composer probe with fm_run_timed instead of GNU timeout (#7636)

* feat: add Rex push notifications and cursor-aware composer detection (#7639)

* feat(rex): push blocked edges from Rex program status through a bounded Lua reader

Rex joins Herdr as a push-capable backend: a bounded rex do reader streams
program_status_changed, child_exited, and block_closed for the watched task
blocks, and a trusted blocked edge wakes the supervisor with Rex's blocked
kind and message in the reason. The per-pane dedupe moves into the shared
transition lib, the record gains a detail field, and gone edges end the wait
for an immediate poll. The real-Rex test isolation is shared by both smokes.

* fix(rex): anchor the composer read on Rex's cursor position

Rex's format method reports the cursor alongside the styled grid, so the
composer verdict now uses the same cursor-anchored read as tmux and falls
back to the cursorless read only where that is unknown. OpenCode 1.19 draws
a status line below its composer, which made every cursorless read of an
idle OpenCode worker on Rex unknown and refused steers, exit, and relaunch.

* test(rex): add a live composer guard for every installed harness on Rex

* docs(rex): record push-event and per-tool live evidence on Rex

* no-mistakes(document): Clarify Rex documentation and shared transition ownership

* no-mistakes(ci): Fixed flaky public-followup fixture teardown: killing only the remote worker child allowed its supervisor to restart and race directory removal. Cleanup now uses the existing whole-worker-tree stop helper. Verified the full public-followup suite, remote-job orphan-reap suite, shell syntax, and git diff checks all pass

* feat(bin): notify owned PR conflicts and failing required checks behind an opt-in flag (#7634)

* refactor(bin): share the branch-to-PR lookup through fm-pr-lib

* feat(bin): notify owned PR health changes behind an opt-in flag

* no-mistakes(review): drop status-line ownership, key checks per name, remove PR wait rule

* no-mistakes(review): rediscover the branch PR once the cached one is final

* no-mistakes(review): refuse retired re-enrollment, require marked checks, verify owned records

* no-mistakes(document): note shared branch-to-PR lookup in scripts table

* fix(bin): notify reported failures when no checks are required

* no-mistakes(document): inventory PR health flag and state, note new pr-forge member

* test: isolate real-Rex suites on private servers (#7649)

* Isolate real Rex tests with private servers

* no-mistakes(review): Trap Rex cleanup early and prove passive-read autostart guard

* no-mistakes(document): Consolidate Rex test isolation documentation

* fix: distinguish outdated tools from missing tools (#5688)

* fix(bin): report an outdated bootstrap tool instead of a missing one

detect_local_tools printed "MISSING:" for a treehouse without --lease, a
no-mistakes below 1.46.0, a gh-axi below its floor, and an incompatible
tasks-axi or quota-axi, so a supervisor read an installed tool as absent
and took the first-install remediation again.

Report those as "OUTDATED:" with the installed version, the requirement
and the tool's own upgrade command: treehouse update, no-mistakes update,
gh-axi update and quota-axi update. tasks-axi ships no self-updater, so it
keeps its install command. "MISSING:" stays for absent tools only, and
lavish-axi keeps PRESENTATION_UNAVAILABLE with its text fallback.

Update the bootstrap-diagnostics handler, the AGENTS.md section 13 trigger
list and the operator diagnostics in docs/configuration.md, and cover
absent, below-floor and at-floor for every floored tool in
tests/fm-bootstrap.test.sh.

* no-mistakes(document): Documented distinct bootstrap tool diagnostics

* fix(bin): reuse the tasks-axi check's own probe results

Rendering the tasks-axi OUTDATED requirement text ran the two `--help`
capability probes again after the compatibility check had already run
them, including when session start handed bootstrap an incompatible
verdict. The check now records the reason behind its verdict - the
version floor, or the capability probes the build fails - and reuses it,
both within the process and across the existing one-hop handoff, so
naming a missing capability costs no second probe pass. A build below the
floor is answered by its version alone and never pays for capability
probes it cannot use.

The bootstrap tests that simulate a tool as absent removed it from the
fake bin directory while bootstrap kept searching the fallback base PATH,
so a real host install could satisfy the lookup instead of the expected
MISSING line. Those cases now hide the tool from the base path as well,
and a new case pins the contrast between a bare and a curated fallback.

Verified: the touched bootstrap suite passes, and its probe-count and
capability assertions fail against the pre-fix scripts. Run with a
fallback base PATH carrying real installs of the absent tools, the
pre-fix suite fails on "absent treehouse reports a missing tool" while
the fixed suite passes every case.

* no-mistakes(document): Documented missing versus outdated tool diagnostics

* no-mistakes(document): Refresh outdated-tool documentation

* no-mistakes(review): Reuse shared version parser for outdated diagnostics

* no-mistakes(document): Correct outdated-tool diagnostics documentation

* no-mistakes(document): Align toolchain upgrade documentation

* fix(skills): keep main's bootstrap-diagnostics description and only add OUTDATED

* fix(bin): clarify ahoy skill legacy session-start exclusion to require verbatim match (#7530)

* Clarify ahoy legacy startup exclusion

* Fix quoted payload code span

* fix(bin): resolve timeout/gtimeout to executable paths via type -P (#7637)

* fix(timeout): bypass shell builtins when invoking external runners

* no-mistakes(review): Remove redundant slashless runner resolution from external timeout

* fix(bin): count answered captain holds moved to the Done archive as durable (#6094)

* fix: count answered captain holds in the Done archive at the completion gate

Done retention moves closed markdown rows into the configured Done archive,
which tasks-axi show never reads, so verify, complete, and scout teardown
refused an answered captain hold once retention archived it. The completion
gate now reads the newest archived block for an attested entry, under its
exact or legacy identity, and accepts it only through a recorded resolution.
Unanswered archived closes and holds found nowhere still refuse.

* no-mistakes(document): document Done-archive durability in captain-hold verification record

* no-mistakes(ci): Fixed the selected Greptile findings in bin/fm-captain-hold.sh (all in the Done-archive read path added by this PR). code_change_needed=true. ci-3 (Archived reads can hang): task_show_archived() now bounds the replayed archive `tasks-axi show` with the same read bound the live backlog read uses (FM_BACKLOG_ROW_TIMEOUT_SECS via fm_run_timed, sanitising a non-positive/padded value to 10s, mirroring fm_backlog_row_show). A bound hit is treated as 124, not absence: task_show_archived returns 124 and prints a loud reason; archived_entry() propagates 124; verify_entry_durable() exits 124 on the archived-read bound (alongside its existing resolve 124 handling); verify_hold_durable() exits 124 rather than reading the row as absent. So verify can no longer hang and complete can no longer stay blocked while holding the origin metadata lock. ci-4 (User-level archive setting ignored): added captain_markdown_archive_setting(), which resolves the [markdown] archive key with tasks-axi's own source precedence — the backlog root's .tasks.toml first, then $HOME/.tasks-axi/config.toml — before the existing default of done-archive.md beside the backlog; a relative value still resolves against the backlog root, which I verified empirically matches tasks-axi (root config wins over home config; a relative home-config value resolves against the backlog root; default stays data/done-archive.md). tasks-axi exposes no command for the archive path, so re-parsing with matched precedence is the available approach. Added test_archived_answer_in_a_user_configured_archive_satisfies_the_gate, which sets the archive only in a fixture $HOME/.tasks-axi/config.toml and drives the whole hold→answer→retention→verify/complete/teardown flow with that HOME, asserting the answered call archived to the relocated location still satisfies the gate. ci-5 (repeated archive scans, P2): left unchanged per the instruction's opt-out. A clean reuse of the row archived_entry already found is not small: archived_entry runs inside a command substitution, so its TASK_SHOW_OUTPUT dies with the subshell and cannot be handed to verify_hold_durable without restructuring both to pass the loaded row through the current shell. The growth is bounded (O(archive size) per attested entry) and P2, so hardening it would add more machinery than the fix warrants. Unanswered archived closes and holds found nowhere still refuse (existing test coverage retained). Verification: `bash -n` clean; pinned ShellCheck 0.11.0 (`shellcheck -x bin/fm-captain-hold.sh`) reports 0 findings; tasks-axi archive-precedence behaviour confirmed by direct experiment. The full fm-captain-hold-lifecycle.test.sh suite (which exercises both the pre-existing archived-gate test and the new user-config test) is slow due to beads spawns and was still running at report time; recommend confirming it green before merge. ci-1/ci-2 need no code change (action_required fork workflow runs awaiting maintainer approval), per the recorded user decision

* no-mistakes(document): Document Done-archive reads under backlog row timeout

* docs: say only the archive row replay is bounded, not the archive scan

* no-mistakes(document): Move Done-archive rule to the complete section

* fix(bin): read a PR with no CI checks as unverified, not checks green (#7627)

* fix(bin): optionally read a PR with no CI checks as unverified, not checks green

nm_ci_checks_state maps the ci log marker "no CI checks reported - still
monitoring" to green, the same verdict as "all CI checks passed". A pull
request that no check ever ran against therefore surfaced as "checks green: PR
ready for review" (#3216).

Add a no-checks verdict for that marker, returned only in a home that creates
config/ci-no-checks-not-green. The run-step consumer reports working with a
detail naming the real condition, and the status-log override no longer
promotes a crew's own "checks green" report while that marker is the latest.
Without the flag every reading is unchanged.

Co-authored-by: Harlan Do <hieudtr8@gmail.com>

* no-mistakes(document): document ended-monitor reading under the zero-checks flag

* fix(bin): read a PR with no CI checks as unverified on every home

The ci log marker "no CI checks reported - still monitoring" now always
yields the no-checks verdict, so a pull request that no check ran against is
reported as working instead of checks green (#3216). The opt-in flag, its
docs section, and its skill entry are removed, the default-path test now
expects working, and the usage header and architecture note describe the
no-checks reading.

---------

Co-authored-by: Harlan Do <hieudtr8@gmail.com>

* fix(bin): correct the wedge reset-failure log line and make the fault test root-safe (#7650)

* no-mistakes(review): correct the counter-reset log line, the sentinel comment, and the root proof

Three findings the review step recorded but never applied, all in this branch's own change.

The clean-rollback branch of the counter-reset guard logged "cap state rolled back", copied
from the sibling marker-write branch. That is wrong here: the cap marker was already written
before this block and _wedge_cap_rollback only truncates the counter, re-arms the since-file
and clears write tracking - it never clears the markers. The window therefore stays silenced
for FM_CAP_HORIZON_SECS, so the one operator-facing line must say that rather than claim the
cap state was rolled back. The rollback behaviour is unchanged and no marker-clear call is
added: the marker is deliberately kept so the window stays quiet.

The sentinel short-circuit comment opened "from either route that has to defend cap state"
and then enumerated three routes. Wording only.

The new regression case injected its fault with chmod 444, which does not restrict root, so
under root the guard would never fire and the case would fail on its own exit-code
assertion. It now skips as root the way this suite's other mode-based faults do. The
assertions are untouched: as the ordinary user the case still proves the guard.

* no-mistakes(review): name both ways a capped window leaves the silence in the reset log line

The tier-0 message for a refused post-fire escalation-counter reset says the cap marker
stands, so the window stays silent until its horizon elapses. That names one release route
where there are two: wedge_episode_end drops the marker through _wedge_cap_markers_clear, so
any episode-ending route ends the silence early, and docs/configuration.md records deleting
the marker as the operator's way to re-engage a capped window at once. This tier writes no
sentinel, so the marker is the only thing left to remove.

The message now names the horizon, an episode-ending route, and the operator remedy, in one
line in the same shape and position as its sibling tier-0 messages. The rollback behaviour,
the marker handling and the tier are unchanged.

* no-mistakes(document): correct root-skip comment's mode-bit precedent in wedge-cap test

* fix: resurface queued wakes from handling successors (#7466)

* fix(bin): resurface wakes appended while a handling successor is parked

The supervision host parks on the handling successor it starts for a wake
its engine handled, and a handling successor never resurfaced recovery, so
a row another script appended during the park (a captain inbox note from
the Basecamp integration) sat queued until an unrelated close - four hours
in the observed case.

A handling successor now records the newest queued sequence at its start
and closes once with the recovery wake while a newer row is still queued;
a newer row already consumed only advances that mark, so the predecessor's
delivered episode is still never re-announced.

Follow-ups, not built here:
- A row appended in the short window between a handled close and its
  successor's start (about a second) is below the successor's mark; if the
  engine handles that close without claiming the row, the row waits for the
  next close. Closing that window needs the host to treat rows left queued
  after a handled attended turn as main's, which is a separate host change.
- After a machine reboot the primary session does not restart on its own,
  so queued wakes wait until it is resumed by hand. Either auto-resume the
  primary session after boot, or alert the owner when the primary session
  is down while wakes are queued.

* no-mistakes(review): Close handling-successor startup wake race

* no-mistakes(test): Stabilize parked-host inbox wake regression timeout

* no-mistakes(document): Clarify handling-successor wake continuity guarantees

* no-mistakes(ci): Stabilized the flaky remote secondmate lifecycle test by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case

* no-mistakes(ci): Fixed flaky concurrent Herdr recovery testing by retrying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices

* no-mistakes(test): Preserve successor wake boundaries across handoffs

* no-mistakes(test): Revert successor boundaries and drain teardown fixture wake

* no-mistakes(test): Notify main when downtime handback publication fails

* no-mistakes(test): Revert downtime handback notification changes

* no-mistakes(document): Correct stale supervision wake routing documentation

* fix(bin): stop the supervision host deadlocking and re-announcing handed-back closes

Two defects in this branch's handling-successor changes surfaced as the
"Behavior portable serial 2" shard hanging at its 30-minute limit.

A TERM that lands while the host settles a handled turn's successor handoff
left the host holding the wake-queue and recovery-marker locks; its exit
cleanup then waited forever on the queue lock it still owned. The cleanup now
releases those locks if this process owns them before releasing its grant.

When an accepted close turns main-only at its turn, the host hands it back and
leaves the successor running, but republished the episode as pending
downtime, so that successor re-announced the same close and exited. The
handback now republishes the episode as already announced; a later durable
append still opens a pending episode the successor recovers.

* no-mistakes(test): Park on successor after handling settlement failure

* no-mistakes(test): Use tab-delimited handled-settlement failure logs

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(bin): preserve accents in pending-reply summaries (#7618)

* fix(bin): keep accented letters in pending-reply request summaries

fm_pending_reply_summarize deleted every byte outside printable ASCII, so a Portuguese summary lost its accents: "não faça a correção" was stored as "no faa a correo". It now removes control characters only. The 120-character cap counts UTF-8 characters from lead bytes, so it never splits a letter under any caller locale, including the C locale.

* no-mistakes(document): Documentar preservação de acentos nos resumos

---------

Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>

* feat: add OpenRouter support for typed dispatch resolution (#7149)

* Add explicit OpenRouter Jev dispatch resolution

* no-mistakes(document): Clarify dispatch documentation and remove stale duplicates

* chore: exclude local Stele binding from PR

* no-mistakes(document): Correct dispatch help and never-send documentation

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct dispatch architecture documentation ownership

* feat(bin): publish lane capacity facts with beat pressure and keyed limits (#6983)

Opt-in: fm-watch.sh publishes state/lane-capacity.json via bin/fm-capacity.sh --publish only while config/lane-capacity exists; adds beat pressure and keyed limits to fm-capacity.sh. Unconfigured fm-capacity output unchanged.

* fix(bin): propagate contribution input assembly failures (#5359)

* fix(bin): transport contribution-input JSON through slurpfile, not argjson

bin/fm-fleet-snapshot.sh --contribution-input passed the full backlog and
task-record JSON to jq through --argjson. A single --argjson argument is
capped by the kernel's MAX_ARG_STRLEN (131072 bytes on Linux), so a large
enough backlog made the kernel refuse to exec jq while the script still
exited 0 with a broken result.

Transport both documents through temporary files and --slurpfile, matching
the pattern the default snapshot path already uses, and propagate a
non-zero exit when that jq invocation fails.

Fixes #5349

* test: narrow contribution-input regression to final assembly failure

The ARG_MAX transport is already fixed on main by #6830, so keep only the regression proving a failing final jq assembly exits non-zero.

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): resolve the tmux container from firstmate's own session, not the most recent group member (#7662)

* fix(bin): resolve the tmux container from the caller's own session, not the most recent group member

* no-mistakes(test): Fall back when the $TMUX session id is stale

* no-mistakes(document): Document tmux container choice under grouped sessions

* fix(bin): read a fully dim Cursor idle placeholder as an empty composer (#7647)

* fix(bin): read a fully dim Cursor placeholder as an empty composer

cursor-agent 2026.10.19 draws the composer glyph and its idle placeholder
as one SGR 2 run with no reverse-video cell, so ghost stripping empties the
row and the empty-content guard returned unknown. Relaunch and exit then
refused on every idle Cursor pane on tmux.

When a styled bare row strips to empty and the plain row is an agent glyph
followed by an anchored idle placeholder, read it empty. Bright typed text,
other dim text, and unstyled rows keep their existing verdicts.

Fixes #7413

* docs(verification): record the fully dim Cursor placeholder verdict and refresh command

* fix(bin): say why away-mode inject deferred and pin named Claude idle composer as empty (#6163)

* fix(bin): recognize a named Claude session's titled composer rule on cursorless backends

`claude -n <name>` right-aligns the session name in the rule above the
composer. Cursorless backends (Herdr) accepted only solid rules, so the
scan saw the lower rule alone, the idle composer read `unknown`, and
away-mode delivery to a named Claude primary deferred until return.

A rule carrying one right-aligned title now opens a separator pair. It
never closes one, the pair it opens counts only over an agent-glyph row,
and it is never a valid Pi pair, so Pi's verdict is unchanged.

The away-mode composer deferral now names which refusal it was:
unsubmitted text, or no composer shape recognized.

* no-mistakes(review): Reword composer deferral reason to cover busy harness

* no-mistakes(ci): ci-3 (Greptile, user chose to fix): The rule that must always hold is that Claude's titled opening rule is accepted for any non-empty session name that doesn't start with a space and doesn't contain the rule glyph `─`, including a multiword name. The only place that check lives is the title `case` in `_fm_composer_titled_rule_row` (bin/fm-composer-lib.sh). It now reads `case "$title" in ''|' '*|*─*) return 1 ;; esac`, as the user asked, and the comment above the function mentions multiword titles. I added regression fixtures to `test_matrix_claude_named_session_titled_rule` in tests/fm-composer-lib.test.sh, next to the existing single-word `Andrew` cases. They use the title `Andrew Chen` and check that an idle composer on herdr reads `empty` and a composer with typed text reads `pending`. Something you should know: the old pattern already accepted a title with a space in the middle. It only rejected a title ending in a space. So the new multiword fixtures also pass against the old code, and the bot's failure scenario did not actually happen for "Andrew Chen". What the fix really changes is that it drops the trailing-space rejection, as instructed. Checks run: tests/fm-composer-lib.test.sh and tests/fm-composer-ghost.test.sh both pass (exit 0, no failures), and `shellcheck -x` is clean on both changed files

* no-mistakes(review): Match unnamed-ghost fixture rule width to the partner rule

* fix(bin): stop watcher arms whose ground is removed and reap Pi test process groups (#7666)

* fix(tests): reap Pi test process groups and stop arms whose ground is removed

Orphaned stub-arm pollers from tests/fm-pi-watch-extension.test.sh outlived
a failed case: they waited for release/stop files the failed driver never
wrote, teardown only removed the temp root, and the loops had no other exit.

Run each node driver in its own recorded process group and reap those groups
in teardown before the root is removed; end every blocking stub loop once its
own script is gone. bin/fm-watch-arm.sh now exits with a typed ground-removed
line within one poll when its script, state directory, or home is deleted,
instead of polling through the successor window.

* no-mistakes(document): Document arm exit when its ground is removed

* feat(bin): defer wedge escalation while a crew's no-mistakes run is validating (#5947)

* fix(bin): defer wedge escalation while an attributed validation run is running or fixing

While a no-mistakes run executes a round, the worker is correctly idle behind
its own blocking drive call, yet the watcher's wedge timer escalated a possible
wedge every FM_STALE_ESCALATE_SECS. The timer now consults the attributed run
step before escalating: a run the current-state reader reports as
validating (running) or validating (fixing) for a named run defers onto the
FM_PAUSE_RESURFACE_SECS recheck cadence, aged from a marker bound to that run
id. Parked, terminal, ci-monitoring, coarse, runless, absent and unreadable
runs keep the unchanged escalation ladder.

* test: count only the validating-run read in the unarmed parked-gate probe

* no-mistakes(document): add .validating-* to watcher-internals marker inventory

* no-mistakes(document): Update fm-watch.sh comments for validating-deferral chain

* no-mistakes(document): Document validating-run deferral in guard and handoff docs

* feat(watch): gate the validating-run wedge deferral behind config/wedge-defer-validating

The deferral changed the default for every home, unlike the comparable
config/wedge-defer-parked-gate and config/wedge-defer-worker-wait waits.
Absent the new presence flag the wedge timer spends no current-state read
for it and keeps the unchanged ladder.

* fix: identify Windows/Git Bash harness sessions for the session lock (#6300)

* fix(session-lock): identify a harness session on Windows/Git Bash

Every session start on Cygwin (Git for Windows) refused the fleet lock and
dropped to read-only with "cannot locate harness process in ancestry", so
spawning, steering, merging, the wake-queue drain, and supervision repair were
skipped on every start. Two independent causes, both on the identity path.

Cygwin's ps has no -o option at all and fails the whole invocation with
"unknown option -- o", so the ancestry walk aborted on its first hop. The walk
now reads comm, args, and ppid through accessors that fall back to Cygwin's
fixed ps columns, leaving the procps/BSD path unchanged.

That alone does not resolve the session: the parent link from a shell the
harness spawns does not cross the Cygwin boundary, and Cygwin reports that
shell's PPID as 1, so no walk can reach a harness that is a native Windows
process. Identity is instead taken from the session pid the harness publishes
and confirmed against the Windows process table before it is used - the pid
must still be live and its executable must independently identify a verified
harness - so an absent, stale, or non-harness value is discarded rather than
bound.

Walking the real Windows parent chain was implemented and then removed as
unsafe. MSYS emulates exec by spawning a fresh Windows process and exiting the
old one, so intermediate shells vanish and a child's recorded parent is
routinely a pid that no longer exists; Windows never reparents an orphan, so
that dangling id stays and can be reissued to an unrelated process. Following
it can bind a home's lock to the wrong process, which is the failure this file
exists to prevent. A harness that publishes nothing stays unresolved, which
leaves the session read-only exactly as before.

Windows pids are tagged rather than stored bare. They are a different namespace:
kill -0 reports a live Windows process as dead, and the number can collide with
an unrelated live Cygwin pid. The tag makes the value non-numeric, so a consumer
that treats it as a local pid - including a future kill - refuses it instead of
acting on the wrong process.

fm-sessionstart-nudge.sh carried a private second copy of the ownership walk and
so stayed wrong after the owner was fixed, nudging a session that already held
the lock. It now asks the owning function.

Verified on Windows 11 (Git Bash, Cygwin ps 3.4.10): the lock is acquired,
reports its holder, is idempotent, and refuses a bogus, dead, or non-harness
published pid. Regressions cover both platform departures behind a fake process
table, so they run on Linux and macOS CI too. The pre-existing e2e failure in
this suite on Windows is unchanged from main; it cannot exec its symlinked
fixture.

Refs #3396

Claude-Session: https://claude.ai/code/session_01F9T29YDqYSkQeDTC2Nfi7h
(cherry picked from commit 8b281b7b5507c342ac7870e8ccbefa56c55d05eb)

* fix(session-lock): keep the nudge's own ancestry question intact

Delegating the nudge to fm_session_lock_owned_by_self changed the question it
asks. The nudge asks whether a process in this ancestry took the lock; the
ownership predicate additionally requires a verified harness in that ancestry,
so a session whose lock was written by a plain shell started being nudged to
run session start again. tests/fm-sessionstart-nudge.test.sh pins the looser
contract deliberately.

The walk stays local, now reading ppid through the portable accessor so it also
survives a ps with no -o option, and defers to the ownership predicate only for
a Windows-tagged holder, which is not in this process table at all.

(cherry picked from commit 0baf64f71ffea275292a0fd88d033caccc041fc9)

* fix(session-lock): accept a tagged identity in every gate that reads the lock

The Windows identity added in this branch introduced a second shape into
state/.lock. Six gates read that field, and each one answered "is this value
usable" with its own inline numeric test, so every one of them read a valid
Windows holder as malformed.

The visible cost was concentrated in startup completion: the record was never
written, and the clear/compact check that consumes it could never match, so
every clear or compact on Windows repeated the full startup sequence. The
deferred network sweeps reported ownership as changed when it had not, and the
Stop auto-arm treated a dead Windows session as an unreadable lock rather than
a recoverable one. fm-lease.sh was the outlier: rather than refusing a value it
could not use, `tr -cd '0-9'` reduced the tag to its digits and produced a
number naming an unrelated process in the local table. It happened to fail
closed downstream, but deriving a wrong-namespace pid is precisely what the tag
exists to prevent, so it now takes the value whole and requires a local pid.

fm_session_pid_valid is now the single owner of that question and every gate
delegates to it, so a third identity shape cannot split them again.

Verified against the shipped bytes of each gate with a tagged lock: startup
completion now records and is recognized (main's gate reruns the full startup
on the same input), both network-ownership gates authorize their sweeps, and a
tagged lock yields no lease holder pid instead of 7204.

(cherry picked from commit 92561828fb9540ab6c77437def67a954e44b0418)

* fix(session-lock): gate the tagged identity on Windows and read it in every lock reader

Accept win:<digits> only where fm_win_boundary_applies, with an all-digit
remainder, so a Linux/macOS reader of a win:N lock stays inert as before.
The sessionstart nudge routes its tagged case through fm_win_untag_pid.
fm_session_lock_foreign_owner_live and fm_session_lock_inspect now validate
through fm_session_pid_valid and resolve a tagged holder through
fm_harness_pid_alive, so a live win:N holder reads as a live foreign owner
and as held; unverifiable tagged holders stay unknown.

* no-mistakes(document): Document Windows tagged session-lock identity in nudge and scripts docs

* fix(session-lock): keep task leases and stale detection working for a tagged holder

A Windows session can now hold the session lock as win:<pid>, but the task
lease still accepted only a local pid: the claim recorded the short-lived
fm-lease.sh process instead, and fm_lease_live rejected the tagged lock, so
the lease was never live and the other supervision actor could clear it and
act on the same task. The lease now records a live tagged lock holder whole
and treats it as live while it is still the lock holder and a verified
harness in the Windows process table. The session-lock library is loaded
only for a win:-shaped value, so POSIX lease verdicts are unchanged.

fm_session_lock_inspect left an exited tagged holder unknown, because
fm_win_command could not tell an absent pid from an unreadable table. It now
returns 1 only when a readable table proves the pid absent and 2 when the
table cannot be read, so inspection matches the local-pid contract: absent
is stale, a live non-harness is unknown with no live harness, and an
unreadable table stays unknown.

* no-mistakes(review): Restrict caller-supplied lease holder pid to local numeric

* no-mistakes(review): Pass tagged session-lock holder whole to task lease

* no-mistakes(review): Make tagged lease-holder regression tests fail without their fixes

* fix(session-lock): take a Windows CLAUDE_PID only with its session id

On Windows the session identity comes from CLAUDE_PID, which every process
started from a Claude pane inherits, so an unrelated process carrying a copy
could take the lock as that session and both would own it. The bridge now
accepts CLAUDE_PID only together with CLAUDE_CODE_SESSION_ID. The trusted
session-id gate matches the tagged win:<pid> form, so that id is recorded
beside the lock, and the anchor stays tagged. fm-lock.sh and the ownership
readers refuse the same tagged pid under a different recorded id as another
live session's. A non-Claude primary hand-started from a Claude pane inherits
both values and still resolves as that session; that remains a known
limitation. POSIX behavior is unchanged: every new branch applies only to a
tagged pid.

* fix(session-lock): let a Windows /clear re-key its own lock

/clear keeps the Claude process, so CLAUDE_PID stays while the session id
changes. Refusing the same tagged pid under a different recorded id locked a
session out of its own lock after /clear, which POSIX handles by re-keying
the sidecar. Drop that refusal: a Windows CLAUDE_PID is still taken only
together with its CLAUDE_CODE_SESSION_ID, and that id is still recorded
beside the lock and re-keyed on /clear as on POSIX.

* no-mistakes(review): Give tagged host test a session id; clarify Windows lock error

* no-mistakes(document): Point the trust-gate comment to the Windows limitation

---------

Co-authored-by: Lloyd <lloydkakunguwo@gmail.com>

* feat(bin): add opt-in local Claude usage threshold warner (#7421)

* feat(bin): add opt-in local Claude usage threshold warner

A usage window is exhausted without warning: work is cut off mid-run
rather than stopping deliberately, and nothing says a window is close to
its cap until it is already gone.

bin/fm-usage-warner.sh is a threshold warner, not a usage viewer.
quota-axi is already the one Claude-quota reader this repo depends on
(bin/fm-quota-axi-lib.sh), so the warner runs that existing read rather
than adding a second reader that could drift from it: one bounded
`quota-axi --provider claude --json --full --no-credential-refresh`, the
snapshot validated with fm_quota_json_valid, and the provider row picked
with the same FM_QUOTA_ROW_JQ join the dispatch consumers use, under
schema 5 and schema 6 alike.

Thresholds are `<window-id>:<percent>` directives in config/usage-warner,
naming quota-axi's own window ids (five_hour, seven_day, model:<name>)
rather than a second vocabulary, and compared against each window's own
percentUsed. Naming the window is the point: the session and weekly
windows exhaust at very different times, so a figure that does not say
which window is close misleads.

One read with two callers and no new schedule: `check` is what a human
runs on demand and what the watcher runs on its ordinary check-shim
cadence once `arm` registers state/usage-warner.check.sh through
bin/fm-check-register.sh. There is no daemon.

Warnings post through macOS Notification Center with the same osascript
call bin/fm-supervise-daemon.sh's wedge alarm makes, without sourcing or
coupling to that daemon's away-mode-specific config and rate limiting.
Delivery is edge-triggered against state/.usage-warner: a crossing warns
once, stays quiet while it holds, and re-arms when the window next reads
back below its threshold, the same standing-report contract
fm-mail-check.sh and fm-tool-update-check.sh already use.

bin/fm-procevent-quota.sh already reads the same snapshot, so docs name
the boundary rather than leaving two similar surfaces unexplained. That
source fires at most once, wakes firstmate with a durable check event,
and compares a provider's aggregate effectivePercentRemaining. This
warner is the standing, human-facing half: per-window, delivered to the
person through Notification Center, and self-re-arming. Neither replaces
the other and arming both is reasonable.

Opt-in is load-bearing and enforced in code. With no valid directive,
`check` returns before any read and `arm` refuses, so an unconfigured
home gains no behaviour change, no new failure mode, and no new hard
dependency at dispatch. Notification Center is macOS-only, so `arm`
refuses on other platforms instead of registering a check that could
never speak.

The warner only warns. It does not stop or pace dispatch, and its
coverage is exactly what quota-axi can see locally, so a plan or
organisation spend cap quota-axi does not report is not covered; the doc
says so rather than implying coverage it does not have.

The new test script carries no measured CI duration hint yet, so the
portable-serial lane balances it on the conservative default until the
hints are next refreshed from a green run, per docs/fm-test-portable-shards.md.

* no-mistakes(review): Key usage-warner de-dupe on window and threshold; fix docs

* no-mistakes(review): Keep absent-window crossings recorded; stub osascript in tests

* no-mistakes(document): Document absent-window de-dupe carry-forward in usage-warner header

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat(bin): add opt-in local Claude usage threshold warner

A usage window is exhausted without warning: work is cut off mid-run
rather than stopping deliberately, and nothing says a window is close to
its cap until it is already gone.

bin/fm-usage-warner.sh is a threshold warner, not a usage viewer.
quota-axi is already the one Claude-quota reader this repo depends on
(bin/fm-quota-axi-lib.sh), so the warner runs that existing read rather
than adding a second reader that could drift from it: one bounded
`quota-axi --provider claude --json --full --no-credential-refresh`, the
snapshot validated with fm_quota_json_valid, and the provider row picked
with the same FM_QUOTA_ROW_JQ join the dispatch consumers use, under
schema 5 and schema 6 alike.

Thresholds are `<window-id>:<percent>` directives in config/usage-warner,
naming quota-axi's own window ids (five_hour, seven_day, model:<name>)
rather than a second vocabulary, and compared against each window's own
percentUsed. Naming the window is the point: the session and weekly
windows exhaust at very different times, so a figure that does not say
which window is close misleads.

One read with two callers and no new schedule: `check` is what a human
runs on demand and what the watcher runs on its ordinary check-shim
cadence once `arm` registers state/usage-warner.check.sh through
bin/fm-check-register.sh. There is no daemon.

Warnings post through macOS Notification Center with the same osascript
call bin/fm-supervise-daemon.sh's wedge alarm makes, without sourcing or
coupling to that daemon's away-mode-specific config and rate limiting.
Delivery is edge-triggered against state/.usage-warner: a crossing warns
once, stays quiet while it holds, and re-arms when the window next reads
back below its threshold, the same standing-report contract
fm-mail-check.sh and fm-tool-update-check.sh already use.

bin/fm-procevent-quota.sh already reads the same snapshot, so docs name
the boundary rather than leaving two similar surfaces unexplained. That
source fires at most once, wakes firstmate with a durable check event,
and compares a provider's aggregate effectivePercentRemaining. This
warner is the standing, human-facing half: per-window, delivered to the
person through Notification Center, and self-re-arming. Neither replaces
the other and arming both is reasonable.

Opt-in is load-bearing and enforced in code. With no valid directive,
`check` returns before any read and `arm` refuses, so an unconfigured
home gains no behaviour change, no new failure mode, and no new hard
dependency at dispatch. Notification Center is macOS-only, so `arm`
refuses on other platforms instead of registering a check that could
never speak.

The warner only warns. It does not stop or pace dispatch, and its
coverage is exactly what quota-axi can see locally, so a plan or
organisation spend cap quota-axi does not report is not covered; the doc
says so rather than implying coverage it does not have.

The new test script carries no measured CI duration hint yet, so the
portable-serial lane balances it on the conservative default until the
hints are next refreshed from a green run, per docs/fm-test-portable-shards.md.

* no-mistakes(review): Key usage-warner de-dupe on window and threshold; fix docs

* no-mistakes(review): Keep absent-window crossings recorded; stub osascript in tests

* no-mistakes(document): Document absent-window de-dupe carry-forward in usage-warner header

* no-mistakes(review): Serialize usage-warner check, dedupe directives, drop vacuous greps

* no-mistakes(document): List usage-warner check lock in state layout

---------

Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Kostadin Pop-Kochev <kostadin.popkocev@gmail.com>
Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): stabilize remote worker process identity (#6440)

* fix(bin): use clock-stable /proc starttime for remote job worker ownership

Linux remote job ownership compared ps lstart, which drifts on WSL2 while
/proc starttime stays fixed, so ensure treated a healthy worker as dead and
started another supervisor on every call. fm_remote_job_process_start now emits
a proc-starttime token when /proc is readable and falls back to ps lstart
otherwise. The Linux start path hands a live worker of the configured root
whose lock still records a legacy start over to one replacement, checked
against the recorded and live command so no unrelated pid is signaled.

Fixes #2921

* no-mistakes(review): Treat legacy lstart claim starts as indeterminate, not mismatched

* no-mistakes(test): Assert legacy handoff interrupts job once

* no-mistakes(test): Remove scratch debug test; legacy job case git-tracked

* no-mistakes(test): Revert legacy start comparator; simplify legacy handoff test

* fix(bin): drop automatic legacy worker upgrade; document manual one-time restart

* chore: remove stray file

* no-mistakes(document): Drop stale handoff mention from remote worker docs

* fix(bin): verify pre-update remote job workers via legacy lstart

When a recorded start lacks the proc-starttime= prefix, compare it against
ps -o lstart= without LC_ALL=C so a healthy pre-update worker still verifies.
The ordinary code-identity path then replaces it once instead of piling
supervisors. Add regression coverage for the bare-lstart cookie and the
lock upgrade path.

* no-mistakes(document): Clarify legacy remote-job start verification docs

* no-mistakes(review): Preserve C-locale legacy cookie verification, captain

* no-mistakes(document): Clarify legacy process identity cookie compatibility

* no-mistakes(lint): Replace deprecated fgrep with lint-compliant grep -F

---------

Co-authored-by: Pitch Perfekt Collective <pitchperfekt@Pitchs-Mac-Studio.local>
Co-authored-by: mehulbhagwani <270960355+mehulbhagwani@users.noreply.github.com>

* feat(bin): add persistent managed-approval failover for Codex and Claude (#6722)

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

* fix: resurface queued wakes from handling successors (#7466)

* fix(bin): resurface wakes appended while a handling successor is parked

The supervision host parks on the handling successor it starts for a wake
its engine handled, and a handling successor never resurfaced recovery, so
a row another script appended during the park (a captain inbox note from
the Basecamp integration) sat queued until an unrelated close - four hours
in the observed case.

A handling successor now records the newest queued sequence at its start
and closes once with the recovery wake while a newer row is still queued;
a newer row already consumed only advances that mark, so the predecessor's
delivered episode is still never re-announced.

Follow-ups, not built here:
- A row appended in the short window between a handled close and its
  successor's start (about a second) is below the successor's mark; if the
  engine handles that close without claiming the row, the row waits for the
  next close. Closing that window needs the host to treat rows left queued
  after a handled attended turn as main's, which is a separate host change.
- After a machine reboot the primary session does not restart on its own,
  so queued wakes wait until it is resumed by hand. Either auto-resume the
  primary session after boot, or alert the owner when the primary session
  is down while wakes are queued.

* no-mistakes(review): Close handling-successor startup wake race

* no-mistakes(test): Stabilize parked-host inbox wake regression timeout

* no-mistakes(document): Clarify handling-successor wake continuity guarantees

* no-mistakes(ci): Stabilized the flaky remote secondmate lifecycle test by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case

* no-mistakes(ci): Fixed flaky concurrent Herdr recovery testing by retrying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices

* no-mistakes(test): Preserve successor wake boundaries across handoffs

* no-mistakes(test): Revert successor boundaries and drain teardown fixture wake

* no-mistakes(test): Notify main when downtime handback publication fails

* no-mistakes(test): Revert downtime handback notification changes

* no-mistakes(document): Correct stale supervision wake routing documentation

* fix(bin): stop the supervision host deadlocking and re-announcing handed-back closes

Two defects in this branch's handling-successor changes surfaced as the
"Behavior portable serial 2" shard hanging at its 30-minute limit.

A TERM that lands while the host settles a handled turn's successor handoff
left the host holding the wake-queue and recovery-marker locks; its exit
cleanup then waited forever on the queue lock it still owned. The cleanup now
releases those locks if this process owns them before releasing its grant.

When an accepted close turns main-only at its turn, the host hands it back and
leaves the successor running, but republished the episode as pending
downtime, so that successor re-announced the same close and exited. The
handback now republishes the episode as already announced; a later durable
append still opens a pending episode the successor recovers.

* no-mistakes(test): Park on successor after handling settlement failure

* no-mistakes(test): Use tab-delimited handled-settlement failure logs

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(bin): preserve accents in pending-reply summaries (#7618)

* fix(bin): keep accented letters in pending-reply request summaries

fm_pending_reply_summarize deleted every byte outside printable ASCII, so a Portuguese summary lost its accents: "não faça a correção" was stored as "no faa a correo". It now removes control characters only. The 120-character cap counts UTF-8 characters from lead bytes, so it never splits a letter under any caller locale, including the C locale.

* no-mistakes(document): Documentar preservação de acentos nos resumos

---------

Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>

* feat: add OpenRouter support for typed dispatch resolution (#7149)

* Add explicit OpenRouter Jev dispatch resolution

* no-mistakes(document): Clarify dispatch documentation and remove stale duplicates

* chore: exclude local Stele binding from PR

* no-mistakes(document): Correct dispatch help and never-send documentation

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct dispatch architecture documentation ownership

* feat(bin): publish lane capacity facts with beat pressure and keyed limits (#6983)

Opt-in: fm-watch.sh publishes state/lane-capacity.json via bin/fm-capacity.sh --publish only while config/lane-capacity exists; adds beat pressure and keyed limits to fm-capacity.sh. Unconfigured fm-capacity output unchanged.

* fix(bin): propagate contribution input assembly failures (#5359)

* fix(bin): transport contribution-input JSON through slurpfile, not argjson

bin/fm-fleet-snapshot.sh --contribution-input passed the full backlog and
task-record JSON to jq through --argjson. A single --argjson argument is
capped by the kernel's MAX_ARG_STRLEN (131072 bytes on Linux), so a large
enough backlog made the kernel refuse to exec jq while the script still
exited 0 with a broken result.

Transport both documents through temporary files and --slurpfile, matching
the pattern the default snapshot path already uses, and propagate a
non-zero exit when that jq invocation fails.

Fixes #5349

* test: narrow contribution-input regression to final assembly failure

The ARG_MAX transport is already fixed on main by #6830, so keep only the regression proving a failing final jq assembly exits non-zero.

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* t…
ywplee added a commit to ywplee/firstmate that referenced this pull request Nov 12, 2026
* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): resolve the tmux container from firstmate's own session, not the most recent group member (#7662)

* fix(bin): resolve the tmux container from the caller's own session, not the most recent group member

* no-mistakes(test): Fall back when the $TMUX session id is stale

* no-mistakes(document): Document tmux container choice under grouped sessions

* fix(bin): read a fully dim Cursor idle placeholder as an empty composer (#7647)

* fix(bin): read a fully dim Cursor placeholder as an empty composer

cursor-agent 2026.10.19 draws the composer glyph and its idle placeholder
as one SGR 2 run with no reverse-video cell, so ghost stripping empties the
row and the empty-content guard returned unknown. Relaunch and exit then
refused on every idle Cursor pane on tmux.

When a styled bare row strips to empty and the plain row is an agent glyph
followed by an anchored idle placeholder, read it empty. Bright typed text,
other dim text, and unstyled rows keep their existing verdicts.

Fixes #7413

* docs(verification): record the fully dim Cursor placeholder verdict and refresh command

* fix(bin): say why away-mode inject deferred and pin named Claude idle composer as empty (#6163)

* fix(bin): recognize a named Claude session's titled composer rule on cursorless backends

`claude -n <name>` right-aligns the session name in the rule above the
composer. Cursorless backends (Herdr) accepted only solid rules, so the
scan saw the lower rule alone, the idle composer read `unknown`, and
away-mode delivery to a named Claude primary deferred until return.

A rule carrying one right-aligned title now opens a separator pair. It
never closes one, the pair it opens counts only over an agent-glyph row,
and it is never a valid Pi pair, so Pi's verdict is unchanged.

The away-mode composer deferral now names which refusal it was:
unsubmitted text, or no composer shape recognized.

* no-mistakes(review): Reword composer deferral reason to cover busy harness

* no-mistakes(ci): ci-3 (Greptile, user chose to fix): The rule that must always hold is that Claude's titled opening rule is accepted for any non-empty session name that doesn't start with a space and doesn't contain the rule glyph `─`, including a multiword name. The only place that check lives is the title `case` in `_fm_composer_titled_rule_row` (bin/fm-composer-lib.sh). It now reads `case "$title" in ''|' '*|*─*) return 1 ;; esac`, as the user asked, and the comment above the function mentions multiword titles. I added regression fixtures to `test_matrix_claude_named_session_titled_rule` in tests/fm-composer-lib.test.sh, next to the existing single-word `Andrew` cases. They use the title `Andrew Chen` and check that an idle composer on herdr reads `empty` and a composer with typed text reads `pending`. Something you should know: the old pattern already accepted a title with a space in the middle. It only rejected a title ending in a space. So the new multiword fixtures also pass against the old code, and the bot's failure scenario did not actually happen for "Andrew Chen". What the fix really changes is that it drops the trailing-space rejection, as instructed. Checks run: tests/fm-composer-lib.test.sh and tests/fm-composer-ghost.test.sh both pass (exit 0, no failures), and `shellcheck -x` is clean on both changed files

* no-mistakes(review): Match unnamed-ghost fixture rule width to the partner rule

* fix(bin): stop watcher arms whose ground is removed and reap Pi test process groups (#7666)

* fix(tests): reap Pi test process groups and stop arms whose ground is removed

Orphaned stub-arm pollers from tests/fm-pi-watch-extension.test.sh outlived
a failed case: they waited for release/stop files the failed driver never
wrote, teardown only removed the temp root, and the loops had no other exit.

Run each node driver in its own recorded process group and reap those groups
in teardown before the root is removed; end every blocking stub loop once its
own script is gone. bin/fm-watch-arm.sh now exits with a typed ground-removed
line within one poll when its script, state directory, or home is deleted,
instead of polling through the successor window.

* no-mistakes(document): Document arm exit when its ground is removed

* feat(bin): defer wedge escalation while a crew's no-mistakes run is validating (#5947)

* fix(bin): defer wedge escalation while an attributed validation run is running or fixing

While a no-mistakes run executes a round, the worker is correctly idle behind
its own blocking drive call, yet the watcher's wedge timer escalated a possible
wedge every FM_STALE_ESCALATE_SECS. The timer now consults the attributed run
step before escalating: a run the current-state reader reports as
validating (running) or validating (fixing) for a named run defers onto the
FM_PAUSE_RESURFACE_SECS recheck cadence, aged from a marker bound to that run
id. Parked, terminal, ci-monitoring, coarse, runless, absent and unreadable
runs keep the unchanged escalation ladder.

* test: count only the validating-run read in the unarmed parked-gate probe

* no-mistakes(document): add .validating-* to watcher-internals marker inventory

* no-mistakes(document): Update fm-watch.sh comments for validating-deferral chain

* no-mistakes(document): Document validating-run deferral in guard and handoff docs

* feat(watch): gate the validating-run wedge deferral behind config/wedge-defer-validating

The deferral changed the default for every home, unlike the comparable
config/wedge-defer-parked-gate and config/wedge-defer-worker-wait waits.
Absent the new presence flag the wedge timer spends no current-state read
for it and keeps the unchanged ladder.

* fix: identify Windows/Git Bash harness sessions for the session lock (#6300)

* fix(session-lock): identify a harness session on Windows/Git Bash

Every session start on Cygwin (Git for Windows) refused the fleet lock and
dropped to read-only with "cannot locate harness process in ancestry", so
spawning, steering, merging, the wake-queue drain, and supervision repair were
skipped on every start. Two independent causes, both on the identity path.

Cygwin's ps has no -o option at all and fails the whole invocation with
"unknown option -- o", so the ancestry walk aborted on its first hop. The walk
now reads comm, args, and ppid through accessors that fall back to Cygwin's
fixed ps columns, leaving the procps/BSD path unchanged.

That alone does not resolve the session: the parent link from a shell the
harness spawns does not cross the Cygwin boundary, and Cygwin reports that
shell's PPID as 1, so no walk can reach a harness that is a native Windows
process. Identity is instead taken from the session pid the harness publishes
and confirmed against the Windows process table before it is used - the pid
must still be live and its executable must independently identify a verified
harness - so an absent, stale, or non-harness value is discarded rather than
bound.

Walking the real Windows parent chain was implemented and then removed as
unsafe. MSYS emulates exec by spawning a fresh Windows process and exiting the
old one, so intermediate shells vanish and a child's recorded parent is
routinely a pid that no longer exists; Windows never reparents an orphan, so
that dangling id stays and can be reissued to an unrelated process. Following
it can bind a home's lock to the wrong process, which is the failure this file
exists to prevent. A harness that publishes nothing stays unresolved, which
leaves the session read-only exactly as before.

Windows pids are tagged rather than stored bare. They are a different namespace:
kill -0 reports a live Windows process as dead, and the number can collide with
an unrelated live Cygwin pid. The tag makes the value non-numeric, so a consumer
that treats it as a local pid - including a future kill - refuses it instead of
acting on the wrong process.

fm-sessionstart-nudge.sh carried a private second copy of the ownership walk and
so stayed wrong after the owner was fixed, nudging a session that already held
the lock. It now asks the owning function.

Verified on Windows 11 (Git Bash, Cygwin ps 3.4.10): the lock is acquired,
reports its holder, is idempotent, and refuses a bogus, dead, or non-harness
published pid. Regressions cover both platform departures behind a fake process
table, so they run on Linux and macOS CI too. The pre-existing e2e failure in
this suite on Windows is unchanged from main; it cannot exec its symlinked
fixture.

Refs #3396

Claude-Session: https://claude.ai/code/session_01F9T29YDqYSkQeDTC2Nfi7h
(cherry picked from commit 8b281b7b5507c342ac7870e8ccbefa56c55d05eb)

* fix(session-lock): keep the nudge's own ancestry question intact

Delegating the nudge to fm_session_lock_owned_by_self changed the question it
asks. The nudge asks whether a process in this ancestry took the lock; the
ownership predicate additionally requires a verified harness in that ancestry,
so a session whose lock was written by a plain shell started being nudged to
run session start again. tests/fm-sessionstart-nudge.test.sh pins the looser
contract deliberately.

The walk stays local, now reading ppid through the portable accessor so it also
survives a ps with no -o option, and defers to the ownership predicate only for
a Windows-tagged holder, which is not in this process table at all.

(cherry picked from commit 0baf64f71ffea275292a0fd88d033caccc041fc9)

* fix(session-lock): accept a tagged identity in every gate that reads the lock

The Windows identity added in this branch introduced a second shape into
state/.lock. Six gates read that field, and each one answered "is this value
usable" with its own inline numeric test, so every one of them read a valid
Windows holder as malformed.

The visible cost was concentrated in startup completion: the record was never
written, and the clear/compact check that consumes it could never match, so
every clear or compact on Windows repeated the full startup sequence. The
deferred network sweeps reported ownership as changed when it had not, and the
Stop auto-arm treated a dead Windows session as an unreadable lock rather than
a recoverable one. fm-lease.sh was the outlier: rather than refusing a value it
could not use, `tr -cd '0-9'` reduced the tag to its digits and produced a
number naming an unrelated process in the local table. It happened to fail
closed downstream, but deriving a wrong-namespace pid is precisely what the tag
exists to prevent, so it now takes the value whole and requires a local pid.

fm_session_pid_valid is now the single owner of that question and every gate
delegates to it, so a third identity shape cannot split them again.

Verified against the shipped bytes of each gate with a tagged lock: startup
completion now records and is recognized (main's gate reruns the full startup
on the same input), both network-ownership gates authorize their sweeps, and a
tagged lock yields no lease holder pid instead of 7204.

(cherry picked from commit 92561828fb9540ab6c77437def67a954e44b0418)

* fix(session-lock): gate the tagged identity on Windows and read it in every lock reader

Accept win:<digits> only where fm_win_boundary_applies, with an all-digit
remainder, so a Linux/macOS reader of a win:N lock stays inert as before.
The sessionstart nudge routes its tagged case through fm_win_untag_pid.
fm_session_lock_foreign_owner_live and fm_session_lock_inspect now validate
through fm_session_pid_valid and resolve a tagged holder through
fm_harness_pid_alive, so a live win:N holder reads as a live foreign owner
and as held; unverifiable tagged holders stay unknown.

* no-mistakes(document): Document Windows tagged session-lock identity in nudge and scripts docs

* fix(session-lock): keep task leases and stale detection working for a tagged holder

A Windows session can now hold the session lock as win:<pid>, but the task
lease still accepted only a local pid: the claim recorded the short-lived
fm-lease.sh process instead, and fm_lease_live rejected the tagged lock, so
the lease was never live and the other supervision actor could clear it and
act on the same task. The lease now records a live tagged lock holder whole
and treats it as live while it is still the lock holder and a verified
harness in the Windows process table. The session-lock library is loaded
only for a win:-shaped value, so POSIX lease verdicts are unchanged.

fm_session_lock_inspect left an exited tagged holder unknown, because
fm_win_command could not tell an absent pid from an unreadable table. It now
returns 1 only when a readable table proves the pid absent and 2 when the
table cannot be read, so inspection matches the local-pid contract: absent
is stale, a live non-harness is unknown with no live harness, and an
unreadable table stays unknown.

* no-mistakes(review): Restrict caller-supplied lease holder pid to local numeric

* no-mistakes(review): Pass tagged session-lock holder whole to task lease

* no-mistakes(review): Make tagged lease-holder regression tests fail without their fixes

* fix(session-lock): take a Windows CLAUDE_PID only with its session id

On Windows the session identity comes from CLAUDE_PID, which every process
started from a Claude pane inherits, so an unrelated process carrying a copy
could take the lock as that session and both would own it. The bridge now
accepts CLAUDE_PID only together with CLAUDE_CODE_SESSION_ID. The trusted
session-id gate matches the tagged win:<pid> form, so that id is recorded
beside the lock, and the anchor stays tagged. fm-lock.sh and the ownership
readers refuse the same tagged pid under a different recorded id as another
live session's. A non-Claude primary hand-started from a Claude pane inherits
both values and still resolves as that session; that remains a known
limitation. POSIX behavior is unchanged: every new branch applies only to a
tagged pid.

* fix(session-lock): let a Windows /clear re-key its own lock

/clear keeps the Claude process, so CLAUDE_PID stays while the session id
changes. Refusing the same tagged pid under a different recorded id locked a
session out of its own lock after /clear, which POSIX handles by re-keying
the sidecar. Drop that refusal: a Windows CLAUDE_PID is still taken only
together with its CLAUDE_CODE_SESSION_ID, and that id is still recorded
beside the lock and re-keyed on /clear as on POSIX.

* no-mistakes(review): Give tagged host test a session id; clarify Windows lock error

* no-mistakes(document): Point the trust-gate comment to the Windows limitation

---------

Co-authored-by: Lloyd <lloydkakunguwo@gmail.com>

* feat(bin): add opt-in local Claude usage threshold warner (#7421)

* feat(bin): add opt-in local Claude usage threshold warner

A usage window is exhausted without warning: work is cut off mid-run
rather than stopping deliberately, and nothing says a window is close to
its cap until it is already gone.

bin/fm-usage-warner.sh is a threshold warner, not a usage viewer.
quota-axi is already the one Claude-quota reader this repo depends on
(bin/fm-quota-axi-lib.sh), so the warner runs that existing read rather
than adding a second reader that could drift from it: one bounded
`quota-axi --provider claude --json --full --no-credential-refresh`, the
snapshot validated with fm_quota_json_valid, and the provider row picked
with the same FM_QUOTA_ROW_JQ join the dispatch consumers use, under
schema 5 and schema 6 alike.

Thresholds are `<window-id>:<percent>` directives in config/usage-warner,
naming quota-axi's own window ids (five_hour, seven_day, model:<name>)
rather than a second vocabulary, and compared against each window's own
percentUsed. Naming the window is the point: the session and weekly
windows exhaust at very different times, so a figure that does not say
which window is close misleads.

One read with two callers and no new schedule: `check` is what a human
runs on demand and what the watcher runs on its ordinary check-shim
cadence once `arm` registers state/usage-warner.check.sh through
bin/fm-check-register.sh. There is no daemon.

Warnings post through macOS Notification Center with the same osascript
call bin/fm-supervise-daemon.sh's wedge alarm makes, without sourcing or
coupling to that daemon's away-mode-specific config and rate limiting.
Delivery is edge-triggered against state/.usage-warner: a crossing warns
once, stays quiet while it holds, and re-arms when the window next reads
back below its threshold, the same standing-report contract
fm-mail-check.sh and fm-tool-update-check.sh already use.

bin/fm-procevent-quota.sh already reads the same snapshot, so docs name
the boundary rather than leaving two similar surfaces unexplained. That
source fires at most once, wakes firstmate with a durable check event,
and compares a provider's aggregate effectivePercentRemaining. This
warner is the standing, human-facing half: per-window, delivered to the
person through Notification Center, and self-re-arming. Neither replaces
the other and arming both is reasonable.

Opt-in is load-bearing and enforced in code. With no valid directive,
`check` returns before any read and `arm` refuses, so an unconfigured
home gains no behaviour change, no new failure mode, and no new hard
dependency at dispatch. Notification Center is macOS-only, so `arm`
refuses on other platforms instead of registering a check that could
never speak.

The warner only warns. It does not stop or pace dispatch, and its
coverage is exactly what quota-axi can see locally, so a plan or
organisation spend cap quota-axi does not report is not covered; the doc
says so rather than implying coverage it does not have.

The new test script carries no measured CI duration hint yet, so the
portable-serial lane balances it on the conservative default until the
hints are next refreshed from a green run, per docs/fm-test-portable-shards.md.

* no-mistakes(review): Key usage-warner de-dupe on window and threshold; fix docs

* no-mistakes(review): Keep absent-window crossings recorded; stub osascript in tests

* no-mistakes(document): Document absent-window de-dupe carry-forward in usage-warner header

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat(bin): add opt-in local Claude usage threshold warner

A usage window is exhausted without warning: work is cut off mid-run
rather than stopping deliberately, and nothing says a window is close to
its cap until it is already gone.

bin/fm-usage-warner.sh is a threshold warner, not a usage viewer.
quota-axi is already the one Claude-quota reader this repo depends on
(bin/fm-quota-axi-lib.sh), so the warner runs that existing read rather
than adding a second reader that could drift from it: one bounded
`quota-axi --provider claude --json --full --no-credential-refresh`, the
snapshot validated with fm_quota_json_valid, and the provider row picked
with the same FM_QUOTA_ROW_JQ join the dispatch consumers use, under
schema 5 and schema 6 alike.

Thresholds are `<window-id>:<percent>` directives in config/usage-warner,
naming quota-axi's own window ids (five_hour, seven_day, model:<name>)
rather than a second vocabulary, and compared against each window's own
percentUsed. Naming the window is the point: the session and weekly
windows exhaust at very different times, so a figure that does not say
which window is close misleads.

One read with two callers and no new schedule: `check` is what a human
runs on demand and what the watcher runs on its ordinary check-shim
cadence once `arm` registers state/usage-warner.check.sh through
bin/fm-check-register.sh. There is no daemon.

Warnings post through macOS Notification Center with the same osascript
call bin/fm-supervise-daemon.sh's wedge alarm makes, without sourcing or
coupling to that daemon's away-mode-specific config and rate limiting.
Delivery is edge-triggered against state/.usage-warner: a crossing warns
once, stays quiet while it holds, and re-arms when the window next reads
back below its threshold, the same standing-report contract
fm-mail-check.sh and fm-tool-update-check.sh already use.

bin/fm-procevent-quota.sh already reads the same snapshot, so docs name
the boundary rather than leaving two similar surfaces unexplained. That
source fires at most once, wakes firstmate with a durable check event,
and compares a provider's aggregate effectivePercentRemaining. This
warner is the standing, human-facing half: per-window, delivered to the
person through Notification Center, and self-re-arming. Neither replaces
the other and arming both is reasonable.

Opt-in is load-bearing and enforced in code. With no valid directive,
`check` returns before any read and `arm` refuses, so an unconfigured
home gains no behaviour change, no new failure mode, and no new hard
dependency at dispatch. Notification Center is macOS-only, so `arm`
refuses on other platforms instead of registering a check that could
never speak.

The warner only warns. It does not stop or pace dispatch, and its
coverage is exactly what quota-axi can see locally, so a plan or
organisation spend cap quota-axi does not report is not covered; the doc
says so rather than implying coverage it does not have.

The new test script carries no measured CI duration hint yet, so the
portable-serial lane balances it on the conservative default until the
hints are next refreshed from a green run, per docs/fm-test-portable-shards.md.

* no-mistakes(review): Key usage-warner de-dupe on window and threshold; fix docs

* no-mistakes(review): Keep absent-window crossings recorded; stub osascript in tests

* no-mistakes(document): Document absent-window de-dupe carry-forward in usage-warner header

* no-mistakes(review): Serialize usage-warner check, dedupe directives, drop vacuous greps

* no-mistakes(document): List usage-warner check lock in state layout

---------

Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Kostadin Pop-Kochev <kostadin.popkocev@gmail.com>
Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): stabilize remote worker process identity (#6440)

* fix(bin): use clock-stable /proc starttime for remote job worker ownership

Linux remote job ownership compared ps lstart, which drifts on WSL2 while
/proc starttime stays fixed, so ensure treated a healthy worker as dead and
started another supervisor on every call. fm_remote_job_process_start now emits
a proc-starttime token when /proc is readable and falls back to ps lstart
otherwise. The Linux start path hands a live worker of the configured root
whose lock still records a legacy start over to one replacement, checked
against the recorded and live command so no unrelated pid is signaled.

Fixes #2921

* no-mistakes(review): Treat legacy lstart claim starts as indeterminate, not mismatched

* no-mistakes(test): Assert legacy handoff interrupts job once

* no-mistakes(test): Remove scratch debug test; legacy job case git-tracked

* no-mistakes(test): Revert legacy start comparator; simplify legacy handoff test

* fix(bin): drop automatic legacy worker upgrade; document manual one-time restart

* chore: remove stray file

* no-mistakes(document): Drop stale handoff mention from remote worker docs

* fix(bin): verify pre-update remote job workers via legacy lstart

When a recorded start lacks the proc-starttime= prefix, compare it against
ps -o lstart= without LC_ALL=C so a healthy pre-update worker still verifies.
The ordinary code-identity path then replaces it once instead of piling
supervisors. Add regression coverage for the bare-lstart cookie and the
lock upgrade path.

* no-mistakes(document): Clarify legacy remote-job start verification docs

* no-mistakes(review): Preserve C-locale legacy cookie verification, captain

* no-mistakes(document): Clarify legacy process identity cookie compatibility

* no-mistakes(lint): Replace deprecated fgrep with lint-compliant grep -F

---------

Co-authored-by: Pitch Perfekt Collective <pitchperfekt@Pitchs-Mac-Studio.local>
Co-authored-by: mehulbhagwani <270960355+mehulbhagwani@users.noreply.github.com>

* feat(bin): add persistent managed-approval failover for Codex and Claude (#6722)

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

* fix: resurface queued wakes from handling successors (#7466)

* fix(bin): resurface wakes appended while a handling successor is parked

The supervision host parks on the handling successor it starts for a wake
its engine handled, and a handling successor never resurfaced recovery, so
a row another script appended during the park (a captain inbox note from
the Basecamp integration) sat queued until an unrelated close - four hours
in the observed case.

A handling successor now records the newest queued sequence at its start
and closes once with the recovery wake while a newer row is still queued;
a newer row already consumed only advances that mark, so the predecessor's
delivered episode is still never re-announced.

Follow-ups, not built here:
- A row appended in the short window between a handled close and its
  successor's start (about a second) is below the successor's mark; if the
  engine handles that close without claiming the row, the row waits for the
  next close. Closing that window needs the host to treat rows left queued
  after a handled attended turn as main's, which is a separate host change.
- After a machine reboot the primary session does not restart on its own,
  so queued wakes wait until it is resumed by hand. Either auto-resume the
  primary session after boot, or alert the owner when the primary session
  is down while wakes are queued.

* no-mistakes(review): Close handling-successor startup wake race

* no-mistakes(test): Stabilize parked-host inbox wake regression timeout

* no-mistakes(document): Clarify handling-successor wake continuity guarantees

* no-mistakes(ci): Stabilized the flaky remote secondmate lifecycle test by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case

* no-mistakes(ci): Fixed flaky concurrent Herdr recovery testing by retrying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices

* no-mistakes(test): Preserve successor wake boundaries across handoffs

* no-mistakes(test): Revert successor boundaries and drain teardown fixture wake

* no-mistakes(test): Notify main when downtime handback publication fails

* no-mistakes(test): Revert downtime handback notification changes

* no-mistakes(document): Correct stale supervision wake routing documentation

* fix(bin): stop the supervision host deadlocking and re-announcing handed-back closes

Two defects in this branch's handling-successor changes surfaced as the
"Behavior portable serial 2" shard hanging at its 30-minute limit.

A TERM that lands while the host settles a handled turn's successor handoff
left the host holding the wake-queue and recovery-marker locks; its exit
cleanup then waited forever on the queue lock it still owned. The cleanup now
releases those locks if this process owns them before releasing its grant.

When an accepted close turns main-only at its turn, the host hands it back and
leaves the successor running, but republished the episode as pending
downtime, so that successor re-announced the same close and exited. The
handback now republishes the episode as already announced; a later durable
append still opens a pending episode the successor recovers.

* no-mistakes(test): Park on successor after handling settlement failure

* no-mistakes(test): Use tab-delimited handled-settlement failure logs

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(bin): preserve accents in pending-reply summaries (#7618)

* fix(bin): keep accented letters in pending-reply request summaries

fm_pending_reply_summarize deleted every byte outside printable ASCII, so a Portuguese summary lost its accents: "não faça a correção" was stored as "no faa a correo". It now removes control characters only. The 120-character cap counts UTF-8 characters from lead bytes, so it never splits a letter under any caller locale, including the C locale.

* no-mistakes(document): Documentar preservação de acentos nos resumos

---------

Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>

* feat: add OpenRouter support for typed dispatch resolution (#7149)

* Add explicit OpenRouter Jev dispatch resolution

* no-mistakes(document): Clarify dispatch documentation and remove stale duplicates

* chore: exclude local Stele binding from PR

* no-mistakes(document): Correct dispatch help and never-send documentation

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct dispatch architecture documentation ownership

* feat(bin): publish lane capacity facts with beat pressure and keyed limits (#6983)

Opt-in: fm-watch.sh publishes state/lane-capacity.json via bin/fm-capacity.sh --publish only while config/lane-capacity exists; adds beat pressure and keyed limits to fm-capacity.sh. Unconfigured fm-capacity output unchanged.

* fix(bin): propagate contribution input assembly failures (#5359)

* fix(bin): transport contribution-input JSON through slurpfile, not argjson

bin/fm-fleet-snapshot.sh --contribution-input passed the full backlog and
task-record JSON to jq through --argjson. A single --argjson argument is
capped by the kernel's MAX_ARG_STRLEN (131072 bytes on Linux), so a large
enough backlog made the kernel refuse to exec jq while the script still
exited 0 with a broken result.

Transport both documents through temporary files and --slurpfile, matching
the pattern the default snapshot path already uses, and propagate a
non-zero exit when that jq invocation fails.

Fixes #5349

* test: narrow contribution-input regression to final assembly failure

The ARG_MAX transport is already fixed on main by #6830, so keep only the regression proving a failing final jq assembly exits non-zero.

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): resolve the tmux container from firstmate's own session, not the most recent group member (#7662)

* fix(bin): resolve the tmux container from the caller's own session, not the most recent group member

* no-mistakes(test): Fall back when the $TMUX session id is stale

* no-mistakes(document): Document tmux container choice under grouped sessions

* fix(bin): read a fully dim Cursor idle placeholder as an empty composer (#7647)

* fix(bin): read a fully dim Cursor placeholder as an empty composer

cursor-agent 2026.10.19 draws the composer glyph and its idle placeholder
as one SGR 2 run with no reverse-video cell, so ghost stripping empties the
row and the empty-content guard returned unknown. Relaunch and exit then
refused on every idle Cursor pane on tmux.

When a styled bare row strips to empty and the plain row is an agent glyph
followed by an anchored idle placeholder, read it empty. Bright typed text,
other dim text, and unstyled rows keep their existing verdicts.

Fixes #7413

* docs(verification): record the fully dim Cursor placeholder verdict and refresh command

* fix(bin): say why away-mode inject deferred and pin named Claude idle composer as empty (#6163)

* fix(bin): recognize a named Claude session's titled composer rule on cursorless backends

`claude -n <name>` right-aligns the session name in the rule above the
composer. Cursorless backends (Herdr) accepted only solid rules, so the
scan saw the lower rule alone, the idle composer read `unknown`, and
away-mode delivery to a named Claude primary deferred until return.

A rule carrying one right-aligned title now opens a separator pair. It
never closes one, the pair it opens counts only over an agent-glyph row,
and it is never a valid Pi pair, so Pi's verdict is unchanged.

The away-mode composer deferral now names which refusal it was:
unsubmitted text, or no composer shape recognized.

* no-mistakes(review): Reword composer deferral reason to cover busy harness

* no-mistakes(ci): ci-3 (Greptile, user chose to fix): The rule that must always hold is that Claude's titled opening rule is accepted for any non-empty session name that doesn't start with a space and doesn't contain the rule glyph `─`, including a multiword name. The only place that check lives is the title `case` in `_fm_composer_titled_rule_row` (bin/fm-composer-lib.sh). It now reads `case "$title" in ''|' '*|*─*) return 1 ;; esac`, as the user asked, and the comment above the function mentions multiword titles. I added regression fixtures to `test_matrix_claude_named_session_titled_rule` in tests/fm-composer-lib.test.sh, next to the existing single-word `Andrew` cases. They use the title `Andrew Chen` and check that an idle composer on herdr reads `empty` and a composer with typed text reads `pending`. Something you should know: the old pattern already accepted a title with a space in the middle. It only rejected a title ending in a space. So the new multiword fixtures also pass against the old code, and the bot's failure scenario did not actually happen for "Andrew Chen". What the fix really changes is that it drops the trailing-space rejection, as instructed. Checks run: tests/fm-composer-lib.test.sh and tests/fm-composer-ghost.test.sh both pass (exit 0, no failures), and `shellcheck -x` is clean on both changed files

* no-mistakes(review): Match unnamed-ghost fixture rule width to the partner rule

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Caleb LeNoir <caleb.lenoir@constructease.com>
Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>
Co-authored-by: Alexandre Custodio <xandy.alexandrec@gmail.com>
Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>
Co-authored-by: Pedro Guimarães <21346846+0x7067@users.noreply.github.com>
Co-authored-by: Konner Moshier <39997550+Moshik21@users.noreply.github.com>
Co-authored-by: Oscar Santis Brante <49914973+osantis@users.noreply.github.com>
Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Kostadin Pop-Kochev <kostadin.popkocev@gmail.com>
Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Tomas Perez <71987424+tomasperezcoscia@users.noreply.github.com>
Co-authored-by: Cameron Aragon <69489633+camaragon@users.noreply.github.com>
Co-authored-by: Brian <bthome@users.noreply.github.com>

* fix(bin): keep handling successors from stranding inbox wakes after counter loss (#6467)

* fix: notify handling successors about newer inbox wakes

* no-mistakes(document): Document handling-successor inbox regression in watcher coverage list

* no-mistakes(ci): Fixed Greptile P1 (comment 4172295712): a handling successor could miss a new inbox wake when `.wake-queue.seq` was missing or malformed. What must always hold: a row added after the successor took its snapshot must be announced and must never be consumed by an older acknowledgement. Two places were breaking this: 1. `bin/fm-watch.sh`: the successor only recorded the highest inherited sequence number. If the counter was reset, a new row could get a number at or below that and be treated as already covered. This now stays silent forever once the inherited rows are acknowledged and the queue drains. 2. `bin/fm-wake-lib.sh` `fm_wake_append_locked`: a reset counter reused the sequence number of a row still in the queue. The predecessor's pending `--ack-through` consumes rows by sequence number, so it deleted the new row before anyone handled it. This was a gap in the existing allocator, and it is what made the before-ack cases fail even after fix 1. Fixes: - Watcher: the successor now snapshots the inherited rows themselves instead of their highest sequence. On each poll it announces if any queued row is not in that snapshot. It still never consumes rows, and inherited rows alone stay silent. - Allocator: the next sequence is now one more than the larger of the counter and the highest sequence still queued, so a new row can't land inside an outstanding acknowledgement's range. - `docs/watcher-continuity.md`: the paragraph and coverage list are updated to match. Tests: `test_append_wakes_handling_successor` in `tests/fm-watch-arm.test.sh` now inherits two rows and takes a counter state (intact, missing, malformed). The four new cases are after-ack and before-ack with a missing or malformed counter, and they run real watcher, arm and drain processes. In after-ack the queue is fully drained before the new append. Evidence: - Before any production change (on 92c724d), all four new cases failed: "not ok - handling successor stranded the second inbox wake" for after-ack and before-ack. - With only the watcher fix, the after-ack cases passed and the before-ack cases still failed, which shows the allocator fix is needed. - With both fixes, all four pass. Full results: `fm-watch-arm` 36/36 (including the intact after-ack and before-ack cases, so ordinary silence and fresh-beacon delivery still hold), `fm-watch-recovery-loop` 2/2, `fm-inbox` 16/16, `fm-pi-watch-extension` 60/60, `fm-wake-queue` 67/67, and all four `fm-wake-drain-*` suites passed (9, 9, 18, 14). Canonical `bin/fm-lint.sh` with `PATH=/home/nino/.local/bin:$PATH` passed: ShellCheck clean, actionlint 1.7.12, 3 workflows valid. That lint run was in local changed-file mode with ShellCheck source following disabled. In a first run of all nine suites in parallel, `fm-wake-queue` failed on "presentation lock delayed the drain for 10s" and one `fm-pi-watch-extension` timing test failed. Both passed in full when rerun on their own, so I read that as load contention, not this change. Design decision to flag: the allocator change sits in the shared wake library, so it goes beyond the watcher comparison the bot pointed at. It is a one-expression change, and the before-ack tests can't pass without it, because otherwise the predecessor's acknowledgement deletes the new message. Not done, per the phase boundary: nothing committed, pushed or posted, and the live fleet was not touched. Evidence logs are in /tmp/fmci, not in a pipeline logs/evidence directory

* no-mistakes(ci): Fixed both Greptile findings on PR #6467. Nothing was committed, pushed or posted, and the live fleet was not touched. **ci-1 (4172409813): a new wake was mistaken for an inherited one.** - Invariant that must hold: a successor treats a row as covered only if it is an unchanged inherited row in the inherited recovery episode. - Cause: after the predecessor's acknowledgement and a lost counter, a re-append with the same kind, key, payload and epoch was byte-identical to the snapshot row, so the successor stayed silent. - Fix (`bin/fm-watch.sh`): I used the existing recovery generation rather than a new identity scheme. Any append after an acknowledgement mints a new generation. The successor records the generation with its row snapshot, under the queue lock and in arm-check's lock order. Each poll counts the queue as newer if a row is not in the snapshot, or if the queue is non-empty and the generation changed. The existing arm-check then decides whether to announce. No rows are consumed, and inherited rows alone stay silent. - The row snapshot is still needed for before-ack, because an append before the acknowledgement keeps the same generation. **ci-2 (4172409821): large sequence numbers became unusable.** - Invariant that must hold: sequence numbers are always exact digit-only decimals. - Fix (`bin/fm-wake-lib.sh`): the allocator picks the largest of the counter and the queued sequences by comparing decimal text (length, then string order, leading zeros stripped), then adds 1 in bash with `$((10#$seq + 1))`. This restores the 64-bit exactness of the original bash counter. - Same fix at two places in `bin/fm-wake-drain.sh` that print sequences: `presented_max_row` and `ACK_THROUGH` print the matched text instead of `max + 0`. **Tests** - `tests/fm-watch-arm.test.sh`: two new `identical` cases, after-ack with a missing and with a malformed counter. A fake `date` pins the epoch, and the test asserts the row is byte-identical, then checks timely notification, preservation until its own acknowledgement, and no repeat notification. - `tests/fm-wake-queue.test.sh`: new `test_large_sequences_stay_exact_decimal_identifiers` starts from 2147483647, 9007199254740991 and 9223372036854775806, each with an intact, missing and malformed counter. It checks the next sequence is exact and digit-only. For the first two it also checks a real drain shows both rows, names the exact acknowledgement sequence, and acknowledging empties the queue. - `docs/watcher-continuity.md` now describes the generation check. **Evidence** (in `/home/nino/.no-mistakes/evidence/01M40CDTX2000A5TFFRZN27YFR/ci-round3/`) - Before, on 050a5fc: both identical cases failed with "handling successor stranded the second inbox wake (after-ack)". The large-sequence test failed with "advanced to '9223372036854775808', not 9223372036854775807". - After the fix, all three pass (`after-*.log`). - All nine suites passed, each run on its own, all with 0 not ok (`final-results.txt`): `fm-wake-queue` 68/68, `fm-watch-arm` 38/38, `fm-watch-recovery-loop` 2/2, `fm-inbox` 16/16, `fm-pi-watch-extension` 60/60, `fm-wake-drain-open-decisions-cursor` 9/9, `fm-wake-drain-open-decisions` 9/9, `fm-wake-drain-outcome-backstop` 18/18, `fm-wake-drain-unread-status` 14/14. - `bin/fm-lint.sh` with `PATH=/home/nino/.local/bin:$PATH` passes: ShellCheck clean, actionlint 1.7.12, 3 workflows valid (local changed-file mode). **Not run** - The only OpenCode suite is an opt-in live test, so I did not run it. **Limits** - The 2.14748e+09 symptom doesn't reproduce with the awks here (gawk, mawk 1.3.4, busybox). The failure reproduced locally is the precision loss at 64-bit values. - The drain's awk comparisons are only exact up to 2^53. That predates this PR and I left it alone, so the drain test stops at 2^53

* no-mistakes(document): Reattach successor poll-loop sentence to its subject

* fix(bin): stop lock waits and test fixtures from spinning after their directory is removed (#7685)

* fix(tests): bound lock waits on removed dirs and reap fixture-root processes

A lock wait spun every 0.1s forever once its directory was removed, so a
watcher or reconcile scan of a deleted test home never reached its own
home-gone exit. fm_lock_acquire_wait now returns within 0.2s once the
lock's parent directory is gone.

Test teardown now signals every process naming the exact fixture root
(TERM, then KILL) before removing it, in both fm_test_cleanup and the
orphan sweep. The supervision-host fake harness sessions stop once their
home is gone or the suite pid has died, so a hard-killed runner no longer
leaves them polling under init.

Fixes #7672

* fix(tests): bound the session-lock concurrency barrier

Forty workers polled a find pipeline every 0.01s to wait for each other,
so the barrier alone launched thousands of processes a second, and once a
stopped run removed the barrier directory the workers polled forever under
init. Count entries with a builtin glob every 0.05s, and end the wait once
the directory is gone, the suite has died, or the stub block bound passes.

Refs #7672

* fix: watch review-bot findings on owned pull requests (#7499)

* fix(bin): admit listed review-bot comments as contribution signals

* no-mistakes(review): Persist review-bot config in contribution check shim

* no-mistakes(review): Classify allowlisted collaborators as review bots

* no-mistakes(document): Document review-bot contribution signals

* no-mistakes(review): Preserve review-bot config and re-raise classification

* no-mistakes(review): Prevent acknowledged bot signals replaying after allowlist changes

* no-mistakes(document): Document configurable review-bot contribution watching

* no-mistakes(document): Clarify review-bot thread documentation

* fix(bin): make review-bot contribution watching opt-in

* docs(bin): state review-bot allowlist has no built-in default

* no-mistakes(document): Document per-home review-bot configuration

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(brief): drop undefined heavy-test slot from the Waiting section (#7674)

The generated Waiting section told workers to wait on a heavy-test slot that nothing in the repository defines. Remove the phrase and assert that a brief generated with config/wait-no-turns does not name one.

* fix(bin): read the no_ci ci-monitor marker as no-checks (#7675)

* fix(bin): read the no_ci ci-monitor marker as no-checks instead of validating

Fixes #7644

* no-mistakes(document): Rewrap nm_ci_checks_state no_ci comment

* feat(bin): add opt-in restricted permission mode for Codex workers (#7683)

* feat: add opt-in restricted permissions for Codex workers

* no-mistakes(review): Document restricted Codex network and git approval limits

* fix(test): keep serial packing at-budget fixture stable with unhinted scripts (#7699)

* fix(test): keep serial packing at-budget when a script has no hint

tests/fm-approval-failover.test.sh landed without a serial duration hint,
so the at-budget packing fixture overflowed by 1040ms. Record a measured
5410ms hint and give the fixture its own complete hint table so unmeasured
defaults cannot join the boundary shard.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

* docs: note the local approval-failover packing hint

Record the 5410 ms provisional local sample for the next CI refresh,
and describe the packi…
jredgard added a commit to jredgard/firstmate that referenced this pull request Nov 15, 2026
…cts (#57)

* feat(bin): add opt-in local Claude usage threshold warner (#7421)

* feat(bin): add opt-in local Claude usage threshold warner

A usage window is exhausted without warning: work is cut off mid-run
rather than stopping deliberately, and nothing says a window is close to
its cap until it is already gone.

bin/fm-usage-warner.sh is a threshold warner, not a usage viewer.
quota-axi is already the one Claude-quota reader this repo depends on
(bin/fm-quota-axi-lib.sh), so the warner runs that existing read rather
than adding a second reader that could drift from it: one bounded
`quota-axi --provider claude --json --full --no-credential-refresh`, the
snapshot validated with fm_quota_json_valid, and the provider row picked
with the same FM_QUOTA_ROW_JQ join the dispatch consumers use, under
schema 5 and schema 6 alike.

Thresholds are `<window-id>:<percent>` directives in config/usage-warner,
naming quota-axi's own window ids (five_hour, seven_day, model:<name>)
rather than a second vocabulary, and compared against each window's own
percentUsed. Naming the window is the point: the session and weekly
windows exhaust at very different times, so a figure that does not say
which window is close misleads.

One read with two callers and no new schedule: `check` is what a human
runs on demand and what the watcher runs on its ordinary check-shim
cadence once `arm` registers state/usage-warner.check.sh through
bin/fm-check-register.sh. There is no daemon.

Warnings post through macOS Notification Center with the same osascript
call bin/fm-supervise-daemon.sh's wedge alarm makes, without sourcing or
coupling to that daemon's away-mode-specific config and rate limiting.
Delivery is edge-triggered against state/.usage-warner: a crossing warns
once, stays quiet while it holds, and re-arms when the window next reads
back below its threshold, the same standing-report contract
fm-mail-check.sh and fm-tool-update-check.sh already use.

bin/fm-procevent-quota.sh already reads the same snapshot, so docs name
the boundary rather than leaving two similar surfaces unexplained. That
source fires at most once, wakes firstmate with a durable check event,
and compares a provider's aggregate effectivePercentRemaining. This
warner is the standing, human-facing half: per-window, delivered to the
person through Notification Center, and self-re-arming. Neither replaces
the other and arming both is reasonable.

Opt-in is load-bearing and enforced in code. With no valid directive,
`check` returns before any read and `arm` refuses, so an unconfigured
home gains no behaviour change, no new failure mode, and no new hard
dependency at dispatch. Notification Center is macOS-only, so `arm`
refuses on other platforms instead of registering a check that could
never speak.

The warner only warns. It does not stop or pace dispatch, and its
coverage is exactly what quota-axi can see locally, so a plan or
organisation spend cap quota-axi does not report is not covered; the doc
says so rather than implying coverage it does not have.

The new test script carries no measured CI duration hint yet, so the
portable-serial lane balances it on the conservative default until the
hints are next refreshed from a green run, per docs/fm-test-portable-shards.md.

* no-mistakes(review): Key usage-warner de-dupe on window and threshold; fix docs

* no-mistakes(review): Keep absent-window crossings recorded; stub osascript in tests

* no-mistakes(document): Document absent-window de-dupe carry-forward in usage-warner header

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat(bin): add opt-in local Claude usage threshold warner

A usage window is exhausted without warning: work is cut off mid-run
rather than stopping deliberately, and nothing says a window is close to
its cap until it is already gone.

bin/fm-usage-warner.sh is a threshold warner, not a usage viewer.
quota-axi is already the one Claude-quota reader this repo depends on
(bin/fm-quota-axi-lib.sh), so the warner runs that existing read rather
than adding a second reader that could drift from it: one bounded
`quota-axi --provider claude --json --full --no-credential-refresh`, the
snapshot validated with fm_quota_json_valid, and the provider row picked
with the same FM_QUOTA_ROW_JQ join the dispatch consumers use, under
schema 5 and schema 6 alike.

Thresholds are `<window-id>:<percent>` directives in config/usage-warner,
naming quota-axi's own window ids (five_hour, seven_day, model:<name>)
rather than a second vocabulary, and compared against each window's own
percentUsed. Naming the window is the point: the session and weekly
windows exhaust at very different times, so a figure that does not say
which window is close misleads.

One read with two callers and no new schedule: `check` is what a human
runs on demand and what the watcher runs on its ordinary check-shim
cadence once `arm` registers state/usage-warner.check.sh through
bin/fm-check-register.sh. There is no daemon.

Warnings post through macOS Notification Center with the same osascript
call bin/fm-supervise-daemon.sh's wedge alarm makes, without sourcing or
coupling to that daemon's away-mode-specific config and rate limiting.
Delivery is edge-triggered against state/.usage-warner: a crossing warns
once, stays quiet while it holds, and re-arms when the window next reads
back below its threshold, the same standing-report contract
fm-mail-check.sh and fm-tool-update-check.sh already use.

bin/fm-procevent-quota.sh already reads the same snapshot, so docs name
the boundary rather than leaving two similar surfaces unexplained. That
source fires at most once, wakes firstmate with a durable check event,
and compares a provider's aggregate effectivePercentRemaining. This
warner is the standing, human-facing half: per-window, delivered to the
person through Notification Center, and self-re-arming. Neither replaces
the other and arming both is reasonable.

Opt-in is load-bearing and enforced in code. With no valid directive,
`check` returns before any read and `arm` refuses, so an unconfigured
home gains no behaviour change, no new failure mode, and no new hard
dependency at dispatch. Notification Center is macOS-only, so `arm`
refuses on other platforms instead of registering a check that could
never speak.

The warner only warns. It does not stop or pace dispatch, and its
coverage is exactly what quota-axi can see locally, so a plan or
organisation spend cap quota-axi does not report is not covered; the doc
says so rather than implying coverage it does not have.

The new test script carries no measured CI duration hint yet, so the
portable-serial lane balances it on the conservative default until the
hints are next refreshed from a green run, per docs/fm-test-portable-shards.md.

* no-mistakes(review): Key usage-warner de-dupe on window and threshold; fix docs

* no-mistakes(review): Keep absent-window crossings recorded; stub osascript in tests

* no-mistakes(document): Document absent-window de-dupe carry-forward in usage-warner header

* no-mistakes(review): Serialize usage-warner check, dedupe directives, drop vacuous greps

* no-mistakes(document): List usage-warner check lock in state layout

---------

Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Kostadin Pop-Kochev <kostadin.popkocev@gmail.com>
Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): stabilize remote worker process identity (#6440)

* fix(bin): use clock-stable /proc starttime for remote job worker ownership

Linux remote job ownership compared ps lstart, which drifts on WSL2 while
/proc starttime stays fixed, so ensure treated a healthy worker as dead and
started another supervisor on every call. fm_remote_job_process_start now emits
a proc-starttime token when /proc is readable and falls back to ps lstart
otherwise. The Linux start path hands a live worker of the configured root
whose lock still records a legacy start over to one replacement, checked
against the recorded and live command so no unrelated pid is signaled.

Fixes #2921

* no-mistakes(review): Treat legacy lstart claim starts as indeterminate, not mismatched

* no-mistakes(test): Assert legacy handoff interrupts job once

* no-mistakes(test): Remove scratch debug test; legacy job case git-tracked

* no-mistakes(test): Revert legacy start comparator; simplify legacy handoff test

* fix(bin): drop automatic legacy worker upgrade; document manual one-time restart

* chore: remove stray file

* no-mistakes(document): Drop stale handoff mention from remote worker docs

* fix(bin): verify pre-update remote job workers via legacy lstart

When a recorded start lacks the proc-starttime= prefix, compare it against
ps -o lstart= without LC_ALL=C so a healthy pre-update worker still verifies.
The ordinary code-identity path then replaces it once instead of piling
supervisors. Add regression coverage for the bare-lstart cookie and the
lock upgrade path.

* no-mistakes(document): Clarify legacy remote-job start verification docs

* no-mistakes(review): Preserve C-locale legacy cookie verification, captain

* no-mistakes(document): Clarify legacy process identity cookie compatibility

* no-mistakes(lint): Replace deprecated fgrep with lint-compliant grep -F

---------

Co-authored-by: Pitch Perfekt Collective <pitchperfekt@Pitchs-Mac-Studio.local>
Co-authored-by: mehulbhagwani <270960355+mehulbhagwani@users.noreply.github.com>

* feat(bin): add persistent managed-approval failover for Codex and Claude (#6722)

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

* fix: resurface queued wakes from handling successors (#7466)

* fix(bin): resurface wakes appended while a handling successor is parked

The supervision host parks on the handling successor it starts for a wake
its engine handled, and a handling successor never resurfaced recovery, so
a row another script appended during the park (a captain inbox note from
the Basecamp integration) sat queued until an unrelated close - four hours
in the observed case.

A handling successor now records the newest queued sequence at its start
and closes once with the recovery wake while a newer row is still queued;
a newer row already consumed only advances that mark, so the predecessor's
delivered episode is still never re-announced.

Follow-ups, not built here:
- A row appended in the short window between a handled close and its
  successor's start (about a second) is below the successor's mark; if the
  engine handles that close without claiming the row, the row waits for the
  next close. Closing that window needs the host to treat rows left queued
  after a handled attended turn as main's, which is a separate host change.
- After a machine reboot the primary session does not restart on its own,
  so queued wakes wait until it is resumed by hand. Either auto-resume the
  primary session after boot, or alert the owner when the primary session
  is down while wakes are queued.

* no-mistakes(review): Close handling-successor startup wake race

* no-mistakes(test): Stabilize parked-host inbox wake regression timeout

* no-mistakes(document): Clarify handling-successor wake continuity guarantees

* no-mistakes(ci): Stabilized the flaky remote secondmate lifecycle test by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case

* no-mistakes(ci): Fixed flaky concurrent Herdr recovery testing by retrying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices

* no-mistakes(test): Preserve successor wake boundaries across handoffs

* no-mistakes(test): Revert successor boundaries and drain teardown fixture wake

* no-mistakes(test): Notify main when downtime handback publication fails

* no-mistakes(test): Revert downtime handback notification changes

* no-mistakes(document): Correct stale supervision wake routing documentation

* fix(bin): stop the supervision host deadlocking and re-announcing handed-back closes

Two defects in this branch's handling-successor changes surfaced as the
"Behavior portable serial 2" shard hanging at its 30-minute limit.

A TERM that lands while the host settles a handled turn's successor handoff
left the host holding the wake-queue and recovery-marker locks; its exit
cleanup then waited forever on the queue lock it still owned. The cleanup now
releases those locks if this process owns them before releasing its grant.

When an accepted close turns main-only at its turn, the host hands it back and
leaves the successor running, but republished the episode as pending
downtime, so that successor re-announced the same close and exited. The
handback now republishes the episode as already announced; a later durable
append still opens a pending episode the successor recovers.

* no-mistakes(test): Park on successor after handling settlement failure

* no-mistakes(test): Use tab-delimited handled-settlement failure logs

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(bin): preserve accents in pending-reply summaries (#7618)

* fix(bin): keep accented letters in pending-reply request summaries

fm_pending_reply_summarize deleted every byte outside printable ASCII, so a Portuguese summary lost its accents: "não faça a correção" was stored as "no faa a correo". It now removes control characters only. The 120-character cap counts UTF-8 characters from lead bytes, so it never splits a letter under any caller locale, including the C locale.

* no-mistakes(document): Documentar preservação de acentos nos resumos

---------

Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>

* feat: add OpenRouter support for typed dispatch resolution (#7149)

* Add explicit OpenRouter Jev dispatch resolution

* no-mistakes(document): Clarify dispatch documentation and remove stale duplicates

* chore: exclude local Stele binding from PR

* no-mistakes(document): Correct dispatch help and never-send documentation

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct dispatch architecture documentation ownership

* feat(bin): publish lane capacity facts with beat pressure and keyed limits (#6983)

Opt-in: fm-watch.sh publishes state/lane-capacity.json via bin/fm-capacity.sh --publish only while config/lane-capacity exists; adds beat pressure and keyed limits to fm-capacity.sh. Unconfigured fm-capacity output unchanged.

* fix(bin): propagate contribution input assembly failures (#5359)

* fix(bin): transport contribution-input JSON through slurpfile, not argjson

bin/fm-fleet-snapshot.sh --contribution-input passed the full backlog and
task-record JSON to jq through --argjson. A single --argjson argument is
capped by the kernel's MAX_ARG_STRLEN (131072 bytes on Linux), so a large
enough backlog made the kernel refuse to exec jq while the script still
exited 0 with a broken result.

Transport both documents through temporary files and --slurpfile, matching
the pattern the default snapshot path already uses, and propagate a
non-zero exit when that jq invocation fails.

Fixes #5349

* test: narrow contribution-input regression to final assembly failure

The ARG_MAX transport is already fixed on main by #6830, so keep only the regression proving a failing final jq assembly exits non-zero.

* fix: correct Rex secondmate grouping and lifecycle (#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* feat(opencode): add OpenCode 2 support with version-gated launch, plugins, and exit (#7336)

* feat(opencode): add OpenCode 2 support with version-gated launch and plugins

OpenCode 2 dropped the v1 server-plugin hook API, so the five fm.primary.*
plugins now export a default definition with an id and a setup function
alongside their legacy OpenCode 1 server export, backed by a new shared
lib/fm-opencode2.js helper; the turn-end guard, watch-arm, cd-check,
pretool-check, and sessionstart-nudge install their behavior from setup(ctx)
on OpenCode 2 and keep the server entrypoint for OpenCode 1.

fm-spawn probes the resolved opencode executable's --version once and branches
the launch, model flag, reasoning config, exit key, and busy-state plugin off
the detected major. A parsed major >= 2 takes the OpenCode 2 shape (no --model,
the model pinned through OPENCODE_CONFIG_CONTENT, a raw Ctrl-C exit, the
session.execution.* busy plugin); OpenCode 1.x and any undetected or
unparseable version fall back to the 1.x shape (--model, 1.x config, /exit)
everywhere. The worker busy-state plugin is always provisioned, but OpenCode 1
keeps the pre-port session.status/session.idle plugin so its busy-state wiring
is unchanged, and only a major >= 2 gets the session.execution plugin. Adapter
and supervision docs, OpenCode 2 live fixtures, and regression tests for the
unknown->1.x launch path and the version-gated busy-plugin shape are included.

* no-mistakes(review): gate OpenCode 2 busy plugin turn-end touch on notifyTurnEnd

* feat(opencode): launch detected OpenCode 2 workers with --standalone

OpenCode 2's default launch attaches to the shared background service, which
hosts plugins with the service's environment and ignores the pane's
OPENCODE_CONFIG_CONTENT. A private server keeps per-worker model, permissions,
FM_HOME, and lock ancestry correct. 1.x and undetected versions are unchanged.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* fix(opencode): resolve the OpenCode 2 project location and treat every terminal turn as a turn end

OpenCode 2.0.x hands plugins the project only as ctx.location.project.directory
and takes ctx.session.prompt({ sessionID, text }), so the V2 setup path never
found its root or delivered a prompt. Interrupted and failed turns now end a
turn like a succeeded one, while a server shutdown does not.

Ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* test(opencode): add a token-free OpenCode 2 native plugin fixture to the live e2e

A private opencode serve plus a loopback provider proves the five primary
plugins load and act on OpenCode 2: startup nudge, cd and watcher-redirection
guards, turn-end guard, watcher arming across succeeded, interrupted, and
failed turns. The fixture declares the complete model capabilities object,
which OpenCode 2.0.11 requires and 2.0.22 accepts. FM_OPENCODE_LIVE_BINS runs
it across several OpenCode 2 executables. The credentialed half now picks its
run flags and session tables by detected major, so it keeps working on 1.x.

Fixture ported from https://github.com/kunchenguid/firstmate/pull/5143.

Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>

* feat(opencode): send one Enter when an OpenCode 2 launch leaves the brief unsent

OpenCode 2.0.11 prefills the --prompt brief without submitting it, while 2.0.22 submits it.
After launch, fm-spawn waits for the worker's busy-state plugin to report the turn start, sends one Enter only if it has not started and the composer is not empty, and fails the spawn if the turn never starts.

* docs(opencode): document the OpenCode 2 launch, delivery gate, and standalone primary homes

Records the 2.0.11 and 2.0.22 live evidence for the native plugin fixture and the post-launch brief delivery gate.

* no-mistakes(review): Trim OpenCode 2 adapter shapes and harden Ctrl-C exit

* no-mistakes(review): Record OpenCode 2 live seatbelt and exit evidence

* no-mistakes(test): Document OpenCode 2.0.22 wide-pane sidebar exit refusal limitation

* no-mistakes(document): Refresh OpenCode 2 exit-key and seatbelt payload docs

* test(opencode): verify OpenCode 1.x live with the dual-export plugins

Pin the live e2e TUI panes to the resolved opencode executable, and record
OpenCode 1.15.7, 1.18.20, and 1.18.31 evidence for plugin loading, the
turn-end guard, watcher continuity, and 1.x worker launch and exit.

* no-mistakes(review): Defer OpenCode 2 Enter on unknown composer; widen turn-end docs

* no-mistakes(document): Document OpenCode 2 delivery gate unknown-composer test outcomes

---------

Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(bin): resolve the tmux container from firstmate's own session, not the most recent group member (#7662)

* fix(bin): resolve the tmux container from the caller's own session, not the most recent group member

* no-mistakes(test): Fall back when the $TMUX session id is stale

* no-mistakes(document): Document tmux container choice under grouped sessions

* fix(bin): read a fully dim Cursor idle placeholder as an empty composer (#7647)

* fix(bin): read a fully dim Cursor placeholder as an empty composer

cursor-agent 2026.10.19 draws the composer glyph and its idle placeholder
as one SGR 2 run with no reverse-video cell, so ghost stripping empties the
row and the empty-content guard returned unknown. Relaunch and exit then
refused on every idle Cursor pane on tmux.

When a styled bare row strips to empty and the plain row is an agent glyph
followed by an anchored idle placeholder, read it empty. Bright typed text,
other dim text, and unstyled rows keep their existing verdicts.

Fixes #7413

* docs(verification): record the fully dim Cursor placeholder verdict and refresh command

* fix(bin): say why away-mode inject deferred and pin named Claude idle composer as empty (#6163)

* fix(bin): recognize a named Claude session's titled composer rule on cursorless backends

`claude -n <name>` right-aligns the session name in the rule above the
composer. Cursorless backends (Herdr) accepted only solid rules, so the
scan saw the lower rule alone, the idle composer read `unknown`, and
away-mode delivery to a named Claude primary deferred until return.

A rule carrying one right-aligned title now opens a separator pair. It
never closes one, the pair it opens counts only over an agent-glyph row,
and it is never a valid Pi pair, so Pi's verdict is unchanged.

The away-mode composer deferral now names which refusal it was:
unsubmitted text, or no composer shape recognized.

* no-mistakes(review): Reword composer deferral reason to cover busy harness

* no-mistakes(ci): ci-3 (Greptile, user chose to fix): The rule that must always hold is that Claude's titled opening rule is accepted for any non-empty session name that doesn't start with a space and doesn't contain the rule glyph `─`, including a multiword name. The only place that check lives is the title `case` in `_fm_composer_titled_rule_row` (bin/fm-composer-lib.sh). It now reads `case "$title" in ''|' '*|*─*) return 1 ;; esac`, as the user asked, and the comment above the function mentions multiword titles. I added regression fixtures to `test_matrix_claude_named_session_titled_rule` in tests/fm-composer-lib.test.sh, next to the existing single-word `Andrew` cases. They use the title `Andrew Chen` and check that an idle composer on herdr reads `empty` and a composer with typed text reads `pending`. Something you should know: the old pattern already accepted a title with a space in the middle. It only rejected a title ending in a space. So the new multiword fixtures also pass against the old code, and the bot's failure scenario did not actually happen for "Andrew Chen". What the fix really changes is that it drops the trailing-space rejection, as instructed. Checks run: tests/fm-composer-lib.test.sh and tests/fm-composer-ghost.test.sh both pass (exit 0, no failures), and `shellcheck -x` is clean on both changed files

* no-mistakes(review): Match unnamed-ghost fixture rule width to the partner rule

* fix: use managed-compatible worker approval modes

* no-mistakes(document): update codex and claude worker approval mode docs

* no-mistakes(ci): Fixed two test files that weren't updated when the PR changed the default claude permission mode from `--dangerously-skip-permissions` (bypass) to `--permission-mode auto`. Changes: - `tests/fm-claude-trust.test.sh` lines 664 and 696: updated two `assert_grep` assertions from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` - `tests/fm-backend-orca.test.sh` line 568: updated one `assert_contains` assertion from `claude --dangerously-skip-permissions` → `claude --permission-mode auto` Both tests now pass locally (orca: exit=0, backend-dispatch/claude-trust: exit=0)

* fix: remove stray scratch directories from tests/

tests/.tmp-managed-approvals-test.bBuGhY/ and tests/.tmp-managed-approvals2.exz2qr/
were accidentally committed as worktree-local scratch dirs and do not belong in the repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: preserve bypass defaults with persistent managed approval failover

* no-mistakes(review): fix approve-for-me fixture and bypass diagnostic messages

* no-mistakes(review): restore absent-Claude-default test and fix pass messages

* fix: recognize managed Codex approval prompts in the C locale

* no-mistakes(review): Fix managed approval failover bounds, authorization, inheritance, and capture

* Simplify managed approval recovery to persistent explicit failover

* no-mistakes(review): Guard failover authorization and unlink staging before recovery

* no-mistakes(document): Correct managed approval documentation and consolidate owner references

* no-mistakes(document): Correct managed-approval references and stale hook guarantees

* fix: require approval and inherit managed modes from primary

* no-mistakes(document): Clarify live hook verification scope

* no-mistakes(review): Remove dead approval_configured key from relaunch metadata

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Caleb LeNoir <caleb.lenoir@constructease.com>
Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>
Co-authored-by: Alexandre Custodio <xandy.alexandrec@gmail.com>
Co-authored-by: Alexandre Custodio <alexandre.custodio@soraschools.com>
Co-authored-by: Pedro Guimarães <21346846+0x7067@users.noreply.github.com>
Co-authored-by: Konner Moshier <39997550+Moshik21@users.noreply.github.com>
Co-authored-by: Oscar Santis Brante <49914973+osantis@users.noreply.github.com>
Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
Co-authored-by: Kostadin Pop-Kochev <kostadin.popkocev@gmail.com>
Co-authored-by: Niranjan <nniranc@gmail.com>
Co-authored-by: Girik Bajaj <bajajgirik2010@gmail.com>
Co-authored-by: Tomas Perez <71987424+tomasperezcoscia@users.noreply.github.com>
Co-authored-by: Cameron Aragon <69489633+camaragon@users.noreply.github.com>
Co-authored-by: Brian <bthome@users.noreply.github.com>

* fix(bin): keep handling successors from stranding inbox wakes after counter loss (#6467)

* fix: notify handling successors about newer inbox wakes

* no-mistakes(document): Document handling-successor inbox regression in watcher coverage list

* no-mistakes(ci): Fixed Greptile P1 (comment 4172295712): a handling successor could miss a new inbox wake when `.wake-queue.seq` was missing or malformed. What must always hold: a row added after the successor took its snapshot must be announced and must never be consumed by an older acknowledgement. Two places were breaking this: 1. `bin/fm-watch.sh`: the successor only recorded the highest inherited sequence number. If the counter was reset, a new row could get a number at or below that and be treated as already covered. This now stays silent forever once the inherited rows are acknowledged and the queue drains. 2. `bin/fm-wake-lib.sh` `fm_wake_append_locked`: a reset counter reused the sequence number of a row still in the queue. The predecessor's pending `--ack-through` consumes rows by sequence number, so it deleted the new row before anyone handled it. This was a gap in the existing allocator, and it is what made the before-ack cases fail even after fix 1. Fixes: - Watcher: the successor now snapshots the inherited rows themselves instead of their highest sequence. On each poll it announces if any queued row is not in that snapshot. It still never consumes rows, and inherited rows alone stay silent. - Allocator: the next sequence is now one more than the larger of the counter and the highest sequence still queued, so a new row can't land inside an outstanding acknowledgement's range. - `docs/watcher-continuity.md`: the paragraph and coverage list are updated to match. Tests: `test_append_wakes_handling_successor` in `tests/fm-watch-arm.test.sh` now inherits two rows and takes a counter state (intact, missing, malformed). The four new cases are after-ack and before-ack with a missing or malformed counter, and they run real watcher, arm and drain processes. In after-ack the queue is fully drained before the new append. Evidence: - Before any production change (on 92c724d), all four new cases failed: "not ok - handling successor stranded the second inbox wake" for after-ack and before-ack. - With only the watcher fix, the after-ack cases passed and the before-ack cases still failed, which shows the allocator fix is needed. - With both fixes, all four pass. Full results: `fm-watch-arm` 36/36 (including the intact after-ack and before-ack cases, so ordinary silence and fresh-beacon delivery still hold), `fm-watch-recovery-loop` 2/2, `fm-inbox` 16/16, `fm-pi-watch-extension` 60/60, `fm-wake-queue` 67/67, and all four `fm-wake-drain-*` suites passed (9, 9, 18, 14). Canonical `bin/fm-lint.sh` with `PATH=/home/nino/.local/bin:$PATH` passed: ShellCheck clean, actionlint 1.7.12, 3 workflows valid. That lint run was in local changed-file mode with ShellCheck source following disabled. In a first run of all nine suites in parallel, `fm-wake-queue` failed on "presentation lock delayed the drain for 10s" and one `fm-pi-watch-extension` timing test failed. Both passed in full when rerun on their own, so I read that as load contention, not this change. Design decision to flag: the allocator change sits in the shared wake library, so it goes beyond the watcher comparison the bot pointed at. It is a one-expression change, and the before-ack tests can't pass without it, because otherwise the predecessor's acknowledgement deletes the new message. Not done, per the phase boundary: nothing committed, pushed or posted, and the live fleet was not touched. Evidence logs are in /tmp/fmci, not in a pipeline logs/evidence directory

* no-mistakes(ci): Fixed both Greptile findings on PR #6467. Nothing was committed, pushed or posted, and the live fleet was not touched. **ci-1 (4172409813): a new wake was mistaken for an inherited one.** - Invariant that must hold: a successor treats a row as covered only if it is an unchanged inherited row in the inherited recovery episode. - Cause: after the predecessor's acknowledgement and a lost counter, a re-append with the same kind, key, payload and epoch was byte-identical to the snapshot row, so the successor stayed silent. - Fix (`bin/fm-watch.sh`): I used the existing recovery generation rather than a new identity scheme. Any append after an acknowledgement mints a new generation. The successor records the generation with its row snapshot, under the queue lock and in arm-check's lock order. Each poll counts the queue as newer if a row is not in the snapshot, or if the queue is non-empty and the generation changed. The existing arm-check then decides whether to announce. No rows are consumed, and inherited rows alone stay silent. - The row snapshot is still needed for before-ack, because an append before the acknowledgement keeps the same generation. **ci-2 (4172409821): large sequence numbers became unusable.** - Invariant that must hold: sequence numbers are always exact digit-only decimals. - Fix (`bin/fm-wake-lib.sh`): the allocator picks the largest of the counter and the queued sequences by comparing decimal text (length, then string order, leading zeros stripped), then adds 1 in bash with `$((10#$seq + 1))`. This restores the 64-bit exactness of the original bash counter. - Same fix at two places in `bin/fm-wake-drain.sh` that print sequences: `presented_max_row` and `ACK_THROUGH` print the matched text instead of `max + 0`. **Tests** - `tests/fm-watch-arm.test.sh`: two new `identical` cases, after-ack with a missing and with a malformed counter. A fake `date` pins the epoch, and the test asserts the row is byte-identical, then checks timely notification, preservation until its own acknowledgement, and no repeat notification. - `tests/fm-wake-queue.test.sh`: new `test_large_sequences_stay_exact_decimal_identifiers` starts from 2147483647, 9007199254740991 and 9223372036854775806, each with an intact, missing and malformed counter. It checks the next sequence is exact and digit-only. For the first two it also checks a real drain shows both rows, names the exact acknowledgement sequence, and acknowledging empties the queue. - `docs/watcher-continuity.md` now describes the generation check. **Evidence** (in `/home/nino/.no-mistakes/evidence/01M40CDTX2000A5TFFRZN27YFR/ci-round3/`) - Before, on 050a5fc: both identical cases failed with "handling successor stranded the second inbox wake (after-ack)". The large-sequence test failed with "advanced to '9223372036854775808', not 9223372036854775807". - After the fix, all three pass (`after-*.log`). - All nine suites passed, each run on its own, all with 0 not ok (`final-results.txt`): `fm-wake-queue` 68/68, `fm-watch-arm` 38/38, `fm-watch-recovery-loop` 2/2, `fm-inbox` 16/16, `fm-pi-watch-extension` 60/60, `fm-wake-drain-open-decisions-cursor` 9/9, `fm-wake-drain-open-decisions` 9/9, `fm-wake-drain-outcome-backstop` 18/18, `fm-wake-drain-unread-status` 14/14. - `bin/fm-lint.sh` with `PATH=/home/nino/.local/bin:$PATH` passes: ShellCheck clean, actionlint 1.7.12, 3 workflows valid (local changed-file mode). **Not run** - The only OpenCode suite is an opt-in live test, so I did not run it. **Limits** - The 2.14748e+09 symptom doesn't reproduce with the awks here (gawk, mawk 1.3.4, busybox). The failure reproduced locally is the precision loss at 64-bit values. - The drain's awk comparisons are only exact up to 2^53. That predates this PR and I left it alone, so the drain test stops at 2^53

* no-mistakes(document): Reattach successor poll-loop sentence to its subject

* fix(bin): stop lock waits and test fixtures from spinning after their directory is removed (#7685)

* fix(tests): bound lock waits on removed dirs and reap fixture-root processes

A lock wait spun every 0.1s forever once its directory was removed, so a
watcher or reconcile scan of a deleted test home never reached its own
home-gone exit. fm_lock_acquire_wait now returns within 0.2s once the
lock's parent directory is gone.

Test teardown now signals every process naming the exact fixture root
(TERM, then KILL) before removing it, in both fm_test_cleanup and the
orphan sweep. The supervision-host fake harness sessions stop once their
home is gone or the suite pid has died, so a hard-killed runner no longer
leaves them polling under init.

Fixes #7672

* fix(tests): bound the session-lock concurrency barrier

Forty workers polled a find pipeline every 0.01s to wait for each other,
so the barrier alone launched thousands of processes a second, and once a
stopped run removed the barrier directory the workers polled forever under
init. Count entries with a builtin glob every 0.05s, and end the wait once
the directory is gone, the suite has died, or the stub block bound passes.

Refs #7672

* fix: watch review-bot findings on owned pull requests (#7499)

* fix(bin): admit listed review-bot comments as contribution signals

* no-mistakes(review): Persist review-bot config in contribution check shim

* no-mistakes(review): Classify allowlisted collaborators as review bots

* no-mistakes(document): Document review-bot contribution signals

* no-mistakes(review): Preserve review-bot config and re-raise classification

* no-mistakes(review): Prevent acknowledged bot signals replaying after allowlist changes

* no-mistakes(document): Document configurable review-bot contribution watching

* no-mistakes(document): Clarify review-bot thread documentation

* fix(bin): make review-bot contribution watching opt-in

* docs(bin): state review-bot allowlist has no built-in default

* no-mistakes(document): Document per-home review-bot configuration

---------

Co-authored-by: Caleb LeNoir <calebl@users.noreply.github.com>

* fix(brief): drop undefined heavy-test slot from the Waiting section (#7674)

The generated Waiting section told workers to wait on a heavy-test slot that nothing in the repository defines. Remove the phrase and assert that a brief generated with config/wait-no-turns does not name one.

* fix(bin): read the no_ci ci-monitor marker as no-checks (#7675)

* fix(bin): read the no_ci ci-monitor marker as no-checks instead of validating

Fixes #7644

* no-mistakes(document): Rewrap nm_ci_checks_state no_ci comment

* feat(bin): add opt-in restricted permission mode for Codex workers (#7683)

* feat: add opt-in restricted permissions for Codex workers

* no-mistakes(review): Document restricted Codex network and git approval limits

* fix(test): keep serial packing at-budget fixture stable with unhinted scripts (#7699)

* fix(test): keep serial packing at-budget when a script has no hint

tests/fm-approval-failover.test.sh landed without a serial duration hint,
so the at-budget packing fixture overflowed by 1040ms. Record a measured
5410ms hint and give the fixture its own complete hint table so unmeasured
defaults cannot join the boundary shard.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

* docs: note the local approval-failover packing hint

Record the 5410 ms provisional local sample for the next CI refresh,
and describe the packing-boundary fixture as independent of unhinted
scripts.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

* fix(inbox): newline-terminate steering records (#6309)

* fix: terminate steering inbox records with newline

* no-mistakes(ci): Fixed Greptile P2 by updating the shared generated `INBOX_SECTION` in `bin/fm-brief.sh`, which is the single guidance source consumed by ship, scout, and secondmate scaffolds. The guidance now tells workers to prefer `fm_task_inbox_body`, explains that `body-terminator=1` marks exactly one synthetic record-termination newline that is not logical body content, and says to remove only that marked terminator while preserving intentional trailing newlines and legacy EOF bodies. Added generated-brief behavioral coverage for all three scaffold paths in `tests/fm-brief.test.sh`. Verified with `./tests/fm-brief.test.sh && bash ./tests/fm-task-inbox.test.sh`

* fix: print fm-send help before resolving FM_HOME (#6402)

* fix(bin): make fm-send.sh --help print usage before FM_HOME resolution

* fix: parse list-form Lavish results without dropping answers (#5404)

* fix(bin): parse Lavish list-form results and refuse unparsed blocks

Lavish emits its queued prompts in TOON list form instead of table form as
soon as the items stop being uniform, for example when some annotations carry
a nested target object or a message carries an attachments table. The adapter
only recognized the table header, so read reported a complete, empty result
and answers closed nothing.

Move the result parsing into one shared reader used by read, answers, and
reconciles that accepts both forms, keeps only column-zero headers, skips
nested structures only beneath the field that opened them, and counts
anything it cannot account for as malformed. An unrecognized header naming
the block is now malformed rather than an empty result, answers and
reconciles exit nonzero when the result is not fully accounted for, and the
queued-content check treats a list header as content.

Refs #4726

* no-mistakes(document): Document Lavish capture formats and incomplete-result handling

* test: expect captain_message_count for the open-board list-form capture

* fix: correct Pi wake ownership and processing-turn handling (#5835)

* fix(pi): let the supervision branch claim Orca stale wakes

The watcher keys Orca endpoints by terminal=, but the branch dispatcher
only indexed window=, so every Orca stale row vetoed the wake scan and
went to main. Index both endpoint fields.

Local hotfix ahead of upstream; refs kunchenguid/firstmate#5623.

* test(pi): cover terminal-keyed Orca stale rows in branch dispatch

Pins the terminal= endpoint lookup: a terminal-keyed stale row queued with
another eligible row must resolve to its task in both routine and heartbeat
scans, instead of vetoing the wake to main.

* no-mistakes(document): Update supervision dispatch doc for Orca terminal-keyed stale rows

* fix(pi): reject conflicting wake endpoint ownership

Index task keys and window/terminal aliases through one ownership check.
Ambiguous records must leave the wake on MAIN instead of selecting the
last task and possibly bypassing another owner's open decision.

Cover duplicate terminals and collisions with window and task keys in
both record orders while preserving unique terminal routing.

* no-mistakes(document): Document conflicting alias ownership as scope corruption

* fix(pi): retain ownership claims from incomplete task records

Check endpoint and task alias ownership before project eligibility so a
projectless record cannot lose its open decision to another terminal owner.
Require project context before decision filtering can grant routing scope.

Cover missing and empty project fields in both record orders, and preserve
refusal for a uniquely mapped terminal without project context.

* no-mistakes(review): Fix canonical routing ownership and custom SDK event handling

* no-mistakes(review): Preserve dedicated custom processing run ownership

* no-mistakes(document): Clarify Pi event handling and fail-closed routing documentation

* feat(bin): add a forge=external review rail that never pushes task branches (#7368)

* feat(bin): add a forge=external review rail that never pushes task branches

A project whose review tool uploads its own snapshot of the worker's local
commits can now be registered [direct-PR forge=external]. Workers on such a
project never need to push a branch to publish, and must never push a task
branch to the shared origin.

- fm-project-mode.sh: external joins the closed forge set; never detected,
  refused on local-only, and +yolo reports yolo=off with a refusal.
- fm-dod-lib.sh: external ships direct-PR only; its first rule forbids origin
  and task-prefixed pushes, its Definition of done renders the home's
  config/external-review.md adapter verbatim, and the ready-report gate
  accepts `done: review <url> uploaded for review` on the URL alone or, with a
  recorded backup remote, once HEAD is on the backup namespace.
- fm-git-push-guard.sh (new): per-task pre-push guard refusing pushes to
  origin or a URL matching origin's, task-branch and task-prefixed refs on any
  remote, and refs outside the backup prefix on the backup remote.
- fm-git-strip-ai-trailers.sh: install gains --push-guard and --no-strip.
- fm-spawn.sh: refuses yolo, a missing adapter, and an unusable backup
  remote before launch; installs the guard even under keep-ai-trailers; and
  records forge=external, backup_remote=, and backup_prefix=.
- fm-review-check.sh (new): records review= and review_head= with no merge
  watch, and publishes the child's ready line in a secondmate home.
- fm-promote.sh refuses promotion onto forge=external, because a scout
  launches without the guard.
- Docs: docs/external-review-forge.md (design), configuration.md's new
  "External review tool" section, scripts.md, and the ship-landing and
  project-management skills.

* no-mistakes(review): Drop string-grep hook assertion from external-review spawn test

* no-mistakes(document): Note forge=external contract token and direct-PR-only composition

* test(pi): Lauf ohne prompt in before_agent_start festnageln (#7387)

Ein Lauf, den sendCustomMessage startet, traegt eine Custom-Nachricht und
keinen prompt. Das Lesen des prompt an dieser Stelle warf, womit jeder
solche Lauf mit einem Fehler auftauchte statt zu starten.

Die Verengung dagegen steht seit 8c9c67de im Zweig, ein Test, der sie
benennt, fehlte: die einzige Abdeckung lag beilaeufig in einem
Abbruch-Fall der Abwesenheits-Haltung und verschwindet mit ihm. Der neue
Fall erweitert den bestehenden Mirror-Test und prueft, dass ein solcher
Lauf weder wirft noch als Dialog gespiegelt wird.

Gegenprobe: ohne die Verengung wirft genau dieser Fall mit
"Cannot read properties of undefined (reading 'trim')".

Co-authored-by: thelad-dev <ladwein@firstmate.bost8.thelad.loc>

* fix(bin): stop tmux target checks reporting gone windows as alive (#7409)

* fix(tmux): verify exact endpoint membership

* fix(tmux): preserve exact target forms

* test(tmux): align endpoint fixture lifecycles

* test(tmux): guard isolated cleanup and shell reader

* no-mistakes(review): Limit tmux .pane target split to window indexes

* fix(composer): prove opencode 1.19 de-emphasised mode footer from the plain row (#7395)

* fix(bin): stop misreading opencode's own footer as pending composer text

An idle OpenCode composer classified as `pending`, and that verdict gates every
typed-plane action firstmate owns: fm-send skips the doorbell, and fm-control
refuses both relaunch and exit. A firstmate operator lost a full session to it and
had to type into worker panes by hand three times.

Root cause: opencode 1.19 draws the mode/model footer's identifying cells
de-emphasised (mode word RGB 67;133;190, middle-dot separators 111;110;105,
luminances ~119.8 and ~109.7, both under fm_composer_strip_ghost's 128
threshold). That helper exists to answer "what did the human type?", so it
deleted exactly the cells that identify the footer. The `^(Build|Plan)` anchor
then became unreachable on every styled backend - tmux, Herdr, and Zellij - not
just one pane, because the unstyled row keeps its styling bytes everywhere.

The fix proves the footer from both forms of that row: the ghost-stripped
content and the ANSI-stripped plain row. Proving it on the form ghost stripping
cannot reach is the whole repair.

What makes that safe, and why the previous argument was not: the earlier draft
argued safety by noting that on a plain capture the two forms collapse to one
string, so the verdict is unchanged. That is true and carries no weight, because
styled=0 is the only configuration where the new proof does nothing. The
exemption is safe because a row reaches the plain form only when the
ghost-stripped row still fails the pattern, which means the stripped content is
non-empty while its own leading Build/Plan cell was deleted as ghost. Nothing
opencode draws de-emphasises a typed row's leading cells - only its furniture is
drawn dimmed - so the only rows the plain form admits beyond the stripped one
are de-emphasised furniture, and the mode footer is the only furniture opencode
draws that opens with a mode word. That is self-confirming rather than asserted,
and it is the argument to recheck when a new opencode release moves a colour.

A review also caught a second change riding along in the same diff: the footer
pattern had been widened from `[[:space:]]+` to `[[:space:]]*`, admitting
`Build ·x` and a bare `Build ·`. Both read as more typeable than the footer, so
they moved the verdict in exactly the direction this rule exists to prevent. No
recorded opencode footer ends at the dot, so the original `+` matches every real
capture and the widening is reverted.

Verification:
- fm-lint.sh exit 0 on pinned shellcheck 0.11.0 and actionlint 1.7.12.
- fm-doc-audience-check.sh ok across 119 surfaces and 757 local links.
- tests/fm-composer-lib.test.sh green via bin/fm-test-run.sh.
- The new regression case fails on exactly one assertion when this change is
  reverted: "opencode 1.19.0 de-emphasised footer row: expected empty, got
  'pending'", which is the reported symptom.
- Confirmed end to end against live panes rather than only fixtures: a real idle
  opencode 1.19.0 worker classified empty after the change and pending before,
  and firstmate reached the worker over the steer channel afterwards.

* no-mistakes(review): fix(bin): apply leftbar footer rule in content extractor; correct cursorless claim

* no-mistakes(document): document opencode 1.19 footer furniture and extractor coverage

* no-mistakes(document): document ghost-luma knob coupling to opencode footer furniture

* no-mistakes(document): document opencode de-emphasised footer recognition invariant

* no-mistakes(review): fix(docs,bin): correct ghost-luma knob direction, gate plain-row extraction

* no-mistakes(review): fix(docs,bin,tests): correct ghost-luma knob wording, share plain-content helper, cover Herdr/Zellij idle

* no-mistakes(document): narrow overstated backend coverage claim in runtime-backends.md

* no-mistakes(document): document leftbar footer override and opencode 1.19 pointer

* test(send): codex im Tuerklingel-Test hook-frei starten (#7406)

Der Kopf des Tests sagt, jedes Programm werde so gestartet, wie
bin/fm-spawn.sh es startet. Im codex-Zweig von launch_cmd fehlte dabei
--disable hooks, das fm-spawn im crewmate- und scout-Pfad setzt.

Ohne den Schalter parkt codex auf dem Hook-Vertrauensdialog ("N hooks
are new or changed"), dessen Auswahl auf "Review hooks" aufsetzt und der
mit der Tastenebene dieses Werkzeugs nicht beantwortbar ist. Der Lauf
meldet dann die Tuerklingel als nicht befolgt, obwohl er ueber die
Tuerklingel gar nichts ausgesagt hat - und das auf jedem Checkout, weil
schon die projekteigene .codex/hooks.json den Dialog aufzieht.

Dazu eine knappe Zusicherung am Startrezept, damit der Schalter beim
naechsten Umbau nicht wieder still ausfaellt.

Co-authored-by: ladwein <ladwein@firstmate.bost8.thelad.loc>

* fix(bin): store only classified review fields in contribution records (#7096)

* fix(bin): store only classified review fields in contribution records

A pull observation stored GitHub's raw reviews payload, so a PR with a few
hundred reviews wrote a record past the 1 MiB read cap and every pending,
verdict and ack read then refused the whole home. Project each stored review
to id, state, submitted_at, commit_id and user.login, the only fields the
classifier reads, and add a many-review regression.

* no-mistakes(document): clarify contribution record read cap in script header

* fix: handle Pi 1.1 and 1.2 supervision events correctly (#7216)

* fix(pi): retain custom-event handling and processing cancellation

* fix(pi): identify custom triggers before legacy prompt narrowing

* no-mistakes(test): Correct branch fixture retirement and verify real notification ownership

* no-mistakes(document): Clarify Pi event boundaries and verification scope

* fix(pi): retain custom-event handling and processing cancellation

* fix(pi): identify custom triggers before legacy prompt narrowing

* no-mistakes(test): Correct branch fixture retirement and verify real notification ownership

* no-mistakes(document): Clarify Pi event boundaries and verification scope

* no-mistakes(review): Fix SDK1.1 prompt staging and verify branch context

* no-mistakes(document): Clarify SDK prompt compatibility and branch-context verification

* no-mistakes(test): Require dual-SDK compiler checks; execution remains pending

* no-mistakes(document): Correct SDK typecheck documentation and stale dependency claims

* no-mistakes(document): Correct stale Pi typecheck documentation and ownership pointers

* no-mistakes(ci): Fixed SC2329 in tests/fm-pi-primary-types.test.sh by inlining EXIT cleanup. Also fixed a reproduced macOS npm-prefix/lockfile path failure without changing dependency pins or assertions. Canonical targeted lint, strict TypeScript 5.9.3 checks against Pi 1.1.0 and 1.2.0, and success/failure cleanup checks pass. Both behavior-shard failures were upstream npm ETARGET errors in workflow steps unchanged from base; no workflow/runtime changes warranted. Hosted CI remains for the outer executor

* fix(test): reconcile queued processing probes after rebase

* no-mistakes(document): Correct Pi compiler-phase documentation and stale CI comments

* fix(bin): verify cursor launch binaries with a bounded probe (#6380)

* fix(cursor): verify cursor-agent by running it, not by name

Cursor's installer writes its `cursor` IDE shim through the
~/.local/bin/cursor -> cursor-agent symlink, which can replace a versioned
cursor-agent with a script that only prints "No Cursor IDE installation
found" and exits non-zero. That file keeps Cursor's own name and install-tree
path, so the name shortcut (and the structural check alone) accepted it and
every Cursor spawn launched the broken file instead of the working agent alias.

A launch candidate now has to print Cursor's CLI identity under the bounded
probe, or carry the structural evidence and run --help successfully. Hosts
without a bounded runner keep the structural verdict, as before.

* no-mistakes(document): Align cursor launch-verify docs with runtime

* no-mistakes: apply CI fixes

* test: restore fm-watch-triage ack_stopped_cycle assertion

The CI fix round loosened ack_stopped_cycle so a drain that prints no
acknowledgement command and exits zero counts as success. That test is
unrelated to the Cursor executable verification this branch changes, so
restore its original assertion rather than mask a watcher failure here.

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix(bin): restore fm-afk-contract clock sampling

A CI fix round changed how fm_afk_contract_cmd_enter samples its epoch.
That away-mode behavior is unrelated to the Cursor executable verification
this branch changes, so restore it here and leave any fix to its own change.

* fix(cursor): load the timeout library only when a probe runs

Sourcing bin/fm-timeout-lib.sh at load time made every consumer of
fm-cursor-lib.sh, including the session-lock and turn-end hook paths that
never probe, depend on that file being next to it. Load it lazily from the
probe instead.

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* test: restore herdr focus-flash e2e test

A CI fix round edited this Herdr end-to-end test, which is unrelated to the
Cursor executable verification this branch changes. Restore it here and leave
any fix to its own change.

---------

Co-authored-by: ladwein <ladwein@firstmate.bost8.thelad.loc>

* fix: require actual PR references in CI-ready ship notes (#7422)

* fix(dod): require a PR reference in CI-ready notes

* no-mistakes(review): Recognize Forgejo plural pull request URLs

* feat(herdr): opt-in project groups with status tags and a sorted agents view (#7434)

* feat(herdr): opt-in project groups with status tags and a sorted agents view

Add config/herdr-project-groups (absent or off: unchanged behavior). When on,
Firstmate tags each Herdr task pane, and its own projected workspace, with
display-only fm_group/fm_state/fm_task/fm_sort tokens, sets a Herdr agents
view sorted by group then status (needs-captain, problem, running, done), and
places a new projected task at the end of its own group inside the parent
block with the same single verified move as before.

The watcher reconciles tags once per poll and a spawn tags its task at once;
bin/fm-herdr-groups.sh also previews (plan), clears, and prints or appends
suggested sidebar rows with a backup. The agents view helper needs python3.
The only test-runner change is the serial weight hint for the new suite.

* docs(herdr): record the live lab check of project groups

The four hand checks for tags, the sorted agents view, placement at the
end of the group, and clear passed against a real Herdr 0.9.5 server
(protocol 22) in a guarded lab session.

* docs(herdr): align project group verification notes with the live check

* fix(bin): pin LC_ALL=C for remote job process identity reads (#7410)

ps -o lstart= renders in the caller's locale, so a lock or claim owner
recorded under one locale (de_DE renders "Di Okt 13 ...") failed identity
verification under another, was declared dead, and a second worker split
the queue: two serve loops reclaimed and reaped each other's live jobs,
which vanished mid-claim and failed staged jobs with exit 125 and no
output. Pin LC_ALL=C in fm_remote_job_process_start and pin the
cross-locale invariant with a regression test.

Co-authored-by: researchworldwide2026 <researchworldwide2026@gmail.com>

* fix(opencode): ignore child stdin EPIPE in guard and encoder (#7447)

* fix(bin): ignore crew state overrides for other tasks (#5881)

* Guard fm-crew-state overrides by task-name basename

bin/fm-crew-state.sh honours FM_CREW_STATE_META_OVERRIDE and FM_CREW_STATE_STATUS_OVERRIDE only when the override's basename is the requested task's own .meta or .status file name.
An override naming a different task, for example one inherited through a server started inside another task's snapshot child, falls through to the task's own records under the state directory.
A snapshot's own override, which names the task it was captured for, is still honoured.
This is complementary to #5622, which keeps the overrides out of the Herdr server launch: whatever path leaks an override, the reader never trusts one that names a different task.
Regression tests cover a mismatched over…
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.