Repository navigation
Conversation
… pooled base A pooled worktree was always reset to origin/<default> before launch. That is right for a project whose landed work reaches origin, and wrong for a `local-only` project: bin/fm-merge-local.sh merges approved work into the LOCAL default branch and never pushes, so origin's tip is missing work the captain has already approved. The next task then started from a base predating that merge, and its branch read as a revert of the landed work - silent, because the worker's own change was correct and the deletions hid inside its diff, and compounding, because every further local landing widened the gap. It is guaranteed rather than occasional: every `local-only` project has this shape. The base now follows where landed work actually lives, by cases: - origin is an ancestor of the local default branch (strictly ahead): use the local branch. It holds everything origin has plus the locally landed work, so nothing can be lost by starting there. This is the safe case precisely because containment is proven, not assumed. - equal: the same commit, so origin stands and behaviour is unchanged. - local behind origin: origin carries work the local branch lacks, so origin remains authoritative. - diverged, with origin not an ancestor: origin remains authoritative. A local branch that does not contain origin's tip is not something to silently build on. Everything else is untouched: origin is still fetched, origin's default branch is still resolved, a worktree with no origin still returns early, and every existing refusal - dirty worktree, stale submodule pin, unreachable origin, unresolved remote default, post-reset verification - still refuses. The preference only picks between two verified commits. fm-review-diff.sh carried the same assumption in the same shape: with an origin configured it always reviewed against origin/<default>, so a local-only branch would be reviewed against a base missing the landed work, reporting that work as part of the branch's own change. It now applies the same rule, pointing at the spawn helper as the owner of the reasoning. bin/fm-teardown.sh and bin/fm-fleet-sync.sh were checked and are not affected: teardown already tests local-only work against the local default branch, and fleet sync only fast-forwards, so a local-ahead clone is skipped rather than rewound. Tests build real git repositories rather than mocking the ancestor check, since the defect was in what git actually reported about origin and local refs.
…de; refresh origin-less pools
…qualified review base
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
freshen_spawn_worktree_baseinbin/fm-spawn.shreset every pooled worktree toorigin/<default>.That is correct for a project whose approved work reaches the remote. It is wrong for a
local-onlyproject, wherebin/fm-merge-local.shfast-forwards the local default branch and never pushes. Every subsequent spawn then hands the worker a base missing exactly the landed-but-unpushed commits, and the branch that worker produces proposes reverting them.This is not theoretical and not a race. It reproduced on the first task dispatched after the first local landing: the resulting branch would have reverted a feature that had just been approved, and the deletions were invisible inside an otherwise ordinary feature diff. It compounds — each further local merge widens the gap.
The fix
Base selection is keyed on the task's own recorded delivery mode, not on the project registry. The registry records a standing posture; whether a given piece of work lands locally is a per-task fact, and
bin/fm-merge-local.shalready gates the local landing onmode=in the task's metadata.With an origin:
mode=local-onlyandorigin/<default>is an ancestor of the local default branch → prefer the local default branch.origin/<default>stays authoritative, exactly as before.With no origin at all: the local default branch is the only possible authority, so the worktree refreshes to it in every mode. This was the one shape left unrefreshed by the original fix, and the one where local is unambiguously correct.
The refresh detaches HEAD rather than resetting in place, so it can never move a branch reference another task owns — in an origin-less repository those commits exist nowhere else. Every pre-existing refusal is preserved: a dirty worktree still refuses rather than discarding uncommitted work, and the refresh additionally refuses when no default branch can be determined rather than launching from an unverified base.
bin/fm-review-diff.shcarried the same assumption and gets the same rule, so what is reviewed matches what will actually be delivered. Without that, a PR-delivered project whose local default is ahead of origin would have the review silently under-report the diff.Known limit
An origin-less repository whose default branch is named neither
mainnormasteris not supported by the pooled base path; it refuses rather than guessing. An earlier revision resolved this from the repository's ownHEAD, which was dropped: it created a second definition of "the default branch" disagreeing withdefault_branchinbin/fm-ff-lib.sh, the one every other consumer uses — and spawn would then accept a base thatbin/fm-merge-local.shrefuses at landing time, so the task could never ship. If that support is ever wanted, it belongs indefault_branchso every consumer gains it at once.Tests
tests/fm-spawn-pool-base-freshen.test.shandtests/fm-review-diff.test.shcover local ahead, equal, behind, diverged, origin-less, and dirty, plus the mode distinction in both directions: alocal-onlytask on a no-mistakes-registered project prefers local, and a no-mistakes task on alocal-only-registered project keeps origin. They run against real git repositories rather than mocks — the original defect was in what git actually reported, and a mocked ancestor check would have passed while the real one failed.bin/fm-test-run.shroutes edits to the new library to the spawn suite; without that, an edit to the library alone would have run none of its proof.