pub fn backfill(
repo: &Path,
records: Vec<MigrationRecord>,
blame_fallback: Option<&str>,
jurisdiction_map: &HashMap<String, String>,
dry_run: bool,
) -> Result<BackfillSummary, String>Expand description
Run the idempotent backfill of records into the store at repo. Deterministic order: records
are sorted by source_key first so a re-run replays the same chain. Idempotency is keyed on the
durable source_key (the non-hashed source_ref’s derived key, or a token in the hashed observe): a record
whose key is already in the store is SKIPPED — chain-position-independent, so a re-run over a
now-non-empty store writes nothing. The chain is kept by threading the PROSPECTIVE parent (the
id we just wrote/found) instead of re-reading the live HEAD each step, so the lineage stays
stable across re-runs. A skipped record whose stored parent differs from where it would now land
is a back-dated mid-chain insert and is reported as re-linked. blame_fallback supplies the
author for a record carrying none; a record with neither is a source-only gap (R5 stays intact —
we never invent an author). jurisdiction_map (source_key → A/B/C/D bucket) tags each imported
decision: a record whose key is in the map carries that jurisdiction, one absent imports untagged
(None) — so the map is purely additive (an empty map ⇒ every record None, the prior behavior).
jurisdiction is NON-hashed, so tagging never moves a tick id (idempotency holds across re-runs).
--dry-run reports the would-import count but writes nothing.