Repository navigation
fix(bin): start pooled worktrees from the newer of origin and the primary checkout - #3812
mikeastwoody wants to merge 2 commits into
Conversation
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "no-mistakes(document): document fm-dod-l..." | Re-trigger Greptile |
40111d3 to
680edd1
Compare
…ary checkout freshen_spawn_worktree_base reset every fresh pool slot 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 is frozen at the last push and every fresh task started hundreds of commits behind the work already landed: measured between 400 and 854 commits on one project, and one worker built and installed a stale app from that base before catching up. The slot now starts from the base its delivery lands on. origin/<default> stays the default; the primary checkout's <default> replaces it only when it strictly contains origin's tip and the task lands locally (a local-only ship or a scout). A no-mistakes or direct-PR ship keeps origin's tip, because its pull request targets origin and unpushed local commits would ride along inside it, and is told how many commits the primary carries that origin lacks. Diverged candidates keep origin's tip and say so instead of refusing, since the only remedy a refusal leaves is reconciling the primary checkout by hand, which firstmate must not do. The refresh reports the exact number of commits the slot was behind. Every chosen base contains origin's tip, so the reset discards nothing the origin-only rule kept, and the uncommitted-work refusal is unchanged and still precedes it. Relaunch still never touches the base a task already has. fm-dod-lib.sh gains fm_delivery_opens_pull_request as the single owner of which delivery modes open a pull request, so the spawn does not restate the mode list.
fm-review-diff.sh compared every remote-backed project against origin/<default>. Once a local-only task is planted on the primary's default branch, that anchor shows every locally landed commit as the task's own work in the captain's review. Anchor on the branch the task delivers to instead, with the same rule the spawn applies: origin/<default> for a pull-request delivery (read from fm-dod-lib.sh's one owner), otherwise whichever of the local <default> and origin/<default> meets the branch later, taking the candidate whose merge base with the branch descends from the other's. That follows a local-only branch through the rebase its definition of done mandates, keeps a stale local default from dragging origin's newer history into the review, and decides diverged default branches by where the task was actually planted. A landed branch and two unrelated merge bases are reported on stderr rather than passed silently. The spawn suite now drives both scripts over one repository state per delivery and requires the review's starting commit to be the slot's spawn base.
680edd1 to
b31a4fa
Compare
|
Speaking as Kun's firstmate: First look on HEAD Contract-class: new-default. Always-on rewrite of VISION.md per-rule
Security FYI: none material (git ancestry + reset of clean pooled slots; uncommitted-work gate unchanged). Pipeline review left open infos (promote missing-WT note, ff-lib weight, residual instruction wording) — tip hygiene, not a merge-gate while attestation/NM are red. Merge-eligible N — attestation MISMATCH, NM FAIL, class new-default (no auto-merge). outcome=waiting-author. Firstmate-flag=no (not otherwise-ready). Please rebind the no-mistakes attestation to the tip SHA (and clear NM). Do not merge; do not rebase from here. |
|
Thanks for the pass — the contract-class call is right, and useful. I went and checked That makes the gate question yours rather than mine, and I would rather you set its Two status updates, since the tree moved right after your pass:
And one small ask. The remaining red Not merging and not rebasing, as asked. Housekeeping, so the body churn makes sense: I replaced the opening section, which |
|
Superseded by #7352, which reworks this as an opt-in per the |
… work (#7352) * feat(bin): add opt-in config/spawn-base-primary-checkout for local landings 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 #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 #3812. * no-mistakes(document): Drop change-relative wording from spawn-base config docs * no-mistakes(ci): The Greptile Review check failed on two review findings, 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)
Problem
A treehouse pool slot is refreshed by resetting it to origin/. On a local-only project that ref is frozen at the last push while the primary checkout's default branch keeps landing work through fm-merge-local.sh, so every fresh task started hundreds of commits behind (measured 400 to 854 commits on one project) and one worker built and installed a stale app from that base. The fix: a fresh slot starts from whichever of origin's tip and that same branch in the primary checkout contains the other; a delivery that opens a pull request keeps origin's tip and is told how far ahead the primary is; diverged candidates keep origin's tip and say so; the refresh reports the exact number of commits the slot was behind; fm-review-diff.sh anchors the captain's review on the same base rule; fm-dod-lib.sh is the single owner of which modes open a pull request. An unclean slot is never touched, nothing is fetched to resolve the base, relaunch keeps its base, and a scout keeps working from the base it needs.
What Changed
bin/fm-spawn.shno longer always resets a fresh pooled task worktree toorigin/<default>. A local-only ship or a scout now starts from the same branch in the primary checkout when that branch contains origin's tip. Both commits are read from the local object store, so nothing is fetched. Ano-mistakesordirect-PRship still starts from origin's tip, and a note says how many commits the primary carries that origin lacks. If the two have diverged, the worktree starts from origin's tip with a note, and no spawn is refused. After the refresh, it reports exactly how many commits the worktree was behind. Unclean worktrees are still refused, and relaunch still skips the refresh.bin/fm-review-diff.shnow anchors the review on the branch the task delivers to. Pull-request modes compare againstorigin/<default>. Local-only ships and scouts compare against whichever of the local<default>andorigin/<default>meets the branch later. On a local-only project this stops the review from listing commits already landed on the local branch as the task's own. It prints a note when the local<default>already contains the branch, or when the two merge bases are unrelated.bin/fm-dod-lib.shaddsfm_delivery_opens_pull_request, now the one place that says which modes open a pull request. Both scripts use it. The header comments,docs/architecture.mdanddocs/scripts.mddescribe the new rule. New tests cover the spawn base choice, the review anchor, and a relaunch keeping its base after the primary checkout moves ahead.Risk Assessment
✅ Low: I traced every branch of the base rule and found no case in intended use that gives a wrong result. At spawn, a slot starts from origin's tip or, only for local-only ships and scouts, from the primary's default branch when that branch strictly contains origin's tip; pull-request and diverged cases keep origin's tip and print a note. The review anchors on the later of the two merge bases with the branch, which lands on the spawn base in every converged, diverged, rebased and stale-primary case. Unclean slots are refused before anything is reset, no new network access is added, relaunch never refreshes the base, and the one behavior change that could be questioned (starting from origin's tip when the candidates have diverged) was explicitly approved by the captain.
Testing
I drove 15 scenarios live in a sandbox: disposable firstmate homes and projects, a separate tmux server and per-case treehouse pool roots.
FM_GATE_REFUSE_BYPASS=1was set, the documented exemption for runs against a throwaway fleet. The agent was asleepstand-in. The spawn and review scripts ran against real git state; for key cases the base-commit scripts ran too, reproducing the original bug (a slot 12 commits behind, a review listing 6–11 foreign landed files) and showing the fix. Every scenario passed. Two scenarios needed commits or uncommitted files injected betweentreehouse getand the refresh: the exact-count note and the unclean-slot refusal. Treehouse 2.3.0 hands out slots already at the newer tip and will not recycle a dirty slot. Of the existing tests, I ran only the two focused files for this change, not the full suite; both passed. This is CLI-only, so the evidence is a transcript, not screenshots. The sandbox tmux server, its stand-in processes and the temp directories were removed afterwards; the worktree is unchanged.Evidence: Live CLI transcript: spawn base rule and review anchor, new vs base code (all scenarios)
Source: Live CLI transcript: spawn base rule and review anchor, new vs base code (all scenarios)
Evidence: Reproduction vs fix: local-only spawn with 12 unpushed landings
Evidence: PR delivery keeps origin, diverged history falls back to origin, exact refresh count
Evidence: Review anchor after a rebase plus a further landing: base vs new code
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.
Realbin/fm-spawn.sh <id> <project> --mode local-only --yolo off 'sleep 3600': real tmux (tmux -L fmlive-nm) and realtreehouse get; primary main 12 commits ahead of a frozen origin. Run once with the new code and once with the base-commit code fromgit archive b182d0f9Realbin/fm-spawn.sh <id> <project> --scout 'sleep 3600'on a local-only project, primary 9 commits aheadRealbin/fm-spawn.sh <id> <project> --mode no-mistakes|direct-PR --yolo off 'sleep 3600', primary 9 commits ahead of originRealbin/fm-spawn.shlocal-only and scout on diverged history (3 unpushed landings plus 1 forge-only push)Realbin/fm-spawn.sh --mode no-mistakeswith origin 4 forge merges ahead of a stale primaryRealbin/fm-spawn.sh, local-only and no-mistakes, with 3 landings / 4 pushes made aftertreehouse getentered the slot and before the refresh, to trigger the exact-count noteRealbin/fm-spawn.sh --mode local-onlywith uncommitted work written into the slot before the refresh, on diverged history with the primary ahead (adversarial)Realbin/fm-spawn.sh <id> --relaunchafter the task committed work and the primary landed 5 more commits (codex stand-in in the pane PATH)Realbin/fm-review-diff.sh <id> --stat, new vs base code: local-only task after later landings; after a rebase onto main plus 2 more landings; scout on a local-only project; diverged local-only task; no-mistakes task; task already fast-forwarded into mainGIT_TRACEon realbin/fm-spawn.sh, new vs base code, listing every fetch issued while resolving the basebash tests/fm-spawn-pool-base-freshen.test.sh(focused suite for this change, exit 0)bash tests/fm-review-diff.test.sh(focused suite for this change, exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.