pub async fn rehydrate(
conn: &Connection,
ids: &[&str],
archive_path: &Path,
) -> Result<RehydrateReport>Expand description
Move concepts back from the cold file into the hot tables (§2.3, C3).
§Rehydration is a move back, not a write
It mints no transaction-time facts and is invisible to both clocks. The
concept’s log entries were never removed, so the ledger already says
everything true about it; writing a fresh 'I' would assert the concept was
learned at rehydration time, and — because the fold takes the highest
seq_id per entity — would additionally outrank any later 'U' that retired
it. See crate::schema::ddl::CREATE_CONCEPTS_LOG_INSERT, which is
marker-gated at v10 for exactly this reason. The whole operation therefore
runs inside a declared archive session, which is what suppresses the trigger.
§rowid_pk: reinstate, or reassign and re-point the index
The common case has no collision — the rowid was freed by archival and
nothing has claimed it since — and reinstating is the clean move-back with no
side effects at all. When something has taken it, the fallback is a fresh
rowid_pk plus an FTS correction: concepts_fts is external-content keyed
on rowid_pk ([D-119]), so a reassignment without re-pointing leaves the
index describing the wrong row, silently. Both exits are taken here rather
than one being assumed, and RehydrateReport::rowids_reassigned reports
which was used.
§A concept outlives its lineage, and is refused (0.15.11, W15.1, C-3)
Database::archive_branch takes a
lineage’s branches row with it, and a cold
concept keeps the branch_id it was minted on. Rehydrating one after the
other therefore reinstates a row whose lineage no longer exists — which
concepts.branch_id REFERENCES branches(branch_id) refuses, with foreign
keys on. It is refused here instead, as
DbError::BranchArchived naming both the concept and the lineage, for
the reason that variant’s own documentation gives: the engine’s message
names neither, and blames the table that was being written rather than the
one that is missing.
Ids whose lineage is intact are unaffected — the refusal names one concept, not the batch.
§Errors
DbError::BranchArchived when a requested concept’s lineage has no row in
branches. Nothing is written: the whole rehydrate runs in one transaction
and the refusal leaves it uncommitted.