Repository navigation
feat(bin): add a firstmate-filled recall section to crewmate briefs - #25
Merged
Merged
Conversation
added 2 commits
September 11, 2026 00:20
Branch, delivery mode, and scope are fixed by firstmate while it writes the brief, before the worker exists, so the worker's own Grounding section can never correct them. Ship and scout scaffolds now carry a firstmate recall section between Task and Grounding: what recall returned, quoted, and what it changed about the brief, where "Nothing" is an explicit first-class answer. fm-spawn.sh refuses a fresh ship or scout spawn while either recall placeholder remains, checking only that each was replaced, never with what; relaunch and secondmate charters skip the check. AGENTS.md section 11's placeholder sentence is amended to cover the new placeholders.
…filled prefix form
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
Add a firstmate-authored grounding section to the crewmate brief scaffold generated by bin/fm-brief.sh, so the knowledge firstmate already holds is consulted when the shape of a task is decided (branch, delivery mode, scope - chosen by firstmate while writing the brief), not after the task is finished.
Rationale: the /retrospective skill's Step 1 pre-flight recall runs at session end where it cannot change finished work; three consecutive KILL-CRITERION ledger rows show recall changed work only via data/learnings.md loaded at session start. The scaffold's existing # Grounding section instructs the crewmate to ground itself, but a crewmate cannot correct a decision made before it existed. Receipt: GOP-275 (unauthenticated SQL injection) was put on branch php8 while the captain deploys test; the fix merged and the hole stayed open. The knowledge that would have raised "which branch reaches the environment where this fix must take effect?" was already in the store.
Requirements: a new section in the scaffold, filled by firstmate before dispatch, clearly distinct from the crewmate-facing # Grounding, with two parts: (1) what we already know - what recall returned, quoted not summarised; (2) what it changed about this brief - one sentence. "Nothing" must be a first-class, explicitly allowed answer for part 2, stated in the scaffold text itself, because a fabricated grounding line launders a guess as evidence. Do not build a query-runner or wire in a specific memory tool; which sources exist is not this task's business. Load firstmate-coding-guidelines; follow bin/ and AGENTS.md conventions. Keep the always-loaded AGENTS.md contract concise (one sentence if one will do; prefer amending an existing sentence over appending a rule). Do not weaken or reword any existing scaffold safety property - the worktree-isolation assertion and the status protocol stay exactly as they are. Never echo/copy/log/commit GEMINI_API_KEY.
Acceptance: newly generated brief contains the section, visibly distinct from the crewmate's grounding, text making clear firstmate fills it and that "nothing" is valid for part 2; existing generated sections unchanged; enforcement decision implemented and reasoning stated in the PR; tests covering the new scaffold output; bin/fm-lint.sh and bin/fm-doc-audience-check.sh clean.
Decisions made (deliberate, not mistakes):
What Changed
bin/fm-brief.shnow puts a new# Firstmate recall - written by firstmate before dispatchsection into ship and scout briefs, between# Taskand the crewmate's own# Grounding. The section has two placeholders:{RECALL_FOUND: firstmate - ...}holds what firstmate's recall returned, quoted rather than summarised.{RECALL_CHANGED: firstmate - ...}holds one sentence on which shape decision it changed (project, base branch, delivery mode or scope). The text tells the crewmate that firstmate filled the section. It also says "Nothing" is an honest answer and a first-class one for the second part, and that no change should be invented to fill the line. Secondmate charters leave the section out, for the same reason they leave out Grounding. The scaffold's "scaffolded:" message now lists the recall placeholders too. The other generated sections are unchanged, including the worktree-isolation assertion and the status protocol.bin/fm-spawn.sh. A fresh ship or scout spawn is refused while either placeholder is still in its unfilled scaffold form ({RECALL_FOUND: firstmate -/{RECALL_CHANGED: firstmate -). The error names the placeholder and says "Nothing" is valid, and the refusal happens before any endpoint or task metadata exists. The reasoning:{RECALL_FOUND}mentioned in a filled brief doesn't trip it.--relaunchskips the check, so recovering an existing task is never blocked. Secondmate charters skip it too.{TASK}sentence now also covers filling the recall placeholders, with "nothing" allowed as an answer; no new rule was added.tests/fm-brief.test.shchecks that the section and its wording are present, that it sits in Task → recall → Grounding order, and that secondmate charters don't have it.tests/fm-task-delivery.test.shchecks that spawns are refused while the ship or scout placeholders are unfilled or half-filled, that "Nothing" gets through, and that a mention of the bare tokens isn't treated as unfilled. The opt-in live cmux composer test now fills the recall placeholders so it isn't refused.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change adds one templated brief section and one early, content-agnostic spawn refusal. The refusal uses the existing exit-and-trap path, is skipped for relaunch and secondmate, runs in a separate process per batch pair, and has no automated caller that would now be refused; last round's narrowing fix matches the scaffold's exact prefix and has a test that would fail against the old check.
Testing
I ran the two suites holding the new tests (fm-brief, fm-task-delivery) and three related suites that scaffold briefs or exercise spawn and relaunch paths (tangle-guard, secondmate-safety, control-relaunch); all passed. I also checked the behaviour end to end and saved evidence files: a base-vs-head diff of generated briefs showing the recall section is the only change and nothing existing was removed; a sandboxed fm-brief.sh -> fm-spawn.sh transcript showing unfilled ship and scout briefs refused with the placeholder named and no task record written, "Nothing" and bare-token briefs getting past the check; and a relaunch probe showing --relaunch is not held by unfilled placeholders. Nothing failed, and the worktree is clean. bin/fm-lint.sh and bin/fm-doc-audience-check.sh were not run because this phase excludes linters and static checks. The change has no UI, so there are no screenshots; the CLI transcripts and generated briefs are the user-facing surface.Evidence: Generated ship/scout brief diff, base vs head (additions only; existing sections unchanged)
Source: Generated ship/scout brief diff, base vs head (additions only; existing sections unchanged)
Evidence: Newly generated ship brief (placeholders unfilled)
Source: Newly generated ship brief (placeholders unfilled)
Evidence: Newly generated scout brief (placeholders unfilled)
Source: Newly generated scout brief (placeholders unfilled)
Evidence: fm-brief.sh -> fm-spawn.sh recall enforcement CLI transcript
Source: fm-brief.sh -> fm-spawn.sh recall enforcement CLI transcript
Evidence: Relaunch is not held by an unfilled recall section
Source: Relaunch is not held by an unfilled recall section
Evidence: Spawn refusal for an unfilled ship brief
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-spawn.sh:1708- The recall refusal runsgrep -qF '{RECALL_FOUND'/'{RECALL_CHANGED'over the whole brief, not just the scaffold's placeholder form, so it also refuses a brief that only mentions the token. Concrete path: firstmate works on its own repo (for example a--no-projectssecondmate's crews, or a follow-up to this feature). It writes a Task such as "rename the{RECALL_FOUND}placeholder in bin/fm-brief.sh", or it follows the section's own instruction to quote recall verbatim and the quoted memory names the token. Both recall parts are properly filled, yet fm-spawn exits 1 with "still carries its unfilled {RECALL_FOUND} placeholder". The only way past is to obfuscate the task or the quote, which contradicts the "quote verbatim" requirement. The scaffold always emits the placeholder as{RECALL_FOUND:/{RECALL_CHANGED:(colon, then the firstmate guidance). Matching that colon form (e.g.'{RECALL_FOUND:') keeps the "was it replaced" check intact without catching prose or backticked mentions of{RECALL_FOUND}. The new test'sperl s/\{RECALL_FOUND:[^}]*\}/.../fills and the live cmux test's regex already key on that colon form.🔧 Fix: Narrow recall placeholder check to scaffold's unfilled prefix form
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-brief.test.sh(includes the new test_firstmate_recall_section) - exit 0bash tests/fm-task-delivery.test.sh(includes the new test_spawn_refuses_an_unfilled_recall_section, including the bare-token case from review round 1) - exit 0bash tests/fm-tangle-guard.test.sh(scaffolds a ship brief with fm-brief.sh, then spawns it) - exit 0bash tests/fm-secondmate-safety.test.sh(brief scaffolds plus secondmate charter spawns, which skip the check) - exit 0bash tests/fm-control-relaunch.test.sh(the relaunch path the check exempts) - exit 0Manual: rendered ship and scout briefs from base b82fc57 (git archive) and HEAD, normalised FM_HOME/FM_ROOT, and diffed them - only additions, no removed or reworded linesManual CLI transcript in a sandbox FM_HOME with a fake tmux that exits 1 and FM_GATE_REFUSE_BYPASS=1, the same bypass tests/lib.sh sets: fm-brief.sh scaffold -> fm-spawn.sh refused unfilled {RECALL_FOUND}, then {RECALL_CHANGED}, with no .meta written; a scout brief was refused the same way; after a Nothing fill it got past the checkManual: a filled brief whose Task mentions the bare {RECALL_FOUND}/{RECALL_CHANGED} tokens reachedtmux new-window(logged by the fake tmux), so it passed the recall checkManual relaunch probe: a throwaway copy of fm-control-relaunch.test.sh under /tmp, with one appended case using a real fm-brief.sh brief that still has both placeholders unfilled;fm-spawn.sh rl90 --relaunch --harness claudeexited 0 and launched the replacement✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.