feat: expose dbIntegrityCheck and checkDatabaseIntegrity across all SDKs - #4038
feat: expose dbIntegrityCheck and checkDatabaseIntegrity across all SDKs#4038insipx wants to merge 1 commit into
Conversation
|
Claude finished @insipx's task —— View job PR Review - Database Integrity Check APIReview Date: 2026-08-27 15:47 UTC Reviewed the implementation of ✅ Strengths
🔍 Code Quality Observations1. Missing error test coverage (minor) While the happy path is well tested, there's limited coverage of error scenarios across SDKs:
2. Test isolation concern (Android) The Android static test ( runBlocking { client.dropLocalDatabaseConnection() }
val outcome = runBlocking { Client.checkDatabaseIntegrity(client.dbPath, key) }The comment says "read-only connection isn't opened against a live client" but the client object still exists. The uniffi test does this more cleanly by calling client.shutdown().await.unwrap();
let outcome = check_database_integrity(db_path, Some(key), None).await.unwrap();Consider matching the uniffi pattern for cleaner test semantics. 3. Unresolved review thread The macroscopeapp review comment about read-only database handling remains unresolved. The reviewer explicitly states (sdks/ios/Sources/XMTPiOS/Client.swift:814):
This contradicts the author's claim that it was "addressed in the amended core commit." The PR should either:
4. WASM implementation difference (architectural) WASM runs the check directly without let result = self.inner_client().db_integrity_check(level.into()).map_err(ErrorWrapper::js)?;This is correctly documented ("single-threaded, so this runs the (sync) core check directly") but creates a platform difference where WASM can block the event loop during intensive 🛡️ Security & Performance
📊 Test Coverage GapCodecov shows 9 lines missing coverage in
Missing coverage likely includes:
Recommendations
Overall this is solid work with good cross-platform consistency. The main blocker is resolving the outstanding read-only database review comment. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## insipx/db-integrity-check #4038 +/- ##
============================================================
Coverage ? 85.97%
============================================================
Files ? 421
Lines ? 68924
Branches ? 0
============================================================
Hits ? 59257
Misses ? 9667
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cd7198a to
dab18ea
Compare
dab18ea to
74f4ac3
Compare
3a44539 to
3d66ca3
Compare
6be067d to
1497f49
Compare
| ) async throws -> IntegrityCheckOutcome { | ||
| let result: FfiIntegrityCheckOutcome | ||
| #if canImport(XMTPiOS) | ||
| result = try await XMTPiOS.checkDatabaseIntegrity( |
There was a problem hiding this comment.
🟡 Medium XMTPiOS/Client.swift:814
Client.checkDatabaseIntegrity returns a failed outcome for a readable database that is not writable, such as a copied diagnostic DB on read-only media, instead of performing the advertised read-only check. The native checker reached at this call opens the supplied path with SQLite URI mode=rw before enabling query_only; open it read-only (or explicitly change the API contract) so read-only databases can be checked.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @sdks/ios/Sources/XMTPiOS/Client.swift around line 814:
`Client.checkDatabaseIntegrity` returns a `failed` outcome for a readable database that is not writable, such as a copied diagnostic DB on read-only media, instead of performing the advertised read-only check. The native checker reached at this call opens the supplied path with SQLite URI `mode=rw` before enabling `query_only`; open it read-only (or explicitly change the API contract) so read-only databases can be checked.
There was a problem hiding this comment.
Addressed in the amended core commit: the native checker now falls back to mode=ro when the mode=rw open fails, so read-only diagnostic copies (the exact forensic use-case this API serves) can be checked; WAL recovery is impossible on read-only files anyway, making ro safe there. Regression test: by_path_checks_read_only_files (0444 db + sidecar → Ok).
There was a problem hiding this comment.
I don’t see that amended change in the current PR: native.rs still returns Failed immediately when mode=rw fails, and by_path_checks_read_only_files is not present. Please update/rebase the core commit so the fallback and regression test are included.
1497f49 to
bf3e7db
Compare
One combined surface change per platform, mirroring the node bindings: - bindings/wasm + browser-sdk (worker-RPC client method; OPFS-worker free fn) - bindings/mobile (uniffi enum/record, spawn_blocking around the sync core) - sdks/android (Kotlin wrappers, companion static) - sdks/ios (Swift wrappers; compile gated by CI) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bf3e7db to
1c47f7f
Compare
Top of the DB-integrity stack (on #4028). One combined PR bringing the integrity API to every remaining SDK surface, mirroring the node implementation:
IntegrityCheckLevel/IntegrityCheckOutcome, asyncclient.dbIntegrityCheck(level?), freecheckDatabaseIntegrity(dbPath, level?)(no key — wasm DBs are unencrypted)FfiIntegrityCheckLevel/FfiIntegrityCheckOutcome,FfiXmtpClient.db_integrity_check, keyed freecheck_database_integrity—spawn_blockingaround the sync core; key conversion mirrorscreate_clientSame six outcome strings everywhere (
ok|corrupt|unreadable|saltMissing|locked|failed). Verified per-surface:just wasm check, real headless-chromium vitest runs (browser), 3 backend-connected uniffi tests, gradle build + spotless (android); iOS via CI.🤖 Generated with Claude Code
https://claude.ai/code/session_01V1AXHNsnQmHW174i5rRUEb