Skip to content

docs: Add commitlog reference document#4668

Open
clockwork-labs-bot wants to merge 5 commits intomasterfrom
bot/docs-commitlog-reference
Open

docs: Add commitlog reference document#4668
clockwork-labs-bot wants to merge 5 commits intomasterfrom
bot/docs-commitlog-reference

Conversation

@clockwork-labs-bot
Copy link
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
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.

2 participants