Skip to content

test: replace source assertions with behavioral coverage - #1282

Merged
kunchenguid merged 5 commits into
mainfrom
fm/fm-source-content-test-cleanup-r1
Jul 30, 2026
Merged

kunchenguid merged 5 commits into
mainfrom
fm/fm-source-content-test-cleanup-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Audit the complete tracked Firstmate test suite and remove every test assertion that reads implementation source bytes directly or indirectly through grep, parsers, regexes, snapshots, shell helpers, or wrappers. Retain or add behavioral coverage only through executable or public interfaces and generated runtime artifacts that exercise their owner. Delete source-only test files and stale runner, manifest, and documentation references. Add the durable source-content-test prohibition to the existing firstmate coding-guidelines skill. Keep the change limited to this cleanup, do not absorb the two unrelated instruction-only tasks, and record the removal and replacement inventory in the task report. The known fm-secondmate-harness Pi-marker portability failure is a separately recorded baseline issue, not fixed on this branch; validate the suite in a subprocess with PI_CODING_AGENT and FM_PI_HARNESS unset.

What Changed

  • Remove source-content assertions and delete test files that only inspected implementation bytes.
  • Replace affected checks with runtime behavior coverage through executables, public interfaces, and generated artifacts.
  • Refresh test-runner inventories, isolation/shard documentation, and coding guidelines to prohibit source-content tests.

Risk Assessment

✅ Low: Captain, the isolation fix uses a process-unique task ID, clears stale state before spawn, and installs explicit cleanup; the complete branch now satisfies the source-content-test cleanup intent without material review concerns.

Testing

Validated the 94-test inventory and exercised 10 focused scripts through the public runner with PI_CODING_AGENT and FM_PI_HARNESS unset. All executed checks passed, including the named secondmate-harness regression; the real Pi/Herdr opt-in test skipped as documented, while its public marker behavior passed in the non-live suite. CLI transcripts and audit artifacts provide reviewer-visible evidence; no screenshot was applicable because this change has no UI surface.

Evidence: Focused behavioral test transcript
FM_TEST_BEGIN 2026-07-30T01:26:00Z tests/fm-test-run.test.sh family=pure-contract-unit expected_gate_skip=none
ok - exact suite coverage: --all lists every tests/*.test.sh once
ok - family selection returns a proper subset of the suite
ok - single-script selection lists exactly that path
ok - changed-file selection stays conservative (never silent full suite)
ok - changed selection covers dependents and fails closed for unmapped source
ok - empty changed selection emits deterministic text and JSON summaries
ok - timing markers and JSON artifact are valid
ok - aggregate exit reflects any script failure
ok - gate-skip accounting is honest and non-failing
ok - fail-on-gate-skip converts herdr-not-found into a hard failure
ok - exclude-family drops the named primary family after selection
ok - portable shard union, disjointness, and coverage guard hold
ok - --jobs refuses non-proven / stateful selections
ok - jobs scheduler runs proven scripts; failure propagates; non-proven refused
ok - aggregate-json merges lane timing artifacts
FM_TEST_END 2026-07-30T01:26:09Z tests/fm-test-run.test.sh exit=0 duration_ms=8928 gate_skip=false
FM_TEST_BEGIN 2026-07-30T01:26:09Z tests/fm-test-isolation-proof.test.sh family=pure-contract-unit expected_gate_skip=none
ok - candidate --list is non-empty, sorted, unique, and real
ok - serial classes remain excluded from the parallel candidate set
ok - audited fake-backend and stub-network extras are candidates
ok - exclusion list documents serial reasons
ok - isolation-proof contract test is family-mapped
ok - parallel shards consume the proven-isolated set only
FM_TEST_END 2026-07-30T01:26:09Z tests/fm-test-isolation-proof.test.sh exit=0 duration_ms=490 gate_skip=false
FM_TEST_BEGIN 2026-07-30T01:26:09Z tests/fm-gotmp.test.sh family=session-bootstrap expected_gate_skip=none
ok - fm-teardown removes the dir pointed to by tasktmp= in meta
ok - fm-teardown skips gracefully when tasktmp= is absent (backward compat)
ok - fm-teardown skips gracefully when tasktmp= points to a nonexistent dir
FM_TEST_END 2026-07-30T01:26:11Z tests/fm-gotmp.test.sh exit=0 duration_ms=1595 gate_skip=false
FM_TEST_BEGIN 2026-07-30T01:26:11Z tests/fm-kimi-harness.test.sh family=pure-contract-unit expected_gate_skip=none
ok - Kimi hook install is idempotent and removal restores every foreign config byte
ok - Kimi hook removal preserves owned newline boundaries and pristine bytes
ok - Kimi hook install refuses missing, malformed, and surprising config without writing
ok - Kimi hook install refuses without jq before any config write
ok - fm-spawn: kimi launches, delivers its brief, and registers a guarded turn-end token
ok - Kimi hook stays silent and inert without a Firstmate registry token
ok - fm-spawn: unsafe Kimi global config refuses before pane creation
ok - fm-teardown: Kimi task pointer and registry token are removed
ok - fm-spawn: Kimi fallback expands the active HOME
ok - fm-spawn: missing Kimi executable refuses before pane creation
ok - fm-spawn: kimi treats a silent pointer drop as a failed spawn
ok - fm-spawn: kimi never sends the brief pointer before an observable ready signal
ok - fm-harness: markerless kimi is detected by ancestry after env-marker precedence
lock acquired: harness pid 44044
ok - fm-lock recognizes Kimi ancestry and live lock holders
ok - busy detection: real Kimi moon-plus-middot captures require its harness while idle labels stay idle
ok - fm-watch: Kimi spinner matching is metadata-scoped and ignores Grok's busy token
ok - composer classifier: kimi's existing bordered > shape is already safe without an override
FM_TEST_END 2026-07-30T01:26:29Z tests/fm-kimi-harness.test.sh exit=0 duration_ms=17717 gate_skip=false
FM_TEST_BEGIN 2026-07-30T01:26:29Z tests/fm-send-secondmate-marker-herdr-e2e.test.sh family=live-harness-optin expected_gate_skip=optin-env
skip: set FM_SEND_MARKER_HERDR_E2E=1 to run the real Pi/Herdr secondmate-marker regression
FM_TEST_END 2026-07-30T01:26:29Z tests/fm-send-secondmate-marker-herdr-e2e.test.sh exit=0 duration_ms=38 gate_skip=true
FM_TEST_BEGIN 2026-07-30T01:26:29Z tests/fm-subagent-pretool-check.test.sh family=pure-contract-unit expected_gate_skip=none
ok - the guard independently denies every work-creating delegation tool by shape
ok - the guard denies delegation-shaped tools that no deny list knows about yet
ok - the guard leaves ordinary tools and observe-or-stop operations alone
ok - the guard leaves the session-local todo list alone
ok - the plan-only exclusion releases exactly two names and nothing that merely contains them
ok - MCP tool names are never classified as harness delegation
ok - deny defers to intake classification and degrades gracefully without fm-scout.sh
ok - the single documented escape hatch releases the guard only on the exact opt-in value
ok - the guard is inert in a crewmate task worktree and in a non-firstmate repo
ok - a marked secondmate home is guarded even though it is a linked worktree
ok - both stdin transports classify correctly and Claude's deny keeps stdout empty
ok - malformed, empty, and tool-name-less payloads fail open rather than blocking every tool call
ok - missing jq for stdin transport fails open rather than denying every tool call
FM_TEST_END 2026-07-30T01:26:31Z tests/fm-subagent-pretool-check.test.sh exit=0 duration_ms=2332 gate_skip=false
FM_TEST_SUMMARY total=6 failed=0 skipped_gate=1 duration_ms=31331
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=38 failed=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=4 duration_ms=29467 failed=0
FM_TEST_SUMMARY_FAMILY family=session-bootstrap count=1 duration_ms=1595 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-kimi-harness.test.sh duration_ms=17717
FM_TEST_SLOWEST rank=2 script=tests/fm-test-run.test.sh duration_ms=8928
FM_TEST_SLOWEST rank=3 script=tests/fm-subagent-pretool-check.test.sh duration_ms=2332
FM_TEST_SLOWEST rank=4 script=tests/fm-gotmp.test.sh duration_ms=1595
FM_TEST_SLOWEST rank=5 script=tests/fm-test-isolation-proof.test.sh duration_ms=490
FM_TEST_SLOWEST rank=6 script=tests/fm-send-secondmate-marker-herdr-e2e.test.sh duration_ms=38
fm-test-run: wrote timing artifact: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KYR96ME0TC3P7P8HW1W93HHC/focused-runtime-tests.json
Evidence: Focused timing data
{
  "families": [
    {
      "count": 1,
      "duration_ms": 38,
      "failed": 0,
      "name": "live-harness-optin"
    },
    {
      "count": 4,
      "duration_ms": 29467,
      "failed": 0,
      "name": "pure-contract-unit"
    },
    {
      "count": 1,
      "duration_ms": 1595,
      "failed": 0,
      "name": "session-bootstrap"
    }
  ],
  "finished_at": "2026-07-30T01:26:31Z",
  "run_id": "fm-test-run-1785374760363-30516",
  "scripts": [
    {
      "duration_ms": 8928,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "path": "tests/fm-test-run.test.sh"
    },
    {
      "duration_ms": 490,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "path": "tests/fm-test-isolation-proof.test.sh"
    },
    {
      "duration_ms": 1595,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "session-bootstrap",
      "gate_skip": false,
      "path": "tests/fm-gotmp.test.sh"
    },
    {
      "duration_ms": 17717,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "path": "tests/fm-kimi-harness.test.sh"
    },
    {
      "duration_ms": 38,
      "exit": 0,
      "expected_gate_skip": "optin-env",
      "family": "live-harness-optin",
      "gate_skip": true,
      "path": "tests/fm-send-secondmate-marker-herdr-e2e.test.sh"
    },
    {
      "duration_ms": 2332,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "path": "tests/fm-subagent-pretool-check.test.sh"
    }
  ],
  "selection": "scripts",
  "started_at": "2026-07-30T01:26:00Z",
  "summary": {
    "duration_ms": 31331,
    "failed": 0,
    "skipped_gate": 1,
    "total": 6
  }
}
Evidence: Public-interface test transcript
FM_TEST_BEGIN 2026-07-30T01:27:49Z tests/fm-send-secondmate-marker.test.sh family=secondmate expected_gate_skip=none
ok - fm-send: a kind=secondmate target gets the from-firstmate marker and corr prepended
ok - fm-send: an exact kind=secondmate task id is marked with corr exactly once
ok - fm-send: exact-id and stable-label kind=ship selectors are sent unmarked
ok - fm-send: explicit endpoints stay unmarked with or without local metadata
ok - fm-send: the --key path carries no marker (no literal text is typed)
ok - fm-send: the marker is '[fm-from-firstmate]' + terminal-safe U+2063, while direct captain text stays unmarked
ok - fm-marker: from-firstmate transformation is idempotent
ok - fm-send: marked secondmate payload preserves trailing newline bytes
FM_TEST_END 2026-07-30T01:27:54Z tests/fm-send-secondmate-marker.test.sh exit=0 duration_ms=5083 gate_skip=false
FM_TEST_BEGIN 2026-07-30T01:27:54Z tests/fm-ask-user-authority.test.sh family=pure-contract-unit expected_gate_skip=none
ok - primary workers and secondmates receive the authority rule through generated instructions
FM_TEST_END 2026-07-30T01:27:54Z tests/fm-ask-user-authority.test.sh exit=0 duration_ms=372 gate_skip=false
FM_TEST_BEGIN 2026-07-30T01:27:55Z tests/fm-documentation-audiences.test.sh family=pure-contract-unit expected_gate_skip=none
ok - documentation inventory classifies every maintained prose surface exactly once
ok - classification, setup routing, and maintained-prose scope fail safely
ok - required documentation owner pointers cannot silently disappear
ok - local links resolve while dates, versions, commands, and incident prose remain semantically reviewed
FM_TEST_END 2026-07-30T01:27:55Z tests/fm-documentation-audiences.test.sh exit=0 duration_ms=790 gate_skip=false
FM_TEST_SUMMARY total=3 failed=0 skipped_gate=0 duration_ms=6358
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=2 duration_ms=1162 failed=0
FM_TEST_SUMMARY_FAMILY family=secondmate count=1 duration_ms=5083 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-send-secondmate-marker.test.sh duration_ms=5083
FM_TEST_SLOWEST rank=2 script=tests/fm-documentation-audiences.test.sh duration_ms=790
FM_TEST_SLOWEST rank=3 script=tests/fm-ask-user-authority.test.sh duration_ms=372
fm-test-run: wrote timing artifact: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KYR96ME0TC3P7P8HW1W93HHC/public-interface-tests.json
Evidence: Cleanup and removal audit
Acceptance environment: PI_CODING_AGENT and FM_PI_HARNESS unset
Current runner inventory: FM_TEST_COVERAGE ok total=94 parallel=24 serial=60 herdr=10
Tracked test scripts: 94
Deleted source-only test files:
tests/fm-bearings-skill.test.sh
tests/fm-captain-translation-contract.test.sh
tests/fm-install-herdr.test.sh
tests/fm-instruction-owners.test.sh
tests/fm-nm-test-contract.test.sh
tests/fm-no-mistakes-ownership.test.sh
tests/fm-quota-array-dispatch.test.sh
tests/fm-stow-contract.test.sh
tests/no-mistakes-required-workflow.test.sh
Deleted-test stale references outside the base-to-head diff: none
Durable prohibition:
100:- Tests must exercise behavior through an executable or public interface and must never assert implementation-source bytes, including through parsers, regexes, snapshots, or indirect wrappers.
Evidence: Secondmate harness transcript
FM_TEST_BEGIN 2026-07-30T01:28:55Z tests/fm-secondmate-harness.test.sh family=secondmate expected_gate_skip=none
ok - A1 fm-harness.sh secondmate resolves the fallback chain; crew mode unchanged
ok - C1 fm-harness.sh secondmate-model/secondmate-effort resolve the optional tokens; bare harness stays empty (backward-compat)
ok - pi-signed identity: authoritative launch selection distinguishes shared wrapper ancestry
ok - harness identity: dash-leading ps command names are basename operands, not options
ok - B1 propagate_inheritable_config: copy, idempotence, convergence, absence-mirror, exclusion, no-op, skip diagnostics
ok - B2 spawn: secondmate runs the secondmate harness; its home inherits declared config
ok - B3 spawn: an absent secondmate-harness falls back to the crew harness (backward-compat)
ok - B4 spawn: no config at all -> own harness and no propagation side effects
ok - B5 spawn: an explicit per-spawn harness arg overrides config/secondmate-harness
ok - B6 spawn: an unverified resolved secondmate harness is refused (guard intact)
ok - B5b spawn: FM_BACKEND wins over inherited config/backend
ok - B5c spawn: explicit --backend wins over FM_BACKEND and inherited config/backend
ok - C2 spawn: a bare harness-only secondmate-harness file launches with no model/effort flag (backward-compat)
ok - C3 spawn: config/secondmate-harness's model token threads --model into the launch and meta
ok - C4 spawn: config/secondmate-harness's model+effort tokens thread into the launch and meta
ok - C5 spawn: an explicit --model overrides config/secondmate-harness's model token; the file's effort token still applies
ok - C6 spawn: an explicit --effort overrides config/secondmate-harness's effort token; the file's model token still applies
ok - C7 spawn: an explicit --harness starts with clean model/effort defaults
ok - C8 spawn: an explicit --harness still honors explicit model/effort flags
ok - C9 spawn: the harness fallback chain still resolves with no tokens; crew/scout launches are unaffected by this feature
ok - B7 bootstrap sweep pushes, re-converges, and mirrors absence; never inherits secondmate-harness
ok - B8 bootstrap sweep propagates config even when the home's tracked files are already current
ok - B9 bootstrap sweep defers new inherited config until the home ignores it
ok - B10 bootstrap sweep with no inherited config is a config no-op and still fast-forwards
ok - B12b backend inheritance: present values and primary absence converge exactly
ok - B11 bootstrap sweep surfaces config propagation failures
ok - B11 bootstrap rereads completed config writes after partial propagation
ok - B12 config-push propagates via shared live discovery, reports items, rereads on change only, and does not fast-forward
ok - B13 config-push reports dirty, non-allowing, and invalid homes without failing warnings-only runs
ok - B14 config-push exits nonzero on real propagation errors
ok - B14 config-push rereads completed config writes after partial propagation
ok - B15 config reread is per-home, exact-byte, ordered, and pointer-only
ok - B16 config reread isolation, ABSENT, generation safety, send failure, and retry
ok - B20 config reread publication failures retain exact generations for retry
ok - B21 config reread instruction-write failures retain exact retry generations
ok - B21 config reread preserves exact bytes when temporary adoption also fails
ok - B21 config reread serializes concurrent propagation and delivery
ok - B22 full config reread retry queues drain before new publication
ok - B23 mixed config reread delivery failures still bound sent history
ok - B26 config reread delivery stops after the oldest failed generation
ok - B17 config reread skips unchanged homes and reads destination post-write bytes
ok - B18 bootstrap config reread path works; spawn flexibility remains defaults-only
ok - B19 bootstrap respawns before inherited-config reread
ok - B25 spawn quarantines stale rereads without blocking relaunch
ok - B24 bootstrap detect-only mode remains filesystem read-only
# all fm-secondmate-harness tests passed
FM_TEST_END 2026-07-30T01:31:09Z tests/fm-secondmate-harness.test.sh exit=0 duration_ms=133593 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=133647
FM_TEST_SUMMARY_FAMILY family=secondmate count=1 duration_ms=133593 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-secondmate-harness.test.sh duration_ms=133593
fm-test-run: wrote timing artifact: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KYR96ME0TC3P7P8HW1W93HHC/secondmate-harness.json
Evidence: Secondmate harness timing data
{
  "families": [
    {
      "count": 1,
      "duration_ms": 133593,
      "failed": 0,
      "name": "secondmate"
    }
  ],
  "finished_at": "2026-07-30T01:31:09Z",
  "run_id": "fm-test-run-1785374935503-45244",
  "scripts": [
    {
      "duration_ms": 133593,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "secondmate",
      "gate_skip": false,
      "path": "tests/fm-secondmate-harness.test.sh"
    }
  ],
  "selection": "scripts",
  "started_at": "2026-07-30T01:28:55Z",
  "summary": {
    "duration_ms": 133647,
    "failed": 0,
    "skipped_gate": 0,
    "total": 1
  }
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 3 issues found → auto-fixed (2) ✅
  • 🚨 tests/fm-kimi-harness.test.sh:19 - Intent requires removing "every test assertion that reads implementation source bytes directly or indirectly." This reachable test still byte-pins fm-spawn with grep, while line 35 separately git-greps the entire tracked tree. Delete these source-only checks or replace the launch assertions with fm-spawn subprocess behavior coverage.
  • 🚨 tests/fm-gotmp.test.sh:105 - Intent requires removing "every test assertion that reads implementation source bytes directly or indirectly" and retaining behavioral coverage through executable interfaces. This test still greps fm-spawn source and then simulates its implementation rather than executing it. Exercise bin/fm-spawn.sh against a fixture and inspect its generated task directory, metadata, and launch environment instead.
  • 🚨 tests/fm-send-secondmate-marker-herdr-e2e.test.sh:107 - Intent requires removing every direct or indirect source-byte assertion. This live E2E reads the tracked Pi extension, searches for exact implementation anchors, and fails when those bytes change before rewriting the source. Instrument capture through a separate supported Pi extension or another public test interface instead of parsing and patching the owner source.

🔧 Fix: Replace source assertions with runtime behavior coverage
1 warning still open:

  • ⚠️ tests/fm-kimi-harness.test.sh:197 - The new runtime coverage uses the fixed global path /tmp/fm-kimi-success-z1, but appending it to FM_TEST_CLEANUP_DIRS does not install an EXIT trap because the earlier fm_test_tmproot call ran inside command substitution. The directory therefore survives successful runs, can collide with concurrent checkouts, and can make the directory assertion pass from stale state. Use a process-unique task ID and register explicit cleanup before invoking fm-spawn.

🔧 Fix: Isolate Kimi task temp runtime coverage
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Inspected git diff --stat, git diff --name-status, and the complete changed-file inventory for daf6dcef4a092c7e858d2eaa91cd9c5a25f1e156..e505f5816ef64f7c884f4dd50732cce5b6596fe3.
  • Ran env -u PI_CODING_AGENT -u FM_PI_HARNESS bin/fm-test-run.sh --check-coverage.
  • Ran env -u PI_CODING_AGENT -u FM_PI_HARNESS bin/fm-test-run.sh --changed --base daf6dcef4a092c7e858d2eaa91cd9c5a25f1e156 --list and confirmed it selected only existing tests.
  • Compared the 94 tracked test scripts with bin/fm-test-run.sh --list --all; inventories matched exactly.
  • Ran env -u PI_CODING_AGENT -u FM_PI_HARNESS bin/fm-test-run.sh --json ... tests/fm-test-run.test.sh tests/fm-test-isolation-proof.test.sh tests/fm-gotmp.test.sh tests/fm-kimi-harness.test.sh tests/fm-send-secondmate-marker-herdr-e2e.test.sh tests/fm-subagent-pretool-check.test.sh.
  • Ran env -u PI_CODING_AGENT -u FM_PI_HARNESS bin/fm-test-run.sh --json ... tests/fm-send-secondmate-marker.test.sh tests/fm-ask-user-authority.test.sh tests/fm-documentation-audiences.test.sh.
  • Ran env -u PI_CODING_AGENT -u FM_PI_HARNESS bin/fm-test-run.sh --json ... tests/fm-secondmate-harness.test.sh.
  • Audited deleted source-only test names for stale references across bin, docs, tests, .github, and .agents; none remained.
  • Confirmed the durable source-content-test prohibition in .agents/skills/firstmate-coding-guidelines/SKILL.md.
  • Ran git status --short after testing; no transient working-tree artifacts remained.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid
kunchenguid merged commit a2d5f26 into main Jul 30, 2026
10 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-source-content-test-cleanup-r1 branch July 30, 2026 02:17
mattadams-dev added a commit to mattadams-dev/firstmate that referenced this pull request Jul 30, 2026
Upstream kunchenguid#1282 forbids asserting implementation-source bytes, so the ci.yml grep
is gone. The guarantee it protected - a renamed gate cause or token slipping past
the required Herdr lane's over-skip guard - now runs through executables instead:
the real bin/fm-herdr-lab.sh gate produces a real refusal reason, and the real
runner must fail on it under the token.
mattadams-dev added a commit to mattadams-dev/firstmate that referenced this pull request Jul 30, 2026
…r contracts, not host identity (#1)

* test(herdr): gate real-Herdr tests on a provisionable lab, not on PATH

command -v herdr proves a binary is on PATH and proves nothing about session
state, so every real-Herdr test hard-failed on an ordinary machine where herdr
is installed but no default session runs - the lab helper's fleet-state tripwire
needs one. Add a gate command to bin/fm-herdr-lab.sh, the owner of that tripwire,
so the gate and provisioning can never disagree, and route all ten gated tests
through it.

* test: assert against resolver contracts, not the host runtime's identity

Two tests read the identity of whatever harness and runtime session happened to
launch the suite:

fm-secondmate-harness stubbed process ancestry but left bin/fm-harness.sh's env
markers ambient, and those are consulted FIRST - so CLAUDECODE=1 decided the
result under claude, and an ambient PI_CODING_AGENT would have satisfied the
no-Pi-marker case for the wrong reason.

fm-session-start pins herdr_session=default in its fake-herdr fixtures, but a
firstmate running inside a NAMED herdr session resolved that operator session
instead, because ambient selection is the documented backend contract
(fm_backend_herdr_session).

Both now drop the ambient inputs on each call, the idiom run_session_start
already used for harness markers.

* test(secondmate-harness): keep shellcheck clean on the bash -c probes

* test(herdr): prove the lab gate in both directions and keep CI's coverage guard

Adds the gate's own coverage: with a running default session it passes silently
and provisioning really succeeds; with the session stopped, absent, unlistable,
or herdr/jq missing it refuses with one reason line naming the cause. Each case
also asserts the gate agrees with what provisioning would do, so the two cannot
drift.

A gate can also fail by skipping too much, which would look green. The required
CI Herdr lane is what forbids that - it starts a default session and must run
the real bodies - so --fail-on-gate-skip becomes repeatable, the lane lists the
new token too, and a test binds that token to the lane.

* docs(herdr): record why a lab needs a running default session

* test: prove the gate token behaviorally instead of reading CI's source

Upstream kunchenguid#1282 forbids asserting implementation-source bytes, so the ci.yml grep
is gone. The guarantee it protected - a renamed gate cause or token slipping past
the required Herdr lane's over-skip guard - now runs through executables instead:
the real bin/fm-herdr-lab.sh gate produces a real refusal reason, and the real
runner must fail on it under the token.

* no-mistakes(review): derive the CI gate-skip token from the lab helper and probe Herdr once

* no-mistakes(review): drop dead herdr-not-found gate token from CI lane
quinnbot-ai pushed a commit to quinnbot-ai/firstmate that referenced this pull request Jul 30, 2026
…#1282)

* test: remove source-content assertions

* no-mistakes(review): Replace source assertions with runtime behavior coverage

* no-mistakes(review): Isolate Kimi task temp runtime coverage

* no-mistakes(document): Refresh test cleanup documentation

* no-mistakes: apply CI fixes
quinnbot-ai added a commit to quinnbot-ai/firstmate that referenced this pull request Jul 30, 2026
…oposal (#68)

* feat(bin): inherit backend config into secondmate homes (kunchenguid#1219)

* Inherit config/backend into secondmate homes with deliberate-override preservation

Add backend to the shared inheritable config allowlist so launch, locked
bootstrap, and config-push converge a primary pin into secondmate homes as each
home local future-spawn default. Track last-inherited bytes in a private state
provenance marker so deliberate per-home overrides survive present and absent
primary convergence, keep --backend and FM_BACKEND stronger, and extend the
existing inheritance tests plus docs and skill claims.

* no-mistakes(review): Preserve equal unprovenanced backend overrides

* no-mistakes(review): Preserve symlink overrides and verify spawn precedence

* no-mistakes(review): Snapshot backend inheritance for consistent provenance

* no-mistakes(review): Simplify backend inheritance to primary-authoritative convergence

* no-mistakes(document): Document inherited backend override preservation

* fix: restore primary-authoritative backend inheritance after document regression

The document step reintroduced provenance and deliberate per-home override
semantics after review had simplified config/backend to plain primary-authoritative
allowlist membership. Restore the primary-always-wins path: present overwrites,
absent removes, no provenance marker, and docs/tests match that contract.

* no-mistakes(review): Add divergent backend precedence regression fixtures

* no-mistakes(document): Document backend inheritance contract

* fix(pi): remove Calm's upper version ceiling (kunchenguid#1226)

* fix(pi): remove Calm's exclusive Pi upper-version ceiling

tests/fm-calm-pi-extension.test.sh gated on a closed PI_COMPAT_VERSIONS
allowlist ("0.81.1 0.82.0") that refused any other installed Pi, and docs
described that range as "supported" rather than verified evidence. The
Calm CHANGELOG shows no API introduced at either version, so there is no
evidence for a real minimum; the presentation adapters already probe the
exact method they patch rather than checking a version.

Replace the allowlist with dated version evidence that never rejects a
newer Pi, and make each presentation adapter degrade independently with
a diagnostic if a future Pi removes its API, instead of the whole Calm
extension failing to load. Rewrite the feasibility doc's "Pi 0.81.1
through 0.82.0" phrasing to state it as verified evidence, not a
ceiling.

* no-mistakes(review): Probe missing Calm adapter exports safely

* no-mistakes(document): Document Calm's unbounded Pi compatibility

* fix(bin): allow session-local todo tools in the subagent guard (kunchenguid#1204)

* fix(guard): allow session-local todo tools in the primary

The delegation-shape guard denied TaskCreate and TaskUpdate because their
normalized names contain the `task` stem. Those tools write only the harness's
session-local todo list, which has no executor: it spawns no agent, allocates
no worktree, registers no schedule, and starts nothing that outlives the
session. That is not the unaccounted work the guard exists to stop, so the stem
match was a false positive, and the deny text told the primary to run
bin/fm-brief.sh and bin/fm-spawn.sh to create a todo entry.

Add a separately-reasoned PLAN_ONLY_TOOLS exact-name exclusion rather than
widening OBSERVE_ONLY_TOOLS, whose documented contract is tools that only
observe or stop existing work. Both lists stay exact-name so neither can widen
by substring.

Tests cover the two allowed names and six near-miss names that a substring or
shortened-stem widening would release; both mutations were watched red.

* no-mistakes(review): drop session-local todo tools from recommended deny list

* no-mistakes: apply CI fixes

* fix(session-lock): resolve Claude bg-spare ancestry to the outermost claude pid (kunchenguid#1206)

* fix(session-lock): resolve Claude bg-spare ancestry to the outermost claude pid

fm_harness_ancestry_pid() previously returned the first ancestor process
whose command matched a verified harness name. Claude Code's Stop hook
fires as a bg-spare worker several levels below the session's actual
lock-owning claude process (hook shell -> claude bg-spare ->
claude bg-pty-host -> claude -> claude(lock)), so the first match was
the bg-spare worker, not the lock owner. fm_session_lock_owned_by_self()
then never matched state/.lock, and the Claude Stop auto-arm silently
treated its own primary session as an unrelated live owner and never
armed the watcher.

The walk now keeps going past a claude-named match, looking for a still
more ancestral claude-named match, and stops the instant a non-match
follows an already-found match (bounding it to a contiguous run rather
than the literal ancestry top, so an unrelated claude-named process
further up the real process tree is never mistaken for part of this
session's own nested chain). Every other harness keeps the original
first-match-wins behavior, since e.g. Pi's shared signed-wrapper
ancestry actually holds the session at the inner engine pid, not an
outer wrapper pid. Hop limit raised from 8 to 16 to cover the deeper
bg-spare chain.

* no-mistakes(review): Add nested-claude-ancestry regression test; fix nudge doc depth claim

* no-mistakes: apply CI fixes

* fix: conferma l'avvio del watcher su Windows/MSYS (kunchenguid#1212)

* fix: confirm watcher startup on MSYS

* no-mistakes(review): gate MSYS arm ready timeout, cache uname, harden locale test

* no-mistakes(review): validate OpenCode ready timeout, make uname cache internal

* fix(spawn): forward CLAUDE_CONFIG_DIR to claude crewmates (kunchenguid#1195)

* fix(spawn): forward firstmate's CLAUDE_CONFIG_DIR to claude crewmates

Crewmate panes are created by a long-lived tmux/herdr daemon that does not
inherit firstmate's current environment. When firstmate runs under a non-default
CLAUDE_CONFIG_DIR (for example a work-vs-personal subscription split), a bare
`claude` in the crewmate pane fell back to the default ~/.claude store and
launched unauthenticated, blocking the crewmate before it could do any work.

fm-spawn now prefixes the claude launch with firstmate's own resolved
CLAUDE_CONFIG_DIR when set, so the crewmate uses the same credential/config
store firstmate is authenticated with. An unset value is the single-store
default and adds no prefix; non-claude harnesses are unaffected.

Adds three tests in fm-spawn-dispatch-profile.test.sh (forwarded-when-set,
omitted-when-unset, non-claude-ignored) and pins CLAUDE_CONFIG_DIR in the test
helper so launch assertions no longer depend on the developer's environment.

* no-mistakes: apply CI fixes

* fix: preserve dispatch identity across authentication checks (kunchenguid#1233)

* fix: preserve dispatch harness identity

* no-mistakes(review): Fix Grok counterfactual tuple validation

* no-mistakes(document): Scope dispatch authentication to selected tuple

* fix: restore dispatch instruction budget

* no-mistakes(review): Scope dispatch authentication after candidate selection

* fix(bin): normalize relative durable paths (kunchenguid#1256)

* fix(bin): handle dash-leading harness process names (#2)

* fix: handle dash-leading harness process names

* no-mistakes(review): Make dash-leading harness regression hermetic

* fix: preserve secondmate reply routes across relative homes

Resolve relative home, data, and state inputs before durable charter generation, and fail when caller-relative directories cannot be resolved.

Use absolute paths at the related spawn, AFK daemon, and X-mode cross-process handoffs so later processes cannot reinterpret them from another working directory.

* no-mistakes(review): Preserve absolute overrides and normalize relative durable paths

* no-mistakes(review): Normalize relative home before deriving durable paths

* no-mistakes(document): Document relative durable-path normalization

* no-mistakes(review): Captain: Ignore inherited CDPATH during relative path normalization

* no-mistakes(lint): Fix empty CDPATH assignments for ShellCheck

* refactor(skills): make Bearings chat-only by default (kunchenguid#1136)

* Add internal status skill

* no-mistakes(document): register /status skill in documentation-audiences inventory

* no-mistakes(lint): replace grep|wc -l with grep -c in status skill test

* test: silence literal status skill patterns

* Refactor bearings default to chat-only

---------

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

* Clarify follow-up routing during validation (kunchenguid#1277)

* fix: honor concrete approval for project operations (kunchenguid#1272)

* docs: add captain-approved project operation exception to hard rule 1

Firstmate stays read-only over projects by default, but when the captain
clearly approves a concrete project operation and scope in the moment,
firstmate may perform exactly that approved operation with its own tools.
The approval is never inferred, broadened, or standing, and it does not
relax the existing force, discard, unlanded-work, or merge-authority
boundaries.

* no-mistakes(review): Clarify captain-approved project operation boundaries

* no-mistakes(document): Clarify captain-approved project operation scope

* docs: cover directories and preserve the operation-or-scope alternative

Widen the captain-approved project operation exception in AGENTS.md to
files or directories, and restore the explicit operation-or-scope
alternative that a prior pipeline auto-fix had collapsed into "and".

Rework project-management SKILL.md's Remove section, which previously
told firstmate to refuse project removal until a guarded helper existed;
that helper was never built, so the text directly contradicted the new
instruction-only exception. It now points at the exception plus the
existing removal preflight it still requires unchanged.

Update the one instruction-owners test assertion that hard-coded the
sentence removed above, so the suite tracks current, not obsolete, text.

* docs: add captain-approved project operation exception to hard rule 1

Firstmate stays read-only over projects by default, but when the captain
clearly approves a concrete project operation and scope in the moment,
firstmate may perform exactly that approved operation with its own tools.
The approval is never inferred, broadened, or standing, and it does not
relax the existing force, discard, unlanded-work, or merge-authority
boundaries.

* no-mistakes(review): Clarify captain-approved project operation boundaries

* no-mistakes(document): Clarify captain-approved project operation scope

* docs: cover directories and preserve the operation-or-scope alternative

Widen the captain-approved project operation exception in AGENTS.md to
files or directories, and restore the explicit operation-or-scope
alternative that a prior pipeline auto-fix had collapsed into "and".

Rework project-management SKILL.md's Remove section, which previously
told firstmate to refuse project removal until a guarded helper existed;
that helper was never built, so the text directly contradicted the new
instruction-only exception. It now points at the exception plus the
existing removal preflight it still requires unchanged.

Update the one instruction-owners test assertion that hard-coded the
sentence removed above, so the suite tracks current, not obsolete, text.

* no-mistakes(review): Align project removal preflight with approved exception

* no-mistakes(document): Align project removal documentation with approved exception

* fix: restore removal test byte-for-byte and preserve the default sentence

tests/fm-instruction-owners.test.sh had been changed to assert different
text; restore it byte-for-byte to origin/main. project-management SKILL.md's
Remove section now keeps the exact default "Never issue a raw removal
command from Firstmate." sentence that test still asserts, immediately
followed by the already-approved captain-operation-or-scope exception, so
the default and the exception both stay explicit and consistent.

* no-mistakes(document): Align project-write boundary documentation

* fix(skills): route new project intake through secondmate scopes (kunchenguid#1275)

* Route project intake through secondmate scopes

* no-mistakes(test): Guard all main-home project registry mutations

* no-mistakes(document): Consolidate secondmate routing documentation

* no-mistakes: apply CI fixes

* Restore new-project routing scope

* no-mistakes(document): Clarify secondmate routing for new-project intake

* no-mistakes: apply CI fixes

* fix: scope validation corrections by accepted behavior (kunchenguid#1281)

* fix: scope validation corrections by accepted behavior

* no-mistakes(review): Classify stale delivery evidence as an autonomous correction

* test: replace source assertions with behavioral coverage (kunchenguid#1282)

* test: remove source-content assertions

* no-mistakes(review): Replace source assertions with runtime behavior coverage

* no-mistakes(review): Isolate Kimi task temp runtime coverage

* no-mistakes(document): Refresh test cleanup documentation

* no-mistakes: apply CI fixes

* fix(watch): escalate busy workers with no completed turn (kunchenguid#1286)

* fix(watch): bound how long a busy pane may run with no completed turn

A busy pane (backend busy state or the harness's rendered footer) was
unconditional, unbounded proof of liveness in every escalation path, so a
hung foreground tool call behind a busy signature could run for hours
undetected (2026-07 hibit-agent-focus-nonsteal-r1 incident: a catastrophic-
backtracking regex hung one bash call for 25h behind an unchanging
"Working..." footer).

FM_BUSY_TURN_MAX_SECS (default 3600s) now bounds how long a busy pane may
run with no completed turn (state/<id>.turn-ended, or its spawn record
before any turn has completed). Past the bound, busy_turn_over_age routes
the pane through the existing wedge_timer_check, reusing the identical
stale reason, escalation counter, and demand-deep-inspection marker for
human inspection only - never an automatic interrupt, signal, or restart
of the worker or its tool process. A completed turn resets the age.

Reproduced end-to-end against the real installed Pi TUI: a foreground
`sleep 999999` bash call with no timeout renders the actual busy footer,
and two captures ~15s apart show the elapsed counter changing the pane
hash while the same turn stays unfinished. Running the pre-fix watcher
against the real captures showed it never starts a wedge timer no matter
how long the pane stays busy; the fixed watcher starts and escalates the
timer through the same mechanism, while the real hung process remained
untouched and alive throughout.

* no-mistakes(review): fix: parse enriched AFK stale reasons

* no-mistakes(review): fix: preserve enriched wedges during AFK supervision

* no-mistakes(review): fix: route all enriched AFK wedges

* no-mistakes(document): Clarify busy-turn age supervision documentation

* fix(gitignore): ignore config/ as a directory, not by exact filename (kunchenguid#1261)

A name-by-name list of config/ entries silently stops ignoring any new or
home-local file placed there, which makes the working tree read as dirty and
blocks guarded sync paths that refuse to touch a dirty home. AGENTS.md
already documents config/ as captain-private and gitignored as a category;
this makes .gitignore match that contract.

* fix(tests): replace source-content .gitignore assertion with behavioral coverage (kunchenguid#1304)

The second assertion in fm-gitignore-config.test.sh (added by kunchenguid#1261) greps
.gitignore for a specific spelling of the config/ ignore pattern. It fails
on a semantically equivalent pattern like config/** and does not prove Git
actually ignores anything, per the completed source-content-test audit.

Replace it with a real git check-ignore control test on a generated
unrelated path, and strengthen the existing directory-coverage test with
generated unpredictable direct and nested config/ paths.

* feat(decision-board): render the captain's daily decision board from the fleet snapshot

Adds bin/fm-decision-board.sh, a thin renderer over bin/fm-fleet-snapshot.sh in
the same shape as fm-fleet-view.sh and fm-bearings-snapshot.sh. It selects the
captain-owned open items the snapshot already normalizes - open backlog entries
with hold_kind=captain plus tasks with open ask-user decisions - merges an id
present in both into a single entry, splits them by whether his answer alone
releases the work, and orders longest-waiting first.

Markdown is the drop-in section for the morning packet, HTML is a standalone
on-demand surface, and JSON exposes the same model. An unreadable decision queue
exits 3 so it can never be mistaken for an empty board.

Colocated behavior tests cover source selection, the merge, the ready split
including the parked override, ordering, bounding with disclosure, all three
formats, HTML escaping of backlog text, and argument validation.

* docs(decision-board): state the verbatim-relay boundary in the script header

The board relays a durable record's own wording rather than paraphrasing it, so
the header now says why: rewording the question a captain is answering would be
inventing it. Section 9 translation is a duty of whoever writes the entry; the
renderer enforces only what it can carry honestly - project names instead of
paths, and plain group wording.

* no-mistakes(review): Fix decision numbering and malformed date handling

* no-mistakes(review): Fix config ignores, decision filtering, and date validation

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Daniel Kuykendall IV <[email protected]>
Co-authored-by: Trillium Smith <[email protected]>
Co-authored-by: Unknownzed <[email protected]>
Co-authored-by: lhalbert <[email protected]>
Co-authored-by: AG <[email protected]>
Co-authored-by: deeto15 <[email protected]>
Co-authored-by: Christopher McKay <[email protected]>
Co-authored-by: QuinnBot <[email protected]>
theaussie86 added a commit to theaussie86/firstmate that referenced this pull request Jul 31, 2026
Rebased onto current main and reconciled with two changes that landed
in the meantime.

- kunchenguid#1093 already restored the fm-brief.sh heredoc captures on main, so
  this branch keeps only the comment that records why those blocks must
  stay free of command substitution (issue kunchenguid#166).
- kunchenguid#1282 replaced source assertions with behavioral coverage, so the
  source-shape assertions this branch carried are dropped. The parse
  sweep is proven by behavior instead: it rejects the exact 3.2-only
  construct, and it resolves a linted root however the path is spelled.
- fm-lint.sh now owns the parse sweep, so the pre-push gate - not only
  the CI macOS lane - is the earliest boundary that catches a 3.2 parse
  defect.
- The sweep covers every root in the owner inventory rather than the bin
  roots alone, because the CI macOS lane parses whatever --list-files
  reports. A tests/ root that only 3.2 rejects would otherwise pass the
  gate and fail that lane; a new test holds that parity.
- fm-bootstrap.sh converts its remaining heredoc capture to the same
  read -r -d '' form, so prose there can contain apostrophes.
trillium pushed a commit to trillium/firstmate that referenced this pull request Jul 31, 2026
…#1282)

* test: remove source-content assertions

* no-mistakes(review): Replace source assertions with runtime behavior coverage

* no-mistakes(review): Isolate Kimi task temp runtime coverage

* no-mistakes(document): Refresh test cleanup documentation

* no-mistakes: apply CI fixes
sbracewell64 added a commit to sbracewell64/firstmate that referenced this pull request Jul 31, 2026
… briefs to read the marker (#9)

* feat(bin): add verified pi-signed runtime adapter (kunchenguid#1145)

* feat: add verified pi-signed adapter

* no-mistakes(review): Correct pi-signed maintainer verification date

* no-mistakes(review): Correct remaining pi-signed verification dates

* no-mistakes(review): Preserve authoritative pi-signed runtime identity

* no-mistakes(document): Document pi-signed shared adapter semantics

* no-mistakes: apply CI fixes

* fix(pi): rearm watcher across session transitions (kunchenguid#1166)

* fix(pi): rearm watcher across same-process session transitions

Pi emits session_shutdown for ordinary /new, /resume, and /fork replacement
as well as terminal quit. The primary watcher extension latched a module-level
stopping flag on every shutdown, so a replacement session in the same process
could not arm monitoring until Pi restarted.

Own arm authority per session generation so only the active live generation
may start, stop, or rearm the child. Replacement sessions can arm again without
restarting Pi, stale prior-generation callbacks cannot mutate the active cycle,
and real quit still blocks late rearm.

* no-mistakes(review): Preserve Pi generation isolation and exit cleanup

* no-mistakes(document): Correct Pi watcher transition documentation

* feat: route crew dispatch using quota-window pace (kunchenguid#1172)

* Consume quota-axi pace signals in dispatch profile array selection.

Add quota-array-dispatch as the single owner of the pace-aware candidate
choice, keep AGENTS.md to the intake boundary and load trigger, and cover
the acceptance cases with sanitized schemaVersion 3 fixtures.

* no-mistakes(review): Stop and report genuine quota dispatch ties

* no-mistakes(document): Document quota pace freshness and uncertainty

* fix: adapt Grok Stop continuation and harden endpoint cleanup (kunchenguid#1171)

* fix(grok): adapt Stop continuation to runtime capability

* no-mistakes(review): Reject ambiguous Grok Stop payloads

* no-mistakes(review): Reject duplicate Grok fields and accept spaced tmux sessions

* no-mistakes(review): Enforce exact tmux cleanup selectors

* no-mistakes(test): Fix historical tmux fixture and validate Grok Stop

* no-mistakes: apply CI fixes

* fix: restore stock macOS Bash 3.2 brief scaffolding (kunchenguid#1093)

* fix(brief): make DOD scaffolding parse-safe on stock macOS Bash 3.2

fm-brief.sh built each Definition-of-done block and the not-enabled
Herdr declaration with `VAR=$(cat <<EOF ... EOF)`. On Bash 3.2 (macOS
/bin/bash) the lexer scans for the command substitution's closing `)`
textually and tracks quote state through the heredoc body, so a single
apostrophe, unbalanced quote, or unbalanced paren in that prose breaks
parsing of the whole script. Every ship-brief scaffold (no-mistakes,
direct-PR, local-only) failed with `unexpected EOF while looking for
matching )`. Bash 4+ parses it fine, so the breakage stayed invisible
everywhere except stock macOS.

Replace all four command-substitution heredocs with
`IFS= read -r -d '' VAR <<EOF || true`. That removes the `$(...)`
wrapper and the entire defect class regardless of future prose, and
preserves the variable expansion the direct-PR and local-only bodies
need. `read` keeps the heredoc's trailing newline that `$(...)` used to
strip, so trim one newline to keep every generated brief byte-identical
to prior output.

Guard the structure, not one historical phrase: a new test rejects any
heredoc nested in a command substitution anywhere in fm-brief.sh, where
the old assertion pinned a single apostrophe phrase and so missed the
reintroduction. Extend the stock-macOS Bash CI job from parsing one
script to the whole maintained shell surface (bin/*.sh,
bin/backends/*.sh, tests/*.sh), matching bin/fm-lint.sh's canonical file
set so parse scope and lint scope cannot drift apart.

* no-mistakes(review): Captain: harden Bash structure and inventory guards

* no-mistakes(document): Align stock macOS Bash contributor checks

* no-mistakes(lint): Suppress deliberate SC2016 literal fixture warnings

* test: stabilize tmux teardown conformance baseline (kunchenguid#1209)

* fix(test): pin teardown tmux baseline to historical kill selectors

merge-base HEAD main collapses to HEAD after the exact-selector change
lands on the default branch, so the old teardown fixture was accidentally
exercising current exact targets. Resolve a content-historical permissive
tmux adapter from first-parent history and force that post-squash topology
inside the conformance case so main and feature branches keep the same
old-vs-new contract.

* no-mistakes(lint): Suppress intentional literal-pattern ShellCheck warnings

* docs: slim quota-array-dispatch to the pace selection core (kunchenguid#1197)

Cut the runtime skill to the compact pace-aware selection procedure plus
minimum owner pointers. Keep every distinct decision rule and move expanded
acceptance scenarios to deterministic fixture ownership assertions.

Size: 170/1374/10187 -> 63/544/4068 (about 63%/60%/60% reduction).

* feat(bin): inherit backend config into secondmate homes (kunchenguid#1219)

* Inherit config/backend into secondmate homes with deliberate-override preservation

Add backend to the shared inheritable config allowlist so launch, locked
bootstrap, and config-push converge a primary pin into secondmate homes as each
home local future-spawn default. Track last-inherited bytes in a private state
provenance marker so deliberate per-home overrides survive present and absent
primary convergence, keep --backend and FM_BACKEND stronger, and extend the
existing inheritance tests plus docs and skill claims.

* no-mistakes(review): Preserve equal unprovenanced backend overrides

* no-mistakes(review): Preserve symlink overrides and verify spawn precedence

* no-mistakes(review): Snapshot backend inheritance for consistent provenance

* no-mistakes(review): Simplify backend inheritance to primary-authoritative convergence

* no-mistakes(document): Document inherited backend override preservation

* fix: restore primary-authoritative backend inheritance after document regression

The document step reintroduced provenance and deliberate per-home override
semantics after review had simplified config/backend to plain primary-authoritative
allowlist membership. Restore the primary-always-wins path: present overwrites,
absent removes, no provenance marker, and docs/tests match that contract.

* no-mistakes(review): Add divergent backend precedence regression fixtures

* no-mistakes(document): Document backend inheritance contract

* fix(pi): remove Calm's upper version ceiling (kunchenguid#1226)

* fix(pi): remove Calm's exclusive Pi upper-version ceiling

tests/fm-calm-pi-extension.test.sh gated on a closed PI_COMPAT_VERSIONS
allowlist ("0.81.1 0.82.0") that refused any other installed Pi, and docs
described that range as "supported" rather than verified evidence. The
Calm CHANGELOG shows no API introduced at either version, so there is no
evidence for a real minimum; the presentation adapters already probe the
exact method they patch rather than checking a version.

Replace the allowlist with dated version evidence that never rejects a
newer Pi, and make each presentation adapter degrade independently with
a diagnostic if a future Pi removes its API, instead of the whole Calm
extension failing to load. Rewrite the feasibility doc's "Pi 0.81.1
through 0.82.0" phrasing to state it as verified evidence, not a
ceiling.

* no-mistakes(review): Probe missing Calm adapter exports safely

* no-mistakes(document): Document Calm's unbounded Pi compatibility

* fix(bin): allow session-local todo tools in the subagent guard (kunchenguid#1204)

* fix(guard): allow session-local todo tools in the primary

The delegation-shape guard denied TaskCreate and TaskUpdate because their
normalized names contain the `task` stem. Those tools write only the harness's
session-local todo list, which has no executor: it spawns no agent, allocates
no worktree, registers no schedule, and starts nothing that outlives the
session. That is not the unaccounted work the guard exists to stop, so the stem
match was a false positive, and the deny text told the primary to run
bin/fm-brief.sh and bin/fm-spawn.sh to create a todo entry.

Add a separately-reasoned PLAN_ONLY_TOOLS exact-name exclusion rather than
widening OBSERVE_ONLY_TOOLS, whose documented contract is tools that only
observe or stop existing work. Both lists stay exact-name so neither can widen
by substring.

Tests cover the two allowed names and six near-miss names that a substring or
shortened-stem widening would release; both mutations were watched red.

* no-mistakes(review): drop session-local todo tools from recommended deny list

* no-mistakes: apply CI fixes

* fix(session-lock): resolve Claude bg-spare ancestry to the outermost claude pid (kunchenguid#1206)

* fix(session-lock): resolve Claude bg-spare ancestry to the outermost claude pid

fm_harness_ancestry_pid() previously returned the first ancestor process
whose command matched a verified harness name. Claude Code's Stop hook
fires as a bg-spare worker several levels below the session's actual
lock-owning claude process (hook shell -> claude bg-spare ->
claude bg-pty-host -> claude -> claude(lock)), so the first match was
the bg-spare worker, not the lock owner. fm_session_lock_owned_by_self()
then never matched state/.lock, and the Claude Stop auto-arm silently
treated its own primary session as an unrelated live owner and never
armed the watcher.

The walk now keeps going past a claude-named match, looking for a still
more ancestral claude-named match, and stops the instant a non-match
follows an already-found match (bounding it to a contiguous run rather
than the literal ancestry top, so an unrelated claude-named process
further up the real process tree is never mistaken for part of this
session's own nested chain). Every other harness keeps the original
first-match-wins behavior, since e.g. Pi's shared signed-wrapper
ancestry actually holds the session at the inner engine pid, not an
outer wrapper pid. Hop limit raised from 8 to 16 to cover the deeper
bg-spare chain.

* no-mistakes(review): Add nested-claude-ancestry regression test; fix nudge doc depth claim

* no-mistakes: apply CI fixes

* fix: conferma l'avvio del watcher su Windows/MSYS (kunchenguid#1212)

* fix: confirm watcher startup on MSYS

* no-mistakes(review): gate MSYS arm ready timeout, cache uname, harden locale test

* no-mistakes(review): validate OpenCode ready timeout, make uname cache internal

* fix(spawn): forward CLAUDE_CONFIG_DIR to claude crewmates (kunchenguid#1195)

* fix(spawn): forward firstmate's CLAUDE_CONFIG_DIR to claude crewmates

Crewmate panes are created by a long-lived tmux/herdr daemon that does not
inherit firstmate's current environment. When firstmate runs under a non-default
CLAUDE_CONFIG_DIR (for example a work-vs-personal subscription split), a bare
`claude` in the crewmate pane fell back to the default ~/.claude store and
launched unauthenticated, blocking the crewmate before it could do any work.

fm-spawn now prefixes the claude launch with firstmate's own resolved
CLAUDE_CONFIG_DIR when set, so the crewmate uses the same credential/config
store firstmate is authenticated with. An unset value is the single-store
default and adds no prefix; non-claude harnesses are unaffected.

Adds three tests in fm-spawn-dispatch-profile.test.sh (forwarded-when-set,
omitted-when-unset, non-claude-ignored) and pins CLAUDE_CONFIG_DIR in the test
helper so launch assertions no longer depend on the developer's environment.

* no-mistakes: apply CI fixes

* fix: preserve dispatch identity across authentication checks (kunchenguid#1233)

* fix: preserve dispatch harness identity

* no-mistakes(review): Fix Grok counterfactual tuple validation

* no-mistakes(document): Scope dispatch authentication to selected tuple

* fix: restore dispatch instruction budget

* no-mistakes(review): Scope dispatch authentication after candidate selection

* fix(bin): normalize relative durable paths (kunchenguid#1256)

* fix(bin): handle dash-leading harness process names (#2)

* fix: handle dash-leading harness process names

* no-mistakes(review): Make dash-leading harness regression hermetic

* fix: preserve secondmate reply routes across relative homes

Resolve relative home, data, and state inputs before durable charter generation, and fail when caller-relative directories cannot be resolved.

Use absolute paths at the related spawn, AFK daemon, and X-mode cross-process handoffs so later processes cannot reinterpret them from another working directory.

* no-mistakes(review): Preserve absolute overrides and normalize relative durable paths

* no-mistakes(review): Normalize relative home before deriving durable paths

* no-mistakes(document): Document relative durable-path normalization

* no-mistakes(review): Captain: Ignore inherited CDPATH during relative path normalization

* no-mistakes(lint): Fix empty CDPATH assignments for ShellCheck

* refactor(skills): make Bearings chat-only by default (kunchenguid#1136)

* Add internal status skill

* no-mistakes(document): register /status skill in documentation-audiences inventory

* no-mistakes(lint): replace grep|wc -l with grep -c in status skill test

* test: silence literal status skill patterns

* Refactor bearings default to chat-only

---------

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

* Clarify follow-up routing during validation (kunchenguid#1277)

* fix: honor concrete approval for project operations (kunchenguid#1272)

* docs: add captain-approved project operation exception to hard rule 1

Firstmate stays read-only over projects by default, but when the captain
clearly approves a concrete project operation and scope in the moment,
firstmate may perform exactly that approved operation with its own tools.
The approval is never inferred, broadened, or standing, and it does not
relax the existing force, discard, unlanded-work, or merge-authority
boundaries.

* no-mistakes(review): Clarify captain-approved project operation boundaries

* no-mistakes(document): Clarify captain-approved project operation scope

* docs: cover directories and preserve the operation-or-scope alternative

Widen the captain-approved project operation exception in AGENTS.md to
files or directories, and restore the explicit operation-or-scope
alternative that a prior pipeline auto-fix had collapsed into "and".

Rework project-management SKILL.md's Remove section, which previously
told firstmate to refuse project removal until a guarded helper existed;
that helper was never built, so the text directly contradicted the new
instruction-only exception. It now points at the exception plus the
existing removal preflight it still requires unchanged.

Update the one instruction-owners test assertion that hard-coded the
sentence removed above, so the suite tracks current, not obsolete, text.

* docs: add captain-approved project operation exception to hard rule 1

Firstmate stays read-only over projects by default, but when the captain
clearly approves a concrete project operation and scope in the moment,
firstmate may perform exactly that approved operation with its own tools.
The approval is never inferred, broadened, or standing, and it does not
relax the existing force, discard, unlanded-work, or merge-authority
boundaries.

* no-mistakes(review): Clarify captain-approved project operation boundaries

* no-mistakes(document): Clarify captain-approved project operation scope

* docs: cover directories and preserve the operation-or-scope alternative

Widen the captain-approved project operation exception in AGENTS.md to
files or directories, and restore the explicit operation-or-scope
alternative that a prior pipeline auto-fix had collapsed into "and".

Rework project-management SKILL.md's Remove section, which previously
told firstmate to refuse project removal until a guarded helper existed;
that helper was never built, so the text directly contradicted the new
instruction-only exception. It now points at the exception plus the
existing removal preflight it still requires unchanged.

Update the one instruction-owners test assertion that hard-coded the
sentence removed above, so the suite tracks current, not obsolete, text.

* no-mistakes(review): Align project removal preflight with approved exception

* no-mistakes(document): Align project removal documentation with approved exception

* fix: restore removal test byte-for-byte and preserve the default sentence

tests/fm-instruction-owners.test.sh had been changed to assert different
text; restore it byte-for-byte to origin/main. project-management SKILL.md's
Remove section now keeps the exact default "Never issue a raw removal
command from Firstmate." sentence that test still asserts, immediately
followed by the already-approved captain-operation-or-scope exception, so
the default and the exception both stay explicit and consistent.

* no-mistakes(document): Align project-write boundary documentation

* fix(skills): route new project intake through secondmate scopes (kunchenguid#1275)

* Route project intake through secondmate scopes

* no-mistakes(test): Guard all main-home project registry mutations

* no-mistakes(document): Consolidate secondmate routing documentation

* no-mistakes: apply CI fixes

* Restore new-project routing scope

* no-mistakes(document): Clarify secondmate routing for new-project intake

* no-mistakes: apply CI fixes

* fix: scope validation corrections by accepted behavior (kunchenguid#1281)

* fix: scope validation corrections by accepted behavior

* no-mistakes(review): Classify stale delivery evidence as an autonomous correction

* test: replace source assertions with behavioral coverage (kunchenguid#1282)

* test: remove source-content assertions

* no-mistakes(review): Replace source assertions with runtime behavior coverage

* no-mistakes(review): Isolate Kimi task temp runtime coverage

* no-mistakes(document): Refresh test cleanup documentation

* no-mistakes: apply CI fixes

* fix(watch): escalate busy workers with no completed turn (kunchenguid#1286)

* fix(watch): bound how long a busy pane may run with no completed turn

A busy pane (backend busy state or the harness's rendered footer) was
unconditional, unbounded proof of liveness in every escalation path, so a
hung foreground tool call behind a busy signature could run for hours
undetected (2026-07 hibit-agent-focus-nonsteal-r1 incident: a catastrophic-
backtracking regex hung one bash call for 25h behind an unchanging
"Working..." footer).

FM_BUSY_TURN_MAX_SECS (default 3600s) now bounds how long a busy pane may
run with no completed turn (state/<id>.turn-ended, or its spawn record
before any turn has completed). Past the bound, busy_turn_over_age routes
the pane through the existing wedge_timer_check, reusing the identical
stale reason, escalation counter, and demand-deep-inspection marker for
human inspection only - never an automatic interrupt, signal, or restart
of the worker or its tool process. A completed turn resets the age.

Reproduced end-to-end against the real installed Pi TUI: a foreground
`sleep 999999` bash call with no timeout renders the actual busy footer,
and two captures ~15s apart show the elapsed counter changing the pane
hash while the same turn stays unfinished. Running the pre-fix watcher
against the real captures showed it never starts a wedge timer no matter
how long the pane stays busy; the fixed watcher starts and escalates the
timer through the same mechanism, while the real hung process remained
untouched and alive throughout.

* no-mistakes(review): fix: parse enriched AFK stale reasons

* no-mistakes(review): fix: preserve enriched wedges during AFK supervision

* no-mistakes(review): fix: route all enriched AFK wedges

* no-mistakes(document): Clarify busy-turn age supervision documentation

* fix(gitignore): ignore config/ as a directory, not by exact filename (kunchenguid#1261)

A name-by-name list of config/ entries silently stops ignoring any new or
home-local file placed there, which makes the working tree read as dirty and
blocks guarded sync paths that refuse to touch a dirty home. AGENTS.md
already documents config/ as captain-private and gitignored as a category;
this makes .gitignore match that contract.

* fix(tests): replace source-content .gitignore assertion with behavioral coverage (kunchenguid#1304)

The second assertion in fm-gitignore-config.test.sh (added by kunchenguid#1261) greps
.gitignore for a specific spelling of the config/ ignore pattern. It fails
on a semantically equivalent pattern like config/** and does not prove Git
actually ignores anything, per the completed source-content-test audit.

Replace it with a real git check-ignore control test on a generated
unrelated path, and strengthen the existing directory-coverage test with
generated unpredictable direct and nested config/ paths.

* feat: bound and consolidate startup memory during stow (kunchenguid#1303)

* Add bounded startup memory curation

* no-mistakes(review): Record reproducible stow verification evidence

* no-mistakes(review): Validate inherited secondmate stow evidence

* no-mistakes(document): Document editable startup-memory budget propagation

* feat(bin): mark crewmate and scout steers as from-firstmate

A steer lands in the receiving agent's own chat, where nothing else told
firstmate's instructions apart from a human typing into that pane. The gap
was proven in both directions on 2026-07-26: the captain opened a crewmate
pane believing it was firstmate and issued cross-lane instructions there, and
a Pi crewmate at an ask-user gate addressed "Captain, ..." into its own pane
and sat parked - nobody reads a crewmate pane, and a parked pipeline emits no
wake, so that direction fails silently. AGENTS.md section 1 rule 4 already
required workers to honor a distinction the system gave them no means to make.

fm-send now applies the existing from-firstmate carrier to every text steer
whose target resolves through this home's meta, not just kind=secondmate.
A crewmate or scout carries the marker alone; the corr= correlation token and
the parent pending-reply record stay secondmate-only, because a crewmate
already answers on its own status file. Explicit backend targets and the
--key path are unchanged.

Command-shaped text is the one exclusion. A harness recognizes a slash
command, or a codex $<skill> invocation, only at the very start of the
composer line, so any prefix silently demotes it to prose. Verified on claude
2.1.220 and pi 0.82.0: with either marker shape prepended, /no-mistakes stops
opening the completion popup entirely and would submit as ordinary text.
Crewmate sends of that shape therefore stay unmarked and byte-identical, which
also keeps every documented popup hazard out of this change's blast radius:
the only bytes that move are plain text no harness parses specially. The
exclusion deliberately does not reach a secondmate, whose marker is what
creates its reply guarantee.

The ship and scout scaffolds gain a "Who is speaking to you" section teaching
the reader side: marked is firstmate, unmarked is a human who may believe the
pane is firstmate, self-identify as a worker on this task before acting, and
escalation is always the status file. AGENTS.md states the provenance
principle once in rule 4; the away-mode stub and the secondmate charter keep
their own distinct consequences.

* no-mistakes(review): align brief's unmarked-message exception wording to fm-send predicate

* no-mistakes(test): fix stale corr-less assertion in Pi/Herdr marker e2e

* no-mistakes(document): generalize task-selector marker context to from-firstmate

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Christopher McKay <[email protected]>
Co-authored-by: Daniel Kuykendall IV <[email protected]>
Co-authored-by: Trillium Smith <[email protected]>
Co-authored-by: Unknownzed <[email protected]>
Co-authored-by: lhalbert <[email protected]>
Co-authored-by: AG <[email protected]>
Co-authored-by: deeto15 <[email protected]>
ammar00sheikh added a commit to ammar00sheikh/firstmate that referenced this pull request Jul 31, 2026