Repository navigation
feat(bin): opt-in spawn base from the primary checkout for local-only work - #7352
Conversation
…ndings A fresh pooled task worktree is reset to origin/<default>. A local-only project lands work on the primary checkout's default branch through fm-merge-local.sh and never pushes, so that ref stays frozen at the last push and every fresh task starts behind work already landed, loading the project's instruction files from the stale tree. The always-on fix proposed in kunchenguid#3812 replaced the specified origin-only refresh for every home; this rework keeps that rule as the default and moves the new base behind an explicit, default-off presence flag, following the existing config/<flag> pattern. With config/spawn-base-primary-checkout present: - fm-spawn.sh starts a fresh local-only ship, or a scout without --base-branch, from the primary checkout's <default> when it strictly contains origin's tip. Publishing modes and named base branches keep origin's tip, because that work is delivered against origin. A diverged primary keeps origin's tip and prints a note counting both sides. The commit is read from the local object store, so nothing extra is fetched, and the clean-slot refusal still runs first. - fm-review-diff.sh anchors a remote-backed task without base_branch= on the branch it delivers to: publishing modes stay on origin/<default>, while a local-only ship or a scout is compared against whichever of the local <default> and origin/<default> meets the branch later, so the review shows the task's own work instead of every locally landed commit. - fm-promote.sh tells a scout promoted to a publishing mode to return to origin's default branch, because in this home the scout may have started from the primary checkout's branch, whose unpushed commits would otherwise be published with the work. fm-dod-lib.sh gains fm_mode_publishes as the one predicate those three readers share. Without the flag every path is unchanged: the spawn resets to origin's tip, the review anchors on origin/<default>, and promotion keeps its wording; the existing tests run unmodified. Treehouse 3 (verified on 3.1.3) already hands a slot out at whichever of the local and remote default branch is further ahead, so with the flag the refresh keeps that slot where Treehouse put it for a local landing instead of rewinding it, and a project without origin is untouched as before. Supersedes kunchenguid#3812.
|
Speaking as Kun's firstmate: thank you @mikeastwoody! Letting a local-landing home start fresh local-only ships and scouts from the work it has already landed, without letting unpushed commits leak into anything that publishes, is a thoughtful change. Contract-class: opt-in (my own read of the tip vs main). Every new branch in VISION: one-interface / authority (an explicit per-home flag the captain creates, with safe fallbacks) / scripts (a deterministic ancestry check) / restart (no new state) / spine (publishing work stays anchored on origin) / vendor / scope: all align. Live: go, 9 of 10. The one untested scenario, worker boot, was blocked only by Codex's own folder-trust prompt. The base and review behavior it would have shown is covered by the slot HEAD and AGENTS.md evidence. CI: I approved the first-time fork CI and Require no-mistakes runs after the diff review (scripts, docs and tests only, no workflow changes). If they come back green and the PR is still mergeable, this can go in on the opt-in path. |
Resolve two add/add conflicts where main and this branch each appended a new config flag at the same place: the config listing in the operational-home-layout skill and the flag sections in docs/configuration.md. Both sides are kept, main's wedge flags first and config/spawn-base-primary-checkout after them.
|
Speaking as Kun's firstmate: Thank you @mikeastwoody for bringing this up to date with What changed since my 2026-10-15 stamp: the head is now Where it stands:
Once the attestation matches and CI is green, this is an opt-in auto-merge candidate. |
Resolve three conflicts with main: - The config listing in the operational-home-layout skill and the flag sections in docs/configuration.md, where main and this branch each appended a new config flag at the same place. Both sides are kept, main's entries first and config/spawn-base-primary-checkout after them. - freshen_spawn_worktree_base in bin/fm-spawn.sh, where main now returns 2 for a slot that is not clean and skips the shared call for the T3 Code backend. The function keeps main's return codes and this branch's <project> <mode> arguments, and the shared call keeps main's t3code exclusion with this branch's arguments. Main's new T3 Code spawn path calls freshen_spawn_worktree_base on its leased slot, so that call now passes the same <project> <mode> arguments. Without them an opted-in home would keep origin's tip for a T3 Code local-only ship or scout, unlike every other backend.
[Medium impact] The PR appears safe to merge; both previous findings are addressed. Reviews (2) · Last reviewed commit: "no-mistakes(ci): The Greptile Review che..." · Reviewed by Greptile |
…ngs, not on a broken build or test. I fixed both as the user directed, and the tests and lint pass. ci-1 (bin/fm-promote.sh): promotion must name origin's default branch only when spawn could actually have started the scout from the primary checkout. Spawn does that only when the project has an origin remote and is recorded on the task. Before this fix, the opt-in flag alone made promotion to no-mistakes or direct-PR say "copy of origin's default branch...", even on a project with no origin. - The new wording now also requires a recorded project (`[ -n "$PROMOTE_PROJECT" ]`) whose `git remote get-url origin` succeeds. That is the same check bin/fm-review-diff.sh already makes. The empty-project guard is needed because `git -C ""` would run in the current directory. Otherwise the existing "default-branch base" wording stays. - The three places that read the flag now agree: spawn, review-diff and promote. - I updated the header and inline comments in fm-promote.sh, and the promote line in docs/configuration.md, to say this applies only to a project with an origin remote. - Test: `test_promote_names_origin_for_a_publishing_mode_in_an_opted_in_home` in tests/fm-task-delivery.test.sh now records a real `project=` with a registry entry, and covers flag on/off × origin/none × direct-PR/no-mistakes/local-only. Only flag on + origin + a publishing mode gets the new wording. The named-base case is unchanged. - Before the fix, the test fails with "not ok - flag on, remote none, direct-PR: the promotion changed the default-branch wording". With the fix, it passes. ci-2 (tests/fm-spawn-pool-base-freshen.test.sh): with the flag set, both publishing modes must start from origin's tip and print no divergence note. - The opted-in spawn test now covers no-mistakes as well as direct-PR, local-only and scout. - The expectations no longer single out direct-PR. Both publishing modes now expect origin's tip, no "note: pooled worktree", and a review anchored at the slot's start, in the leading, diverged and trailing cases. Verification: - `bash tests/fm-task-delivery.test.sh`: exit 0. - `bash tests/fm-spawn-pool-base-freshen.test.sh`: exit 0. - `bin/fm-lint.sh` on the three changed shell files: exit 0 (ShellCheck 0.11.0, pinned, with extended analysis)
|
Speaking as Kun's firstmate: thank you @mikeastwoody for re-raising this through no-mistakes and fixing both Greptile findings. What changed since my 2026-10-21 stamp: the head is now Where it stands:
Nothing is needed from you right now. This is waiting on CI. If it goes green on this head and stays mergeable, it can land as opt-in on a later pass. |
|
Speaking as Kun's firstmate: this is merged. Thank you @mikeastwoody — really appreciate you taking the time on this. It landed as opt-in (nothing changes unless a home creates |
Supersedes #3812
This supersedes #3812, which made every home start a fresh local-only ship or scout worktree from the primary checkout's default branch.
The triage on #3812 classified that as a
new-defaultcontract change: it replaced the specified, test-covered rule that a fresh pooled slot resets toorigin/<default>without an opt-in gate, which does not fit the principle that authority is explicit and never inferred.This version keeps that rule as the default and moves the new base behind the explicit, default-off
config/spawn-base-primary-checkoutpresence flag, following the existingconfig/<flag>pattern.With the flag absent, spawn, review, and promotion follow exactly the old paths, and the existing tests run unmodified.
Compared with #3812, the review anchor and the shared mode predicate sit behind the same flag, the promotion wording is new, and the always-on behind-count notes are dropped.
The problem it addresses: on a local-only project,
origin/<default>stays at the last push while work lands on the primary checkout's default branch throughbin/fm-merge-local.sh, so fresh tasks started hundreds of commits behind (400 to 854 commits, as measured in #3812) and loaded the project's instruction files from that stale tree.What Changed
bin/fm-spawn.sh: adds an off-by-defaultconfig/spawn-base-primary-checkoutflag. When a home sets it, a fresh local-only ship, or a scout spawned without--base-branch, resets its pooled worktree to the primary checkout's<default>if that branch strictly contains origin's tip. The commit is read from the shared object store, so nothing extra is fetched. Publishing modes (no-mistakes, direct-PR) and named base branches keep origin's tip, and if the two branches have diverged the spawn prints a note with both counts and also uses origin's tip. A new shared helper,fm_mode_publishesinbin/fm-dod-lib.sh, decides which modes publish.bin/fm-review-diff.sh: when the flag is set, a remote-backed local-only ship or scout with no recorded base is reviewed against whichever of the local<default>andorigin/<default>has the later merge base with the branch. If both merge bases are the same, or they are unrelated, it uses the local<default>. It prints notes when the local<default>already contains the branch and when the merge bases are unrelated. Publishing modes still review againstorigin/<default>.bin/fm-promote.sh: when the flag is set and a scout without a named base is promoted to a publishing mode, the scout is now told to start again from a copy of origin's default branch instead of the primary checkout's. The flag is documented indocs/configuration.md,docs/architecture.mdand the operational-home-layout skill. New tests cover the spawn base, the review anchor and the promotion wording.Risk Assessment
✅ Low: Every new path sits behind a default-off presence flag. Without it, spawn, review and promotion behave byte-for-byte as before. With it, the base and anchor rules were traced through the leading, trailing, diverged, rebased, landed and named-base cases and gave the correct base each time, and the merge with current main is clean.
Testing
I built a disposable lab home with a private tmux server, a treehouse pool inside the lab, a throwaway project with a lab-private origin, and real Claude Code workers. A real worker plusfm-merge-local.shlanded a CLAUDE.md change locally, leaving origin one commit behind; this is the state the change targets. I then ran the realfm-spawn.sh,fm-review-diff.shandfm-promote.shwith the flag absent and present. Without the flag, a local-only ship and a scout still start at origin's tip and their workers boot with STALE-ORIGIN-v1. With the flag, a local-only ship and a scout start at the primary's main and their workers boot with FRESH-LOCAL-v2. No-mistakes and direct-PR ships, a named base branch, and a diverged primary all keep origin's tip; the diverged case prints a note counting both sides. With the flag, review anchors on local main for local-only work and on origin/main for no-mistakes work, so each diff shows only the task's own file. With the flag, promoting a scout to no-mistakes tells the worker to return to origin's default branch; without the flag, and for a named base, the original wording is unchanged. All 14 live scenarios passed, the lab was fully torn down, and the three targeted suites (spawn-pool-base-freshen, review-diff, task-delivery) passed. This is a CLI-only change, so the evidence is transcripts and worker pane captures rather than screenshots.feature/hub'Evidence: Live lab transcript: spawn, review and promote with the flag on and off, plus worker boot panes
Source: Live lab transcript: spawn, review and promote with the flag on and off, plus worker boot panes
Evidence: Lab driver: brief and backlog scaffolding
Source: Lab driver: brief and backlog scaffolding
Evidence: Lab driver: real fm-spawn.sh invocation and base facts
Source: Lab driver: real fm-spawn.sh invocation and base facts
Evidence: Worker boot markers per task
Evidence: Review anchor with and without the flag
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
feature/hub'Lab setup:bin/fm-lab-home.sh createplus a private tmux server, withTREEHOUSE_ROOTand a throwaway projectdemo(lab-private bare origin) inside the lab; Claude Code workers ran on sonnet at low effortSetup landing: thelab-landworker edited CLAUDE.md, thenFM_HOME=$LAB bin/fm-merge-local.sh lab-landmoved local main from e4566b5 to c73bf9f while origin stayed at e4566b5S1:bin/fm-spawn.sh lab-default demo --mode local-only --yolo onwith no flagS1b:bin/fm-spawn.sh lab-scout2 demo --scoutwith no flagS2:touch config/spawn-base-primary-checkout, thenbin/fm-spawn.sh lab-optin demo --mode local-only --yolo onS3:bin/fm-spawn.sh lab-scout demo --scoutwith the flagS4:bin/fm-spawn.sh lab-nm demo --mode no-mistakes --yolo offandbin/fm-spawn.sh lab-dpr demo --mode direct-PR --yolo offwith the flagS5: forge-only commit pushed to origin, thenbin/fm-spawn.sh lab-div demo --mode local-only --yolo onwith the flagS6: origin/feature/hub plus a local feature/hub one commit ahead, thenbin/fm-spawn.sh lab-base demo --scout --base-branch feature/hubwith the flagEach probe worker was asked, without reading any file, which CLAUDE.md marker it loaded at boot (read from its status line and pane)R1/R2/R4:bin/fm-review-diff.sh lab-optin|lab-nm|lab-default --statwith the flag, after each task committed its own fileR3:bin/fm-review-diff.sh lab-optin --statwith the flag temporarily removedP1:bin/fm-promote.sh lab-scout --mode no-mistakes --yolo offwith the flagP2:bin/fm-promote.sh lab-scout2 --mode no-mistakes --yolo offwithout the flagP3:bin/fm-promote.sh lab-base --mode no-mistakes --yolo offwith the flag, named baseTeardown: lab tmux kill-server; checked no lab processes survived; removed the lab's /tmp/fm-<id> task temp dirs and the 10 lab project entries in ~/.claude.json (atomic replace, same method asfm-live-lab.sh down);fm-lab-home.sh teardown; rm -rf the lab root; checked ~/.treehouse was unchanged and the worktree was cleanbash tests/fm-spawn-pool-base-freshen.test.sh(exit 0)bash tests/fm-review-diff.test.sh(exit 0)bash tests/fm-task-delivery.test.sh(exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.