Skip to content

Conversation

@zxch3n
Copy link
Member

@zxch3n zxch3n commented Jan 11, 2026

Add detailed documentation for Loro's binary encoding format including:

  • Overall binary structure with header format
  • FastSnapshot and FastUpdates body formats
  • KV Store (SSTable) encoding details
  • OpLog and State encoding schemas
  • Change Block structure and layout
  • Value encoding types and tags
  • Compression techniques (LEB128, RLE, Delta, LZ4)

Mark incomplete sections with checkboxes for future expansion.
This enables developers to implement Loro-compatible encoders/decoders
in other programming languages.

Add detailed specifications for components critical to pure JavaScript implementations:

- encoding-xxhash32.md: Complete xxHash32 algorithm with JS code and test vectors
- encoding-lz4.md: LZ4 Frame format specification with decompression algorithm
- encoding-container-states.md: Container state snapshot formats for Map, List,
  Text (Richtext), Tree, and MovableList containers

Update encoding.md with:
- Links to supplementary documentation in table of contents
- Cross-references in relevant sections (checksum, state encoding, compression)
- New "Supplementary Documentation" section
- Extended implementation checklist with container state items
Address two critical documentation gaps:

1. ContainerType postcard serde mapping:
   - Document that postcard serialization uses a DIFFERENT historical mapping
     than ContainerID.to_bytes() (e.g., Text=0 vs Text=2)
   - This affects Option<ContainerID> decoding in ContainerWrapper.parent
   - Added comparison table in both encoding.md and encoding-container-states.md

2. Op prop field semantics:
   - Document how the `prop` column value is computed per container/op type
   - List/Text: position for Insert/Delete, start for StyleStart
   - MovableList: position for Insert/Delete, target for Move
   - Map: key index into keys arena
   - Tree: always 0

These were blocking issues for implementing a complete decoder.
@zxch3n zxch3n changed the base branch from main to claude/analyze-lorodoc-encoding-ulfBB January 11, 2026 04:23
@github-actions
Copy link
Contributor

WASM Size Report

  • Original size: 3186.38 KB
  • Gzipped size: 1006.76 KB
  • Brotli size: 699.37 KB

@zxch3n zxch3n merged commit 79b3757 into claude/analyze-lorodoc-encoding-ulfBB Jan 11, 2026
1 check passed
@zxch3n zxch3n deleted the claude/review-pure-js-encoder-decoder-iCZLv branch January 11, 2026 04:25
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a795a48fbf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +136 to +137
// Empty with LORO seed
xxHash32(new Uint8Array([]), LORO_SEED) === 0x30CFEAB0 // 819588784

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct LORO-seed xxHash32 test vectors

The LORO-seed vectors listed here don’t match the algorithm defined just above (and the xxHash32 implementation used by Loro). If you run the provided JS algorithm with LORO_SEED = 0x4F524F4C, the empty-input hash comes out as 0xDC3BF95A, not 0x30CFEAB0 (and the other LORO-seed vectors in this block are similarly off). This inconsistency will cause implementers to think their encoder/decoder is wrong even when it matches Loro’s checksum behavior.

Useful? React with 👍 / 👎.

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.

3 participants