brainy/src/db
David Snelling 1201e25543 feat: two-tier history reads + the repacker + generationDigest — D1+D3 wired end-to-end
The packed tier goes live inside GenerationStore:

- Two-tier reads: getDelta / readBeforeImage / readGenerationRecords
  fall through live-tier → sealed segments (live-tier-wins: a crash
  mid-fold leaves a duplicate representation, never a gap). Cold-open
  seeds committedRanges from the segment manifest via interval merge —
  packed generations resolve without their directories existing.
- repackHistory({timeBudgetMs, batchGenerations}): folds cold
  generations (older than the newest 1024) oldest-first into sealed
  segments, deleting per-generation directories only after segment +
  manifest are durable. Public API + automatic time-bounded pass at
  close() (before compaction, so reclaim can drop whole segments);
  re-representation only — the sole history transform under the
  archival profile. Early stop = consistent prefix, next pass resumes.
- compact(): packed generations reclaim logically in the loop and
  physically at whole-segment boundaries via dropSegmentsBelow (the
  frozen partial-segments-wait rule).
- generationDigest(g) (D8): deterministic content digest through g —
  sealed-segment checksum chain + live-tier delta hashes; O(segments +
  live window); RangeError out of range, GenerationCompactedError
  below the horizon (a gate can never silently pin reclaimed history).

Four end-to-end pins: asOf answers byte-identical across fold + cold
reopen with folded dirs physically gone; repack+reclaim composition;
digest reopen-stability/divergence/loud-horizon; budget no-op+resume.
2026-07-19 16:26:10 -07:00
..
db.ts docs: external-backups/sparse-storage guide + generation fact log concept 2026-07-16 10:30:32 -07:00
errors.ts fix: refuse writes when single-op history cannot be made durable 2026-07-13 09:31:25 -07:00
factLog.ts feat: scanFacts liveness contract — first batch or loud failure within a documented bound 2026-07-19 14:54:36 -07:00
familyStamp.ts feat: provider access to the fact log + shared stamp verifier via internals 2026-07-15 12:36:27 -07:00
generationSegments.ts feat: generation-segment store — the D1+D3 packed-tier file format 2026-07-19 15:14:27 -07:00
generationStore.ts feat: two-tier history reads + the repacker + generationDigest — D1+D3 wired end-to-end 2026-07-19 16:26:10 -07:00
portableGraph.ts refactor(8.0): rename BackupData → PortableGraph (the type is interchange, not a backup) 2026-06-19 12:37:23 -07:00
stableEqual.ts feat(8.0): temporal range verbs — diff, history, since(gen|Date), asOf{exclusive}, transactionLog window 2026-06-19 13:21:02 -07:00
types.ts feat: flush() never compacts — history maintenance moves to close() with bounded passes 2026-07-19 12:04:39 -07:00
whereMatcher.ts refactor(8.0): remove the 4 deprecated query-operator aliases (clean break) 2026-06-29 10:29:20 -07:00