Summary
ClearReadyFlags() (DbContext.cs:560-563) is called at the start of every index run to demote trust if the run crashes — that's good for read-side correctness. But there is no way to roll back to the prior known-good state if a schema migration or backfill-fold partially completes and corrupts the DB. The user's options are: rebuild from scratch (hours of work) or manually salvage with sqlite3 shell. There is no cdidx db checkpoint or cdidx db restore command.
Where
src/CodeIndex/Database/DbContext.cs:560-563 (ClearReadyFlags — no checkpoint complement)
src/CodeIndex/Cli/IndexCommandRunner.cs:285-380 (RunBackfillFold — no pre-flight snapshot)
Suggested approach
(1) Before destructive maintenance (backfill-fold, schema migration, --rebuild), automatically take a sidecar snapshot to <db>.checkpoint-<timestamp> (hardlink if same filesystem, otherwise file copy gated by --no-checkpoint opt-out). (2) Add cdidx db checkpoint <name> for explicit named checkpoints. (3) Add cdidx db restore <name> that atomically swaps the snapshot in. (4) Add cdidx db checkpoints --list to enumerate. (5) Auto-prune checkpoints older than N days (configurable). (6) Document in DEVELOPER_GUIDE under "Maintenance".
Summary
ClearReadyFlags()(DbContext.cs:560-563) is called at the start of every index run to demote trust if the run crashes — that's good for read-side correctness. But there is no way to roll back to the prior known-good state if a schema migration orbackfill-foldpartially completes and corrupts the DB. The user's options are: rebuild from scratch (hours of work) or manually salvage withsqlite3shell. There is nocdidx db checkpointorcdidx db restorecommand.Where
src/CodeIndex/Database/DbContext.cs:560-563(ClearReadyFlags — no checkpoint complement)src/CodeIndex/Cli/IndexCommandRunner.cs:285-380(RunBackfillFold — no pre-flight snapshot)Suggested approach
(1) Before destructive maintenance (
backfill-fold, schema migration,--rebuild), automatically take a sidecar snapshot to<db>.checkpoint-<timestamp>(hardlink if same filesystem, otherwise file copy gated by--no-checkpointopt-out). (2) Addcdidx db checkpoint <name>for explicit named checkpoints. (3) Addcdidx db restore <name>that atomically swaps the snapshot in. (4) Addcdidx db checkpoints --listto enumerate. (5) Auto-prune checkpoints older than N days (configurable). (6) Document in DEVELOPER_GUIDE under "Maintenance".