Repository navigation
fix(wallet): show the launch hold's card when the wallet inventory cannot be read - #1153
romchornyi wants to merge 6 commits into
Conversation
…nnot be read Follow-up to the launch fix: with the launch decided only once the app is active, a "no wallet" answer can still come from a keychain failure that is not the lock, and the launch hold released it into setup. The hold takes one tri-state `walletPresence` read instead of a Bool. Every verdict derives from a single snapshot: present presents the wallet, only a definite absent goes on to the legacy-material question and setup, and unknown shows the blocking card (`Keychain:unreadableWalletInventory`) whose Try Again re-reads and whose late-success watcher completes the launch once a read works. Split out of #1147. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
A build-time rename of the test module slipped into the previous commit. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
✅ Final review complete — no blockers (commit 98dcf1c) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The coordinator correctly treats an unreadable wallet inventory as a blocking failure, but the production launch gate does not start it when migration is already complete. In that case, an unknown wallet presence is still converted to the setup screen, so the PR does not fully protect existing wallets from Create/Recover being offered after a failed keychain read.
🔴 1 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Unreadable inventory is still routed to setup when migration is complete
DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:213-216
The new tri-state coordinator is only started when keyMigrationPending is true. When the migration-done sentinel exists, legacyWalletMaterialPendingMigration() returns false regardless of the SDK wallet inventory result. If WalletEnvironment.walletPresence is .unknown, model.hasAWallet is also false by design, so this condition evaluates to false and the root controller immediately presents setupController without starting the coordinator or showing the blocking keychain failure card. This is the migration-complete scenario described by the PR: a funded wallet can be present while its inventory read fails, and Create/Recover can still be offered over it. The root launch decision must sample wallet presence and hold on .unknown as well as pending legacy material, preferably using one presence snapshot for the gate and coordinator, with an integration regression test covering the migration-complete case.
source: gpt-6-astra (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — This is a contained but nontrivial launch-state behavior change spanning coordinator logic, failure modeling, production wiring, and tests, without modifying funds movement, cryptography, key handling, storage migrations, or other critical surfaces. - Phase 1 reviewers:
gemini-3.8-flash-high— general (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— security-auditor (completed, effort high); agentphase1-reviewer - Phase 1 model:
gemini-3.8-flash-high— antigravity quota: weekly 82% left, 5h 98% left - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort high); 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 `DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m`:
- [BLOCKING] DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:213-216: Unreadable inventory is still routed to setup when migration is complete
The new tri-state coordinator is only started when `keyMigrationPending` is true. When the migration-done sentinel exists, `legacyWalletMaterialPendingMigration()` returns false regardless of the SDK wallet inventory result. If `WalletEnvironment.walletPresence` is `.unknown`, `model.hasAWallet` is also false by design, so this condition evaluates to false and the root controller immediately presents `setupController` without starting the coordinator or showing the blocking keychain failure card. This is the migration-complete scenario described by the PR: a funded wallet can be present while its inventory read fails, and Create/Recover can still be offered over it. The root launch decision must sample wallet presence and hold on `.unknown` as well as pending legacy material, preferably using one presence snapshot for the gate and coordinator, with an integration regression test covering the migration-complete case.
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/WalletPreparationFailure.swift`:
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/WalletPreparationFailure.swift:31-35: Add direct coverage for the unreadable-wallet failure initializer
The new `.keychain` failure kind and `init(unreadableWallet:)` are exercised indirectly by the lifecycle coordinator test through their kind and diagnostic code, but `WalletPreparationFailureTests` does not verify the initializer's presentation copy or diagnostic report. A focused test should construct this failure with a fixed date and assert its kind, `Keychain:unreadableWalletInventory` code, generic recovery title/message, and report category/code so later changes cannot silently regress the new failure presentation.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- The migration completion callback still re-reads wallet presence before routing — In
DWAppRootViewController.m,presentInitialControllerAfterKeyMigration:checks bothmigratedWalletPresentand a freshself.model.hasAWalletread. A transient failure on that second read can route a successful coordinator result to setup. This is a concrete fail-open race, but the method predates this PR and should be handled in a separate launch-gating change rather than expanded into this review.- Follow-up: Track a separate fix to trust the coordinator's
migratedWalletPresentresult or pass an explicit tri-state snapshot through the completion path.
- Follow-up: Track a separate fix to trust the coordinator's
| init(unreadableWallet: Void, now: Date = Date()) { | ||
| id = UUID() | ||
| occurredAt = now | ||
| kind = .keychain | ||
| codes = ["Keychain:unreadableWalletInventory"] |
There was a problem hiding this comment.
🟡 Suggestion: Add direct coverage for the unreadable-wallet failure initializer
The new .keychain failure kind and init(unreadableWallet:) are exercised indirectly by the lifecycle coordinator test through their kind and diagnostic code, but WalletPreparationFailureTests does not verify the initializer's presentation copy or diagnostic report. A focused test should construct this failure with a fixed date and assert its kind, Keychain:unreadableWalletInventory code, generic recovery title/message, and report category/code so later changes cannot silently regress the new failure presentation.
source: gemini-3.8-flash-high (phase1-reviewer: general, security-auditor)
There was a problem hiding this comment.
Resolved (re-reviewed at b662446b): The added WalletPreparationFailureTests coverage directly verifies the unreadable-wallet initializer's keychain category, diagnostic code, generic user-facing copy, and diagnostic report.
…active' into fix/unreadable-wallet-inventory-card
The hold only began for pending legacy material, so with the migration already done an inventory that could not be read still reached setup: `hasAWallet` is false on "unknown" by design, and nothing else looked. The root controller now reads the tri-state once and hands the launch to the hold for "unknown" as well, whose card offers Try Again instead of Create/Recover over a wallet the read missed. The hold's verdict is no longer re-read before presenting the wallet. Direct coverage for the unreadable-inventory failure: kind, code, the generic copy and the diagnostic report. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The tri-state launch decision correctly prevents setup from being offered when wallet inventory is unreadable, and both prior findings are fixed with direct coverage and single-snapshot routing. One blocking lifecycle gap remains: when inventory recovery later finds an existing wallet, the hold dismisses and presents the wallet without restarting the stopped SDK runtime.
🔴 1 blocking
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: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — This is a cross-cutting behavioral change spanning wallet lifecycle state, launch/root navigation, failure modeling, production wiring, and tests, but it does not alter funds movement, key handling, cryptography, consensus, networking, or storage migrations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— security-auditor (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 35% left, 5h 0% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort high); 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 `DashWallet/Sources/Infrastructure/SwiftDashSDK/WalletLifecycleTransitionState.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/WalletLifecycleTransitionState.swift:495-498: Restart the wallet runtime when inventory recovery releases the hold
On an already-migrated installation, the initial `SwiftDashSDKWalletRuntime.refresh` can reach its `.unknown` wallet-presence branch and return after teardown, leaving the host and SPV runtime stopped. When the keychain becomes readable, `deliverIfWalletPresent()` calls `deliver(hasWallet: true)`, which clears the launch hold and presents the wallet, but neither that path nor the completion callback requests a runtime start. The polling watcher only rechecks presence, and a Try Again migration run exits at the existing done sentinel without emitting a wallet-material-change notification. The result is a visible wallet UI backed by a stopped runtime until an unrelated restart or sync action occurs. Request an idempotent start through the existing runtime lifecycle boundary when successful inventory recovery delivers the wallet, and add coverage for startup returning `.unknown` followed by both polling recovery and Try Again.
| private func deliverIfWalletPresent() -> Bool { | ||
| guard completion != nil, dependencies.hasWallet() else { return false } | ||
| guard completion != nil, dependencies.walletPresence() == .present else { return false } | ||
| deliver(hasWallet: true) | ||
| return true |
There was a problem hiding this comment.
🔴 Blocking: Restart the wallet runtime when inventory recovery releases the hold
On an already-migrated installation, the initial SwiftDashSDKWalletRuntime.refresh can reach its .unknown wallet-presence branch and return after teardown, leaving the host and SPV runtime stopped. When the keychain becomes readable, deliverIfWalletPresent() calls deliver(hasWallet: true), which clears the launch hold and presents the wallet, but neither that path nor the completion callback requests a runtime start. The polling watcher only rechecks presence, and a Try Again migration run exits at the existing done sentinel without emitting a wallet-material-change notification. The result is a visible wallet UI backed by a stopped runtime until an unrelated restart or sync action occurs. Request an idempotent start through the existing runtime lifecycle boundary when successful inventory recovery delivers the wallet, and add coverage for startup returning .unknown followed by both polling recovery and Try Again.
source: gpt-6-astra (phase2-reviewer: general)
There was a problem hiding this comment.
Resolved (re-reviewed at 98dcf1c2): Your wallet-delivery callback now invokes SwiftDashSDKWalletRuntime.startIfReady() after completing root presentation and releasing the hold-owned phase, using the existing serialized refresh path and readiness-based rebuild suppression. The passing regression tests cover late inventory recovery, Try Again, and excluding setup delivery from runtime-start requests.
… link without the wallet gate Three findings on ab835b9. - A read that answers "unknown" — a keychain failure while the app is active, or an unreadable selectable-material read — no longer reaches setup: the root controller reads the tri-state once (`DWRootProtocol.walletPresence`) and hands `.unknown` to the launch hold, and the hold itself takes one tri-state read — only a definite `.absent` goes on to the legacy-material question and setup, `.unknown` is the blocking card (`Keychain:unreadableWalletInventory`) whose Try Again re-reads and whose late-success watcher completes the launch. The hold's verdict is not re-read before presenting the wallet. This is #1153's card, carried here so this PR is safe to merge on its own. - A link kept during a deferred launch is replayed to the initial controller directly, not through `application:openURL:options:`, whose wallet gate reads presence while the just-enqueued key migration has not landed an upgrader's wallet and dropped the link. The root controller keeps a Dash URL while no wallet is presented (hold, card, setup), as it already kept invitations, and handles it after the unlock, after the hold delivers, or after setup finishes. - The two launch log lines carry only the link's scheme (a universal link its host): invitation links carry a bearer key. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…active' into fix/unreadable-wallet-inventory-card
… it could not read at launch A launch whose runtime start saw an unreadable inventory left the runtime stopped. When the keychain became readable, the hold's late-success watcher or Try Again delivered the wallet and presented it — but nothing started the runtime: Try Again's migrator re-run returns at the done sentinel without a material change, and the watcher only re-reads presence. The wallet UI sat on a stopped runtime. The hold's `deliver(hasWallet: true)` now calls a `walletDelivered` dependency, wired to the idempotent `SwiftDashSDKWalletRuntime.startIfReady()` (the refresh elides a rebuild when Core is already up, so a wallet the migrator just delivered is not restarted). Both release paths run under the card in the foreground, after the launch decision was taken. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Independently reviewed the complete base-to-head diff and relevant launch, root-selection, and runtime-start paths at 98dcf1c; all three prior findings are addressed, with no remaining in-scope findings. The focused wallet-preparation harness passed all 49 tests, and the diff whitespace check passed. Full iOS compilation and simulator smoke remain unverified: the pinned DashUIKit revision requires Swift tools 6.3, while the installed Xcode provides Swift 6.1.2.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
lowbygpt-6-astra(effort low) — The diff adds a small, contained wallet-delivery callback that starts the runtime after launch completion, with focused tests, without changing key handling, migration logic, or funds movement. - Phase 1 reviewers:
gemini-3.8-flash-high— general (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— security-auditor (completed, effort high); agentphase1-reviewer - Phase 1 model:
gemini-3.8-flash-high— antigravity quota: weekly 28% left, 5h 66% left - 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 medium); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort medium); agentphase2-reviewer,gpt-6-astra— general (completed, effort medium); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort medium); 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.
… an invitation delivered during it An inventory that cannot be read at launch leaves the runtime stopped: its refresh returns on "unknown", and the card that the hold shows offers Try Again. When the read recovers, the hold delivered the wallet to the UI but asked nothing to start, so the main screen opened over a runtime that never came up. The hold now takes a `walletDelivered` dependency, wired to `SwiftDashSDKWalletRuntime.startIfReady()`, called once the wallet is delivered — never on the setup outcome. (Brought over from #1153, which becomes an empty delta against this branch.) An invitation that reaches the root controller while the launch hold is still deciding used to go to onboarding's storage, which only a finished setup reads: with the hold ending in a presented wallet, the invitation was stranded. The root controller now keeps it with the other deferred links while the hold is pending, moves an invitation that arrived before its view loaded out of onboarding's storage when the hold delivers a wallet, and hands a kept invitation to onboarding only on the hold's definite "no wallet" verdict. The drain after the unlock is the existing one. Tests: the coordinator test asserts one runtime-start request per delivered wallet and none for setup; the python harness adds the unknown → stopped runtime → readable → start-requested path against the real funnel. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Closing as superseded: this PR's changes are now part of #1151. The unreadable-inventory card, the single-read root decision and the failure initializer came in with d8ac3a0, and the runtime start on the hold's delivery (98dcf1c here) with 3be57b4. Merging this branch into #1151's would change nothing. 🤖 Generated with Claude Code |
Issue being fixed or feature implemented
Stacked on #1151 (base branch
fix/defer-launch-decision-until-active). With the launch decided only once the app is active, a "no wallet" answer at launch can still come from a keychain failure that is not the lock (the daemon refusing, an access error). The #1144 launch hold askedhasWallet(a Bool) and, with the migration already done, released into setup onfalse— Create/Recover over a wallet the read missed. Split out of #1147 (superseded).What was done?
LegacyWalletMigrationLaunchCoordinator: thehasWalletdependency becomes one tri-statewalletPresenceread (WalletEnvironment.WalletPresencefrom fix(wallet): decide the launch only once the app is active #1151). Every verdict derives from a single snapshot:.presentpresents the wallet, only a definite.absentgoes on to the legacy-material question and setup, and.unknownis a failure to show — fix(wallet): hold the launch on a failed legacy wallet import instead of offering setup #1144's blocking card with Try Again,WalletPreparationFailure(unreadableWallet:),Kind.keychain, codeKeychain:unreadableWalletInventory. Try Again re-reads; the late-success watcher (material-change notification plus the 5 s fallback) completes the launch once a read works.WalletPreparationFailure: thekeychainkind and theunreadableWalletinitializer (no status in the attachment; the status is in the app log).WalletEnvironment.walletPresence.How Has This Been Tested?
dashpayscheme, Debug, arm64 simulator, Xcode 27 (local-only-ld64→-ld_classic) — built successfully.SwiftDashSDKCoreLifecycleTests+BackgroundRefreshCoordinatorTests: 107 run, 4 failures — the 2 known pre-existing balance-message tests (testDuffDenominatedInsufficientBalanceMessageNamesTheBalance,testShieldedInsufficientBalanceMessageUsesSpendableAmount, each counted twice), untouched by this change.python3 scripts/test_wallet_preparation.py(WalletLifecycleTransitionStateTests): 46/46. New: an unreadable inventory shows the card (kindkeychain, codeKeychain:unreadableWalletInventory) and never setup, and a later successful read completes the launch; successive unknown, unknown, present reads with migration done never release into setup.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code