Skip to content

feat(brief): forbid leading cd in generated scout and ship briefs - #7481

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
Azd325:fm/fm-3598-no-leading-cd-rule
Oct 20, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
Azd325:fm/fm-3598-no-leading-cd-rule

Conversation

@Azd325

@Azd325 Azd325 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3598

Contract class: new-default (per the maintainer triage).
Dismissing the approval prompt from the control plane is a later follow-on and stays out of scope.

What Changed

  • bin/fm-brief.sh defines a shared SHARED_NO_CD_RULE (rule 8). It forbids starting a shell command with cd and forbids searches that depend on the current directory. It directs crewmates to use absolute paths, git -C <abs>, or a ( cd <abs> && ... ) subshell, and to pass the rule to every sub-agent they launch.
  • The rule is added after SHARED_INFRA_RULE in both the ship and scout brief templates, so the two briefs carry identical text.
  • tests/fm-brief.test.sh extends test_crewmate_scaffolds_forbid_pool_administration. It checks that the ship brief emits the rule, that the scout brief's rule matches it, and that the scout brief tells sub-agents to follow it.

Risk Assessment

✅ Low: The change adds one shared static rule (8) to the scout and ship brief templates, as the maintainer triage requires. Rule 8 forbids a leading cd and cwd-dependent searches, requires absolute paths, git -C, or a subshell, and tells the worker to pass the rule to sub-agents. No other emitted rule uses number 8, and no other emitted brief text tells the worker to start a command with cd. The test checks the generated brief, which is the prompt the agent receives: it confirms the rule is present and identical in both brief kinds, and it would fail before the fix.

Testing

I ran the brief generator for scout and each ship mode in a disposable home and confirmed the new rule appears verbatim in every generated brief. The existing fm-brief test file also passes. Dismissing the approval prompt from the control plane is out of scope, and I did not drive a live Claude session against the deny-rule behavior.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Scout brief generated by fm-brief.sh contains the no-leading-cd rule with sub-agent propagation ✅ pass live briefs-rule.txt (s1)
Ship briefs in no-mistakes, local-only and direct-PR modes contain the identical rule ✅ pass live briefs-rule.txt
Ship and scout rule text cannot drift apart (test suite) ✅ pass live bash tests/fm-brief.test.sh exit 0
Evidence: generated briefs rule 8

Source: generated briefs rule 8

== s1
71:8. Never start a shell command with `cd`, and never run a search whose path depends on the current directory.
72-   Use absolute paths, `git -C <abs>`, or a `( cd <abs> && ... )` subshell.
73-   Pass this rule to every sub-agent you launch.
== p-no-mistakes
83:8. Never start a shell command with `cd`, and never run a search whose path depends on the current directory.
84-   Use absolute paths, `git -C <abs>`, or a `( cd <abs> && ... )` subshell.
85-   Pass this rule to every sub-agent you launch.
== p-local-only
80:8. Never start a shell command with `cd`, and never run a search whose path depends on the current directory.
81-   Use absolute paths, `git -C <abs>`, or a `( cd <abs> && ... )` subshell.
82-   Pass this rule to every sub-agent you launch.
== p-direct-PR
80:8. Never start a shell command with `cd`, and never run a search whose path depends on the current directory.
81-   Use absolute paths, `git -C <abs>`, or a `( cd <abs> && ... )` subshell.
82-   Pass this rule to every sub-agent you launch.

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Scout brief generated by fm-brief.sh contains the no-leading-cd rule with sub-agent propagation ✅ pass live briefs-rule.txt (s1)
Ship briefs in no-mistakes, local-only and direct-PR modes contain the identical rule ✅ pass live briefs-rule.txt
Ship and scout rule text cannot drift apart (test suite) ✅ pass live bash tests/fm-brief.test.sh exit 0
  • bash tests/fm-brief.test.sh (exit 0, including the new ship/scout rule-parity assertions)
  • Ran bin/fm-brief.sh live for --scout and --mode no-mistakes/local-only/direct-PR in a temp FM_HOME and inspected the emitted brief.md
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thanks @Azd325, this looks good from our side. Head c40fb649 is MERGEABLE/CLEAN, all CI checks are green (including Behavior portable serial 2 and Herdr), and the no-mistakes attestation matches this head with live validation 3/3 go.

Contract-class: new-default. Every generated scout and ship brief now carries a new rule 8 (no leading cd, no cwd-dependent searches, absolute paths / git -C / subshell, and pass the rule to sub-agents). That changes what every unconfigured crewmate is told to do, so it is a new default, not a restore. It matches the fix #3598 asked for. I checked the diff: it touches only bin/fm-brief.sh and tests/fm-brief.test.sh, it adds no workflow, secret or network surface, and rule 8 does not collide with any existing numbered rule.

VISION: aligns. Unattended workers stop stalling on approval prompts, which helps peace of mind. It also strengthens a refusal path, stays deterministic in the brief generator, and binds to harness-agnostic brief semantics rather than to a vendor UI.

This is now a captain decision hold: new-default changes are never auto-merged, so it is waiting on Kun to decide whether to merge. Nothing is waiting on you.

@kunchenguid
kunchenguid merged commit 9731630 into kunchenguid:main Oct 20, 2026
20 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @Azd325 — really appreciate you taking the time on this.

Pibomeister added a commit to Pibomeister/firstmate that referenced this pull request Oct 22, 2026
…ort kept (#15)

* fix: parse list-form Lavish results without dropping answers (#5404)

* fix(bin): parse Lavish list-form results and refuse unparsed blocks

Lavish emits its queued prompts in TOON list form instead of table form as
soon as the items stop being uniform, for example when some annotations carry
a nested target object or a message carries an attachments table. The adapter
only recognized the table header, so read reported a complete, empty result
and answers closed nothing.

Move the result parsing into one shared reader used by read, answers, and
reconciles that accepts both forms, keeps only column-zero headers, skips
nested structures only beneath the field that opened them, and counts
anything it cannot account for as malformed. An unrecognized header naming
the block is now malformed rather than an empty result, answers and
reconciles exit nonzero when the result is not fully accounted for, and the
queued-content check treats a list header as content.

Refs #4726

* no-mistakes(document): Document Lavish capture formats and incomplete-result handling

* test: expect captain_message_count for the open-board list-form capture

* fix: correct Pi wake ownership and processing-turn handling (#5835)

* fix(pi): let the supervision branch claim Orca stale wakes

The watcher keys Orca endpoints by terminal=, but the branch dispatcher
only indexed window=, so every Orca stale row vetoed the wake scan and
went to main. Index both endpoint fields.

Local hotfix ahead of upstream; refs kunchenguid/firstmate#5623.

* test(pi): cover terminal-keyed Orca stale rows in branch dispatch

Pins the terminal= endpoint lookup: a terminal-keyed stale row queued with
another eligible row must resolve to its task in both routine and heartbeat
scans, instead of vetoing the wake to main.

* no-mistakes(document): Update supervision dispatch doc for Orca terminal-keyed stale rows

* fix(pi): reject conflicting wake endpoint ownership

Index task keys and window/terminal aliases through one ownership check.
Ambiguous records must leave the wake on MAIN instead of selecting the
last task and possibly bypassing another owner's open decision.

Cover duplicate terminals and collisions with window and task keys in
both record orders while preserving unique terminal routing.

* no-mistakes(document): Document conflicting alias ownership as scope corruption

* fix(pi): retain ownership claims from incomplete task records

Check endpoint and task alias ownership before project eligibility so a
projectless record cannot lose its open decision to another terminal owner.
Require project context before decision filtering can grant routing scope.

Cover missing and empty project fields in both record orders, and preserve
refusal for a uniquely mapped terminal without project context.

* no-mistakes(review): Fix canonical routing ownership and custom SDK event handling

* no-mistakes(review): Preserve dedicated custom processing run ownership

* no-mistakes(document): Clarify Pi event handling and fail-closed routing documentation

* feat(bin): add a forge=external review rail that never pushes task branches (#7368)

* feat(bin): add a forge=external review rail that never pushes task branches

A project whose review tool uploads its own snapshot of the worker's local
commits can now be registered [direct-PR forge=external]. Workers on such a
project never need to push a branch to publish, and must never push a task
branch to the shared origin.

- fm-project-mode.sh: external joins the closed forge set; never detected,
  refused on local-only, and +yolo reports yolo=off with a refusal.
- fm-dod-lib.sh: external ships direct-PR only; its first rule forbids origin
  and task-prefixed pushes, its Definition of done renders the home's
  config/external-review.md adapter verbatim, and the ready-report gate
  accepts `done: review <url> uploaded for review` on the URL alone or, with a
  recorded backup remote, once HEAD is on the backup namespace.
- fm-git-push-guard.sh (new): per-task pre-push guard refusing pushes to
  origin or a URL matching origin's, task-branch and task-prefixed refs on any
  remote, and refs outside the backup prefix on the backup remote.
- fm-git-strip-ai-trailers.sh: install gains --push-guard and --no-strip.
- fm-spawn.sh: refuses yolo, a missing adapter, and an unusable backup
  remote before launch; installs the guard even under keep-ai-trailers; and
  records forge=external, backup_remote=, and backup_prefix=.
- fm-review-check.sh (new): records review= and review_head= with no merge
  watch, and publishes the child's ready line in a secondmate home.
- fm-promote.sh refuses promotion onto forge=external, because a scout
  launches without the guard.
- Docs: docs/external-review-forge.md (design), configuration.md's new
  "External review tool" section, scripts.md, and the ship-landing and
  project-management skills.

* no-mistakes(review): Drop string-grep hook assertion from external-review spawn test

* no-mistakes(document): Note forge=external contract token and direct-PR-only composition

* test(pi): Lauf ohne prompt in before_agent_start festnageln (#7387)

Ein Lauf, den sendCustomMessage startet, traegt eine Custom-Nachricht und
keinen prompt. Das Lesen des prompt an dieser Stelle warf, womit jeder
solche Lauf mit einem Fehler auftauchte statt zu starten.

Die Verengung dagegen steht seit 8c9c67de im Zweig, ein Test, der sie
benennt, fehlte: die einzige Abdeckung lag beilaeufig in einem
Abbruch-Fall der Abwesenheits-Haltung und verschwindet mit ihm. Der neue
Fall erweitert den bestehenden Mirror-Test und prueft, dass ein solcher
Lauf weder wirft noch als Dialog gespiegelt wird.

Gegenprobe: ohne die Verengung wirft genau dieser Fall mit
"Cannot read properties of undefined (reading 'trim')".

Co-authored-by: thelad-dev <[email protected]>

* fix(bin): stop tmux target checks reporting gone windows as alive (#7409)

* fix(tmux): verify exact endpoint membership

* fix(tmux): preserve exact target forms

* test(tmux): align endpoint fixture lifecycles

* test(tmux): guard isolated cleanup and shell reader

* no-mistakes(review): Limit tmux .pane target split to window indexes

* fix(composer): prove opencode 1.19 de-emphasised mode footer from the plain row (#7395)

* fix(bin): stop misreading opencode's own footer as pending composer text

An idle OpenCode composer classified as `pending`, and that verdict gates every
typed-plane action firstmate owns: fm-send skips the doorbell, and fm-control
refuses both relaunch and exit. A firstmate operator lost a full session to it and
had to type into worker panes by hand three times.

Root cause: opencode 1.19 draws the mode/model footer's identifying cells
de-emphasised (mode word RGB 67;133;190, middle-dot separators 111;110;105,
luminances ~119.8 and ~109.7, both under fm_composer_strip_ghost's 128
threshold). That helper exists to answer "what did the human type?", so it
deleted exactly the cells that identify the footer. The `^(Build|Plan)` anchor
then became unreachable on every styled backend - tmux, Herdr, and Zellij - not
just one pane, because the unstyled row keeps its styling bytes everywhere.

The fix proves the footer from both forms of that row: the ghost-stripped
content and the ANSI-stripped plain row. Proving it on the form ghost stripping
cannot reach is the whole repair.

What makes that safe, and why the previous argument was not: the earlier draft
argued safety by noting that on a plain capture the two forms collapse to one
string, so the verdict is unchanged. That is true and carries no weight, because
styled=0 is the only configuration where the new proof does nothing. The
exemption is safe because a row reaches the plain form only when the
ghost-stripped row still fails the pattern, which means the stripped content is
non-empty while its own leading Build/Plan cell was deleted as ghost. Nothing
opencode draws de-emphasises a typed row's leading cells - only its furniture is
drawn dimmed - so the only rows the plain form admits beyond the stripped one
are de-emphasised furniture, and the mode footer is the only furniture opencode
draws that opens with a mode word. That is self-confirming rather than asserted,
and it is the argument to recheck when a new opencode release moves a colour.

A review also caught a second change riding along in the same diff: the footer
pattern had been widened from `[[:space:]]+` to `[[:space:]]*`, admitting
`Build ·x` and a bare `Build ·`. Both read as more typeable than the footer, so
they moved the verdict in exactly the direction this rule exists to prevent. No
recorded opencode footer ends at the dot, so the original `+` matches every real
capture and the widening is reverted.

Verification:
- fm-lint.sh exit 0 on pinned shellcheck 0.11.0 and actionlint 1.7.12.
- fm-doc-audience-check.sh ok across 119 surfaces and 757 local links.
- tests/fm-composer-lib.test.sh green via bin/fm-test-run.sh.
- The new regression case fails on exactly one assertion when this change is
  reverted: "opencode 1.19.0 de-emphasised footer row: expected empty, got
  'pending'", which is the reported symptom.
- Confirmed end to end against live panes rather than only fixtures: a real idle
  opencode 1.19.0 worker classified empty after the change and pending before,
  and firstmate reached the worker over the steer channel afterwards.

* no-mistakes(review): fix(bin): apply leftbar footer rule in content extractor; correct cursorless claim

* no-mistakes(document): document opencode 1.19 footer furniture and extractor coverage

* no-mistakes(document): document ghost-luma knob coupling to opencode footer furniture

* no-mistakes(document): document opencode de-emphasised footer recognition invariant

* no-mistakes(review): fix(docs,bin): correct ghost-luma knob direction, gate plain-row extraction

* no-mistakes(review): fix(docs,bin,tests): correct ghost-luma knob wording, share plain-content helper, cover Herdr/Zellij idle

* no-mistakes(document): narrow overstated backend coverage claim in runtime-backends.md

* no-mistakes(document): document leftbar footer override and opencode 1.19 pointer

* test(send): codex im Tuerklingel-Test hook-frei starten (#7406)

Der Kopf des Tests sagt, jedes Programm werde so gestartet, wie
bin/fm-spawn.sh es startet. Im codex-Zweig von launch_cmd fehlte dabei
--disable hooks, das fm-spawn im crewmate- und scout-Pfad setzt.

Ohne den Schalter parkt codex auf dem Hook-Vertrauensdialog ("N hooks
are new or changed"), dessen Auswahl auf "Review hooks" aufsetzt und der
mit der Tastenebene dieses Werkzeugs nicht beantwortbar ist. Der Lauf
meldet dann die Tuerklingel als nicht befolgt, obwohl er ueber die
Tuerklingel gar nichts ausgesagt hat - und das auf jedem Checkout, weil
schon die projekteigene .codex/hooks.json den Dialog aufzieht.

Dazu eine knappe Zusicherung am Startrezept, damit der Schalter beim
naechsten Umbau nicht wieder still ausfaellt.

Co-authored-by: ladwein <[email protected]>

* fix(bin): store only classified review fields in contribution records (#7096)

* fix(bin): store only classified review fields in contribution records

A pull observation stored GitHub's raw reviews payload, so a PR with a few
hundred reviews wrote a record past the 1 MiB read cap and every pending,
verdict and ack read then refused the whole home. Project each stored review
to id, state, submitted_at, commit_id and user.login, the only fields the
classifier reads, and add a many-review regression.

* no-mistakes(document): clarify contribution record read cap in script header

* fix: handle Pi 1.1 and 1.2 supervision events correctly (#7216)

* fix(pi): retain custom-event handling and processing cancellation

* fix(pi): identify custom triggers before legacy prompt narrowing

* no-mistakes(test): Correct branch fixture retirement and verify real notification ownership

* no-mistakes(document): Clarify Pi event boundaries and verification scope

* fix(pi): retain custom-event handling and processing cancellation

* fix(pi): identify custom triggers before legacy prompt narrowing

* no-mistakes(test): Correct branch fixture retirement and verify real notification ownership

* no-mistakes(document): Clarify Pi event boundaries and verification scope

* no-mistakes(review): Fix SDK1.1 prompt staging and verify branch context

* no-mistakes(document): Clarify SDK prompt compatibility and branch-context verification

* no-mistakes(test): Require dual-SDK compiler checks; execution remains pending

* no-mistakes(document): Correct SDK typecheck documentation and stale dependency claims

* no-mistakes(document): Correct stale Pi typecheck documentation and ownership pointers

* no-mistakes(ci): Fixed SC2329 in tests/fm-pi-primary-types.test.sh by inlining EXIT cleanup. Also fixed a reproduced macOS npm-prefix/lockfile path failure without changing dependency pins or assertions. Canonical targeted lint, strict TypeScript 5.9.3 checks against Pi 1.1.0 and 1.2.0, and success/failure cleanup checks pass. Both behavior-shard failures were upstream npm ETARGET errors in