Expand description
Recovery procedures for corrupt shards, partial writes, and missing DB.
This module implements the runtime recovery procedures that restore a bones project to a consistent state after:
- Partial/torn writes (process crash mid-append)
- Corrupt shard data (bit flips, truncation, invalid content)
- Missing or corrupt
SQLiteprojection database - Missing or corrupt binary cache files
- Locked database (retry with timeout)
§Recovery Philosophy
- Deterministic: same input → same recovery action, every time.
- No silent data loss: corrupt data is quarantined, never deleted outright.
- Fast common path: torn-write repair is the typical case (truncate last incomplete line). Complex cases (quarantine, rebuild) are rarer.
- User-facing messages: every action emits a diagnostic so operators know exactly what happened and why.
Structs§
- Health
Check Result - Result of a full project health check.
- Recovery
Report - Report from recovering a corrupt or partially-written shard file.
Enums§
- Recovery
Action - The action taken during recovery.
- Recovery
Error - Errors that can occur during recovery operations.
Functions§
- auto_
recover - Run a full health check and auto-recovery on a bones project directory.
- open_
db_ with_ retry - Attempt to open a
SQLitedatabase with retry and timeout for lock contention. - recover_
corrupt_ cache - Recover from a corrupt or missing binary cache by deleting it.
- recover_
corrupt_ shard - Recover a corrupt shard file by scanning for the last valid event line and quarantining corrupt data to a backup file.
- recover_
missing_ db - Recover from a missing or corrupt
SQLiteprojection by triggering a full rebuild from the event log. - recover_
partial_ write - Recover from a partial write (e.g., crash mid-append).