Diffinery

homeflare/celldpublic

celld/crates/ltx/README.md
66 lines · 3.4 KBRaw History
1# celld-ltx
2
3celld's in-process SQLite-to-object-store replication engine. It reads each
4cell's SQLite WAL, writes LTX files to a fleet bucket, restores a database from
5that bucket, and — as it grows — exposes the replicated position so celld can
6gate a write's response until it is durable. This is the foundation of celld's
7durability goal: RPO=0 for every cell write, matching Durable Objects.
8
9## Provenance and attribution
10
11Seeded on 2026-08-03 from a read-only snapshot of rustyriver
12(https://github.com/mikenomitch/rustyriver), a from-scratch Rust
13reimplementation of Litestream v0.5 and the LTX file format. celld owns and
14evolves this snapshot as first-class celld source; it does not track an
15upstream branch.
16
17Attribution for the vendored and ported work:
18
19- **rustyriver** — Copyright 2026 The rustyriver authors, licensed under the
20 Apache License, Version 2.0.
21- **Litestream** (https://github.com/benbjohnson/litestream) — Copyright (c)
22 Ben Johnson and the Litestream authors, licensed under the Apache License,
23 Version 2.0. The original replication behavior comes from tag v0.5.11. The
24 current format oracle uses tag v0.5.16 because it includes LTX v0.5.2.
25- **LTX file format and reference implementation**
26 (https://github.com/superfly/ltx), tag v0.5.2 — Copyright (c) Superfly, Inc.,
27 licensed under the Apache License, Version 2.0.
28- **pierrec/lz4 block compressor**
29 (https://github.com/pierrec/lz4), tag v4.1.23 — Copyright (c) 2015 Pierre
30 Curto, licensed under the BSD 3-Clause License. The Rust port preserves the
31 exact compressed bytes that the LTX v0.5.2 writer produces.
32
33The port is not complete, deliberately. `leaser.rs` — Litestream's
34object-storage lease (`leaser.go`, `heartbeat.go`, `s3/leaser.go`) — was
35ported and then removed on 2026-08-06, unused. celld fences cell ownership
36with a conditional-write record carrying an epoch, and fences the data path by
37stamping that epoch into the LTX prefix; a lease file under the replica prefix
38would be a second, competing layer. Upstream's own leaser is unwired for the
39same reason. Recover it from git if a future design needs it.
40
41The full Apache License, Version 2.0 text is in [LICENSE](LICENSE). The full
42BSD 3-Clause License text is in
43[LICENSE.pierrec-lz4](LICENSE.pierrec-lz4).
44
45## Tests
46
47The suite ports the upstream conformance vectors. The codec and compactor
48fixtures compare complete output bytes with `superfly/ltx` v0.5.2. The tests
49also compact the older LZ4 frame fixtures from Litestream v0.5.11.
50
51Celld and Litestream v0.5.16 can read the new block files and the older frame
52files. Litestream v0.5.11 can read only the older frame files. This is a reader
53compatibility boundary because LTX keeps file version 3 for both layouts.
54
55The ordinary celld L0 writer still emits the older frame representation. The
56v0.5.2 encoder and compactor emit exact block files. Celld contains a
57node-wide scheduler that publishes additive L1 files, and the scheduler is on
58by default. Every takeover target must have the dual decoder before the first
59L1 publication, so a mixed fleet must set `CELLD_LTX_COMPACTION=0` until all
60nodes can read block files. The same reader-first requirement applies to a
61later L0 writer switch.
62
63`differential_xtool` checks LTX reads and writes against a real Litestream
64binary in three directions. It skips when the binary is absent, so the fast CI
65does not require the Go toolchain. The release gate builds the pinned binary
66and runs the real oracle.