Skip to content

feat: adopt constitution layering in worker briefs - #3454

Closed
derickdsouza wants to merge 3 commits into
kunchenguid:mainfrom
derickdsouza:fm/adopt-constitution-layering
Closed

derickdsouza wants to merge 3 commits into
kunchenguid:mainfrom
derickdsouza:fm/adopt-constitution-layering

Conversation

@derickdsouza

Copy link
Copy Markdown

Intent

Adopt the constitution-layering discipline into firstmate's worker-facing rule-file contract, per the captain's ruling of 2026-09-01 ("1 = adopt", harbor #107).

The discipline: shared worker-facing rule files are law and are never same-name overridden by a project; project specialization lives in separate, clearly-namespaced local-* style files. This keeps shared rules drift-free across every project a worker touches. It matches the captain's own standing config practice (global config is law, local files specialize under distinct names).

Requirements:

  1. Codify the discipline in the right owning location(s) of firstmate's shared tracked surface - AGENTS.md's worker-brief/crewmate contract area and/or the brief scaffold's generated contract - using pointer-style concision, never duplicating the same rule in two places (one-owner rule).
  2. Check docs/configuration.md and bin/fm-brief.sh first: the contract text workers actually read is the scaffold's generated sections, so the discipline must reach the worker-facing surface, not just an internal doc.
  3. Keep AGENTS.md size discipline: prefer one tight sentence over a paragraph; prune or merge rather than append.
  4. Colocated test or verification if the scaffold text changes (e.g. a scaffold test asserting the layering line exists).

Constraints:

  • This task edits firstmate shared tracked material and must follow firstmate-coding-guidelines: one sentence per line, one-owner rule, shellcheck-clean, colocated tests, no agent co-author.
  • Another PR (reviewer input sanitizer) may land on this repo concurrently; expect an ordinary rebase, do not build on its branch.
  • Do not broaden scope beyond the layering contract and the smallest downstream change needed to keep that contract reaching every ship-facing worker.

Accepted later requirement (firstmate decision key promoted-scouts-layering): promoted scouts must receive the layering contract. fm-promote.sh already renders the delivery DoD contracts for promoted workers, so extend that same rendering to include the layering/project-memory contract sections. Add or extend the colocated scaffold test to pin that promoted briefs carry the layering line. Keep everything else as-is.

Implementation choices already made (not mistakes):

  • The generated ship project-memory section in bin/fm-brief.sh is the single owner of the worker-facing layering sentence.
  • AGENTS.md section 11 only names that generated section as owner and does not restate the rule.
  • docs/configuration.md does not own this contract and was not changed.
  • Scout and secondmate scaffolds stay without a duplicate restatement; promoted scouts receive the contract via the promote path's shared owner, matching the accepted later requirement.

What Changed

Final changed paths and statuses:

M	AGENTS.md
M	bin/fm-brief.sh
M	bin/fm-dod-lib.sh
M	bin/fm-promote.sh
M	docs/scripts.md
M	tests/fm-brief.test.sh
M	tests/fm-task-delivery.test.sh

Risk Assessment

✅ Low: The change is a tightly bounded contract addition: one sentence with a single shared owner rendered into two already-existing delivery surfaces, pinned by colocated behavioral tests that execute the real generation paths, with no reachable path producing a wrong or missing contract.

Testing

Ran the two colocated test files covering the change (all passing), reproduced both real generation paths end-to-end with the actual CLIs to confirm the layering sentence reaches the worker-facing ship brief and the promoted scout's delivered message, confirmed scout/secondmate scaffolds and AGENTS.md carry no duplicate restatement, and verified at the base commit that both new assertions fail, establishing them as genuine regression tests. No failures; worktree left clean.

Evidence: Generated ship brief (worker-facing surface) with layering line in Project memory section

Source: Generated ship brief (worker-facing surface) with layering line in Project memory section

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 filled in above.
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 fixture-project, 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/layering-demo-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}" >> '/tmp/fm-layering-demo/home/state/layering-demo-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 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.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/tmp/fm-layering-demo/home/state/layering-demo-ship.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/tmp/fm-layering-demo/home/state/layering-demo-ship.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/tmp/fm-layering-demo/home/state/layering-demo-ship.inbox'/NNN.msg '/tmp/fm-layering-demo/home/state/layering-demo-ship.inbox'/handled/`.
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.

# Project memory
If `AGENTS.md` or `CLAUDE.md` already exists, or if this task produced durable project-intrinsic knowledge, run `~/.no-mistakes/worktrees/7f0ec18181b6/01M1ESQWZ7A1FSEJ7A8JR3E4W7/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.
A shared worker-facing rule file is law: never replace it with a same-named project file; put that specialization in a clearly-namespaced `local-*` file instead.
If you touch a project `AGENTS.md` that lacks `## Maintaining this file`, add that short self-governance section from `~/.no-mistakes/worktrees/7f0ec18181b6/01M1ESQWZ7A1FSEJ7A8JR3E4W7/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 `ask-user-authority` 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.
- NEVER pass `--yes` (or `-y`) to `no-mistakes axi run` or `no-mistakes axi respond`. It is banned fleet-wide.
  It auto-resolves every gate including ask-user findings with no escalation, and answering your own ask-user finding is a hard rule violation.

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: Promoted scout's ship-instructions.md carrying the layering contract

Source: Promoted scout's ship-instructions.md carrying the layering contract

Your scout task has been promoted to a ship task, mode=no-mistakes. Your window, worktree, and context stay as they are; only the contract below changes.

# Ship instructions
1. **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. If either does not resolve to the worktree you were launched in, stop and escalate to firstmate.
2. Inventory this worktree's scratch state with `git status` and `git log` before changing anything.
3. Return to a clean default-branch base, then create your branch: `git checkout -b fm/layering-demo-scout`.
4. Carry over only the intended fix changes. Leave scratch commits, debug edits, and experiment files behind.
5. If you reproduced a bug, turn that reproduction into a regression test.
6. These ship instructions supersede the scout delivery rules and report-based Definition of done. Everything else in your original instructions carries over unchanged: the status protocol; the instruction inbox and its acknowledgement; the escalation rules, including ask-user; and every safety rule.

A shared worker-facing rule file is law: never replace it with a same-named project file; put that specialization in a clearly-namespaced `local-*` file instead.

# 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 `ask-user-authority` 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.
- NEVER pass `--yes` (or `-y`) to `no-mistakes axi run` or `no-mistakes axi respond`. It is banned fleet-wide.
  It auto-resolves every gate including ask-user findings with no escalation, and answering your own ask-user finding is a hard rule violation.

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: Message actually delivered to the promoted worker (captured via the fm-send.sh delivery command promotion printed), layering line at line 11 directly above the Definition of done

Source: Message actually delivered to the promoted worker (captured via the fm-send.sh delivery command promotion printed), layering line at line 11 directly above the Definition of done

Your scout task has been promoted to a ship task, mode=no-mistakes. Your window, worktree, and context stay as they are; only the contract below changes.

# Ship instructions
1. **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. If either does not resolve to the worktree you were launched in, stop and escalate to firstmate.
2. Inventory this worktree's scratch state with `git status` and `git log` before changing anything.
3. Return to a clean default-branch base, then create your branch: `git checkout -b fm/layering-demo-scout`.
4. Carry over only the intended fix changes. Leave scratch commits, debug edits, and experiment files behind.
5. If you reproduced a bug, turn that reproduction into a regression test.
6. These ship instructions supersede the scout delivery rules and report-based Definition of done. Everything else in your original instructions carries over unchanged: the status protocol; the instruction inbox and its acknowledgement; the escalation rules, including ask-user; and every safety rule.

A shared worker-facing rule file is law: never replace it with a same-named project file; put that specialization in a clearly-namespaced `local-*` file instead.

# 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 `ask-user-authority` 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.
- NEVER pass `--yes` (or `-y`) to `no-mistakes axi run` or `no-mistakes axi respond`. It is banned fleet-wide.
  It auto-resolves every gate including ask-user findings with no escalation, and answering your own ask-user finding is a hard rule violation.

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: fm-promote.sh transcript: kind=scout→ship flip, mode/yolo recorded, ship instructions written, delivery command printed

Source: fm-promote.sh transcript: kind=scout→ship flip, mode/yolo recorded, ship instructions written, delivery command printed

promoted layering-demo-scout to ship mode=no-mistakes yolo=off (teardown protection restored)
wrote ship instructions for mode=no-mistakes: /tmp/fm-layering-demo/home/data/layering-demo-scout/ship-instructions.md
next: FM_HOME=/tmp/fm-layering-demo/home bin/fm-send.sh fm-layering-demo-scout "$(cat /tmp/fm-layering-demo/home/data/layering-demo-scout/ship-instructions.md)"

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.

  • bash tests/fm-brief.test.sh (all pass, incl. test_ship_project_memory_wording pinning the layering line in the generated ship brief)
  • bash tests/fm-task-delivery.test.sh (all pass, incl. test_promotion_delivers_the_real_definition_of_done asserting the delivered payload carries the layering contract for no-mistakes/direct-PR/local-only)
  • manual e2e: FM_HOME=$DEMO ./bin/fm-brief.sh layering-demo-ship fixture-project --mode no-mistakes then inspected generated brief.md Project memory section
  • manual e2e: ./bin/fm-promote.sh layering-demo-scout --mode no-mistakes --yolo off with kind=scout task record, then executed the printed fm-send.sh delivery command via a capturing stub and asserted the delivered payload contains the layering line
  • one-owner check: grep -rn &#34;A shared worker-facing rule file is law&#34; --include=&#39;*.sh&#39; --include=&#39;*.md&#39; . shows the sentence only in bin/fm-dod-lib.sh plus the two pinning tests; scout and secondmate generated briefs confirmed free of it
  • base-commit regression check: ran fm-brief.sh and fm-promote.sh extracted from 355f46f against temp FM_HOME; layering line absent in both generated outputs, proving the new assertions fail before the fix
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

derickdsouza and others added 3 commits September 1, 2026 21:04
Put constitution-layering in the generated ship project-memory contract so workers specialize in local-* files instead of replacing shared rule files.
@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge, with both worker-delivery surfaces consistently using the same shared contract owner.

The helper is sourced before use in both generation paths, its output is rendered into the intended worker-facing sections, and the changed tests cover the resulting contract without revealing a conflicting runtime or repository invariant.

Reviews (1): Last reviewed commit: "no-mistakes(document): Document layering..." | Re-trigger Greptile

@derickdsouza derickdsouza changed the title chore: update pull request feat: adopt constitution layering in worker briefs Sep 1, 2026
@derickdsouza

Copy link
Copy Markdown
Author

@kunchenguid friendly nudge: this PR comes from a fork, so GitHub needs a maintainer to approve workflow runs before CI can start (the 'Approve and run' prompt on the checks panel). Could you approve when you have a moment? Happy to adjust anything in the meantime.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: first-time fork CI approved after a full-thread + full-diff review (no .github/workflows writes). Runs 33528328923 (CI), 33530171878 (Require no-mistakes), and 33528329061 (Require no-mistakes, opened event).

Inspected HEAD 7ba0d372eee9e8a6d055498fe77841e438525b43 vs main 355f46fe5528ccc9790481171bf9da48dee2e90d: AGENTS.md §11 owner pointer, bin/fm-dod-lib.sh fm_layering_line, bin/fm-brief.sh project-memory render, bin/fm-promote.sh ship-instructions render, docs/scripts.md, and the two colocated generation tests. Attestation MATCH (body head_sha equals HEAD). MERGEABLE/UNSTABLE. workflow-zero. Greptile SUCCESS (5/5). Security clean (derickdsouza not blocked; static worker-facing sentence; no secrets, no eval, no workflow injection). Generated ship-brief and promote evidence both carry the layering line from the shared owner.

Contract-class: new-default. This is always-on new worker-brief law: every ship brief and every promoted scout is told a shared worker-facing rule file is never same-name overridable and specialization belongs in local-* files. Main VISION.md / AGENTS.md / fm-brief.sh do not already specify this exact default. A claimed captain harbor #107 "1 = adopt" is not authorization for auto-merge. VISION: new capability ships as an option to enable, never as behavior that assumes consent. No auto-merge.

VISION.md per-rule

  • One captain, one interface — aligns. Worker-facing contract only; no captain-channel noise.
  • Authority is explicit and never inferred — resists. Always-on new default assumes consent that shared rule files are law across every project a worker touches.
  • Scripts own the mechanics, agents own the judgment — aligns. Single owner in fm-dod-lib.sh; both generation paths render it; tests pin the real CLIs.
  • A restart is a non-event — n/a.
  • Delegation with a spine — mixed. Tightens the worker contract, but as a fleet-wide default rather than a mode/opt-in.
  • The fleet outlives any vendor — aligns. Harness-agnostic instruction text.
  • Scope — aligns. Command-layer brief contract; no workshop growth.

This wait is on CI (and no-mistakes), not the author or the captain. Will not auto-merge on green.

@derickdsouza

Copy link
Copy Markdown
Author

Closing per maintainer-side decision: this fork will keep its changes local rather than sending them upstream. Apologies for the noise.

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.

2 participants