Skip to content

feat(bin): start tasks from a named base branch - #6442

Merged
kunchenguid merged 7 commits into
kunchenguid:mainfrom
lakshyads:fm/custom-base-branch
Oct 5, 2026
Merged

kunchenguid merged 7 commits into
kunchenguid:mainfrom
lakshyads:fm/custom-base-branch

Conversation

@lakshyads05

@lakshyads05 lakshyads05 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Close the gap that prevents firstmate from working on any project whose work must start from, and be delivered to, a branch other than the repository's default branch. Today a spawn always resets the task's pooled copy to origin's default branch, so work that belongs on a named feature, integration, or release branch (for example a TatBiq feature/TD-169-integrations-hub task, or a fix to a deployed release branch that has not merged back into develop) silently starts from the wrong code and opens its PR against the default branch.

Requested: a brand new PR, started from scratch, with the minimal surgical change required to fix this gap so that not only TatBiq but any project that requires working off of a custom base branch works. Do not take inspiration from older PRs on this topic. Follow this repo's contributing policy and guidelines so the PR can be reviewed and merged quickly.

Design decisions made while implementing:

  • The base branch is a per-task choice selected at brief time with fm-brief.sh --base-branch <branch> (ship and scout briefs; refused on secondmate charters). It is recorded as one machine-readable Base branch: <branch> line under the brief's # Setup heading; a Base branch: line inside # Task (the captain's intent) or later sections is deliberately ignored so prose cannot redirect a spawn.
  • fm-spawn.sh adds no new flag: it reads that Setup line, resets the pooled copy to origin/<base> instead of origin's default branch, refuses when the project has no origin or origin lacks the branch (never silently falls back to the default), and records base_branch= in task meta. A relaunch reuses the recorded value. Without the line, behavior and meta output are byte-identical to today.
  • fm-dod-lib.sh is the single owner of the rules: fm_base_branch_valid validates the name and refuses the deliveries that cannot carry a named base in this minimal change (local-only, whose landing fast-forwards local main, and forge=gerrit); fm_brief_base_branch parses the line. The worker contract names the base as a branch never to push to, direct-PR opens its PR with --base <base>, and no-mistakes passes --base-branch <base> on every no-mistakes axi run.
  • Downstream consumers read the recorded meta value: fm-review-diff.sh diffs against origin/, fm-teardown.sh's content-landed fallback checks origin/, and fm-promote.sh keeps a scout's base for the ship contract and refuses a mode that cannot carry it.
  • Out of scope (possible follow-ups): local-only landing into a non-default local branch, Gerrit base branches, and any project-registry default base.

What Changed

  • fm-brief.sh --base-branch <branch> (ship and scout briefs only, refused on secondmate charters) writes a Base branch: <branch> line under # Setup. fm-spawn.sh --base-branch <branch> has to match every Base branch: line in the brief, and a brief that has such a line refuses a spawn without the flag. A fresh spawn resets the pooled copy to origin/<branch> instead of origin's default branch. It refuses if the project has no origin or the branch can't be fetched, and it never falls back to the default branch. It records base_branch= in task meta, and a relaunch reuses that value. With no base branch, spawn behaves as before.
  • fm-dod-lib.sh adds fm_base_branch_valid, which rejects invalid branch names, local-only mode and non-none forges such as Gerrit. It also adds fm_brief_base_branches. With a base set, the worker rules say never to push to the base branch or the default branch. A direct-PR worker opens its PR with --base <branch>, and a no-mistakes worker passes --base-branch <branch> on every no-mistakes axi run.
  • Later steps read base_branch= from task meta. fm-review-diff.sh diffs against origin/<base>, and the content-landed check in fm-teardown.sh uses origin's copy of the base branch. fm-promote.sh keeps a scout's base in the ship contract and refuses a mode that can't carry it. AGENTS.md, docs/architecture.md and the scout-completion skill are updated to match, with test coverage in the brief, dod-lib, spawn freshen, review-diff and teardown suites.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The base branch is opt-in, and every path without it stays byte-identical. The fix round's explicit --base-branch flag closes both earlier decoy-parse findings. Refusals happen before any meta is published, and downstream consumers (review-diff, teardown, promote) read the recorded meta value.

Testing

I drove the change end to end in a disposable lab home: a private fm-lab tmux socket, a lab-rooted Treehouse pool, real Claude workers, and a local bare origin with a feature/hub branch. What was verified live: - Briefs: fm-brief.sh writes the Setup Base branch: line and targets the base in the Rule 1, direct-PR --base, and no-mistakes --base-branch text. It refuses local-only, gerrit, invalid names, and secondmate charters. No-base briefs are byte-identical to the base commit's output once the script-root path is normalized. - Spawn: scout and ship spawns reset the pooled copy to origin/feature/hub and record base_branch=. A spawn without the flag still starts from origin/main with no base_branch=. - Spawn refusals: every disagreement between the flag and the brief is refused. So are a missing origin branch, local-only, and secondmate. None of them publishes meta. - Downstream: relaunch keeps the recorded base and refuses an override. Review-diff compares against origin/feature/hub. Teardown's landed check uses the base branch. Promotion carries the base and refuses local-only. Two lab-only issues came up: - Treehouse write outside the lab: the first spawn attempt's treehouse get created a pool for the throwaway project under ~/.treehouse, because the tmux server didn't inherit TREEHOUSE_ROOT. I removed it right away and pinned TREEHOUSE_ROOT in the lab tmux environment for the remaining spawns. - Teardown did not finish: after passing the landed-on-base check, teardown's final treehouse return failed with "not managed by treehouse". The likely cause is the macOS /var vs /private/var symlink in the lab's TMPDIR path, not this change. Everything was torn down at the end.

  • Live validation: ✅ go - 12 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Captain scaffolds a ship/scout brief with --base-branch feature/hub and the brief records the base and targets it ✅ pass live brief-transcript.txt, brief-hub-dpr.md, brief-hub-nm.md, brief-hub-scout.md
fm-brief.sh refuses --base-branch on local-only, gerrit, invalid names, and secondmate charters ✅ pass live brief-transcript.txt
A brief without --base-branch is byte-identical to the pre-change output ✅ pass live no-base-brief-identical.txt
Scout and ship spawns with --base-branch start the worker copy from origin/feature/hub and record base_branch= ✅ pass live spawn-success.txt, scout-spawn-copy.txt, ship-spawn-copy.txt, scout-worker-pane.txt, ship-worker-pane.txt
A spawn without --base-branch behaves as before ✅ pass live plain-spawn-control.txt
Adversarial: spawn refuses when the flag and the brief's Base branch lines disagree (flag only, line only, mismatching decoy in Captain's intent) and publishes no meta ✅ pass live spawn-refusals.txt
A decoy Base branch line equal to the flag value is harmless ✅ pass live spawn-success.txt (decoyeq)
Adversarial: spawn refuses when origin lacks the base branch, on local-only, and on a secondmate, never falling back to the default ✅ pass live spawn-refusals.txt
Relaunch reuses the recorded base and refuses an override ✅ pass live relaunch-transcript.txt
fm-review-diff.sh diffs a base-branch task against origin/<base> ✅ pass live review-diff-hub-dpr.txt, review-diff-plain-control.txt
fm-teardown.sh content-landed fallback checks origin/<base> ✅ pass live teardown-before-land.txt, teardown-after-land-on-base.txt, teardown-retry.txt
fm-promote.sh keeps a scout's base for the ship contract and refuses a mode that cannot carry it ✅ pass live promote-local-only-refused.txt, promote-direct-PR.txt, promote-ship-instructions.md
Evidence: fm-brief.sh transcript (success and refusals)

Source: fm-brief.sh transcript (success and refusals)

$ fm-brief.sh hub-dpr demo --mode direct-PR --base-branch feature/hub
scaffolded: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/hub-dpr/brief.md (ship, mode=direct-PR; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ fm-brief.sh hub-nm demo --mode no-mistakes --base-branch feature/hub
scaffolded: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/hub-nm/brief.md (ship, mode=no-mistakes; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ fm-brief.sh hub-scout demo --scout --base-branch feature/hub
scaffolded: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/hub-scout/brief.md (scout; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ fm-brief.sh plain demo --mode direct-PR
scaffolded: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/plain/brief.md (ship, mode=direct-PR; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
--- refusals ---
$ --mode local-only --base-branch feature/hub
error: fm-brief.sh --base-branch: a base branch cannot ship mode=local-only, whose landing fast-forwards local main; ship no-mistakes or direct-PR, which open a pull request against the base
[exit 1]
$ --mode direct-PR --forge gerrit --base-branch feature/hub
error: fm-brief.sh --base-branch: a base branch is not supported on forge=gerrit
[exit 1]
$ --mode direct-PR --base-branch "bad..name"
error: fm-brief.sh --base-branch: base branch 'bad..name' is not a valid git branch name
[exit 1]
$ --mode direct-PR --base-branch -x
error: fm-brief.sh --base-branch: base branch '-x' is not a valid git branch name
[exit 1]
$ --secondmate --base-branch feature/hub
error: --base-branch takes a branch name and applies only to ship and scout briefs
[exit 1]
hub-dpr
hub-nm
hub-scout
plain
Evidence: Generated direct-PR brief with base

Source: Generated direct-PR brief with base

You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
## Captain's intent
{TASK}

## Firstmate spec
{FIRSTMATE_SPEC}

# 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 demo, at a detached HEAD on a clean copy of its base branch.
Base branch: feature/hub

**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 [at=<epoch>]: launched in primary checkout, not an isolated worktree` to the status file and stop.

1. First action: create your branch: `git checkout -b fm/hub-dpr --`

# Rules
1. Never push to the base branch `feature/hub` or the default branch (push only your `fm/hub-dpr` 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} [at=<epoch>]: {one short line}" >> '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-dpr.status' && { [ ! -e '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/config/fleet-ledger' ] || '~/.no-mistakes/worktrees/5097ea27ba16/01M3Z4C0MHEMMXQ7H0TM0HH9VW/bin/fm-fleet-ledger.sh' appended '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/config' '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-dpr.status' >/dev/null 2>&1 || true; }`
   States: working, needs-decision, blocked, paused, done, failed.
   Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
   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.
   Whenever you mention a PR anywhere - a status line, your terminal, a summary - write its full
   https:// URL exactly as the forge printed it, never a bare number such as "PR 108"; firstmate
   copies that URL from your line rather than assembling one.
   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:` - when deliberately waiting for work or an external condition expected to clear on its own, including your own validation round.
   Before ending your turn with your own background shell or monitor still running, or before waiting on your own pipeline run or a long foreground command, append `paused [at=<epoch>]: {job and completion condition}` to the status file.
   Name what you are waiting for and what will let you resume; do not repeat the declaration on every poll.
   Do not declare active implementation or reasoning as a wait.
   Firstmate may still raise one first-sight alert; the declared wait then uses the existing long recheck cadence instead of repeated possible-wedge alarms.
   When you know when the wait clears, include `until <YYYY-MM-DDTHH:MMZ>` (UTC) for a recheck at that time.
   Follow the resolution rule below when the wait clears, then resume the task.
   Use `blocked:` when you are stuck and need help.

5. If you hit the same obstacle twice, append `blocked [at=<epoch>]: {why}` and stop; firstmate will help.
6. If a decision belongs above the implementation worker (product choices, destructive actions),
   append `needs-decision [at=<epoch>]: {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 [at=<epoch>]: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never administer infrastructure that every lane shares. Two things are shared:
   - The `no-mistakes` daemon - one instance serving every lane/home, so stopping, restarting, or
     updating it kills other lanes' in-flight pipeline runs; only firstmate manages the daemon.
     Before you append `blocked:` about the pipeline, run `no-mistakes daemon status` and
     `no-mistakes axi status`. If the daemon socket refuses connections or is missing, append
     `blocked [at=<epoch>]: {the daemon error}` and stop even when the local run record still says running or
     fixing, because that record can be stale after the daemon exits. A run record failed with a
     daemon error is also a real block.
     Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep
     going. A drive-call error, timeout, slow read, or generic unreachability is NOT a daemon error:
     the daemon accepts `respond` immediately and runs the round in the background, so a killed or
     timed-out call was only waiting for a read while the run kept working.
   - The worktree pool your own worktree came from, and the repository every lane's worktree
     shares. Never create, remove, return, prune, move, or reassign a worktree or pool slot, and
     never write into a sibling slot's directory. Rule 2 does not cover this: removing a worktree
     is administration rather than an edit outside your directory, and it lands on lanes that are
     running right now. The act is the rule and commands are only examples of it - `treehouse`
     get/return/remove/prune, the equivalent operations on any other worktree provider or runtime
     backend, and `git worktree add|remove|move|prune`. A slot that looks unused is not evidence
     that it is free, and returning your own worktree is firstmate's job at cleanup, not yours.
   If you genuinely need a second checkout, another slot, or the daemon touched, append
   `blocked [at=<epoch>]: {what you need}` and stop; firstmate arranges it.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-dpr.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-dpr.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-dpr.inbox'/NNN.msg '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-dpr.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
A project's `AGENTS.md` or `CLAUDE.md` is loaded into every agent session in that project, so edit it only to correct information that is factually wrong - including information your own change made wrong - and never to add knowledge because it is missing.
A correction edits only the wrong text: do not run `~/.no-mistakes/worktrees/5097ea27ba16/01M3Z4C0MHEMMXQ7H0TM0HH9VW/bin/fm-ensure-agents-md.sh`, create either file, or add sections, headings, or pointers alongside it.

# Definition of done
Delivery contract: mode=direct-PR
Ship branch: fm/hub-dpr
This task ships **direct-PR**: you raise the PR yourself, without the no-mistakes pipeline.
The task is complete only when committed on your branch.
When it is implemented and committed, push your branch and open a PR with `gh-axi` against the base branch `feature/hub` (`--base feature/hub`), not the repository default that is ready for review, not a draft.
Before you report done, read the PR back from the forge and confirm it is not a draft (`gh-axi pr view <number>` must print `draft: no`, where <number> is the PR number from your PR URL); if it is a draft, mark it ready with `gh-axi pr ready <number>`.
A draft cannot be merged, so a done report on one leaves the merge unasked.
Then append `done [at=<epoch>]: PR {url}` to the status file and stop.
That `done:` is accepted only when this copy's HEAD - your latest commit - is pushed to your PR branch; the check tests that commit, not merely that a branch moved.
If you deliberately keep the PR a draft, append `paused [at=<epoch>]: {why the draft is held}` instead of done.
Do NOT run /no-mistakes. The configured merge authority decides whether to merge the PR; firstmate relays the outcome.
Evidence: Generated no-mistakes brief with base

Source: Generated no-mistakes brief with base

You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
## Captain's intent
{TASK}

## Firstmate spec
{FIRSTMATE_SPEC}

# 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 demo, at a detached HEAD on a clean copy of its base branch.
Base branch: feature/hub

**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 [at=<epoch>]: launched in primary checkout, not an isolated worktree` to the status file and stop.

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

# Rules
1. Never push to the base branch `feature/hub` or 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} [at=<epoch>]: {one short line}" >> '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-nm.status' && { [ ! -e '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/config/fleet-ledger' ] || '~/.no-mistakes/worktrees/5097ea27ba16/01M3Z4C0MHEMMXQ7H0TM0HH9VW/bin/fm-fleet-ledger.sh' appended '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/config' '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-nm.status' >/dev/null 2>&1 || true; }`
   States: working, needs-decision, blocked, paused, done, failed.
   Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
   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.
   Whenever you mention a PR anywhere - a status line, your terminal, a summary - write its full
   https:// URL exactly as the forge printed it, never a bare number such as "PR 108"; firstmate
   copies that URL from your line rather than assembling one.
   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:` - when deliberately waiting for work or an external condition expected to clear on its own, including your own validation round.
   Before ending your turn with your own background shell or monitor still running, or before waiting on your own pipeline run or a long foreground command, append `paused [at=<epoch>]: {job and completion condition}` to the status file.
   Name what you are waiting for and what will let you resume; do not repeat the declaration on every poll.
   Do not declare active implementation or reasoning as a wait.
   Firstmate may still raise one first-sight alert; the declared wait then uses the existing long recheck cadence instead of repeated possible-wedge alarms.
   When you know when the wait clears, include `until <YYYY-MM-DDTHH:MMZ>` (UTC) for a recheck at that time.
   Follow the resolution rule below when the wait clears, then resume the task.
   Use `blocked:` when you are stuck and need help.

5. If you hit the same obstacle twice, append `blocked [at=<epoch>]: {why}` and stop; firstmate will help.
6. If a decision belongs above the implementation worker (product choices, destructive actions),
   append `needs-decision [at=<epoch>]: {summary of options}` and stop. Firstmate will reply with the decision.
   For a no-mistakes ask-user gate specifically, escalate all ask-user findings as one event plus one snapshot file, using that same shape even when the gate holds only a single ask-user finding: write only the ask-user findings, verbatim and unparaphrased (id, severity, file, line, description, authority), to `/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/hub-nm/nm-<run>-findings.txt`, then report the gate with
   `needs-decision [at=<epoch>] [key=nm-<run>-<step>]: ask-user findings=<id1>,<id2>,... file=/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/hub-nm/nm-<run>-findings.txt`
   naming every ask-user finding id from that gate. The status line only points at the file; it never restates or summarizes a finding's content.
   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 [at=<epoch>]: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never administer infrastructure that every lane shares. Two things are shared:
   - The `no-mistakes` daemon - one instance serving every lane/home, so stopping, restarting, or
     updating it kills other lanes' in-flight pipeline runs; only firstmate manages the daemon.
     Before you append `blocked:` about the pipeline, run `no-mistakes daemon status` and
     `no-mistakes axi status`. If the daemon socket refuses connections or is missing, append
     `blocked [at=<epoch>]: {the daemon error}` and stop even when the local run record still says running or
     fixing, because that record can be stale after the daemon exits. A run record failed with a
     daemon error is also a real block.
     Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep
     going. A drive-call error, timeout, slow read, or generic unreachability is NOT a daemon error:
     the daemon accepts `respond` immediately and runs the round in the background, so a killed or
     timed-out call was only waiting for a read while the run kept working.
   - The worktree pool your own worktree came from, and the repository every lane's worktree
     shares. Never create, remove, return, prune, move, or reassign a worktree or pool slot, and
     never write into a sibling slot's directory. Rule 2 does not cover this: removing a worktree
     is administration rather than an edit outside your directory, and it lands on lanes that are
     running right now. The act is the rule and commands are only examples of it - `treehouse`
     get/return/remove/prune, the equivalent operations on any other worktree provider or runtime
     backend, and `git worktree add|remove|move|prune`. A slot that looks unused is not evidence
     that it is free, and returning your own worktree is firstmate's job at cleanup, not yours.
   If you genuinely need a second checkout, another slot, or the daemon touched, append
   `blocked [at=<epoch>]: {what you need}` and stop; firstmate arranges it.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-nm.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-nm.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-nm.inbox'/NNN.msg '/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/state/hub-nm.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
A project's `AGENTS.md` or `CLAUDE.md` is loaded into every agent session in that project, so edit it only to correct information that is factually wrong - including information your own change made wrong - and never to add knowledge because it is missing.
A correction edits only the wrong text: do not run `~/.no-mistakes/worktrees/5097ea27ba16/01M3Z4C0MHEMMXQ7H0TM0HH9VW/bin/fm-ensure-agents-md.sh`, create either file, or add sections, headings, or pointers alongside it.

# Definition of done
Delivery contract: mode=no-mistakes
Ship branch: fm/hub-nm
The task is complete only when committed on your branch.
When you believe it is complete, append `done [at=<epoch>]: {summary}` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate and ship a PR.
That first `done:` is the handoff that starts the pipeline, which owns the push; it is not a request to push from this copy.
This task's base branch is `feature/hub`, not the repository default: pass `--base-branch feature/hub` on every `no-mistakes axi run` that starts a run, so the pipeline rebases onto, opens its PR against, and watches CI for that branch.

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, pass `--intent` as only this brief's `## Captain's intent` subsection body, not its heading, plus any later words the captain actually said.
Preserve the actual words without adding speaker labels or direct address; the subsection heading supplies provenance outside the pipeline input.
For a legacy brief with no such subsection, include only words on lines marked `[captain] `, excluding that metadata prefix; never copy its mixed `# Task` wholesale.
If it has no provenance-marked captain words, stop and ask firstmate instead of starting no-mistakes.
Do not include `## Firstmate spec`, later Firstmate build constraints, or your own decisions and tradeoffs.
The `--intent` string you pass must be self-sufficient: that string plus the codebase must let a reader reconstruct roughly the same specification, without depending on a separate report, a PR, or context that lives only in this conversation.
When the captain's intent refers to a report, decision, or PR ("do items 1, 2, 3, and 7 of the report"), write the substance of the referenced items into `--intent` in the captain's terms, not only the pointer; that substance is the captain's ask by reference, while Firstmate's build instructions and your own decisions still stay out.
This replaces the no-mistakes skill's advice to enrich `--intent` with decisions and tradeoffs; that advice does not apply to Firstmate-dispatched work.
Do not hand-edit, commit, or fix findings yourself while a run is active - the pipeline applies every fix.

One drive call blocks until the next gate or outcome, which routinely outlives what your harness lets a single command run: Claude Code kills a command at ten minutes maximum, while one fix round is capped around thirty minutes and up to three rounds chain.
So background the drive call instead of sitting in one blocking hold your harness will kill, and read its return when it finishes.
Declare that wait using the brief's status-reporting rule before waiting on the backgrounded drive call.
Where a harness's own command limit is not established, assume it bounds commands and use that same backgrounded shape.
Only a drive call's return reports the green PR: `no-mistakes axi status` shows progress but never reports `checks-passed` while the ci step is still monitoring the PR for merge, so never wait on a status poll for the next gate or outcome.
Whenever a drive call returns without a gate or an outcome - its own wait elapsed, or it was killed or timed out - reattach at once by re-running `no-mistakes axi run` without flags, backgrounded the same way; once checks are green it returns `checks-passed` immediately, and if it refuses because no run is active, read the finished outcome from `no-mistakes axi status`.
A killed or timed-out call is never evidence the daemon died: the daemon accepts your response immediately and runs the round in the background, so the call was only ever waiting for a read while the run kept working.
Reattach and keep going rather than reporting the pipeline blocked; rule 7 owns the checks that decide when a pipeline block is real.

Two firstmate-specific rules layer on top of that guidance:
- ask-user findings are never yours to answer: escalate to firstmate using rule 6's ask-user format 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), read the PR back from the forge and confirm it is not a draft (`gh-axi pr view <number>` must print `draft: no`, where <number> is the PR number from your PR URL); if it is a draft, mark it ready with `gh-axi pr ready <number>`.
A draft cannot be merged, so a done report on one leaves the merge unasked.
Then append `done [at=<epoch>]: PR {url} checks green` and stop. You are finished.
That CI-ready `done:` is accepted only when this copy's HEAD - your latest commit - is one the /no-mistakes run pushed, so commit nothing after the run; the check tests that commit, not merely that a branch moved.
If you deliberately keep the PR a draft, append `paused [at=<epoch>]: {why the draft is held}` instead of done.
Evidence: No-base briefs identical to base commit

Source: No-base briefs identical to base commit

plain: no-base brief identical to base commit 87fa81b output (after normalizing script root path)
pnm: no-base brief identical to base commit 87fa81b output (after normalizing script root path)
psc: no-base brief identical to base commit 87fa81b output (after normalizing script root path)
Evidence: Live spawn successes (scout, direct-PR ship, matching decoy)

Source: Live spawn successes (scout, direct-PR ship, matching decoy)

$ fm-spawn.sh hub-scout /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --scout --base-branch feature/hub --harness claude
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
spawned hub-scout harness=claude kind=scout window=primary:fm-hub-scout worktree=/private/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T/fm-lab.PKJQM5/th/.treehouse/demo-96df6c/1/demo
[exit 0]

$ fm-spawn.sh hub-dpr /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --mode direct-PR --yolo off --base-branch feature/hub --harness claude
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
notice: hub-dpr ships mode=direct-PR while the standing posture for demo is no-mistakes - less rigor than the captain's standing posture; proceed only on a current explicit captain instruction or an intake judgment you can state
spawned hub-dpr harness=claude kind=ship mode=direct-PR yolo=off window=primary:fm-hub-dpr worktree=/private/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T/fm-lab.PKJQM5/th/.treehouse/demo-96df6c/2/demo
[exit 0]

$ fm-spawn.sh decoyeq /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --scout --base-branch feature/hub --harness claude
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
spawned decoyeq harness=claude kind=scout window=primary:fm-decoyeq worktree=/private/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T/fm-lab.PKJQM5/th/.treehouse/demo-96df6c/2/demo
[exit 0]
Evidence: Live spawn refusals

Source: Live spawn refusals

$ fm-spawn.sh flagonly /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --scout --base-branch feature/hub
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
error: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/flagonly/brief.md must record Base branch: feature/hub and no other Base branch line to spawn with --base-branch feature/hub; scaffold it with bin/fm-brief.sh --base-branch feature/hub
[exit 1]

$ fm-spawn.sh lineonly /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --scout
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
error: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/lineonly/brief.md records a Base branch line but the spawn has no --base-branch; pass the brief's base with --base-branch or re-scaffold the brief without one
[exit 1]

$ fm-spawn.sh decoy /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --scout --base-branch feature/hub
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
error: /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/data/decoy/brief.md must record Base branch: feature/hub and no other Base branch line to spawn with --base-branch feature/hub; scaffold it with bin/fm-brief.sh --base-branch feature/hub
[exit 1]

$ fm-spawn.sh sm --secondmate --base-branch feature/hub
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
error: --base-branch applies only to ship and scout spawns; a secondmate charter has no task base
[exit 1]

$ fm-spawn.sh flagonly /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --mode local-only --yolo off --base-branch feature/hub
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
error: fm-spawn.sh --base-branch: a base branch cannot ship mode=local-only, whose landing fast-forwards local main; ship no-mistakes or direct-PR, which open a pull request against the base
[exit 1]

$ fm-spawn.sh missing /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5/projects/demo --scout --base-branch feature/missing
fm-gate-refuse: gate agent lifecycle permitted only against lab home /var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T//fm-lab.PKJQM5
fatal: couldn't find remote ref refs/heads/feature/missing
error: could not fetch 'origin/feature/missing' for pooled worktree '/private/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T/fm-lab.PKJQM5/th/.treehouse/demo-96df6c/1/demo'; refusing to launch from a potentially stale base
[exit 1]
Evidence: Scout copy starts at origin/feature/hub

Source: Scout copy starts at origin/feature/hub

worker copy HEAD:      9c881af176ad6c768e4b868db996bd33f970d8c2
origin/feature/hub:    9c881af176ad6c768e4b868db996bd33f970d8c2
origin/main:           ee93ebc07eae23bac711a69df837017c97d4c489
ls worker copy: feature-only.txt README.md 
only on feature/hub
Evidence: Ship copy starts at origin/feature/hub

Source: Ship copy starts at origin/feature/hub

ship worker copy HEAD: 9c881af176ad6c768e4b868db996bd33f970d8c2
origin/feature/hub:    9c881af176ad6c768e4b868db996bd33f970d8c2
branch: 
feature-only.txt
README.md
Evidence: No-base control spawn at origin/main, no base_branch meta

Source: No-base control spawn at origin/main, no base_branch meta

--- plain (no --base-branch) meta:
window=primary:fm-plain
endpoint_task_id=plain
worktree=/private/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T/fm-lab.PKJQM5/th/.treehouse/demo-96df6c/3/demo
project=/var/folders/9_/lqnhn5_j6vz053wzxq2mk9rm0000gn/T/fm-lab.PKJQM5/projects/demo
harness=claude
kind=ship
mode=direct-PR
yolo=off
branch=fm/plain
tasktmp=/tmp/fm-plain
model=default
effort=default
busy_gen=g1790973522.27468.13528
spawn_gen=s1790973522.26775.16710
copy HEAD: ee93ebc07eae23bac711a69df837017c97d4c489  origin/main: ee93ebc07eae23bac711a69df837017c97d4c489
files: README.md 
0
Evidence: Review diff against origin/feature/hub

Source: Review diff against origin/feature/hub

$ fm-review-diff.sh hub-dpr --stat
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
diff base: origin/feature/hub
 work.txt | 1 +
 1 file changed, 1 insertion(+)
[exit 0]

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (2) ✅
  • ⚠️ bin/fm-dod-lib.sh:184 - fm_brief_base_branch takes the first line that is exactly # Setup, but the brief puts # Task (the captain's intent and firstmate spec, filled with free text) before the real # Setup. Nothing stops that text from containing a # Setup line (fm_brief_task_content_valid does not reject top-level headings), so a pasted ticket or doc with a # Setup H1 breaks the parse in two ways. (1) If no Base branch: line follows it before the next # heading, awk hits exit at the scaffold's own # Setup and never reads the real Base branch: &lt;b&gt; line. The spawn then silently starts from origin's default branch, records no base_branch=, and the worker still opens its PR against &lt;b&gt; as the brief tells it. That is exactly the wrong-code start this change is meant to close. (2) If a Base branch: x line follows it, prose redirects the spawn, which the intent forbids. Concrete case: fm-brief.sh --mode direct-PR --base-branch feature/hub, then the captain's intent contains "# Setup\nRun npm i". The spawn resets to origin/main. Smallest fix: anchor the parse to the scaffold's own Setup section, for example accept Base branch: only as the line right after the scaffold's fixed You are in a disposable git worktree ... clean copy of its base branch. line, or skip the # Task section before looking for # Setup. Add a regression case where the intent contains a # Setup line. Same reader: bin/fm-spawn.sh:3070 (the only caller).

🔧 Fix applied.
2 warnings still open:

  • ⚠️ bin/fm-dod-lib.sh:184 - fm_brief_base_branch takes the first line that is exactly # Setup, but the brief puts # Task (the captain's intent and firstmate spec, filled with free text) before the real # Setup. Nothing stops that text from containing a # Setup line (fm_brief_task_content_valid does not reject top-level headings), so a pasted ticket or doc with a # Setup H1 breaks the parse in two ways. (1) If no Base branch: line follows it before the next # heading, awk hits exit at the scaffold's own # Setup and never reads the real Base branch: &lt;b&gt; line. The spawn then silently starts from origin's default branch, records no base_branch=, and the worker still opens its PR against &lt;b&gt; as the brief tells it. That is exactly the wrong-code start this change is meant to close. (2) If a Base branch: x line follows it, prose redirects the spawn, which the intent forbids. Concrete case: fm-brief.sh --mode direct-PR --base-branch feature/hub, then the captain's intent contains "# Setup\nRun npm i". The spawn resets to origin/main. Smallest fix: anchor the parse to the scaffold's own Setup section, for example accept Base branch: only as the line right after the scaffold's fixed You are in a disposable git worktree ... clean copy of its base branch. line, or skip the # Task section before looking for # Setup. Add a regression case where the intent contains a # Setup line. Same reader: bin/fm-spawn.sh:3070 (the only caller).
  • ⚠️ bin/fm-dod-lib.sh:174 - The round-1 fix round rewrote fm_brief_base_branch to keep the last Base branch: line that follows the base-variant Setup sentence. That only works when the scaffold itself wrote a base, because the real Setup pair then comes after # Task and wins. It still fails when the brief has no base. Then the scaffold writes the default-variant sentence (... at a detached HEAD on a clean default branch.). If the captain's intent or Firstmate spec contains the base-variant sentence followed by Base branch: x, that prose pair is the only match and becomes the base. Concrete case: fm-brief.sh t1 firstmate --mode direct-PR (no --base-branch), and the intent quotes a brief snippet. That is realistic for firstmate working on its own repo, and it is the exact text shape the fix round's own test inserts. fm-spawn.sh:3070 then resets the copy to origin/x and records base_branch=x. Meanwhile the brief's Rule 1 and Definition of done still target the default branch. This is the 'prose redirects a spawn' outcome the intent forbids: 'a Base branch: line inside # Task ... is deliberately ignored so prose cannot redirect a spawn.' The fix round's regression test (tests/fm-brief.test.sh:471-475) only covers a brief that already has a base, so it passes while this case is broken. Smallest fix in the same function: make the last Setup sentence of either variant decide. Add a rule that clears base when a line matches ^You are in a disposable git worktree of .*, at a detached HEAD on a clean default branch\.$. Because the scaffold's Setup sentence always follows # Task, its variant then wins. Extend the test with the same decoy inserted into a no-base brief (brief-base-none-b4) and assert an empty result. The only consumer is bin/fm-spawn.sh:3070.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 info
  • ℹ️ bin/fm-dod-lib.sh:220 - The direct-PR Definition of done with a base branch now reads 'open a PR with gh-axi against the base branch feature/hub (--base feature/hub), not the repository default that is ready for review, not a draft'. Inserting the base clause before 'that is ready for review' makes 'that' seem to attach to 'the repository default'. The worker read it correctly in the live run; the fix is only a wording polish.
  • Live validation: ✅ go - 12 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Captain scaffolds a ship/scout brief with --base-branch feature/hub and the brief records the base and targets it ✅ pass live brief-transcript.txt, brief-hub-dpr.md, brief-hub-nm.md, brief-hub-scout.md
fm-brief.sh refuses --base-branch on local-only, gerrit, invalid names, and secondmate charters ✅ pass live brief-transcript.txt
A brief without --base-branch is byte-identical to the pre-change output ✅ pass live no-base-brief-identical.txt
Scout and ship spawns with --base-branch start the worker copy from origin/feature/hub and record base_branch= ✅ pass live spawn-success.txt, scout-spawn-copy.txt, ship-spawn-copy.txt, scout-worker-pane.txt, ship-worker-pane.txt
A spawn without --base-branch behaves as before ✅ pass live plain-spawn-control.txt
Adversarial: spawn refuses when the flag and the brief's Base branch lines disagree (flag only, line only, mismatching decoy in Captain's intent) and publishes no meta ✅ pass live spawn-refusals.txt
A decoy Base branch line equal to the flag value is harmless ✅ pass live spawn-success.txt (decoyeq)
Adversarial: spawn refuses when origin lacks the base branch, on local-only, and on a secondmate, never falling back to the default ✅ pass live spawn-refusals.txt
Relaunch reuses the recorded base and refuses an override ✅ pass live relaunch-transcript.txt
fm-review-diff.sh diffs a base-branch task against origin/<base> ✅ pass live review-diff-hub-dpr.txt, review-diff-plain-control.txt
fm-teardown.sh content-landed fallback checks origin/<base> ✅ pass live teardown-before-land.txt, teardown-after-land-on-base.txt, teardown-retry.txt
fm-promote.sh keeps a scout's base for the ship contract and refuses a mode that cannot carry it ✅ pass live promote-local-only-refused.txt, promote-direct-PR.txt, promote-ship-instructions.md
  • fm-brief.sh hub-dpr|hub-nm demo --mode direct-PR|no-mistakes --base-branch feature/hub and fm-brief.sh hub-scout demo --scout --base-branch feature/hub in the lab home (checked the Setup line, Rule 1, the direct-PR --base, and the no-mistakes --base-branch instruction)
  • fm-brief.sh refusals: local-only, --forge gerrit, bad..name, -x, and --secondmate each combined with --base-branch
  • No-base briefs (direct-PR, no-mistakes, scout) compared byte-for-byte with base commit 87fa81b's fm-brief.sh output (git archive export), after normalizing the script-root path
  • Live fm-spawn.sh hub-scout &lt;proj&gt; --scout --base-branch feature/hub --harness claude on the lab tmux socket with a lab-rooted Treehouse pool: worker copy HEAD == origin/feature/hub, feature-only.txt present, meta base_branch=feature/hub; the Claude worker's report shows the feature commit
  • Live fm-spawn.sh hub-dpr &lt;proj&gt; --mode direct-PR --yolo off --base-branch feature/hub --harness claude: copy at origin/feature/hub on fm/hub-dpr, base_branch= recorded, worker proposes a PR against feature/hub
  • Control spawn fm-spawn.sh plain &lt;proj&gt; --mode direct-PR --yolo off (no flag): copy at origin/main, no base_branch= in meta
  • Spawn refusals: flag without brief line, brief line without flag, mismatching Base branch: release/decoy in Captain's intent, --secondmate with flag, local-only with flag, origin lacking feature/missing; no meta published for any of them
  • Matching decoy Base branch: feature/hub in Captain's intent plus the flag spawns successfully
  • fm-spawn.sh hub-dpr --relaunch --base-branch other refused; fm-control.sh hub-dpr relaunch --note-file ... relaunched with base_branch=feature/hub kept
  • fm-review-diff.sh hub-dpr --stat after origin/main advanced: diff base origin/feature/hub, only work.txt; control fm-review-diff.sh plain --stat uses origin/main
  • fm-teardown.sh hub-dpr before the work landed (REFUSED, unpushed and not landed), then after a squash commit landed on origin/feature/hub only (passes the landed check and reaps processes)
  • fm-promote.sh hub-scout --mode local-only refused because of the recorded base; --mode direct-PR succeeds, keeps base_branch=, and the ship instructions name feature/hub for checkout, Rule 1, and --base feature/hub
  • Lab teardown: tmux -L fm-lab kill-server, removed the lab dir and the /tmp/fm-<id> tasktmp dirs, verified no demo pool left under ~/.treehouse
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Spawns always reset a task's pooled copy to origin's default branch,
so work that belongs on a feature, integration, or release branch
started from the wrong code and opened its PR against the default.

fm-brief.sh --base-branch records the base in the brief, fm-spawn.sh
resets the copy to origin/<base> and records base_branch= in task
meta, and the worker targets its PR at that branch. Review diffs,
the cleanup content check, and scout promotion read the recorded
base. local-only and Gerrit deliveries refuse a named base.
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds optional base-branch parameter to task workflow scripts.

The PR appears safe to merge based on the reviewed changes and resolved findings.

Reviews (4) · Last reviewed commit: "Merge upstream main into fm/custom-base-..."

Comment thread bin/fm-spawn.sh Resolved
Comment thread bin/fm-spawn.sh Resolved
Comment thread bin/fm-dod-lib.sh Resolved
Comment thread bin/fm-dod-lib.sh Resolved
…fied. The affected suites pass locally: fm-brief, fm-dod-lib, fm-spawn-pool-base-freshen, fm-review-diff, fm-teardown and fm-task-delivery. shellcheck on the changed files reports only info-level notes, no warnings or errors. I didn't revert the code to watch each new test fail before the fix. - **ci-1 (brief text blocked or redirected spawns):** In bin/fm-dod-lib.sh, `fm_brief_base_branches` now only accepts a `Base branch: <value>` line that comes directly after the base-variant Setup sentence fm-brief.sh writes. Any other `Base branch:` line is ignored. `--base-branch` is still the only authority, and the existing checks in fm-spawn.sh are unchanged. With the flag, the spawn is refused unless a matching pair exists and no pair names a different branch. Without the flag, it is refused only if such a pair exists. The header comment in fm-spawn.sh is updated to match. - The `brief_with_base` test helper now writes the real two-line pair. - The decoy refusal case now uses a full decoy pair in the captain's intent. - New test `test_prose_base_branch_line_is_ignored`: a brief with no base whose intent quotes `Base branch: release/1.2` spawns normally with no `base_branch=` recorded. A spawn with `--base-branch feature/hub` whose intent names release/1.2 starts from `origin/feature/hub` and records it. - **ci-2 (scout base not checked against the forge):** fm-spawn.sh now looks up the project's registered forge with `bin/fm-project-mode.sh --forge`, like the ship path does, before `fm_base_branch_valid` runs. Previously it passed `none`. New test `test_scout_base_branch_refused_on_gerrit_forge`: a scout with a base on a forge=gerrit project is refused at spawn and no meta file is written. - **ci-3 (base not shell-quoted in worker commands):** `fm_dod_block` now quotes the base with `printf %q` in the `--base` and `--base-branch` arguments, and the branch name in the prose stays readable. The test in fm-brief.test.sh uses the base `release/$HOTFIX` and checks that both direct-PR and no-mistakes briefs render `release/\$HOTFIX` in the commands. - **ci-4 (ambiguous PR sentence):** The direct-PR sentence now reads "open a PR with `gh-axi` that is ready for review, not a draft, against the base branch `X` (`--base X`), not the repository default." A brief with no base renders exactly as before. The existing assertion in fm-brief.test.sh is updated
@lakshyads05

Copy link
Copy Markdown
Contributor Author

@kunchenguid this PR is ready to be reviewed. Please approve the workflows.

@lakshyads05

Copy link
Copy Markdown
Contributor Author

@kunchenguid why are the workflows not starting?
image
I am waiting on this PR since 2 days. is there an issue with this PR that i need to address?

@kunchenguid

Copy link
Copy Markdown
Owner

This triage comes from Kun's firstmate (an automated assistant, posting publicly). It is waiting on CI. You don't need to do anything right now. Sorry the runs sat unapproved for two days. They are approved and running now.

What the tip does (my reading vs main f470a01c): Adds an optional per-task --base-branch <branch> to bin/fm-brief.sh and bin/fm-spawn.sh. The brief records a Base branch: line under # Setup, and spawn must be given the same flag. It then resets the pooled copy to origin/<branch>. It refuses when there is no origin, the branch is missing, the mode is local-only, or the forge is gerrit. It never falls back to the default branch. It records base_branch= in task meta. fm-review-diff.sh, fm-teardown.sh's content-landed check and fm-promote.sh read that meta value. The worker contract targets the base (--base / --base-branch, quoted with %q).

contract-class: opt-in. I did not rely on the PR's own framing for this. Without the flag, SETUP_BASE is the same Setup sentence. fm_ship_rule_one still says "Never push to the default branch". The no-mistakes DoD keeps the same blank line. freshen_spawn_worktree_base with an empty base runs the unchanged set-head --auto / default_branch path. Consumers fall back to default_branch when meta has no base_branch=. Promote keeps the "default-branch base" wording. The new behavior only runs when the captain passes the flag.

VISION (per rule):

  • One captain, one interface: aligns. There are no new wakes or captain-facing surfaces, and it stops based work from silently starting off the wrong branch.
  • Authority is explicit and never inferred: aligns. It is an explicit per-task flag, the brief and spawn must agree, and nothing is inferred from prose (only the Setup line directly after the base-variant sentence counts). It is off by default.
  • Scripts own the mechanics, agents own the judgment: aligns. Validation lives in deterministic fm_base_branch_valid / fm_brief_base_branches in fm-dod-lib.sh, and the scripts refuse rather than guess. AGENTS.md grows by 43 words (6845 → 6888), well under the 9,000 ceiling.
  • A restart is a non-event: aligns. The base is durable in task meta, kept through preserve_relaunch_meta, and a relaunch refuses an override.
  • Delegation with a spine: aligns. It extends the existing ship/scout contract with a parameter rather than adding a new task shape, and refuses local-only/gerrit where no PR carries the base.
  • The fleet outlives any vendor: aligns. It uses plain git/gh/no-mistakes flags with no harness or session-manager coupling.
  • Scope: aligns. This is command-layer task setup, and validation and merge stay with no-mistakes and the forge.

Gates on this head (2542a28c):

  • Attestation MATCH. The body's no-mistakes-pipeline-attestation head_sha equals the head.
  • Fork workflows approved this pass, for this head only: CI 37064756768 (action_required → in progress), Require no-mistakes 37064757066 (action_required → SUCCESS).
  • Greptile 5/5 on 2542a28c. The three earlier P1s (prose decoy, gerrit validation, shell quoting) and the P2 wording issue were raised on 7fd9e385. The tip fixes all four and the threads are resolved, so there are no open P1s.
  • MERGEABLE/UNSTABLE (CI pending). No .github/workflows changes. No Fixes/Closes link.

Small note: the PR body's Intent bullet still says "fm-spawn.sh adds no new flag", but What Changed and the code both use fm-spawn.sh --base-branch. That is cosmetic, not blocking.

Next: once CI is green this is otherwise ready. Because it is opt-in, it does not need a default-behavior decision. I'm not raising a captain card from this triage, and I'm not merging anything.

… from CI tooling and a Pi version bump, not from the base-branch feature. Fixes for both already exist on upstream main, so I applied those two commits to the working tree with `git cherry-pick --no-commit`. Nothing is committed or pushed, and no feature file changed. - **Lint 2:** ShellCheck ran out of memory on `bin/fm-teardown.sh` (rss about 8 GB, exit 251, "shellcheck: out of memory"). The rule that broke is that the lint gate must finish on any valid shell root without exceeding the runner's memory ceiling. Upstream commit d719ef3 (kunchenguid#6443) fixes this in `bin/fm-lint.sh`: a root that hits the memory ceiling is retried without `--external-sources`. It also updates `tests/fm-lint.test.sh` and `docs/fm-test-portable-shards.md`. - **Behavior portable serial 6:** `tests/fm-calm-pi-extension.test.sh` failed with "grep disappeared from /export calm.html HTML while calm mode was on". Pi 1.0.1 renamed its HTML export renderer lookup, and upstream commit fede619 (kunchenguid#6530) updates the test to accept the new name. This change is test-only. Both commits applied cleanly. The four touched files are `bin/fm-lint.sh`, `docs/fm-test-portable-shards.md`, `tests/fm-lint.test.sh` and `tests/fm-calm-pi-extension.test.sh`. None of them is in the feature diff, so the feature contract is unchanged. **Local checks:** - `tests/fm-lint.test.sh` passes. - `bin/fm-lint.sh` on `bin/fm-teardown.sh`, `bin/fm-spawn.sh` and `bin/fm-dod-lib.sh` exits 0 with full ShellCheck analysis. - `tests/fm-calm-pi-extension.test.sh` exits 0 with 7 ok and 0 not ok. One case skipped because the Pi package isn't installed locally, so the Pi 1.0.1 export path that failed in CI couldn't be reproduced here. CI needs to confirm it. - I didn't reproduce the 8 GB OOM locally. The PR has to be updated through the pipeline with a normal push: no force push, no replacement PR, no merge
@lakshyads05

Copy link
Copy Markdown
Contributor Author

The 6th commit (c76e0f15) brings in two fixes already on upstream main for the failing CI checks:

  • Lint 2: retry ShellCheck without external-source analysis when it runs out of memory, retaining the original time/memory limits and explicitly reporting the narrower check. Includes regression tests and documentation.
  • Behavior portable serial 6: update the export-rendering test fixture for Pi 1.0.1+'s renamed renderer lookup, while retaining compatibility with the earlier name.

The named-base-branch feature is unchanged. Could you please approve the fork workflows for this new commit so CI can run again? Thanks!

@kunchenguid

Copy link
Copy Markdown
Owner

This triage comes from Kun's firstmate (an automated assistant, posting publicly). It is waiting on you (the author), because CI is red on the new head. Thanks for the quick follow-up commit. I approved both fork runs for c76e0f15 right after you asked.

What changed since my last note: You pushed c76e0f15. It brings in the two upstream fixes for the earlier failures. I checked bin/fm-lint.sh, docs/fm-test-portable-shards.md, tests/fm-lint.test.sh and tests/fm-calm-pi-extension.test.sh at this head, and all four are byte-for-byte the same as current main (from #6443 and #6530). No feature file changed. Lint 2 and Behavior portable serial 6 both pass now.

What is still failing (CI run 37290289885, 16 passed, 1 failed, 1 cancelled):

  • Behavior portable serial 7 failed in tests/fm-remote-job.test.sh: not ok - the replacement adopted an unrelated persisted pid.
  • Behavior portable serial 2 hit the 30-minute job timeout and was cancelled. tests/fm-supervision-host.test.sh passed, but it took about 26 minutes (1581 s), and the shard was cancelled during tests/fm-procevent-quota.test.sh.

Neither failure is in code this PR touches. The same feature code passed both lanes on 2542a28c. Main has also reworked the remote-job worker since your branch point (#6431, #6575), and your branch is 9 commits behind main. What unblocks it: update the branch to latest main through your no-mistakes pipeline with a normal push (no force push), then CI runs again. If these two lanes pass, this PR is otherwise ready.

What the tip does (my reading vs main f470a01c): I read it again on this head and it is unchanged. It adds an optional per-task --base-branch <branch> to bin/fm-brief.sh and bin/fm-spawn.sh. The brief records a Base branch: line directly under the base-variant Setup sentence, and spawn must be given the same flag. Spawn then resets the pooled copy to origin/<branch> and records base_branch= in task meta. fm-review-diff.sh, fm-teardown.sh's content check and fm-promote.sh read that value. The ship contract targets that base, with %q quoting. It refuses local-only, a non-none forge, a missing origin, and invalid names, and it never falls back to the default branch.

contract-class: opt-in. I worked this out from the code again, not from the PR's own description. Without the flag, the Setup line, rule one ("Never push to the default branch") and the DoD all render as before. freshen_spawn_worktree_base with an empty base runs the unchanged set-head --auto / default_branch path. Every consumer falls back to the default branch when meta has no base_branch=. The only new refusal without the flag is a brief that carries the scaffolded base pair, and only --base-branch writes that pair. The new behavior runs only when the captain asks for it.

VISION (per rule):

  • One captain, one interface: aligns. There are no new wakes or captain-facing surfaces.
  • Authority is explicit and never inferred: aligns. It is an explicit per-task flag, brief and spawn must agree, prose Base branch: lines are ignored, and it is off by default.
  • Scripts own the mechanics, agents own the judgment: aligns. Validation lives in deterministic fm_base_branch_valid / fm_brief_base_branches, and the scripts refuse rather than guess. AGENTS.md gains one line, well under the 9,000-word ceiling.
  • A restart is a non-event: aligns. The base lives in task meta and is kept through preserve_relaunch_meta.
  • Delegation with a spine: aligns. It adds a parameter to the existing ship and scout contracts, not a new task shape.
  • The fleet outlives any vendor: aligns. It uses plain git, gh and no-mistakes flags.
  • Scope: aligns. This is command-layer task setup, and validation and merge stay with no-mistakes and the forge.

Gates on c76e0f15: Attestation MATCH. Require no-mistakes 37290289972 SUCCESS. CI 37290289885 failure (serial 7 and serial 2, above). Greptile 5/5 on this commit with no open P1. MERGEABLE/UNSTABLE. No .github/workflows changes. No Fixes/Closes link. I'm not raising a captain card from this triage, and I'm not merging anything until CI is green.

@lakshyads05

Copy link
Copy Markdown
Contributor Author

The 7th commit (5239f79e) merges the latest upstream main (f470a01c) into this branch with a normal merge commit (no rebase, no force push), as suggested. It brings the branch up to date with main for the two lanes that failed on c76e0f15, neither of which is in code this PR touches:

The named-base-branch feature is unchanged: the diff against main is still the same 14 files. Could you please approve the fork workflows for this new commit so CI can run again? Thanks!

@kunchenguid

kunchenguid commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

This triage comes from Kun's firstmate (an automated assistant, posting publicly). This PR is ready, so I'm squash-merging it now. Thanks for merging main in so quickly. It fixed both lanes.

What changed since my last note: You pushed 5239f79e, a normal merge of main f470a01c into the branch. The diff against main is still the same 14 files, and no feature file changed. CI run 37302779990 is fully green on this head, including Behavior portable serial 2 and serial 7.

What the tip does (my reading on 5239f79e): I read it again on this head. It adds an optional per-task --base-branch <branch> to bin/fm-brief.sh and bin/fm-spawn.sh. The brief writes a Base branch: line directly under the base-variant Setup sentence, and spawn has to be given the same flag. Spawn then resets the pooled copy to origin/<branch> and records base_branch= in task meta. fm-review-diff.sh, fm-teardown.sh's content-landed check and fm-promote.sh read that value. It refuses local-only, a non-none forge, a missing origin or branch, and invalid names, and it never falls back to the default branch.

contract-class: opt-in. I checked this in the code again rather than taking it from the PR description. Without the flag, the Setup sentence, rule one ("Never push to the default branch"), and the direct-PR and no-mistakes DoD all render as before. freshen_spawn_worktree_base with an empty base takes the unchanged set-head --auto / default_branch path. Every consumer falls back to the default branch when meta has no base_branch=.

VISION (per rule):

  • One captain, one interface: aligns. It adds no new wakes or captain-facing surfaces.
  • Authority is explicit and never inferred: aligns. It is an explicit per-task flag that is off by default. Brief and spawn must agree, and prose Base branch: lines are ignored.
  • Scripts own the mechanics, agents own the judgment: aligns. Validation is deterministic (fm_base_branch_valid / fm_brief_base_branches), and the scripts refuse rather than guess. AGENTS.md grows by one line (6845 → 6888 words), well under the 9,000-word ceiling.
  • A restart is a non-event: aligns. The base lives in task meta, survives preserve_relaunch_meta, and a relaunch refuses an override.
  • Delegation with a spine: aligns. It adds a parameter to the existing ship and scout contracts, not a new task shape.
  • The fleet outlives any vendor: aligns. It uses plain git, gh and no-mistakes flags.
  • Scope: aligns. This is command-layer task setup. Validation and merge stay with no-mistakes and the forge.

Gates on 5239f79e:

  • Attestation MATCH: the body's no-mistakes-pipeline-attestation head_sha equals the head.
  • Require no-mistakes 37302780070 SUCCESS. CI 37302779990 SUCCESS (all 20 checks pass).
  • Greptile 5/5 on this commit. All four earlier review threads (three P1s and one P2) are resolved, so no P1 is open.
  • MERGEABLE/CLEAN. No .github/workflows changes. No Fixes/Closes link.
  • Main has moved one commit since your merge (98d80a16, feat(bin): record no-mistakes pipeline spend per task at teardown, opt-in #5354). It touches bin/fm-teardown.sh and tests/fm-teardown.test.sh in hunks separate from yours. I merged the two locally and the result was clean. On the merged result, the pipeline-spend, brief, review-diff and spawn-freshen suites pass. The dod-lib suite fails one environment-dependent case, and main alone fails that same case on my box. So I'm not asking for another update.

Next: because this is opt-in, it needs no default-behavior decision. I'm squash-merging it now and not raising a captain card.

@kunchenguid
kunchenguid merged commit 6a7b391 into kunchenguid:main Oct 5, 2026
20 checks passed
max-metaplanet pushed a commit to max-metaplanet/firstmate that referenced this pull request Oct 6, 2026
* feat(bin): start tasks from a named base branch

Spawns always reset a task's pooled copy to origin's default branch,
so work that belongs on a feature, integration, or release branch
started from the wrong code and opened its PR against the default.

fm-brief.sh --base-branch records the base in the brief, fm-spawn.sh
resets the copy to origin/<base> and records base_branch= in task
meta, and the worker targets its PR at that branch. Review diffs,
the cleanup content check, and scout promotion read the recorded
base. local-only and Gerrit deliveries refuse a named base.

* no-mistakes(review): Anchor brief base-branch parse on scaffold Setup line

* no-mistakes(review): Require explicit --base-branch on spawn, matching brief lines

* no-mistakes(document): Note base-branch reset in fm-spawn freshness header

* no-mistakes(ci): I fixed all four Greptile findings the way you specified. The affected suites pass locally: fm-brief, fm-dod-lib, fm-spawn-pool-base-freshen, fm-review-diff, fm-teardown and fm-task-delivery. shellcheck on the changed files reports only info-level notes, no warnings or errors. I didn't revert the code to watch each new test fail before the fix. - **ci-1 (brief text blocked or redirected spawns):** In bin/fm-dod-lib.sh, `fm_brief_base_branches` now only accepts a `Base branch: <value>` line that comes directly after the base-variant Setup sentence fm-brief.sh writes. Any other `Base branch:` line is ignored. `--base-branch` is still the only authority, and the existing checks in fm-spawn.sh are unchanged. With the flag, the spawn is refused unless a matching pair exists and no pair names a different branch. Without the flag, it is refused only if such a pair exists. The header comment in fm-spawn.sh is updated to match. - The `brief_with_base` test helper now writes the real two-line pair. - The decoy refusal case now uses a full decoy pair in the captain's intent. - New test `test_prose_base_branch_line_is_ignored`: a brief with no base whose intent quotes `Base branch: release/1.2` spawns normally with no `base_branch=` recorded. A spawn with `--base-branch feature/hub` whose intent names release/1.2 starts from `origin/feature/hub` and records it. - **ci-2 (scout base not checked against the forge):** fm-spawn.sh now looks up the project's registered forge with `bin/fm-project-mode.sh --forge`, like the ship path does, before `fm_base_branch_valid` runs. Previously it passed `none`. New test `test_scout_base_branch_refused_on_gerrit_forge`: a scout with a base on a forge=gerrit project is refused at spawn and no meta file is written. - **ci-3 (base not shell-quoted in worker commands):** `fm_dod_block` now quotes the base with `printf %q` in the `--base` and `--base-branch` arguments, and the branch name in the prose stays readable. The test in fm-brief.test.sh uses the base `release/$HOTFIX` and checks that both direct-PR and no-mistakes briefs render `release/\$HOTFIX` in the commands. - **ci-4 (ambiguous PR sentence):** The direct-PR sentence now reads "open a PR with `gh-axi` that is ready for review, not a draft, against the base branch `X` (`--base X`), not the repository default." A brief with no base renders exactly as before. The existing assertion in fm-brief.test.sh is updated

* no-mistakes(ci): Both real failures on PR 6442 (run 37064756768) come from CI tooling and a Pi version bump, not from the base-branch feature. Fixes for both already exist on upstream main, so I applied those two commits to the working tree with `git cherry-pick --no-commit`. Nothing is committed or pushed, and no feature file changed. - **Lint 2:** ShellCheck ran out of memory on `bin/fm-teardown.sh` (rss about 8 GB, exit 251, "shellcheck: out of memory"). The rule that broke is that the lint gate must finish on any valid shell root without exceeding the runner's memory ceiling. Upstream commit d719ef3 (kunchenguid#6443) fixes this in `bin/fm-lint.sh`: a root that hits the memory ceiling is retried without `--external-sources`. It also updates `tests/fm-lint.test.sh` and `docs/fm-test-portable-shards.md`. - **Behavior portable serial 6:** `tests/fm-calm-pi-extension.test.sh` failed with "grep disappeared from /export calm.html HTML while calm mode was on". Pi 1.0.1 renamed its HTML export renderer lookup, and upstream commit fede619 (kunchenguid#6530) updates the test to accept the new name. This change is test-only. Both commits applied cleanly. The four touched files are `bin/fm-lint.sh`, `docs/fm-test-portable-shards.md`, `tests/fm-lint.test.sh` and `tests/fm-calm-pi-extension.test.sh`. None of them is in the feature diff, so the feature contract is unchanged. **Local checks:** - `tests/fm-lint.test.sh` passes. - `bin/fm-lint.sh` on `bin/fm-teardown.sh`, `bin/fm-spawn.sh` and `bin/fm-dod-lib.sh` exits 0 with full ShellCheck analysis. - `tests/fm-calm-pi-extension.test.sh` exits 0 with 7 ok and 0 not ok. One case skipped because the Pi package isn't installed locally, so the Pi 1.0.1 export path that failed in CI couldn't be reproduced here. CI needs to confirm it. - I didn't reproduce the 8 GB OOM locally. The PR has to be updated through the pipeline with a normal push: no force push, no replacement PR, no merge
@Nitsur10 Nitsur10 mentioned this pull request Oct 7, 2026