Repository navigation
fix(loro.js): use Rust's L{lamport}@{peer} format for movable-list JSON element IDs - #1129
Merged
Merged
Conversation
…t JSON element IDs Rust rejected loro.js JSON updates containing movable-list moves or sets, and loro.js failed on Rust's. The unprefixed form is still accepted on import. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
WASM Size Report
|
This was referenced Sep 27, 2026
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
Found while porting the Rust #1125 MovableList tests to
loro.js: their forged JSON updates ("elem_id": "L1@0") could not be imported.JSON updates that contain MovableList
move/setops are not interoperable betweenloro.jsand Rust/loro-crdt:elem_idasIdLp, which isL{lamport}@{peer}(crates/loro-common/src/id.rs).loro.jswrote{lamport}@{peer}. Rust rejects that withDecodeError("Invalid ID format").loro.jsfails on Rust's form withcounter is out of range: NaN. The Rust fixtureloro-js/tests/fixtures/rust/updates.jsonalready contained such ops but was not imported by any test.Fix
exportJsonUpdatesnow writesL{lamport}@{peer}.importJsonUpdatesaccepts it and still accepts the unprefixed form thatloro.js0.2.1 and earlier wrote. Theelem_idfield type changes fromJsonOpIDto a new exportedJsonIdLp.Validation
loro-js/tests/runtime.test.ts: it imports Rust'supdates.json, checks it against the same history fromupdates.blob, and asserts every exportedelem_idmatches^L\d+@\d+$. It also checks that the legacy unprefixed JSON still imports. The test fails onmainwithcounter is out of range: NaN. Binary values are normalized in the comparison because the JSON schema stores them as number arrays, and Rust's own JSON round trip does the same.mainimportsloro.jsJSON (move + set) and reaches the same value,{"l":["b","B","a"]}. Before this change it failed to decode.pnpm --dir loro-js test(17 files, 241 tests),typecheck,lint,format:checkall pass.Related: #1125, whose tests use this format.
🤖 Generated with Claude Code