Library: migrate durable catalog state to SQLite
Draft
TE
2mo ago+1051+1051+0123456789012345678901234567890123456789-20-20-01234567890123456789
Implements #35 as a clean stack on #67 / #34. Supersedes #75, whose earlier SQLite branch diverged while #34 and main moved.
This replacement keeps the same product semantics on the reviewed #34 head and includes:
- explicit SQLite schema version with Sources, entries, present/missing reconciliation observations, normalized tags/metadata, favorites, recent/play-state table, ordered collections and playback weekdays;
- indexes for Source catalog identity/path/availability and common Library lookups;
- deterministic bounded JSON migration into a sibling candidate database in one transaction;
- SQLite
quick_check, foreign-key verification, row/database bounds and semantic catalog equality before publish; - candidate sync + database publication + versioned backend-selector switch last, with JSON retained byte-for-byte as the recovery snapshot;
- transactional SQLite ownership after activation, with no dual writes;
- recovery through the retained JSON snapshot if the selected SQLite database fails verification, plus verified rebuild on the next successful mutation and preservation of the invalid database as a diagnostic backup;
- deterministic sorted-key JSON debug/export representation;
- a 64 MiB database bound while retaining the 4 MiB JSON bridge, 4,096 Source-entry limit and existing catalog/state limits;
- media remains external; SQLite stores catalog/state only.
Tests cover exact migration round trips, ordering/IDs/timestamps/tombstones, expected indexes, historical JSON retention after SQLite activation, deterministic export, corrupt-database recovery/rebuild and unknown-selector failure. Existing #34 reconciliation, 4K scale, digest containment, Ambient Set and Library gallery tests remain in the stack.
Documentation: docs/library-sqlite.md.
🧱 Quarry