Skip to content

fix: enforce shallow snapshot concurrency boundaries - #1090

Merged
zxch3n merged 2 commits into
mainfrom
test/shallow-snapshot-concurrency
Sep 6, 2026
Merged

zxch3n merged 2 commits into
mainfrom
test/shallow-snapshot-concurrency

Conversation

@zxch3n

@zxch3n zxch3n commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Problem and behavior

A shallow replica must reject updates rooted before its retained history without corrupting the document or leaving those updates pending. An update exactly concurrent with the root frontier previously escaped the boundary check: its deps equal the root's own deps, so a version-vector shortcut classified it as acceptable even though the dependency ids were already trimmed. Import then panicked while resolving its Lamport timestamp.

Reject that boundary explicitly with ImportUpdatesThatDependsOnOutdatedVersion. The rejected update never enters pending storage, and later valid post-root imports still work. The fix and the concurrency contract now land together, independently of #1091's export optimization.

Stacked on #1087; #1091 follows this PR.

Contracts and tests

Seven public tests in crates/loro/tests/shallow_snapshot_concurrency.rs cover:

  • Faithful bootstrap and repeated already-included history as a no-op.
  • Causally post-root updates merging normally.
  • Pre-root forks, including the exact root-dependency boundary, being rejected.
  • Post-root missing dependencies pending until delivery.
  • Shallow edits merging back into full-history peers without trimming their history.
  • A pre-root concurrent chain whose genesis is rejected and whose later changes cannot resolve.

DAG and internal import tests additionally assert the exact boundary and that rejected changes are dropped rather than queued. The public boundary regression also verifies subsequent valid imports after rejection. All fixtures use fixed peers and explicit changes, without timing dependencies.

docs/shallow-snapshot-concurrency.md documents these guarantees and their limits: shallow snapshots cannot preserve arbitrary offline forks that diverged before the root. A non-empty target consumes retained changes rather than adopting the snapshot's state sections.

Validation

  • Public concurrency suite: 7 passed.
  • Exact-dependency and dropped-not-pending internal regressions pass.
  • Original boundary reproducer aborted on a0e34943; the corrected path returns the expected error and preserves the document.
  • Changeset included; git diff --check passed.

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 3145.29 KB
  • Gzipped size: 1041.32 KB
  • Brotli size: 730.52 KB

@zxch3n
zxch3n force-pushed the test/shallow-snapshot-concurrency branch from 5a3846b to e905696 Compare September 4, 2026 04:17
@zxch3n
zxch3n changed the base branch from main to feat/wasm-json-text-export September 4, 2026 04:18
@zxch3n
zxch3n force-pushed the test/shallow-snapshot-concurrency branch from e905696 to 3a5f6bb Compare September 4, 2026 11:22
@zxch3n
zxch3n force-pushed the test/shallow-snapshot-concurrency branch from 3a5f6bb to 0303fa7 Compare September 4, 2026 12:17
@zxch3n
zxch3n force-pushed the test/shallow-snapshot-concurrency branch from 0303fa7 to 2240dd2 Compare September 4, 2026 16:38
@zxch3n
zxch3n force-pushed the test/shallow-snapshot-concurrency branch from 2240dd2 to a0e3494 Compare September 5, 2026 05:15
@zxch3n zxch3n changed the title test: pin down shallow snapshot merge semantics with concurrent peers fix: enforce shallow snapshot concurrency boundaries Sep 5, 2026
Base automatically changed from feat/wasm-json-text-export to main September 6, 2026 05:27
Backport the dependency-boundary fix from PR #1091 so the guarantees and tests in PR #1090 hold independently. Verify that valid post-root imports still succeed after rejection.

Model: gpt-6
@zxch3n
zxch3n force-pushed the test/shallow-snapshot-concurrency branch from 7c3d66b to 23c6271 Compare September 6, 2026 05:27
@zxch3n
zxch3n merged commit 7d26c7e into main Sep 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant