1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! Write-ahead log for LoraDB.
//!
//! `lora-wal` is the additive durability layer that sits between
//! [`lora_store::MutationEvent`] producers (the in-memory engine) and a
//! durable byte stream on disk. It is deliberately separate from
//! `lora-store`:
//!
//! - `lora-store` stays storage-only — backends do not learn about logs,
//! segments, or fsync. The mutation surface they already expose
//! (`MutationEvent` + `MutationRecorder`) is the only seam.
//! - `lora-wal` owns segment files, framing, replay, and truncation.
//! Consumers depending on the no-WAL story (wasm, embedded read-only)
//! can avoid this crate entirely.
//! - `lora-database` glues the two together: it installs a [`WalRecorder`]
//! onto the store and brackets each query with `arm` / `commit` /
//! `abort` markers so replay sees query-atomic units even though the
//! recorder fires per primitive mutation.
//!
//! See `docs/decisions/0004-wal.md` for the full design and
//! `docs/operations/wal.md` for operator-facing semantics.
// ---- Operator-facing surface ----------------------------------------------
//
// Everything below is what callers (`lora-database`, the HTTP server,
// admin paths, integration tests) need. Internal types — segment
// framing constants, the segment reader/writer, record codec — stay
// `pub(crate)`. Bumping that boundary later is opt-in and easy; the
// reverse (un-publishing a previously-public type) breaks downstream
// builds.
pub use ;
pub use SegmentId;
pub use WalError;
pub use Lsn;
pub use ;
pub use ;
pub use Wal;