Skip to content

fix: merge upstream firstmate main into fork (16 commits, through #4775) - #26

Merged
andrewesweet merged 19 commits into
mainfrom
fm/fm-upstream-sync-2
Sep 18, 2026
Merged

andrewesweet merged 19 commits into
mainfrom
fm/fm-upstream-sync-2

Conversation

@andrewesweet

@andrewesweet andrewesweet commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Merge this PR with a merge commit (Create a merge commit); never squash or rebase, because the branch carries a true two-parent merge of upstream/main that must stay a merge so future upstream syncs see the shared history.

The no-mistakes run that validated this branch was started with --skip rebase for the same reason: the pipeline's rebase step would otherwise be the one place the merge commit could be flattened, and the branch already contains origin/main (acd7047, #25) through a plain merge.

What upstream brought in

upstream/main at 9bc051f, 16 commits since the merge-base 9f8ad95:

The last four were already carried by fork commit ab912c7 (#19) as one squashed commit, which is why git could not see them as applied and reported conflicts in the files they touch.

Conflict resolution

Rule applied to every hunk: upstream's version wins verbatim for code the fork had only squashed in from upstream, and the fork's genuine additions are re-applied on top. Each surviving file was read whole afterwards and diffed against upstream/main to confirm the residual diff is fork material only.

  1. bin/fm-dispatch-resolve.sh (add/add): the fork's copy at ab912c7 was byte-identical to upstream 69d660a, so the only fork delta is the outcome log from feat(bin): log one JSON outcome line per dispatch-resolve call #24. Kept the fork file: upstream content plus the feat(bin): log one JSON outcome line per dispatch-resolve call #24 log.
  2. docs/verification/dispatch-resolve.md (add/add): same situation; kept the fork file, whose one extra line is the feat(bin): log one JSON outcome line per dispatch-resolve call #24 log evidence.
  3. tests/fm-dispatch-resolve.test.sh (add/add): same situation; kept the fork file, whose extra tests cover the feat(bin): log one JSON outcome line per dispatch-resolve call #24 log.
  4. bin/fm-crew-state.sh: the conflicting header comment was 334fa12's wording (squashed in feat(bin): merge upstream typed dispatch resolution and status-event fixes #19) against upstream f5d7f5f's later rewording of the same paragraph. Took upstream's paragraph. The fork's fix(bin): stop herdr server inheriting fm-crew-state snapshot overrides #17 basename guard on FM_CREW_STATE_*_OVERRIDE survives untouched and is the only remaining diff against upstream.
  5. bin/fm-spawn.sh: the whole launch_template case body conflicted because a fork no-mistakes pass had re-indented it by two spaces, so every line differed. Rebuilt from upstream's body (which adds --disable hooks to the codex crewmate launch, fa93097) and re-applied the three fork additions on top: the Claude --settings JSON with autoCompactWindow (feat(fm-spawn): set autoCompactWindow 220000 for every Claude worker launch #20) and the startup-context trim (feat(bin): trim the startup context of Claude and Pi workers #13) plus its explanatory comment, and the Pi crewmate --exclude-tools flag with its comment. Upstream's indentation is kept so the residual diff is substantive only.
  6. bin/fm-test-run.sh: two hunks inside portable_serial_weight_hints. Took upstream 4055cbd's refreshed hints verbatim for every script upstream has, then re-added the seven fork-only scripts in sorted position with the hints the fork gave them: tests/fm-branch-claude-mod-live-e2e.test.sh, tests/fm-branch-claude-mod-plugin.test.sh, tests/fm-branch-claude-mod.test.sh, tests/fm-branch-mod-bin.test.sh, tests/fm-precompact-skills.test.sh, tests/fm-promote.test.sh, tests/fm-trace-span-lib.test.sh. Upstream dropped the tests/fm-herdr-attached-viewer-live-e2e.test.sh hint in its refresh; that is upstream's call and is kept. The fork's family-map additions for the mod and bin/fm-promote.sh auto-merged cleanly. bin/fm-test-run.sh --check-coverage passes with serial_unhinted=0.
  7. docs/fm-test-portable-shards.md: took upstream's refresh paragraph (the 2026-09-17 CI runs covering all 176 upstream serial scripts) and replaced the fork's "sixteen further hints" sentence with one naming only the seven fork-only scripts that still carry doubled local measurements, since upstream now has real measurements for the other nine.
  8. docs/configuration.md: the typed-dispatch-resolution section was identical to upstream apart from the two fork lines describing the feat(bin): log one JSON outcome line per dispatch-resolve call #24 outcome log; kept the fork hunk.

Fork-only material verified intact after the merge: the Claude Code supervision-branch mod (.claude/mods/fm-branch-mod, its docs, tests, and bin/ pieces), the dispatch-resolve outcome log (#24), the Claude worker autoCompactWindow launch setting (#20), the state/.compact-skills inventory line (#21), and the OTLP tracing work (#1 to #6).

Regression evidence

The full serial suite ran on the upstream merge commit 51a1782; the later plain merge of origin/main (fb2bec9, bringing in #25, a docs-only mod pin bump) was followed by the quick checks below on fb2bec9. --jobs was not used for --all because the runner refuses it (tests/fm-afk-contract.test.sh is not in the proven-isolated set).

Lint and documentation checks (CI=true bin/fm-lint.sh, bin/fm-doc-audience-check.sh), both rc=0:

fm-lint.sh: ShellCheck 0.11.0 (pinned 0.11.0)
fm-lint.sh: full ShellCheck extended analysis enabled
fm-lint-workflows.sh: actionlint 1.7.12 (pinned 1.7.12)
fm-lint-workflows.sh: 3 workflow files valid
fm-doc-audience-check: ok surfaces=105 local_links=443

Coverage and the supervision-branch mod on fb2bec9 (bin/fm-test-run.sh --check-coverage, claude plugin validate --strict .claude/mods/fm-branch-mod on Claude Code 2.1.276, bin/fm-test-run.sh tests/fm-branch-claude-mod-plugin.test.sh):

FM_TEST_COVERAGE ok total=223 parallel=24 parallel_max_ms=417163 parallel_imbalance_ms=2894 parallel_unhinted=0 serial=183 serial_shards=9 serial_unhinted=0 herdr=16
✔ Validation passed
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=2150
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=2090 failed=0

Full suite (bin/fm-test-run.sh --all, serial, 116 minutes):

FM_TEST_SUMMARY total=223 failed=6 skipped_gate=28 duration_ms=6952285
FM_TEST_SUMMARY_FAMILY family=afk count=3 duration_ms=77282 failed=0
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=16 duration_ms=501334 failed=0
FM_TEST_SUMMARY_FAMILY family=cmux count=2 duration_ms=3213 failed=0
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=35 duration_ms=110355 failed=1
FM_TEST_SUMMARY_FAMILY family=orca count=1 duration_ms=20280 failed=0
FM_TEST_SUMMARY_FAMILY family=pr-forge count=8 duration_ms=544775 failed=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=39 duration_ms=976666 failed=0
FM_TEST_SUMMARY_FAMILY family=real-herdr-gated count=16 duration_ms=651500 failed=0
FM_TEST_SUMMARY_FAMILY family=secondmate count=22 duration_ms=1011701 failed=1
FM_TEST_SUMMARY_FAMILY family=session-bootstrap count=11 duration_ms=503517 failed=2
FM_TEST_SUMMARY_FAMILY family=snapshot-bearings count=5 duration_ms=229311 failed=0
FM_TEST_SUMMARY_FAMILY family=standalone count=30 duration_ms=836952 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=11 duration_ms=36041 failed=1
FM_TEST_SUMMARY_FAMILY family=watcher-wake-lock count=22 duration_ms=1435195 failed=0
FM_TEST_SUMMARY_FAMILY family=zellij count=2 duration_ms=8198 failed=1

All six failures are left in place because none is introduced by this merge: each one reproduces identically on a clean git archive copy of the pre-merge fork main (459972d) and of upstream/main (9bc051f) on this host, so they are upstream's own or this host's environment.

  1. tests/fm-backend-zellij-smoke.test.sh - not ok - create_task failed ("could not find a terminal pane for zellij tab 1") with zellij 0.45.1. Reproduces on both clean copies; the zellij backend is unchanged by this merge.
  2. tests/fm-composer-codex-idle-live-e2e.test.sh - not ok - codex (codex-cli 0.154.0): idle screen never classified empty (tmux read: unknown, cursorless styled read: unknown). Reproduces on both clean copies; the composer libraries are unchanged by this merge.
  3. tests/fm-gemini-harness.test.sh - not ok - GEMINI_CLI must identify a node-bundle gemini worker, got 'claude'. Reproduces on both clean copies, including with CLAUDECODE unset: the suite was run from inside a Claude Code worker, whose process ancestry the guard picks up.
  4. tests/fm-secondmate-liveness.test.sh - not ok - Herdr pane state unknown should map to unreadable, got 'missing'. Reproduces on both clean copies. Root cause is upstream 3e817d3 (fix(herdr): recover gone and drifted worker endpoints kunchenguid/firstmate#4120): fm_backend_herdr_agent_state now maps an unknown pane state to missing when the Herdr server is stopped, which is the case on this host with herdr 0.9.0 installed and not running, while the test still expects unreadable. Not touched here because it is upstream's own behaviour and test.
  5. tests/fm-session-start.test.sh - not ok - a digest child that died mid-stage must still let the session open (parent exits 0): expected exit 0, got 143. Environmental: this worker inherited FM_SESSION_START_STAGE_FILE from its spawning firstmate, and that variable is the flag bin/fm-session-start.sh uses to tell a timed child from the parent, so every digest under test ran unbounded and the death-banner case terminated the wrong ancestor. On the clean upstream/main copy with the same inherited environment the script fails in the neighbouring runtime-bound case instead (not ok - a truncated session start did not say so, after 41 minutes of hung fake git). On the merged head with FM_SESSION_START_STAGE_FILE, FM_CREW_STATE_META_OVERRIDE, and FM_CREW_STATE_STATUS_OVERRIDE unset it passes: FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=237088.
  6. tests/fm-sessionstart-nudge.test.sh - not ok - the compact run wrapper did not forward its source to instruction refresh (missing: 'RUN_TIER_AGENTS=updated'). Same inherited-environment cause; reproduces on both clean copies and passes on the merged head with the same three variables unset.

CI on the opened PR

The first CI run on fb2bec9 passed 17 checks and failed two, both in code this merge does not change and both green in the local runs above:

  • Behavior portable serial 3 - tests/fm-quota-choose.test.sh "bare omp candidate returned: ..." because fm_control_harness_supported in bin/fm-control-lib.sh returned early from a read loop over a process substitution, so the writer intermittently printed printf: write error: Broken pipe on stderr, which the test captures with 2>&1 and compares exactly. The pipeline's CI repair round fixed this at the root in 8bedf23 (an ordinary follow-up commit on top of the merge; fb2bec9 is unchanged and remains its parent) by iterating over a command substitution instead. The function is byte-identical on upstream/main, so the same flake exists there.
  • Behavior portable serial 4 - tests/fm-procevent.test.sh "the superseded paced runner invoked its stale command", a timing race in the registration-pacing case (FM_PROCEVENT_LAUNCH_FLOOR_SECONDS=3) in files this PR does not touch. It could not be reproduced in 25 local runs, including under CPU load, so no speculative change was made; it passed on the CI re-run.

All 19 checks passed on the re-run at 8bedf23.


Intent

Pull latest upstream firstmate changes, rebase ours over the top. Only run full regression if there was merge conflict (resolvable by git or otherwise).

Proceed as you recommended, exception use Opus/xhigh.

Context for reading that ask. The fork is github.com/andrewesweet/firstmate, upstream is github.com/kunchenguid/firstmate (remote upstream). At intake main is 459972d, 34 commits ahead of upstream/main (9bc051f, 2026-09-18) and 16 behind; merge-base 9f8ad95. The firstmate recommendation the captain accepted was: bring upstream in through a pull request that merges upstream/main into main with a true merge commit, not a rebase, because a rebase would rewrite main and break the fork's standing posture (PRs merge under yolo, running homes fast-forward), and because a dry-run rebase already conflicted at the first supervision-branch mod commit. Conflicts exist, so the captain's rule makes the full regression mandatory for this task. A dry-run git merge upstream/main on main conflicted in eight files: bin/fm-crew-state.sh, bin/fm-dispatch-resolve.sh, bin/fm-spawn.sh, bin/fm-test-run.sh, docs/configuration.md, docs/fm-test-portable-shards.md, docs/verification/dispatch-resolve.md, tests/fm-dispatch-resolve.test.sh. The root cause of most of them is fork commit ab912c7 (PR 19), which squashed four upstream commits (69d660a typed dispatch resolution, 334fa12 latest status event read, 795e5e4 Orca worktree id, b0877b4 pending-reply clearing) into one fork commit, so git cannot see they are already applied; the fm-test-run.sh and shards-doc conflicts come from upstream 4055cbd (kunchenguid#4800) rebalancing the same serial-shard hints the fork's mod commits edited. Fork-only material that must survive intact: the Claude Code supervision-branch mod (.claude/mods/fm-branch-mod and its docs, tests, and bin/ pieces), the dispatch-resolve outcome log (fork PR 24), the Claude worker autoCompactWindow launch setting (PR 20), the state/.compact-skills inventory line (PR 21), and the OTLP tracing work (PRs 1 to 6). A separate one-line pin bump, fork PR 25 (CLAUDE_CODE_PIN 2.1.274 to 2.1.276 in the mod plus its two doc pages), is in flight on the same repository and may land on main during this task.

What Changed

  • Merges upstream/main (kunchenguid/firstmate, 16 commits from b0877b4 through 9bc051f) into the fork as a true merge commit, resolving conflicts in bin/fm-crew-state.sh, bin/fm-spawn.sh, bin/fm-test-run.sh, and the dispatch-resolve and portable-shards files so fork-only material (supervision-branch mod, dispatch-resolve outcome log, autoCompactWindow launch setting, .compact-skills inventory line, OTLP tracing) stays intact; also merges the concurrent pin bump to Claude Code 2.1.276 (fix(mod): bump supervision-branch Claude Code pin to 2.1.276 #25).
  • Upstream runtime fixes brought in: fm-spawn.sh answers the Kimi 2.0.0 folder-trust dialog and launches Codex crewmates/scouts with --disable hooks; fm-watch.sh reports a dead-agent record once instead of escalating forever; fm-turnend-guard.sh lets non-owner Claude Stops exit safely; fm-crew-state.sh selects authoritative no-mistakes runs and distinguishes captain outcomes from no-op updates (with new v1.70.1 capture fixtures); fm-contributions.sh settles terminal observations; fm-mail-check.sh hardening; Pi Calm preserves substantive mid-turn text via new fm-calm-preservation.ts modules.
  • CI and test infrastructure: fm-lint.sh gains --partition/--telemetry and runs as a two-way matrix; full-coverage test shards rebalanced from 5 to 9 runners; new tests for the Codex hook-layer live E2E, foreign-owner turn-end repro, Kimi harness, and watcher lock/triage paths.

Risk Assessment

✅ Low: True merge commit (no rewrite of main) whose eight hand-resolved conflict files reconcile exactly to upstream plus the fork-only material the intent names; every other file matches git's own auto-merge tree, PR 25's pin bump is carried verbatim, and no duplicate definitions, syntax errors, or colliding test expectations were found, leaving only the intent-mandated full regression for the test phase.

Testing

Audited the merge resolution by recomputing git's auto-merge tree and diffing it against fb2bec9 (only the 8 conflicted files differ; no conflict markers remain; fm-branch-mod byte-identical to fork main), syntax-checked every changed shell script, ran the runner's --check-coverage guard (223 scripts partitioned, 0 unhinted), then ran 22 targeted behaviour suites covering every conflicted file and every fork-only feature plus the upstream-touched watcher/contributions/mail/turn-end suites, including the supervision-branch mod's claude plugin validate --strict and claude plugin test under the real installed Claude Code 2.1.276. All 22 passed with no gate skips. Full regression per the captain's conflict rule was not run here (the test phase is targeted by contract); it belongs to remote CI. Only pre-existing upstream gap observed: --changed --base acd7047 dies on no changed-test mapping for source path: GROK_BOT.md, which upstream's own runner also lacks (not merge-introduced).

  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Merge resolution matches git auto-merge everywhere except the eight conflicted files, and no conflict markers remain ✅ pass live merge-resolution-audit.md (git merge-tree tree c380506 vs fb2bec9: exactly 8 files differ; marker grep empty)
Supervision-branch mod survives intact at pin 2.1.276 and loads under the real installed Claude Code (strict validate + engine-hosted suite) ✅ pass live targeted-run-2.log: tests/fm-branch-claude-mod-plugin.test.sh exit=0; git diff acd7047 fb2bec9 -- .claude/mods/fm-branch-mod empty
Mod bin/ pieces and portable Node checks still pass after merge ✅ pass live targeted-run-1.log: tests/fm-branch-mod-bin.test.sh, tests/fm-branch-claude-mod.test.sh, tests/fm-branch-supervision.test.sh exit=0
Typed dispatch resolution keeps upstream behaviour and the fork's outcome log (data/dispatch-resolve.jsonl written per call, never key or brief; off path and exit-2 write nothing; failed log write doe… ✅ pass live targeted-run-1.log: tests/fm-dispatch-resolve.test.sh exit=0 (includes upstream's new latest-status and outcome-log cases)
Claude worker launch carries autoCompactWindow 220000 and startup-context trims; Pi launch carries --exclude-tools; env allowlist retains OTEL_RESOURCE_ATTRIBUTES ✅ pass live targeted-run-1.log: tests/fm-spawn-dispatch-profile.test.sh exit=0
OTLP tracing: spawn records traceparent/trace_started/trace_link, emits firstmate.spawn span, scrubs ambient TRACEPARENT when off (superset of upstream's relaunch-only unset) ✅ pass live targeted-run-1.log: tests/fm-trace-context-spawn.test.sh, fm-trace-context-lib, fm-trace-span-lib exit=0; run-2: fm-remote-secondmate-trace-context exit=0
Crew-state reads honour upstream's latest-status-event and Orca worktree id while keeping the fork's override-leak guard ✅ pass live targeted-run-1.log: tests/fm-crew-state.test.sh exit=0
Test runner: rebalanced serial shards plus fork's added scripts partition every script exactly once with a hint (adversarial: any script dropped or unhinted fails the guard) ✅ pass live bin/fm-test-run.sh --check-coverage → FM_TEST_COVERAGE ok total=223 serial_unhinted=0; tests/fm-test-run.test.sh and tests/fm-ci-workflow.test.sh exit=0
.compact-skills inventory line and PreCompact hook still work ✅ pass live targeted-run-1.log: tests/fm-precompact-skills.test.sh exit=0; AGENTS.md state/ inventory retains .compact-skills entry
Upstream-touched watcher, contributions, mail-check, turn-end guard, bootstrap, and Calm mod suites pass on the merged tree ✅ pass live targeted-run-2.log and targeted-run-1.log: fm-watch-triage, fm-contributions, fm-mail-check, fm-turnend-guard, fm-bootstrap, fm-calm-claude-mod(-plugin) exit=0
Full regression (captain's rule for a conflicted merge): every portable lane plus Herdr lane green ⏸️ untested no The test phase contract forbids running the complete repository suite; the full regression the captain's conflict rule requires is owned by remote CI (Behavior portable parallel 1-2, serial 1-9, Herdr…
Evidence: Merge-resolution audit (auto-merge tree vs merge commit, per-file numstat, fork-only diffs vs upstream)

Source: Merge-resolution audit (auto-merge tree vs merge commit, per-file numstat, fork-only diffs vs upstream)

# Merge-resolution audit: fb2bec9 (merge of upstream/main 9bc051f into fork main acd7047)

## git merge-tree auto-merge vs actual merge commit (only the 8 conflicted files differ)
 bin/fm-crew-state.sh                  |   8 -
 bin/fm-dispatch-resolve.sh            | 408 ---------------------
 bin/fm-spawn.sh                       | 498 ++------------------------
 bin/fm-test-run.sh                    | 316 +----------------
 docs/configuration.md                 |  37 --
 docs/fm-test-portable-shards.md       |  11 +-
 docs/verification/dispatch-resolve.md |  77 ----
 tests/fm-dispatch-resolve.test.sh     | 642 ----------------------------------
 8 files changed, 36 insertions(+), 1961 deletions(-)

## Conflict markers left in tree
none

## Per conflicted file: lines added/removed vs upstream and vs fork
bin/fm-crew-state.sh  vs-upstream:13/2  vs-fork:111/57
bin/fm-dispatch-resolve.sh  vs-upstream:103/1  vs-fork:
bin/fm-spawn.sh  vs-upstream:172/28  vs-fork:385/255
bin/fm-test-run.sh  vs-upstream:22/3  vs-fork:186/164
docs/configuration.md  vs-upstream:34/0  vs-fork:3/2
docs/fm-test-portable-shards.md  vs-upstream:1/0  vs-fork:27/11
docs/verification/dispatch-resolve.md  vs-upstream:1/0  vs-fork:
tests/fm-dispatch-resolve.test.sh  vs-upstream:75/2  vs-fork:

## fork-only mod untouched by merge
(empty = identical to fork main)

## Merge result vs upstream for conflicted bin/docs (fork-only material that survived)
diff --git a/bin/fm-crew-state.sh b/bin/fm-crew-state.sh
index 160c729..4fb9622 100755
--- a/bin/fm-crew-state.sh
+++ b/bin/fm-crew-state.sh
@@ -130,8 +130,19 @@ ID=${1:-}
 
 # Fleet snapshot composition supplies its captured metadata path here so every
 # state read resolves the same task generation selected by that snapshot.
-META=${FM_CREW_STATE_META_OVERRIDE:-"$STATE/$ID.meta"}
-LOG=${FM_CREW_STATE_STATUS_OVERRIDE:-"$STATE/$ID.status"}
+# An override is honoured only when its basename is exactly this task's own
+# file name: an override inherited from another task's environment (via a
+# herdr server started inside that task's fleet-snapshot child, for example)
+# must fall through to $STATE/$ID.* instead of reading another task's
+# captured generation (2026-09-16 override-leak incident).
+case ${FM_CREW_STATE_META_OVERRIDE:-} in
+  "$ID.meta"|*/"$ID.meta") META=$FM_CREW_STATE_META_OVERRIDE ;;
+  *) META=$STATE/$ID.meta ;;
+esac
+case ${FM_CREW_STATE_STATUS_OVERRIDE:-} in
+  "$ID.status"|*/"$ID.status") LOG=$FM_CREW_STATE_STATUS_OVERRIDE ;;
+  *) LOG=$STATE/$ID.status ;;
+esac
 NM_TIMEOUT=${FM_CREW_STATE_NM_TIMEOUT:-10}
 case "$NM_TIMEOUT" in ''|*[!0-9]*) NM_TIMEOUT=10 ;; esac
 # How many of the most recent `no-mistakes runs` rows each ledger read
diff --git a/bin/fm-dispatch-resolve.sh b/bin/fm-dispatch-resolve.sh
index 12f67db..ecf69f9 100755
--- a/bin/fm-dispatch-resolve.sh
+++ b/bin/fm-dispatch-resolve.sh
@@ -43,6 +43,23 @@
 #   existing unreadable rules file, malformed rules, or missing jq), which is
 #   actionable, never selected around.
 #
+# Outcome log (docs/configuration.md "Typed dispatch resolution" owns the
+#   operator contract): every resolved outcome (clear, ambiguous, escalate,
+#   error) appends exactly one JSON object as one line to
+#   $FM_HOME/data/dispatch-resolve.jsonl before the block prints, with fields
+#   ts (UTC ISO 8601), task (the <id> when the brief sits at a
+#   data/<id>/brief.md-shaped path, else null), project (the --project value
+#   or null), status, confidence (number or null), rule ("<choice>
+#   (<when excerpt>)" exactly as the block renders it, or null), profile (the
+#   profile line's value on clear, else null), reason (the non-clear reason,
+#   else null), latency_ms, and tokens (the usage object when the response
+#   carried one, else null). Never recorded: the API key, the brief text, and
+#   the request body. A failed append (unwritable directory, read-only home)
+#   prints one "dispatch-resolve: outcome log unwritable: <path>" line on
+#   stderr and never changes the block or the exit code; only data/ itself is
+#   created when absent. The off path and exit-2 usage or configuration
+#   errors write nothing: they are not calls.
+#
 # Environment:
 #   TYPESAFE_API_KEY is the only resolver-specific environment setting.
 #
@@ -77,6 +94,7 @@ DEFAULT_WHEN="No listed rule applies to this task."
 
 die() { printf 'error: %s\n' "$1" >&2; exit 2; }
 no_rules() {
+  log_dispatch_outcome escalate '' '' '' 'no rules to match'
   printf 'dispatch-resolve:\n  status: escalate\n  reason: no rules to match\n'
   exit 0
 }
@@ -98,6 +116,89 @@ while [ $# -gt 0 ]; do
   esac
 done
 
+LAT_MS=null
+# The outcome log lives beside the home's other private records; only a brief
+# sitting at a data/<id>/brief.md-shaped path contributes a task id, so an
+# arbitrary directory name is never mistaken for one.
+DISPATCH_LOG="$FM_HOME/data/dispatch-resolve.jsonl"
+DISPATCH_TASK_ID=''
+case /${BRIEF%/*} in
+  */data/*)
+    candidate=/$BRIEF
+    candidate=${candidate##*/data/}
+    candidate=${candidate%%/*}
+    case $candidate in
+      *[!a-z0-9-]*|'') DISPATCH_TASK_ID='' ;;
+      *) DISPATCH_TASK_ID=$candidate ;;
+    esac ;;
+esac
+
+# Append exactly one outcome line to the home's dispatch-resolve log. Every
+# argument is shell-controlled and already flat of newlines and tabs; a failed
+# write prints one stderr line and never changes the outcome. Only data/
+# itself is created when absent.
+dispatch_log_append() {  # <json-line>
+  { mkdir -p "${DISPATCH_LOG%/*}" && printf '%s\n' "$1" >> "$DISPATCH_LOG"; } 2>/dev/null || \
+    printf 'dispatch-resolve: outcome log unwritable: %s\n' "$DISPATCH_LOG" >&2
+  return 0
+}
+
+# log_dispatch_outcome <status> <confidence> <rule-render> <profile> <reason>
+# for outcomes resolved without a parsed model answer (no rules, error):
+# confidence, rule, profile, and tokens stay null and latency is whatever the
+# call reached.
+log_dispatch_outcome() {
+  local line
+  line=$(jq -cn \
+    --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
+    --arg task "$DISPATCH_TASK_ID" \
+    --arg project "$PROJECT" \
+    --arg status "$1" --arg confidence "$2" --arg rule "$3" --arg profile "$4" --arg reason "$5" \
+    --argjson latency "$LAT_MS" '
+    def n: if . == "" then null else . end;
+    {ts: $ts, task: ($task | n), project: ($project | n), status: $status,
+     confidence: ($confidence | n), rule: ($rule | n), profile: ($profile | n),
+     reason: ($reason | n), latency_ms: $latency, tokens: null}') || {
+    printf 'dispatch-resolve: outcome log unwritable: %s\n' "$DISPATCH_LOG" >&2
+    return 0
+  }
+  dispatch_log_append "$line"
+}
+
+# log_dispatch_result records the resolved RESULT object's own fields; the
+# rule renders as the block renders it and the profile is the profile line's
+# value.
+log_dispatch_result() {
+  local line
+  line=$(jq -cn \
+    --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
+    --arg task "$DISPATCH_TASK_ID" \
+    --arg project "$PROJECT" \
+    --argjson result "$RESULT" '
+  ($result) as $r |
+  def flat: tostring | gsub("[\t\r\n]"; " ");
+  {
+    ts: $ts,
+    task: (if $task == "" then null else $task end),
+    project: (if $project == "" then null else $project end),
+    status: $r.status,
+    confidence: $r.confidence,
+    rule: (if $r.rule then (($r.rule | flat) + " (" + ($r.rule_when | flat) + ")") else null end),
+    profile: (if $r.status == "clear" and $r.chosen then
+      "--harness " + ($r.chosen.profile.harness | @sh)
+      + (if $r.chosen.profile.model then " --model " + ($r.chosen.profile.model | @sh) else "" end)
+      + (if $r.chosen.profile.effort then " --effort " + ($r.chosen.profile.effort | @sh) else "" end)
+    else null end),
+    reason: (if $r.status == "clear" then null else ($r.reason // null) end),
+    latency_ms: $r.latency_ms,
+    tokens: $r.tokens
+  }') || {
+    printf 'dispatch-resolve: outcome log unwritable: %s\n' "$DISPATCH_LOG" >&2
+    return 0
+  }
+  dispatch_log_append "$line"
+}
+
 # ---- opt-in gate ---------------------------------------------------------------
 if [ -z "$TYPESAFE_API_KEY_PRIVATE" ]; then
   TYPESAFE_API_KEY_PRIVATE=$(fmx_env_get TYPESAFE_A

... [12646 bytes truncated] ...

ionale.
+Pi crewmate launches carry `--exclude-tools` for the primary extension tools; the [Pi adapter reference](../.agents/skills/harness-adapters/references/harness/pi.md) owns that flag.
 
 ## Crew dispatch profiles (config/crew-dispatch.json)
 
@@ -504,6 +522,8 @@ Firstmate passes its profile line unless it states a reason to override, such as
 
 The resolver and bootstrap copy an environment-provided key into a non-exported private variable and unset `TYPESAFE_API_KEY` before launching child processes, so the secret is absent from child environments.
 The resolver sends the key to `curl` only as a header read from a file descriptor, never on argv, and nothing prints, logs, or writes it.
+Every resolved call also appends one JSON line to the home's gitignored `data/dispatch-resolve.jsonl` recording the UTC time, task id, project, status, confidence, matched rule, chosen profile or non-clear reason, and the call's latency and token counts; the API key, the brief text, and the request body are never recorded, and the off path and exit-2 configuration errors write nothing because they are not calls.
+A failed log write prints one stderr line and never blocks the intake or changes the outcome.
 The resolver fixes the endpoint at `https://api.typesafe.ai`, model at `jev-latest`, confidence floor at 0.6, and request timeout at 5 seconds; `TYPESAFE_API_KEY` is its only resolver-specific environment setting.
 The live rule-match evidence is recorded in [`verification/dispatch-resolve.md`](verification/dispatch-resolve.md).
 
@@ -578,6 +598,7 @@ This section is the single owner of the canonical schema.
       "version_args": ["<optional args that make it print its version, default --version>"],
       "announce_pattern": "<optional extended regex matching the tool's own update announcement>",
       "announce_args": ["<optional args for the command that carries that announcement, default version_args>"],
+      "version_url": "<optional https URL whose body carries the newest published version>",
       "git": {
         "repo": "<optional absolute path to a local clone>",
         "remote": "<optional remote name, default origin>",
@@ -593,6 +614,19 @@ A `command` entry gives the `PATH` comparison above, and adding `announce_patter
 A tool does not always announce a new release on the command that prints its version: `no-mistakes --version` prints only the version, while its other commands carry the announcement.
 `announce_args` names the command to search for the announcement in that case, and it is asked only of the copy `PATH` resolves; without it the version probe's own output is searched.
 An `announce_pattern` that is not a usable extended regular expression stops `arm`, and during a sweep it is reported as that one tool's own check failure so one broken pattern never stops the other watched tools from being checked.
+A tool whose CLI never announces its own updates can name a `version_url` instead: the document is fetched read-only with `curl` inside the same probe bound, the first dotted number in its body is the published version, and `update available` is reported when that is newer than the version `PATH` resolves.
+Claude Code is the shipped example, because its `--version` prints only the version and its release channel is a plain-text document; the exact entry is:
+
+`` `json
+{
+  "name": "claude",
+  "command": "claude",
+  "version_args": ["--version"],
+  "version_url": "https://downloads.claude.ai/claude-code-releases/latest"
+}
+`` `
+
+A home running the Claude Code supervision-branch mod should carry that entry, because the mod refuses to load on any Claude Code version other than its pin and this check is what turns a new release into the pin-bump procedure in [`docs/claude-supervision-branch.md`](claude-supervision-branch.md).
 A `git` entry reports how many commits the local clone is behind its remote branch, and stays silent when the clone is current or ahead.
 An omitted `branch` uses the remote's default branch, taken from the clone's own record of it and otherwise asked of the remote directly, so a `--single-branch` clone still resolves.
 Both probe kinds are read-only and bounded, and a probe that cannot answer is reported as a check failure rather than assumed current.
diff --git a/docs/fm-test-portable-shards.md b/docs/fm-test-portable-shards.md
index c7d6be3..f6d601e 100644
--- a/docs/fm-test-portable-shards.md
+++ b/docs/fm-test-portable-shards.md
@@ -61,6 +61,7 @@ The serial hints were refreshed from successful per-script records in the `fm-te
 Together these cover all 176 serial scripts at refresh time; retain the slower successful sample where both exist.
 The native-Windows-only `tests/fm-pi-windows-shell-invocation.test.sh` retains its separate 5121 ms measurement from 2026-09-06T21:02Z instead of a portable capability skip.
 An unfinished or failed invocation is not a healthy duration sample.
+The three `tests/fm-branch-claude-mod*.test.sh` hints and the `tests/fm-branch-mod-bin.test.sh` hint, plus the `tests/fm-precompact-skills.test.sh`, `tests/fm-promote.test.sh`, and `tests/fm-trace-span-lib.test.sh` hints, are local measurements from 2026-09-16 doubled, pending their first green CI artifacts.
 A script with no hint gets the conservative `PORTABLE_SERIAL_DEFAULT_WEIGHT_MS` default.
 Hints only affect balance: the coverage guard keeps the partition complete and disjoint whatever they say, so a stale hint costs a slower shard rather than lost coverage.
 Balance is still worth keeping current, because enough unmeasured scripts let one shard carry more than twice another shard's real work and reach the job cap while another runner sits idle.
diff --git a/docs/verification/dispatch-resolve.md b/docs/verification/dispatch-resolve.md
index 5815219..4068e7b 100644
--- a/docs/verification/dispatch-resolve.md
+++ b/docs/verification/dispatch-resolve.md
@@ -61,6 +61,7 @@ It proves the absent key (environment and `.env`) prints one stderr line, nothin
 It proves absent, default-only, and empty-rules files return `no rules to match` without a model or quota request, while a broken rules-file symlink exits 2 as unreadable.
 It proves the documented starter configuration resolves its Pi default through the declared Claude provider, a `.env` key turns the tool on, and the environment wins over it.
 It proves the key is absent from child environments, never appears on `curl` argv, and arrives only as the bearer header on the descriptor.
+It proves every resolved outcome appends exactly one JSON line to the home's `data/dispatch-resolve.jsonl` carrying the outcome's own fields and never the key or the brief text, that the off path and exit-2 usage and configuration errors append nothing, and that a failed log write leaves the stdout block and the exit code untouched.
 It proves the request uses the fixed endpoint and model, carries only the project, brief, and rule Choice with one option per rule plus the fixed neutral none option, and never carries `why`, `use`, or quota.
 It proves the clear, fixed-floor ambiguous with candidate evidence, escalate (approval with candidate evidence, unverifiable rule floor, tie, nothing rankable), known rule-floor fall-through, known and unverifiable profile-floor evidence, explicit-provider and provider-ID enforcement, authoritative Agy and explicit-provider Gemini routing, partial providers, eligible unranked candidates and their clear-result note, concrete quota vetoes and profile-floor shortfalls taking precedence over uncertainty, account-wide quota veto, limiting-bound ranking, missing-curl and quota-axi failures, HTTP 429 and 500, transport failure, malformed usage, zero-mass or malformed probabilities or confidence, malformed or duplicate profile, invalid selector, removed-option rejection, and out-of-range rule ID paths behave as the contract states, with configuration errors exiting 2 before any network call.
 `tests/fm-bootstrap.test.sh` proves bootstrap ignores resolver-only fields without the typed key, validates each malformed shape when the environment or home `.env` activates typed resolution, and prevents an environment-provided key from reaching child processes.
Evidence: Coverage guard after shard rebalance merge
FM_TEST_COVERAGE ok total=223 parallel=24 parallel_max_ms=417163 parallel_imbalance_ms=2894 parallel_unhinted=0 serial=183 serial_shards=9 serial_unhinted=0 herdr=16
Evidence: Targeted run 1 timing artifact

Source: Targeted run 1 timing artifact

{
  "families": [
    {
      "count": 2,
      "duration_ms": 216303,
      "failed": 0,
      "name": "backend-dispatch"
    },
    {
      "count": 5,
      "duration_ms": 175233,
      "failed": 0,
      "name": "pure-contract-unit"
    },
    {
      "count": 1,
      "duration_ms": 35157,
      "failed": 0,
      "name": "session-bootstrap"
    },
    {
      "count": 1,
      "duration_ms": 4363,
      "failed": 0,
      "name": "standalone"
    },
    {
      "count": 4,
      "duration_ms": 4970,
      "failed": 0,
      "name": "unclassified"
    },
    {
      "count": 1,
      "duration_ms": 8916,
      "failed": 0,
      "name": "watcher-wake-lock"
    }
  ],
  "finished_at": "2026-09-18T16:51:31Z",
  "run_id": "fm-test-run-1789749874121-3008626",
  "scripts": [
    {
      "duration_ms": 27254,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-crew-state.test.sh"
    },
    {
      "duration_ms": 146436,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-test-run.test.sh"
    },
    {
      "duration_ms": 8916,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "watcher-wake-lock",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-branch-mod-bin.test.sh"
    },
    {
      "duration_ms": 100,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-branch-claude-mod.test.sh"
    },
    {
      "duration_ms": 365,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-trace-context-lib.test.sh"
    },
    {
      "duration_ms": 1078,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-calm-claude-mod.test.sh"
    },
    {
      "duration_ms": 35157,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "session-bootstrap",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-bootstrap.test.sh"
    },
    {
      "duration_ms": 4363,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "standalone",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-dispatch-resolve.test.sh"
    },
    {
      "duration_ms": 143238,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "backend-dispatch",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-spawn-dispatch-profile.test.sh"
    },
    {
      "duration_ms": 73065,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "backend-dispatch",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-trace-context-spawn.test.sh"
    },
    {
      "duration_ms": 918,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "unclassified",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-trace-span-lib.test.sh"
    },
    {
      "duration_ms": 167,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "unclassified",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-precompact-skills.test.sh"
    },
    {
      "duration_ms": 1840,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "unclassified",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-promote.test.sh"
    },
    {
      "duration_ms": 2045,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "unclassified",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-ci-workflow.test.sh"
    }
  ],
  "selection": "scripts;jobs=4",
  "started_at": "2026-09-18T16:44:34Z",
  "summary": {
    "duration_ms": 417747,
    "failed": 0,
    "skipped_gate": 0,
    "total": 14
  }
}
Evidence: Targeted run 2 timing artifact

Source: Targeted run 2 timing artifact

{
  "families": [
    {
      "count": 2,
      "duration_ms": 4977,
      "failed": 0,
      "name": "live-harness-optin"
    },
    {
      "count": 1,
      "duration_ms": 57059,
      "failed": 0,
      "name": "secondmate"
    },
    {
      "count": 1,
      "duration_ms": 30167,
      "failed": 0,
      "name": "snapshot-bearings"
    },
    {
      "count": 1,
      "duration_ms": 7721,
      "failed": 0,
      "name": "standalone"
    },
    {
      "count": 3,
      "duration_ms": 794272,
      "failed": 0,
      "name": "watcher-wake-lock"
    }
  ],
  "finished_at": "2026-09-18T17:06:08Z",
  "run_id": "fm-test-run-1789750311465-3274832",
  "scripts": [
    {
      "duration_ms": 7049,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "watcher-wake-lock",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-mail-check.test.sh"
    },
    {
      "duration_ms": 30272,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "watcher-wake-lock",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-turnend-guard.test.sh"
    },
    {
      "duration_ms": 756951,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "watcher-wake-lock",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-watch-triage.test.sh"
    },
    {
      "duration_ms": 57059,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "secondmate",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-remote-secondmate-trace-context.test.sh"
    },
    {
      "duration_ms": 7721,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "standalone",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-branch-supervision.test.sh"
    },
    {
      "duration_ms": 2002,
      "exit": 0,
      "expected_gate_skip": "live-capability",
      "family": "live-harness-optin",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-branch-claude-mod-plugin.test.sh"
    },
    {
      "duration_ms": 2975,
      "exit": 0,
      "expected_gate_skip": "live-capability",
      "family": "live-harness-optin",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-calm-claude-mod-plugin.test.sh"
    },
    {
      "duration_ms": 30167,
      "exit": 0,
      "expected_gate_skip": "optional-binary",
      "family": "snapshot-bearings",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-contributions.test.sh"
    }
  ],
  "selection": "scripts;jobs=4",
  "started_at": "2026-09-18T16:51:51Z",
  "summary": {
    "duration_ms": 857202,
    "failed": 0,
    "skipped_gate": 0,
    "total": 8
  }
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 10 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Merge resolution matches git auto-merge everywhere except the eight conflicted files, and no conflict markers remain ✅ pass live merge-resolution-audit.md (git merge-tree tree c380506 vs fb2bec9: exactly 8 files differ; marker grep empty)
Supervision-branch mod survives intact at pin 2.1.276 and loads under the real installed Claude Code (strict validate + engine-hosted suite) ✅ pass live targeted-run-2.log: tests/fm-branch-claude-mod-plugin.test.sh exit=0; git diff acd7047 fb2bec9 -- .claude/mods/fm-branch-mod empty
Mod bin/ pieces and portable Node checks still pass after merge ✅ pass live targeted-run-1.log: tests/fm-branch-mod-bin.test.sh, tests/fm-branch-claude-mod.test.sh, tests/fm-branch-supervision.test.sh exit=0
Typed dispatch resolution keeps upstream behaviour and the fork's outcome log (data/dispatch-resolve.jsonl written per call, never key or brief; off path and exit-2 write nothing; failed log write doe… ✅ pass live targeted-run-1.log: tests/fm-dispatch-resolve.test.sh exit=0 (includes upstream's new latest-status and outcome-log cases)
Claude worker launch carries autoCompactWindow 220000 and startup-context trims; Pi launch carries --exclude-tools; env allowlist retains OTEL_RESOURCE_ATTRIBUTES ✅ pass live targeted-run-1.log: tests/fm-spawn-dispatch-profile.test.sh exit=0
OTLP tracing: spawn records traceparent/trace_started/trace_link, emits firstmate.spawn span, scrubs ambient TRACEPARENT when off (superset of upstream's relaunch-only unset) ✅ pass live targeted-run-1.log: tests/fm-trace-context-spawn.test.sh, fm-trace-context-lib, fm-trace-span-lib exit=0; run-2: fm-remote-secondmate-trace-context exit=0
Crew-state reads honour upstream's latest-status-event and Orca worktree id while keeping the fork's override-leak guard ✅ pass live targeted-run-1.log: tests/fm-crew-state.test.sh exit=0
Test runner: rebalanced serial shards plus fork's added scripts partition every script exactly once with a hint (adversarial: any script dropped or unhinted fails the guard) ✅ pass live bin/fm-test-run.sh --check-coverage → FM_TEST_COVERAGE ok total=223 serial_unhinted=0; tests/fm-test-run.test.sh and tests/fm-ci-workflow.test.sh exit=0
.compact-skills inventory line and PreCompact hook still work ✅ pass live targeted-run-1.log: tests/fm-precompact-skills.test.sh exit=0; AGENTS.md state/ inventory retains .compact-skills entry
Upstream-touched watcher, contributions, mail-check, turn-end guard, bootstrap, and Calm mod suites pass on the merged tree ✅ pass live targeted-run-2.log and targeted-run-1.log: fm-watch-triage, fm-contributions, fm-mail-check, fm-turnend-guard, fm-bootstrap, fm-calm-claude-mod(-plugin) exit=0
Full regression (captain's rule for a conflicted merge): every portable lane plus Herdr lane green ⏸️ untested no The test phase contract forbids running the complete repository suite; the full regression the captain's conflict rule requires is owned by remote CI (Behavior portable parallel 1-2, serial 1-9, Herdr…
  • git merge-tree --write-tree acd7047 9bc051f then git diff --stat &lt;tree&gt; fb2bec9 (only 8 conflicted files differ)
  • git grep -nE &#39;^( | | )( |$)&#39; fb2bec9 (no conflict markers)
  • git diff --stat acd7047 fb2bec9 -- .claude/mods/fm-branch-mod docs/claude-supervision-branch.md (empty: mod identical to fork main)
  • bash -n on every changed bin/.sh and tests/.sh
  • bin/fm-test-run.sh --check-coverage (FM_TEST_COVERAGE ok total=223 serial_unhinted=0 parallel_unhinted=0)
  • bin/fm-test-run.sh --list --lane &lt;each lane&gt; (9 serial shards, 2 parallel, herdr)
  • bin/fm-test-run.sh tests/fm-crew-state.test.sh tests/fm-dispatch-resolve.test.sh tests/fm-spawn-dispatch-profile.test.sh tests/fm-test-run.test.sh tests/fm-trace-context-spawn.test.sh tests/fm-trace-context-lib.test.sh tests/fm-trace-span-lib.test.sh tests/fm-branch-claude-mod.test.sh tests/fm-branch-mod-bin.test.sh tests/fm-precompact-skills.test.sh tests/fm-promote.test.sh tests/fm-bootstrap.test.sh tests/fm-ci-workflow.test.sh tests/fm-calm-claude-mod.test.sh (14/14 pass)
  • bin/fm-test-run.sh tests/fm-branch-claude-mod-plugin.test.sh tests/fm-calm-claude-mod-plugin.test.sh tests/fm-watch-triage.test.sh tests/fm-contributions.test.sh tests/fm-mail-check.test.sh tests/fm-turnend-guard.test.sh tests/fm-branch-supervision.test.sh tests/fm-remote-secondmate-trace-context.test.sh (8/8 pass, plugin suites ran under real claude 2.1.276)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

thelad-dev and others added 19 commits September 16, 2026 15:45
…kunchenguid#4680)

* fix(bin): clear parent pending-replies on local secondmate retirement

Local secondmate teardown left resolved parent pending-reply records behind
after home removal (seen after papa-hdds / pxmx retirement). Refuse non-forced
retirement while any reply for that id is still unresolved, and delete every
matching record plus its delivery confirmation after a successful local or
remote retirement, matching the remote cleanup path.

* no-mistakes(document): Align secondmate retirement docs with pending-reply cleanup

* no-mistakes(review): Lokale Pending-replies-Sicherheitsprüfung vor Home-Entfernung

* no-mistakes(review): Pending-replies-corr_id auf 16-Hex absichern

* no-mistakes(review): Pending-replies Basename und corr_id abgleichen

* no-mistakes(document): Clarify forced retirement pending-reply cleanup

---------

Co-authored-by: ladwein <ladwein@firstmate.bost8.thelad.loc>
kunchenguid#4677)

* fix(bin): accept Orca's composite worktree id at teardown

Teardown refused every Orca-backed task because the endpoint validator
checked orca_worktree_id with the simple-atom rule meant for tmux-style
window names, which rejects any character outside [A-Za-z0-9._@%+-]. Orca
returns that id as `<orca id>::<absolute worktree path>`, so the colon and
slashes in every real value made validation fail and finished Orca tasks
could never be cleaned up.

Validate the field as the composite it is: both halves of the first `::`
split present, the path half absolute, and no embedded newline, carriage
return, or tab. The terminal field keeps the atom check, which is correct
for it, and no other backend's validation changes.

The existing Orca fixtures recorded ids like `wt-teardown`, a shape Orca
never returns, which is why the suite passed a check the real value fails.
They now carry the composite form, so the tests exercise the real value.

* no-mistakes(document): name Orca's repo id in the composite worktree id

* no-mistakes(document): list teardown endpoint safety suite in Orca regression entry points
* feat(bin): add opt-in typed dispatch resolution through typesafe.ai

Add bin/fm-dispatch-resolve.sh, which resolves one concrete crewmate or
scout profile from a written brief with typesafe.ai's System One model:
one Choice question over the rules' `when` texts, then the confidence
floor, the rule's `approval` and `floor`, each profile's `provider` and
`floor`, one quota-axi snapshot, and the spendPriority argmax all in code.
It is off unless TYPESAFE_API_KEY is in the environment or the home's
gitignored .env; off means one stderr line, exit 0, and no network call,
so firstmate dispatches exactly as before. The key reaches curl on a file
descriptor, never argv.

Extract fmx_env_get into bin/fm-env-lib.sh as the one .env accessor and
the harness-to-provider table into bin/fm-quota-axi-lib.sh so the new
tool and bin/fm-quota-choose.sh share one owner each. Bootstrap validates
the four new optional dispatch fields. Document the schema, the operator
contract, the AGENTS.md intake step, and the live and benchmark evidence.

* no-mistakes(review): Harden typed dispatch resolution and quota bounds

* no-mistakes(review): Validate dispatch floors and ranking evidence

* no-mistakes(review): Tighten dispatch response and floor evidence

* no-mistakes(review): Neutralize none matching and resolve defaults locally

* no-mistakes(review): Preserve providerless profiles outside typed resolution

* no-mistakes(review): Validate response usage and reject duplicate profiles

* no-mistakes(review): Escalate unverifiable floors and validate probabilities

* no-mistakes(review): Validate probability mass and unknown profile floors

* no-mistakes(review): Simplify resolver interface and preserve fallback routing

* no-mistakes(review): Fix constants and rank partial quota evidence

* no-mistakes(review): Add authoritative provider mapping and enforce explicit providers

* no-mistakes(review): Declare provider for documented Pi profile

* no-mistakes(review): Validate provider identifiers and support Gemini dispatch

* no-mistakes(review): Strictly anchor provider identifiers

* no-mistakes(review): Validate selectors and preserve fallback candidate evidence

* no-mistakes(review): Gate typed validation and harden resolver evidence

* no-mistakes(review): Preserve opt-in routing and harden candidate evidence

* no-mistakes(review): Prioritize known exhaustion over quota uncertainty

* no-mistakes(review): Isolate API secrets and preserve no-key diagnostics

* no-mistakes(review): Fallback safely when dispatch rules are absent

* no-mistakes(review): Prioritize quota vetoes and isolate bootstrap secrets

* no-mistakes(document): Document typed dispatch safety and fallback behavior
…n decisions aren't lost (kunchenguid#3753)

* test: reproduce buried status declarations in shared readers

* fix: share status event reads and preserve open blockers

* fix: retain terminal scout and ship status declarations

* no-mistakes(review): Fix status chronology, legacy completions, and reader performance

* no-mistakes(review): Share terminal decision reconciliation across fleet snapshots

* no-mistakes(review): Unify terminal supersession across cached folds and consumers

* no-mistakes(review): Filter per-key status history while preserving terminal chronology

* no-mistakes(test): Preserve parent lock ownership in Bash 3.2 subshells

* no-mistakes(review): Anchor legacy status tokens so prose cannot hide pauses

* no-mistakes(document): Document latest-event status read and kind-scoped fold cursor

* no-mistakes(lint): Quote literal done in test for-lists for SC1010

* ci: expect 19 snapshot/fleet-view tests

This branch adds a fleet-snapshot regression, so the stock macOS Bash
lane's hardcoded guard of 18 'ok - ' lines fails on the new count.
Bump the guard and its message to 19.

* no-mistakes(review): Restore multiline child outcome reporting

* no-mistakes(review): Select ledger terminal events through bounded shared reader

* no-mistakes(review): Report newest open decision instead of preferring blocked

* no-mistakes(review): Require colon before ship/scout terminal supersession in fold

* no-mistakes(review): Gate socket-down override on latest event; drop lock matrix

* no-mistakes(review): Fold only colon-bearing or keyed lines as decision transitions

* no-mistakes(review): Pre-select candidate lines before per-key closing-verb fold

* no-mistakes(test): Update fleet-view expectations to newest-open-decision rule

* no-mistakes(document): Align status-read docs with fold-resolved crew state

* no-mistakes(document): Correct status-reader contracts in classify-lib and crew-state headers

* no-mistakes(ci): Greptile P1 (bin/fm-crew-state.sh:729, "Stale socket blocker survives") was a real defect introduced by commit b7c2183 on this branch, and is fixed. Root cause: the daemon-socket-down override took its verb check from `last_status_line "$LOG"` but its evidence and emitted detail from `$LOG_LINE` (status_current_line = the fold's newest still-open decision). Those are different lines whenever a later recognized `blocked:` event is one the decision fold declines. Reproduced by sourcing bin/fm-classify-lib.sh on `blocked: no-mistakes daemon socket is missing` followed by `blocked [key=pending-reply-t3]: still waiting on the answer` (reserved-namespace key whose note does not speak that vocabulary, so _fm_decision_key_transition_allowed rejects it): open set still holds the socket blocker, last_status_line returns the newer line, its verb is blocked, so the gate passed and the stale daemon-down evidence overrode a healthy attributed run. Fix (bin/fm-crew-state.sh): capture LOG_LATEST=$(last_status_line "$LOG") once and read verb, socket-down evidence, and the emitted note all off that same line, so the override fires only while the socket-down declaration is itself the log's latest recognized event — preserving the narrow override the prior round's user instruction asked for. Comment updated to state that contract. No new machinery; the two-line conflation was removed rather than papered over. Regression: extended tests/fm-crew-state.test.sh:test_socket_refusal_override_expires_when_the_crew_moves_on with the reproduced sequence, asserting the run-step reading (state: working, source: run-step) and absence of the override detail. It fails before the fix ("not ok - a later unfolded blocked event also hands the reading back to the run (missing: 'state: working')") and passes after. Verified locally: tests/fm-crew-state.test.sh, tests/fm-fleet-snapshot-view.test.sh, tests/fm-classify-decision-key.test.sh, tests/fm-watch-triage.test.sh, tests/fm-captain-hold-lifecycle.test.sh all pass; bin/fm-lint.sh (shellcheck 0.11.0 + actionlint) exits 0. Changes left uncommitted in the worktree

* test: fold terminal-cleanup snapshot coverage into the completed-scout case

Keep the ship/scout/secondmate supersession assertions without adding a
nineteenth top-level fleet-view test, so CI can stay at the upstream suite count.

* no-mistakes(document): Clarify socket-down override expiry in architecture doc

* ci: retrigger flaky contribution check
…nchenguid#4689)

* fix(spawn): launch codex crewmates with codex's hook layer disabled

A freshly launched Codex worker never reached its instructions. Codex
stopped it on an interactive "Hooks need review" modal whose selection
sits on "Review hooks", which is neither trusting nor declining.
Firstmate's key plane carries only Enter, Escape and Ctrl-C with no arrow
navigation, so the selection cannot be moved, and pre-accepting the
prompt by writing Codex's own trust store would record an operator
consent that was never given.

The hooks are the machine's own ~/.codex/hooks.json plus any project's
.codex/hooks.json. A crewmate needs neither: its turn-end signal is the
-c notify= program on the same launch, and Firstmate's project hooks are
primary-session infrastructure that stands down in a child worktree.

Crewmate and scout launches now pass --disable hooks. That is the
opposite of --dangerously-bypass-hook-trust, which RUNS the untrusted
hooks; disabling the feature runs none of them and leaves the operator's
~/.codex untouched. An unknown feature name is a hard Codex error, so a
release that drops the flag fails the launch loudly instead of silently
restoring the modal. A secondmate is a primary in its own home and keeps
the project hooks its turn-end guard and session-start digest ride on.

Verified on codex-cli 0.151.0: the modal is gone and the turn-end
notification still lands.

This unblocks the second review that every finished pull request is supposed to get.

Fixes kunchenguid#4673

* no-mistakes(review): Fix contradictory hook count in Codex verification record
…d#4669, Fixes kunchenguid#4670) (kunchenguid#4710)

* fix(bin): settle terminal contributions and wake once per read-failure episode

A contribution whose last good observation is merged or closed is final:
poll no longer re-reads it, projection keeps it fresh, and a stale error
recorded beside it is cleared once. A genuine forge-read failure on an open
contribution still records its error on every cycle but prints the
unavailable wake only when it starts a failure episode; a successful read
ends the episode. Open PRs linked from done tasks keep being observed.

The false unavailable beside a complete observation was budget exhaustion
mid-observation, already fixed by kunchenguid#4661.

* fix(review): Settle terminal contribution owners

* fix(review): Deduplicate shared contribution failure episodes

* fix(test): Preserve settled terminal contribution records
* fix(crew-state): select authoritative validation runs by identity

Use the AXI run overview and id-addressed status reads to preserve replacement review gates, report competing live runs as unknown, and retain newer failures. Keep the coarse ledger in creation order rather than preferring an older live row.

Refs: kunchenguid#3215

* fix(review): Resolve same-branch run identities beyond capped history

* fix(review): Fix run-selection compatibility, races, and worker-state fallbacks

* fix(review): Limit run validation to the requested branch

* fix(test): Anchor AXI fixtures and document remaining live evidence gaps

* fix(document): Clarify run selection documentation and capture ownership

* fix(lint): Fix ShellCheck diagnostics while preserving fixture isolation
* fix(AGENTS): send a captain-facing outcome instead of shipshape for finished requested work

MAIN answered a supervision-branch outcome for completed captain-requested
work (implementation done, PR ready for review and merge approval) with
"Captain, shipshape.", reading section 9's no-action reply as covering it
and reading the Pi protocol's "do not re-emit the anchor verbatim" as "no
captain-facing response is owed".

Section 9 now limits the shipshape reply to true no-ops (idle re-read,
empty heartbeat, consequence-free acknowledgement) and requires a short
outcome response naming what finished and what word is needed whenever
requested work finishes or a result needs the captain's word, even when a
transcript entry already shows the substance. The Pi protocol's re-emit
rule now says it bounds repetition only, and carries a worked example of
the ready-for-review outcome whose correct processing turn a shipshape
reply fails.

No executable contract evaluates the content of MAIN's captain-facing
reply, so the regression is the protocol example in the owner doc rather
than a text-match test.

* no-mistakes(document): Clarify captain-facing outcomes versus no-ops

* docs(pi): restore the ready-for-review regression example as a preserved-verbatim contract line

The document step condensed the Pi protocol's re-emit rule and dropped the
worked example of a finished, ready-for-review outcome whose correct
processing turn a "Captain, shipshape." reply fails. That example is the
contract's regression: no executable contract evaluates the content of
MAIN's captain-facing reply, so the owner doc's example is the test case.

Restore it directly under the re-emit rule, prefixed as a regression
example that is kept verbatim and never condensed or summarized away.

* no-mistakes(review): Clarify captain outcome and decision-word requirements

* no-mistakes(document): Clarify captain-facing completion outcomes

* docs(pi): require the PR URL in the visible captain-facing outcome reply

Captain review on the regression example: drop the sample reply string
and say only that the ready-for-review outcome requires relaying a
captain-facing outcome response, not just "Captain, shipshape.".

Fold in the visible-PR-handoff failure seen this session: after the
branch outcome reporting this fix green, MAIN's visible reply was only
"Awaiting your merge call." with no PR URL, leaning on the dim anchor.
Section 9's URL rule now also covers a review or merge ask and names the
visible reply as where the URL goes, sourced from the ready status, pr=
metadata, or the supervision branch's summary and never left to a
transcript entry. The Pi protocol adds the same-way failure and places
the captain-facing text in the final visible assistant reply after the
fm_branch_processed call, because Calm hides assistant text emitted in
the same step as a tool call as a working note.

Investigation verdict, evidence in the PR comment: no recent PR caused
the handoff failure; Pi has hidden same-step pre-tool assistant text
since kunchenguid#2339 (2026-08-13), kunchenguid#4655 changed only the Claude Code mod, and
kunchenguid#4658 touched only remote report transfer.

* no-mistakes(review): Restore safe outcome ordering and consolidate PR URLs

* no-mistakes(document): Clarify captain-facing supervision outcomes

* docs(AGENTS): keep the whenever-a-PR-is-mentioned trigger on the consolidated URL rule

The consolidated section 9 URL rule narrowed its trigger to a review or
merge ask, dropping the "whenever a PR is mentioned" catch-all from
kunchenguid#3648 that keeps every PR URL copied from a durable record and never
assembled from memory. Restore that trigger as a union with the review
or merge ask so the one consolidated rule covers both.
* Fix foreign-owner turn-end supervision loop

* no-mistakes(review): Scope foreign-owner safe exit to Claude guard

* no-mistakes(document): Document Claude foreign-owner safe exit
…orb (kunchenguid#4778)

Under set -u, stock macOS bash 3.2.57 treats "${arr[@]}" on an empty
indexed array as an unbound variable and aborts the shell. In
signal_turnend_panes_churned() the missing_keys loop was reachable with
an empty array whenever every churned key already held a fresh
.churn-since-* marker (a second churning turn-end inside an open
deferral window), so each watcher cycle died about half a minute in and
supervision restarted endlessly. The created_keys rollback loops had the
same latent crash on their error paths.

Audit of bin/ for the same pattern found one more confirmed-reachable
case: remote_handoff's noncanonical-body scan iterates to_move, which is
empty when a retried remote handoff finds every key already staged in
the outbox. All other "${arr[@]}" sites are either count-guarded,
guaranteed non-empty by construction, or unreachable while empty.

Guard the three reachable expansions with the repo's existing
"${arr[@]+...}" idiom. New regression test drives a real watcher
through the all-marked churn path; the macos-stock-bash CI lane runs it
under real /bin/bash 3.2 via FM_TEST_ONLY.
… lock. (kunchenguid#4783)

The synthetic harness was named synthetic-claude, which Linux procps truncates to synthetic-claud so fm-lock.sh never matched a harness or wrote state/.lock before the test read it.

Co-authored-by: Cursor <cursoragent@cursor.com>
* docs: require complete final responses across harnesses

* no-mistakes(document): Document complete final replies for Grok Bot

* docs: point Grok replies to the shared contract owner

* no-mistakes(review): Clarify final recap without batching decision asks
* fix(calm): preserve substantive Pi mid-turn text

* no-mistakes(review): Preserve substantive Pi Calm text per block

* no-mistakes(test): Cover shared Calm preservation boundaries behaviorally

* no-mistakes(document): Consolidate Calm preservation documentation
)

* Improve CI reliability and rebalance full-coverage validation

* no-mistakes(document): Clarify lint partition documentation
…guid#4799)

* Handle Kimi workspace trust dialog

* no-mistakes(review): Retry Kimi trust Enter and gate ready on dialog markers

* no-mistakes(review): Gate Kimi ready on any trust marker and clean captures

* no-mistakes(review): Read visible pane for Kimi trust and ready gates

* no-mistakes(review): Add per-backend visible-pane capture for Kimi trust gate

* no-mistakes(review): Harden Kimi viewport capture and trust dialog detection

* no-mistakes(document): Document Kimi spawn refusal on cmux and Orca
…er (kunchenguid#4775)

* fix(bin): report a record whose agent is gone once instead of escalating forever

The wedge escalation path never asked whether there was still an agent to be
wedged. A wedge is something stuck that might recover, so re-alarming it earns
its cost; an agent that is gone never moves again, its pane never churns, the
idle timer never resets, and the escalate path clears its own timer and re-arms
with nothing bounding the count.

Observed on a live fleet: two finished lanes reached 226 and 203 consecutive
escalations, roughly one every FM_STALE_ESCALATE_SECS, indefinitely - about 400
notifications a day from two lanes with no agent running at all. On one,
fm-control.sh exit answered already-stopped and fm-crew-state.sh read
"failed - run failed". Closing the Herdr pane did not stop it either: with the
pane genuinely gone and herdr pane read returning pane_not_found, the count kept
climbing, because the poll is driven by the record's window= line rather than by
the pane. The cost is not the repetition but that it drowns the alarms that
matter.

fm_backend_agent_state already separates a thinking agent from a gone one at
process level. In the branch that was about to escalate, read it once and treat
only its two recovery-grade verdicts - dead (endpoint present, no agent in it)
and missing (endpoint authoritatively absent) - as proof, reporting that record
once and not re-escalating it while it stays that way. Every other verdict,
including alive, ambiguous, unreadable, unverified, and a read that failed
outright, keeps the identical schedule, reason, and escalation count, so a
genuinely wedged live agent is unaffected. The probe costs at most one backend
read per window per threshold, the same budget the declared-wait consult and the
worktree write probe already take.

The report decides nothing about the record's fate: both lanes still held
unlanded work and teardown refusing them was correct, so retiring, relaunching,
or cleaning up stays with the supervisor. The once-only marker is owned entirely
by that function and is dropped by the same read the moment the endpoint stops
reading gone, so a replacement launched into the same window escalates normally
and its own later death is reported again.

Related, and not closed by this: kunchenguid#4412, kunchenguid#4482, kunchenguid#4316.

Tests drive the real watcher against a record whose endpoint does not exist and
pin both directions: dead and missing report once and never advance the count
across later thresholds, while alive, ambiguous, and unreadable endpoints keep
escalating with the identical reason and a climbing count.

* fix(bin): bind the once-only dead report to the pane it reported

Review of the parent commit found a reachable sequence where a later death in
the same window lost its promised report. The marker was keyed on the verdict
string alone and dropped only when a threshold probe read a non-gone verdict,
but probes run only at thresholds: a replacement launched into the same window
that dies without ever being probed alive - it crashes at startup, or works and
then crashes - was absorbed by the previous death's marker. The pane's first
sight yielded only the generic stale wake and every later threshold matched the
stale marker, so the second death never got the detailed once-report that both
the function's own comment and docs/architecture.md promise.

Record the verdict together with the pane hash it was reported for, and absorb a
repeat only while both still match. A replacement churns the pane, which resets
the stale suppressor, wedge timer, and escalation count while no reset site
touches this marker, so the pane half is what tells the second death apart from
the first. The live-probe drop stays as it was.

Clearing the marker at those reset sites instead would re-open unbounded
re-alarming for a dead pane whose display ever ticks, which is the exact defect
the parent commit exists to close.

The noise bound is unchanged: an unchanged dead pane still absorbs on every
later threshold and never advances the escalation count, and every verdict short
of proof still escalates exactly as before.

* no-mistakes(review): Key the dead-record once-marker on the busy incarnation token

* no-mistakes(document): Document dead-record escalation cap in stale-pane config entry

* no-mistakes(document): Add busy-state inventory line to AGENTS.md

* no-mistakes(document): Document dead-record probe on busy-turn-bound wedge path
# Conflicts:
#	bin/fm-crew-state.sh
#	bin/fm-dispatch-resolve.sh
#	bin/fm-spawn.sh
#	bin/fm-test-run.sh
#	docs/configuration.md
#	docs/fm-test-portable-shards.md
#	docs/verification/dispatch-resolve.md
#	tests/fm-dispatch-resolve.test.sh
…e omp candidate returned: ...") fixed at root cause: fm_control_harness_supported in bin/fm-control-lib.sh returned early from a read loop over a process substitution, so the writer intermittently emitted "printf: write error: Broken pipe" on stderr, which the test captures with 2>&1 and compares exactly. Now iterates over a command substitution; test passes repeatedly with no Broken pipe, shellcheck clean. Shard 4 failure (tests/fm-procevent.test.sh, "the superseded paced runner invoked its stale command") is a pre-existing upstream timing flake in files this PR does not touch; could not reproduce in 25 local runs including under heavy CPU load, mechanism not identified, no speculative change made — needs CI rerun
@andrewesweet
andrewesweet merged commit c3e9391 into main Sep 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

10 participants