Repository navigation
feat(bin): start tasks from a named base branch - #6442
Conversation
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.
|
…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
|
@kunchenguid this PR is ready to be reviewed. Please approve the workflows. |
|
@kunchenguid why are the workflows not starting? |
|
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 contract-class: opt-in. I did not rely on the PR's own framing for this. Without the flag, VISION (per rule):
Gates on this head (
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 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
|
The 6th commit (
The named-base-branch feature is unchanged. Could you please approve the fork workflows for this new commit so CI can run again? Thanks! |
|
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 What changed since my last note: You pushed What is still failing (CI run
Neither failure is in code this PR touches. The same feature code passed both lanes on What the tip does (my reading vs main 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. VISION (per rule):
Gates on |
|
The 7th commit (
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! |
|
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 What the tip does (my reading on 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. VISION (per rule):
Gates on
Next: because this is opt-in, it needs no default-behavior decision. I'm squash-merging it now and not raising a captain card. |
* 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

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:
fm-brief.sh --base-branch <branch>(ship and scout briefs; refused on secondmate charters). It is recorded as one machine-readableBase branch: <branch>line under the brief's# Setupheading; aBase branch:line inside# Task(the captain's intent) or later sections is deliberately ignored so prose cannot redirect a spawn.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 recordsbase_branch=in task meta. A relaunch reuses the recorded value. Without the line, behavior and meta output are byte-identical to today.--base <base>, and no-mistakes passes--base-branch <base>on everyno-mistakes axi run.What Changed
fm-brief.sh --base-branch <branch>(ship and scout briefs only, refused on secondmate charters) writes aBase branch: <branch>line under# Setup.fm-spawn.sh --base-branch <branch>has to match everyBase 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 toorigin/<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 recordsbase_branch=in task meta, and a relaunch reuses that value. With no base branch, spawn behaves as before.fm-dod-lib.shaddsfm_base_branch_valid, which rejects invalid branch names,local-onlymode and non-noneforges such as Gerrit. It also addsfm_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 everyno-mistakes axi run.base_branch=from task meta.fm-review-diff.shdiffs againstorigin/<base>, and the content-landed check infm-teardown.shuses origin's copy of the base branch.fm-promote.shkeeps a scout's base in the ship contract and refuses a mode that can't carry it.AGENTS.md,docs/architecture.mdand 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 SetupBase branch:line and targets the base in the Rule 1, direct-PR--base, and no-mistakes--base-branchtext. 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 recordbase_branch=. A spawn without the flag still starts from origin/main with nobase_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'streehouse getcreated 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 finaltreehouse returnfailed 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.Evidence: fm-brief.sh transcript (success and refusals)
Source: fm-brief.sh transcript (success and refusals)
Evidence: Generated direct-PR brief with base
Source: Generated direct-PR brief with base
Evidence: Generated no-mistakes brief with base
Source: Generated no-mistakes brief with base
Evidence: No-base briefs identical to base commit
Source: No-base briefs identical to base commit
Evidence: Live spawn successes (scout, direct-PR ship, matching decoy)
Source: Live spawn successes (scout, direct-PR ship, matching decoy)
Evidence: Live spawn refusals
Source: Live spawn refusals
Evidence: Scout copy starts at origin/feature/hub
Source: Scout copy starts at origin/feature/hub
Evidence: Ship copy starts at origin/feature/hub
Source: Ship copy starts at origin/feature/hub
Evidence: No-base control spawn at origin/main, no base_branch meta
Source: No-base control spawn at origin/main, no base_branch meta
Evidence: Review diff against origin/feature/hub
Source: Review diff against origin/feature/hub
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# Setupline (fm_brief_task_content_valid does not reject top-level headings), so a pasted ticket or doc with a# SetupH1 breaks the parse in two ways. (1) If noBase branch:line follows it before the next#heading, awk hitsexitat the scaffold's own# Setupand never reads the realBase branch: <b>line. The spawn then silently starts from origin's default branch, records no base_branch=, and the worker still opens its PR against<b>as the brief tells it. That is exactly the wrong-code start this change is meant to close. (2) If aBase branch: xline 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 acceptBase branch:only as the line right after the scaffold's fixedYou are in a disposable git worktree ... clean copy of its base branch.line, or skip the# Tasksection before looking for# Setup. Add a regression case where the intent contains a# Setupline. 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# Setupline (fm_brief_task_content_valid does not reject top-level headings), so a pasted ticket or doc with a# SetupH1 breaks the parse in two ways. (1) If noBase branch:line follows it before the next#heading, awk hitsexitat the scaffold's own# Setupand never reads the realBase branch: <b>line. The spawn then silently starts from origin's default branch, records no base_branch=, and the worker still opens its PR against<b>as the brief tells it. That is exactly the wrong-code start this change is meant to close. (2) If aBase branch: xline 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 acceptBase branch:only as the line right after the scaffold's fixedYou are in a disposable git worktree ... clean copy of its base branch.line, or skip the# Tasksection before looking for# Setup. Add a regression case where the intent contains a# Setupline. 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 lastBase 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# Taskand 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 byBase 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: 'aBase 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 clearsbasewhen 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.
bin/fm-dod-lib.sh:220- The direct-PR Definition of done with a base branch now reads 'open a PR withgh-axiagainst the base branchfeature/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.fm-brief.sh hub-dpr|hub-nm demo --mode direct-PR|no-mistakes --base-branch feature/hubandfm-brief.sh hub-scout demo --scout --base-branch feature/hubin the lab home (checked the Setup line, Rule 1, the direct-PR--base, and the no-mistakes--base-branchinstruction)fm-brief.shrefusals: local-only,--forge gerrit,bad..name,-x, and--secondmateeach combined with --base-branchNo-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 pathLivefm-spawn.sh hub-scout <proj> --scout --base-branch feature/hub --harness claudeon 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 commitLivefm-spawn.sh hub-dpr <proj> --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/hubControl spawnfm-spawn.sh plain <proj> --mode direct-PR --yolo off(no flag): copy at origin/main, no base_branch= in metaSpawn refusals: flag without brief line, brief line without flag, mismatchingBase branch: release/decoyin Captain's intent, --secondmate with flag, local-only with flag, origin lacking feature/missing; no meta published for any of themMatching decoyBase branch: feature/hubin Captain's intent plus the flag spawns successfullyfm-spawn.sh hub-dpr --relaunch --base-branch otherrefused;fm-control.sh hub-dpr relaunch --note-file ...relaunched with base_branch=feature/hub keptfm-review-diff.sh hub-dpr --statafter origin/main advanced: diff base origin/feature/hub, only work.txt; controlfm-review-diff.sh plain --statuses origin/mainfm-teardown.sh hub-dprbefore 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-onlyrefused because of the recorded base;--mode direct-PRsucceeds, keeps base_branch=, and the ship instructions name feature/hub for checkout, Rule 1, and--base feature/hubLab 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.