Repository navigation
Conversation
no-mistakes renders the --intent string verbatim into the PR body, so intent written for an internal audience is published to the repo's maintainers. Ship briefs for the two PR-opening modes now state that the body is public, reviewer-facing writing, and require the crewmate to read the live body back from the API before reporting done. Add bin/fm-pr-body-check.sh: it fetches a live PR title and body and prints the lines that read as meta-instructions, second-person direction, internal vocabulary, or an agent co-author. It surfaces lines to read rather than a count, and carries the REST API repair path, because gh pr edit --body can silently no-op.
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#500 at |
|
Automated reminder: this PR still looks blocked on a rebase or merge conflict fix. If you are still interested, please rebase onto the current base branch, resolve the conflict, and push. If I do not hear back, I may close this as inactive. |
|
I am closing this because it has been waiting on a rebase or merge-conflict fix since 2026-07-16, and I have not seen a comment or push since then. If you still want to keep working on this, please reopen it or open a new PR and mention this one. Happy to take another look when there is an update. |
Intent
Firstmate's ship briefs have a crewmate hand no-mistakes an --intent string, and no-mistakes renders that string verbatim into the PR body. The brief never said so. Intent text written as a private working note could therefore be published to a repository's maintainers, and the agent could report success without ever reading what it had published.
This makes the PR body an explicit part of the brief contract for the two delivery modes that open a PR. The body is public, reviewer-facing writing: no meta-instructions addressed to a reviewer or a bot, no second-person direction, no internal project vocabulary, no agent co-author. The brief also requires reading the published body back from the API before the work may be reported as finished. Local-only briefs, which open no PR, are unchanged.
bin/fm-pr-body-check.sh backs that step up. It fetches a pull request's live title and body and prints every line that reads as a meta-instruction, second-person direction, internal vocabulary, or an agent co-author. It prints the lines rather than a count, since matches need judgment and a repository legitimately names itself in its own PRs. It also documents the REST API path for rewriting a body, because gh pr edit --body can fail without changing anything and without reporting an error.
Tests cover the scaffolded briefs for every delivery mode and the new script.
What Changed
no-mistakes,direct-PR) now carry an explicit public-PR-body contract inbin/fm-brief.sh: the body is reviewer-facing writing with no meta-instructions, no second-person direction, no internal vocabulary, and no agent co-author, and the crewmate must read the published body back from the API and clear it before reportingdone.local-onlybriefs, which open no PR, are unchanged.bin/fm-pr-body-check.sh, which fetches a PR's live title and body and prints every line that reads as a meta-instruction, second-person direction, internal vocabulary, or an agent co-author, rather than a count, since matches need judgment. It skips the pipeline-generated## Pipelinefooter, exits 2 rather than reportingcleanwhen the body could not be fetched or a pattern scan errors, and documents the REST path for rewriting a body (gh pr edit --bodycan fail silently).bin/fm-pr-check.shso firstmate looks at the published body independently of the brief, deduping repeat prints for the same PR through a newstate/<id>.body-scanrecord thatbin/fm-teardown.shcleans up; the scan never blocks the PR-ready or merge path. Documented inAGENTS.md,docs/architecture.md, anddocs/scripts.md, with new suites for the brief scaffolds, the new script, and the PR-check wiring.Risk Assessment
✅ Low: The change is additive and well-bounded: a new surface-only scanner plus brief/doc text, with the scan explicitly non-blocking on both the PR-ready and merge paths and thorough tests pinning the clean, flagged, error, empty-fetch, footer, and dedupe behaviors; the two remaining items are cosmetic/recoverability nits.
Testing
The configured suite passed as baseline, and I re-ran the six suites touching this change (fm-pr-body-check, fm-brief, fm-pr-check, fm-pr-merge, fm-teardown, fm-bootstrap) with all green. Because passing tests alone do not show the leak being caught, I reproduced the real failure by stubbing the GitHub API with a PR whose body carried a crewmate's private working note rendered verbatim from --intent, then drove the actual scripts: the body check printed each offending line with its reason while leaving no-mistakes' generated Pipeline footer unscanned, fm-pr-check surfaced that scan at PR-ready, stayed quiet on an unchanged re-scan, and reported an unfetchable body as unchecked rather than clean, and the brief scaffold carried the public-writing contract and read-it-back-before-done step for no-mistakes and direct-PR but not local-only. CLI transcripts for all of it are in the evidence directory, and the working tree is clean.
Evidence: Leaked --intent text flagged in a live PR body (CLI transcript)
$ bin/fm-pr-body-check.sh https://github.com/acme/webapp/pull/482 FLAGGED (live PR https://github.com/acme/webapp/pull/482) - read each line below and judge it; a hit is not a verdict. line 3 [meta-instruction internal vocabulary]: firstmate task auth-rot-k3: the captain asked for this, do not re-raise the TTL choice, it was already decided in the brief. line 4 [second-person direction internal vocabulary]: You should not flag the missing test for the legacy path as surprising - out of scope for this ship task. line 9 [agent co-author]: Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> These lines are PUBLIC: a maintainer who knows nothing about how this change was produced will read them. Some matches are legitimate (a PR about firstmate names firstmate), so read them - do not act on the count. To rewrite a dirty body, do NOT usegh pr edit --body: it can silently NO-OP. gh api -X PATCH repos/OWNER/REPO/pulls/<n> -F body=@<file> Then re-run this check against the live PR. [exit 1]Evidence: fm-pr-check reads the published body back: flag, dedupe on re-scan, clean after repair, loud failure on an unreadable body
$ bin/fm-pr-check.sh auth-rot-k3 https://github.com/acme/webapp/pull/482 armed: state/auth-rot-k3.check.sh polls https://github.com/acme/webapp/pull/482 FLAGGED (live PR ...) - read each line below and judge it; a hit is not a verdict. line 3 [meta-instruction internal vocabulary]: firstmate task auth-rot-k3: the captain asked for this, do not re-raise the TTL choice, it was already decided in the brief. $ FM_PR_CHECK_CONTEXT=merge bin/fm-pr-check.sh auth-rot-k3 <same url> PR body scan: same flagged lines as the last check of this PR; nothing new. Read them in state/auth-rot-k3.body-scan. $ # after the body is rewritten via the REST API: clean (live PR https://github.com/acme/webapp/pull/482): nothing flagged. $ # when the API returns nothing: PR BODY SCAN FAILED (exit 2): the published body was NOT checked - read it yourself before relaying the PR.Evidence: Public-PR contract present for no-mistakes and direct-PR briefs, absent for local-only
Evidence: Full public-PR section of a scaffolded no-mistakes brief, including the verify-before-done step
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-pr-body-check.sh:92- bin/fm-pr-body-check.sh:92 is the only script in bin/ that requires bash 4:declare -A LABELS=()/declare -A TEXTS=(). On macOS's stock /bin/bash (3.2), which the repo's own backend evidence shows is a primary environment,declare -Afails with 'invalid option' andset -euaborts the script. Additionally, on any bash older than 4.4,${!TEXTS[@]}at line 109 tripsnounsetwhen the associative array is empty, so a CLEAN body would exit 1 (the 'flagged' exit code) with an 'unbound variable' error instead of printing 'clean'. Because the brief now makes this script a mandatory pre-donestep for both PR-opening modes, this failure blocks the crewmate rather than degrading gracefully. The per-line label aggregation can be done with an indexed array or a single grep pass without associative arrays.bin/fm-pr-body-check.sh:66- bin/fm-pr-body-check.sh:66 capturesgh api ... 2>&1, which folds stderr into $TEXT on the SUCCESS path as well as the failure path. Any warning or deprecation notice gh writes to stderr becomes part of the text that is scanned and printed to the crewmate as if it were published PR body content, producing confusing false flags. Capture stderr to a separate variable/file so it is only used to build the exit-2 error message.bin/fm-brief.sh:299- The public-PR section tells the crewmate to repair a dirty body with rawgh api -X PATCH ...and warns offgh pr edit --body, while brief rule 3 (bin/fm-brief.sh:379) tells it to use gh-axi for all GitHub operations. Rawghis correct here (gh-axi exposes noapisubcommand), but the brief does not say so, so a crewmate following rule 3 may try to translate the command or stall. One clause noting that this specific repair intentionally bypasses gh-axi would close the gap.🔧 Fix: make PR-body check bash 3.2-safe and stderr-clean
3 issues (1 warning, 2 infos) still open:
bin/fm-pr-body-check.sh:90- Theinternal vocabularypattern includesno-mistakes, but the no-mistakes pipeline appends its own## Pipelinesection to every PR body it produces, containing the literal lineUpdates from [git push no-mistakes](https://github.com/kunchenguid/no-mistakes)(verified against this repo's live PR fix(teardown): keep state cleanup running when treehouse return fails #498). That line always matches, so in no-mistakes mode - the default delivery mode, and the one this check exists for because it publishes--intentverbatim -fm-pr-body-check.sh <url>can never exit 0 / printclean. The crewmate is left triaging a permanent false positive it cannot fix (the pipeline regenerates the footer), on every single ship. The pipeline footer is not the crewmate's writing and is not reviewer-facing prose it authored; consider scanning only the body above the pipeline-generated section (or excluding that known boilerplate) so a genuinely clean body reports clean and a real leak line stands out instead of arriving alongside guaranteed noise.bin/fm-pr-body-check.sh:89- Two of the nine patterns (second-person directionat line 89 andinternal vocabularyat line 90) rely on\bword boundaries, which are a GNU regex extension rather than POSIX ERE. The sibling commit deliberately made this script run on stock macOS bash 3.2, and that same environment ships BSD grep; if its regex engine treats\bas a literalb, both patterns silently stop matching and a dirty body reportsclean- the one failure mode this tool exists to prevent, and one no test would catch since the suite runs on GNU grep. Worth confirming on macOS; if\bis not honored, an anchored character-class form such as(^|[^[:alnum:]-])you (must|should|...)is portable across both greps.bin/fm-brief.sh:298- In no-mistakes mode the brief asks for two separatedone:appends:done: {summary}after the implementation commit (bin/fm-brief.sh:342, before any PR exists) anddone: PR {url} checks greenafter CI (line 354). The public-PR section says "Verify what you actually published, before you report done" and "rewrite it and re-verify before appendingdone:", which reads against the first, pre-PRdone:as easily as the final one. "Once the PR exists" partly mitigates it, but a crewmate that takes the instruction literally could stall trying to check a PR that does not exist yet. Naming the finaldone: PR {url} checks greenline explicitly in that sentence would remove the ambiguity.🔧 Fix: scope PR-body check above pipeline footer; portable boundaries
2 issues (1 warning, 1 info) still open:
bin/fm-pr-body-check.sh:133-done < <(grep -n -i -E -- "$regex" "$SCAN" || true)treats grep's exit 2+ (a real error: unsupported regex construct, unreadable file) identically to exit 1 (no match). If any pattern fails to compile under a different grep engine, that pattern silently contributes no hits; if every pattern errors, $HITS stays empty, the script printscleanand exits 0, and the crewmate reports done on a body it never actually read. That is the exact false-clean failure the sibling commit's portable-boundary work exists to prevent - it fixed the\binstance while leaving the general one open, and no test would catch it because the suite runs GNU grep. Capture the status (e.g. run grep into a temp file,st=$?, and[ "$st" -le 1 ] || { echo "error: pattern scan failed" >&2; exit 2; }) so a scanner malfunction exits 2 rather than reporting clean.bin/fm-pr-check.sh:22- The public-body contract is enforced only inside the crewmate brief. bin/fm-pr-check.sh is firstmate's PR-ready gate - it already callsgh pr viewfor the PR head and is the point where firstmate learns the PR URL - but it never invokes fm-pr-body-check.sh. A crewmate that skips or forgets the verify step still appendsdone: PR {url} checks green, and firstmate relays the PR to the captain without any independent look at the published body, so the incident this change is about could recur with the check present but unused. Running the scan from fm-pr-check.sh (surfacing flagged lines to firstmate, not blocking) would make the guard structural rather than brief-honor-based. Flagging rather than fixing since it may be a deliberate scope boundary.🔧 Fix: fail loudly on scan errors; scan PR body at pr-check
4 issues (1 warning, 3 infos) still open:
tests/fm-secondmate-safety.test.sh:44- Wiring fm-pr-body-check.sh into fm-pr-check.sh (bin/fm-pr-check.sh:52) gives fm-pr-check an unconditionalgh apicall. tests/fm-secondmate-safety.test.sh:44 invokes the real bin/fm-pr-check.sh with no fake gh on PATH (that case never installs a fakebin), so the suite now shells out to the live GitHub API forrepos/example/repo/pulls/1using whatever credentials the host has. The test still passes - fm-pr-check exits 0 regardless and stderr is sent to /dev/null - so the dependency is silent: it adds real network latency, and in a network-isolated sandbox it depends on gh failing fast rather than hanging. Add an exit-0ghstub to that case's PATH (fm_fakebin + fm_fake_exit0, as the other suites do) so the scan stays hermetic.bin/fm-pr-merge.sh:82- bin/fm-pr-merge.sh:82 calls fm-pr-check.sh, so the new published-body scan now also runs on the merge path. Two consequences worth a deliberate decision: under yolo (where firstmate runs fm-pr-check at PR-ready and then fm-pr-merge itself) the same flagged lines are printed twice, and a scan failure at merge time emits "the published body was NOT checked - read it yourself before relaying the PR" (bin/fm-pr-check.sh:57), which is misleading at a point where the PR is being merged rather than relayed. If the scan is meant to be a PR-ready gate only, fm-pr-merge could suppress it (e.g. an env flag fm-pr-check honors) rather than re-running it after the body has already been judged.bin/fm-brief.sh:279- The new comment above public_pr_section says "$INTENT_CLAUSE names the specific text that reaches the public body in that mode", but no INTENT_CLAUSE variable exists - the clause is passed as the function's first positional parameter (local intent_clause=$1). The comment sends a reader looking for a variable that was never introduced.bin/fm-pr-body-check.sh:115- The footer carve-out requires BOTH the exact heading## Pipelineand the exact generated lineUpdates from [git push no-mistakes]. That conjunction is deliberately conservative, and the failure direction is safe: if no-mistakes ever changes the footer's wording, the cut stops matching and every no-mistakes PR flags again (noisy) rather than silently hiding text (false clean). Noting the coupling so the noise is recognized as this, not as a new leak, if the pipeline's footer text ever changes.🔧 Fix: dedupe merge-path PR body scan output; stub gh in tests
3 infos still open:
bin/fm-pr-body-check.sh:102- Theinternal vocabularypattern matches bareharnessandworktree(andcaptain), which are ordinary English in most repos - "the test harness now retries three times", "build from a clean worktree" - not firstmate-internal leakage. Because fm-pr-check.sh now runs this scan on every PR-ready and every merge for every project in the fleet, any project whose PR prose legitimately uses those words will surface flagged lines on every single ship. That is the same steady-noise dynamic the pipeline-footer carve-out was added to eliminate (round 2: "a check that can never report clean is worse than no check"), reintroduced through pattern breadth rather than boilerplate. The precise terms (firstmate, crewmate, secondmate, scout task, ship task, task id, no-mistakes, the brief) carry almost all the signal; qualifying or dropping the two generic ones would keep the real leaks flagged without a recurring false positive on unrelated projects. Raising rather than changing it, since pattern breadth is a deliberate authorial choice ("deliberately broad: this is a prompt to read a line, not a classifier").bin/fm-pr-body-check.sh:81- On the live path, agh apicall that exits 0 but produces empty stdout yields an empty $TEXT, which scans to zero hits and printsclean (live PR ...): nothing flagged.with exit 0. That is the one remaining path where "clean" does not mean "the body was read" - the exact failure mode the header disclaims ("never a silent 'clean' on a body that was not read") and that the exit-2 and grep-error paths were hardened against in earlier rounds. It is not just theoretical: the exit-0 gh stubs in tests/fm-secondmate-safety.test.sh, tests/fm-pr-merge.test.sh, and tests/fm-teardown.test.sh all produce exactly this, so those suites are asserting against a vacuous "clean". Guarding the live path with a non-empty check (empty fetched text -> the exit-2 "could not fetch" path) closes it in one line; leave --file mode alone so an empty draft still scans as empty.AGENTS.md:99- fm-pr-check.sh introduces a new per-task state file,state/<id>.body-scan(the dedupe record for the published-body verdict), and fm-teardown.sh removes it on both the task and secondmate-child paths - but AGENTS.md section 2's state/ inventory, which enumerates every other per-task file (<id>.status,<id>.turn-ended,<id>.check.sh,<id>.meta,<id>.grok-turnend-token), does not list it. A one-line entry alongside<id>.check.shkeeps the inventory the single place a future session can learn what a stray state file is.🔧 Fix: tighten PR-body vocabulary; empty fetch is never clean
3 issues (1 warning, 2 infos) still open:
tests/fm-teardown.test.sh:101- The gh stubs in tests/fm-teardown.test.sh (make_case:101 and add_gh_pr_merged_for_head:223) only answerpr viewand fall through to a bareexit 0with empty stdout for everything else. Since 8c94579 added the empty-fetch guard,gh apireturning exit 0 with no output makes fm-pr-body-check.sh exit 2, so all three PR_CHECK invocations in that suite (lines 759, 767, 796) now take fm-pr-check.sh's failure branch and print "PR BODY SCAN FAILED (exit 2): the published body was NOT checked" to stderr. The assertions still pass because they only inspect stdout and the meta, so the suite silently exercises the failure path on every run and emits an alarm that reads like a real regression. The sibling suites (tests/fm-pr-merge.test.sh, tests/fm-secondmate-safety.test.sh) were given anapi)branch returning clean reviewer-facing prose in the same round; add the same branch to both gh stubs here.bin/fm-pr-check.sh:80- When the merge-path verdict matches state/<id>.body-scan, fm-pr-check.sh prints only "PR body scan: same flagged lines as the last check of this PR; already surfaced, nothing new to read." The dedupe record survives a firstmate restart, so a session that did not run the PR-ready check (restart, or a different session merging) sees the suppression message for lines it has never read, with no pointer to where they are. Naming the record path in that message (state/<id>.body-scan) makes the suppressed content recoverable in one read without reintroducing the duplicate print.bin/fm-brief.sh:293- The brief still lists captain, harness, worktree, scout, and ship as forbidden internal vocabulary, while 8c94579 deliberately removed harness/worktree/captain from the scanner's internal-vocabulary pattern to avoid fleet-wide false positives on ordinary English. This is a coherent split (the brief is the contract, the scanner is a noise-tuned prompt to read a line) and the meta-instruction pattern still catches "captain asked/decided/approved", so no change is needed - noting it so a future reader does not "fix" one to match the other.🔧 Fix: stub gh api in teardown tests; locate deduped body scan
2 infos still open:
bin/fm-pr-merge.sh:86- fm-pr-merge.sh runs fm-pr-check.sh (and therefore the published-body scan) and then proceeds to merge unconditionally in the same invocation. The scan's rationale in the header - "the last moment it can be fixed cheaply" - only holds if a human reads the output before the merge command runs, but here both happen in one command; under yolo firstmate merges without any pause. So the merge-time scan is in practice a post-hoc record of what was published, not a gate that can still prevent it. This is the non-blocking contract that was explicitly requested, so raising it rather than changing it: if the intent is that a flagged body at merge time can still be fixed, the merge path needs to stop on a flagged verdict (or require an explicit override) rather than print and continue.bin/fm-pr-check.sh:75- The print dedupe is keyed only on the URL plus the scan output, so it suppresses the flagged lines on ANY repeat invocation for the same PR, not just the merge path that the header and AGENTS.md describe. A second PR-ready run (a no-mistakes fix round, or a fresh session re-arming the merge poll) prints the pointer line instead of the lines. The 5b3df70 change naming state/<id>.body-scan in that message makes the content recoverable in one read, so this is a behavior note rather than a defect - flagging it so the wording in the header ("bin/fm-pr-merge.sh runs this script again at merge time... only the PRINT is deduped") is not later read as a guarantee that a PR-ready re-run always re-prints.🔧 Fix: describe merge-time PR-body scan honestly as post-hoc
2 infos still open:
bin/fm-pr-check.sh:99- On a scan failure (exit >= 2), fm-pr-check.sh runsrm -f "$RECORD", deleting state/<id>.body-scan. That file is the durable copy of the flagged lines, and the dedupe path explicitly tells the reader "Read them in state/<id>.body-scan". Failure scenario: the PR-ready scan flags a leaky intent line and records it; at merge time gh hits a transient network/auth failure, the scan exits 2, and the record is deleted - so a session (or a later session) that was pointed at that file finds nothing, and the only remaining copy of the surfaced lines is the earlier transcript. Deleting is not needed to avoid a stale dedupe: PREV is consulted only on the flagged (exit 1) branch, and a failed scan never produces a matching SCANNED value, so leaving the record in place is safe and keeps the content recoverable.bin/fm-pr-body-check.sh:81- The scanned text is.title + "\n" + (.body // ""), so line 1 is the PR title and every body line is reported one higher than its position in the body. The flagged output (line N [label]: ...) therefore does not line up with the file the crewmate is told to write back viagh api -X PATCH ... -F body=@<file>. Judgment is unaffected because each flagged line is printed in full - this is a note about the numbering, not a functional defect.🔧 **Test** - 1 issue found → auto-fixed ✅
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: simulate missing tools via command -v shim in tests
✅ Re-checked - no issues remain.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-pr-body-check.test.shbash tests/fm-brief.test.shbash tests/fm-pr-check.test.shbash tests/fm-pr-merge.test.shbash tests/fm-teardown.test.shbash tests/fm-bootstrap.test.shManual end-to-end: stubbedgh apiwith a realistic leaked-intent PR body, ranbin/fm-pr-body-check.sh https://github.com/acme/webapp/pull/482, and confirmed every meta-instruction, second-person, internal-vocabulary, and agent-co-author line was printed while the## Pipelinefooter was notManual end-to-end:bin/fm-pr-check.sh auth-rot-k3 <pr-url>against dirty, unchanged-repeat (FM_PR_CHECK_CONTEXT=merge), clean, and unfetchable bodies to confirm surface-then-dedupe and the never-a-false-clean failure pathManual end-to-end:bin/fm-brief.shscaffolded against a no-mistakes, a direct-PR, and a local-only project to confirm the public-PR contract and verify-before-done step appear only for the PR-opening modes✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: silence SC2016 on tests/lib.sh literal shim source
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.