feat: bootstrap scaffold sync base from Cella-Base trailer with tree-similarity fallback#4
Merged
Merged
Conversation
…similarity fallback A fresh create-cella scaffold shares no git history with upstream, so the first sync had no merge-base and failed unless the user manually seeded refs/cella/last-sync. ensureSyncBase now resolves the base from ordered sources where the first commit that actually exists after the upstream fetch wins: 1. refs/cella/last-sync (sync-point record, unchanged) 2. cella.manifest.json committed at HEAD, then the worktree copy 3. the root commit's `Cella-Base: <sha>` trailer stamped by create-cella 4. tree-similarity inference: score the root snapshot against recent upstream commits with diff-tree and take the closest match, guarded by a confidence threshold The trailer travels with push/clone (unlike a local ref) and needs no worktree file; inference reseeds scaffolds whose trailer is absent or stale (local-template scaffolds, amended root commits, upstream history squashes). A stale recorded base now falls through to the next source instead of hard-failing. Replaces the never-read `.cella/base` file that create-cella used to write. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
A fresh create-cella scaffold shares no git history with upstream, so the first
cella synchad no merge-base and failed with "no common ancestor" unless the user manually seededrefs/cella/last-sync. The old mechanism for this — a committed.cella/basefile written by create-cella — was never read by this CLI.ensureSyncBasenow resolves the bootstrap base with one uniform rule: try each source in order; the first one whose commit actually exists after the upstream fetch wins.refs/cella/last-sync(sync-point record, unchanged)cella.manifest.jsoncommitted at HEAD, then the worktree copyCella-Base: <sha>trailer, stamped by create-cella (see companion PR feat: stamp scaffold provenance as a Cella-Base trailer, drop .cella/base create-cella#12)diff-tree --name-only, up to 400 candidates no newer than the root commit) and take the closest match, rejected when >30% of paths differThe trailer travels with push/clone (unlike a local ref) and needs no worktree file. Inference reseeds scaffolds whose trailer is absent or stale: local-template scaffolds, amended/squashed root commits, upstream history rewrites. Whichever source wins is persisted (ref immediately, manifest on the first applied sync), so this runs at most once per fork lifetime.
Behavior change: a recorded base that is missing after the fetch (stale manifest, foreign upstream) now falls through to the next source instead of hard-failing.
Tests
tests/e2e/ensure-sync-base.test.tsbuilds scaffold-shaped fixture repos (snapshot + template-cleaner-style edits + unrelated history) and covers: exact inference with newer upstream commits and fork-local work present, tie-breaking toward the newest candidate, trailer priority over inference, fall-through on a bogus trailer SHA, and rejection of a non-scaffold repo.🤖 Generated with Claude Code