Repository navigation
feat(bin): add grounding, candidate-finding, and pause-wording contracts to ship briefs - #9
Merged
Merged
Conversation
added 11 commits
September 2, 2026 11:55
…ngs, pause-declaration, and retrospective contracts Six additive fixes to the generated ship brief, each grounded in measured worker failures on 2026-09-01/02: verify PP Brain with one live search_knowledge call before believing an auth_missing banner, a typed blocked: line for a genuinely unreachable server, CANDIDATE findings recorded via working: for firstmate to promote (never a direct write), a paused: line after opening the PR/MR so a merge wait recheck long instead of alarming forever, correct colleague- approval wording, and a mandatory retrospective pass before the final status line.
… scaffold asserts
…tes, persist retro report
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 six missing contracts to bin/fm-brief.sh's generated SHIP crewmate brief only (scout and secondmate contracts left untouched, since the assembled context record data/brief-worker-grounding-and-retro/context.md never mentions them): (1) Verify PP Brain before believing a failure - if the session-start banner reports pp-brain: auth_missing or anything suggests PP Brain is unauthenticated, the worker must make ONE real search_knowledge call before acting on it; that warning is a known false positive; only a failing live call is evidence; never stop, and never proceed without org context, on the banner alone. (2) A typed degraded-mode status line - when a server is genuinely unreachable after that live check, the worker must use one exact status verb the classifier already recognizes (chosen: the existing 'blocked:' verb, with a fixed template 'blocked: unreachable (confirmed by a live call, not the startup banner)' - verified against bin/fm-classify-lib.sh's status_is_terminal_verb/status_is_captain_relevant, which only recognize working/needs-decision/blocked/paused/done/failed/resolved/captain-held; do not invent a new verb). (3) Findings become candidates, not writes - the worker must record durable findings (knowledge-store drift, a ticket whose real state differs from the brief, verified tool behavior, a trap) as working: CANDIDATE - {finding} status lines for the supervisor to promote, and must NEVER write to PP Brain or any shared memory itself; this reuses the existing status-file channel the supervisor already reads on every append rather than creating a new one. (4) Declare the wait, not just done - after opening the PR/MR (direct-PR and no-mistakes delivery modes only; local-only never opens one), the worker must append a done: PR/MR {url} line immediately followed by a paused: {why} line naming the wait, using the existing / forge-vocabulary variables so this stays correct for both GitHub and GitLab, because a declared pause gets a long recheck cadence while a bare done: alarms every few minutes indefinitely until merge. (5) Correct the pause wording - the wait is on a colleague's approval, never the captain's merge decision, because the captain cannot approve their own merge/pull request; this wording must be correct everywhere it is introduced (verified no occurrence of the wrong wording survives in the file). (6) Require the retrospective, and one real return - before its final done:/failed: line, the worker must run the retrospective skill in its no-human-reachable mode (gated writes become drafted pending items rather than skipped or assumed), mandatory when it hit a gotcha/trap/anything that cost time; the worker must also send at least one working: status carrying real substance before its terminal line, never a report that is a single done: line with nothing before it. Constraints honored: bin/ is firstmate's shared tracked material (firstmate-coding-guidelines skill loaded before editing); upstream carries five unmerged commits touching this same file, so the change is additive/surgical rather than restructuring; this repo's no-mistakes usage and its CI attestation-block-in-PR-body convention were NOT stripped (that rule is for company repos, not this one); source comments default to none with a hard 3-line cap and no ticket ids. Acceptance already verified before this run: bash -n passes; all four brief variants (ship no-mistakes/direct-PR/local-only/herdr-lab, scout, secondmate) were scaffolded into scratch dirs and inspected, including a GitLab-remote ship brief to confirm MR wording; worktree-isolation assertion, keyed decision/blocker semantics, forge-vocabulary derivation, and the Herdr lab contract (including its loud NOT-ENABLED declaration) were all confirmed intact and unchanged; bin/fm-lint.sh (pinned shellcheck) passes clean.
What Changed
bin/fm-brief.shnow emits a PP Brain grounding contract in ship briefs: a session-startpp-brain: auth_missingbanner is declared a known false positive, the worker must make one realsearch_knowledgecall before acting on it, and only a genuinely failing live call justifies the fixedblocked: <server> unreachable (confirmed by a live call, not the startup banner)status line.note:status verb in the Rule 4 state list: durable findings are recorded asnote: CANDIDATE - {finding}for firstmate to promote instead of the worker writing to PP Brain or any shared memory,note:is declared nonterminal alongsideworking:, and the brief discloses that the supervisor's wedge guards do not yet covernote:. Rule 4 also now requires at least one substantiveworking:line before the firstdone:/failed:, and adds a forge-vocabulary pause note (a wait on an open PR/MR is a colleague's approval, never the captain's merge decision) that is suppressed inlocal-onlymode. Scout briefs and secondmate charters are unchanged.AGENTS.mdrecords the matching routing duty for thenote: CANDIDATEchannel;tests/fm-brief.test.shadds atest_ship_worker_operating_contractscase asserting the new wording across the no-mistakes, direct-PR, local-only, and GitLab-remote ship variants, and asserting its absence from scout and secondmate output.Risk Assessment
note:) into worker hands whose interaction with the supervisor's wedge guards is a real, reachable hole that this change discloses rather than fixes — safe to merge with the guard fix tracked as the stated follow-up.Testing
Ran the change's own suite (tests/fm-brief.test.sh, all 28 checks pass) and the production consumer test for the note: channel (tests/fm-wake-drain-unread-status.test.sh, all pass), then demonstrated the intent the way a crewmate experiences it: I scaffolded all six brief variants and saved the rendered briefs, then had a simulated crewmate read its status-file path and its literal line templates out of the generated brief and append them, and asked the unmodified production consumers what they made of it — bin/fm-classify-lib.sh parses the fixed degraded-mode line as a terminal, captain-relevant blocked: line, every verb the brief enumerates (note included) is one the classifier already knows so nothing was invented, and bin/fm-wake-drain.sh actually printed the note: CANDIDATE line back under UNREAD STATUS, proving the candidate channel reaches firstmate rather than merely being described. A contract matrix over the rendered briefs confirms the contracts are ship-only, absent from scout/secondmate, that the pause reminder is absent from local-only, that PR/MR and pull-request/merge-request vocabulary is correct per forge with zero occurrences of the wrong captain's-merge-decision wording, and that each PR/MR-opening DOD ends on its done: line with no trailing paused:. I also verified the brief's wedge-guard disclosure is an accurate statement of current supervisor behavior rather than false comfort. No screenshot or rendered-HTML artifact applies: the changed surface is a generated markdown prompt file a worker agent consumes as text in a terminal pane, so the reviewer-visible artifact is the rendered brief itself, included verbatim, plus the CLI transcripts. Everything passed and the worktree was left clean.
Evidence: Rendered ship brief a crewmate receives (no-mistakes mode, GitHub remote) — carries all six contracts
Source: Rendered ship brief a crewmate receives (no-mistakes mode, GitHub remote) — carries all six contracts
Evidence: Rendered ship brief on a GitLab remote (direct-PR) — MR / merge request vocabulary
Source: Rendered ship brief on a GitLab remote (direct-PR) — MR / merge request vocabulary
Evidence: Rendered local-only ship brief — pause reminder correctly absent (mode never opens a PR/MR)
Source: Rendered local-only ship brief — pause reminder correctly absent (mode never opens a PR/MR)
Evidence: Rendered scout brief and secondmate charter — must not duplicate the ship-only contracts
Source: Rendered scout brief and secondmate charter — must not duplicate the ship-only contracts
Evidence: End-to-end: crewmate obeys the generated brief, real drain + classifier consume its lines
Source: End-to-end: crewmate obeys the generated brief, real drain + classifier consume its lines
Evidence: Key excerpt: the note: CANDIDATE line the crewmate wrote, presented back to firstmate by the real drain
Pipeline
Updates from git push no-mistakes
... (15 earlier update rounds omitted to keep the PR body within GitHub's 65536-char limit; full history is in the run log.)
🔧 Fix: reframe note wording guidance, fix overstated assertion
3 issues (1 warning, 2 infos) still open:
bin/fm-brief.sh:556- The round-7 reframe tells the worker that escalation-shapednote:prose "may surface it sooner as well - a difference in timing, not in whether it is seen", and the header comment at bin/fm-brief.sh:74 states"note:" is nonterminal like "working:". Source evidence shows a second consequence the reframe does not cover: such a line also DISABLES wedge detection for that pane. Concrete sequence, with the brief's own instruction followed literally: worker appendsnote: CANDIDATE - upstream already merged the same fix, then its agent process hangs. (a) status_is_captain_relevant (bin/fm-classify-lib.sh:118-136) excludes only working|resolved|captain-held|paused from free-text matching, so verbnotefalls through togrep -qiEagainst FM_CLASSIFY_CAPTAIN_RE_DEFAULT andmergedmatches -> captain-relevant. (b) classify_stale (bin/fm-supervise-daemon.sh:388-400) checkscase $(status_line_verb) in working|resolved|captain-held)for the nonterminal escape;noteis absent, so it takes the terminal path and returnsescalate|stale + terminal status. (c) handle_wake's escalate branch (bin/fm-supervise-daemon.sh:1246) runsstale_marker_removeand writes the seen marker. (d) Every later stale wake for the same unchanged last line dedupes toself|stale + terminal (already escalated by signal), and the*)branch's_clear_wedgeblock (bin/fm-supervise-daemon.sh:1274-1281) uses the same guard list, so verbnotehits*) _clear_wedge=1and calls stale_marker_remove again. The wedge marker is therefore never recorded and housekeeping's persistence recheck never ages it: the hung crewmate escalates exactly once as a false "terminal status" and then goes permanently silent. The identical line written asworking: ...records the marker and does escalate as a wedge. The non-AFK watcher path has the same shape: stale_is_terminal (bin/fm-classify-lib.sh:1363) is just status_is_captain_relevant, so bin/fm-watch.sh:1182-1220 surfaces the note once per hash and never starts wedge_timer_check. This is materially different from the settled 'wording collision' question the owner ruled on in rounds 6-7: that ruling reasoned only about whether the FINDING reaches firstmate (which is correct - print_unread_status_section still prints it), not about losing wedge supervision of the crew. The earliest supported shared boundary is the two nonterminal-verb guard lists in bin/fm-supervise-daemon.sh (:396 and :1276) plus the watcher's terminal branch - note that these are NOT in bin/fm-classify-lib.sh, so the standing no-change constraint on that file does not block the fix. The remedy changes supervisor behavior outside this change's stated brief-wording scope and contradicts the owner's ratified 'harmless timing variability' framing, so it needs authorization rather than an auto-fix.bin/fm-brief.sh:449- The colleague-approval PAUSE_NOTE string is byte-identical at bin/fm-brief.sh:449 (direct-PR) and bin/fm-brief.sh:478 (no-mistakes); only local-only differs by setting it empty. The two copies must stay in sync or the two delivery modes silently drift in the exact wording intent criterion 5 governs, and tests/fm-brief.test.sh asserts the same literal against both. Non-functional dedup: assign the shared text once beforecase "$MODE"and set PAUSE_NOTE="" only in the local-only branch (FORGE_ABBR/FORGE_NOUN are already resolved at line 336-349, well before the case).bin/fm-brief.sh:540- Recorded for traceability only; no action requested. Three stated intent criteria are not implemented as literally written, each by an in-run owner decision already on record: (1) criterion 3 requiresworking: CANDIDATE - {finding}lines; the brief emitsnote: CANDIDATE - {finding}(bin/fm-brief.sh:553) after the owner routed candidates through the note: unread-surface channel in round 5. (2) criterion 4 requires apaused: {why}line immediately after thedone: PR/MR {url}line; both DODs end on their terminal done: line and tests/fm-brief.test.sh:924/:941 assertassert_no_grep "paused:"over each - dropped by the owner in rounds 1, 3 and 5 because every consumer classifies from the LAST status line, so a trailing pause would mask the completion and hide the url. (3) criterion 6's retrospective half is absent and tests/fm-brief.test.sh:920 now asserts the word cannot appear; dropped by the owner in round 7. Criterion 6's second half (a substantiveworking:line before the first terminal line) IS implemented at bin/fm-brief.sh:559-561, and criteria 1, 2 and 5 are implemented verbatim and verified in the generated output for GitHub, GitLab and all three ship modes.🔧 Fix: disclose note wedge-guard gap, dedupe pause note
4 issues (1 warning, 3 infos) still open:
bin/fm-brief.sh:554- Intent criterion 3 requires the worker "must NEVER write to PP Brain or any shared memory itself". The brief instead says "never write to PP Brain or any shared memory system beyond this workstation directly" (bin/fm-brief.sh:553-554, restated in the header at :74). That qualifier was added in round 2 (a3a1b3d) for one reason: the same brief then mandated the retrospective skill, whose agentmemory lesson/observation saves would have violated an unqualified ban - round 7 (7ea7687) even spelled that out as a "narrow exception". Round 7's successor (77b29ca) removed the retrospective mandate entirely (tests/fm-brief.test.sh:920 now asserts the word cannot appear) and dropped the explicit exception, but kept the qualifier. Nothing in the current generated brief requires any memory write: Grounding only READS the local memory store (:518), and Project memory writes AGENTS.md inside the worktree via the branch. So the surviving qualifier grants a permission with no remaining consumer, and reads to a worker as explicit license formemory_lesson_save-class writes into the workstation-local store that the very next crewmate's Grounding search will read back - the unpromoted-durable-write drift criterion 3 exists to prevent. Minimal remedy (revert to the pre-round-2 wording rather than layering more prose): drop "beyond this workstation" so the sentence ends "or any shared memory system directly", and make the header at :74 match; tests/fm-brief.test.sh:899 asserts only up to "any shared memory system", so it stays green. Flagging rather than fixing because this is worker-visible contract prose the owner has deliberately reworded three times in this run - if the qualifier is being kept on purpose (e.g. to avoid conflicting with a harness-level agentmemory hook the crewmate does not control), say so and it can stand as a ratified deviation.bin/fm-brief.sh:74- The header summary still asserts flatly that"note:" is nonterminal like "working:", which is true of the brief's prose but not of the supervisor: the body at :555-559 now discloses the opposite for wedge detection. More importantly, that five-line disclosure is coupled to code it never names. When the separately-filed guard fix lands (addingnoteto theworking|resolved|captain-heldenumerations at bin/fm-supervise-daemon.sh:396 and :1279, plus the watcher's stale_is_terminal path), every ship brief will keep telling crewmates about a gap that no longer exists, and nothing fails: tests/fm-brief.test.sh:882-889 assert the stale wording is PRESENT, so the suite actively pins it. Mechanical remedy: qualify the header line and add a one-line cross-reference naming those two guard sites as the removal trigger for the :555-559 paragraph, so the disclosure is discoverable from the code that owns the defect (fits the file's existing header-as-documentation convention and the 3-line comment cap).bin/fm-brief.sh:555- Recorded as a property of the chosen channel, not a defect. The brief promises "Everynote:line reaches firstmate: the next status drain presents it whatever its wording", which is accurate - status_line_is_unread_surface (bin/fm-classify-lib.sh:1037-1040) short-circuits on verbnote, and print_unread_status_section runs on every drain including the empty-queue fast path. But that presentation is explicitly one-shot: fm-wake-drain.sh:107 prints the section headed "not re-printed after this presentation" and the cursor then advances past those bytes. So anote: CANDIDATE - ...line firstmate does not promote during that single drain is never re-surfaced; it survives only as a line in the durable status file that someone must re-read deliberately. Intent criterion 3 chose this channel on purpose ("reuses the existing status-file channel ... rather than creating a new one"), and any promotion-retry machinery would be new durable state outside this change's scope, so no action is requested - noting it so the promotion side is a conscious expectation rather than an assumed guarantee.bin/fm-brief.sh:552- Re-recorded for traceability only; no action requested, all three ratified in this run's round history. (1) Criterion 3 asks forworking: CANDIDATE - {finding}lines; the brief emitsnote: CANDIDATE - {finding}(:552) after the owner routed candidates through the note: unread-surface channel in round 5. (2) Criterion 4 asks for apaused: {why}line immediately after thedone: PR/MR {url}line; both PR-opening DODs end on their terminal done: line and tests/fm-brief.test.sh:924/:941 assertassert_no_grep "paused:"over each - dropped in rounds 1/3/5 because every consumer classifies from the LAST status line, so a trailing pause would supersede the completion and hide the url. (3) Criterion 6's retrospective half is absent and tests/fm-brief.test.sh:920 asserts the word cannot appear - dropped in round 7 so no brief mandates a write escaping the disposable worktree. Criterion 6's other half (a substantiveworking:line before the first terminal line) is implemented at :560-562, and criteria 1, 2 and 5 are implemented verbatim - I re-rendered no-mistakes/direct-PR/local-only briefs against both a GitHub and a GitLab remote and confirmed the banner/live-call contract, the fixedblocked: <server> unreachable (confirmed by a live call, not the startup banner)template (accepted by status_is_terminal_verb), and the colleague-approval wording in both PR and MR vocabulary with no wrong-wording occurrence anywhere in the file.🔧 Fix: unqualify shared-memory ban, align header, mark disclosure
3 infos still open:
bin/fm-brief.sh:559- Recorded, not blocking — the owner deferred the guard fix to a separate fleet-wide task in round 9 and the brief discloses it honestly. Concrete path: the brief now instructs workers to emitnote: CANDIDATE - {finding}and names "a ticket whose real state differs from this brief" as a prime example, so a line likenote: CANDIDATE - ticket says open but the MR was already mergedis likely. status_is_captain_relevant (fm-classify-lib.sh:120) does not exclude verbnote, so the free-text default regex (...|merged) matches and returns 0. classify_stale (fm-supervise-daemon.sh:387) then finds it captain-relevant but non-terminal, and its exclusion case at :396 only lists working|resolved|captain-held — so it falls through toescalate|stale + terminal status. On the next wake with the same last line, handle_wake's*)branch computes _clear_wedge=1 at :1279 (again note is absent from the enumeration) and calls stale_marker_remove, so a genuinely wedged pane stops aging and is never re-surfaced. fm-watch.sh:1182's stale_is_terminal path inherits the same classification. The remedy is in those three guards, not in this file; the source comment at bin/fm-brief.sh:509-511 already names them as the removal trigger for the disclosure.bin/fm-brief.sh:447- Traceability record only; both deviations were ratified by the task owner earlier in this run. (1) Criterion 4 requires apaused: {why}line "immediately followed by" thedone: PR/MR {url}line; no brief emits one — both PR-opening DODs end on their terminal done: line and tests/fm-brief.test.sh assertsassert_no_grep "paused:"over each DOD. It was dropped because every consumer classifies from the LAST status line, so a trailing pause would supersede the completion and hide the url; what remains is PAUSE_NOTE (line 447), which only corrects how a declared wait must be worded, not that one be declared. (2) Criterion 6's retrospective half is absent and the test asserts the word cannot appear, dropped in round 7 so no brief mandates a write escaping the disposable worktree. Criterion 6's other half (a substantiveworking:line before the first terminal line) is implemented at :563-565, and criteria 1, 2, 3 and 5 are implemented as specified.tests/fm-brief.test.sh:892-assert_no_grep 'Say it another way' "$brief"guards against a phrase that only ever existed in a fix-round draft that was reverted before this HEAD; no current or plausible future brief wording contains it, and its failure message ("ship brief again coaches the worker to swap specific words") is unintelligible without that discarded history. It can only ever pass, so it adds a line of noise to the contract test without constraining anything. The sibling negative assertions on the same block ('beyond this workstation', 'narrow exception') do map to wording intent criterion 3 forbids, so those are worth keeping; only this one is inert. Remedy is deleting the two lines.✅ **Test** - passed
✅ No issues found.
bash tests/fm-brief.test.sh— full fm-brief suite including the newtest_ship_worker_operating_contracts(28 checks, all pass)bash tests/fm-wake-drain-unread-status.test.sh— the production consumer of thenote:unread-status channel the brief promisesScaffolded every brief variant a real crewmate receives:bin/fm-brief.sh <id> gh-proj --mode no-mistakes|direct-PR|local-only,bin/fm-brief.sh <id> gl-proj --mode direct-PR(GitLab remote),--scout, and--secondmate --no-projectsEnd-to-end brief→supervisor demo: extracted the status-file path and the literalblocked:/note: CANDIDATE - {finding}/done: PR {url}templates out of the generated brief, appended them as a crewmate would, then ran the realbin/fm-wake-drain.sh(FM_STATE_OVERRIDE) and confirmed the CANDIDATE note was presented underUNREAD STATUSFed the brief-prescribed lines through the unmodifiedbin/fm-classify-lib.sh:status_is_terminal_verb,status_is_captain_relevant,status_is_paused,status_line_verb,status_line_is_unread_surface— plus every verb in the brief'sStates:enumeration to prove none was inventedPer-variant contract matrix over the rendered briefs: contract presence per variant, PR/MR + pull-request/merge-request forge vocabulary, zero occurrences of the wrong "captain's merge decision" wording, and the last status-line instruction in each PR/MR-opening DOD (no trailingpaused:)Verified the brief's wedge-guard disclosure is truthful:status_is_captain_relevantonnote: CANDIDATE - PR ready for reviewvsworking: PR ready for review, andnoteabsent from theworking|resolved|captain-heldenumerations atbin/fm-supervise-daemon.sh:396and:1279bin/fm-brief.sh --help— confirmed the reworded header/summary renders and matches the body contractsgit status --porcelain— worktree left clean; all evidence written outside it✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.