| 1 | # celld-ltx |
| 2 | |
| 3 | `celld-ltx` is celld's in-process SQLite replication library. It captures |
| 4 | committed WAL data as L0 LTX segments and reports the captured position. The |
| 5 | crate can write segments to a filesystem or an object store. It can restore a |
| 6 | database, compact levels, create a snapshot, and read segments from bundle |
| 7 | objects. |
| 8 | |
| 9 | celld uses this library inside a larger durability protocol. The output gate, |
| 10 | epoch fencing, replicated node log, and takeover recovery enforce the write |
| 11 | acknowledgement contract. |
| 12 | |
| 13 | ## Provenance and attribution |
| 14 | |
| 15 | Seeded on 2026-08-03 from a read-only snapshot of rustyriver |
| 16 | (https://github.com/mikenomitch/rustyriver), a from-scratch Rust |
| 17 | reimplementation of Litestream v0.5 and the LTX file format. celld owns and |
| 18 | evolves this snapshot as first-class celld source; it does not track an |
| 19 | upstream branch. |
| 20 | |
| 21 | Attribution for the vendored and ported work: |
| 22 | |
| 23 | - **rustyriver** — Copyright 2026 The rustyriver authors, licensed under the |
| 24 | Apache License, Version 2.0. |
| 25 | - **Litestream** (https://github.com/benbjohnson/litestream) — Copyright (c) |
| 26 | Ben Johnson and the Litestream authors, licensed under the Apache License, |
| 27 | Version 2.0. The original replication behavior comes from tag v0.5.11. The |
| 28 | current block format follows tag v0.5.16 because it includes LTX v0.5.2. |
| 29 | - **LTX file format and reference implementation** |
| 30 | (https://github.com/superfly/ltx), tag v0.5.2 — Copyright (c) Superfly, Inc., |
| 31 | licensed under the Apache License, Version 2.0. |
| 32 | - **pierrec/lz4 block compressor** |
| 33 | (https://github.com/pierrec/lz4), tag v4.1.23 — Copyright (c) 2015 Pierre |
| 34 | Curto, licensed under the BSD 3-Clause License. The Rust port preserves the |
| 35 | exact compressed bytes that the LTX v0.5.2 writer produces. |
| 36 | |
| 37 | The port is not complete, deliberately. `leaser.rs` — Litestream's |
| 38 | object-storage lease (`leaser.go`, `heartbeat.go`, `s3/leaser.go`) — was |
| 39 | ported and then removed on 2026-08-06, unused. celld fences cell ownership |
| 40 | with a conditional-write record carrying an epoch, and fences the data path by |
| 41 | stamping that epoch into the LTX prefix; a lease file under the replica prefix |
| 42 | would be a second, competing layer. Upstream's own leaser is unwired for the |
| 43 | same reason. Recover it from git if a future design needs it. |
| 44 | |
| 45 | The full Apache License, Version 2.0 text is in [LICENSE](LICENSE). The full |
| 46 | BSD 3-Clause License text is in |
| 47 | [LICENSE.pierrec-lz4](LICENSE.pierrec-lz4). |
| 48 | |
| 49 | ## File compatibility |
| 50 | |
| 51 | Celld and Litestream v0.5.16 can read the new block files and the older frame |
| 52 | files. Litestream v0.5.11 can read only the older frame files. This is a reader |
| 53 | compatibility boundary because LTX keeps file version 3 for both layouts. |
| 54 | |
| 55 | The ordinary celld L0 writer still emits the older frame representation. The |
| 56 | v0.5.2 encoder and compactor emit exact block files. Celld contains a |
| 57 | node-wide scheduler that publishes additive L1 files, and the scheduler is on |
| 58 | by default. Every takeover target must have the dual decoder before the first |
| 59 | L1 publication, so a mixed fleet must set `CELLD_LTX_COMPACTION=0` until all |
| 60 | nodes can read block files. The same reader-first requirement applies to a |
| 61 | later L0 writer switch. |