git_seed export: keep the Mac's base record while newer exports replace refs/cmux-back

Merged
TE
4d ago
+101-8

Fixes #31014, a review follow-up from #30923.

Leo's words, for the Cloud project seed this belongs to:

Your project folder is copied up.
we'll want to deal with the edge cases for this too

The problem

git.seed.export records refs/cmux-back/* before the Mac has merged anything. When the pull then conflicts, the Mac stays on its older base, but on the machine that base was referenced only by the refs/cmux-back/* the export just replaced. That causes three problems:

  • gc could prune the old base's INDEX and WORK commits, which a retried bundle needs as prerequisites;
  • the stash comparison no longer found the old base's record;
  • a delta seed from the old base no longer matched any record.

The fix

When an export replaces the back record the Mac is on (its since), that record moves to refs/cmux-base/*. The machine keeps only the Mac's base and the newest export:

  • a since that is already refs/cmux-base leaves it alone;
  • a since that is the seed itself clears refs/cmux-base.

git.seed.export's stash comparison and git.seed.start's delta check both now accept refs/cmux-back, refs/cmux-base and refs/cmux-seed, newest first. The bundle's refs, and so the Mac side, are unchanged.

Tests

a_retry_after_a_conflict_still_has_the_macs_base:

  1. Merge one export, then make two exports the Mac could not merge.
  2. refs/cmux-base/work is still the Mac's base.
  3. Run reflog expire and gc --prune=now; the base's commits are still there.
  4. An export from the base, with the files back as they were, is unchanged against that record.

On cmux-ci: git_seed 38 passed, cargo fmt is clean and clippy reports nothing in git_seed.

Risk: small and limited to the machine-side record refs. Nothing on the wire changes.

Agent session: agent session

šŸ¤– Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes #31014: git.seed.export now keeps the Mac's base record (refs/cmux-base/*) when a newer export replaces the refs/cmux-back record that a conflicted Mac is still on, so gc no longer prunes that base's commits and retries still find it.

Bug Fixes

  • When an export replaces the back record the Mac hasn't merged, that record moves to refs/cmux-base/*; only the Mac's base and the newest export are kept.
  • The stash comparison and delta seed now accept refs/cmux-back, refs/cmux-base, and refs/cmux-seed.
  • Nothing on the wire changes; the bundle's refs are unaffected.