Skip to content

fix(database): add native reliability validation#540

Merged
ucguy4u merged 1 commit into
mainfrom
codex/issue-516-database-validation
Jun 29, 2026
Merged

fix(database): add native reliability validation#540
ucguy4u merged 1 commit into
mainfrom
codex/issue-516-database-validation

Conversation

@ucguy4u

@ucguy4u ucguy4u commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

fix(database): add native reliability validation


Summary

This PR introduces changes to the native database reliability contract.
Goal: make local database backup/restore and malformed-file recovery deterministic and verifiable on current main.

Core outcome:

  • adds file-based backup/restore helpers plus malformed-file recovery before native Drift open
  • adds a repeatable validation suite and release runbook for database reliability

Changes

Code

  • Added:

    • deterministic native database reliability tests
    • release runbook for database reliability validation
    • shared make test-database-reliability target
  • Updated:

    • native AppDatabase with path-based construction, backup restore helpers, WAL-aware export, and malformed-file recovery
    • release checklist to include database reliability validation

Logic

  • checkpoints WAL before reading backup bytes so exported backups include current writes
  • recreates obviously malformed database files before Drift opens them
  • supports restoring backup bytes to an explicit database path for deterministic recovery testing

API Changes (if any)

  • AppDatabase now accepts an optional native database path.
  • AppDatabase.restoreBackup(...) and restoreDatabase(...) are added for backup restore flows.

Database Changes (if any)

  • No schema version bump.
  • No destructive migration.
  • Reliability behavior around open/export/restore is strengthened for the existing schema.

Observability / Logging

  • None

Performance Impact

  • Latency: negligible except when explicitly exporting a backup due to WAL checkpointing
  • Throughput: no expected runtime regression for ordinary CRUD paths
  • Memory/CPU: no meaningful steady-state change

Risks

  • malformed-file detection currently targets obvious non-SQLite files rather than deeper logical corruption

  • backup export now performs a checkpoint, which is correct for durability but should remain limited to explicit backup paths

  • Rollback plan:

    • revert this PR to restore the prior database open/export behavior and remove the validation target/docs

Testing

  • Unit tests:

    • flutter test test/core/database/app_database_reliability_test.dart
  • Integration tests:

    • none
  • Manual testing:

    • adb devices -l confirms a reachable Pixel 9 for device-only follow-up checks
    • focused docs/runbook validation and release checklist update

Deployment Notes

  • Config changes:

    • none
  • Order of deployment:

    • normal merge to main

Related Commits

  • fix(database): add native reliability validation

Notes

- add file-based backup/restore helpers and malformed-file recovery for the native Drift database
- cover sqlite pragmas, backup round trips, corruption recovery, and larger history restores with deterministic tests
- add a shared make target and release runbook for database reliability validation

This turns issue #516 into a reproducible database-reliability slice on top of current main.
@github-actions

Copy link
Copy Markdown
Contributor

Plugin Module Size Gate

Policy: modules over 3 MB must be delivered as plugins; plugin modules over 5 MB must document cache management.

Module Size Type Status
No changed Dart/Flutter modules detected n/a n/a OK

@github-actions

Copy link
Copy Markdown
Contributor

🚀 PR Quick Check Summary

Check Status Description
PR Validation ✅ success Title format, docs, bundled model guardrail
Code Quality ✅ success Analyze, formatting
Core Tests ✅ success Core package unit tests

💡 Note: Full app tests, coverage reports, and security scans run on merge to main.

View Details

@ucguy4u ucguy4u merged commit f0c8b3d into main Jun 29, 2026
18 checks passed
@ucguy4u ucguy4u deleted the codex/issue-516-database-validation branch June 29, 2026 15:58
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant