Skip to content

feat(bin): add a verified Command Code (commandcode) crewmate/scout adapter - #6679

Merged
kunchenguid merged 7 commits into
kunchenguid:mainfrom
pback34:fm/cmd-adapter
Oct 15, 2026
Merged

kunchenguid merged 7 commits into
kunchenguid:mainfrom
pback34:fm/cmd-adapter

Conversation

@pback34

@pback34 pback34 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Use the Command Code GOAT subscription for DeepSeek V4.1 Flash; Command Code (cmd) is the ideal harness for this.
Get Command Code support working in firstmate.

Context: firstmate currently has no verified adapter for Command Code, so it cannot dispatch workers into it.
The goal is for firstmate to dispatch crewmates and scouts on Command Code with the model deepseek/deepseek-v4.1-flash, billed to the existing Command Code subscription, so that small, clear tasks and second-opinion reads can be routed there through config/crew-dispatch.json.

can you rebase our fork on main so it has lastest?
yes (to rebasing the PR branch onto the latest upstream main and resolving its conflicts)

What Changed

  • Adds commandcode as a verified crewmate/scout harness. It is registered in harness detection (comm=command-code), the control-plane harness lists, crew-dispatch validation and fm-spawn.sh. Spawns launch Command Code with --yolo --trust --skip-onboarding --no-auto-update, and --model is passed through. --effort is passed only for deepseek/deepseek-v4.1-flash with low, high or max. Spawn refuses --secondmate launches, and it refuses backends other than tmux or herdr before it creates any pane or task state. Interrupt and exit use a single Escape and /quit, and a guard detects and handles the Rewind checkpoint picker.

  • Adds bin/fm-commandcode-mod.ts, a mod loaded for one process that writes busy state. It reports busy on run_start and idle on run_end and on session end. fm-busy-event.sh apply gains a --turn-ended flag that touches state/<id>.turn-ended while still holding the writer lock, after the generation check passes. This means a stale incarnation cannot signal its replacement.

  • Teaches the composer and tmux layers to read Command Code panes:

    • A delivery busy regex (esc to interrupt and the elapsed cell between bullets).
    • The Ask your question... idle placeholder.
    • A ghost luma ceiling of 160, applied only when the tmux or herdr identity probe reports Command Code.
    • Identity-gated reclassification without the cursor in fm_tmux_composer_state.

    Also strips the CommandCodeBot <[email protected]> co-author trailer. Adds an adapter reference and a verification doc, updates the config and backend docs, and adds harness, busy-state, control, liveness and live e2e tests.

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The adapter is well covered by behavioural tests and live checks and is limited to crewmate and scout work, but one relaunch path can stop a running agent before the new backend refusal fires. That should be fixed, though it does not block a careful merge.

Testing

Drove the real Command Code CLI (1.77.0, newer than the 1.74.1 the docs record) through Firstmate twice. Both runs used the real subscription login, copied into an isolated home. Run 1 used the repo's credentialed tmux guard on a private socket: 8 of 8 checks passed in 320 s (launch brief, model and effort; no CommandCode co-author trailer on the worker's commit; empty-composer steering; rewind-picker hazard handled; one-Escape interrupt; /quit; native resume; relaunch). Run 2 was a new driver of the same lifecycle in a guarded fm-lab Herdr session. All steps passed in 190 s, and teardown confirmed the default session was untouched. The real fm-spawn and fm-bootstrap entry points, run against disposable homes, showed four things. Effort is passed only for verified flash pairs; the -fast model gets none. Commandcode is refused on zellij, cmux and orca, with no task record or busy state created. Secondmate is refused. Crew-dispatch validation accepts commandcode. Refusing a relaunch onto commandcode off tmux and herdr was checked only through the fm-control regression test with backend fixtures, because no zellij, cmux or orca install was available to host a live agent. Targeted portable suites passed. All lab homes, sockets and Herdr sessions were removed, and the worktree is clean. There is no UI change, so there are no screenshots; CLI transcripts are the evidence.

  • Live validation: ✅ go - 9 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Captain dispatches a scout on Command Code (tmux) with deepseek/deepseek-v4.1-flash; it runs the brief and commits with no Command Code attribution ✅ pass live commandcode-live-tmux-e2e.log: 'spawn brief, model, effort, autonomy, trust, identity, and the busy mod' and 'the worker commit carries no attribution'
Firstmate steers an idle Command Code worker: composer reads empty, fm-send doorbell is read and acknowledged (tmux) ✅ pass live commandcode-live-tmux-e2e.log: 'idle composer reads empty; real fm-send doorbell read and acknowledged'
Interrupt, exit, resume and relaunch on tmux: one Escape cancels a busy turn, an open rewind picker blocks exit and is closed without restoring, /quit exits, relaunch re-arms the mod ✅ pass live commandcode-live-tmux-e2e.log: lines 4-8, exit=0 elapsed=320s
Same worker lifecycle on the Herdr backend in a guarded fm-lab session (spawn, empty composer, steer, interrupt, exit, relaunch) ✅ pass live commandcode-live-herdr-lab.log: herdr agent=cmd idle, composer empty, steer=1147 acknowledged, interrupt-delivered, stopped, relaunched model=deepseek/deepseek-v4.1-flash effort=low, result 91, fresh…
Operator routes small, clear tasks to commandcode + deepseek/deepseek-v4.1-flash in config/crew-dispatch.json; bootstrap accepts it and rejects a misspelled harness ✅ pass live crew-dispatch-bootstrap-validation.txt: valid rule gives no CREW_DISPATCH error; 'command-code' gives 'unverified harness: command-code'
Only verified effort pairs reach the CLI: flash low/high/max are passed; xhigh and every -fast pair are recorded but omitted ✅ pass live spawn-effort-and-backend-guard.txt effort routing table
Adversarial: a commandcode spawn on zellij, cmux or orca is refused before any launch, task record or busy state ✅ pass live spawn-effort-and-backend-guard.txt backend guard section (rc=1, launched=no, task_record=no, busy_armed=no); tests/fm-commandcode-harness.test.sh
Adversarial: relaunching a running claude task onto commandcode on zellij, cmux or orca is refused before the old agent is stopped ⏸️ untested no The prior payload did not establish a live result. No zellij, cmux or orca install was available to host a real running agent, so this was covered only by the fm-control.test.sh regression with backen…
Adversarial: a commandcode secondmate launch is refused ✅ pass live spawn-effort-and-backend-guard.txt secondmate section: 'crewmate/scout adapter only', rc=1
The PR branch is rebased on the latest upstream main ✅ pass live git merge-base --is-ancestor origin/main HEAD succeeded; origin/main = 2ce57d0 = run base
Evidence: Live tmux Command Code guard transcript (real CLI 1.77.0, deepseek-v4.1-flash)

Source: Live tmux Command Code guard transcript (real CLI 1.77.0, deepseek-v4.1-flash)

ok - commandcode 1.77.0: spawn brief, model, effort, autonomy, trust, identity, and the busy mod
ok - commandcode 1.77.0: the worker commit carries no attribution
ok - commandcode 1.77.0: idle composer reads empty; real fm-send doorbell read and acknowledged
ok - commandcode 1.77.0: idle interrupt opens nothing; an open rewind picker blocks exit and is closed without restoring
ok - commandcode 1.77.0: one Escape cancels, preserves the agent, and the mod records idle
ok - commandcode 1.77.0: fm-control exit via /quit
ok - commandcode 1.77.0: native --resume <session-id>
ok - commandcode 1.77.0: fm-control relaunch re-arms the mod with a fresh generation
exit=0 elapsed=320s
Evidence: Live Herdr lab Command Code lifecycle transcript

Source: Live Herdr lab Command Code lifecycle transcript

lab session: fm-lab-cc-gate-2067209-22017
herdr pane get: {"agent":"cmd","status":"idle"}
fm_backend_agent_state: alive
fm_backend_composer_state: empty
ok - commandcode 1.77.0: herdr: real fm-spawn launch ran the brief on deepseek-v4.1-flash; agent alive; idle composer reads empty; mod idle
ok - commandcode 1.77.0: herdr: fm-send steer delivered, executed (1147), and inbox acknowledged
  interrupt: interrupt-delivered cc-herdr harness=commandcode backend=herdr verified=agent-alive cancel=unconfirmed
ok - commandcode 1.77.0: herdr: busy turn interrupted with one Escape; agent alive; mod records idle
  exit: stopped cc-herdr harness=commandcode backend=herdr endpoint=fm-lab-cc-gate-2067209-22017:w1:p2 worktree=/tmp/cch.ApXmAx/wt
ok - commandcode 1.77.0: herdr: fm-control exit via /quit; agent state dead
  relaunch: relaunched cc-herdr harness=commandcode from=commandcode model=deepseek/deepseek-v4.1-flash effort=low backend=herdr endpoint=fm-lab-cc-gate-2067209-22017:w1:p2 worktree=/tmp/cch.ApXmAx/wt
busy generation: before= after=g1791419367.2081430.28538
ok - commandcode 1.77.0: herdr: fm-control relaunch ran the note (91) and re-armed the mod on a fresh generation
all herdr scenarios passed
teardown: lab session fm-lab-cc-gate-2067209-22017 removed; fleet tripwire verified
exit=0 elapsed=190s
Evidence: Herdr lab driver script

Source: Herdr lab driver script

#!/usr/bin/env bash
# Live Command Code worker on a real Herdr backend, inside a guarded fm-lab-*
# session owned by bin/fm-herdr-lab.sh. The launch command is the one the real
# bin/fm-spawn.sh generates (fixture spawn records it); the process then runs in
# a real Herdr pane with the task record pointing at that pane, and every later
# read and verb goes through the real Firstmate backend and control plane.
# Usage: drive-commandcode-herdr-lab.sh <worktree-root>
set -u
ROOT=$1
cd "$ROOT" || exit 2
. tests/fixtures.sh
. tests/herdr-test-safety.sh
herdr_forget_inherited_pane
VERSION="commandcode $(commandcode --version 2>/dev/null)"
MODEL=deepseek/deepseek-v4.1-flash
SESSION=$(bin/fm-herdr-lab.sh name cc-gate)
export HERDR_SESSION="$SESSION"
LAB=$(mktemp -d "${TMPDIR:-/tmp}/cch.XXXXXX"); LAB=$(cd "$LAB" && pwd -P)
cleanup() {
  herdr_safe_stop_and_delete "$SESSION" && echo "teardown: lab session $SESSION removed; fleet tripwire verified"
  chmod -R u+w "$LAB" 2>/dev/null; rm -rf "$LAB"
}
trap cleanup EXIT
fail() { printf 'not ok - %s: %s\n' "$VERSION" "$1"; echo '--- pane:'; herdr pane read "$PANE_ID" --session "$SESSION" 2>/dev/null | tail -25; exit 1; }
ok() { printf 'ok - %s: %s\n' "$VERSION" "$1"; }
fm_herdr_lab_prepare "$SESSION" || { echo 'could not prepare lab'; exit 1; }
echo "lab session: $SESSION"
. bin/fm-busy-lib.sh
. bin/fm-backend.sh
. bin/fm-composer-lib.sh
fm_backend_source herdr || fail 'fm_backend_source herdr'

H="$LAB/home"; WT="$LAB/wt"; PROJ="$LAB/project"; ID=cc-herdr
fm_test_spawn_home "$H" commandcode
fm_git_worktree "$PROJ" "$WT" cc-herdr >/dev/null 2>&1
git -C "$WT" config user.name 'CC Herdr Gate'; git -C "$WT" config user.email [email protected]
mkdir -p "$H/user-home/.commandcode"
cp ~/.commandcode/auth.json "$H/user-home/.commandcode/auth.json"; chmod 600 "$H/user-home/.commandcode/auth.json"
cp ~/.commandcode/settings.json "$H/user-home/.commandcode/settings.json"   # Herdr's own cmd SessionStart hook
fm_test_spawn_brief "$H" "$ID" "Runtime verification only: compute 12345 plus 67890 using your shell tool and write only the result into answer.txt. Do no other work and stop as soon as this is done."
fakebin=$(make_spawn_fakebin "$LAB/fake" claude)
ln -s "$(command -v commandcode)" "$fakebin/commandcode"
FM_FAKE_LAUNCH_LOG="$LAB/launch.sh" fm_test_run_spawn "$H" "$WT" "$fakebin" "$ID" "$PROJ" \
  --scout --harness commandcode --model "$MODEL" --effort low > "$LAB/spawn.log" 2>&1 || fail "fm-spawn: $(cat "$LAB/spawn.log")"

CONTAINER_RAW=$(fm_backend_herdr_container_ensure "$WT") || fail 'container_ensure'
CONTAINER=${CONTAINER_RAW%%$'\t'*}; SEEDED=${CONTAINER_RAW#*$'\t'}; WS=${CONTAINER#*:}
read -r TAB_ID PANE_ID <<EOF
$(fm_backend_herdr_create_task "$CONTAINER" "fm-$ID" "$WT" "$SEEDED")
EOF
[ -n "$PANE_ID" ] || fail 'create_task'
grep -v -E '^(window|backend|herdr_[a-z_]*)=' "$H/state/$ID.meta" > "$LAB/meta"
{ cat "$LAB/meta"; echo "window=$SESSION:$PANE_ID"; echo backend=herdr; echo "herdr_session=$SESSION"
  echo "herdr_workspace_id=$WS"; echo "herdr_tab_id=$TAB_ID"; echo "herdr_pane_id=$PANE_ID"; } > "$H/state/$ID.meta"
TARGET="$SESSION:$PANE_ID"
export FM_HOME="$H"
unset FM_ROOT_OVERRIDE FM_STATE_OVERRIDE FM_DATA_OVERRIDE FM_CONFIG_OVERRIDE FM_PROJECTS_OVERRIDE
herdr pane run "$PANE_ID" "cd '$WT' && HOME='$H/user-home' /bin/sh '$LAB/launch.sh'; HOME='$H/user-home' exec /bin/bash --noprofile --norc" --session "$SESSION" >/dev/null \
  || fail 'pane run'
classify() { fm_busy_classify herdr "$TARGET" commandcode "$ID" "$H/state"; }
wait_for() { local i; for i in $(seq 1 "$2"); do eval "$1" && return 0; sleep 0.5; done; return 1; }
wait_for '[ -s "$WT/answer.txt" ]' 480 || fail 'launch brief never executed'
[ "$(tr -d '[:space:]' < "$WT/answer.txt")" = 80235 ] || fail 'wrong answer'
wait_for '[ "$(classify)" = "idle commandcode-mod" ]' 240 || fail "no mod idle: $(classify)"
herdr_agent=$(herdr pane get "$PANE_ID" --session "$SESSION" 2>/dev/null | jq -c '{agent: (.result.pane.agent // .agent), status: (.result.pane.agent_status // .status)}' 2>/dev/null)
echo "herdr pane get: $herdr_agent"
st=$(fm_backend_agent_state herdr "$TARGET"); echo "fm_backend_agent_state: $st"
[ "$st" = alive ] || fail 'not alive'
wait_for '[ "$(fm_backend_composer_state herdr "$TARGET" 2>/dev/null)" = empty ]' 40 \
  || fail "composer read $(fm_backend_composer_state herdr "$TARGET" 2>/dev/null)"
echo "fm_backend_composer_state: empty"
ok 'herdr: real fm-spawn launch ran the brief on deepseek-v4.1-flash; agent alive; idle composer reads empty; mod idle'
bin/fm-send.sh "$ID" 'Runtime steering verification: compute 31 times 37 and write only the result to steer.txt. Acknowledge this instruction by moving its .msg file into handled/ as instructed by the doorbell. Do no other work.' > "$LAB/send.log" 2>&1 || fail "send: $(cat "$LAB/send.log")"
sed 's/^/  fm-send: /' "$LAB/send.log"
wait_for '[ -s "$WT/steer.txt" ] && [ -s "$H/state/$ID.inbox/handled/001.msg" ]' 480 || fail 'steer not done/acknowledged'
[ "$(tr -d '[:space:]' < "$WT/steer.txt")" = 1147 ] || fail 'wrong steer result'
wait_for '[ "$(classify)" = "idle commandcode-mod" ]' 240 || fail 'no idle after steer'
ok 'herdr: fm-send steer delivered, executed (1147), and inbox acknowledged'
wait_for '[ "$(fm_backend_composer_state herdr "$TARGET" 2>/dev/null)" = empty ]' 40 || fail 'composer not empty before probe'
bin/fm-send.sh "$ID" 'Runtime interrupt verification: run sleep 90 in your shell tool in the foreground, then wait for it to finish. Do not respond before it finishes.' > "$LAB/send2.log" 2>&1 || fail 'send2'
wait_for '[ "$(classify)" = "busy commandcode-mod" ]' 240 || fail 'never busy'
sleep 2
bin/fm-control.sh "$ID" interrupt > "$LAB/int.log" 2>&1 || fail "interrupt: $(cat "$LAB/int.log")"
sed 's/^/  interrupt: /' "$LAB/int.log"
wait_for '[ "$(classify)" = "idle commandcode-mod" ]' 120 || fail "interrupt did not settle idle: $(classify)"
[ "$(fm_backend_agent_state herdr "$TARGET")" = alive ] || fail 'interrupt killed agent'
herdr pane read "$PANE_ID" --session "$SESSION" 2>/dev/null | grep -q 'Interrupted' || fail 'no Interrupted render'
ok 'herdr: busy turn interrupted with one Escape; agent alive; mod records idle'
wait_for '[ "$(fm_backend_composer_state herdr "$TARGET" 2>/dev/null)" = empty ]' 40 || fail 'composer not empty before exit'
bin/fm-control.sh "$ID" exit > "$LAB/exit.log" 2>&1 || fail "exit: $(cat "$LAB/exit.log")"
sed 's/^/  exit: /' "$LAB/exit.log"
[ "$(fm_backend_agent_state herdr "$TARGET")" = dead ] || fail 'exit left agent running'
ok 'herdr: fm-control exit via /quit; agent state dead'
gen_before=$(cat "$H/state/$ID.busy-gen" 2>/dev/null)
bin/fm-control.sh "$ID" relaunch --note 'Runtime relaunch probe: write the product of 13 and 7 into relaunched.txt, then stop.' > "$LAB/relaunch.log" 2>&1 \
  || fail "relaunch: $(cat "$LAB/relaunch.log")"
sed 's/^/  relaunch: /' "$LAB/relaunch.log"
wait_for '[ -s "$WT/relaunched.txt" ]' 480 || fail 'relaunch note not processed'
[ "$(tr -d '[:space:]' < "$WT/relaunched.txt")" = 91 ] || fail 'wrong relaunch result'
wait_for '[ "$(classify)" = "idle commandcode-mod" ]' 240 || fail 'relaunch mod not idle'
gen_after=$(cat "$H/state/$ID.busy-gen" 2>/dev/null)
echo "busy generation: before=$gen_before after=$gen_after"
[ "$gen_before" != "$gen_after" ] || fail 'relaunch did not re-arm a fresh generation'
ok 'herdr: fm-control relaunch ran the note (91) and re-armed the mod on a fresh generation'
bin/fm-control.sh "$ID" exit > "$LAB/exit2.log" 2>&1 || fail "final exit: $(cat "$LAB/exit2.log")"
echo "all herdr scenarios passed"
Evidence: fm-spawn effort routing, backend guard and secondmate refusal transcript

Source: fm-spawn effort routing, backend guard and secondmate refusal transcript

\### effort routing (generated launch command, model/effort flags only)
deepseek/deepseek-v4.1-flash low         -> --model 'deepseek/deepseek-v4.1-flash' --effort 'low'   (meta: effort=low)
deepseek/deepseek-v4.1-flash high        -> --model 'deepseek/deepseek-v4.1-flash' --effort 'high'   (meta: effort=high)
deepseek/deepseek-v4.1-flash max         -> --model 'deepseek/deepseek-v4.1-flash' --effort 'max'   (meta: effort=max)
deepseek/deepseek-v4.1-flash xhigh       -> --model 'deepseek/deepseek-v4.1-flash'   (meta: effort=xhigh)
deepseek/deepseek-v4.1-flash-fast low    -> --model 'deepseek/deepseek-v4.1-flash-fast'   (meta: effort=low)
deepseek/deepseek-v4.1-flash-fast max    -> --model 'deepseek/deepseek-v4.1-flash-fast'   (meta: effort=max)

\### backend guard (commandcode refused off tmux/herdr, nothing provisioned)
backend=zellij rc=1 launched=no task_record=no busy_armed=no
  error: commandcode is verified on the tmux and herdr backends only; backend=zellij cannot prove its composer empty. Select backend tmux or herdr.
backend=cmux rc=1 launched=no task_record=no busy_armed=no
  error: commandcode is verified on the tmux and herdr backends only; backend=cmux cannot prove its composer empty. Select backend tmux or herdr.
backend=orca rc=1 launched=no task_record=no busy_armed=no
  error: commandcode is verified on the tmux and herdr backends only; backend=orca cannot prove its composer empty. Select backend tmux or herdr.

\### secondmate refusal
error: commandcode is a verified crewmate/scout adapter only and cannot run a secondmate; it has no primary supervision protocol. Select a harness verified for secondmates.
rc=1
Evidence: fm-spawn driver script

Source: fm-spawn driver script

#!/usr/bin/env bash
# Ad-hoc driver: runs the real bin/fm-spawn.sh and bin/fm-bootstrap.sh against a
# disposable home with a fake backend binary, printing a transcript.
set -u
cd "$1"
. tests/fixtures.sh
T=$(mktemp -d "${TMPDIR:-/tmp}/cc-drive.XXXXXX"); trap 'chmod -R u+w "$T"; rm -rf "$T"' EXIT
home=$T/home; proj=$T/proj; wt=$T/wt
fm_test_spawn_home "$home" commandcode
fm_git_worktree "$proj" "$wt" cc-drive >/dev/null 2>&1
fakebin=$(make_spawn_fakebin "$T/fake" claude)
ln -s "$(command -v commandcode)" "$fakebin/commandcode"
spawn() { local id=$1; shift; fm_test_spawn_brief "$home" "$id"
  FM_FAKE_LAUNCH_LOG="$T/$id.launch" fm_test_run_spawn "$home" "$wt" "$fakebin" "$id" "$proj" --scout --harness commandcode "$@" 2>&1; }
echo "### effort routing (generated launch command, model/effort flags only)"
for pair in "deepseek/deepseek-v4.1-flash low" "deepseek/deepseek-v4.1-flash high" "deepseek/deepseek-v4.1-flash max" "deepseek/deepseek-v4.1-flash xhigh" "deepseek/deepseek-v4.1-flash-fast low" "deepseek/deepseek-v4.1-flash-fast max"; do
  set -- $pair; id="e-$(echo "$1-$2" | tr '/.' '--')"
  spawn "$id" --model "$1" --effort "$2" >/dev/null || { echo "spawn failed $pair"; continue; }
  flags=$(grep -o -- "--model '[^']*'\( --effort '[^']*'\)\?" "$T/$id.launch")
  printf '%-40s -> %s   (meta: %s)\n' "$pair" "$flags" "$(grep '^effort=' "$home/state/$id.meta")"
done
echo; echo "### backend guard (commandcode refused off tmux/herdr, nothing provisioned)"
cat > "$fakebin/orca" <<'O'
#!/bin/sh
printf '%s\n' '{"ok":true,"result":{"runtime":{"reachable":true,"state":"ready"}}}'
O
chmod +x "$fakebin/orca"
for b in zellij cmux orca; do
  out=$(spawn "g-$b" --backend "$b"); rc=$?
  printf 'backend=%s rc=%s launched=%s task_record=%s busy_armed=%s\n  %s\n' "$b" "$rc" \
    "$([ -e "$T/g-$b.launch" ] && echo yes || echo no)" "$([ -e "$home/state/g-$b.meta" ] && echo yes || echo no)" \
    "$([ -e "$home/state/g-$b.busy-gen" ] && echo yes || echo no)" "$out"
done
echo; echo "### secondmate refusal"
fm_test_spawn_brief "$home" sm1
fm_test_run_spawn "$home" "$wt" "$fakebin" sm1 "$proj" --secondmate --harness commandcode 2>&1 | head -2; echo "rc=${PIPESTATUS[0]}"
Evidence: crew-dispatch.json bootstrap validation transcript

Source: crew-dispatch.json bootstrap validation transcript

\### config/crew-dispatch.json routing small clear tasks to commandcode + deepseek/deepseek-v4.1-flash
{"rules":[{"when":"small, clear task or second-opinion read","use":{"harness":"commandcode","model":"deepseek/deepseek-v4.1-flash","effort":"low"}}]}
--- fm-bootstrap.sh CREW_DISPATCH / dispatch lines:

\### adversarial: misspelled harness "command-code" in the same rule
{"rules":[{"when":"small, clear task","use":{"harness":"command-code","model":"deepseek/deepseek-v4.1-flash"}}]}
--- fm-bootstrap.sh CREW_DISPATCH / dispatch lines:
CREW_DISPATCH: invalid config/crew-dispatch.json - unverified harness: command-code
Evidence: Targeted portable Command Code tests

Source: Targeted portable Command Code tests

== fm-commandcode-harness
ok - Command Code native identity; anchored liveness
ok - worker-only resolution, single-press interrupt, rewind-picker hazard, and lifecycle capabilities
ok - composer placeholder, draft safety, identity-scoped ceiling, and independent delivery signals
ok - busy mod: run_start busy, run_end and session end idle, stale and unconfigured writes refused
ok - scout launch carries model, verified effort only, autonomy, typed brief, and the per-process mod
ok - Command Code launches are refused on zellij, cmux, and orca
rc=0
== fm-busy-state
ok - the Pi signature requires both the dialog heading and its decline option, not the bare word trust
ok - a Gemini launch parked on its trust, auth-picker, or API-key dialog classifies unknown launch-prompt
ok - the launch-prompt backstop never reclassifies a genuinely working launch
ok - the launch-prompt backstop is scoped to harnesses with a verified signature
ok - the launch-prompt backstop only ever touches the untouched fm-spawn seed
ok - the launch-prompt backstop never runs without a captured tail
ok - the grok fallback is regex-scoped to grok and classifies only grok tasks
ok - codex classifies unknown until a semantic source passes its verification gate
ok - standalone kimi classifies unknown until the live verification gate opens
ok - cursor classifies only from its transcript fold, never rendered text or native state
ok - endpoint death is the only process-level override and yields dead, never busy
ok - herdr's native verdict is trusted for busy only, and records outrank it
ok - record parsing never clobbers the caller's positional parameters, glob setting, or fields
ok - the boolean view reports busy only on an exact busy verdict
all fm-busy-state tests passed
rc=0
== fm-git-strip-ai-trailers
ok - a human co-author at a vendor domain survives; only the exact bot address is stripped
ok - a hook manager resolving the pane hooks dir fails instead of displacing the strip
ok - a relaunch reinstall replaces the read-only strip dir and still strips
ok - install chains the previous commit-msg hook after stripping
ok - a relative project core.hooksPath resolves against the worktree and still runs
ok - an inherited GIT_CONFIG hooksPath does not become the chained previous hooks
ok - a project hook that appears after install still runs for the rest of the task
ok - a pane GIT_CONFIG hooksPath still chains the repository git is actually in
ok - an empty project core.hooksPath runs no repository hook and still strips the trailer
ok - an unresolvable project core.hooksPath still refuses the commit
ok - a valueless project core.hooksPath still refuses the commit
ok - the repository's pre-push runs and can refuse under every hooksPath override channel
ok - a git -c hooksPath override still strips the trailer and chains the project's hooks
ok - commit-msg file mode strips the trailer and keeps the subject
# all fm-git-strip-ai-trailers tests passed
rc=0
== fm-tmux-agent-liveness
ok - tmux liveness: Command Code's anchored process name classifies alive; a containing name stays ambiguous
ok - tmux liveness: a version-named executable under a harness install path classifies alive
ok - tmux liveness: a version-named executable under a decoy path stays ambiguous
ok - tmux liveness: a process neither name source attributes stays ambiguous rather than inventing an agent
ok - tmux liveness: a launcher whose own identity reads as a bare shell classifies alive from its harness child
ok - tmux liveness: an idle shell pane classifies dead
ok - tmux liveness: a harness-named background process in an idle pane still classifies dead
ok - tmux liveness: an absent window classifies missing rather than inheriting tmux's active-window fallback
ok - cursor composer: an idle Cursor pane reads empty even though the cursor row is blind
ok - cursor composer: real typed text still reads pending, so the injection guard holds
ok - cursor composer: an identical screen stays unknown when the pane is not Cursor
ok - cursor composer: a stale Cursor screen over a dead shell never reads empty
ok - commandcode composer: an idle pane reads empty although its cursor row is blind and its placeholder is bright
ok - commandcode composer: typed text still reads pending
ok - commandcode composer: an identical screen stays unknown when the pane is not Command Code
rc=0
Evidence: fm-control commandcode relaunch pre-stop refusal

Source: fm-control commandcode relaunch pre-stop refusal

ok - fm-control relaunch: commandcode off tmux and herdr is refused before the running agent is stopped

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-spawn.sh - merge conflict rebasing onto origin/main

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

⚠️ **Review** - 1 warning
  • ⚠️ bin/fm-control.sh:931 - The new rule that Command Code runs only on tmux or Herdr is checked only in bin/fm-spawn.sh:2409. During a relaunch, fm-spawn runs only after fm-control has already stopped the old agent. The comment at bin/fm-control.sh:927-930 states the invariant this breaks: a launch the launch owner would refuse must be refused on the pre-stop side, before anything changes (the kind check and account-pin check already work this way). Failing sequence: a claude ship task on backend=zellij (or cmux or orca) runs fm-control.sh &lt;id&gt; relaunch --harness commandcode. fm_control_harness_supported and fm_control_harness_supports_kind commandcode ship both pass. do_exit stops the running claude agent (line ~1112). fm-spawn.sh --relaunch then exits with "commandcode is verified on the tmux and herdr backends only". fm-control dies with "could not be launched on commandcode", and the task is left with no running agent. That is the outcome the pre-stop gate exists to prevent. The ci-1 note says the guard "covers --relaunch", but it fires only after the old agent is gone. Fix: put the backend rule in one shared predicate in bin/fm-control-lib.sh, for example fm_control_harness_supports_backend &lt;harness&gt; &lt;backend&gt; (commandcode → tmux|herdr only). Call it from fm-spawn.sh:2409 and from fm-control.sh next to the line-931 kind check, using $BACKEND from line 357. Add a regression: a zellij task relaunched with --harness commandcode is refused and its agent is never stopped.
  • ⚠️ bin/fm-composer-lib.sh:1783 - Simplification: the change adds a new environment override, FM_COMPOSER_COMMANDCODE_GHOST_LUMA_MAX (default 160), for the brightness ceiling used on Command Code screens. No intent requirement, and no recorded decision, needs this to be configurable. The intent only needs the verified Command Code placeholder (brightness ~147.3) to read as empty. A narrower form does the same job: a fixed ceiling of 160 inside the commandcode|cmd identity branch, with no new variable. Recommendation: remove the override unless you want maintainers to be able to tune it.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-control.sh:931 - The new rule that Command Code runs only on tmux or Herdr is checked only in bin/fm-spawn.sh:2409. During a relaunch, fm-spawn runs only after fm-control has already stopped the old agent. The comment at bin/fm-control.sh:927-930 states the invariant this breaks: a launch the launch owner would refuse must be refused on the pre-stop side, before anything changes (the kind check and account-pin check already work this way). Failing sequence: a claude ship task on backend=zellij (or cmux or orca) runs fm-control.sh &lt;id&gt; relaunch --harness commandcode. fm_control_harness_supported and fm_control_harness_supports_kind commandcode ship both pass. do_exit stops the running claude agent (line ~1112). fm-spawn.sh --relaunch then exits with "commandcode is verified on the tmux and herdr backends only". fm-control dies with "could not be launched on commandcode", and the task is left with no running agent. That is the outcome the pre-stop gate exists to prevent. The ci-1 note says the guard "covers --relaunch", but it fires only after the old agent is gone. Fix: put the backend rule in one shared predicate in bin/fm-control-lib.sh, for example fm_control_harness_supports_backend &lt;harness&gt; &lt;backend&gt; (commandcode → tmux|herdr only). Call it from fm-spawn.sh:2409 and from fm-control.sh next to the line-931 kind check, using $BACKEND from line 357. Add a regression: a zellij task relaunched with --harness commandcode is refused and its agent is never stopped.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-control.sh:931 - The new rule that Command Code runs only on tmux or Herdr is checked only in bin/fm-spawn.sh:2409. During a relaunch, fm-spawn runs only after fm-control has already stopped the old agent. The comment at bin/fm-control.sh:927-930 states the invariant this breaks: a launch the launch owner would refuse must be refused on the pre-stop side, before anything changes (the kind check and account-pin check already work this way). Failing sequence: a claude ship task on backend=zellij (or cmux or orca) runs fm-control.sh &lt;id&gt; relaunch --harness commandcode. fm_control_harness_supported and fm_control_harness_supports_kind commandcode ship both pass. do_exit stops the running claude agent (line ~1112). fm-spawn.sh --relaunch then exits with "commandcode is verified on the tmux and herdr backends only". fm-control dies with "could not be launched on commandcode", and the task is left with no running agent. That is the outcome the pre-stop gate exists to prevent. The ci-1 note says the guard "covers --relaunch", but it fires only after the old agent is gone. Fix: put the backend rule in one shared predicate in bin/fm-control-lib.sh, for example fm_control_harness_supports_backend &lt;harness&gt; &lt;backend&gt; (commandcode → tmux|herdr only). Call it from fm-spawn.sh:2409 and from fm-control.sh next to the line-931 kind check, using $BACKEND from line 357. Add a regression: a zellij task relaunched with --harness commandcode is refused and its agent is never stopped.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 9 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Captain dispatches a scout on Command Code (tmux) with deepseek/deepseek-v4.1-flash; it runs the brief and commits with no Command Code attribution ✅ pass live commandcode-live-tmux-e2e.log: 'spawn brief, model, effort, autonomy, trust, identity, and the busy mod' and 'the worker commit carries no attribution'
Firstmate steers an idle Command Code worker: composer reads empty, fm-send doorbell is read and acknowledged (tmux) ✅ pass live commandcode-live-tmux-e2e.log: 'idle composer reads empty; real fm-send doorbell read and acknowledged'
Interrupt, exit, resume and relaunch on tmux: one Escape cancels a busy turn, an open rewind picker blocks exit and is closed without restoring, /quit exits, relaunch re-arms the mod ✅ pass live commandcode-live-tmux-e2e.log: lines 4-8, exit=0 elapsed=320s
Same worker lifecycle on the Herdr backend in a guarded fm-lab session (spawn, empty composer, steer, interrupt, exit, relaunch) ✅ pass live commandcode-live-herdr-lab.log: herdr agent=cmd idle, composer empty, steer=1147 acknowledged, interrupt-delivered, stopped, relaunched model=deepseek/deepseek-v4.1-flash effort=low, result 91, fresh…
Operator routes small, clear tasks to commandcode + deepseek/deepseek-v4.1-flash in config/crew-dispatch.json; bootstrap accepts it and rejects a misspelled harness ✅ pass live crew-dispatch-bootstrap-validation.txt: valid rule gives no CREW_DISPATCH error; 'command-code' gives 'unverified harness: command-code'
Only verified effort pairs reach the CLI: flash low/high/max are passed; xhigh and every -fast pair are recorded but omitted ✅ pass live spawn-effort-and-backend-guard.txt effort routing table
Adversarial: a commandcode spawn on zellij, cmux or orca is refused before any launch, task record or busy state ✅ pass live spawn-effort-and-backend-guard.txt backend guard section (rc=1, launched=no, task_record=no, busy_armed=no); tests/fm-commandcode-harness.test.sh
Adversarial: relaunching a running claude task onto commandcode on zellij, cmux or orca is refused before the old agent is stopped ⏸️ untested no The prior payload did not establish a live result. No zellij, cmux or orca install was available to host a real running agent, so this was covered only by the fm-control.test.sh regression with backen…
Adversarial: a commandcode secondmate launch is refused ✅ pass live spawn-effort-and-backend-guard.txt secondmate section: 'crewmate/scout adapter only', rc=1
The PR branch is rebased on the latest upstream main ✅ pass live git merge-base --is-ancestor origin/main HEAD succeeded; origin/main = 2ce57d0 = run base
  • FM_COMMANDCODE_SIGNALS_LIVE=1 bash tests/fm-commandcode-signals-live-e2e.test.sh (credentialed, real commandcode 1.77.0 on a private tmux socket, deepseek/deepseek-v4.1-flash --effort low)
  • drive-commandcode-herdr-lab.sh (evidence dir): real fm-spawn launch command run in a pane of a guarded fm-lab-cc-gate-* Herdr 0.9.3 session via bin/fm-herdr-lab.sh; checked agent and composer state, ran fm-send steer, fm-control interrupt, exit and relaunch, then tore the lab down with the tripwire verified
  • drive-spawn-and-dispatch.sh (evidence dir): real bin/fm-spawn.sh effort routing for deepseek-v4.1-flash and -fast, backend refusal on zellij, cmux and orca, secondmate refusal
  • bin/fm-bootstrap.sh against a disposable bin/fm-lab-home.sh home with config/crew-dispatch.json naming commandcode + deepseek/deepseek-v4.1-flash, plus a misspelled-harness case
  • bash tests/fm-commandcode-harness.test.sh
  • bash tests/fm-busy-state.test.sh
  • bash tests/fm-git-strip-ai-trailers.test.sh
  • bash tests/fm-tmux-agent-liveness.test.sh
  • bash tests/fm-control.test.sh (includes commandcode relaunch refused before stop on zellij, cmux and orca)
  • git merge-base --is-ancestor origin/main HEAD
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds Command Code as a supported worker harness.

The PR appears safe to merge based on this review.

Reviews (3) · Last reviewed commit: "no-mistakes(ci): I fixed ci-sc2016. Shel..."

Comment thread bin/fm-spawn.sh Resolved
Comment thread bin/fm-commandcode-mod.ts Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Status: waiting on CI · contract-class: opt-in · head fcb2bedb

Thanks for the careful live verification on this adapter. I read the full diff (no workflow changes, nothing that reaches outside the task's own wiring) and approved this head's fork runs (CI and Require no-mistakes). Both Greptile threads are resolved and its latest review is 5/5.

On the class: Command Code only runs when a captain dispatches to commandcode (explicit --harness or a crew-dispatch.json rule), and it's refused for secondmates and on backends other than tmux and Herdr. The shared-path touches stay inert for the unconfigured fleet: the composer ghost ceiling and the tmux unknown recheck only change a verdict when the pane's identity is Command Code, the new idle placeholder only matches Command Code's exact text, and the trailer strip only adds Command Code's own co-author line. So it's opt-in, matching how earlier crewmate-only adapters were handled.

Next: if CI and the no-mistakes check come back green, this is eligible to merge without a captain decision. If anything goes red, it will be back with you.

VISION.md per-rule: One captain, one interface: aligns. Authority explicit: aligns (opt-in; --yolo here is the harness's permission bypass like other crewmate adapters, while firstmate's merge authority stays with the task's --yolo on|off). Scripts/agents split: aligns (busy state comes from a per-process mod through fm-busy-event.sh). Restart is a non-event: aligns (native resume and relaunch verified). Delegation with a spine: aligns. Outlives any vendor: aligns (another verified adapter, version-pinned to 1.74.1 with its own verification doc; the rendered-surface composer read is identity-scoped). Scope: aligns, and the always-loaded AGENTS.md line grows by only the adapter name.

Add `commandcode` as a verified worker runtime for crewmate and scout work
only, so Firstmate can dispatch workers on Command Code models such as
deepseek/deepseek-v4.1-flash.

- Detection: the anchored `command-code` process title identifies the
  adapter in fm-harness.sh and the shared liveness classifier.
- Launch: fm-spawn passes --yolo, --trust, --skip-onboarding, the model, an
  effort only where the model's accepted set is verified, and the typed
  launch brief after --; taste-learning state is kept out of git.
- Busy state: a tracked mod, bin/fm-commandcode-mod.ts, is loaded per
  process with --mod and --mod-option, writing run_start/run_end/session
  end through fm-busy-event.sh; no user or project settings are edited
  (Command Code's --config persists globally, so it is never used).
- Control: one Escape interrupts; the idle double-Escape Rewind picker is a
  recognized hazard that exit refuses and interrupt dismisses; /quit exits.
- Composer: the bright truecolor placeholder is read with an
  identity-scoped ghost ceiling, and the tmux adapter supplies the identity
  for a cursor parked below the footer; Herdr reports it natively as `cmd`.
- Attribution: the fleet commit-msg strip removes the CommandCodeBot
  trailer.
- Docs, harness reference, verification record, portable regressions, and
  the FM_COMMANDCODE_SIGNALS_LIVE live guard.
…th new regression tests fail on the old code and pass now. The changes are not committed. **ci-1: Command Code on zellij, cmux and orca.** The rule that must hold is that a Command Code worker only runs on a backend that tells Firstmate the pane is Command Code. Without that, its idle placeholder never reads as an empty composer, so steering stalls. `bin/fm-spawn.sh` now refuses `--harness commandcode` unless the backend is tmux or herdr. The error reads: `commandcode is verified on the tmux and herdr backends only; backend=<b> cannot prove its composer empty. Select backend tmux or herdr.` - The check runs after both the harness and the backend are known, so it covers fresh spawns and `--relaunch`. - It runs before any pane, worktree, task record or busy state is created. - New test in `tests/fm-commandcode-harness.test.sh`: tries a scout spawn on each of zellij, cmux and orca (with a fake `orca` that reports ready). It checks for the refusal and that nothing was launched, no task record was written and busy state was not armed. It needs no real backend installed. - Documented in `docs/configuration.md`, the Command Code adapter reference and the `fm-spawn.sh` header. **ci-2: an old process signalling its replacement.** The rule is that the `turn-ended` notification may only be raised under the same generation check as the idle write. The mod used to touch the file itself after the writer returned, which left a gap for a relaunch to slip in. - `bin/fm-busy-event.sh apply` takes a new `--turn-ended` flag. It touches `state/<id>.turn-ended` while still holding the writer lock, after the generation check passes. A stale generation is refused with no touch, and the flag is rejected on any subcommand other than `apply`. - `bin/fm-commandcode-mod.ts` no longer touches files itself. On `run_end` it passes `--turn-ended` unless the turn was interrupted. - New test in `tests/fm-commandcode-harness.test.sh`: a fake writer accepts the idle write and then arms a replacement before the mod continues. It asserts no notification appears. - New test in `tests/fm-busy-state.test.sh`: the notification is raised for the current generation, not for a stale one, and not outside `apply`. **Checks run:** - Passing: `fm-commandcode-harness`, `fm-busy-state`, `fm-busy-adapter-wiring`, `fm-backend`, `fm-documentation-audiences`, and `bash -n` on the changed shell files. - `fm-bootstrap.test.sh` fails one case ("backend=herdr must fail closed on its own missing session CLI"). It fails the same way on an untouched copy of the branch, because herdr is installed at `/usr/bin/herdr` on this machine. - `bin/fm-lint.sh` could not run because ShellCheck 0.11.0 is not on PATH, so the changed shell files have not been linted. **Not changed:** Devin's hook does the same thing outside this PR: it runs `apply ... && touch` in `bin/fm-devin-config.sh`. That predates this PR and is not in the changed area, so I left it alone
…is machine, so I could not confirm that the lint warning is gone. **The rule that was broken:** the repo lints with ShellCheck at its default severity, which also fails on info-level notes. Any single-quoted `$` that is meant to stay literal needs a scoped disable comment that says why. Only one place in the changed area needed this: the racing-writer `printf` in `tests/fm-commandcode-harness.test.sh`. Its format string writes `"$2" "$3"` on purpose, so the generated fake writer reads its own arguments when it runs. **The fix:** I added one line just above that `printf`: `# shellcheck disable=SC2016 # positional params expand in the generated writer.` The repo already does this the same way, for example in `tests/fm-afk-launch.test.sh` and `tests/fm-ask-user-authority.test.sh`. Nothing else changed, so the test behaves exactly as before. **Checks run:** - `bash -n tests/fm-commandcode-harness.test.sh` passes. - `bash tests/fm-commandcode-harness.test.sh` passes all six cases, including the busy-mod case with the racing writer. **Not run:** `bin/fm-lint.sh` stops with "ShellCheck not found" because ShellCheck 0.11.0 is not on PATH and there is no copy in the repo. I did not install it, since installs outside the worktree are off limits here. The upstream lint run will be the first ShellCheck pass on this change. The change is not committed
@pback34 pback34 changed the title feat(bin): add Command Code crewmate and scout adapter feat(bin): add a verified Command Code (commandcode) crewmate/scout adapter Oct 8, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Status: waiting on CI · contract-class: opt-in · head d2d75630

Thanks @pback34 for rebasing onto current main and closing the relaunch gap. Since my last stamp (head fcb2bedb, which went fully green), the branch was rebased onto main 2ce57d00. I compared the two diffs file by file. Only three files changed:

  • bin/fm-composer-lib.sh: the Command Code ghost-luma ceiling is now a fixed 160, still applied only when the backend identity probe reports Command Code. The FM_COMPOSER_COMMANDCODE_GHOST_LUMA_MAX override is gone.
  • docs/configuration.md: the matching doc note.
  • tests/fm-control.test.sh: a new case asserting that a relaunch onto commandcode on zellij, cmux or orca is refused before the running agent is touched.

There are still no .github or CI-script changes, so I approved this head's fork runs (CI and both Require no-mistakes runs).

Class unchanged: opt-in. The fleet-wide ghost ceiling stays at 128, and every new composer or tmux verdict is scoped to a Command Code identity, so an unconfigured fleet reads panes exactly as before.

Next: if CI and the no-mistakes check come back green on this head, it can merge without a captain decision. If anything goes red, it'll be back with you. My VISION per-rule read from the earlier comment stands (aligns on every rule).

@pback34

pback34 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Hi @kunchenguid, a friendly nudge on this one.

Head d2d75630 came back fully green: CI, both Require no-mistakes runs, and every behavior suite. Your triage note above says it is opt-in class and can merge without a captain decision once green.

GitHub still reports it MERGEABLE / CLEAN against current main. It is 14 commits behind, but a test merge onto main goes through without conflicts.

Could you merge it when you get a chance? I'm happy to rebase or change anything first if you'd prefer. Thanks!

@opariffazman

Copy link
Copy Markdown

Waiting on this too, please merge when have the chance good sir @kunchenguid

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @pback34 for the nudge, and thanks @opariffazman for the ping.

Delta since my last stamp (2026-10-08): no new commits (still head d2d75630). CI and both Require no-mistakes runs are green on this head; GitHub reports MERGEABLE/CLEAN. Attestation MATCH; live was already ✅ go (9/10). Behind main a bit, but no conflict.

Contract-class: still opt-in. Command Code only runs when dispatched; shared-path touches stay identity-scoped.

VISION.md per-rule: prior verdict stands — aligns on every rule (opt-in adapter; authority explicit; vendor-surviving harness lane).

Next: eligible to auto-merge once main's current tip CI is green. Main just moved to 7df545bf (#7172) and its run was still in progress when I checked, so I am not merging yet. No action needed from you unless that run goes red in a way that dirties this branch.

@opariffazman

Copy link
Copy Markdown

@kunchenguid all good for auto merge boss?

@kunchenguid
kunchenguid merged commit a24f4cb into kunchenguid:main Oct 15, 2026
20 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @pback34 — really appreciate you taking the time on this. (And thanks @opariffazman for the patience.)

valerius21 added a commit to valerius21/firstmate that referenced this pull request Oct 15, 2026
* fix: require explicit authority for Firstmate upstream contributions (kunchenguid#7172)

* feat(bin): gate firstmate-upstream publication behind a declared home role

Users who clone firstmate and run it as-is got a surprise: when their
agent hit a firstmate bug, it could drive a pull request at upstream
because nothing distinguished the maintainer's home from an ordinary
user's. Every home now resolves to user/operator unless the gitignored
config/firstmate-role grants a maintainer scope, or a single task
carries the captain's recorded --upstream-consent on the brief, spawn,
and promotion. fm-brief, fm-spawn, and fm-promote apply one fail-closed
gate in bin/fm-role-lib.sh; the role is never inferred from gh identity,
remotes, permissions, or CI, and secondmates honor only receipt-proven
inherited grants so a child cannot grant itself. Session start reports
the resolved role with no network call. Ordinary project delivery and
the clone-and-run setup flow are unchanged.

* no-mistakes(review): Harden firstmate role parsing, normalization, and inheritance

* no-mistakes(review): Detect firstmate by lineage; drop consent fallback; fix claims

* no-mistakes(document): Correct and consolidate Firstmate role documentation

* fix(pi): narrow before_agent_start events before reading prompt (kunchenguid#7248)

* fix: narrow Pi before-agent prompt events

* no-mistakes(review): Restore processing-run abort detection and type Pi test events

* feat: let a home declare authoritative external memory tiers (kunchenguid#6608)

* docs: let a home declare authoritative external memory tiers

AGENTS.md section 6 routed durable knowledge only to firstmate-local files,
so a home whose captain keeps reasoning and facts in external stores had no
tracked rule keeping those stores authoritative over the per-machine data/
cache. Add a generic home-declared Memory layering contract (schema in
docs/configuration.md), make firstmate the capture path for workers whose
harness cannot reach a declared tier, and teach the stow skill to route to
declared tiers first and never prune a tier-owned entry without capturing it.

* no-mistakes(review): Report missing memory-layering declaration and index tier docs

* no-mistakes(document): Narrow memory-tier re-seed step to captain re-declaration

* no-mistakes(ci): Environment: 2026-10-05, host wildrobot, Linux 7.0.0-34. Finding ci-1 (Greptile): a tier-owned fact could be lost when its declared tier was unreachable from the session. - The invariant that was broken: until the declared tier holds a tier-owned fact, that fact must stay in a memory file loaded at startup. - Where it could be broken: the declared-tier guard, which said to archive the entry to the never-loaded cold tier; the routing step for new findings, which only mentioned the receipt; and the budget-eviction and offload eligibility rules. Fix, made only in .agents/skills/stow/SKILL.md: - **New marker.** Added `<!--t:NAME-->` to the existing compact marker list, so its meaning lives in one place. It marks a tier-owned entry that tier NAME does not hold yet. Stow never prunes, ages out, evicts, offloads, consolidates away, or archives an entry carrying it, whatever its tier clock says. A later pass that can reach NAME captures the entry there and removes the marker. - **Declared-tier guard.** "still archive rather than delete" now says to leave the entry in place with its pending-capture marker, and the receipt still names it. - **Routing step 2.** When the tier is unreachable, a new finding is written to the startup-loaded local file its class would otherwise use, or kept where it already lives, with the marker. It is still reported as an exception in the receipt. - **Budget eviction and offload eligibility.** Both now exclude entries pending capture, so the convergence pool is counted correctly. - **Receipt bullet.** Changed "finding or pruned entry" to entries left carrying the pending-capture marker, because those entries are no longer pruned. docs/configuration.md ("protects tier-owned entries from pruning") and AGENTS.md section 6 are still accurate, so I left them unchanged. No new file, queue, script, or digest section. One sentence per line, plain dashes. Verification: tests/fm-stow-cascade.test.sh, tests/fm-documentation-audiences.test.sh, and tests/fm-lint.test.sh all pass

* docs: keep undeclared memory-tier path silent and close stuck tier markers

Drop the stow receipt line reporting a missing Memory layering declaration
(AGENTS.md section 6, the stow skill, docs/configuration.md) so a home with
no declaration behaves exactly as before. Name pending-capture entries in the
exempt floor wording, and say how stow retargets or clears a pending-capture
marker whose tier was renamed or retired.

* fix: keep unsupported contribution URLs unmeasured (kunchenguid#7233)

* fix: keep unsupported contributions unmeasured during polling

* no-mistakes(document): Clarify unsupported contribution polling documentation

* no-mistakes(review): Match literal GitHub hostname and cover unsupported lookalikes

* no-mistakes(review): Separate durable ownership compatibility from GitHub observation eligibility

* no-mistakes(document): Clarify unsupported contribution coverage and ownership compatibility

* fix(bin): keep inherited Git config entries when installing the trailer-strip hooks path (kunchenguid#6341)

* fix(bin): keep inherited Git credential helpers when installing the trailer hooks path

Problem:
Every fleet launch prefixed the worker command with `export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.hooksPath GIT_CONFIG_VALUE_0=...`.
That replaced any `GIT_CONFIG_*` entries the pane already carried, so a scoped HTTPS credential setup such as `credential.helper=` followed by `credential.helper=!gh auth git-credential` was silently dropped.
Git then fell back to the system or global helper (for example `osxkeychain` from the system gitconfig on macOS), so a worker meant to use a scoped token pushed with the user's personal credentials.

Reproduction on main:
GIT_CONFIG_COUNT=2 GIT_CONFIG_KEY_0=credential.helper GIT_CONFIG_VALUE_0= GIT_CONFIG_KEY_1=credential.helper GIT_CONFIG_VALUE_1='!gh auth git-credential' sh -c "<emitted launch>; git config --get-all credential.helper" prints none of the inherited entries, only the system helper (`osxkeychain` from Homebrew's system gitconfig on the reporting machine).

Fix:
The launch prefix now appends `core.hooksPath` at index `GIT_CONFIG_COUNT` and increments the count, resolved in the destination shell after any `config/launch-env-allowlist` filtering.
The inherited count is validated as decimal before shell arithmetic, leading zeros are normalized (Git accepts `02`), and a count that cannot be extended within Git's signed int refuses.
A refusal uses `return 1 2>/dev/null || exit 1`, so when the pane sources the launch file the error stays visible and the interactive shell survives instead of the pane dying with the message.

Tests:
`tests/fm-spawn-dispatch-profile.test.sh` gains a behavior test that runs the real emitted launch under sh, bash, and zsh with inherited credential-helper entries and counts `2` and `02`, then asks Git for `credential.helper` and `core.hooksPath`.
The same test checks that an invalid or overflowing count refuses, and that sourcing the launch file from an interactive shell keeps that shell alive with the error visible.
The exact-launch assertions in the dispatch-profile and Kimi suites now extract the emitted prefix through one `fm_test_launch_git_prefix` helper in `tests/lib.sh` instead of two hand-copied strings, whose content the behavior test covers.

Risk:
Top-level `return` outside a sourced file is unspecified by POSIX; verified on macOS sh (bash 3.2 in POSIX mode), bash, and zsh, and every path still ends nonzero before the worker command runs.
The hook wrapper still unsets only `GIT_CONFIG_COUNT` and index 0, which is sufficient because Git ignores indexed entries once the count is unset.
A launch that forwards `GIT_CONFIG_COUNT` without all of its indexed keys now fails in Git instead of being masked by the overwrite.

* no-mistakes(review): Keep inherited Git config in hooks and fish-safe launch

* no-mistakes(document): docs: describe appended hooksPath keeping inherited Git config

* test: run the fish pane launch cases in CI

Install fish in the portable serial lane and run the credential-append
and invalid-count refusal cases under fish. Under CI the spawn test
fails instead of falling back to the static syntax check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: strip the Git config launch prefix before reading the Claude doorbell

The trust suite evaluated the whole launch command to find the final prompt
argument, so it now also sourced the per-spawn git-config env file that the
fake pane never writes. Drop that prefix the same way the dispatch suite does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: share the launch command parser across the spawn suites

The trust suite failed in CI because its copy of the launch parser missed
the Git configuration prefix the dispatch suite's copies already stripped.
Move the prefix and export stripping into tests/lib.sh next to
fm_test_launch_git_prefix so the three parsers cannot drift again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(bin): canonicalize env-file hooks path and tighten launch-config tests

env-file now writes the canonical (pwd -P) spelling of the hooks directory, matching what install records, so a symlinked path no longer makes the hook wrapper miss its own entry and silently skip the repository's hook.
A new strip test passes a symlinked hooks path through env-file and fails without this change.

The launch-env-allowlist test now also asserts the appended core.hooksPath, so a regression that drops the strip-hook entry only on the env -i path is caught.

Without fish installed locally, the launch test now prints an explicit fish skip line and limits its pass message to sh, bash and zsh, instead of claiming every pane shell after only a static token check.

* no-mistakes(review): Drop CI fish install and CI-only fish refusal

* no-mistakes(document): Document GIT_CONFIG_COUNT overflow refusal in configuration docs

* test: prove a refused Git config count never starts the worker

The invalid-count refusal checks only asserted a nonzero status and the helper's own error text.
If the launch line kept going after the refusal, the worker probe's final `git config` also failed under the bad count, so the checks still passed.
The probe now prints a marker on stderr, and every refusal case in sh, bash, zsh and fish asserts the marker never appears.
Dropping the `|| return 1 2>/dev/null || exit 1` guard from the launch line now fails the test.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(bin): name the failing step when a contribution observation is unavailable (kunchenguid#6810)

* fix(bin): name the failing read when a contribution observation is unavailable

An unavailable contribution observation recorded one constant error and
discarded the failing read's exit status and error output on cleanup, so a
network failure, a forge refusal and a structural check failure all looked
the same and left nothing to diagnose once the next good read cleared it.

The record's error and the unavailable line now name the first failing step:
the read's label, exit status, budget seconds left and the first line of its
error output, or the structural check that refused the observation. Budget
refusal stays silent and unmeasured as before.

* no-mistakes(review): Label closing head read's structural failure as its own cause

* no-mistakes(document): Note structural refusals record contribution errors too

* fix(spawn): scope Orca worker launch env to an opt-in tmux session (kunchenguid#6365)

* fix(spawn): give Orca workers an opt-in scoped environment source

Fixes kunchenguid#6339

On the Orca backend, `config/launch-env-allowlist` expands each allowlisted name in the destination pane, and that pane is an Orca terminal whose environment comes from the Orca app and the user's shell startup files.
Allowlisted credentials therefore resolve to the user's personal values or to nothing, with no warning, while the same allowlist scopes tmux workers correctly.

Add an opt-in `config/launch-env-tmux-session` naming one tmux session.
On a fresh Orca spawn, before the worktree or terminal is allocated, fm-spawn reads each allowlisted name from that session's local environment with `tmux -u show-environment -t =<session> <name>`.
The worker launches with the existing `env -i` boundary and operational floor, the snapshotted values in place of destination expansion, and `GIT_CONFIG_NOSYSTEM=1` so a system credential helper cannot answer for the worker.
The source requires an allowlist, so tmux's automatic update-environment names such as `SSH_AUTH_SOCK` are never forwarded unless listed.
A listed name missing from the session, an unreadable session, or a malformed selector refuses before allocation; an explicit `-NAME` record stays a deliberate unset.
Values are shell-quoted only in the existing owner-only staged launch file, never terminal input, and the pane deletes that file as sourcing starts; a deletion failure refuses the worker launch and keeps the interactive shell.
`-u` is required because tmux's non-UTF-8 client output replaces newlines and non-ASCII bytes in values with underscores.

The source is opt-in and nothing changes for homes that do not create the file.
When `config/backend` is orca, the allowlist is nonempty, and no source is configured, fm-spawn now prints a stderr warning that allowlisted names resolve from the Orca terminal, so the mismatch is no longer silent.
It warns rather than refuses because refusing would stop every existing Orca home that uses an allowlist, which the triage asked not to assume.
Other backends, relaunch (already refused on Orca), and secondmate inheritance are unchanged; the selector is not in the inherited configuration list.

The scoped Git credential helper case also needs kunchenguid#6341, which stops fm-spawn's `core.hooksPath` entry from overwriting inherited `GIT_CONFIG_*` entries; this change does not depend on it.

Tests in `tests/fm-spawn-orca-worktree.test.sh`:

- A real-tmux regression on a private socket checks exact multiline UTF-8 values under absent and C locales through sh, Bash, and zsh, refusal of names that exist only server-globally or only inside another value, and exclusion of the automatic `SSH_AUTH_SOCK`.
- Fake-Orca spawns execute the real staged launch file under synthetic personal credentials and cover the configured source, an empty allowlist, refusal before allocation for each invalid setting, file privacy and deletion before the worker runs, and the deletion-failure path.
- The warning appears for a nonempty allowlist without a source and not for an empty allowlist or a configured source.

Risk: the source keeps tmux and the named session as dependencies of Orca spawns, and secret values sit in a 0600 file under a 0700 directory until the pane sources it.
It is not a filesystem sandbox; a worker can still read the user's credential files unless the harness restricts that.
The hardened path was verified with the regressions above, not with a live Orca spawn.

* no-mistakes(review): Harden Orca launch-file cleanup, floor unsets, and stat portability

* no-mistakes(review): Scope Orca abort cleanup to the staged launch file

* docs: scope Orca source to fresh spawns and qualify pane values

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: state that Orca relaunch is refused

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* no-mistakes: apply CI fixes

* no-mistakes(review): Keep Orca launch file while delivered terminal stays open

* no-mistakes(document): Qualify fm-spawn help's destination-pane expansion claim for Orca

* fix(spawn): keep launch-send failures fatal and compare tmux bytes per version

The Orca launch-file cleanup wrapped both launch sends in a condition, which runs outside errexit.
A failed send on tmux and every other non-Orca backend then continued as success, so a post-publication relaunch failure no longer failed closed.
Each send failure now exits again, and Orca source mode removes its staged file first.

The real-tmux regression asserted that invalid UTF-8 bytes survive tmux itself, which holds on tmux 3.6a but not on the CI runner's tmux.
It now asserts that the snapshot reproduces exactly the bytes the installed tmux reports for that name.

* fix(spawn): reclaim an Orca launch file the pane never runs

In Orca source mode the pane unlinks the credential-bearing launch file as it starts sourcing it.
A pane that accepted the source command but never ran it left the file on disk until teardown, because the abort cleanup keeps the file for a delivered, still-open terminal.
After delivery, fm-spawn now waits up to 30 seconds for the pane to consume the file; if it has not, fm-spawn removes it and fails the spawn with a status line naming the unrun command.

The snapshot already reads and writes tmux output as latin1, so bytes that are not valid UTF-8 reach the launch file unchanged.
A deterministic fake-tmux regression now pins that, independent of how the installed tmux stores such values.

The live-terminal test now drives a slow pane and fails unless the spawn waits for it, and the controlled-source test reads the file the fake pane consumed.

* no-mistakes(review): Keep Orca terminal open when launch file is unconsumed

* no-mistakes(review): Refuse Orca worker when launch file already reclaimed

* no-mistakes(review): Make Orca spawn's deadline launch-file reclaim exclusive

* no-mistakes(document): Document Orca launch-file reclaim keeping the terminal open

* fix(spawn): reclaim an interrupted Orca launch file and keep errexit panes open

An HUP, INT or TERM after the source command reached the Orca terminal left
the credential-bearing launch file on disk: bash ran the EXIT trap with status
0 and abort cleanup kept a delivered file for the pane. Source mode now traps
those signals until the pane consumes the file, and abort cleanup reclaims it
with the same non-forced unlink arbitration as the consume deadline, refusing
the worker when the spawn wins and leaving the terminal open.

The delivered source line now keeps a pane shell with errexit set open when
the launch is refused, including when the file was already reclaimed.

* no-mistakes(review): Trap signals as soon as Orca launch file is published

* no-mistakes(document): Record pre-send interrupt coverage in Orca verification notes

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

* fix(bin): treat OpenCode's right-aligned cwd rail as composer furniture, including absolute paths (kunchenguid#7307)

* fix(composer): treat OpenCode >= 1.18 right-aligned cwd:branch as furniture

OpenCode 1.18.31 draws the worker pane's working directory and branch
right-aligned inside the left-bar composer rows above the Build footer,
wrapped over up to three rail-width fragments whose final fragment
continues onto the footer row's right end. The fragments are RGB 128
grey with luminance exactly on the ghost-luma ceiling, so they survive
ghost stripping, and the left-bar classifier read them as unsent typed
text: every idle 1.18.31 pane answered pending, which skipped the
steering doorbell, the watcher's re-ring ladder, and /exit typing.

_fm_composer_leftbar_cwd_start recognises the run structurally and
position-gated: contiguous single-token rows immediately above the
footer row whose gap after the bar exceeds half the row, whose
fragments plus the footer row's gap-separated right-hand tail
concatenate to a path, optionally followed by :<branch>. A path-shaped
string typed at the composer's left edge is still typed text, so a
wrong call can only defer, never inject. Extraction shares the same
rule so extracted composer content stays user-scoped.

* no-mistakes(review): drop dead footer-tail concat, add live short-cwd fixture

* no-mistakes(review): accept only ~/ cwd rail; lone slash stays pending

* no-mistakes(review): require footer row for leftbar cwd furniture walk

* no-mistakes(review): Require topmost cwd fragment to carry ~/ prefix

* no-mistakes(document): Correct cwd furniture recognition doc to topmost-fragment check

* fix(composer): gate cwd rail on region width; correct version story

Review round on the independent PR review: the position gate now measures
the gap against the region's width (the widest trimmed plain row across
first..last), so a short space-prefixed home path typed into an otherwise
empty composer no longer reads empty; the right-half lone-token residual
is pinned explicitly. The cwd:branch furniture is documented as present
since OpenCode 1.18.0 (upstream anomalyco/opencode#36457, merged
2026-07-11), not a 1.18.31 layout change. The 1.18.30 capture comment
notes it omits the directory footer, and a cropped-composer extraction
assertion scopes user content to the typed row above the rail.

* no-mistakes(document): correct OpenCode cwd-furniture version framing and doc typos

* fix(composer): accept an absolute cwd rail outside $HOME as OpenCode furniture

Refs kunchenguid#4632, builds on kunchenguid#5030.

* no-mistakes(review): Harden live abs-cwd check waits and qualify rail comment

* no-mistakes(review): Fix composer-lib relative path in OpenCode harness doc

* no-mistakes(test): Relax live check's DONE wait for wide OpenCode panes

* no-mistakes(document): Separate absolute-cwd verification output block from following prose

---------

Co-authored-by: Konrad Heimel <[email protected]>

* fix(bin): report a worker parked on the exit picker as blocked-on-prompt (kunchenguid#6682)

* fix: name the Claude exit picker on existing stale wakes

A pane parked on that picker still read as healthy quiet after Enter was refused. The existing stale and wedge reports now carry the dialog name, including through away-mode escalation.

Refs kunchenguid#4754

* no-mistakes(review): fix: report exit picker on terminal-status away stales

* no-mistakes(document): docs: describe exit-picker reporting in stale supervision

* no-mistakes(review): fix: drop away stale marker when second-mate picker closes

* fix: keep the exit-picker name off paths main does not already run

A second mate stays exempt from stale capture, and a finished worker in away mode no longer ages into a wedge. The name remains on the stale and wedge wakes a worker already raises.

* no-mistakes(review): name the exit picker on wedge deferral reasons

* no-mistakes(review): limit exit-picker name to plain stale and wedge escalation

* feat: set afk spend cap from live ordinary workers at entry (kunchenguid#7308)

* feat(afk): Spend-Obergrenze beim Eintritt aus der lebenden Worker-Zahl

Ohne ausdrückliches --spend nimmt der Eintritt in den Away-Modus die Zahl der
gerade im Home stehenden gewöhnlichen Worker als Obergrenze, damit der Modus
laufende Parallelität nicht einengt. Der bisherige Default bleibt Untergrenze,
0 bleibt ausgeschlossen, und ein ausdrückliches --spend gewinnt weiterhin.

Die Zählung bekommt mit `live-workers` genau eine Implementierung in
bin/fm-afk-contract.sh. bin/fm-spawn.sh liest sie dort statt mit einer eigenen
Schleife, sodass Eintritt und spätere Sperre nicht auseinanderlaufen können.

* no-mistakes(document): Remove misplaced afk spend-cap plan

---------

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

* fix(bin): guide completed-scout cleanup and permit stock lab supervision paths (kunchenguid#6965)

* fix(bin): guide supervision through completed-scout cleanup

* no-mistakes(document): Document completed-scout cleanup ownership and regression coverage

* no-mistakes(test): Allow confined lab overrides and verify live scout cleanup

* no-mistakes(test): Clarify per-task cleanup reporting and verify live outcomes

* ci: let a fork skip the push run and the macOS job by repository variable (kunchenguid#7260)

* fix(bin): have workers paused on their own background job set until to the job's timeout (kunchenguid#7240)

* fix: recheck a worker paused on its own background job

A worker that declares `paused:` on its own background job and then misses the job's completion stays idle until the long declared-wait recheck, because the first-sight alert spends the declaration's throttle and nothing else names when the job must have ended.
The worker pause instructions now say that `until` for such a job is its start plus its timeout, and the watcher already rechecks once when that time passes.
The recovery playbook now tells the supervisor to verify the condition a declared wait names before reporting the wait as healthy.

Fixes kunchenguid#7239

* test: give the background-job until test headroom over its quiet round

The first absorb round of the until test may take four poll cycles of up to 30 s each on a loaded runner.
With `until` only 15 s ahead, that time could pass during the round and fail the test although the watcher behaves correctly.
Set `until` 120 s ahead so the window covers those four cycles, as CONTRIBUTING asks of fixture windows.

* chore: retrigger CI

* chore: retrigger CI

* no-mistakes(review): Rebuild bg-job until test with passed until, no sleep

* no-mistakes(review): Restore bg-job absorb checks and assert due recheck marker

---------

Co-authored-by: pedromuller-del <[email protected]>

* feat(bin): add a verified Command Code (commandcode) crewmate/scout adapter (kunchenguid#6679)

* feat: add Command Code crewmate and scout adapter

Add `commandcode` as a verified worker runtime for crewmate and scout work
only, so Firstmate can dispatch workers on Command Code models such as
deepseek/deepseek-v4.1-flash.

- Detection: the anchored `command-code` process title identifies the
  adapter in fm-harness.sh and the shared liveness classifier.
- Launch: fm-spawn passes --yolo, --trust, --skip-onboarding, the model, an
  effort only where the model's accepted set is verified, and the typed
  launch brief after --; taste-learning state is kept out of git.
- Busy state: a tracked mod, bin/fm-commandcode-mod.ts, is loaded per
  process with --mod and --mod-option, writing run_start/run_end/session
  end through fm-busy-event.sh; no user or project settings are edited
  (Command Code's --config persists globally, so it is never used).
- Control: one Escape interrupts; the idle double-Escape Rewind picker is a
  recognized hazard that exit refuses and interrupt dismisses; /quit exits.
- Composer: the bright truecolor placeholder is read with an
  identity-scoped ghost ceiling, and the tmux adapter supplies the identity
  for a cursor parked below the footer; Herdr reports it natively as `cmd`.
- Attribution: the fleet commit-msg strip removes the CommandCodeBot
  trailer.
- Docs, harness reference, verification record, portable regressions, and
  the FM_COMMANDCODE_SIGNALS_LIVE live guard.

* no-mistakes(review): Drop flash-fast effort pairs; correct identity-probe cost comments

* no-mistakes(ci): I fixed both Greptile findings the way you asked. Both new regression tests fail on the old code and pass now. The changes are not committed. **ci-1: Command Code on zellij, cmux and orca.** The rule that must hold is that a Command Code worker only runs on a backend that tells Firstmate the pane is Command Code. Without that, its idle placeholder never reads as an empty composer, so steering stalls. `bin/fm-spawn.sh` now refuses `--harness commandcode` unless the backend is tmux or herdr. The error reads: `commandcode is verified on the tmux and herdr backends only; backend=<b> cannot prove its composer empty. Select backend tmux or herdr.` - The check runs after both the harness and the backend are known, so it covers fresh spawns and `--relaunch`. - It runs before any pane, worktree, task record or busy state is created. - New test in `tests/fm-commandcode-harness.test.sh`: tries a scout spawn on each of zellij, cmux and orca (with a fake `orca` that reports ready). It checks for the refusal and that nothing was launched, no task record was written and busy state was not armed. It needs no real backend installed. - Documented in `docs/configuration.md`, the Command Code adapter reference and the `fm-spawn.sh` header. **ci-2: an old process signalling its replacement.** The rule is that the `turn-ended` notification may only be raised under the same generation check as the idle write. The mod used to touch the file itself after the writer returned, which left a gap for a relaunch to slip in. - `bin/fm-busy-event.sh apply` takes a new `--turn-ended` flag. It touches `state/<id>.turn-ended` while still holding the writer lock, after the generation check passes. A stale generation is refused with no touch, and the flag is rejected on any subcommand other than `apply`. - `bin/fm-commandcode-mod.ts` no longer touches files itself. On `run_end` it passes `--turn-ended` unless the turn was interrupted. - New test in `tests/fm-commandcode-harness.test.sh`: a fake writer accepts the idle write and then arms a replacement before the mod continues. It asserts no notification appears. - New test in `tests/fm-busy-state.test.sh`: the notification is raised for the current generation, not for a stale one, and not outside `apply`. **Checks run:** - Passing: `fm-commandcode-harness`, `fm-busy-state`, `fm-busy-adapter-wiring`, `fm-backend`, `fm-documentation-audiences`, and `bash -n` on the changed shell files. - `fm-bootstrap.test.sh` fails one case ("backend=herdr must fail closed on its own missing session CLI"). It fails the same way on an untouched copy of the branch, because herdr is installed at `/usr/bin/herdr` on this machine. - `bin/fm-lint.sh` could not run because ShellCheck 0.11.0 is not on PATH, so the changed shell files have not been linted. **Not changed:** Devin's hook does the same thing outside this PR: it runs `apply ... && touch` in `bin/fm-devin-config.sh`. That predates this PR and is not in the changed area, so I left it alone

* no-mistakes(ci): I fixed ci-sc2016. ShellCheck is not installed on this machine, so I could not confirm that the lint warning is gone. **The rule that was broken:** the repo lints with ShellCheck at its default severity, which also fails on info-level notes. Any single-quoted `$` that is meant to stay literal needs a scoped disable comment that says why. Only one place in the changed area needed this: the racing-writer `printf` in `tests/fm-commandcode-harness.test.sh`. Its format string writes `"$2" "$3"` on purpose, so the generated fake writer reads its own arguments when it runs. **The fix:** I added one line just above that `printf`: `# shellcheck disable=SC2016 # positional params expand in the generated writer.` The repo already does this the same way, for example in `tests/fm-afk-launch.test.sh` and `tests/fm-ask-user-authority.test.sh`. Nothing else changed, so the test behaves exactly as before. **Checks run:** - `bash -n tests/fm-commandcode-harness.test.sh` passes. - `bash tests/fm-commandcode-harness.test.sh` passes all six cases, including the busy-mod case with the racing writer. **Not run:** `bin/fm-lint.sh` stops with "ShellCheck not found" because ShellCheck 0.11.0 is not on PATH and there is no copy in the repo. I did not install it, since installs outside the worktree are off limits here. The upstream lint run will be the first ShellCheck pass on this change. The change is not committed

* no-mistakes(review): Hard-code Command Code ghost luma ceiling at 160

* no-mistakes(review): Test commandcode relaunch refusal off tmux/herdr before stop

* no-mistakes(document): Note Command Code fixed ghost luma ceiling in config docs

* fix: put a read cue at the head of a context re-emit (kunchenguid#7298)

Claude spills a hook output over 10,000 characters and shows only the first
2,000 plus a saved-file path. The re-emit prints captain.md and learnings.md
last, so they never reached the session. Print a short cue first that names
the saved file and the memory files, and document the cap.

Refs kunchenguid#6303

* fix(bin): retry transient contribution forge reads once before waking (kunchenguid#7302)

* fix: retry transient contribution reads once

* fix: classify contribution read errors safely

Address review findings for kunchenguid#7262 by parsing only gh status forms, recognizing real DNS errors, refusing GraphQL not-found retries, clearing per-URL diagnostics, and restoring exit-137 handling.

* fix: recognize bare gh HTTP errors

Complete kunchenguid#7262 review fixes by accepting bodyless gh status lines and keeping all GraphQL errors out of transient network classification.

* no-mistakes(review): Classify gh network errors by Go error tokens

* no-mistakes(document): Note why contribution 404 reads are never retried

* no-mistakes(review): Retry message-less GraphQL HTTP 5xx on closing read

* fix: retry transient contribution reads once

* fix: classify contribution read errors safely

Address review findings for kunchenguid#7262 by parsing only gh status forms, recognizing real DNS errors, refusing GraphQL not-found retries, clearing per-URL diagnostics, and restoring exit-137 handling.

* fix: recognize bare gh HTTP errors

Complete kunchenguid#7262 review fixes by accepting bodyless gh status lines and keeping all GraphQL errors out of transient network classification.

* no-mistakes(review): Classify gh network errors by Go error tokens

* no-mistakes(document): Note why contribution 404 reads are never retried

* no-mistakes(review): Retry message-less GraphQL HTTP 5xx on closing read

* fix(bin): let a backlog captain hold bound the watcher's wedge escalation (kunchenguid#7338)

* fix(bin): let a backlog captain hold bound the watcher's wedge escalation

A stuck worker whose task was held for the captain through
bin/fm-captain-hold.sh kept wedge-escalating every STALE_ESCALATE_SECS,
because wedge_wait_evidence only read the status line. It now also reads
the open backlog captain call (task_captain_call_open) and defers to the
existing captain-facing long recheck, silent while the away record exists.

* no-mistakes(review): Publish no wait age for backlog captain holds

* no-mistakes(review): Let an elapsed paused-until line fall through to backlog hold

* no-mistakes(document): Document backlog captain hold in wedge wait-evidence contract

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Ian Brown <[email protected]>
Co-authored-by: Stephen Haptonstahl <[email protected]>
Co-authored-by: Michal Zuber <[email protected]>
Co-authored-by: Andrew Li <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Steven G Woods <[email protected]>
Co-authored-by: Kostadin Pop-Kochev <[email protected]>
Co-authored-by: Konrad Heimel <[email protected]>
Co-authored-by: Tiago <[email protected]>
Co-authored-by: Sebastian <[email protected]>
Co-authored-by: ladwein <[email protected]>
Co-authored-by: Phu <[email protected]>
Co-authored-by: Pedro Müller <[email protected]>
Co-authored-by: pedromuller-del <[email protected]>
Co-authored-by: pback34 <[email protected]>
Co-authored-by: Tim Kleinschmidt <[email protected]>
Co-authored-by: Liam Sarsfield <[email protected]>
Co-authored-by: yairtech <[email protected]>
Co-authored-by: Valerius Mattfeld <[email protected]>
@pback34
pback34 deleted the fm/cmd-adapter branch October 16, 2026 22:03
witt3rd added a commit to witt3rd/firstmate that referenced this pull request Oct 21, 2026