Skip to content

fix: preserve literal ampersands in spawn and supervision rendering - #7906

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
WTF-Am-ID:fm/up-fm-7786
Oct 30, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
WTF-Am-ID:fm/up-fm-7786

Conversation

@WTF-Am-ID

@WTF-Am-ID WTF-Am-ID commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7786

Review was single-family (Codex) by the owner's temporary choice.

The no-mistakes Test step did not drive the Bash 5.2+ literal-path scenario or the additional raw supervision-output capture because execution guards refused those operations. The approved exception is retained in the pipeline evidence below. tests/fm-spawn-compact-adviser-disable.test.sh covers exact inbox and encoded-brief delivery for normal paths and paths containing ampersands, quotes and spaces. tests/fm-supervision-instructions.test.sh covers the corresponding rendered extension and config paths. Before submission, both focused suites passed on Bash 3.2.57 and Bash 5.2.37 at 1dd10d753fc8f34c1dbe22bda72494266c1f68bc; the new Bash 5.2 regressions failed before the fix.

Intent

ok same instructions i gave you before pick high value issues from scan, in all the repos you scanning and use codex only to close them

Context: this task is scan pick P2: upstream issue #7786 in kunchenguid/firstmate. Bash 5.2+ substitutes the matched placeholder for an ampersand inside a brief or home path. Triage contract class: restore. Scan notes for this pick:
Issue: #7786

Bash 5.2+ substitutes the matched placeholder for an ampersand inside a brief or home path.
The maintainer explicitly welcomes a standalone fix covering both spawn and supervision rendering.
Size S.
Contract class: restore.
Maintainer triage.

Evidence: No patsub_replacement normalization in bin/fm-spawn.sh. bin/fm-supervision-instructions.sh:167-175 still interpolates unquoted replacement variables.

Competing work: No exact issue reference or complete fix found. #3708 already repairs spawn as part of a larger writable-roots change, but does not change fm-supervision-instructions.sh. The issue's maintainer explicitly says that partial overlap does not cover the issue and invites the standalone correction.

Closure test: Using only fake launch tools, render and capture a launch under a path containing R&D and verify the exact brief/home bytes. Exercise the supervision renderer under the same path. Run stock /bin/bash 3.2 and an installed Bash 5.2+ with its default patsub_replacement enabled. Both scripts must retain literal ampersands, quotes and spaces. Extend an existing spawn fixture plus tests/fm-supervision-instructions.test.sh, with normal-path controls.
The owner approved fixing the scan's high-value picks upstream through PRs, written and reviewed by Codex only.

What Changed

  • Disable patsub_replacement in bin/fm-spawn.sh and bin/fm-supervision-instructions.sh so Bash 5.2+ preserves literal ampersands during template rendering.
  • Extend spawn and supervision fixtures with paths containing ampersands, quotes and spaces, alongside normal-path controls.

Risk Assessment

✅ Low: The bounded change restores literal template substitution in both scripts, with behavioral regression coverage and no substantiated correctness or scope issues.

Testing

Bash 3.2 spawn path cases and the supervision script passed. The combined run later stopped at an unrelated secondmate fixture’s refusal of a home inside the repository; the issue-specific spawn rerun passed with receiver receipts. Bash 5.2 checks and additional supervision-output capture were guard-blocked. No baseline execution or visual UI check ran. Scratch files were removed.

  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Under Bash 3.2, spawn with normal and R&D home paths containing quotes and spaces delivers the exact inbox path and encoded brief to a fake Codex receiver. ✅ pass live Exact inbox and brief received by fake Codex; Bash 3.2 focused test results
Under Bash 3.2, render supervision instructions with normal and special-character paths without corrupting literal paths or leaking placeholders. ✅ pass live Bash 3.2 focused test results
Under Bash 5.2+ with default patsub_replacement enabled, both renderers preserve ampersands, quotes and spaces, with normal-path controls. ⏸️ untested no The explicitly supplied Bash binary reported version 5.2.37. PreToolUse refused the command intended to inspect its default option and run the focused checks: 'BLOCKED: Indirect command execution not…
Evidence: Bash 3.2 focused test results

Source: Bash 3.2 focused test results

FM_TEST_BEGIN 2026-10-28T12:00:03Z tests/fm-spawn-compact-adviser-disable.test.sh family=backend-dispatch expected_gate_skip=none
ok - launch preserves literal ampersands, quotes and spaces in home and brief paths
ok - ship launch with no allowlist starts its agent with the compact-adviser switch on
ok - ship launch under an enabled allowlist keeps the compact-adviser switch through the cleared environment
ok - the launch command sets the switch on its own, whichever allowlist posture is in force
not ok - secondmate spawn with allowlist=absent should succeed: error: secondmate home cannot be inside the firstmate repo: ~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.EhuILu/secondmate-absent/secondmate-home: expected exit 0, got 1
FM_TEST_END 2026-10-28T12:01:01Z tests/fm-spawn-compact-adviser-disable.test.sh exit=1 duration_ms=57915 gate_skip=false
FM_TEST_BEGIN 2026-10-28T12:01:01Z tests/fm-supervision-instructions.test.sh family=pure-contract-unit expected_gate_skip=none
ok - snippets preserve literal ampersands, quotes and spaces in paths across primary harnesses
ok - renderer adds the supervision-host protocol on a claude home unless config/supervision-host-off opts it out, leaving the claude block intact
ok - renderer gives each non-Pi arm owner the host protocol in its own terms, and grok arms the host
ok - renderer prints exactly the selected harness block
ok - renderer falls back to unknown.md for unverified harness names
ok - renderer includes read-only, afk, and effective x-mode current-state stanzas
ok - renderer's away/quiet stanzas are mode-aware, default to away, and fall back safely on garbage input
ok - renderer repair-line mode is harness-aware and honors conditional state
ok - omp restart guidance names the fm launcher only when the home is not the checkout
ok - renderer preserves every harness ordinary-continuation and missing-cycle repair path
ok - pi-signed keeps its identity while sharing Pi's supervision protocol
ok - grok supervision is Claude-shaped background notify with passive Stop-hook backstop
ok - grok rendered command sources the effective x-mode config
ok - pi supervision snippet renders the effective extension path
FM_TEST_END 2026-10-28T12:01:06Z tests/fm-supervision-instructions.test.sh exit=0 duration_ms=4861 gate_skip=false
FM_TEST_SUMMARY total=2 failed=1 skipped_gate=0 duration_ms=63092
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=1 duration_ms=57915 failed=1
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=4861 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-spawn-compact-adviser-disable.test.sh duration_ms=57915
FM_TEST_SLOWEST rank=2 script=tests/fm-supervision-instructions.test.sh duration_ms=4861
Evidence: Exact inbox and brief received by fake Codex

Source: Exact inbox and brief received by fake Codex


CASE normal
~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-normal/home/state/path-normal-a1.inbox
⁣FIRSTMATE_OP: v1 launch-brief: # Current worker role contract
You are a crewmate: an autonomous worker agent managed by firstmate.
This section establishes your current identity before every project or task instruction below and supersedes any conflicting role identity in those instructions.
Do the assigned work yourself and report only to firstmate; do not adopt a firstmate or secondmate supervisor identity, delegate the task, run fleet supervision, or address the captain.
Your steering inbox is `~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-normal/home/state/path-normal-a1.inbox`; this exact path belongs to your current task even when it is outside the worktree or under the supervising firstmate home, so read and acknowledge its messages and do not reject it as another home's state.
Never inspect or change any other home's endpoint namespace; this authorization is limited to the exact task paths named by this brief.
When this task works on Firstmate itself, the repository root `AGENTS.md` (also imported by `CLAUDE.md`) is project content and the supervisor contract for the firstmate managing you: follow this brief instead of that supervisor contract.
Project instructions still govern the work wherever they do not conflict with this worker identity, including `CONTRIBUTING.md` and `firstmate-coding-guidelines` for Firstmate changes.
If the `firstmate-coding-guidelines` skill name does not resolve in this session, read `~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.agents/skills/firstmate-coding-guidelines/SKILL.md` instead.

# Task
## Captain's intent
brief for path-normal-a1

## Firstmate spec
Exercise the spawn behavior under test.

# Current no-mistakes intent contract
This section supersedes every earlier brief instruction about constructing `--intent`, but not later clarifications actually supplied by the captain.
Use everything under `## Captain intent authorized for --intent` through the end of this brief, including any nested subheadings but excluding that heading, plus any later words the captain actually supplied as `--intent`; never include Firstmate specification or other mixed Task content.
Preserve those words without adding speaker labels or direct address.
Firstmate-authored constraints, acceptance criteria, implementation details, decisions, and tradeoffs are specification, not captain intent.
The Definition of done's rule that `--intent` must be self-sufficient still governs the string you pass: resolve any report, decision, or PR the intent below refers to into its substance rather than passing the pointer.

## Captain intent authorized for --intent
brief for path-normal-a1

CASE literal
~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-literal/R&D "double" 'single' home/state/path-literal-a1.inbox
⁣FIRSTMATE_OP: v1 launch-brief: # Current worker role contract
You are a crewmate: an autonomous worker agent managed by firstmate.
This section establishes your current identity before every project or task instruction below and supersedes any conflicting role identity in those instructions.
Do the assigned work yourself and report only to firstmate; do not adopt a firstmate or secondmate supervisor identity, delegate the task, run fleet supervision, or address the captain.
Your steering inbox is `~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-literal/R&D "double" 'single' home/state/path-literal-a1.inbox`; this exact path belongs to your current task even when it is outside the worktree or under the supervising firstmate home, so read and acknowledge its messages and do not reject it as another home's state.
Never inspect or change any other home's endpoint namespace; this authorization is limited to the exact task paths named by this brief.
When this task works on Firstmate itself, the repository root `AGENTS.md` (also imported by `CLAUDE.md`) is project content and the supervisor contract for the firstmate managing you: follow this brief instead of that supervisor contract.
Project instructions still govern the work wherever they do not conflict with this worker identity, including `CONTRIBUTING.md` and `firstmate-coding-guidelines` for Firstmate changes.
If the `firstmate-coding-guidelines` skill name does not resolve in this session, read `~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.agents/skills/firstmate-coding-guidelines/SKILL.md` instead.

# Task
## Captain's intent
brief for path-literal-a1

## Firstmate spec
Exercise the spawn behavior under test.

# Current no-mistakes intent contract
This section supersedes every earlier brief instruction about constructing `--intent`, but not later clarifications actually supplied by the captain.
Use everything under `## Captain intent authorized for --intent` through the end of this brief, including any nested subheadings but excluding that heading, plus any later words the captain actually supplied as `--intent`; never include Firstmate specification or other mixed Task content.
Preserve those words without adding speaker labels or direct address.
Firstmate-authored constraints, acceptance criteria, implementation details, decisions, and tradeoffs are specification, not captain intent.
The Definition of done's rule that `--intent` must be self-sufficient still governs the string you pass: resolve any report, decision, or PR the intent below refers to into its substance rather than passing the pointer.

## Captain intent authorized for --intent
brief for path-literal-a1
Evidence: Generated launch containing literal special characters

Source: Generated launch containing literal special characters

export COMPACT_ADVISER_DISABLE=1; export FM_TASK_INBOX='~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-literal/R&D "double" '\''single'\'' home/state/path-literal-a1.inbox'; '~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/bin/fm-git-strip-ai-trailers.sh' env-file '~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-literal/R&D "double" '\''single'\'' home/state/path-literal-a1.git-hooks' '/tmp/fm-path-literal-a1+b8f392bf6ad1da9bb727eb4948d6ec9efbcccb97c6e5db89f020b8c72ccf7fce/git-config.s1793188944.12148.3508.sh' && . '/tmp/fm-path-literal-a1+b8f392bf6ad1da9bb727eb4948d6ec9efbcccb97c6e5db89f020b8c72ccf7fce/git-config.s1793188944.12148.3508.sh' || return 1 2>/dev/null || exit 1; env -u CURSOR_AGENT -u CURSOR_INVOKED_AS -u GEMINI_CLI codex --dangerously-bypass-approvals-and-sandbox --disable hooks -c "notify=[\"bash\",\"-c\",\"touch '~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-literal/R&D "double" '\''single'\'' home/state/path-literal-a1.turn-ended'\"]" "$('~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/bin/fm-operational-input.sh' encode launch-brief < '~/.no-mistakes-upstream-codex/worktrees/46c06fdd4673/01M615X9HEFP93TT47E557AFK8/.test-7786/tmp/fm-spawn-compact-adviser.bfJRVD/path-literal/R&D "double" '\''single'\'' home/data/path-literal-a1/launch-brief.md')"
Evidence: Repeatable spawn receipt driver

Source: Repeatable spawn receipt driver

#!/usr/bin/env bash
# tests/fm-spawn-compact-adviser-disable.test.sh - every agent this fleet
# launches must start with COMPACT_ADVISER_DISABLE=1 in its environment.
#
# The assertions never read bin/fm-spawn.sh's source. They drive the real spawn
# against a fake pane and a real isolated git worktree, then EXECUTE the launch
# command the pane actually received, under a synthetic pane environment, with
# the harness binary replaced by a probe that prints the environment it was
# started with. What the probe prints is what a real agent would have received.
#
# The remote second-mate route never reaches this path; its coverage lives in
# tests/fm-spawn-compact-adviser-disable-remote.test.sh.
set -u

# shellcheck source=tests/fixtures.sh
. "$PWD/tests/fixtures.sh"

CONTROL="$ROOT/bin/fm-control.sh"
TMP_ROOT=$(fm_test_tmproot fm-spawn-compact-adviser)

# A synthetic pane value the launch must override rather than inherit: the
# switch is a floor, so a pane that already carries the wrong value still has to
# start its agent with 1.
CONTRARY=0

# make_case <name> <harness> <id>...
# Echoes "<case-dir>|<home>|<project>|<worktree>|<fakebin>|<launch-log>|<pane-log>".
make_case() {
  local name=$1 harness=$2 case_dir home proj wt fakebin launchlog panelog id
  shift 2
  case_dir="$TMP_ROOT/$name"
  home="$case_dir/home"
  proj="$case_dir/project"
  wt="$case_dir/wt"
  launchlog="$case_dir/launch.log"
  panelog="$case_dir/pane.log"
  fakebin=$(fm_test_make_spawn_fakebin "$case_dir/fake")
  fm_test_spawn_home "$home" "$harness"
  fm_git_worktree "$proj" "$wt" "wt-$name"
  for id in "$@"; do
    fm_test_spawn_brief "$home" "$id"
  done
  printf '%s\n' "$case_dir|$home|$proj|$wt|$fakebin|$launchlog|$panelog"
}

read_case() {
  IFS='|' read -r CASE_DIR HOME_DIR PROJ_DIR WT_DIR FAKEBIN_DIR LAUNCH_LOG PANE_LOG <<EOF
$1
EOF
}

run_case_spawn() {
  : > "$LAUNCH_LOG"
  : > "$PANE_LOG"
  FM_FAKE_LAUNCH_LOG="$LAUNCH_LOG" FM_FAKE_PANE_LOG="$PANE_LOG" \
    fm_test_run_spawn "$HOME_DIR" "$WT_DIR" "$FAKEBIN_DIR" "$@"
}

# Replace the harness binary with a probe that reports the single environment
# fact under test, so executing the emitted launch answers "what would the agent
# have seen" rather than "what does the command text look like".
install_env_probe() {  # <fakebin> <harness> [variable]
  cat > "$1/$2" <<SH
#!/bin/sh
printf '%s\n' "\${${3:-COMPACT_ADVISER_DISABLE}-unset}"
SH
  chmod +x "$1/$2"
}

# Run the emitted launch command in a synthetic pane shell. The pane carries the
# CONTRARY value, so a launch that merely forwarded the ambient environment
# would be caught here rather than reported as a pass.
#   emitted_launch_env <fakebin> <launch-log> <pane-log>
emitted_launch_env() {
  local fakebin=$1 launchlog=$2 panelog=$3 launch preamble
  launch=$(cat "$launchlog")
  # The pane exports run before the launch command in the real pane shell, so
  # replay them here in the same order: the filtered launch environment retains
  # what the pane holds, and dropping them would test a pane that never existed.
  preamble=$(grep '^export ' "$panelog")
  env -i HOME="$TMP_ROOT/pane-home" PATH="$fakebin:$PATH" TERM=xterm \
    TMUX=synthetic-pane COMPACT_ADVISER_DISABLE="$CONTRARY" \
    /bin/sh -c "$preamble
$launch"
}

pane_export_lines() { grep -c '^export COMPACT_ADVISER_DISABLE=1$' "$1" || true; }

assert_pane_export_precedes_launch() {  # <pane-log> <label>
  local panelog=$1 label=$2
  [ "$(pane_export_lines "$panelog")" = 1 ] \
    || fail "$label: the pane shell should receive exactly one compact-adviser export, got $(pane_export_lines "$panelog")"
  # Ordering: the export must ride the same pre-launch site as GOTMPDIR, which
  # is what makes it set before the agent process starts.
  local gotmp switch
  gotmp=$(grep -n '^export GOTMPDIR=' "$panelog" | tail -1 | cut -d: -f1)
  switch=$(grep -n '^export COMPACT_ADVISER_DISABLE=1$' "$panelog" | tail -1 | cut -d: -f1)
  [ -n "$gotmp" ] && [ -n "$switch" ] \
    || fail "$label: the pane log is missing the pre-launch exports"
  [ "$switch" -gt "$gotmp" ] \
    || fail "$label: the compact-adviser export must ride the GOTMPDIR pre-launch site (gotmp=$gotmp switch=$switch)"
}

test_ship_allowlist_absent() {
  local rec out status seen
  rec=$(make_case ship-open codex ship-open-a1)
  read_case "$rec"
  out=$(run_case_spawn ship-open-a1 "$PROJ_DIR" --mode no-mistakes --yolo off)
  status=$?
  expect_code 0 "$status" "ship spawn without an allowlist should succeed: $out"
  assert_pane_export_precedes_launch "$PANE_LOG" "ship, allowlist absent"
  install_env_probe "$FAKEBIN_DIR" codex
  seen=$(emitted_launch_env "$FAKEBIN_DIR" "$LAUNCH_LOG" "$PANE_LOG") \
    || fail "ship, allowlist absent: the emitted launch failed to run"
  assert_equals 1 "$seen" \
    "a ship worker launched with the ambient environment must start with the compact adviser disabled"
  pass "ship launch with no allowlist starts its agent with the compact-adviser switch on"
}

test_ship_allowlist_enabled() {
  local rec out status seen launch
  rec=$(make_case ship-filtered codex ship-filtered-a1)
  read_case "$rec"
  # An empty file is the strictest opt-in: the launch keeps Firstmate's own
  # operational floor and nothing else, so it is where a floor either holds or
  # is lost.
  : > "$HOME_DIR/config/launch-env-allowlist"
  out=$(run_case_spawn ship-filtered-a1 "$PROJ_DIR" --mode no-mistakes --yolo off)
  status=$?
  expect_code 0 "$status" "ship spawn under an allowlist should succeed: $out"
  assert_pane_export_precedes_launch "$PANE_LOG" "ship, allowlist enabled"
  launch=$(cat "$LAUNCH_LOG")
  assert_contains "$launch" '/usr/bin/env -i' \
    "an enabled allowlist should launch under a cleared environment"
  install_env_probe "$FAKEBIN_DIR" codex
  seen=$(emitted_launch_env "$FAKEBIN_DIR" "$LAUNCH_LOG" "$PANE_LOG") \
    || fail "ship, allowlist enabled: the emitted launch failed to run"
  assert_equals 1 "$seen" \
    "a ship worker launched under the cleared allowlisted environment must still start with the compact adviser disabled"
  pass "ship launch under an enabled allowlist keeps the compact-adviser switch through the cleared environment"
}

# The floor must not depend on the pane export having landed: a pane whose
# export was lost still has to launch its agent with the switch on. Replaying
# the launch alone, with a contrary ambient value, is that case.
test_launch_command_carries_the_switch_without_the_pane_export() {
  local setting rec out status seen launch
  for setting in absent enabled; do
    rec=$(make_case "ship-nopane-$setting" codex "ship-nopane-$setting-a1")
    read_case "$rec"
    [ "$setting" = absent ] || : > "$HOME_DIR/config/launch-env-allowlist"
    out=$(run_case_spawn "ship-nopane-$setting-a1" "$PROJ_DIR" --mode no-mistakes --yolo off)
    status=$?
    expect_code 0 "$status" "allowlist=$setting spawn should succeed: $out"
    install_env_probe "$FAKEBIN_DIR" codex
    launch=$(cat "$LAUNCH_LOG")
    seen=$(env -i HOME="$TMP_ROOT/pane-home" PATH="$FAKEBIN_DIR:$PATH" TERM=xterm \
      TMUX=synthetic-pane COMPACT_ADVISER_DISABLE="$CONTRARY" \
      /bin/sh -c "$launch") \
      || fail "allowlist=$setting: the emitted launch failed to run without the pane exports"
    assert_equals 1 "$seen" \
      "allowlist=$setting: the launch command alone must set the compact-adviser switch, overriding a contrary pane value"
  done
  pass "the launch command sets the switch on its own, whichever allowlist posture is in force"
}

test_secondmate_launch() {
  local setting rec sm out status seen
  for setting in absent enabled; do
    rec=$(make_case "secondmate-$setting" codex "sm-$setting")
    read_case "$rec"
    [ "$setting" = absent ] || : > "$HOME_DIR/config/launch-env-allowlist"
    sm="$CASE_DIR/secondmate-home"
    mkdir -p "$sm/bin" "$sm/data"
    printf '# Firstmate\n' > "$sm/AGENTS.md"
    printf '%s\n' "sm-$setting" > "$sm/.fm-secondmate-home"
    printf 'charter for sm-%s\n' "$setting" > "$sm/data/charter.md"
    printf '%s\n' 'projects/' 'state/' 'data/' 'config/' '.no-mistakes/' > "$sm/.gitignore"
    git -C "$sm" init -q -b main
    out=$(run_case_spawn "sm-$setting" "$sm" --secondmate)
    status=

... [1803 bytes truncated] ...

robe "$FAKEBIN_DIR" codex FM_TASK_INBOX
    seen=$(emitted_launch_env "$FAKEBIN_DIR" "$LAUNCH_LOG" "$PANE_LOG") \
      || fail "$kind: the emitted launch failed to run"
    want="$(cd "$HOME_DIR/state" && pwd -P)/$id.inbox"
    assert_equals "$want" "$seen" \
      "a $kind agent must start with FM_TASK_INBOX set to its absolute steering inbox"
  done
  pass "ship and secondmate launches export their absolute steering inbox as FM_TASK_INBOX"
}

# --- relaunch ---------------------------------------------------------------
#
# bin/fm-control.sh relaunch stops the agent and rebuilds the launch through
# bin/fm-spawn.sh --relaunch, so this drives the operator-facing verb rather
# than the rebuild alone. The stub below models just enough pane lifecycle for
# that transaction: the harness exit command leaves a bare shell behind, and the
# launch literal starts the harness again.
make_relaunch_stub() {  # <case-dir>
  local fb="$1/fakebin"
  mkdir -p "$fb"
  cat > "$fb/tmux" <<'SH'
#!/usr/bin/env bash
set -u
D=$FM_FAKE_DIR
case "${1:-}" in
  send-keys)
    shift
    literal=0
    while [ $# -gt 0 ]; do
      case "$1" in
        -t) shift 2 ;;
        -l) literal=1; shift ;;
        *) break ;;
      esac
    done
    payload=${1:-}
    if [ "$literal" = 1 ]; then
      case "$payload" in
        ". '"*"'")
          staged=${payload#". '"}
          staged=${staged%"'"}
          [ ! -f "$staged" ] || payload=$(cat "$staged")
          ;;
      esac
      printf '%s\n' "$payload" >> "$D/literal"
      case "$payload" in
        /exit|/quit) printf 'zsh' > "$D/command" ;;
        *'encode launch-brief'*) printf 'codex' > "$D/command" ;;
      esac
    else
      printf '%s\n' "$payload" >> "$D/keys"
    fi
    exit 0 ;;
  display-message)
    for a in "$@"; do
      case "$a" in
        *cursor_y*) printf '1\n'; exit 0 ;;
        *pane_current_command*) cat "$D/command"; printf '\n'; exit 0 ;;
        *pane_current_path*) cat "$D/cwd"; printf '\n'; exit 0 ;;
      esac
    done
    printf 'fakepane\n'; exit 0 ;;
  capture-pane) printf '╭────╮\n│    │\n╰────╯\n'; exit 0 ;;
  list-windows) [ -f "$D/windows" ] && cat "$D/windows"; exit 0 ;;
esac
exit 0
SH
  chmod +x "$fb/tmux"
  cat > "$fb/sleep" <<'SH'
#!/usr/bin/env bash
exit 0
SH
  chmod +x "$fb/sleep"
}

test_relaunch_rebuilds_the_switch() {
  local setting dir home proj wt id out status seen launch preamble
  for setting in absent enabled; do
    id="relaunch-$setting-a1"
    dir="$TMP_ROOT/relaunch-$setting"
    home="$dir/home"
    proj="$dir/proj"
    wt="$dir/wt"
    mkdir -p "$home/state" "$home/data" "$home/config" "$home/projects" "$dir/fake"
    touch "$home/state/.last-watcher-beat"
    [ "$setting" = absent ] || : > "$home/config/launch-env-allowlist"
    make_relaunch_stub "$dir"
    fm_git_worktree "$proj" "$wt" "wt-relaunch-$setting"
    fm_test_spawn_brief "$home" "$id"
    : > "$dir/fake/literal"
    : > "$dir/fake/keys"
    printf 'codex' > "$dir/fake/command"
    printf '%s\n' "fm-$id" > "$dir/fake/windows"
    printf '%s' "$wt" > "$dir/fake/cwd"
    {
      echo "window=fmses:fm-$id"
      echo "endpoint_task_id=$id"
      echo "worktree=$wt"
      echo "project=$proj"
      echo "harness=codex"
      echo "kind=ship"
      echo "mode=no-mistakes"
      echo "yolo=off"
      echo "tasktmp=$dir/tasktmp"
      echo "model=default"
      echo "effort=default"
    } > "$home/state/$id.meta"

    mkdir -p "$dir/user-home"
    out=$(env PATH="$dir/fakebin:$PATH" FM_HOME="$home" FM_FAKE_DIR="$dir/fake" \
      HOME="$dir/user-home" CLAUDE_CONFIG_DIR='' FM_SPAWN_NO_GUARD=1 \
      FM_CONTROL_POLL=0.01 FM_CONTROL_EXIT_WAIT=0.05 FM_CONTROL_LAUNCH_WAIT=0.05 \
      "$CONTROL" "$id" relaunch --note 'replacement continues the same task' 2>&1)
    status=$?
    expect_code 0 "$status" "relaunch with allowlist=$setting should succeed: $out"

    grep -qx 'export COMPACT_ADVISER_DISABLE=1' "$dir/fake/keys" \
      || fail "relaunch with allowlist=$setting did not re-export the compact-adviser switch into the pane"
    launch=$(grep 'encode launch-brief' "$dir/fake/literal" | tail -1)
    [ -n "$launch" ] || fail "relaunch with allowlist=$setting sent no replacement launch command"
    install_env_probe "$dir/fakebin" codex
    preamble=$(grep '^export ' "$dir/fake/keys")
    seen=$(env -i HOME="$dir/user-home" PATH="$dir/fakebin:$PATH" TERM=xterm \
      TMUX=synthetic-pane COMPACT_ADVISER_DISABLE="$CONTRARY" \
      /bin/sh -c "$preamble
$launch") \
      || fail "relaunch with allowlist=$setting: the replacement launch failed to run"
    assert_equals 1 "$seen" \
      "a relaunched agent with allowlist=$setting must start with the compact adviser disabled, exactly as a fresh spawn does"
  done
  pass "relaunch rebuilds the compact-adviser switch for the replacement agent in both allowlist postures"
}

# A command-prefix assignment only covers the first simple command. A raw
# compound launch such as `cd <dir> && <probe>` must still start the probe with
# the switch on, so this drives that escape hatch and executes the pane's
# launch under a contrary ambient value.
test_raw_compound_launch_command_carries_the_switch() {
  local rec out status seen launch probe_dir
  rec=$(make_case raw-compound claude raw-compound-a1)
  read_case "$rec"
  printf '%s\n' '{"rules":[{"when":"current events","use":{"harness":"grok","model":"grok-4","effort":"high"}}],"default":{"harness":"codex","model":"gpt-5","effort":"medium"}}' \
    > "$HOME_DIR/config/crew-dispatch.json"

  probe_dir="$CASE_DIR/agent-cwd"
  mkdir -p "$probe_dir"
  cat > "$probe_dir/probe" <<'SH'
#!/bin/sh
printf '%s\n' "${COMPACT_ADVISER_DISABLE-unset}"
SH
  chmod +x "$probe_dir/probe"

  out=$(run_case_spawn raw-compound-a1 "$PROJ_DIR" --mode no-mistakes --yolo off \
    "cd $probe_dir && ./probe")
  status=$?
  expect_code 0 "$status" "raw compound launch spawn should succeed: $out"
  launch=$(cat "$LAUNCH_LOG")
  [ -n "$launch" ] || fail "raw compound launch spawn sent no launch command"
  seen=$(env -i HOME="$TMP_ROOT/pane-home" PATH="$FAKEBIN_DIR:$PATH" TERM=xterm \
    TMUX=synthetic-pane COMPACT_ADVISER_DISABLE="$CONTRARY" \
    /bin/sh -c "$launch") \
    || fail "raw compound launch: the emitted launch failed to run"
  assert_equals 1 "$seen" \
    "a raw compound launch must start its agent with the compact adviser disabled, even after cd"
  pass "a compound raw launch-command still starts its agent with the compact-adviser switch on"
}

test_launch_preserves_literal_home_and_brief_paths() {
  local name rec id out status seen want brief
  for name in normal literal; do
    id="path-$name-a1"
    rec=$(make_case "path-$name" codex "$id")
    read_case "$rec"
    if [ "$name" = literal ]; then
      mv "$HOME_DIR" "$CASE_DIR/R&D \"double\" 'single' home"
      HOME_DIR="$CASE_DIR/R&D \"double\" 'single' home"
    fi
    out=$(run_case_spawn "$id" "$PROJ_DIR" --mode no-mistakes --yolo off)
    status=$?
    expect_code 0 "$status" "$name path spawn should succeed: $out"
    # Capture the environment and final prompt received by the fake agent.
    cat > "$FAKEBIN_DIR/codex" <<'SH'
#!/bin/sh
{
printf '%s\n' "$FM_TASK_INBOX"
for arg do :; done
printf '%s\n' "$arg"
} | tee -a '~/.no-mistakes-upstream-codex/evidence/01M615X9HEFP93TT47E557AFK8/spawn32-received.txt' 
SH
    chmod +x "$FAKEBIN_DIR/codex"
    printf '\nCASE %s\n' "$name" >> '~/.no-mistakes-upstream-codex/evidence/01M615X9HEFP93TT47E557AFK8/spawn32-received.txt'
    cp "$LAUNCH_LOG" '~/.no-mistakes-upstream-codex/evidence/01M615X9HEFP93TT47E557AFK8'/spawn32-"$name"-launch.txt
    seen=$(emitted_launch_env "$FAKEBIN_DIR" "$LAUNCH_LOG" "$PANE_LOG") \
      || fail "$name path: the emitted launch failed to run"
    brief=$("$ROOT/bin/fm-operational-input.sh" encode launch-brief < "$HOME_DIR/data/$id/launch-brief.md")
    want="$(cd "$HOME_DIR/state" && pwd -P)/$id.inbox
$brief"
    assert_equals "$want" "$seen" "$name path: launch changed the home or brief bytes"
  done
  pass "launch preserves literal ampersands, quotes and spaces in home and brief paths"
}

test_launch_preserves_literal_home_and_brief_paths
Evidence: Execution guard refusals and fixture limitation

Source: Execution guard refusals and fixture limitation

Bash 5.2.37 is available at the explicitly supplied /tmp/upfm7786.oxSHob/bash-bin/bash.
Its attempted focused-test command was refused before execution by the PreToolUse hook:
BLOCKED: Indirect command execution not allowed.
Command used env isolation, the supplied Bash 5.2 with -c to record its default patsub_replacement and invoke the two focused scripts.
The refused operation was stopped and was not retried through another command or runtime.

Bash 3.2 full focused selection: spawn literal-path regression and normal controls passed, supervision script passed.
The unrelated secondmate case refused its synthetic home inside the source repository because TMPDIR was deliberately inside the worktree. No real secondmate or fleet session was created.

A separate Bash 3.2 supervision-output capture via Python subprocess.run was also refused by PreToolUse: BLOCKED: Indirect command execution not allowed. It was stopped without retry. The completed existing supervision test is retained as evidence, but this additional raw-output capture did not run.
- Outcome: ⚠️ 1 warning across 1 run (5m32s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (2 of 3 scenarios were driven live against the product); untested: Under Bash 5.2+ with default patsub_replacement enabled, both renderers preserve ampersands, quotes and spaces, with normal-path controls.
  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Under Bash 3.2, spawn with normal and R&D home paths containing quotes and spaces delivers the exact inbox path and encoded brief to a fake Codex receiver. ✅ pass live Exact inbox and brief received by fake Codex; Bash 3.2 focused test results
Under Bash 3.2, render supervision instructions with normal and special-character paths without corrupting literal paths or leaking placeholders. ✅ pass live Bash 3.2 focused test results
Under Bash 5.2+ with default patsub_replacement enabled, both renderers preserve ampersands, quotes and spaces, with normal-path controls. ⏸️ untested no The explicitly supplied Bash binary reported version 5.2.37. PreToolUse refused the command intended to inspect its default option and run the focused checks: 'BLOCKED: Indirect command execution not…
  • /bin/bash --version and /tmp/upfm7786.oxSHob/bash-bin/bash --version
  • bin/fm-test-run.sh tests/fm-spawn-compact-adviser-disable.test.sh tests/fm-supervision-instructions.test.sh under Bash 3.2 with isolated FM_HOME and worktree-local TMPDIR
  • /bin/bash .test-7786/spawn-receipt.sh selecting the new spawn cases and capturing generated launches and fake-receiver bytes
  • Attempted Bash 5.2 focused checks and separate supervision-output capture; both refused by PreToolUse
  • Removed owned test scratch files and verified the candidate remained unchanged at 1dd10d753fc8f34c1dbe22bda72494266c1f68bc
⚠️ **Document** - 1 warning
  • ⚠️ Documentation review remains incomplete: the command guard rejected the targeted source/documentation inspection as “Piping into shell not allowed.” Stopped dependent work without bypassing the guard. No files changed.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Reviews (1) · Last reviewed commit: "fix: preserve literal ampersands in spaw..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @WTF-Am-ID. This is a nice small fix.

What I checked (tip 1dd10d75 vs main): both scripts now run shopt -u patsub_replacement right after set -eu. Neither script is sourced by anything else, so the setting stays inside them. No existing ${var//pat/rep} in either script relies on & meaning "the match". The new spawn and supervision fixtures cover R&D/quote/space homes with normal-path controls. CI is 21/21 green, the PR is CLEAN, and the NM attestation binds the head.

Contract-class: restore. Templated paths are supposed to render literally, and that's how they behave on Bash 3.2. Bash 5.2's default broke it, and nothing new runs.

One ask before merge: the live table leaves the scenario this PR exists for, Bash 5.2+ with patsub_replacement on, as untested (2/3, inconclusive). Could you post a short live transcript from Bash 5.2+ showing a spawn under an R&D home that delivers the exact inbox path and brief, and the supervision renderer output under the same path? Re-raising through git push no-mistakes with that scenario driven works too. Once it's in, this is ready to merge.

FYI, older #3708 adds the same shopt to fm-spawn.sh as part of a larger writable-roots feature and textually conflicts with this one. They don't compete; I'm just noting it.

Waiting on you for the Bash 5.2 live evidence.

@WTF-Am-ID

Copy link
Copy Markdown
Contributor Author

I ran the missing scenario on unchanged head 1dd10d753fc8f34c1dbe22bda72494266c1f68bc using real Bash 5.2.37 and installed codex-cli 0.165.0.
The disposable home was $LAB/R&D "double" home, with a product-marked lab home, private tmux server, and private treehouse pool.

$ bash52 -O patsub_replacement shell-option.txt
BASH_VERSION=5.2.37(1)-release
patsub_replacement  on

$ FM_HOME="$LAB/R&D \"double\" home" bash52 -O patsub_replacement bin/fm-spawn.sh \
    a11-bash52-probe "$LAB/project" --scout --harness codex \
    --model gpt-6.1-sol --effort low --backend tmux
spawned a11-bash52-probe harness=codex kind=scout window=firstmate:fm-a11-bash52-probe worktree=<private lab pool>/project
exit=0

# Real worker command and exact output, with only the temporary prefix shortened:
$ printenv FM_TASK_INBOX
$LAB/R&D "double" home/state/a11-bash52-probe.inbox

# Codex's recorded initial user message compared with the product encoder output:
received encoded brief == expected encoded brief: true
12101 characters matched in full
worker read nonce: A11_LITERAL_R&D_7906_20261029
worker launch-brief SHA256: 823ce08aabc4106e12c2f69157aa2492ab8adcc4e4e840d090064467dad53ff1
launcher launch-brief SHA256: 823ce08aabc4106e12c2f69157aa2492ab8adcc4e4e840d090064467dad53ff1

$ FM_HOME="$LAB/R&D \"double\" home" bash52 -O patsub_replacement \
    bin/fm-supervision-instructions.sh --harness codex --x-mode 1
- X mode: active; source $LAB/R&D "double" home/config/x-mode.env before launching any watcher process so the 30s cadence is inherited.
2. Source `$LAB/R&D "double" home/config/x-mode.env` first when Relay is active.
exit=0

$ bash52 -O patsub_replacement bin/fm-test-run.sh \
    tests/fm-spawn-compact-adviser-disable.test.sh \
    tests/fm-supervision-instructions.test.sh
ok - launch preserves literal ampersands, quotes and spaces in home and brief paths
ok - snippets preserve literal ampersands, quotes and spaces in paths across primary harnesses
FM_TEST_SUMMARY total=2 failed=0 skipped_gate=0 duration_ms=49879
exit=0

The option is enabled on interpreter entry, and each product script disables it internally as intended.
The live spawn used the real Codex executable, with no fake harness or fake tmux.
The two existing focused suites provide the normal-path controls and additional single-quote coverage.
These direct test invocations passed the supervising command guards.
The worker used Firstmate's unchanged stock Codex launch template.

No source changes or new pipeline run were needed.
The original no-mistakes Test exception remains historical evidence.
Current checks are 21/21 passing, including Greptile Review and no-mistakes compliance, on this same head.

@kunchenguid
kunchenguid merged commit b83dc59 into kunchenguid:main Oct 30, 2026
22 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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

The Bash 5.2 transcript (patsub_replacement on, real Codex spawn under an R&D "double" home, exact inbox path and brief hash match, supervision snippet literal) was exactly the missing scenario. The full suite had already passed on this head, and it was still clean against main.

trillium added a commit to trillium/firstmate that referenced this pull request Oct 30, 2026
…m commits on the branch (e.g. kunchenguid#7906, kunchenguid#7969, kunchenguid#7939) that don't fit this repo's base c12c102. The base's `fm-spawn.sh` already requires a backlog item to record its repo, and the upstream tests don't set one. That caused the failures across spawn, hooks and project capacity, plus lint and Full suite. I reset the working tree to c12c102 and re-applied only the herdr diff, so the staged change is now just `bin/backends/herdr.sh`, `docs/herdr-backend.md` and `tests/fm-backend-herdr.test.sh`. `fm-backend-herdr` and `fm-ci-workflow` pass locally. `fm-project-capacity` still fails on the base too, so it is not caused by this PR. I did not re-run the other failing shards or the lint jobs locally. Nothing is committed or pushed; the pipeline must commit this tree and push, because the branch history still contains the upstream commits
kesslerio pushed a commit to kesslerio/firstmate that referenced this pull request Oct 31, 2026
nathanjgaul-agile added a commit to nathanjgaul-agile/firstmate that referenced this pull request Nov 2, 2026
* fix(bin): keep failed or non-schema remote reply reads out of captures (#7874)

* Keep malformed remote reply captures from wedging

* no-mistakes(document): Fix garbled remote reply source failure comment

* no-mistakes(document): Document remote reply failure handling

---------

Co-authored-by: Pitch Perfekt Collective <[email protected]>

* feat(bin): add per-project pr=manual registry token for worker-written PR text (#7937)

* feat(bin): per-project pr=manual registry token for hand-written PR text

A no-mistakes ship on a project where an outside maintainer reviews the PR let
the pipeline's pr step rewrite the hand-written title and body on every
validated push. The registry now records pr=manual, resolved by
fm-project-mode.sh --pr and carried by fm-brief.sh --pr, fm-spawn.sh and
fm-promote.sh like forge=. The generated brief skips pr and ci, and the worker
writes and publishes the PR text itself.

* no-mistakes(review): Drop pr_text key; fix manual-PR checks wait and base

* no-mistakes(review): Remove dead PR_TEXT and timeout example

* no-mistakes(document): Fix README pr=manual sentence grammar

* test(bin): restore the displaced placeholder comment and rename the spawn agreement test

The comment for the leftover-placeholder test sat above the new pr=manual tests.
The spawn test said it recorded the PR text, but it only checks that a launch happens.

* fix: refuse teardown when Git hides untracked files (#7909)

* fix(teardown): detect untracked work regardless of Git status config

* test(watcher): avoid blocking FIFO contention handshakes

* no-mistakes(document): Document hidden-untracked teardown safety

---------

Co-authored-by: Kun Chen <[email protected]>

* fix(bin): keep newest run attribution in crew-state (#5954)

* fix: prefer current run over stale overview row

* fix: preserve newest run precedence over stale status

* no-mistakes(document): Document live-run precedence in crew-state attribution

* fix: use ledger order for same-minute run precedence

* test: cover both overview orders for same-minute run attribution

Document and pin newer-first (recorded AXI) and historical-first overview
orders. Same-minute ledger timestamps use row order as the tie-break so an
older live bare status cannot hide a newer completed run.

* no-mistakes(review): Treat failed as overridable terminal overview status

* no-mistakes(review): Fix equal-head live run precedence with identity ordering

* no-mistakes(document): Updated run identity ordering documentation

* no-mistakes(lint): Fix ShellCheck export warning

* no-mistakes(review): Prove same-head ordering or report unknown

* no-mistakes(review): Guard failed selected-run reads and drop dead same-head ordering

* no-mistakes(ci): I fixed both Greptile findings (ci-1, ci-2) in bin/fm-crew-state.sh. The change is in the working tree. I did not commit it, push it, or reply to the Greptile threads, because those steps belong to the outer pipeline. ci-1. Invariant: a live run from bare `axi status` may replace a terminal overview selection only when it is proven newer than every other run on the same branch. Previously the code compared it only against the selected run. Now crew-state reads each other candidate with `axi status --run <id>` and compares the live run against each one: - If another candidate is also live, it reports `unknown`, "competing live runs". This keeps the competing-live-runs check. - If two runs share a head and a ULID timestamp, it reports `unknown`, "same-head run ordering unverified", as before. - It promotes the live run only when it is proven newer than all other candidates. - If the live run is newer than the selected run but not proven newer than some other candidate, it reports `unknown`, "run ordering unverified", and names every run id. This means neither the stale selected run nor the live run can hide a newer failed run. This branch is the one judgement call: without it, the stale "done" row A would still hide C's failure. - In all other cases the overview's selection stands. The lib helper is now a pairwise compare called `fm_nm_run_is_newer_than` (it was `fm_nm_run_is_newer_than_selected`). The selected run's detail from the loop is reused when the read succeeded, as in the round-1 fix. I updated the sentence in docs/architecture.md to match. ci-2. Invariant: the `no-mistakes runs` ledger is read only to order runs with different heads. It is now fetched lazily, at most once, and only when a candidate's head differs from the live run's head. Same-head ULID comparisons never call it. Regression test: `test_live_run_newer_than_selection_does_not_hide_newer_failed_run` covers A (stale completed, listed first), C (newer failed) and B (live, created between them). All three share one head and use ULID ids. It expects `state: unknown`, C's id in the output, and no `state: working`. Before the fix it fails: with the fixed code stashed it printed `state: working ... run: 01M1...` (run B). On the original base 3fbace9f the overview would select A, so the output would be `done`, which also fails the `unknown` check. I did not run that base case. Verification: `bash tests/fm-crew-state.test.sh` passes in full ("all fm-crew-state tests passed", the new test included). `shellcheck` on the three changed shell files reports only the existing info-level SC1091 "not following sourced file" notes. No end-to-end run against a live no-mistakes daemon was possible here. I checked the change with the crew-state test harness and its fake `no-mistakes` CLI

---------

Co-authored-by: mehulbhagwani <[email protected]>
Co-authored-by: Pitch Perfekt Collective <[email protected]>

* chore(ci): run the full suite on outside pull requests only after the full-ci label

Outside pull requests run only the coverage guard and repo invariants until the full-ci label is added; lint and every test lane wait.

A new Full suite check fails naming the full-ci label until it is added, and fails whenever a lane fails or is cancelled.

The label starts the full suite, and later pushes run it again; main pushes, own branches and write-access authors run everything as before.

Other labels run no job at all: their skipped checks take a 'Not run for label - ' prefix, so they cannot hide an earlier failure or a later pass.

Close main pushes keep only the newest run; CONTRIBUTING.md explains the label, and the full-ci label now exists.

* feat(bin): add opt-in systemone and openai decision providers to dispatch resolution (#7664)

* feat(bin): add opt-in systemone and openai providers to typed dispatch resolution

Extend the FM_DISPATCH_PROVIDER/FM_DISPATCH_MODEL seam with a generic
systemone provider (any System One-compatible host at FM_DISPATCH_BASE_URL,
optional FM_DISPATCH_API_KEY) and an openai provider that maps the Choice
request to OpenAI's Decisions API and its answer back. No provider set keeps
the original off line; the never-send check runs on the endpoint and the final
per-provider body. Live provider captures are recorded as pending.

Refs #7643, builds on #7149.

* docs(verification): record the live OpenAI Decisions capture for dispatch resolution

Add a dated 2026-10-23 section for the openai provider: 25 hand-labeled
synthetic briefs against gpt-6-luna, outcome and latency tables, the usage
and header fields actually returned, a calibration note, and one verbatim
request and response pair. The systemone live check stays pending.

Refs #7643.

* docs(verification): record the live Clef capture for the systemone provider

Replace the pending systemone section with a dated 2026-10-23 run against
Cloudflare Workers AI's @cf/cloudflare/clef, reached through a local
test-only relay because Workers AI serves System One at /ai/run/<model> in
a {result, success} envelope. Adds the outcome and latency tables, a
calibration note compared with the gpt-6-luna run, and one verbatim request
and envelope pair. A direct Workers AI option stays out of scope.

Refs #7643.

* feat(bin): promote agy to a full primary and secondmate harness (#7941)

* feat(agy): promote Antigravity CLI to full primary and secondmate harness

Add tracked .agents/hooks.json, bin/fm-sessionstart-agy.sh, bin/fm-turnend-guard-agy.sh, PreToolUse --agy seatbelt flags, session-lock agy ancestry, autoarm supervision model, and --secondmate agy workspace trust pre-registration and spawn support.

* no-mistakes(review): Fix agy Stop-hook park, hooks.json shape, and live coverage

* no-mistakes(review): Unbound agy Stop park, raise ceiling, prove live deny

* no-mistakes(review): Correct agy verification doc park-bound wording

* no-mistakes(document): Document agy as verified primary and secondmate harness

* no-mistakes(ci): I fixed all three selected findings, and every check I ran passed, including the live agy end-to-end run. **ci-1 (`tests/fm-agy-primary-live-e2e.test.sh`):** The invariant is that the live Stop-hook test passes only if a real watcher starts and its wake reaches a follow-up turn. The old test passed as soon as `.agy-park-owner` existed. I replaced the Stop-hook park block with the one the user specified. It waits until both `.agy-park-owner` and `.last-watcher-beat` exist, wakes the watcher with a `done:` status line, and asserts that the park owner was recorded, the watcher started, and `DONE` appears in the agy output. **ci-2 (agy away daemon):** The invariant is that `/afk` must not launch a separate away daemon on any primary whose home runs the supervision host. The agy Stop-hook guard already runs the host when it is enabled, but `fm_afk_launch_host_primary` left agy out. I added `agy` there, which is the one shared check all three callers use. I also added agy to: - the header comment in `bin/fm-afk-launch.sh`; - the three harness loops and the pass message in `tests/fm-afk-launch.test.sh`; - the primary lists and counts in `docs/supervision-host.md`, the matching lines in its engine-selection section, and a new Antigravity (`agy`) row in its Arm owners table; - the header comment in `bin/fm-supervision-instructions.sh`. **user-1 (`.agents/hooks.json`):** The invariant is that each hook command stays one script under Windows `cmd /c` and exits 0 when `sh` is missing. All 5 commands now use `sh -c "..." || cd .`. This does not change behaviour on Linux or macOS, because the `--agy` hooks report deny or continue as JSON on stdout and exit 0. The file keeps its live-verified `{"firstmate":{...}}` shape, matchers and 28800s Stop timeout. **Verification:** - `tests/fm-agy-primary.test.sh` passes, including running the SessionStart hook command from both `.agents/` and the repo root. - `tests/fm-afk-launch.test.sh` has no failures, and the new agy check passes. Its rex end-to-end cases were skipped because the rex CLI is not installed. - `tests/fm-supervision-instructions.test.sh` has no failures. - `bin/fm-lint.sh` and `bin/fm-doc-audience-check.sh` pass. - `FM_AGY_PRIMARY_LIVE=1 tests/fm-agy-primary-live-e2e.test.sh` printed all four `ok` lines and no failures, including "Stop hook parks on a real watcher and delivers its wake to a follow-up turn". The output went through `tail`, so the exit code shown is `tail`'s, not the test script's

* feat(bin): add shared_quota opt-out from quota-based dispatch ranking (#7894)

* feat(dispatch): add shared_quota home opt-out from quota-based ranking

A home whose Claude and other provider usage draws on one combined AI
budget has no meaningful per-provider quota rows, so spendPriority
ranking and runway gates pick the wrong candidate. An optional
top-level "shared_quota": true in config/crew-dispatch.json now opts
the home out: the typed resolver makes no quota-axi call, applies no
quota floor or runway gate, ranks nothing by spendPriority, and
resolves the matched rule's use profiles in declared order, printing
every candidate line with quota ranking off by home declaration.
Firstmate's quota-array-dispatch intake honors the same declaration.
Without the setting, behavior is unchanged. Non-boolean values are
actionable configuration errors in both the resolver and bootstrap.

* test(dispatch): cover shared-quota bypass of unmet rule and profile floors

The shared_quota opt-out test picked a rule with no quota floor, so the
separate rule-floor and profile-floor bypass paths stayed untested.
Two cases now run against the same fixture: a rule whose model:fable
floor (20%) exceeds the snapshot's 15%, and a profile whose all_models
floor (50%) exceeds codex's 31%, each asserting the declared-order pick
still wins with no quota-axi invocation.

* no-mistakes(review): Narrow shared-quota skill opt-out to quota-only gates

* no-mistakes(review): Document preferred_provider under shared_quota opt-out and test it

* no-mistakes(document): Document shared_quota in schema example and verification inventory

* fix(bin): distinguish recycled reaper PIDs in tombstone cleanup (#7958)

* fix(bin): distinguish recycled reaper PIDs in tombstone cleanup

* no-mistakes(ci): ci-2 fixed in tests/fm-watcher-lock.test.sh (test_lock_tombstone_tracks_reaper_start_time). Invariant: no fixture child may outlive a SIGKILLed runner without a bound. (1) The paused reaper's wait loop now also stops when FM_TEST_SUITE_PID is no longer alive or when SECONDS reaches FM_TEST_STUB_MAX_BLOCK_SECONDS. (2) The one sibling child in the same test, the unrelated `sleep 300`, now sleeps for FM_TEST_STUB_MAX_BLOCK_SECONDS so it uses the same bound. Verification, run serially: bash tests/fm-watcher-lock.test.sh. The new test passed on 4 of 4 runs. Red-before still holds: with the base bin/fm-wake-lib.sh from c9da5523, the test fails with 'not ok - recycled reaper pid kept an abandoned tombstone alive'. Separately, the known stand-down flake ('the replaced watcher did not stand down on its own', watch-legacy-local-time-identity) failed on every run on this host and also fails on base c9da5523 without this change, so the test file still exits 1; left unfixed as instructed. ci-1 (Full suite waiting on the full-ci maintainer label) was ignored per the user's decision

* feat(bin): allow omp as a remote secondmate harness (#7939)

* feat: allow omp as a remote secondmate harness

* test: cover omp on the remote secondmate gates

* fix: retire a remote secondmate whose busy state left with its home

* docs: record omp remote retirement evidence

* review: Refresh pinned remote doctor bootstrap checksum

* fix(bin): name a consumed branch grant instead of a wiring bug (#7969)

* fix(bin): name a consumed branch grant instead of a wiring bug

When a supervision branch's own acknowledgement consumes every granted
row, the drain removes the branch-eligible row snapshot while the owner
record stays live. A repeat drain or acknowledgement in the same turn then
refused with a message implying a broken handoff. Say instead that the
grant was already consumed; the refusal and its exit status are unchanged.

* no-mistakes(document): Document consumed-grant refusal in watcher continuity doc

---------

Co-authored-by: c-c6aw <[email protected]>

* fix: preserve literal ampersands in spawn and supervision paths (#7906)

* feat(bin): read dispatch provider keys from a declared credential source (#5409)

* feat(dispatch): read Typesafe key from Keychain

* no-mistakes(review): Share Keychain key lookup with bootstrap; hard-code service name

* no-mistakes(review): Use one readable-secret Keychain check for bootstrap and resolver

* no-mistakes(document): Point AGENTS key row to owner; record Keychain bootstrap evidence

* feat(dispatch): read provider keys from a declared credential source

bin/fm-dispatch-resolve.sh took the typesafe.ai and OpenRouter keys only
from the environment or $FM_HOME/.env, so a home that keeps its key in the
macOS Keychain needed a wrapper to supply it, and the documented direct
call reported off.

Let the resolver consume an optional, provider