Conversation
Stop the pairwise reduction when no common ancestor remains. Cover independent and shared histories and retain a boundary-aware import regression. Fixes loro-dev#1095 Agent: codex-1
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.
Fixes #1095.
A shallow snapshot exported from a version with three, five, or seven independent heads can fail to import into an empty document with
SwitchToVersionBeforeShallowRoot.The shallow-root calculation reduces frontier heads in pairs. An empty common-ancestor result was represented by adding no IDs to the next round; an odd, unpaired head could then survive and become a root that was not common to the requested version. Returning immediately on an empty result preserves it through the reduction, while retaining the existing clamp for already-shallow documents. Snapshot formats and import guards are unchanged.
Tests cover 1–12 independent heads, shared and partially shared histories, imported state and version metadata, synchronization after import, and rejection of unavailable history. The existing boundary-import regression also now uses a valid shallow root and a JSON update with explicit boundary-plus-retained dependencies, instead of relying on the incorrect root selection. It verifies the applied state and detects use of the wrong import guard. A patch changeset is included.
Validation
ImportUpdatesThatDependsOnOutdatedVersionwhen the import preflight uses the checkout guard, and passes after restoring the intended guard.loroandloro-internalsuites passed (549 and 526 tests respectively). Release WASM build/package checks passed: 373 Vitest tests, TypeScript, CommonJS smoke, 4 Deno tests, and 4 Bun tests. Production logic has not changed since those runs.git diff --checkpasses.Repository-wide formatting and Clippy have unrelated failures on the unmodified base with local Rust 1.98 (formatting differences and existing
generic-btreediagnostics). The full native suites used the standard Cargo test harness because cargo-nextest was unavailable. WASM package tests used a temporary empty PostCSS configuration to avoid an unrelated parent-directory configuration. None of those local workarounds or unrelated changes is included.