Skip to content

feat(bin): bake token-economy brevity caps into generated worker briefs - #12

Merged
Hozzy02 merged 3 commits into
mainfrom
fm/fm-brief-brevity-caps
Sep 25, 2026
Merged

Hozzy02 merged 3 commits into
mainfrom
fm/fm-brief-brevity-caps

Conversation

@Hozzy02

@Hozzy02 Hozzy02 commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Intent

Bake the captain's token-economy caps into the generated worker instructions in bin/fm-brief.sh (ship, scout, and secondmate charter variants): status lines under 300 characters; commit messages one subject line plus at most 3 prose body lines (git trailers outside the cap); PR description at most 5 lines plus the attribution footer; no narration of routine progress. The secondmate charter additionally says that once its queue is empty and its children are torn down it goes idle, and the main firstmate sends /clear (a secondmate cannot self-issue it). Keep wording short, do not duplicate existing lifecycle text. Colocated tests in tests/fm-brief.test.sh assert the caps appear in each variant. Shellcheck clean.

What Changed

  • bin/fm-brief.sh now puts the captain's token-economy caps into every brief it generates. Ship and scout briefs get them as a numbered "Brevity caps" rule, and the secondmate charter gets them in a new # Brevity section. The caps are:
    • status lines stay under 300 characters
    • a commit message is one subject line plus at most 3 body lines, and git trailers don't count toward the limit
    • a PR description is at most 5 lines plus the attribution footer
    • routine progress is not narrated
  • The secondmate charter adds one lifecycle line. Once a secondmate's queue is empty and its children are torn down, it goes idle and the main firstmate sends /clear, because a secondmate can't issue it itself. The secondmate-provisioning skill now documents this step from the main firstmate's side, using bin/fm-send.sh.
  • tests/fm-brief.test.sh adds test_brevity_caps_in_every_variant. It checks that the caps appear in the ship, scout and secondmate briefs, and that the /clear rule appears in the secondmate charter (matched as a fixed string).

🤖 Generated with Claude Code

Risk Assessment

✅ Low: This is a small, prompt-text-only change. It adds the caps to all three worker variants through unquoted heredocs, so the variables expand correctly, and it adds tests that use fixed-string checks on each variant and on the /clear rule, which matches what the intent asks for.

Testing

I ran the colocated test file tests/fm-brief.test.sh. It passed, including the new brevity-caps test. I also generated real ship, scout and secondmate briefs with bin/fm-brief.sh. The ship and scout briefs carry the four caps on one line as rule 8. The secondmate charter carries them in a # Brevity section, plus one short new line: go idle, then the main firstmate sends /clear, which the secondmate can't send itself. The generated briefs and the grep transcript are saved as evidence. I did not run shellcheck, because this phase does not run linters.

Evidence: Brevity caps and /clear rule as they appear in each generated brief

===== ship brief ===== 46:8. Brevity caps: Status lines stay under 300 characters. Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap. PR descriptions: at most 5 lines plus the attribution footer. Do not narrate routine progress. ===== scout brief ===== 39:8. Brevity caps: (same line) ===== second brief ===== 33:# Brevity 34:Status lines stay under 300 characters. 35:Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap. 36:PR descriptions: at most 5 lines plus the attribution footer. 37:Do not narrate routine progress. 61:Once your queue is empty and your children are torn down, go idle; the main firstmate sends /clear (you cannot self-issue it).

===== ship brief =====
46:8. Brevity caps: Status lines stay under 300 characters. Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap. PR descriptions: at most 5 lines plus the attribution footer. Do not narrate routine progress.
===== scout brief =====
39:8. Brevity caps: Status lines stay under 300 characters. Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap. PR descriptions: at most 5 lines plus the attribution footer. Do not narrate routine progress.
===== second brief =====
33:# Brevity
34:Status lines stay under 300 characters.
35:Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap.
36:PR descriptions: at most 5 lines plus the attribution footer.
37:Do not narrate routine progress.
57:You are persistent by default. Do not exit just because your queue is empty.
61:Once your queue is empty and your children are torn down, go idle; the main firstmate sends `/clear` (you cannot self-issue it).
Evidence: Generated ship brief
You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
{TASK}

# Herdr lifecycle declaration - NOT ENABLED
**HARD SAFETY GATE:** this scaffold cannot inspect the task text that replaces the task placeholder above later.
If the task will start, stop, delete, restart, profile, or otherwise drive Herdr lifecycle behavior, stop and regenerate the brief with `--herdr-lab` before dispatch.
Do not add Herdr lifecycle commands to this unguarded brief by hand.

# Setup
You are in a disposable git worktree of firstmate, at a detached HEAD on a clean default branch.

**Verify isolation before anything else.** Run `pwd -P` and `git rev-parse --show-toplevel`; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, not the primary checkout firstmate operates from.
The path check is authoritative: `git rev-parse --git-dir` and `git rev-parse --git-common-dir` can help inspect the repo, but they do not prove you are outside the primary checkout.
If the top-level path is the primary checkout or not the worktree you were launched in, STOP - do not branch or commit here - append `blocked: launched in primary checkout, not an isolated worktree` to the status file and stop.

1. First action: create your branch: `git checkout -b fm/ev-ship`
2. Run `no-mistakes doctor`; if it reports the repo is not initialized here, run `no-mistakes init`.

# Rules
1. Never push to the default branch. Never merge a PR.
2. Stay inside this worktree; modify nothing outside it.
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
   `echo "{state}: {one short line}" >> '/var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/tmp.8lHdZOPwTG/state/ev-ship.status'`
   States: working, needs-decision, blocked, paused, done, failed.
   Each append wakes firstmate, so report sparingly: only phase changes a supervisor
   would act on (setup done, bug reproduced, fix implemented, validation passed) and the
   needs-decision/blocked/paused/done/failed states. No step-by-step FYI progress lines;
   firstmate reads your pane for that.
   A mid-task `working:` line (including setup complete) is nonterminal: do not end the
   turn after it; continue the same stage until a defined `done:` gate under Definition of done.
   Use `paused: {why}` - distinct from `blocked:` - ONLY when you are deliberately idling on a
   known external wait you expect to clear on its own (an upstream release, a rate-limit reset,
   a scheduled window): firstmate then leaves your idle pane alone and rechecks it on a long
   cadence instead of treating it as a possible wedge. Use `blocked:` when you are stuck and need help.
5. If you hit the same obstacle twice, append `blocked: {why}` and stop; firstmate will help.
6. If a decision belongs above the implementation worker (product choices, destructive actions, ask-user findings),
   append `needs-decision: {summary of options}` and stop. Firstmate will apply the configured authority and reply with the decision.
   A decision or blocker you opened stays open until a `resolved` line carrying its exact key lands; a later `done:` or `working:` line never closes it, even when the answer is what started that work.
   Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append `resolved: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never stop, restart, or update the shared `no-mistakes` daemon - it is one instance serving
   every lane/home, so restarting it kills other lanes' in-flight pipeline runs. On ANY no-mistakes
   daemon error, append `blocked: {the daemon error}` and stop; only firstmate manages the daemon.
8. Brevity caps: Status lines stay under 300 characters. Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap. PR descriptions: at most 5 lines plus the attribution footer. Do not narrate routine progress.

# Project memory
If `AGENTS.md` or `CLAUDE.md` already exists, or if this task produced durable project-intrinsic knowledge, run `/Users/randalwade/.no-mistakes/worktrees/3a2378ca6c3e/01M3B88274DCNCKYF2G0DMCSSR/bin/fm-ensure-agents-md.sh .` in the worktree.
Record only project knowledge useful to almost every future session.
For anything the codebase already shows, prefer a pointer to the authoritative file, command, or doc over copying the detail.
If you touch a project `AGENTS.md` that lacks `## Maintaining this file`, add that short self-governance section from `/Users/randalwade/.no-mistakes/worktrees/3a2378ca6c3e/01M3B88274DCNCKYF2G0DMCSSR/bin/fm-ensure-agents-md.sh` in the same pass.
Keep it proportionate: skip `AGENTS.md` edits for trivial tasks that produced no durable project knowledge.

# Definition of done
Delivery contract: mode=no-mistakes
The task is complete only when committed on your branch.
When you believe it is complete, append `done: {summary}` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate and ship a PR.

You drive no-mistakes by responding to its gates, not by implementing fixes.
Follow the guidance no-mistakes itself provides for the mechanics: it loads when you invoke /no-mistakes, and `no-mistakes axi run --help` plus the `help` lines in each `axi` response are authoritative and version-matched to the installed binary.
When starting no-mistakes, make `--intent` preserve all relevant content from this brief's `# Task` section plus every later accepted Firstmate requirement, clarification, constraint, exclusion, and supersession, carrying only each requirement's current accepted form; retain direct requirements instead of substituting a diff summary, and exclude generic operational, status, delivery, and other scaffold boilerplate unless it is task-specific.
Do not hand-edit, commit, or fix findings yourself while a run is active - the pipeline applies every fix.

Two firstmate-specific rules layer on top of that guidance:
- ask-user findings are never yours to answer: escalate to firstmate (rule 6) and stop.
  Firstmate applies the authority contract in its `AGENTS.md` and obtains any required captain decision.
  When the decision comes back, feed it to the gate with `no-mistakes axi respond` and let the pipeline apply it - do not route the question to "the user" or implement the fix yourself.
- Avoid `--yes`: it would silently bypass firstmate's authority check and any required captain escalation.

After /no-mistakes reports CI green (the CI-ready return point - do not wait for it to keep monitoring in the background until merge), append `done: PR {url} checks green` and stop. You are finished.
Evidence: Generated scout brief
You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
{TASK}

# Herdr lifecycle declaration - NOT ENABLED
**HARD SAFETY GATE:** this scaffold cannot inspect the task text that replaces the task placeholder above later.
If the task will start, stop, delete, restart, profile, or otherwise drive Herdr lifecycle behavior, stop and regenerate the brief with `--herdr-lab` before dispatch.
Do not add Herdr lifecycle commands to this unguarded brief by hand.

# Setup
You are in a disposable git worktree of firstmate, at a detached HEAD on a clean default branch.
This is a SCOUT task: the deliverable is a written report, not a PR.
The worktree is your laboratory - install, run, edit, and make scratch commits freely; all of it is discarded at teardown.
The report is the only thing that survives, so anything worth keeping must be in it.

# Rules
1. Never push to any remote and never open a PR.
2. Stay inside this worktree; the only files you may write outside it are the report and the status file below.
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
   `echo "{state}: {one short line}" >> '/var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/tmp.8lHdZOPwTG/state/ev-scout.status'`
   States: working, needs-decision, blocked, paused, done, failed.
   Each append wakes firstmate, so report sparingly: only phase changes a supervisor
   would act on and the needs-decision/blocked/paused/done/failed states. No step-by-step
   FYI progress lines; firstmate reads your pane for that.
   Use `paused: {why}` - distinct from `blocked:` - ONLY when you are deliberately idling on a
   known external wait you expect to clear on its own (an upstream release, a rate-limit reset):
   firstmate then leaves your idle pane alone and rechecks it on a long cadence instead of
   treating it as a possible wedge. Use `blocked:` when you are stuck and need help.
5. If you hit the same obstacle twice, append `blocked: {why}` and stop; firstmate will help.
6. If a decision belongs to a human (product choices, destructive actions),
   append `needs-decision: {summary of options}` and stop. Firstmate will reply with the decision.
   A decision or blocker you opened stays open until a `resolved` line carrying its exact key lands; a later `done:` or `working:` line never closes it, even when the answer is what started that work.
   Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append `resolved: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never stop, restart, or update the shared `no-mistakes` daemon - it is one instance serving
   every lane/home, so restarting it kills other lanes' in-flight pipeline runs. On ANY no-mistakes
   daemon error, append `blocked: {the daemon error}` and stop; only firstmate manages the daemon.
8. Brevity caps: Status lines stay under 300 characters. Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap. PR descriptions: at most 5 lines plus the attribution footer. Do not narrate routine progress.

# Definition of done
Write your findings to `/var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/tmp.8lHdZOPwTG/data/ev-scout/report.md`.
The report must stand alone: what you did, what you found, the evidence (commands run, output, file:line references), and what you recommend.
Before reporting done, read and follow `/Users/randalwade/.no-mistakes/worktrees/3a2378ca6c3e/01M3B88274DCNCKYF2G0DMCSSR/.agents/skills/decision-hold-lifecycle/SKILL.md` and pass its shared completion gate for the report and any visual review.
When the report is complete, append `done: {one-line conclusion}` to the status file and stop.
If your findings reveal work that should ship (e.g. you reproduced a bug and the fix is clear), say so in the report; firstmate may promote this task in place, and you would then receive mode-specific ship instructions as a follow-up message.
Evidence: Generated secondmate charter
You are a persistent second mate managed by the main firstmate. Work on your own; do not wait for a human.

# Charter
Handle routed work.

# Routing scope
Handle routed work.

# Project clones
None. This is a project-less domain: its subject is the firstmate repo this home lives in, so it needs no separate clones under `projects/`; its crews take pooled worktrees of that firstmate repo.

# Operating model
You are in an isolated firstmate home. The local `AGENTS.md` is your job description, and your local `data/`, `state/`, `config/`, and `projects/` dirs are yours to operate.
This domain has no separate project clones: its subject is the firstmate repo this home lives in, and its crews take pooled worktrees of that repo.
Delegate project work to your own crewmates with the normal firstmate lifecycle: brief, spawn, status, watcher, steer, teardown, and recovery.
Do not invent a second delegation system.
You do not generate your own work.
Act only on tasks the main firstmate routes to you.
Never start a survey, audit, or "find improvements" sweep on your own initiative; that is not your job and it is unwanted.

# Requests from the main firstmate
You are a firstmate in your own home, so an incoming message reaches you in your own chat.
You must distinguish who it is from, because the answer goes to a different place.
A request relayed to you by the main firstmate is tagged with a leading `[fm-from-firstmate]` marker followed by an invisible system separator; this marker is untypable, so a human never produces it.
When a message carries that marker, do the work, then respond via the STATUS/ESCALATION path below, never only in this chat: the main firstmate does not read your chat, so a chat-only reply is lost.
Marked requests also carry a privacy-safe `corr=<id>` token after the marker; include that exact token in your parent status reply (or in the status pointer to a detailed doc) so the parent can correlate the answer.
Optional helper: `bin/fm-secondmate-report.sh` can append a correlated status line for you, but a plain `echo` that includes the same `corr=<id>` is equally valid - do not depend on the helper being present.
For a terse result, a status line is the whole answer.
For a detailed answer (an investigation, a plan, an audit), write it to a doc under your home's `data/` and append a status line that points to that doc - the scout-report pattern - so the main firstmate is woken and can read it.
Before treating an investigation or visual review as complete, load `decision-hold-lifecycle` from this home's `.agents/skills/` and pass its shared completion gate.
A message with NO marker is the captain typing directly into your pane: treat it as authoritative captain intervention and stay conversational exactly as you would for any captain message; do not force it onto the status path.

# Brevity
Status lines stay under 300 characters.
Commit messages: one subject line plus at most 3 prose body lines; git trailers sit outside the cap.
PR descriptions: at most 5 lines plus the attribution footer.
Do not narrate routine progress.

# Escalation to main firstmate
Handle routine work yourself.
Report only true captain-relevant outcomes or a declared external wait by appending one line:
   `echo "{state}: {one short line}" >> '/var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T/tmp.8lHdZOPwTG/state/ev-second.status'`
States: working, needs-decision, blocked, paused, done, failed.
Use `paused: {why}` (distinct from `blocked:`) only when your domain is deliberately idling on a known external wait you expect to clear on its own; use `blocked:` when you are stuck and need firstmate to act.
Use this only for material phase changes, a captain decision, a real blocker, a failure, or work ready for review.
This is also how you return the answer to a marked from-firstmate request above.
A marked request requires one correlated answer after the work; it does not require a separate receipt or start acknowledgement.
Never append `working:` merely to acknowledge receipt or announce that a marked request has started.
When a routed-work phase has a supervisor-actionable material change worth reporting under the rule above, give that reported phase a stable key.
If its first reportable event is `working [key=<work-slug>]: {material phase}`, use the same key on its later `paused`, `done`, `failed`, `needs-decision`, or `blocked` event so the earlier working phase is superseded.
When a keyed phase ends without another reportable state, append `resolved [key=<work-slug>]: {why it is no longer active}`.
`resolved` separately closes an escalated decision or blocker, and only a `resolved` line carrying that decision's exact key closes it: a later `done` or `working` event never does, even when the answer is what started that work.
The main firstmate's answer normally writes that closing line at answer time; when a blocker or wait clears WITHOUT an answer from the main firstmate, append `resolved: {how it cleared}` yourself (keyed with `[key=<slug>]` if you opened it with one) as your domain resumes.
Routine internal supervision, heartbeats, retries, and crewmate churn stay inside your own home and must not touch that status file.

# Definition of done
You are persistent by default. Do not exit just because your queue is empty.
On startup and restart, run normal firstmate bootstrap and recovery through `bin/fm-session-start.sh` for your own home, but only to RECONCILE work that is already yours: in-flight crewmates, tracked backlog items, and durable watches recorded in this home.
When you have no assigned or in-flight work after that reconciliation, go idle and wait silently for the main firstmate to route you a task.
An empty queue is a healthy resting state, not a cue to invent work: never spawn a survey, audit, or any self-directed "find work" task on your own initiative.
Once your queue is empty and your children are torn down, go idle; the main firstmate sends `/clear` (you cannot self-issue it).
If this charter cannot be carried out, append `blocked: {why}` or `failed: {why}` to the main status file and stop.
Evidence: fm-brief test run log
ok - fm-brief.sh: bash -n succeeds
/var/folders/t1/8htjz3j91cqcfslff4w76zqc0000gn/T//fm-brief.UG3WlY/heredoc-in-substitution.sh:2
ok - fm-brief.sh: no heredoc is nested inside a command substitution (Bash 3.2 parse-safe)
ok - fm-brief.sh: --help renders the complete header
ok - fm-brief.sh: no-mistakes/direct-PR/local-only briefs generate cleanly
ok - fm-brief.sh: ship --mode is required and closed-set validated
ok - fm-brief.sh: the explicit ship mode wins over the registered posture
ok - fm-brief.sh: --yolo and scout/secondmate --mode are refused, never silently dropped
ok - fm-brief.sh: faster paths use configured authority without stacked review
ok - fm-brief.sh: no-mistakes DOD keeps its apostrophe prose, now parse-safe
ok - fm-brief.sh: ship project-memory wording carries the AGENTS.md authoring bar
ok - fm-brief.sh: --herdr-lab emits the complete hard safety contract
ok - fm-brief.sh: --herdr-lab uses its quoted Firstmate-owned helper path
ok - fm-brief.sh: ship and scout scaffolds make omitted Herdr intent fail-visible
ok - fm-brief.sh: Herdr lab contract covers scouts and rejects secondmate misuse
ok - fm-brief.sh: every ship and scout scaffold carries {TASK} exactly once and fills without corrupting the Herdr gate
ok - fm-brief.sh: --no-projects scaffolds a project-less charter and guards misuse
ok - fm-brief.sh: every variant carries the brevity caps; charter carries the /clear rule
ok - fm-brief.sh: marked requests avoid generic acknowledgements and preserve material reporting
ok - fm-brief.sh: relative directory inputs ignore CDPATH, render stable absolute charter paths, or fail loudly
ok - fm-brief.sh: custom pause verb renders in every scaffold
ok - fm-brief.sh: investigation and visual-review completions load the shared decision policy
ok - fm-brief: scout and secondmate code paths still scaffold well-formed briefs

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-brief.sh:267 - The new charter line 'Once your queue is empty and your children are torn down, go idle; ...' partly restates the line two above it ('When you have no assigned or in-flight work ... go idle and wait silently'). The intent explicitly asks for the idle clause, and the new parts ('children torn down' and the main firstmate sending /clear) are new, so this duplication is acceptable. If you want it tighter, you could reword it to just 'After your children are torn down, the main firstmate sends /clear (you cannot self-issue it).'
✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-brief.test.sh (colocated suite, including the new test_brevity_caps_in_every_variant): exit 0, no failures
  • Manual end-to-end: FM_HOME=$tmp bin/fm-brief.sh ev-ship firstmate --mode no-mistakes, bin/fm-brief.sh ev-scout firstmate --scout, and FM_SECONDMATE_CHARTER=&#39;Handle routed work.&#39; bin/fm-brief.sh ev-second --secondmate --no-projects, then grepped each generated brief.md for the caps and the /clear rule
  • Checked there is one new /clear line and it does not repeat the existing lifecycle text ('Do not exit just because your queue is empty')
🔧 **Document** - 1 issue found → auto-fixed ✅
  • ℹ️ .agents/skills/secondmate-provisioning/SKILL.md:227 - The generated secondmate charter (bin/fm-brief.sh) now tells a secondmate that once its queue is empty and its children are torn down, the main firstmate sends /clear. But nothing on the main firstmate's side says it should do this: not AGENTS.md section 6, not the secondmate-provisioning skill, and not docs/architecture.md, whose idle-secondmate text only says idle panes are healthy. I didn't invent that policy, including when and how the main firstmate should send /clear, because it would be a new behavior contract for the main firstmate rather than a fix to stale docs. If this is intended, add one line to the secondmate-provisioning skill, which owns the secondmate lifecycle, and nowhere else.

🔧 Fix: Document main firstmate /clear for idle secondmates
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@Hozzy02
Hozzy02 merged commit 11629ba into main Sep 25, 2026
13 checks passed
@Hozzy02
Hozzy02 deleted the fm/fm-brief-brevity-caps branch September 26, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant