Skip to main content

Module recovery

Module recovery 

Source
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 SQLite projection 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§

HealthCheckResult
Result of a full project health check.
RecoveryReport
Report from recovering a corrupt or partially-written shard file.

Enums§

RecoveryAction
The action taken during recovery.
RecoveryError
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 SQLite database 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 SQLite projection by triggering a full rebuild from the event log.
recover_partial_write
Recover from a partial write (e.g., crash mid-append).