Skip to main content

Module row_history

Module row_history 

Source
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.
TableHistory
The version history of one user table.

Enums§

VersionOrigin
Where a RowVersion came from. Logical provenance only — never a timestamp.
ViewState
The EVIDENCE-based state of a row version relative to the FINAL live view.

Functions§

build_rowid_versions
Build the ordered RowVersions for ONE rowid by walking views (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 (None last), then commit_seq ascending with None (live / order-unknown residue) grouped LAST within the rowid. Stable.
table_history
Assemble the TableHistory for ONE table from its chronological views (commit views in epoch order, then the final live view last) and its schema.