Expand description
Per-table, per-rowid VERSION HISTORY over a SQLite database’s WAL temporal
model — the evidence-based “row history” (Phase 1 of the WAL-temporal work).
Database::row_histories walks each salt
epoch’s CommitSnapshots in commit order, then the
final live view, and for every rowid emits the sequence of distinct record
values it held — an INSERT/UPDATE/DELETE/reinsert history reconstructed
purely from the bytes, with NO timestamps (SQLite WAL carries no wall-clock
time; commit_seq is LOGICAL order within an epoch only).
The two correctness-critical transforms are pure and unit-testable here:
build_rowid_versions collapses identical consecutive values into one
version (labelled by the EARLIEST view it appeared in) and classifies each
version’s ViewState from evidence; the same walk detects rowid REUSE (a
present→absent→present-with-a-different-record gap is a delete+reinsert, two
entities, never one continuous update).
Structs§
- RowVersion
- One version of one row: a distinct record value the rowid held at some point, with its evidence-based classification and logical provenance.
- RowView
- One chronological VIEW of a single table: a rowid→values map plus the view’s
logical position and trust flags. The ordered list of these (commit views in
epoch order, then the final live view last) is the input to
build_rowid_versions. - Table
History - The version history of one user table.
Enums§
- Version
Origin - Where a
RowVersioncame from. Logical provenance only — never a timestamp. - View
State - The EVIDENCE-based state of a row version relative to the FINAL live view.
Functions§
- build_
rowid_ versions - Build the ordered
RowVersions for ONErowidby walkingviews(already in chronological order: epoch commits ascending, then the final live view). - sort_
table_ versions - Re-sort a table’s versions into the canonical order after a caller has
appended more (e.g. the forensic layer merging carved residue): by
rowid(Nonelast), thencommit_seqascending withNone(live / order-unknown residue) grouped LAST within the rowid. Stable. - table_
history - Assemble the
TableHistoryfor ONE table from its chronologicalviews(commit views in epoch order, then the final live view last) and its schema.