Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/skade

.nornir/time-travel-design.md

Time-travel — design

Class: design · Function: time-travel · Uses: store. Only the shape that runs; the why (why STree64, why immutable-swap, why a live tail) is in time-travel-reasoning.md.

f0 — resolve a table as of a snapshot

Time-travel resolves (table, snapshot_id) → metadata_location through the Ragnar static index when the id is covered by the cutoff, else the redb commits live tail. Routing rule (catalog.rs:149 resolve_location_at): probe the ArcSwapOption<StaticIndex>; on a covered hit whose table_key matches, return it; otherwise open a redb read txn and point-lookup the commits table.

The public entry points:

method source returns
resolve_metadata_at(ident, sid) catalog.rs:174 parsed Arc<TableMetadata> (no Table build)
load_table_at(ident, sid) catalog.rs:189 a built Table, via the L1.5 handle cache
resolve_many(ident, &[sid]) catalog.rs:215 one slot per id, in order (None = never committed)
compact_static_index() catalog.rs:140 force a rebuild now; returns indexed count
commit_seq() catalog.rs:79 durable monotonic commit count

f1 — the commit log (store.rs)

COMMITS (store.rs:77) is append-only: key {table_key}\x1f{snapshot_id:u64_be} → metadata_location. The big-endian id (commit_key, store.rs:99) makes redb's lexicographic order equal ascending snapshot order within a table, so per-table scans and cutoffs are contiguous. Snapshot ids are immutable and globally unique in Iceberg, so a row is never rewritten. record_commit (store.rs:111) appends only when a commit carries a snapshot id, and bumps META_COMMIT_SEQ + META_UPDATE_COUNTER.

f2 — the Ragnar STree64 index (static_index.rs)

StaticIndex (static_index.rs:42) is an immutable projection of the commit log: sorted ids: Arc<[i64]> parallel to entries: Arc<[Entry]>, with a STree64 — Ragnar Groot Koerkamp's cache-line-packed implicit B-tree — built over the ids.

f3 — the compactor (store.rs)

The index is built at open (warm-start from the durable log, store.rs:201) and rebuilt in the background as history grows:

Reads never block on compaction; the only write-path cost is one atomic increment. Correctness rests on immutability: the compactor swaps a whole new immutable index in — it never mutates one in place, and it drops nothing a covered id still needs.