Skip to content

docs: Add commitlog reference document#4668

Merged
clockwork-labs-bot merged 7 commits intomasterfrom
bot/docs-commitlog-reference
Apr 15, 2026
Merged

docs: Add commitlog reference document#4668
clockwork-labs-bot merged 7 commits intomasterfrom
bot/docs-commitlog-reference

Conversation

@clockwork-labs-bot
Copy link
Copy Markdown
Collaborator

Per Tyler's request. Consolidates the three commitlog proposals from SpacetimeDBPrivate into a single public reference document:

  • Proposal 0003 (commitlog format): Segment structure, commit format, transaction records, mutations, integrity model, wire format, versioning
  • Proposal 0016 (offset index): Index files, entry format, read/write behavior, configuration
  • Proposal 0027 (commitlog epoch): Epoch field for replication, format version 1

The document is written in textbook style with no emdashes or contractions, following the docs style guide. All proposal-specific language (motivation sections, alternatives considered, implementation stages, etc.) has been removed in favor of a direct reference format.

Placed at docs/docs/00200-core-concepts/00100-databases/00400-commitlog.md alongside the existing database concept docs.

No private repo details are referenced.

TypeScript modules use ctx.random (a deterministic RNG on the context),
not Math.random(). The old note incorrectly stated that Math.random()
was automatically seeded by SpacetimeDB.

Changes:
- Remove Math.random() from the warning about non-deterministic RNGs
- Replace the incorrect note with a proper table row documenting
  ctx.random in the TypeScript context properties reference
- Apply same fixes to versioned docs (v1.12.0)
Consolidates proposals 0003 (commitlog format), 0016 (offset index),
and 0027 (commitlog epoch) into a single reference document covering
the on-disk format, integrity model, transaction record structure,
offset indexing, wire format, and versioning.

Written in textbook style with no emdashes or contractions, per the
docs style guide.
Per Tyler: this is a reference manual, not something users need to know
to use the database. Moved from core-concepts/databases/ to
resources/reference/internals/ alongside the ABI reference and BSATN
docs.
Corrections after auditing against crates/commitlog source:
- Flags use high bits (7, 6, 5), not low bits (0, 1, 2)
- Inputs have a u32 length prefix before the reducer name
- Varint encoding is standard variable-length, not protobuf zig-zag
- Outputs use a 1-byte length prefix (max 255 bytes)
- V0 commits have no epoch field (8 bytes shorter)
- Format version 1 is the current default
- Version 1 can read version 0 segments (backward compatible)
- Mutations: table IDs are u32, counts are varint
Copy link
Copy Markdown
Contributor

@kim kim left a comment

Choose a reason for hiding this comment

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

It may be worth mentioning that commitlog segments may be compressed. The only supported compression format is zstd seekable, which allows the offset indexes to remain valid after compression.

Comment thread docs/docs/00300-resources/00200-reference/00300-internals/00400-commitlog.md Outdated
Comment thread docs/docs/00300-resources/00200-reference/00300-internals/00400-commitlog.md Outdated
Comment thread docs/docs/00300-resources/00200-reference/00300-internals/00400-commitlog.md Outdated
- Remove paragraph about old sled-based design (not relevant to reference doc)
- Simplify commitlog terminology entry
- Clarify that records payload is defined by the datastore, not the commitlog
- Add note about zstd seekable compression for segments
Comment thread docs/docs/00300-resources/00200-reference/00300-internals/00400-commitlog.md Outdated
@clockwork-labs-bot clockwork-labs-bot added this pull request to the merge queue Apr 15, 2026
Merged via the queue into master with commit 2356bbc Apr 15, 2026
35 of 36 checks 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.

3 participants