Skip to content

fix(brief): identify firstmate's permanent clone structurally in ship brief isolation check - #9

Merged
digbycampbell merged 4 commits into
mainfrom
fm/fm-brief-isolation-wording
Aug 19, 2026
Merged

digbycampbell merged 4 commits into
mainfrom
fm/fm-brief-isolation-wording

Conversation

@digbycampbell

Copy link
Copy Markdown
Owner

Intent

Fix a false-positive isolation refusal in bin/fm-brief.sh's generated ship brief. Its phrase 'the primary checkout firstmate operates from' collided with the claude harness's own 'Primary working directory' session banner, so a careful crewmate refused to branch inside a perfectly good isolated worktree (observed 2026-08-19, cost a dispatch, would recur on every claude ship spawn). Reworded the isolation assertion to a STRUCTURAL test: firstmate's permanent clone lives under a firstmate home's projects/ directory checked out to its attached default branch, whereas a task worktree sits at a detached HEAD in a pool/managed path. The distinguishing wording avoids the bare colliding phrase 'primary working directory' in any casing. Guard safety is unchanged: a worker genuinely launched in the primary checkout still stops and appends the same blocked: status line - the fix removes the false positive without weakening the guard. Scope is wording plus its test only; did not restructure the brief, touch other generated sections, or alter bin/fm-spawn.sh's isolation mechanism. Extended tests/fm-brief.test.sh (existing pattern) with test_ship_isolation_instruction_avoids_harness_banner_collision, which asserts the isolation instruction is present, asserts the new structural distinguishing language (projects/ clone, detached HEAD) is present, and asserts the colliding phrase 'primary working directory' (any casing) is absent from the generated brief. Proved the test red against the old wording via git stash before implementing the fix, then green after. Searched bin/, .agents/skills/, and docs/ for other occurrences of the colliding phrase; found none elsewhere. shellcheck via bin/fm-lint.sh passed on both changed files; actionlint (workflow linting) was unavailable in this local sandbox so that portion of fm-lint.sh's default file-set run only ran in CI, not locally - a known local environment gap, not something newly introduced. Delivery mode: no-mistakes.

What Changed

  • Reworded the ship brief's isolation check in bin/fm-brief.sh to identify firstmate's permanent clone structurally — a default-branch, attached-HEAD checkout either under a firstmate home's projects/<repo> or, in a project-less self-repo domain, the home's own checkout — instead of by the phrase "the primary checkout firstmate operates from", which collided with the claude harness's "Primary working directory" session banner. The STOP path and its blocked: ... status line are unchanged in effect, now worded as blocked: launched in firstmate's permanent clone, not an isolated worktree.
  • Added test_ship_isolation_instruction_avoids_harness_banner_collision to tests/fm-brief.test.sh, asserting the generated brief keeps the isolation instruction and blocked-status safety line, carries the new structural cues (projects/<repo>, self-repo domain, attached vs detached HEAD), and contains no primary working directory/primary checkout phrasing in any casing.
  • Updated docs/architecture.md to describe the brief-side check as structural and to note that bin/fm-brief.sh owns the exact wording.

Risk Assessment

✅ Low: The change is confined to prompt wording in one generated brief section plus its test; the round-1 finding is genuinely addressed (both the projects/ and self-repo checkout shapes are now positive structural stop conditions, and the vacuous assertions were replaced by a negative regex that is truly red against the old wording), with no behavioral or safety regression - the blocked: status path is preserved.

Testing

I ran the targeted fm-brief test suite (all pass, including the new isolation-wording case), proved that case red against the base commit's wording and green against the fix, and then generated a real no-mistakes ship brief and read its rendered Setup section exactly as a crewmate would receive it — the isolation assertion is now structural (projects/<repo> clone or self-repo home checkout, attached HEAD on default branch, contrasted with the task worktree's detached HEAD), the colliding phrase is absent in any casing, and the blocked-status STOP instruction is intact. This is a generated-prompt text change with no rendered UI surface, so the reviewer-visible artifact is the generated brief excerpt rather than a screenshot. One note beyond the change's scope: the phrase "primary checkout" still appears widely in bin/ source comments and docs/ (e.g. docs/architecture.md:171 describing this very instruction), so the intent's "found none elsewhere" holds for agent-delivered brief text but not for the repo at large; none of those are delivered to a crewmate, so nothing here needs changing.

Evidence: Generated ship brief — Setup/isolation section (end-user surface)

Source: Generated ship brief — Setup/isolation section (end-user surface)

# Setup You are in a disposable git worktree of some-proj, at a detached HEAD on a clean default branch. Verify isolation before anything else, by structure, not by any directory label a harness banner prints - that label names where the harness started, not which checkout this is. Run pwd -P and git rev-parse --show-toplevel; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, sitting at a detached HEAD. Firstmate's own permanent clone is different in kind: it always sits on its default branch at an attached HEAD, never detached. In the common case it lives under a firstmate home's projects/&lt;repo&gt; directory; in a project-less self-repo domain there is no such clone and the firstmate home is itself that checkout, its own repository root on its default branch. The path check is authoritative: git rev-parse --git-dir and git rev-parse --git-common-dir can help inspect the repo, but they do not prove you are outside firstmate's permanent clone. If the top-level path sits under a firstmate home's projects/&lt;repo&gt; clone on its default branch, or is a firstmate home's own checkout on its default branch, or is otherwise not the detached-HEAD worktree you were launched in, STOP - do not branch or commit here - append blocked: launched in firstmate&#39;s permanent clone, not an isolated worktree to the status file and stop. 1. First action: create your branch: git checkout -b fm/demo-ship

# Setup
You are in a disposable git worktree of some-proj, at a detached HEAD on a clean default branch.

**Verify isolation before anything else, by structure, not by any directory label a harness banner prints - that label names where the harness started, not which checkout this is.** Run `pwd -P` and `git rev-parse --show-toplevel`; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, sitting at a detached HEAD. Firstmate's own permanent clone is different in kind: it always sits on its default branch at an attached HEAD, never detached. In the common case it lives under a firstmate home's `projects/<repo>` directory; in a project-less self-repo domain there is no such clone and the firstmate home is itself that checkout, its own repository root on its default branch.
The path check is authoritative: `git rev-parse --git-dir` and `git rev-parse --git-common-dir` can help inspect the repo, but they do not prove you are outside firstmate's permanent clone.
If the top-level path sits under a firstmate home's `projects/<repo>` clone on its default branch, or is a firstmate home's own checkout on its default branch, or is otherwise not the detached-HEAD worktree you were launched in, STOP - do not branch or commit here - append `blocked: launched in firstmate's permanent clone, not an isolated worktree` to the status file and stop.

1. First action: create your branch: `git checkout -b fm/demo-ship`
Evidence: Collision check on the generated brief
$ grep -inE "primary (working directory|checkout)" /tmp/nm-brief-home/data/demo-ship/brief.md
(none)
Evidence: Regression red/green proof
# with bin/fm-brief.sh restored to base ecb59e6:
not ok - brief-isolation-e1: isolation instruction must tell the worker to verify by structure, not by a harness banner's directory label

# with the fix applied:
ok - fm-brief.sh: isolation instruction avoids the harness banner's colliding phrase

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ⚠️ bin/fm-brief.sh:458 - The stop condition was narrowed from "the top-level path is the primary checkout" to "sits under a projects/ clone on its default branch". For a project-less domain, fm-brief.sh:202 states the subject repo is "the firstmate repo this home lives in, so it needs no separate clones under projects/" — that permanent checkout is NOT under projects/, so the new structural cue does not describe it. Safety is not lost (the residual "or is not the worktree you were launched in" clause still triggers a stop), but the primary distinguishing test the intent relies on is inapplicable to the self-repo case, weakening the signal exactly where a firstmate-repo ship worker runs. Consider adding the home-root firstmate clone alongside the projects/ clone as an attached-HEAD permanent checkout.
  • ℹ️ tests/fm-brief.test.sh:785 - The headline assertion grep -qi &#34;primary working directory&#34; never failed against the old wording — the pre-fix text said "primary checkout", not "primary working directory" — so it is a vacuous guard that cannot regress-detect the reported bug. Likewise assert_grep &#34;detached HEAD&#34; already matched pre-fix via the Setup line above. Only the projects/ assertion was actually red. The test is still net-useful as a lock against reintroducing the banner phrase, but its red-before/green-after evidence rests on one assertion, not the three claimed.

🔧 Fix: cover self-repo shape in ship brief isolation cue
2 infos still open:

  • ℹ️ tests/fm-brief.test.sh:775 - Three of the new assertions match long verbatim sentences from the prompt source ("not by any directory label a harness banner prints", "project-less self-repo domain", "or is a firstmate home's own checkout on its default branch"). The generated brief is a legitimate generated-output contract, so grepping it is allowed, but pinning whole sentences means any behavior-preserving rewording of the instruction breaks the test while the real contract (structural cue present, banner-colliding label absent) is unchanged. The genuinely load-bearing assertions are the negative primary (working directory|checkout) regex and the blocked-status line; the structural cues would be better asserted on short invariant tokens (e.g. projects/&lt;repo&gt;, attached HEAD, detached HEAD) as already done in the other two checks.
  • ℹ️ tests/fm-brief.test.sh:793 - The regression guard forbids primary (working directory|checkout) anywhere in the generated brief, which is broader than the intent's stated forbidden phrase ('primary working directory' in any casing). It is currently green and does capture the old wording (which said "primary checkout"), so this is the right red-before/green-after guard - just noting that it also bans an unrelated future use of "primary checkout" elsewhere in the ship brief.
✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-brief.test.sh — full fm-brief suite, all cases pass including the new test_ship_isolation_instruction_avoids_harness_banner_collision
  • Red/green proof: restored bin/fm-brief.sh from base commit ecb59e6 and re-ran the suite — new test reported not ok - brief-isolation-e1: isolation instruction must tell the worker to verify by structure, not by a harness banner&#39;s directory label; restored the fix and it passes
  • Manual end-user generation: FM_HOME=/tmp/nm-brief-home bin/fm-brief.sh demo-ship some-proj --mode no-mistakes and inspected the rendered # Setup section of the produced brief.md as a crewmate would receive it
  • grep -inE &#34;primary (working directory|checkout)&#34; brief.md on the generated brief → no matches (collision removed at the delivered-prompt level)
  • Verified the blocked-status safety line survives in the generated output: blocked: launched in firstmate&#39;s permanent clone, not an isolated worktree
  • grep -rlnE &#34;primary (checkout|working directory)&#34; tests/ to confirm no other brief-text test depends on the old wording
✅ **Document** - passed

✅ No issues found.

⏭️ **Lint** - skipped
  • ⚠️ linter found issues (exit code 127)
✅ **Push** - passed

✅ No issues found.

The claude harness prints its own "Primary working directory" banner
for wherever it starts. A crewmate misread the brief's "primary
checkout firstmate operates from" as referring to that banner and
refused to branch inside a genuinely isolated worktree. Reword the
isolation assertion to a structural test - firstmate's permanent
clone lives under a home's projects/ directory on its default branch
(attached HEAD), unlike a task worktree's detached HEAD - so it can't
be confused with any harness-printed directory label. The refusal
path for a genuine mis-launch is unchanged.
…worded brief

fm-tangle-guard.test.sh pinned the old blocked-status line and label
("launched in primary checkout") that bin/fm-brief.sh no longer emits
after the isolation wording was made structural. CI's portable-serial-4
shard caught the mismatch; local no-mistakes test step did not run this
file. Update the pin to the new text.
@digbycampbell

Copy link
Copy Markdown
Owner Author

Follow-up: CI's Behavior portable serial 4 shard caught a cross-file regression the local no-mistakes test step didn't run. tests/fm-tangle-guard.test.sh:test_brief_assertion_precedes_branch pinned the old isolation blocked-status line (blocked: launched in primary checkout, not an isolated worktree), which no longer matches the reworded brief's blocked: launched in firstmate's permanent clone, not an isolated worktree. Fixed the pin in commit 947eb43, verified both tests/fm-tangle-guard.test.sh and tests/fm-brief.test.sh pass locally, searched the repo for any other stale references (none found), and re-ran the pipeline. All 13 CI checks are now green.

@digbycampbell
digbycampbell merged commit 70615da into main Aug 19, 2026
13 checks passed
@digbycampbell
digbycampbell deleted the fm/fm-brief-isolation-wording branch August 23, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant