Repository navigation
feat(bin): check the no-mistakes --intent string before the run starts - #6
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Critical authorization and reference-filtering issues remain, and generated paths need shell quoting.
Review effort: Lite
Findings: None
What changed in this PR
Adds pre-run validation and scrubbing for no-mistakes --intent strings before PR body creation.
Changes:
- Added intent checking, scrubbing, and reference validation.
- Integrated the contract into briefs and promotions.
- Added tests and CLI documentation.
| File | Description |
|---|---|
tests/fm-task-delivery.test.sh |
Normalizes task-specific command paths. |
tests/fm-intent-check.test.sh |
Adds intent behavior coverage. |
docs/scripts.md |
Documents the new CLI. |
bin/fm-promote.sh |
Applies the intent contract during promotion. |
bin/fm-intent-check.sh |
Exposes check and scrub commands. |
bin/fm-dod-lib.sh |
Implements intent rules and worker instructions. |
bin/fm-brief.sh |
Includes validation requirements in new briefs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The pipeline publishes --intent as the pull request body. Add fm-intent-check.sh (rules in fm-dod-lib.sh) to refuse speaker labels, direct address, attributed quotes, foreign fleet terms, and sentences outside the authorized words, to require Refs #<n> for linked issues, and to scrub the authorized words into a passing starting string. The no-mistakes Definition of done now tells the worker to run it.
… sentences to be dropped
zakna
force-pushed
the
fm/fm-intent-publication-scrub-o1
branch
from
September 27, 2026 09:13
cc9c7f9 to
5519417
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Keep captain quotes and worker instructions out of the PR body composed from --intent, and check the composed string before the run starts.
Sources: data/dotagents-239-retro-s1/report.md rows 4 and 5, data/unraid-43-retro-s1/report.md section 3.4 and row 2, data/ha-71-retro-s1/report.md section 4, data/ha-72-retro-s1/report.md section 3.4.
The no-mistakes pipeline composes the PR body from the --intent string, so sentences from the brief's Captain's intent (a captain quote, second-person worker instructions) were published in dotagents PR 245 for 11 minutes before a manual edit; in unraid PR 61 the run passed three forbidden block headings and three of four "the user" attributions that were Firstmate spec; ha PR 71's body opened with the fleet-level sentence, and the ha-72 retro shows the leak also covers firstmate build framing in paragraph 2 of the intent (checks green, no run exists), not only the captain sentence.
Refs # was also added by a later edit instead of at creation.
Change bin/fm-dod-lib.sh (and the brief template if needed) so the passed intent keeps the specification but strips quotes and worker-directed sentences, so the composed body carries the issue reference at creation, and add a check before the run starts that rejects speaker labels and any sentence outside the authorized intent section.
What Changed
bin/fm-intent-check.sh, backed by newfm_intent_check/fm_intent_scrubfunctions inbin/fm-dod-lib.sh.checkrejects an--intentfile that contains speaker labels, direct address (such as an openingpleaseoryou must), quotes attributed to a speaker, or fleet terms the repository's own tracked files don't use. It also rejects any sentence outside the brief's authorized intent section, and requires aRefs #<n>for every issue of the repo's github.com origin that the brief links.scrubprints the authorized words and appends any missingRefsline. Scrub doesn't strip or reword refused lines: when it finds one, it prints nothing, names each refused line on stderr and exits 1. Fenced code, indented examples and inline code are exempt from every rule except the authorized-section rule. A later captain wording can be allowed with--captain-words <file>and resolved report or PR substance with--resolved <file>.fm_dod_blockfromfm-brief.shandfm-promote.sh. It tells workers to runscrub, thencheckon the exact string before starting the run, and to pass that string unchanged only if the check passes. When a line is refused, workers ask firstmate to reword the brief's intent or stop, rather than dropping the line themselves. The launch overlay says the same.tests/fm-intent-check.test.shand a row for the new script indocs/scripts.md. The Gerrit/plain comparison intests/fm-task-delivery.test.shnow normalizes task ids, because the embedded check command names each task's data directory.Risk Assessment
Refsline the brief names and never removes a specification sentence, and on any refused line it prints nothing, names the line, and exits 1 so the intent wording is corrected before the run. The heuristics can still refuse a legitimate sentence, which stops the run rather than changing what is published.Testing
I ran the focused intent-check test file (all 13 pass). I then drove the real CLI end to end in a disposable lab home: fm-brief.sh scaffolded a no-mistakes brief, and I filled it with the leak patterns from the dotagents, unraid and ha retros. Scrub and check were run from a throwaway project repo with a github.com origin, and the transcript and driver script are saved in the evidence directory. Every scenario behaved as intended: - Leaked lines were refused by line number with exit 1 and nothing was printed. - A clean specification came out unchanged withRefs #43added, and passed the check. - A missing Refs line, an invented reference, Firstmate spec content and speaker labels were all refused. - The launch overlay replaces the brief as the source and repeats the rule never to drop or reword a refused sentence. This is a CLI-only change, so there is no visual artifact. The lab home and repo were removed afterwards.Evidence: Live CLI transcript (scenarios A-E)
Source: Live CLI transcript (scenarios A-E)
Evidence: Live driver script
Source: Live driver script
Evidence: Scrub refusing a leaky intent
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-dod-lib.sh:503- fm_intent_scrub passes an emptymentionedset to fm_intent_scan, so anyRefs #<n>line in the captain's authorized words is marked "reference not named by the brief" and removed. Scrub then adds back only the issues the brief links by full github.com URL. Repro: a brief whose authorized section is 'Make the fan quieter at night.\nRefs test: pass Pi 1.1's getToolRenderers lookup to HTML export renderer fixtures #43' makes scrub print only the first sentence and drop the reference.checkthen accepts that output (exit 0), because test: pass Pi 1.1's getToolRenderers lookup to HTML export renderer fixtures #43 is not a URL-linked issue and so is not inneed. The composed body loses the issue reference, which contradicts the intent's requirement that "the composed body carries the issue reference at creation". The worker is told to pass scrub's output, so this happens on the documented path. Fix: in fm_intent_scrub, computementionedfrom the source exactly as fm_intent_check does (line 489) and pass it to the scan. Also consider keeping a Refs line the brief names rather than re-deriving it.bin/fm-dod-lib.sh:406- The refusal heuristics strip real specification sentences as well as worker-directed ones. Any sentence containing the word 'you'/'your' counts as direct address, for example the product requirement 'Show the temperature so you can see drift'. Any sentence using a fleet term the target repo does not already use is also refused, for example 'the user', 'supervisor', 'fleet' or 'status file' in a spec about user-facing behavior. Scrub removes these silently apart from a stderr note, and the worker is told to pass scrub's output. This conflicts with the intent's requirement that the passed intent "keeps the specification but strips quotes and worker-directed sentences". Decide whether scrub should refuse instead of silently dropping, or whether the heuristics should be narrowed.🔧 Fix applied.
4 issues (1 error, 3 warnings) still open:
bin/fm-dod-lib.sh:503- fm_intent_scrub passes an emptymentionedset to fm_intent_scan, so anyRefs #<n>line in the captain's authorized words is marked "reference not named by the brief" and removed. Scrub then adds back only the issues the brief links by full github.com URL. Repro: a brief whose authorized section is 'Make the fan quieter at night.\nRefs test: pass Pi 1.1's getToolRenderers lookup to HTML export renderer fixtures #43' makes scrub print only the first sentence and drop the reference.checkthen accepts that output (exit 0), because test: pass Pi 1.1's getToolRenderers lookup to HTML export renderer fixtures #43 is not a URL-linked issue and so is not inneed. The composed body loses the issue reference, which contradicts the intent's requirement that "the composed body carries the issue reference at creation". The worker is told to pass scrub's output, so this happens on the documented path. Fix: in fm_intent_scrub, computementionedfrom the source exactly as fm_intent_check does (line 489) and pass it to the scan. Also consider keeping a Refs line the brief names rather than re-deriving it.bin/fm-dod-lib.sh:406- The refusal heuristics strip real specification sentences as well as worker-directed ones. Any sentence containing the word 'you'/'your' counts as direct address, for example the product requirement 'Show the temperature so you can see drift'. Any sentence using a fleet term the target repo does not already use is also refused, for example 'the user', 'supervisor', 'fleet' or 'status file' in a spec about user-facing behavior. Scrub removes these silently apart from a stderr note, and the worker is told to pass scrub's output. This conflicts with the intent's requirement that the passed intent "keeps the specification but strips quotes and worker-directed sentences". Decide whether scrub should refuse instead of silently dropping, or whether the heuristics should be narrowed.bin/fm-dod-lib.sh:504- Issue numbers are compared without their repository, so aRefsline can point to the wrong issue and still pass.fm_intent_mentioned(bin/fm-dod-lib.sh:504) collects the digits from every#n,/issues/nand/pull/nanywhere in the source, including URLs to other repositories. Round 1 made scrub use this same set (the fix for review-1), so check and scrub now share the gap. Repro: the brief contains 'See https://github.com/other/repo/issues/7 for background.' A worker who writes 'Refs fix(bin): read producer output whole before early returns to stop broken-pipe stderr lines #42, fix(skills): file a declined finding's author note durably before cleanup #7' passes the check (known[7] is set), and the PR body then references acme/widgets#7, an issue the brief never named. This breaks the documented rule 'refuses a reference the brief does not name'. Sibling site: the Refs-unit parser at bin/fm-dod-lib.sh:428-431 reduces a URL reference to its trailing number (sub(/^.*\//, "", num)). So 'Refs https://github.com/other/repo/issues/42' both counts as known and satisfies the requiredneed[42]for this repository's fix(bin): read producer output whole before early returns to stop broken-pipe stderr lines #42. Fix: buildknownonly from bare#nmentions plus/issues|pull/nURLs whose owner/repo matches the origin slug (reuse the slug logic in fm_intent_linked_issues). Refuse, or at least do not count, URL-form Refs entries that point at another repository.bin/fm-dod-lib.sh:405- The bracket form of the speaker-label rule,t ~ /^\[[a-z][a-z' -]*\]/, matches any sentence that starts with a Markdown link or a checked task-list item. Examples: 'Fan docs describe the night curve.' and '- [x] Keep the column order.' Scrub drops these specification sentences, logging only to stderr, and check refuses them as 'speaker label'. This goes against the intent requirement that the passed intent 'keeps the specification'. Legacy[captain]markers are already stripped by fm_brief_marked_captain_words before this text is scanned. So the rule only needs to catch a real bracketed speaker tag. Narrow it so that it does not match when the bracket is followed by(or[, or when the tag is the single-character task box[x]. Alternatively, restrict it to the same speaker names the colon form lists.🔧 Fix applied.
6 issues (2 errors, 4 warnings) still open:
bin/fm-dod-lib.sh:503- fm_intent_scrub passes an emptymentionedset to fm_intent_scan, so anyRefs #<n>line in the captain's authorized words is marked "reference not named by the brief" and removed. Scrub then adds back only the issues the brief links by full github.com URL. Repro: a brief whose authorized section is 'Make the fan quieter at night.\nRefs test: pass Pi 1.1's getToolRenderers lookup to HTML export renderer fixtures #43' makes scrub print only the first sentence and drop the reference.checkthen accepts that output (exit 0), because test: pass Pi 1.1's getToolRenderers lookup to HTML export renderer fixtures #43 is not a URL-linked issue and so is not inneed. The composed body loses the issue reference, which contradicts the intent's requirement that "the composed body carries the issue reference at creation". The worker is told to pass scrub's output, so this happens on the documented path. Fix: in fm_intent_scrub, computementionedfrom the source exactly as fm_intent_check does (line 489) and pass it to the scan. Also consider keeping a Refs line the brief names rather than re-deriving it.bin/fm-dod-lib.sh:406- The refusal heuristics strip real specification sentences as well as worker-directed ones. Any sentence containing the word 'you'/'your' counts as direct address, for example the product requirement 'Show the temperature so you can see drift'. Any sentence using a fleet term the target repo does not already use is also refused, for example 'the user', 'supervisor', 'fleet' or 'status file' in a spec about user-facing behavior. Scrub removes these silently apart from a stderr note, and the worker is told to pass scrub's output. This conflicts with the intent's requirement that the passed intent "keeps the specification but strips quotes and worker-directed sentences". Decide whether scrub should refuse instead of silently dropping, or whether the heuristics should be narrowed.bin/fm-dod-lib.sh:504- Issue numbers are compared without their repository, so aRefsline can point to the wrong issue and still pass.fm_intent_mentioned(bin/fm-dod-lib.sh:504) collects the digits from every#n,/issues/nand/pull/nanywhere in the source, including URLs to other repositories. Round 1 made scrub use this same set (the fix for review-1), so check and scrub now share the gap. Repro: the brief contains 'See https://github.com/other/repo/issues/7 for background.' A worker who writes 'Refs fix(bin): read producer output whole before early returns to stop broken-pipe stderr lines #42, fix(skills): file a declined finding's author note durably before cleanup #7' passes the check (known[7] is set), and the PR body then references acme/widgets#7, an issue the brief never named. This breaks the documented rule 'refuses a reference the brief does not name'. Sibling site: the Refs-unit parser at bin/fm-dod-lib.sh:428-431 reduces a URL reference to its trailing number (sub(/^.*\//, "", num)). So 'Refs https://github.com/other/repo/issues/42' both counts as known and satisfies the requiredneed[42]for this repository's fix(bin): read producer output whole before early returns to stop broken-pipe stderr lines #42. Fix: buildknownonly from bare#nmentions plus/issues|pull/nURLs whose owner/repo matches the origin slug (reuse the slug logic in fm_intent_linked_issues). Refuse, or at least do not count, URL-form Refs entries that point at another repository.bin/fm-dod-lib.sh:405- The bracket form of the speaker-label rule,t ~ /^\[[a-z][a-z' -]*\]/, matches any sentence that starts with a Markdown link or a checked task-list item. Examples: 'Fan docs describe the night curve.' and '- [x] Keep the column order.' Scrub drops these specification sentences, logging only to stderr, and check refuses them as 'speaker label'. This goes against the intent requirement that the passed intent 'keeps the specification'. Legacy[captain]markers are already stripped by fm_brief_marked_captain_words before this text is scanned. So the rule only needs to catch a real bracketed speaker tag. Narrow it so that it does not match when the bracket is followed by(or[, or when the tag is the single-character task box[x]. Alternatively, restrict it to the same speaker names the colon form lists.bin/fm-dod-lib.sh:237- The launch overlay still tells the worker to drop refused sentences. It says to use the authorized words "less every sentence the Definition of done's intent check refuses". The overlay is appended after the Definition of done in launch-brief.md and declares that it "supersedes every earlier brief instruction about constructing--intent". So on the normal no-mistakes launch path it overrides the round-2 Definition of done rule "never drop or reword it yourself: ask firstmate to edit the brief's intent wording, or stop" (bin/fm-dod-lib.sh:592). A worker whose scrub refuses one line will read the overlay as permission to delete that sentence and pass the rest. That is the silent drop the user's review-2 decision forbids. This line came from the original commit, and the round-2 fix updated the Definition of done and the header but missed it. Fix: reword the overlay to say the string must pass the Definition of done's intent check unchanged, and that a refused line goes back to firstmate or the worker stops.bin/fm-dod-lib.sh:406- The direct-address rule implements a narrower form than the user's review-2 instruction. The instruction was to flag sentences that "contain ... 'captain'". The round-2 code flags only a vocative captain (^captain,or, captain,) and otherwise relies on the fleet-vocabulary list, which is skipped when the repository's tracked files already use the word 'captain'. In such a repository, for example the test fixture repository or firstmate itself, 'The captain wants exports in UTF-8.' passes the check and reaches the PR body. Following the instruction literally would also refuse the fixture's 'Pin the captain dependency list.', which the test asserts must pass. Decide whether any 'captain' should be refused regardless of repository vocabulary, as instructed, or whether the vocative-plus-vocabulary form is acceptable.🔧 Fix applied.
1 warning still open:
bin/fm-dod-lib.sh:406- The direct-address rule implements a narrower form than the user's review-2 instruction. The instruction was to flag sentences that "contain ... 'captain'". The round-2 code flags only a vocative captain (^captain,or, captain,) and otherwise relies on the fleet-vocabulary list, which is skipped when the repository's tracked files already use the word 'captain'. In such a repository, for example the test fixture repository or firstmate itself, 'The captain wants exports in UTF-8.' passes the check and reaches the PR body. Following the instruction literally would also refuse the fixture's 'Pin the captain dependency list.', which the test asserts must pass. Decide whether any 'captain' should be refused regardless of repository vocabulary, as instructed, or whether the vocative-plus-vocabulary form is acceptable.✅ **Test** - passed
✅ No issues found.
bash tests/fm-intent-check.test.sh(13 focused behavior tests, all ok)bin/fm-lab-home.sh create $LABthenFM_HOME=$LAB bin/fm-brief.sh intent-live-a1 rackfan --mode no-mistakes, then read the Definition of done lines that name the scrub and check commands and the no-drop ruleScenario A: filled Captain's intent with retro leak patterns and ranfm-intent-check.sh scrub $Dfrom a project repo with a github.com originScenario B: filled a clean spec with an issue URL, second-person product wording and a Markdown link; ranscrub > intent.txtthencheck $D intent.txtScenario C:checkon the scrub output with the Refs line removedScenario D:checkon a composed string with an added Firstmate spec sentence, a## Firstmate specheading, aUser:label and an inventedRefs #99Scenario E: rendered launch-brief.md with the realfm_brief_intent_overlay, confirmed the task dir resolves to it and that the overlay repeats the never-drop rule✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.