Repository navigation
fix(swift-sdk): take migration copies out of WAL mode - #5070
Conversation
A SQLite backup copies page 1, so a copy of a WAL store keeps the WAL
header but has no -wal/-shm beside it. The legacy bridge then opens its
snapshot read-only for the integrity check; on iOS that connection cannot
create the -shm and fails with SQLITE_CANTOPEN ("unable to open database
file"). Every store written by App Store 9.0.0 is a WAL store that needs
the bridge, so updating straight to 9.1.1 showed "Couldn't open your
wallet data".
Switch each new copy to DELETE journal mode on the connection that wrote
it. Promotion into the live store is unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughSQLite copies without a locked destination check now switch to DELETE journal mode after backup. Tests verify the copied database’s journal format, integrity, and data, including migration snapshots. ChangesSQLite copy journal mode
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The snapshot-format fix has no identified merge-blocking issue. Merge after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change makes migration snapshots readable without WAL sidecar files while leaving live-store installation guarded. No new security exposure was identified in the traced migration path, but device-interruption behavior was not independently verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Final review complete — no blockers (commit 55f0587) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified the findings against exact head ab2aaa4 and traced the snapshot, candidate, and locked-promotion callers. The journal-mode change is correctly limited to unlocked copies; no correctness or layering defect was confirmed, and only an ambiguous new comment warrants a nitpick. Validation was source inspection; tests were not independently rerun.
💬 1 nitpick(s)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: architecture-layering); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
lowbygpt-6-astra(effort low) — The diff adds a small, guarded journal-mode conversion in DashLegacyStoreSQLite.copy for scratch copies with two focused regression tests, leaving live-store promotion unchanged and lacking the size or intricacy required for critical. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— architecture-layering (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 95% left, weekly 27% left; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 13% left, 5h 100% left) - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort medium); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashLegacyStoreSQLite.swift`:
- [NITPICK] packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashLegacyStoreSQLite.swift:117-119: Clarify that the new copy is switched out of WAL mode
The phrase "leave WAL on the new copy" can read as preserving WAL mode, whereas the following statement explicitly selects DELETE mode. Write "switch the new copy out of WAL mode" to make the direction of this fix unambiguous.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Verified the complete PR diff and migration callers at head 55f0587. Scratch copies switch to DELETE mode after backup completion and verify the result, while locked live-store promotion remains unchanged; no actionable in-scope defects were found, and the prior comment finding is fixed. The added regression tests cover WAL-copy readability and migration snapshot integrity; git diff --check passed, but runtime tests were not independently rerun during this verification.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: architecture-layering); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — The diff changes SQLite storage-migration behavior and adds targeted tests, making it a small, contained logic fix, but it is not one of the defined critical surfaces such as consensus, funds, cryptography, or key handling. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— architecture-layering (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 13% left, 5h 100% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
|
/self-reviewed |
|
@coderabbitai review No review for |
llbartekll
left a comment
There was a problem hiding this comment.
Reviewed at 55f0587. The journal-mode conversion is limited to scratch copies after backup completion and verifies the resulting mode; locked promotion into the live store is unchanged.
Additional device validation: a store originating from App Store 9.0.1 failed on 9.1.1 (35) in the legacy-v1 bridge before afterSnapshot. With 9.1.2 (7), built from this exact PR head, the exported iPhone logs show the same source model checksum progressing through afterSnapshot, afterMigration, beforeInstall and afterCommit to store_open_succeeded. Wallet restoration and subsequent persistence writes succeeded. A separate app restart opened the existing V3 store successfully without rerunning the bridge, and persistence writes continued.
The Swift SDK build/tests and frozen-schema checks are green. No blocking findings. This device validation covers the tested 9.0.1 store; it does not claim coverage of every historical store layout.
|
/skip-bots |
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
Issue being fixed or feature implemented
After updating from App Store Dash Wallet 9.0.0 straight to 9.1.1, users see "Couldn't open your wallet data". Those stores are labelled
1.0.0with a graph that does not match the frozen V1, so onlyDashLegacySchemaBridge(legacy-v1-bridge-to-v3) can open them, and on a device the bridge always fails withDashLegacyStoreSQLite.Failure.database("unable to open database file").The cause is how the bridge copies the store.
sqlite3_backupcopies page 1 as it is, so a copy of a WAL store keeps the WAL header (bytes 18/19 = 2) but has no-wal/-shmbeside it.integrityCheck(backup)then opens that copy withSQLITE_OPEN_READONLY. A read-only connection cannot create the-shm, so the first statement fails withSQLITE_CANTOPEN. Every app-written store is WAL. The committed fixtures are DELETE-mode, so the tests never exercised this.What was done?
DashLegacyStoreSQLite.copy(from:to:): when the copy goes to a new scratch file (nolockedDestinationCheck), it now switches that copy tojournal_mode=DELETEon the connection that wrote it, and fails if the mode does not change. This covers bothoriginal.storeandcandidate.store. Promotion into the live store is unchanged.How Has This Been Tested?
DashLegacySchemaMigrationTestshas two new tests:testCopyOfWALStoreLeavesWALModeAndReadsReadOnly: a copy of a WAL store with uncheckpointed data has a DELETE header, can be read by a read-only connection, and keeps the WAL data.testWALStoreSnapshotIsReadableBeforeMigration: atafterSnapshotthe retainedoriginal.storeis not in WAL mode and passesintegrityCheck, and the migration completes.swift test --filter DashLegacySchemaMigrationTests: the two new tests fail without the fix and pass with it; the suite is 37/37 with the fix. This ran on the v4.3-dev base, where the persistence sources and these tests are identical to v4.2-dev.ecb9d20b80plus this change, and installed it over App Store 9.1.1, which was failing on a real store written by App Store 9.0.0 (1013) (testnet, throwaway wallet). Before the change, the log showedintegrityCheck(backup)→unable to open database file. After the change, the whole chainafterSnapshot → afterMigration → afterCommit → store_open_succeededran,validatePreservationpassed, and the wallets open with their history.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
55f0587When every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit