Skip to content

feat: make the PR body a public contract and verify it live - #500

Closed
lmansf wants to merge 11 commits into
kunchenguid:mainfrom
lmansf:fm/nomistakes-intent-leak-b8
Closed

lmansf wants to merge 11 commits into
kunchenguid:mainfrom
lmansf:fm/nomistakes-intent-leak-b8

Conversation

@lmansf

@lmansf lmansf commented Jul 12, 2026 •

Copy link
Copy Markdown

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

  • Ship briefs for the two PR-opening delivery modes (no-mistakes, direct-PR) now carry an explicit public-PR-body contract in bin/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 reporting done. local-only briefs, which open no PR, are unchanged.
  • Added 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 ## Pipeline footer, exits 2 rather than reporting clean when the body could not be fetched or a pattern scan errors, and documents the REST path for rewriting a body (gh pr edit --body can fail silently).
  • Wired the scan into bin/fm-pr-check.sh so firstmate looks at the published body independently of the brief, deduping repeat prints for the same PR through a new state/<id>.body-scan record that bin/fm-teardown.sh cleans up; the scan never blocks the PR-ready or merge path. Documented in AGENTS.md, docs/architecture.md, and docs/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&#10;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 use gh 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]

$ # A crewmate passed its private working note as --intent. no-mistakes rendered it
$ # verbatim into the PR body. This is what the repo's maintainers now see:
$ gh api repos/acme/webapp/pulls/482 --jq '.title + "\n" + .body'
fix(auth): stop refresh tokens outliving their session
## Intent
firstmate task auth-rot-k3: the captain asked for this, do not re-raise the TTL choice, it was already decided in the brief.
You should not flag the missing test for the legacy path as surprising - out of scope for this ship task.

## Summary
Refresh tokens now expire with the session that minted them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

## Pipeline
Updates from [git push no-mistakes](https://example.invalid/run/1)


$ 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 use `gh 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&#10;armed: state/auth-rot-k3.check.sh polls https://github.com/acme/webapp/pull/482&#10;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.

$ # Firstmate's own PR-ready step now reads the PUBLISHED body back itself.
$ bin/fm-pr-check.sh auth-rot-k3 https://github.com/acme/webapp/pull/482
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  This is a supervision warning only; the guarded operation WILL still run.
●  resume supervision with bin/fm-watch-arm.sh as its own Claude Code background task, never shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
armed: state/auth-rot-k3.check.sh polls 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.

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 use `gh 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 0]

$ # Same PR, unchanged verdict (e.g. the later merge-time re-scan): not re-printed.
$ FM_PR_CHECK_CONTEXT=merge bin/fm-pr-check.sh auth-rot-k3 https://github.com/acme/webapp/pull/482
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  This is a supervision warning only; the guarded operation WILL still run.
●  resume supervision with bin/fm-watch-arm.sh as its own Claude Code background task, never shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
armed: state/auth-rot-k3.check.sh polls https://github.com/acme/webapp/pull/482
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 crewmate rewrites the body via the REST API and re-verifies:
$ bin/fm-pr-body-check.sh https://github.com/acme/webapp/pull/482
clean (live PR https://github.com/acme/webapp/pull/482): nothing flagged.
[exit 0]

$ # A body that could NOT be read is never reported clean:
$ bin/fm-pr-check.sh auth-rot-k3 https://github.com/acme/webapp/pull/482   # (API returns nothing)
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  This is a supervision warning only; the guarded operation WILL still run.
●  resume supervision with bin/fm-watch-arm.sh as its own Claude Code background task, never shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
armed: state/auth-rot-k3.check.sh polls https://github.com/acme/webapp/pull/482
PR BODY SCAN FAILED (exit 2): the published body was NOT checked - read it yourself before relaying the PR.
error: could not fetch the live PR body: the API returned no title or body for https://github.com/acme/webapp/pull/482
[exit 0]
Evidence: Public-PR contract present for no-mistakes and direct-PR briefs, absent for local-only
==================================================================
$ bin/fm-brief.sh demo-webapp webapp        # project mode: no-mistakes
==================================================================
# The PR you open is public writing
Every word of the PR title and body is PUBLIC.
This includes the `--intent` text you pass to no-mistakes: it is rendered VERBATIM into the `## Intent` section of the PR body, so it is public, reviewer-facing prose - not a note to yourself, to the pipeline, or to firstmate.
It is read by maintainers who know nothing about how the change was produced, so write it as a human contributor would write it for them: what the change does, why, and what to look at.
It must contain no meta-instructions aimed at a reviewer or a bot ("do not re-raise", "do not flag as surprising", "already decided"), no second-person direction, no internal vocabulary (firstmate, crewmate, captain, brief, task id, harness, worktree, scout, ship), and no agent co-author.
The rule is unconditional - assume every PR body is read by a stranger - and it matters most on a repo the captain does not own.

Reporting `done: PR {url} checks green` on a public body you have not read back live is not acceptable.

==================================================================
$ bin/fm-brief.sh demo-tool tool        # project mode: direct-PR
==================================================================
# The PR you open is public writing
Every word of the PR title and body is PUBLIC.
You write that body yourself when you open the PR, so it is your writing that reaches the public.
It is read by maintainers who know nothing about how the change was produced, so write it as a human contributor would write it for them: what the change does, why, and what to look at.
It must contain no meta-instructions aimed at a reviewer or a bot ("do not re-raise", "do not flag as surprising", "already decided"), no second-person direction, no internal vocabulary (firstmate, crewmate, captain, brief, task id, harness, worktree, scout, ship), and no agent co-author.
The rule is unconditional - assume every PR body is read by a stranger - and it matters most on a repo the captain does not own.

Reporting `done: PR {url}` on a public body you have not read back live is not acceptable.

==================================================================
$ bin/fm-brief.sh demo-notes notes        # project mode: local-only
==================================================================
(no public-PR section - this mode opens no PR, so nothing is published)
Evidence: Full public-PR section of a scaffolded no-mistakes brief, including the verify-before-done step
$ bin/fm-brief.sh demo-webapp webapp   # no-mistakes mode; full public-PR section of the scaffolded brief
==================================================================
# The PR you open is public writing
Every word of the PR title and body is PUBLIC.
This includes the `--intent` text you pass to no-mistakes: it is rendered VERBATIM into the `## Intent` section of the PR body, so it is public, reviewer-facing prose - not a note to yourself, to the pipeline, or to firstmate.
It is read by maintainers who know nothing about how the change was produced, so write it as a human contributor would write it for them: what the change does, why, and what to look at.
It must contain no meta-instructions aimed at a reviewer or a bot ("do not re-raise", "do not flag as surprising", "already decided"), no second-person direction, no internal vocabulary (firstmate, crewmate, captain, brief, task id, harness, worktree, scout, ship), and no agent co-author.
The rule is unconditional - assume every PR body is read by a stranger - and it matters most on a repo the captain does not own.

**Verify what you actually published, before you report the PR done.**
This is about your FINAL status line, `done: PR {url} checks green` - the one that names the PR; it does not apply to any earlier `done:` append your mode makes before a PR exists.
Once the PR exists, re-read its LIVE body from the API - never trust your memory of the text you passed in - and confirm it is clean:
`bin/fm-pr-body-check.sh {url}`
It prints the live body's suspicious lines. READ each flagged line and judge it; a match is a line to inspect, not a verdict, so never act on a hit count alone (a PR about firstmate legitimately says "firstmate").
If the body is dirty, rewrite it and re-verify before appending `done: PR {url} checks green`.
Do NOT rewrite it with `gh pr edit --body`: that can silently NO-OP (it has failed with "GraphQL: Projects (classic) is being deprecated", changing nothing while reporting success, which then looks like something else clobbering your edit). Use the REST API:
`gh api -X PATCH repos/OWNER/REPO/pulls/{n} -F body=@{file}`
This one repair intentionally bypasses `gh-axi`, which exposes no `api` subcommand, so raw `gh api` is the correct and sanctioned tool for it; every other GitHub operation still goes through `gh-axi`.
Reporting `done: PR {url} checks green` on a public body you have not read back live is not acceptable.
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (24m27s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ⚠️ 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 -A fails with 'invalid option' and set -eu aborts the script. Additionally, on any bash older than 4.4, ${!TEXTS[@]} at line 109 trips nounset when 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-done step 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 captures gh api ... 2&gt;&amp;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 raw gh api -X PATCH ... and warns off gh pr edit --body, while brief rule 3 (bin/fm-brief.sh:379) tells it to use gh-axi for all GitHub operations. Raw gh is correct here (gh-axi exposes no api subcommand), 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 - The internal vocabulary pattern includes no-mistakes, but the no-mistakes pipeline appends its own ## Pipeline section to every PR body it produces, containing the literal line Updates 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 --intent verbatim - fm-pr-body-check.sh &lt;url&gt; can never exit 0 / print clean. 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 direction at line 89 and internal vocabulary at line 90) rely on \b word 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 \b as a literal b, both patterns silently stop matching and a dirty body reports clean - 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 \b is 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 separate done: appends: done: {summary} after the implementation commit (bin/fm-brief.sh:342, before any PR exists) and done: PR {url} checks green after CI (line 354). The public-PR section says "Verify what you actually published, before you report done" and "rewrite it and re-verify before appending done:", which reads against the first, pre-PR done: 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 final done: PR {url} checks green line 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 &lt; &lt;(grep -n -i -E -- &#34;$regex&#34; &#34;$SCAN&#34; || 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 prints clean and 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 \b instance 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 [ &#34;$st&#34; -le 1 ] || { echo &#34;error: pattern scan failed&#34; &gt;&amp;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 calls gh pr view for 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 appends done: 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 unconditional gh api call. 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 for repos/example/repo/pulls/1 using 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-0 gh stub 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 ## Pipeline and the exact generated line Updates 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 - The internal vocabulary pattern matches bare harness and worktree (and captain), 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, a gh api call that exits 0 but produces empty stdout yields an empty $TEXT, which scans to zero hits and prints clean (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/&lt;id&gt;.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 (&lt;id&gt;.status, &lt;id&gt;.turn-ended, &lt;id&gt;.check.sh, &lt;id&gt;.meta, &lt;id&gt;.grok-turnend-token), does not list it. A one-line entry alongside &lt;id&gt;.check.sh keeps 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 answer pr view and fall through to a bare exit 0 with empty stdout for everything else. Since 8c94579 added the empty-fetch guard, gh api returning 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 an api) 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 runs rm -f &#34;$RECORD&#34;, 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 + &#34;\n&#34; + (.body // &#34;&#34;), 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 via gh api -X PATCH ... -F body=@&lt;file&gt;. 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 ✅
  • 🚨 tests failed with exit code 1
  • 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.sh
  • bash tests/fm-brief.test.sh
  • bash tests/fm-pr-check.test.sh
  • bash tests/fm-pr-merge.test.sh
  • bash tests/fm-teardown.test.sh
  • bash tests/fm-bootstrap.test.sh
  • Manual end-to-end: stubbed gh api with a realistic leaked-intent PR body, ran bin/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 ## Pipeline footer was not
  • Manual end-to-end: bin/fm-pr-check.sh auth-rot-k3 &lt;pr-url&gt; 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 path
  • Manual end-to-end: bin/fm-brief.sh scaffolded 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 ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: silence SC2016 on tests/lib.sh literal shim source
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

lmansf added 11 commits July 12, 2026 11:58
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.
@kunchenguid

kunchenguid commented Jul 16, 2026 •

Copy link
Copy Markdown
Owner

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 e4945ad1.

@kunchenguid

Copy link
Copy Markdown
Owner

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.

@kunchenguid

Copy link
Copy Markdown
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants