feat(activity): handle cache corruption with integrity check and recovery #320

Merged
fuzzy merged 1 commit from phase06-cache-integrity into main 2026-07-07 12:27:00 +00:00
Owner

What

Add SQLite integrity checking and corruption recovery, completing #254 and Phase 6.

Changes

  • CheckIntegrity() — runs PRAGMA integrity_check, returns ErrCorrupted sentinel error on failure with details
  • Open() — now calls CheckIntegrity() after migration; closes DB and returns ErrCorrupted if check fails
  • OpenWithRecovery(path) — wraps Open(): if ErrCorrupted, deletes the corrupted DB file and retries with a fresh database. Passes through other errors.
  • ErrCorrupted — exported sentinel error for callers to detect

Phase 6 complete

# Task Status
#242 Offline handling
#246 High activity
#250 New/empty contexts
#254 Cache corruption

References: #254, #251, #252, #253

Testing

  • 3 new tests: integrity check on fresh DB, OpenWithRecovery on :memory:, OpenWithRecovery file-based round-trip
  • go test -race ./... — all pass
## What Add SQLite integrity checking and corruption recovery, completing #254 and **Phase 6**. ### Changes - **CheckIntegrity()** — runs `PRAGMA integrity_check`, returns `ErrCorrupted` sentinel error on failure with details - **Open()** — now calls `CheckIntegrity()` after migration; closes DB and returns `ErrCorrupted` if check fails - **OpenWithRecovery(path)** — wraps `Open()`: if `ErrCorrupted`, deletes the corrupted DB file and retries with a fresh database. Passes through other errors. - **ErrCorrupted** — exported sentinel error for callers to detect ### Phase 6 complete | # | Task | Status | |---|------|--------| | #242 | Offline handling | ✓ | | #246 | High activity | ✓ | | #250 | New/empty contexts | ✓ | | #254 | Cache corruption | ✓ | References: #254, #251, #252, #253 ## Testing - [x] 3 new tests: integrity check on fresh DB, OpenWithRecovery on :memory:, OpenWithRecovery file-based round-trip - [x] `go test -race ./...` — all pass
feat(activity): handle cache corruption with integrity check and recovery
Some checks failed
Test and Release / test (pull_request) Has been cancelled
Test and Release / lint (pull_request) Has been cancelled
e8dae173ca
- CheckIntegrity(): runs PRAGMA integrity_check, returns ErrCorrupted
  on failure with details from SQLite
- Open(): now calls CheckIntegrity() after migration, closing the DB
  and returning ErrCorrupted if integrity fails
- OpenWithRecovery(path): wraps Open(), deletes corrupted DB file and
  retries if ErrCorrupted; otherwise passes through the error
- ErrCorrupted sentinel error for the caller to detect and handle
- 3 new tests: integrity check on fresh DB, OpenWithRecovery on
  :memory:, OpenWithRecovery on file-based DB round-trip

This completes Phase 6.

Ref: #254, #251, #252, #253
the.auditor approved these changes 2026-07-07 12:12:36 +00:00
Dismissed
the.auditor left a comment

Review

Result: Approved — no blocking issues.

Summary: Adds SQLite integrity checking and recovery. ErrCorrupted sentinel error for errors.Is() detection. CheckIntegrity() runs PRAGMA integrity_check — called during Open() after migration. OpenWithRecovery() wraps Open(): on corruption, deletes corrupted file and retries with fresh DB. ROADMAP2.md updated — Phase 6 fully complete.

Non-blocking:

  • #321 — Add godocs for exported ErrCorrupted, CheckIntegrity, OpenWithRecovery

Checklist:

  • Correctness: PRAGMA integrity_check correct, recovery deletes and retries once (no loop)
  • Completeness: Closes #254 — detection (integrity check), recovery (delete+retry), sentinel error
  • Test coverage: 3 tests (integrity in-memory, OpenWithRecovery in-memory, OpenWithRecovery file round-trip)
  • Race-safe: go test -race passes
  • Maintainability: Clean sentinel error pattern, single-retry recovery logic
## Review **Result: Approved** — no blocking issues. **Summary:** Adds SQLite integrity checking and recovery. `ErrCorrupted` sentinel error for `errors.Is()` detection. `CheckIntegrity()` runs `PRAGMA integrity_check` — called during `Open()` after migration. `OpenWithRecovery()` wraps `Open()`: on corruption, deletes corrupted file and retries with fresh DB. ROADMAP2.md updated — Phase 6 fully complete. **Non-blocking:** - #321 — Add godocs for exported `ErrCorrupted`, `CheckIntegrity`, `OpenWithRecovery` **Checklist:** - Correctness: ✅ PRAGMA integrity_check correct, recovery deletes and retries once (no loop) - Completeness: ✅ Closes #254 — detection (integrity check), recovery (delete+retry), sentinel error - Test coverage: ✅ 3 tests (integrity in-memory, OpenWithRecovery in-memory, OpenWithRecovery file round-trip) - Race-safe: ✅ `go test -race` passes - Maintainability: ✅ Clean sentinel error pattern, single-retry recovery logic
fuzzy added this to the Steeper project 2026-07-07 12:12:47 +00:00
fuzzy self-assigned this 2026-07-07 12:12:49 +00:00
fuzzy force-pushed phase06-cache-integrity from e8dae173ca
Some checks failed
Test and Release / test (pull_request) Has been cancelled
Test and Release / lint (pull_request) Has been cancelled
to d4c802afd8
All checks were successful
Test and Release / test (pull_request) Successful in 2m48s
Test and Release / lint (pull_request) Successful in 14m2s
2026-07-07 12:12:54 +00:00
Compare
fuzzy dismissed the.auditor's review 2026-07-07 12:12:54 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-07 12:13:28 +00:00
the.auditor left a comment

Re-Review

Result: Approved — unchanged from previous review. Rebase-only update.

Previous review findings still apply — no blocking issues. #321 filed for missing godocs.

## Re-Review **Result: Approved** — unchanged from previous review. Rebase-only update. Previous review findings still apply — no blocking issues. #321 filed for missing godocs.
fuzzy merged commit d4c802afd8 into main 2026-07-07 12:27:00 +00:00
fuzzy deleted branch phase06-cache-integrity 2026-07-07 12:27:00 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/steeper!320
No description provided.