Repository navigation
fix(bin): separate captain intent from firstmate specs - #3597
Merged
Merged
Conversation
Keep no-mistakes --intent as the captain's ask plus later captain words, not the build spec or worker tradeoffs.
Promotion was swallowing the scout Setup contract into Firstmate spec, and pre-subsection briefs lost their # Task body.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "no-mistakes(ci): Updated stale spawn/pro..." | Re-trigger Greptile |
…tain intent and Firstmate spec subsections, corrected launch-path expectations to launch-brief.md, and resolved ShellCheck quoting findings. Verified with fm-lint.sh and 15 affected behavior tests, including real Herdr tests; all passed
…Orca, secondmate-harness, and public-followup suites to provide valid Captain's intent and Firstmate spec subsections. Verified full Orca and secondmate-harness suites, targeted public-followup promotion behavior, Bash syntax, diff checks, and fm-lint
npayette84
added a commit
to npayette84/firstmate
that referenced
this pull request
Sep 3, 2026
…rebase The rebase onto main picked up the brief split (kunchenguid#3597): a spawn now refuses a brief without nonempty `## Captain's intent` and `## Firstmate spec` subsections, so both codex sandbox-grant suites failed at the first ship spawn on their one-line fixture brief. Both fixtures now carry the two subsections, matching what tests/fixtures.sh fm_test_spawn_brief writes. Nothing about the grant under test changes.
Marcos-Leyva
added a commit
to Marcos-Leyva/firstmate
that referenced
this pull request
Sep 3, 2026
) * fix: surface inbound Relay media to responding agents (kunchenguid#3442) * fix: surface inbound Relay attachments to the responding agent A Discord support thread's screenshots were never seen by the agent handling the mention. The relay delivered them and the poll stashed them: the reporter's images arrived on the `thread_starter` entry of `in_reply_to_chain` while the mention's own media list was empty. The gap was in the responder's playbook, which enumerated a fixed field list (`request_id`, `text`, `in_reply_to`, `in_reply_to_chain`) and so made every other field, attachments included, invisible. Fix it where the gap is, in prose: - Read the complete payload object rather than a fixed field list, so media and later relay fields are never skipped again. - Fetch and view attached media with the agent's own tools, on the mention and on every chain entry, and call out the common shape where only the thread starter carries the screenshots. - Restrict those fetches to known-good platform media hosts over https (Discord: cdn.discordapp.com, media.discordapp.net, images-ext-1.discordapp.net, images-ext-2.discordapp.net; X: pbs.twimg.com, video.twimg.com), report a blocked host instead of working around it, and treat everything fetched as untrusted public input on the same terms as the surrounding thread text. The poll stays out of it and downloads nothing, so no third-party bytes are pulled on the polling path. The new test pins the contract the playbook depends on: a mention in the incident's shape, with an empty top-level media list and screenshots on the thread starter, must reach the inbox with the payload intact and its media URLs unfetched. * no-mistakes(review): Preserve media authority and enforce poll-only fetching * no-mistakes(document): Clarify Relay attachment safety prose * fix(bin): defer inactive reconciliation during startup (kunchenguid#3480) * Defer inactive startup reconciliation * no-mistakes(review): Queue deferred inactive reconciliation diagnostics durably * no-mistakes(review): Require worker phases to cover startup requests * no-mistakes(review): Make diagnostic wakes safely acknowledgeable * no-mistakes(document): Document deferred startup phase coverage * fix(bin): bound wake drain presentation lock waits (kunchenguid#3475) * fix: bound status presentation lock waits * no-mistakes(review): Distinguish malformed presentation locks from live contention * no-mistakes(review): Bound no-ack drain queue lock acquisition * no-mistakes(document): Document bounded presentation-lock drain behavior * no-mistakes(lint): Annotate bounded lock output global * no-mistakes(ci): Added deterministic regression coverage for successful bounded-lock acquisition after live contention, verifying helper-to-caller PID ownership handoff and caller release. Verified with bash syntax checks, git diff checks, and the full fm-wake-queue test suite * fix(bin): retire public follow-ups in remote homes (kunchenguid#3479) * fix(relay): close a public loop whose work lives in a remote secondmate home A public-followup loop bound to a REMOTE secondmate could never be closed. `clear_public_followup_link` (bin/fm-public-followup.sh:701) required an absolute recorded `work_home_path` for a `secondmate:*` work home, but a remote route has no local path on this machine, so registration records that field empty (bin/fm-public-followup.sh:291). Every close ran that clear first, so `retire` died with "could not clear the legacy X link ... retained for reconciliation" forever, and `deliver` posted the public reply and then stranded the loop at `posted`. `--force` never covered that step. The clear now goes to the remote home over that route's SSH transport, running `fm-x-followup.sh --clear <work-id>` through `bin/fm-on.sh`. The route is decided from `data/secondmates.md` before any local path is consulted, so a same-named local directory can never stand in for a remote home, and registrations already on disk retire without needing a new field. `fm-on.sh` passes ssh's status through, so 255 stays the established "delivered but completion unknown" result this codebase already reconciles: the close is refused, the registration and the remote link are left exactly as they were, and the message names the unknown completion instead of claiming a definite failure. Local secondmate and `main` work homes are untouched, and `--force` still governs only the unresolved-obligation refusal. Three regression cases drive a remote route end to end, faking only the ssh binary at the FM_SSH_BIN seam and then running the real remote entrypoint against a local checkout, so the clear that must reach the remote home actually happens there. * no-mistakes(review): Guard remote link clears by request identity * no-mistakes(review): Fail guarded clears on unreadable remote state * no-mistakes(review): Reject guarded clears on non-writable remote state * no-mistakes(review): Allow no-link retirement in non-writable remote state * no-mistakes(d
Intent
B. Use brief subsections instead of a file.
Captain intent is the original ask, enrichable with context but not a solution spec the captain did not specify. Firstmate spec can be detailed build instructions and must not be treated as captain intent. no-mistakes --intent must be captain intent, not the full spec.
What Changed
Captain's intentandFirstmate specsubsections.--intentto captain-authored requests and clarifications while excluding Firstmate specifications and worker decisions.Risk Assessment
✅ Low: The change is well-bounded and consistently separates captain intent from Firstmate specification across scaffolding, spawn, legacy compatibility, and scout promotion paths.
Testing
Targeted brief and delivery tests passed; an end-to-end CLI exercise confirmed Captain intent and Firstmate spec remain separate, spawn serializes only Captain intent plus later captain words for
--intent, and promotion preserves intent while replacing scout specifications with ship-time instructions. A reviewer-visible transcript was captured, and the worktree remained clean.Evidence: End-to-end intent/spec CLI transcript
Source: End-to-end intent/spec CLI transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed (9) ✅
bin/fm-dod-lib.sh:41-fm_brief_heading_bodystops at every line beginning with#, not the next heading at the same or higher level. A valid Firstmate spec containing### Acceptance criteriais therefore silently truncated during promotion, and headings inside fenced examples are also mistaken for boundaries. Parse the target heading level and stop only at an unfenced heading of equal or higher level.bin/fm-dod-lib.sh:25- Validation checks only for literal placeholder tokens. If both placeholders are replaced with empty text, spawn accepts a brief with no captain intent; promotion instead fabricates “Write the captain's ship-time ask here” and publishes it as a ship task. A missing scout brief reaches the same promotion fallback. Add shared semantic validation requiring readable, nonempty subsection content for subsection-format briefs, while preserving compatibility for a genuinely filled legacy# Taskbody.🔧 Fix: Validate brief content and preserve nested specifications
2 errors still open:
bin/fm-promote.sh:139- This contradicts the required criterion that “Captain intent is the original ask” and must not include “a solution spec the captain did not specify.” Promotion tells Firstmate to replace an investigation ask with a ship-time ask, while the legacy fallback at lines 149–150 places the entire historically mixed# Taskbody—including possible Firstmate build instructions—under## Captain's intent. Decide whether legacy briefs must be manually split or rejected, and preserve the original captain ask during promotion rather than inventing a shipping request.bin/fm-dod-lib.sh:28- The placeholder guard searches the entire brief, so a filled task such as “Fix replacement of{TASK}in Herdr briefs” is rejected as unfilled. This is especially reachable in this repository, whose tasks discuss these literal tokens. Restrict detection to a subsection body whose trimmed value is exactly its scaffold placeholder instead of matching the token anywhere in user content or examples.🔧 Fix: Scope placeholder validation to scaffold-only subsection bodies
2 issues (1 error, 1 warning) still open:
bin/fm-promote.sh:14- This contradicts the required criterion that “Captain intent is the original ask” and must not include “a solution spec the captain did not specify.” The changed header directs Firstmate to rewrite an investigation ask into a ship-time ask, and the legacy fallback at lines 149–150 places the historically mixed# Taskbody—including Firstmate-authored acceptance criteria and constraints—under## Captain's intent, which no-mistakes then receives as--intent. Preserve the original captain ask and place promotion-time build instructions in## Firstmate spec; ask the user whether unsplittable legacy briefs should be rejected or manually migrated.bin/fm-dod-lib.sh:94- Legacy detection uses unrestrictedgrepwhile body extraction ignores fenced headings. A valid legacy# Taskcontaining a fenced example with both## Captain's intentand## Firstmate specmakeshas_intentandhas_spectrue, but both extracted bodies are empty, so spawn and promotion reject the brief despite the stated legacy compatibility. Detect subsection headings through the same unfenced parser used for extraction.🔧 Fix: Ignore fenced subsection headings during brief validation
1 error still open:
bin/fm-promote.sh:139- This contradicts the required criterion that “Captain intent is the original ask” and must not include “a solution spec the captain did not specify.” Promotion directs Firstmate to replace the investigation ask with a ship-time ask; the legacy fallback at lines 149–150 also labels the historically mixed# Taskbody as captain intent. Preserve the original captain ask, append only actual later captain authorization, and keep promotion-time build instructions in## Firstmate spec; ask the user how unsplittable legacy briefs should be handled.🔧 Fix: Preserve captain intent across scout promotion
2 errors still open:
bin/fm-dod-lib.sh:118- The legacy fallback accepts any nonempty mixed# Task, although the required invariant is “Captain intent is the original ask” and--intentmust exclude Firstmate spec. A legacy no-mistakes ship brief can therefore launch with its old instruction to pass the entire mixed Task as intent; promotion instead assumes only the first nonempty line is captain-authored, so a multiline captain ask is truncated and moved into Firstmate spec. Ask the user whether unsplit legacy briefs should be rejected/migrated or what reliable provenance marks clearly captain-authored text; enforce that decision at this shared validation boundary.bin/fm-promote.sh:146- Promotion copies the existing scout-time Firstmate spec unchanged and succeeds without any ship-time specification. For example, a scout spec saying “reproduce and report the cause” is emitted as the promoted ship's spec even though the selected requirement says, “On promote ... Put ship-time instructions in Firstmate spec.” The test avoids this path by manually replacing the scout spec before promotion, but no documented workflow or interface requires that step. Ask the user whether promotion should require an explicit ship spec argument or require a documented pre-promotion brief update.🔧 Fix: Enforce safe intent boundaries for legacy promotions
2 errors still open:
bin/fm-spawn.sh:1783- The unconditional guard rejects every legacy no-mistakes ship, including a safely provenance-marked# Tasksuch asCaptain: Fix X. This contradicts the selected requirement, “do not refuse spawn of every old brief,” and makes the marked-word fallback documented infm-dod-lib.shunreachable for ordinary spawn. Ask whether marked legacy briefs should proceed using that fallback while only unmarked briefs stop for migration.bin/fm-promote.sh:149- A legacy scout with no inline provenance marker produces an emptyINTENT_BODY, yet promotion still publishes it as## Captain's intent. For direct-PR and local-only modes, line 182's instruction to stop “before starting no-mistakes” never applies, so work can ship with no preserved original ask. This contradicts “Captain intent is the original ask.” Ask whether such promotions should stop pending provenance, or how non-inline clearly marked captain text should be recovered.🔧 Fix: Allow marked legacy intent and reject empty promotions
3 issues (2 errors, 1 warning) still open:
bin/fm-spawn.sh:1783- The criterion requires “no-mistakes --intent must be captain intent, not the full spec,” but a marked legacy brief is launched unchanged. Pre-subsection no-mistakes briefs instruct workers to pass the mixed# Taskcontent as--intent; merely confirming that oneCaptain:line exists does not supersede that stale instruction, so Firstmate-authored text remains reachable in--intent. Preserve the authorized marked-legacy compatibility while ensuring the spawned worker receives the current intent contract.bin/fm-dod-lib.sh:117- Subsection detection and extraction search the entire brief rather than the# Taskbody. A legacy brief with its real task under# Taskand later unrelated## Captain's intent/## Firstmate specheadings is accepted as subsection-format; promotion then publishes that unrelated content as captain intent. This contradicts “Captain intent is the original ask.” Scope both heading detection and extraction to the unfenced# Tasksection.tests/fm-cmux-claude-composer-live-e2e.test.sh:61- The live cmux probe still replaces only{TASK}. The changed spawn guard now rejects its generated scout brief because{FIRSTMATE_SPEC}remains, so this executable integration lane can no longer reach the behavior it tests. Fill the new spec subsection in this fixture.🔧 Fix: Scope task parsing and overlay legacy intent contracts
1 error still open:
bin/fm-spawn.sh:1783- The required criterion says “no-mistakes --intent must be captain intent, not the full spec,” but the corrective overlay is added only when no Captain's-intent subsection exists. A pre-change no-mistakes brief can be migrated into the new subsections while retaining its old Definition of done that directs the worker to pass the mixed Task and Firstmate requirements as--intent; it then passes validation and launches without the overlay. Ensure the spawn boundary supplies the authoritative current intent contract for migrated subsection briefs too, rather than limiting it to unsplit legacy briefs.🔧 Fix: Overlay current intent contract for all no-mistakes spawns
1 error still open:
bin/fm-dod-lib.sh:133- The overlay says to use only the captain intent serialized at spawn and supersedes all earlier instructions, contradicting the required intent contract and line 197's inclusion of later captain words. Concrete path: after spawn, the captain clarifies the ask, Firstmate appends/steers those words as AGENTS.md requires, then the worker starts no-mistakes; the later overlay instructs it to omit that valid captain intent. Amend this shared overlay boundary to authorize the serialized intent plus later words actually supplied by the captain while still excluding Firstmate spec.🔧 Fix: Preserve later captain clarifications in intent overlays
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-brief.test.shbash tests/fm-task-delivery.test.shEnd-to-end CLI exercise: scaffolded and filled a no-mistakes brief, invoked spawn with the test bypass and fake tmux, inspected the generated worker launch brief, then promoted the task and inspected ship instructions.git status --shortconfirmed testing left the worktree clean.✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.