integrity core - #4029
Conversation
|
Claude finished @insipx's task —— View job Code Review — August 27, 2026, 15:47 UTCI've reviewed this PR focusing on areas not already covered by previous reviewers. The implementation is generally solid and most issues have been addressed through the review process. Here are a few remaining observations: Architecture & API DesignPositive: The trait-based design with Minor concern: The API surfaces Error HandlingThe
...this is acceptable, but worth documenting the brittleness. Test Coverage GapsCodecov shows 24 uncovered lines. Looking at the native.rs file, the uncovered lines appear to be in:
The Security ObservationsPositive findings:
Note: The ro/rw semantics have been well-discussed in review comments. The final documented behavior (rw with crash recovery, ro fallback for forensics) is reasonable and well-explained in the docs. PerformanceThe dedicated connection approach is correct for WAL concurrency. The test Minor: Documentation QualityThe module-level docs and function docs are excellent, especially:
Android Test FailureThe failing test SummaryThis is a well-designed, thoroughly tested feature. Most concerns raised during review have been addressed. The main remaining items are:
The PR is in good shape for merge after addressing the unrelated Android test failure. |
24bc39f to
23c44aa
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4029 +/- ##
==========================================
+ Coverage 85.91% 85.94% +0.03%
==========================================
Files 419 421 +2
Lines 68400 68811 +411
==========================================
+ Hits 58763 59137 +374
- Misses 9637 9674 +37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
23c44aa to
0b6bc34
Compare
0b6bc34 to
949672a
Compare
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a substantial cross-platform database integrity subsystem with SQLCipher HMAC checks, filesystem and OPFS access, dedicated connections, and changed salt-file initialization behavior. Its runtime and security-sensitive effects exceed the scope suitable for automatic approval. You can add or adjust custom eligibility rules. Learn more. |
949672a to
7660a29
Compare
7660a29 to
e1a9390
Compare
e1a9390 to
3eed6cf
Compare
3eed6cf to
7fb1745
Compare
This comment has been minimized.
This comment has been minimized.
7fb1745 to
e111bf4
Compare
Adds PRAGMA quick_check / integrity_check / cipher_integrity_check support with a structured IntegrityCheckResult (Ok / Corrupt / Unreadable / SaltMissing / Locked / Failed): - check_database_integrity(db_path, key, level): standalone by-path check on a dedicated short-lived read-only connection (file:?mode=rw open, query_only=ON, busy_timeout). Rebuilds the SQLCipher session pragmas (key + plaintext header + sidecar salt) via the same builders EncryptedConnection uses; never creates or migrates. - XmtpDb::integrity_check defaulted trait method; NativeDb overrides it to use the dedicated checker connection (ephemeral falls back to the existing connection); EncryptedMessageStore forwards explicitly. - wasm: async by-path check over the OPFS SAH pool. - In WAL mode the checker is a concurrent reader and does not block the database's own connections (proven by a check-while-writing test). Note: quick_check does not reliably detect ciphertext corruption on SQLCipher databases - only Full's cipher_integrity_check validates per-page HMACs. Documented on IntegrityCheckLevel::Quick. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e111bf4 to
3b41bb0
Compare
Summary
Bottom of the DB-integrity-check stack. Adds read-only SQLite corruption detection to
xmtp_db:PRAGMA quick_check/integrity_check/cipher_integrity_checkbehind a structuredIntegrityCheckResult(Ok | Corrupt | Unreadable | SaltMissing | Locked | Failed)check_database_integrity(db_path, key?, level): dedicated short-lived read-only connection (file:…?mode=rw,query_only=ON), SQLCipher session pragmas rebuilt from the same buildersEncryptedConnectionuses (key + plaintext header + validated salt sidecar); never creates or migrates; URI-delimiter-safe pathsXmtpDb::integrity_checkdefaulted trait method;NativeDboverrides with the dedicated checker connection;EncryptedMessageStoreforwards; wasm gets an async by-path check over OPFSNote:
quick_checkdoes not reliably detect ciphertext corruption on SQLCipher DBs — onlyFull'scipher_integrity_checkvalidates per-page HMACs (documented onIntegrityCheckLevel::Quick). Interval sweeps should runFull.Testing: 13 integrity tests (healthy/corrupt/wrong-key/malformed-salt/missing-salt/missing-db/unencrypted/ephemeral/URI-delimiters/concurrent-writer), full xmtp_db suite 227/227, wasm suite green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01V1AXHNsnQmHW174i5rRUEb
Note
Add
integrity_checkAPI toXmtpDband newintegritymoduleintegritymodule (mod.rs) that runsPRAGMA quick_check/integrity_checkand native SQLCipher HMAC checks, returning a structuredIntegrityCheckResult.integrity_checkto theXmtpDbtrait with a default that runs on the current connection;NativeDboverrides it to open a dedicated checker connection by path.session_pragmastoConnectionOptionsso encrypted backends can supply SQLCipher pragmas for the by-path checker;assemble_session_pragmascentralizes their construction.read_salt_hex, which bounds I/O to 64 bytes and requires exactly 32 hex characters.EncryptedConnection::newnow returnsInvalidDatafor malformed or oversized salt files instead of partially reading them;EncryptedConnection::pragmasnow returnsStringinstead ofimpl Display.Macroscope summarized 3b41bb0.