Skip to content

fix(wallet): serialize deep-link handling - #1159

Open
romchornyi wants to merge 27 commits into
fix/defer-launch-decision-until-activefrom
fix/serialize-deep-links
Open

romchornyi wants to merge 27 commits into
fix/defer-launch-decision-until-activefrom
fix/serialize-deep-links

Conversation

@romchornyi

@romchornyi romchornyi commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Fixes #1158.

Pending deep links lived in five places with five drain rules — two single slots in the root controller (first link of a kind wins; the unlock handled one and cleared both), onboarding's invitation store, the deferred-launch replay's one-per-kind buffer and the initial controller's two slots — and application:openURL: dropped a live link outright while no wallet was present (a link opened during the launch-time migration vanished with no log line). Two links handed over in one pass presented on top of each other: the scanner over the invitation's alert — a Debug assert in DWBasePayViewController, a refused presentation in Release.

Stacked on #1151 (fix/defer-launch-decision-until-active); merge after it.

Scope

Scope frozen at 42de471 (41ad7bb and f537806 fix two regressions this PR introduced in DashConnect: re-entrant replacement, and a refused newcomer settling the request on screen). This PR serializes deep-link handling:

  • one queue owns every pending link;
  • a link is dispatched only when a wallet is presented, the hierarchy is attached, the device is unlocked and no launch hold is pending;
  • the queue advances on the handler's own completion, with a 45 s watchdog and dispatch tokens;
  • before the next link, the real presentation owner is dismissed;
  • payment state is per operation: the previous amount step is removed and its callbacks are bound to their operation, and replacement cannot re-enter itself;
  • the backlog is bounded.

Known follow-ups are tracked in #1160 and are not part of this PR:

  • whether a queued link should wait while a manual payment is open;
  • a liveness signal so the watchdog does not give up on slow BIP70/BIP73 requests;
  • presentation-level test seams for PaymentController, the DashConnect sheets and the setup controller.

Further review findings of that kind will be answered with a pointer to #1160.

What was done?

One queue, owned by the root controller — DeepLinkQueue (DashWallet/Sources/UI/RootNavigation/DeepLinkQueue.swift), pure and unit-tested:

  • every entry point enqueues: application:openURL:, a universal link (continueUserActivity:), the deferred-launch replay (LaunchDecision), the initial controller's kept links; every link is kept in arrival order — no slot per kind;
  • a link is handed over only when the wallet is on screen, the device is unlocked (no lock screen due, none displayed) and no launch hold is pending; dispatchNextLinkIfReady is called wherever one of those changes (a link arrives, the hold delivers, the unlock completes, setup finishes, a link's screen settles);
  • one link at a time: MainTabbarController.performScanQRCodeAction(completion:), performPay(to:completion:), openDashConnect(_:completion:) and handleDeeplink(_:definedUsername:completion:) dismiss whatever is presented with a completion, perform, and report back once the screen they presented (or pushed) has finished its transition; the queue hands the next link over only then;
  • a walletless install keeps its invitation (and any URL) in the same queue through setup and hands them over once setup has presented the wallet — invitationSetup and the separate store are gone from the root controller;
  • the wallet gate (DWURLParser.allowsURLHandling, the early return in the app delegate) is removed; malformed links still get the "Not a Dash URL" alert;
  • the pre-root holders keep every link in order too: LaunchDecision.pendingLinks replays all of them, the initial controller's deferredLinks hands all of them to the root at its creation.

Removed: deferredURLToProcess, deferredDeeplinkToProcess, invitationSetup, processDeferredLinks and the follow-up poll from DWAppRootViewController; pendingURL / pendingUserActivity from LaunchDecision; deferredDeeplink / deferredURL from DWInitialViewController.

How Has This Been Tested?

  • DeepLinkQueueTests (new): arrival order and keeping every link, one-at-a-time until the screen reports back, gating on wallet / unlock / launch hold, the walletless invitation waiting through setup, an empty queue, link classification. testLinksDeliveredWhileDeferredAreKeptAndReplayedOnce updated for the ordered replay.
  • Xcode unit tests (dashpay scheme, iPhone 17 / iOS 26.5): 115 tests in the SwiftDashSDKCoreLifecycleTests + BackgroundRefreshCoordinatorTests + DeepLinkQueueTests set, 4 failures = the two known pre-existing balance-message tests (each counted twice), same as on the base branch; scripts/test_wallet_preparation.py: 50/50.
  • DEBUG harness (local-only branch, simulated locked launch with an un-migrated legacy fixture):
    • lock screen on, dashpay://invite delivered during the locked phase and dashwallet://scanqr inside the migration hold, PIN entered by the harness once the lock screen is up → both kept, the invitation handled first, the scanner once the invitation's screen settled; no assert, no crash report;
    • lock screen off, dash: payment link delivered 0.3 s after the activation, inside the migration hold → handled once the hold delivered the wallet (the Send screen opens).

Breaking Changes

None. MainTabbarController's link actions now take a completion; their only caller is the root controller.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Pending deep links lived in five places with five drain rules — two
single slots in the root controller (first link of a kind wins, an unlock
handled one and cleared both), onboarding's invitation store, the
deferred-launch replay's one-per-kind buffer and the initial controller's
two slots — and `application:openURL:` dropped a live link outright while
no wallet was present. Two links handed over in one pass then presented
on top of each other: the scanner over the invitation's alert, a Debug
assert in `DWBasePayViewController`, a refused presentation in Release.

One queue now, owned by the root controller (`DeepLinkQueue`, pure and
unit-tested): every entry point enqueues — a live URL, a universal link,
the deferred-launch replay, the initial controller's kept links — and
every link is kept in arrival order. The queue hands one link over only
when the wallet is on screen, the device is unlocked and no launch hold
is pending, and the next only once the previous link's screen has
finished its transition: `MainTabbarController`'s link actions dismiss
with a completion, perform, and report back when the presented (or
pushed) screen has settled. A walletless install keeps its invitation
in the same queue through setup and hands it over once setup has
presented the wallet — no separate store. The wallet gate in the app
delegate is gone; malformed links still get the "Not a Dash URL" alert.

The pre-root holders keep every link in order too: `LaunchDecision`
replays all of them, the initial controller hands all of them to the
root at its creation.

Fixes #1158.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 395d3e86-36d3-41b5-95bd-1479e8a0afad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Final review complete — no blockers (commit 2a5fb16) · triage: critical

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review — Phase 1 blocker gate

The ordered queue addresses the previous single-slot link loss, but its completion boundary does not cover asynchronous or sync-deferred presentations, so links can still overlap or overwrite a deferred invitation. The queue also introduces an unbounded backlog of externally supplied links. Verification at c3552b0 used source tracing and a successful Swift importer type-check; no app build or end-to-end smoke was performed.

Validated blockers were found by the Phase-1 review and confirmed by a fresh verifier. Phase 2 is deferred until a fresh same-head revalidation clears the blocker gate.

🔴 1 blocking | 🟡 1 suggestion(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: security-auditor); final verifier: gpt-6-astra (agent: astra-gate-verifier, role: verifier)

  • Triage: normal by gpt-6-astra (effort low) — This cross-cutting change serializes deep-link delivery across launch, unlock, onboarding, and UI transitions, but does not itself change funds movement, key handling, storage migrations, or another qualifying critical surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — verifier; agent astra-gate-verifier
  • Phase 2 reviewers: not run (deferred by blocker gate)
🤖 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/Main/MainTabbarController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Main/MainTabbarController.swift:585-596: Keep the queue busy until deferred link handling actually presents its screen
  This snapshots only transitions already running when the action returns. A payment with an amount starts an asynchronous Task through WalletSendService.prepareStandardSendForConfirmation, and a BIP70 request waits for fetchAndVerify before PaymentController presents its confirmation. With no transition yet, completion advances the queue on the next main-queue turn; a following scanner can open before the first payment's authentication or confirmation arrives. Invitations have an additional deterministic failure: HomeViewController.handleDeeplink stores the invitation in its single invitationSetup property while sync is incomplete and returns without presenting. Two queued invitations are therefore marked finished and the second overwrites the first; the retained invitation is opened later by syncingActivityMonitorStateDidChange. DWURLRequestAction similarly advances immediately after starting authentication. These paths bypass the new serialization contract. Propagate an explicit completion from the actual asynchronous/deferred handler through presentation settlement, including cancellation and failure, rather than treating the absence of an immediate transition as completion. Add regression coverage for delayed payment preparation and multiple invitations before syncDone.

In `DashWallet/Sources/UI/RootNavigation/DeepLinkQueue.swift`:
- [SUGGESTION] DashWallet/Sources/UI/RootNavigation/DeepLinkQueue.swift:73-75: Bound the backlog of externally supplied deep links
  enqueue appends without a limit, replacing bounded per-kind slots with an arbitrarily large backlog. Links can accumulate behind the wallet, unlock, or launch gates. Unsupported URLs are especially persistent: DWAppRootViewController.performURL advances the queue only when the user taps OK, so a burst delivered by another app can leave the user clearing one alert per queued URL before their own link is handled. Define a bounded admission or overflow policy and apply it consistently to the root queue and the pre-root pendingLinks/deferredLinks buffers. Include a burst-input test so the memory and repeated-alert behavior stay bounded.

Comment on lines +585 to +596
private func settlePresentation(then completion: @escaping () -> Void) {
let candidates: [UIViewControllerTransitionCoordinator?] = [
presentedViewController?.transitionCoordinator,
selectedViewController?.transitionCoordinator,
(selectedViewController as? UINavigationController)?.topViewController?.transitionCoordinator,
]
if let coordinator = candidates.compactMap({ $0 }).first {
coordinator.animate(alongsideTransition: nil) { _ in completion() }
} else {
DispatchQueue.main.async(execute: completion)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Keep the queue busy until deferred link handling actually presents its screen

This snapshots only transitions already running when the action returns. A payment with an amount starts an asynchronous Task through WalletSendService.prepareStandardSendForConfirmation, and a BIP70 request waits for fetchAndVerify before PaymentController presents its confirmation. With no transition yet, completion advances the queue on the next main-queue turn; a following scanner can open before the first payment's authentication or confirmation arrives. Invitations have an additional deterministic failure: HomeViewController.handleDeeplink stores the invitation in its single invitationSetup property while sync is incomplete and returns without presenting. Two queued invitations are therefore marked finished and the second overwrites the first; the retained invitation is opened later by syncingActivityMonitorStateDidChange. DWURLRequestAction similarly advances immediately after starting authentication. These paths bypass the new serialization contract. Propagate an explicit completion from the actual asynchronous/deferred handler through presentation settlement, including cancellation and failure, rather than treating the absence of an immediate transition as completion. Add regression coverage for delayed payment preparation and multiple invitations before syncDone.

source: muse-spark-1.3-contributor (phase1-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on all three. Commit 99aa81b5c (pushed) propagates each handler's own completion instead of sampling for a transition:

  • payment and BIP70: PaymentController.performPayment(with:presentationSettled:) settles once when the first screen has presented — the amount step's push (with its transition coordinator), the confirmation's present completion, the error alert's present completion — or when preparation ends without one (paymentProcessorDidCancelTransactionSigning, a nil-error failure, a send that needed no confirmation); DWBasePayViewController.performPayToURL:completion: and MainTabbarController.performPay(to:completion:) pass it through;
  • invitations before sync-done stay in the queue: DeepLinkQueue.takeNext gains invitationsReady, fed from HomeViewController.isReadyForInvitations (sync done) through the tab controller; the root re-asks on the sync monitor's state change; a waiting invitation does not hold up URLs behind it. Home's invitationSetup slot and DWInvitationSetupState are removed; handleDeeplink(_:definedUsername:completion:) settles on the alert's presentation or the redeem screen's push;
  • the address request: DWURLRequestHandler.handleURLRequest:completion: completes once authentication resolved (granted, denied or cancelled) and the reply was handed to the system;
  • the scanner settles on its present completion (performScanQRCodeActionWithCompletion:); DashConnect on the More stack's push transition.
    Coverage at the queue level: testADelayedPaymentPreparationKeepsTheQueueBusy (a taken link keeps the queue busy however often the owner asks, until it reports) and testInvitationsWaitForSyncInOrderWithoutBlockingURLs (two invitations before sync-done are both kept and handed over in order once ready, a URL behind them goes through meanwhile). Harness (lock screen on, invitation during the locked phase + dashwallet://scanqr inside the migration hold, PIN entered by the harness; and lock off with a dash: link inside the hold): both links are queued and kept through the hold (invitations ready 0), the URL is handed over and its screen opens, the invitation stays queued because the fixture wallet never reaches sync-done in the harness — which is the new gating at work, not a drop; no assert, no crash report. A sync-done-gated hand-over of the invitation itself is covered at the queue level only (the harness fixture never syncs).

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 99aa81b5): Your completion chain now waits for payment/BIP70 presentation or preparation termination and address-request authentication resolution; invitations remain queued until syncDone instead of overwriting Home's single slot. I verified those paths and the passing queue regressions; the remaining DashConnect asynchronous handoff is reported separately because it uses a different handler.

Comment on lines +73 to +75
@objc func enqueue(_ link: DeepLink) {
pending.append(link)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Bound the backlog of externally supplied deep links

enqueue appends without a limit, replacing bounded per-kind slots with an arbitrarily large backlog. Links can accumulate behind the wallet, unlock, or launch gates. Unsupported URLs are especially persistent: DWAppRootViewController.performURL advances the queue only when the user taps OK, so a burst delivered by another app can leave the user clearing one alert per queued URL before their own link is handled. Define a bounded admission or overflow policy and apply it consistently to the root queue and the pre-root pendingLinks/deferredLinks buffers. Include a burst-input test so the memory and repeated-alert behavior stay bounded.

source: muse-spark-1.3-contributor (phase1-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same commit: DeepLinkQueue.capacity = 10 — a burst keeps the newest ten (enqueue reports queuedEvictingOldest, the root logs the count); a link identical to the one queued just before it is dropped (droppedDuplicate); an unsupported URL while one is already pending is dropped, so a burst shows one "Unsupported URL" alert (droppedUnsupportedCoalesced); LaunchDecision.pendingLinks and DWInitialViewController.deferredLinks keep the newest ten as well (the replay logs how many were dropped). testABurstIsBoundedDeduplicatedAndCoalesced and testLinksDeliveredWhileDeferredAreBoundedToTheNewest cover it.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 99aa81b5): Your capacity-ten policy now bounds the root queue and both pre-root buffers, and I verified the duplicate/unsupported admission rules and passing burst regression. Unsupported coalescing covers pending entries rather than an alert already in flight, but the backlog identified in this thread is bounded.

…and bound the backlog

The queue advanced when no transition was running at the moment the
handler returned. Wrong for handlers that present later: a payment with
an amount (the send is prepared in a task) and a BIP70 request (fetched
and verified first) show their confirmation afterwards; an invitation
before the sync was done was parked in the home screen's single slot —
two queued invitations were both "finished", the second overwriting the
first; an address request advanced as soon as authentication started.

Every handler now reports through its own completion: the payment
controller settles once its first screen has presented (amount step,
confirmation, error alert) or preparation ended without one (cancelled,
silent failure); the scanner and the invitation alert settle on their
presentation completion, the redeem screen on its push; the address
request once authentication resolved and the reply was handed to the
system. Invitations before sync-done stay in the queue: the queue hands
one over only when the home screen reports it is ready (sync done), asks
again on the sync state change, and lets URLs behind a waiting
invitation through. The home screen's invitation slot is gone.

The backlog is bounded: at most ten links (a burst keeps the newest), a
link identical to the one queued just before it is dropped, unsupported
URLs collapse into one alert per burst; the deferred-launch replay and
the initial controller keep the newest ten as well.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The two prior findings are fixed, but pre-attachment dispatch and DashConnect's early completion still violate the new serialization contract. Validation passed nine exact-source queue tests and all 50 wallet-preparation checks; a focused UIKit simulator experiment confirmed the attachment failure and refuted the reported modal-ownership collision. Full-app validation remains incomplete: the pinned DashUIKit manifest requires Swift tools 6.3, while the installed toolchain provides 6.1.

🔴 2 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: normal by gpt-6-astra (effort low) — This is a cross-cutting, intricate change to deep-link queuing, launch gating, and UI completion sequencing, but the described diff does not itself change funds movement, coin selection, cryptography, key handling, consensus, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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:293-296: Wait for root attachment before draining pre-root links
  This drain runs in viewDidLoad, before the new root is attached to a window. On a reinstall with the keychain-backed lockScreenDisabled setting retained, open a scanner link during onboarding and then choose Keep Wallets: createRootController transfers the link before DWContainerViewController loads the root's view and attaches it. The walletPresented check already passes because the main controller is the root's current child, so the queue takes the scanner link and presents from an unattached hierarchy. A focused UIKit simulator experiment reproduced this ordering: the presentation completion never ran, even after attachment. Consequently isDispatching remains true and subsequent links cannot drain. Require an attached presentation hierarchy before taking a link, and retry from viewDidAppear or the container's completed transition.

In `DashWallet/Sources/UI/Main/MainTabbarController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Main/MainTabbarController.swift:533-536: Wait for DashConnect request resolution before releasing the queue
  DashConnect completion still tracks navigation rather than the asynchronous request handler. On testnet, when Connections is already visible, openDashConnectNow calls connections.handle(uri:), which starts ConnectionsViewModel.onQRScanned's Task and awaits parseQR and makeConnectionRequest. No push occurs, so settle releases the queue on the next main-loop turn while resolution is still pending. Two queued dash-key links can therefore increment requestGeneration twice; the first result is discarded by the generation check before its approval sheet appears. A following scanner can likewise start before the delayed approval presentation. Propagate completion through the hosting controller and ViewModel to request resolution and presentation settlement, including refusal and error paths. Add a regression covering two queued links with a delayed metadata lookup.

Comment on lines +293 to +296
// Links the initial controller handed over before this view loaded: with
// the wallet on screen and no lock due they are handled now; otherwise
// the unlock, the hold's delivery or setup's completion hands them over.
[self dispatchNextLinkIfReady];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Wait for root attachment before draining pre-root links

This drain runs in viewDidLoad, before the new root is attached to a window. On a reinstall with the keychain-backed lockScreenDisabled setting retained, open a scanner link during onboarding and then choose Keep Wallets: createRootController transfers the link before DWContainerViewController loads the root's view and attaches it. The walletPresented check already passes because the main controller is the root's current child, so the queue takes the scanner link and presents from an unattached hierarchy. A focused UIKit simulator experiment reproduced this ordering: the presentation completion never ran, even after attachment. Consequently isDispatching remains true and subsequent links cannot drain. Require an attached presentation hierarchy before taking a link, and retry from viewDidAppear or the container's completed transition.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed: the viewDidLoad drain passed walletPresented before the root was in a window, the scanner presented from an unattached hierarchy, its completion never came and isDispatching stayed set. Commit ef4de8ba3 (pushed): DeepLinkQueue.takeNext gains attached — the root's own view and the main controller's view both in a window (viewIfLoaded.window != nil) — and the root asks again from viewDidAppear, so a link handed over at the root's creation (a scanner link opened during onboarding, then Keep Wallets) has its screen once the hierarchy is on screen. Safety net: every hand-over carries a dispatchToken; a watchdog fires 15 s later and, if that dispatch is still in flight with nothing presented or animating, ends it (logged) and asks the queue again — while something is on screen it re-checks; a handler's late report for a token the queue has moved past is ignored (dispatchDidFinish(token:) returns false). Tests: the attached gate in testNothingIsHandedOverWhileTheAppCannotActOnLinks, the token in testALateReportCannotFinishALaterDispatch. The Keep-Wallets attach case itself is not in the harness: it needs the carousel's Keep tap, which the harness cannot drive.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at ef4de8ba): Your attachment check now requires both the root and main controller views to be in a window before takeNext can consume a link, and viewDidAppear retries the drain. This addresses the pre-root handover defect; the gate and late-token tests cover those state changes, although they do not constitute an end-to-end Keep Wallets smoke test.

Comment on lines +533 to +536
self.openDashConnectNow(uri)
// A push on the More tab's stack, or a handoff to the screen
// already on top: settled with its transition, or at once.
self.settle(after: self.menuNavigationController?.navigationController?.transitionCoordinator, then: completion)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Wait for DashConnect request resolution before releasing the queue

DashConnect completion still tracks navigation rather than the asynchronous request handler. On testnet, when Connections is already visible, openDashConnectNow calls connections.handle(uri:), which starts ConnectionsViewModel.onQRScanned's Task and awaits parseQR and makeConnectionRequest. No push occurs, so settle releases the queue on the next main-loop turn while resolution is still pending. Two queued dash-key links can therefore increment requestGeneration twice; the first result is discarded by the generation check before its approval sheet appears. A following scanner can likewise start before the delayed approval presentation. Propagate completion through the hosting controller and ViewModel to request resolution and presentation settlement, including refusal and error paths. Add a regression covering two queued links with a delayed metadata lookup.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: with Connections already on top, handle(uri:) started the view model's task and nothing was pushed, so the queue moved on at once and a second dash-key: link discarded the first approval. Same commit: the completion travels through DashConnectHostingController.handle(uri:completion:) (and the push initializer) into ConnectionsViewModel.onURIReceived(_:settled:), which settles once — when the approval sheet is published (pendingRequest set after the metadata lookup), on a refusal (a request already on screen, a state transition in progress), on an error, when a state transition completes, when the feature is unavailable, or when a newer request supersedes the one still resolving (it will publish nothing). Regression, view-model level with a fake whose metadata lookup waits for the test: testTwoQueuedLinksWithADelayedLookupSettleInTurnAndKeepTheFirstApproval — the first link does not settle until its sheet is published, the second (handed over only then) is refused at once and the first approval stays on screen with no second lookup; plus testASupersededRequestSettlesSoTheQueueIsNotHeldByIt and testAnUnavailableFeatureSettlesAtOnce.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at ef4de8ba): Your completion now reaches ConnectionsViewModel through both the existing-screen and pushed-screen paths, and the delayed lookup publishes pendingRequest before settling; refusal preserves the first approval. The added regression covers that ordering, so the original immediate-release defect is fixed; the new watchdog's independent early-release path is reported separately.

…DashConnect on its request, and never let a lost completion wedge the queue

The pre-root drain ran in `viewDidLoad`, before the root controller was
in a window: a scanner link opened during onboarding on a reinstall
that kept the lock screen off passed every gate, the scanner was
presented from an unattached hierarchy, its completion never came and
the queue stayed busy forever. The queue now also requires the owner's
hierarchy — this controller and the main controller's view — to be in
a window, and `viewDidAppear` asks again. Behind that, a watchdog: 15 s
after a hand-over with nothing presented or animating, the dispatch is
ended and the queue asked again; every dispatch carries a token, so a
handler's late report cannot end a later link's dispatch.

DashConnect's completion tracked navigation, not the request: with the
Connections screen already on top nothing was pushed and the queue moved
on at once, a second `dash-key:` link bumped the request generation and
the first approval was discarded. The completion now travels through the
hosting controller into `ConnectionsViewModel.onURIReceived(_:settled:)`
and settles when the approval sheet is published, on a refusal or an
error, when a state transition completes, or when a newer request
supersedes the one in flight.

Tests: the attached gate and the token in `DeepLinkQueueTests`; a view
model fake with a delayed metadata lookup shows the first link keeping
the queue busy until its sheet is published and the second being refused
without touching the first approval.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Preliminary review — Phase 1 blocker gate

Verified head ef4de8b: the four prior findings are addressed, but the new invitation-readiness accessor introduces a non-DASHPAY compilation error. The watchdog also permits overlapping handlers during slow asynchronous preparation. The separate claim that tab-level dismissal misses the home modal was refuted by an isolated UIKit simulator experiment; this verification did not include a full wallet build or end-to-end wallet smoke test.

Validated blockers were found by the Phase-1 review and confirmed by a fresh verifier. Phase 2 is deferred until a fresh same-head revalidation clears the blocker gate.

🔴 1 blocking | 🟡 1 suggestion(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: security-auditor); final verifier: gpt-6-astra (agent: astra-gate-verifier, role: verifier)

  • Triage: normal by gpt-6-astra (effort low) — This is a large, cross-cutting change to deep-link queuing, launch gating, and UI completion sequencing, but the described diff does not change funds movement, coin selection, key handling, cryptography, consensus, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — verifier; agent astra-gate-verifier
  • Phase 2 reviewers: not run (deferred by blocker gate)
🤖 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/Main/MainTabbarController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Main/MainTabbarController.swift:501-505: Unguarded invitation-readiness accessor breaks non-DASHPAY builds
  This new accessor is compiled in both app targets, but HomeViewController.isReadyForInvitations is declared only inside #if DASHPAY. Without DASHPAY, the member reference therefore cannot compile. This is a newly introduced error, independent of the documented pre-existing dashwallet build problems. Keep the Objective-C-visible accessor available in both configurations because DWAppRootViewController calls it unconditionally, and conditionally compile its body. Returning true without DASHPAY is sufficient because DeepLink classifies every link as a non-invitation in that configuration.

In `DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m`:
- [SUGGESTION] DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:188-197: Watchdog can release the queue during slow but healthy async preparation
  The watchdog treats the absence of a presented controller or root transition as evidence that the handler can be abandoned, but asynchronous preparation can still be running. A concrete case is BIP70: PaymentProtocolTransport allows a 30-second request timeout, while this watchdog releases the dispatch after 15 seconds without cancelling or invalidating the fetch. With a scanner link queued behind it, the scanner can open at 15 seconds and the original BIP70 callback can subsequently present its confirmation through PaymentController.topController(). The dispatch token prevents a late completion from finishing another dispatch; it does not prevent the old handler from presenting UI. Explicit approval is still required, but this reintroduces overlapping financial prompts. Track handler liveness or cancel and invalidate the abandoned handler before advancing, and add a regression where preparation exceeds the watchdog interval.

Comment on lines +501 to 505
/// Whether the home screen can take an invitation now (sync done).
@objc
public func performScanQRCodeAction() {
dismiss(animated: false, completion: nil)
selectedIndex = MainTabbarTabs.home.rawValue
homeController?.performScanQRCodeAction()
public var isReadyForInvitations: Bool {
homeController?.isReadyForInvitations ?? false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Unguarded invitation-readiness accessor breaks non-DASHPAY builds

This new accessor is compiled in both app targets, but HomeViewController.isReadyForInvitations is declared only inside #if DASHPAY. Without DASHPAY, the member reference therefore cannot compile. This is a newly introduced error, independent of the documented pre-existing dashwallet build problems. Keep the Objective-C-visible accessor available in both configurations because DWAppRootViewController calls it unconditionally, and conditionally compile its body. Returning true without DASHPAY is sufficient because DeepLink classifies every link as a non-invitation in that configuration.

Suggested change
/// Whether the home screen can take an invitation now (sync done).
@objc
public func performScanQRCodeAction() {
dismiss(animated: false, completion: nil)
selectedIndex = MainTabbarTabs.home.rawValue
homeController?.performScanQRCodeAction()
public var isReadyForInvitations: Bool {
homeController?.isReadyForInvitations ?? false
}
/// Whether the home screen can take an invitation now (sync done).
@objc
public var isReadyForInvitations: Bool {
#if DASHPAY
return homeController?.isReadyForInvitations ?? false
#else
return true
#endif
}

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, HomeViewController.isReadyForInvitations lives inside Home's #if DASHPAY block. Commit 9605b8496 (pushed) keeps the @objc accessor in both configurations with the guard inside: DashPay → Home's answer, otherwise true (no invitations to wait for). I went through everything rounds 13–14 added for other DashPay-only symbols used unconditionally: DeepLink's classifier calls DWInvitationLinkNormalizer under #if DASHPAY (else false); the root's handleDeeplink:, its invitation branch in dispatchNextLinkIfReady and MainTabbarController.handleDeeplink(_:definedUsername:completion:) are inside #if DASHPAY; AppDelegate's continueUserActivity: and the invitation branch of the replay are inside #if DASHPAY; DWURLRequestHandler, PaymentController, DWBasePayViewController, DeepLinkQueue, LaunchDecision, DWInitialViewController and the DashConnect files (both synchronized folders are in both targets) use nothing DashPay-only; the tests guard their invitation classification with #if DASHPAY. Compile check of the dashwallet scheme (Debug, simulator, WATCHOS_DEPLOYMENT_TARGET=9.0 and SwiftLint/SwiftFormat off the PATH to get past the phases that stop it before compilation): it does not build on this branch's base either — the target's Swift flags carry DASHPAY in every configuration (SWIFT_ACTIVE_COMPILATION_CONDITIONS / -DDASHPAY) while the DashPay-only files are not members, so #if DASHPAY code in it references files it does not have: Transaction.swift/TxDetailModel.swift (DashPayPaymentTxLookup), TxDetailCells.swift, HomeView.swift (JoinDashPayViewModel), UsernameRequestStatusScreen.swift (TemporaryUsernameFieldModel) — none of them touched here — and, for the same reason, DeepLinkQueue.swift's guarded DWInvitationLinkNormalizer call. The ObjC side did not get compiled there (the Swift module failed first). The accessor and the guards are correct against the flag as it would be set for a non-DashPay build; making that target green is the project-level flag/membership fix, outside this PR.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 9605b849): Your accessor now remains Objective-C-visible in both configurations while guarding Home's DashPay-only member reference inside #if DASHPAY and returning true otherwise. This fixes the specific introduced compilation defect without asserting that the entire dashwallet target builds.

Comment on lines +188 to +197
const BOOL busy = strongSelf.view.window.rootViewController.presentedViewController != nil ||
strongSelf.transitionCoordinator != nil;
if (busy) {
[strongSelf armLinkWatchdogForToken:token];
return;
}
DWLog(@"LINKS no screen appeared for the link handed over 15 s ago; releasing the queue");
[strongSelf.linkQueue dispatchDidFinishWithToken:token];
[strongSelf dispatchNextLinkIfReady];
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Watchdog can release the queue during slow but healthy async preparation

The watchdog treats the absence of a presented controller or root transition as evidence that the handler can be abandoned, but asynchronous preparation can still be running. A concrete case is BIP70: PaymentProtocolTransport allows a 30-second request timeout, while this watchdog releases the dispatch after 15 seconds without cancelling or invalidating the fetch. With a scanner link queued behind it, the scanner can open at 15 seconds and the original BIP70 callback can subsequently present its confirmation through PaymentController.topController(). The dispatch token prevents a late completion from finishing another dispatch; it does not prevent the old handler from presenting UI. Explicit approval is still required, but this reintroduces overlapping financial prompts. Track handler liveness or cancel and invalidate the abandoned handler before advancing, and add a regression where preparation exceeds the watchdog interval.

source: security-auditor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Same commit: the watchdog fires at 45 s, above the BIP70 transport's 30 s timeout, and the handler learns it was given up — isAbandoned, answered from the dispatch token (!isDispatching || dispatchToken != token), travels with the completion through MainTabbarController.performPay(to:completion:isAbandoned:) / openDashConnect(_:completion:isAbandoned:) into PaymentController.performPayment(with:presentationSettled:isAbandoned:) — asked right before the amount step, the confirmation and the error alert; an abandoned payment resets the processor, logs, settles and presents nothing — and into ConnectionsViewModel.onURIReceived(_:settled:isAbandoned:) — asked before the approval sheet, the purchase sheet, a success/error message. The scanner and the invitation screens present synchronously in the hand-over, so the watchdog can only fire on them once they are on screen, where it re-arms instead of releasing; the address request only opens a callback URL after authentication. Regression: testARequestTheQueueGaveUpPublishesNothingWhenItsLookupReturns — a DashConnect lookup outlasts the watchdog (the abandon flag flips while it runs), the lookup returns, no sheet and no message are published, the late report settles and the queue (which already moved on) ignores it; the queue side of "the queue advances and the late report is ignored" is testALateReportCannotFinishALaterDispatch. The payment controller's branch has no unit seam without DWPaymentProcessor; it follows the same dropIfAbandoned gate and was read through.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still applies (re-reviewed at 9605b849): Your abandonment gate handles a delayed payment followed by a scanner, but a following payment replaces that gate on Home's shared PaymentController, allowing the abandoned fetch's callback to use the replacement's predicate or nil. The 45-second threshold also does not bound BIP73's two sequential fetches; operation-scoped callback invalidation is still needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 99583e23): The fix no longer depends solely on increasing the timeout: the dispatch-bound abandonment predicate reaches payment and DashConnect presentation paths, and obsolete payment callbacks are rejected by processor identity and token. A preparation that outlasts the watchdog therefore cannot use the replacement operation's live predicate to present its result.

…up on present nothing

`MainTabbarController.isReadyForInvitations` read a Home property that
exists only with DashPay, so the dashwallet target did not compile. The
accessor stays in both configurations and answers "ready" without
DashPay, where there are no invitations to wait for.

The watchdog released a dispatch after 15 s when nothing was presented,
but a slow preparation — a BIP70 fetch has a 30 s timeout — was still
alive: the next link's scanner opened, and the old payment later put
its confirmation on top of it. The watchdog now fires at 45 s, above the
longest legitimate preparation, and the handler learns it was given up:
`isAbandoned`, answered from the dispatch token, travels with the
completion into `PaymentController` (asked before the amount step, the
confirmation and the error alert) and `ConnectionsViewModel` (asked
before the approval sheet, the purchase sheet and a message); an
abandoned handler resets, logs, settles and presents nothing.

Test: a DashConnect request whose lookup outlasts the watchdog publishes
no sheet when the lookup returns.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified head 9605b84: four prior findings are fixed, but payment callback ownership and DashConnect presentation settlement still break deep-link serialization. Independent UIKit/SwiftUI simulator experiments reproduced the DashConnect presentation race and refuted the reported tab-dismissal defect. All 10 isolated non-DASHPAY queue tests and 50 wallet-preparation checks passed; these checks do not constitute a full-app smoke test.

🔴 2 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: normal by gpt-6-astra (effort low) — This is an intricate, cross-cutting change to deep-link ordering, lifecycle gating, and UI completion handling, but the changes do not clearly alter funds movement, coin selection, cryptography, key handling, consensus, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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/Payment Controller/PaymentController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payment Controller/PaymentController.swift:90-93: Watchdog can release the queue during slow but healthy async preparation
  Home reuses one PaymentController, so starting payment B replaces payment A's abandonment predicate and settlement callback. DWPaymentProcessor.reset() clears input state but neither cancels the outstanding BIP70 fetch nor invalidates its callback. After the watchdog abandons A and dispatches B, A's eventual confirmation therefore checks B's live predicate—or nil after B settles—and is allowed to present. It can also invoke B's settlement callback while B is still preparing. Raising the watchdog to 45 seconds does not exclude this: PaymentProtocolTransport supports a BIP73 URI-list hop with two sequential 30-second requests, so two 25-second responses suffice. Explicit approval remains required, but an abandoned merchant request can introduce a stale financial confirmation into the replacement payment flow. Bind abandonment and settlement to each operation, and reject obsolete processor callbacks before they mutate state or present UI. Add regressions for A abandoned → B started → A returns, both before and after B settles.

In `DashWallet/Sources/UI/DashConnect/ConnectionsViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashConnect/ConnectionsViewModel.swift:208-210: Wait for DashConnect request resolution before releasing the queue
  The completion now waits for metadata resolution, but publishing pendingRequest does not complete the SwiftUI sheet's presentation. settle() synchronously reaches the root completion, which immediately dispatches the next link. With a scanner queued behind the request, afterDismissingPresented sees no presented controller yet, switches to Home, and presents the scanner before ConnectionsScreen processes its sheet binding. An independent iOS 18.6 UIKit/SwiftUI reproduction of this ordering confirmed that neither presenter had a modal immediately after publication; the scanner then completed presentation but disappeared, leaving the approval pending and neither modal attached. The purchase-sheet and alert branches also publish state and settle immediately. Keep UI-producing requests in flight until the presentation layer acknowledges their actual presentation transition, with immediate settlement reserved for genuine no-UI outcomes. Add a presentation-level regression for a resolved DashConnect request followed by a scanner; the ViewModel-only test cannot detect this race.

Comment on lines +90 to +93
public func performPayment(with input: DWPaymentInput, presentationSettled: @escaping () -> Void, isAbandoned: @escaping () -> Bool) {
self.presentationSettled = presentationSettled
self.isAbandoned = isAbandoned
performPayment(with: input)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Watchdog can release the queue during slow but healthy async preparation

Home reuses one PaymentController, so starting payment B replaces payment A's abandonment predicate and settlement callback. DWPaymentProcessor.reset() clears input state but neither cancels the outstanding BIP70 fetch nor invalidates its callback. After the watchdog abandons A and dispatches B, A's eventual confirmation therefore checks B's live predicate—or nil after B settles—and is allowed to present. It can also invoke B's settlement callback while B is still preparing. Raising the watchdog to 45 seconds does not exclude this: PaymentProtocolTransport supports a BIP73 URI-list hop with two sequential 30-second requests, so two 25-second responses suffice. Explicit approval remains required, but an abandoned merchant request can introduce a stale financial confirmation into the replacement payment flow. Bind abandonment and settlement to each operation, and reject obsolete processor callbacks before they mutate state or present UI. Add regressions for A abandoned → B started → A returns, both before and after B settles.

source: gpt-6-astra (phase2-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, including the BIP73 point — 45 s does not cover two sequential 30 s requests, so the watchdog cannot be the answer; the callback has to know which payment it belongs to. Commit 3f3cc3a7e (pushed): every performPayment is an operation — its own DWPaymentProcessor (no longer one shared instance), its own token from PaymentOperationGate (pure), its own settlement and isAbandoned. A processor callback is admitted only when its processor is the current operation's and the gate admits the token; an obsolete callback (A returning after B started, before or after B settled) mutates nothing, presents nothing and is logged (PAY a callback (…) from a payment this controller has moved past; ignored); starting B settles A's link, since A will show nothing. The confirm and amount screens drive the current operation's processor. Regressions at the gate level, since DWPaymentProcessor has no seam for a late callback: testAnObsoleteOperationsLateCallbackNeitherActsNorEndsTheNext (A abandoned → B started → A returns before B settled: not admitted, cannot end B; after B settled: not admitted either), testOnlyTheCurrentOperationIsAdmitted, testEndingIsOnce. The controller's use of the gate (processor identity + token) was read through; a controller-level test would need a real DWPaymentInput run through the processor against a wallet runtime, which the unit target does not have.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 99583e23): Your per-payment processor and token binding now rejects A's processor callbacks once B becomes current, before those callbacks can update output, present UI, or settle B. This closes the reported late-fetch scenario both before and after B settles; the remaining visible-screen ownership issue is distinct and covered in the new finding.

Comment on lines +208 to +210
pendingLoginRequest = request
pendingRequest = connectionRequest
settle()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Wait for DashConnect request resolution before releasing the queue

The completion now waits for metadata resolution, but publishing pendingRequest does not complete the SwiftUI sheet's presentation. settle() synchronously reaches the root completion, which immediately dispatches the next link. With a scanner queued behind the request, afterDismissingPresented sees no presented controller yet, switches to Home, and presents the scanner before ConnectionsScreen processes its sheet binding. An independent iOS 18.6 UIKit/SwiftUI reproduction of this ordering confirmed that neither presenter had a modal immediately after publication; the scanner then completed presentation but disappeared, leaving the approval pending and neither modal attached. The purchase-sheet and alert branches also publish state and settle immediately. Keep UI-producing requests in flight until the presentation layer acknowledges their actual presentation transition, with immediate settlement reserved for genuine no-UI outcomes. Add a presentation-level regression for a resolved DashConnect request followed by a scanner; the ViewModel-only test cannot detect this race.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: settle() ran synchronously on publish, the scanner was dispatched, and the sheet binding then fought it. Same commit: a UI outcome — the approval sheet, the purchase sheet, a message alert (the request refusal during a state transition, a completion message, an error) — now settles only when the presentation layer reports it on screen: ConnectionsViewModel.presentationDidAppear(), called from the sheet content's .onAppear and from the alert's message onAppear (the alert moved to the alert(_:isPresented:presenting:actions:message:) form so its content can report). Immediate settlement stays for genuine no-UI outcomes: a refusal shown on a sheet already up, supersession by a newer request, an unavailable feature, an abandoned request. A sheet that never appears is covered by the root watchdog (45 s with nothing presented → release; the handler's isAbandoned then publishes nothing). Regression at the view-model level: testTwoQueuedLinksWithADelayedLookupSettleInTurnAndKeepTheFirstApproval now asserts the link is still unsettled after pendingRequest is published and settles exactly once on presentationDidAppear(); testAnAppearanceNobodyWaitsForSettlesNothing covers an appearance with no link waiting. Not done: a presentation-level test with a hosting controller in a window (the unit target has no window host for SwiftUI sheets), and the harness run — DashConnect is testnet-only and the harness fixture is a mainnet wallet, so a dash-key: link there resolves to "feature unavailable" (no sheet) before the scanner; the sheet path is exercised by the view-model test only.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 99583e23): Your change removes the synchronous settlement immediately after publishing a UI outcome: approval, purchase, and message paths now wait for presentationDidAppear(), wired from ConnectionsScreen. This addresses the reported publish-before-presentation race in the source; the acknowledged absence of a hosting-controller regression still limits runtime evidence.

jeanpierreroma and others added 2 commits September 27, 2026 17:29
…tle a DashConnect link once its sheet is on screen

A screen keeps one `PaymentController`, so starting payment B replaced
A's abandonment predicate and link settlement while A's preparation —
a BIP70 fetch, a BIP73 hop of two 30 s requests — was still alive: A's
late confirmation checked B's predicate (or none), presented, and could
fire B's settlement. Every payment is now an operation with its own
processor, token, settlement and predicate; a processor callback is
admitted only for the current operation (`PaymentOperationGate`, pure),
an obsolete one mutates nothing, presents nothing and is logged, and
starting a payment settles the one it supersedes.

Publishing `pendingRequest` does not present the approval sheet, so the
Connections screen settled the link before the sheet was up and the next
link's scanner raced the sheet's binding. A UI outcome — the approval or
purchase sheet, a message alert — now settles only when the screen
reports it on screen (`presentationDidAppear`, from the sheet content's
and the alert message's `onAppear`); refusals shown on a sheet already
up, supersession, an unavailable feature and an abandoned request still
settle at once; a sheet that never appears is the root watchdog's case.

Tests: the gate (A abandoned, B started, A returns before and after B
settled); the view model waiting for the appearance, and ignoring an
appearance nobody waits for.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The previous commit carried the build-time rename of the test module
(dashwallet → dashpay) in seven test files it did not otherwise touch;
this puts the lines back as they were.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Preliminary review — Phase 1 blocker gate

At head 99583e2, source inspection confirms fixes for all eight prior findings. One blocking issue remains: the next link does not reliably dismiss presentations owned by child controllers, allowing scanner conflicts and reuse of a previous payment’s visible confirmation. The two new reviewer findings are combined because they describe consequences of this same presentation-ownership gap; no build or runtime reproduction was performed in this verification.

Validated blockers were found by the Phase-1 review and confirmed by a fresh verifier. Phase 2 is deferred until a fresh same-head revalidation clears the blocker gate.

🔴 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); final verifier: gpt-6-astra (agent: astra-gate-verifier, role: verifier)

  • Triage: normal by gpt-6-astra (effort low) — The diff is intricate and cross-cutting but changes deep-link queueing, launch gating, UI presentation sequencing, and payment callback ownership rather than transaction construction, funds movement, signing, key handling, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — verifier; agent astra-gate-verifier
  • Phase 2 reviewers: not run (deferred by blocker gate)
🤖 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/Main/MainTabbarController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Main/MainTabbarController.swift:591-596: Dismiss child-owned presentations before handing over the next link
  The queue immediately dispatches the next link when the preceding handler's presentation completion runs, but this helper checks only the tab controller's presentedViewController. That property does not search its descendants. Home.handleDeeplink presents the invitation alert from Home, and PaymentController presents its page-sheet confirmation from the Home/amount-screen anchor's topController, so these presentations can remain attached to a child while this guard runs body() without dismissal. An invitation followed by a scanner then reaches DWBasePayViewController's assertion that Home.presentedViewController must be nil; without assertions, UIKit can refuse the second presentation. Two payment links expose another consequence: Home reuses its PaymentController, and the second operation's confirmPaymentOutput finds the still-visible confirmViewController and updates it with the second payment rather than presenting a distinct confirmation. Resolve and dismiss the actual presentation owner in the active child hierarchy before advancing to the next handler, and ensure a replaced payment cannot retain or drive the preceding operation's screens. Add presentation-level regressions for invitation → scanner and payment → payment, including an invitation with hasLocalIdentity true after syncDone.

Comment on lines +591 to +596
/// `dismiss` reports through its completion only when something was
/// presented; with nothing presented the body runs at once.
private func afterDismissingPresented(_ body: @escaping () -> Void) {
guard presentedViewController != nil else { return body() }
dismiss(animated: false, completion: body)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Dismiss child-owned presentations before handing over the next link

The queue immediately dispatches the next link when the preceding handler's presentation completion runs, but this helper checks only the tab controller's presentedViewController. That property does not search its descendants. Home.handleDeeplink presents the invitation alert from Home, and PaymentController presents its page-sheet confirmation from the Home/amount-screen anchor's topController, so these presentations can remain attached to a child while this guard runs body() without dismissal. An invitation followed by a scanner then reaches DWBasePayViewController's assertion that Home.presentedViewController must be nil; without assertions, UIKit can refuse the second presentation. Two payment links expose another consequence: Home reuses its PaymentController, and the second operation's confirmPaymentOutput finds the still-visible confirmViewController and updates it with the second payment rather than presenting a distinct confirmation. Resolve and dismiss the actual presentation owner in the active child hierarchy before advancing to the next handler, and ensure a replaced payment cannot retain or drive the preceding operation's screens. Add presentation-level regressions for invitation → scanner and payment → payment, including an invitation with hasLocalIdentity true after syncDone.

source: muse-spark-1.3-contributor (phase1-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 14ecfbb.

Who owns the presentations (checked before changing anything): no definesPresentationContext in HomeViewController, MainTabbarController or the navigation controllers. The only context-defining screen is ProvideAmountViewController (vc.definesPresentationContext = true in PaymentController, where it is pushed onto Home's navigation stack). ConfirmPaymentViewController, DWQRScanViewController and DPAlertViewController (a plain UIViewController subclass under DashPay/Presentation/Shared/DPAlert) set no modal style, so on their own they go to the root-most presenter, an ancestor of the tab, and the tab's presentedViewController does see them. The case the tab could not see is the one you describe: a confirmation presented over the amount step is owned by the amount step, and presentedViewController on the tab is nil.

Changes:

  • PresentationOwner.find(from:) (new, UI/RootNavigation/PresentationOwner.swift) is a pure walk over a three-property PresentationNode protocol (presentedNode, presentingNode, activeChildNode; UIViewController conforms, with a tab's selectedViewController and a navigation controller's topViewController as the active child). It walks tab → selected → top of stack and returns the deepest controller whose presented controller names it as presenter; when nothing on the chain owns a presentation but one is visible (owned above the tab) it returns the chain's root, whose dismiss forwards up; nil when nothing is presented.
  • afterDismissingPresented dismisses from that owner (animated: false) and runs the next handler only in the dismissal's completion; with no owner it runs the handler directly.
  • PaymentController.performPayment(with:presentationSettled:isAbandoned:) clears confirmViewController, provideAmountViewController and paymentOutput when a new operation begins, so confirmPaymentOutput presents a fresh confirmation for the current operation instead of updating the previous one's.

Regression coverage:

  • PresentationOwnerTests (5) over a fake tree whose presentedNode behaves like presentedViewController (visible from the owner and its ancestors): nothing presented → nil; presentation owned above the chain → the tab (dismissed through the chain's root); confirmation owned by the amount step → the amount step, with the tab's own presentedNode nil; the deepest owner wins, then falls back to the tab once it dismisses; a cycle in the active chain does not loop.
  • Simulator harness (local build, not pushed): invitation delivered in the locked phase + dashwallet://scanqr inside the migration hold, lock screen on, PIN entered by the harness — no assert, no crash report, the scanner is up (camera prompt) 1 s after the unlock, the invitation stays queued because the harness wallet has no identity. Two dash: payment links (0.01 and 0.02 to different addresses, one in the locked phase, one in the hold) — handled in turn 1 s apart, the second operation's own amount step (0.02, its address) is on top; no crash report.

Numbers: scripts/test_wallet_preparation.py 50/50; notif-tests build-for-testing OK; unit tests 133 executed, 4 failures, all the known pre-existing pair (testDuffDenominatedInsufficientBalanceMessageNamesTheBalance, testShieldedInsufficientBalanceMessageUsesSpendableAmount, each counted twice); DeepLinkQueueTests, ConnectionsViewModelTests, PaymentOperationGateTests, PresentationOwnerTests all green.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still applies (re-reviewed at 14ecfbb3): The presentation-owner walk fixes the modal ownership case, but the replacement-payment path still only clears the prior amount controller's reference. The old pushed controller remains on the navigation stack and can forward its input to the current operation, so the payment A → payment B → Back scenario remains unfixed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pushed amount step is handled in 668888c (see 4116450744): a superseded payment's step is removed from the navigation stack when the next operation begins, and the amount delegate is bound to its operation, so a stale step neither stays reachable through Back nor feeds the current processor. The presentation walk from 14ecfbb covers what is presented; this covers what is pushed.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 668888c7): Your pushed-screen fix closes the remaining case identified in the follow-up: the previous amount step is removed and unbound when the next operation begins. Together with the presentation-owner dismissal and fresh confirmation controller, this addresses both the modal and stale pushed-screen paths.

…efore the next link, and never reuse a previous payment's screens

Before handing a link over, the tab controller dismissed only what its
own `presentedViewController` showed. That property sees a presentation
an ancestor owns, not one a descendant owns: the amount step defines its
own presentation context, so a payment's confirmation presented over it
belongs to the amount step and the tab saw nothing. The next link then
presented on top — the scanner into the base pay controller's assert or
a refused presentation — and a second payment's confirmation found the
first one still up and updated it with the second payment.

The presentation owner is now resolved by walking the active chain (tab
→ selected → top of the navigation stack) for the deepest controller
whose presented controller names it as presenter (`PresentationOwner`,
pure over a small node protocol); the dismissal is asked of that owner,
which takes the whole chain above it down, and the next handler runs in
its completion. When only an ancestor owns a presentation the chain's
root dismisses, which forwards up as before. A payment operation that
begins also forgets the previous operation's confirmation, amount screen
and output: `confirmPaymentOutput` presents fresh for the current one.

Tests: the owner walk over a fake tree — nothing presented, a
presentation owned above the chain (dismissed through the chain's
root), one owned by the amount step below it (found there), the deepest
owner winning, a cyclic chain.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The PR substantially improves deep-link serialization, including queue bounds, attachment gating, per-operation payment isolation, and presentation-aware settlement. One blocking flow issue remains: consecutive payment operations can leave the first payment's pushed amount screen on the navigation stack, allowing that stale screen to send input to the replacement payment's processor.

🔴 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: normal by gpt-6-astra (effort low) — The diff intricately changes deep-link queuing, launch gating, presentation ownership, and payment callback isolation, but does not directly change funds movement, coin selection, signing, key handling, consensus, peer deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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/Payment Controller/PaymentController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payment Controller/PaymentController.swift:128-133: Dismiss child-owned presentations before handing over the next link
  The new presentation-owner walk correctly dismisses modal presentations, but it does not remove a previous payment's pushed amount screen from the navigation stack. When payment A pushes its amount screen and payment B starts, `performPayment` only clears the weak `provideAmountViewController` reference; payment A's controller remains retained by the navigation stack, and payment B is pushed above it. Pressing Back from B therefore reveals A's recipient and amount UI. `ProvideAmountViewControllerDelegate` has no sender or operation identity, so submitting the stale A screen calls `provideAmountViewControllerDidInput`, which forwards the amount to `operation?.processor`—the current B processor. The processor-identity gate cannot reject this because the stale screen is invoking the current processor rather than A's obsolete processor. Remove or invalidate the previous amount controller when a new operation begins, or bind the amount callback to its originating controller/operation. Add a payment A → payment B → Back → Continue regression.

Comment on lines +128 to +133
// The previous operation's screens are not this one's: the link
// queue dismissed them before handing this link over, and a
// confirmation left behind must never be updated with this payment.
confirmViewController = nil
provideAmountViewController = nil
paymentOutput = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Dismiss child-owned presentations before handing over the next link

The new presentation-owner walk correctly dismisses modal presentations, but it does not remove a previous payment's pushed amount screen from the navigation stack. When payment A pushes its amount screen and payment B starts, performPayment only clears the weak provideAmountViewController reference; payment A's controller remains retained by the navigation stack, and payment B is pushed above it. Pressing Back from B therefore reveals A's recipient and amount UI. ProvideAmountViewControllerDelegate has no sender or operation identity, so submitting the stale A screen calls provideAmountViewControllerDidInput, which forwards the amount to operation?.processor—the current B processor. The processor-identity gate cannot reject this because the stale screen is invoking the current processor rather than A's obsolete processor. Remove or invalidate the previous amount controller when a new operation begins, or bind the amount callback to its originating controller/operation. Add a payment A → payment B → Back → Continue regression.

source: muse-spark-1.3-contributor (phase1-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 668888c, both ways.

  • Off the stack: when an operation begins, PaymentController.removeSupersededAmountStep() takes the previous operation's amount step out of its navigation controller (setViewControllers without animation — the new operation is about to push or present), nils its delegate and drops the reference. After two dash: links the stack is Home → B's step; Back returns to Home.
  • Bound to its operation: ProvideAmountViewControllerDelegate now names its sender (provideAmountViewController(_:didInput:selectedCurrency:)). PaymentOperationGate binds a step to the operation that pushed it (bind(_:to:), refused for an obsolete token) and answers admits(screen:); bindings are cleared when an operation is superseded or ended. PaymentController binds the step it pushes and refuses an amount from any other step — logged, ignored, the step's activity indicator hidden — whichever processor is current, so a stale step cannot drive the current payment even if it were still reachable.

Regressions:

  • PaymentOperationGateTests.testOnlyTheCurrentOperationsOwnScreenFeedsIt: A's step bound to A; B begins → A's step refused, before and after B binds its own; B's step admitted; an unbound step refused; binding A's step to A again (obsolete) refused; after B ends, B's step refused.
  • Simulator harness (local build, not pushed), two dash: links (0.01 / 0.02 to different addresses, one in the locked phase, one in the migration hold): both handled in turn; the log shows PAY removed the previous payment's amount step from the navigation stack (2 → 1) before B's step is pushed; B's own step (0.02, its address) is on top; the harness then pops the top as Back would — nav stack before Back: 2 [HomeViewController > ProvideAmountViewController], after Back: 1 [HomeViewController] — and the screenshot shows Home. No crash report.
  • Scenario A (invitation in the locked phase + dashwallet://scanqr in the hold, lock on, PIN by harness) re-run on the same build: no assert, no crash report, scanner up 1 s after the unlock, invitation still queued (no identity in the harness wallet).

Numbers: scripts/test_wallet_preparation.py 50/50; notif-tests build-for-testing OK; unit tests 134 executed, 4 failures — the known pre-existing pair (testDuffDenominatedInsufficientBalanceMessageNamesTheBalance, testShieldedInsufficientBalanceMessageUsesSpendableAmount, each counted twice); DeepLinkQueueTests, ConnectionsViewModelTests, PaymentOperationGateTests (4), PresentationOwnerTests (5) all green.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 668888c7): Your latest change removes the superseded amount controller from its navigation stack and clears its delegate. The sender-aware delegate also checks the current operation's screen binding, so the stale A screen can neither remain reachable through Back nor supply an amount to B.

…nd let only the current payment's own step feed it an amount

The amount step is pushed onto Home's navigation stack, not presented, so
the dismissal before the next link left payment A's step where it was and
payment B pushed its own above it. Back then showed A's recipient and
amount, and Continue there handed A's amount to whichever processor was
current — B's — because the amount delegate carried no sender and the
processor-identity gate saw only B's processor.

When an operation begins it now takes the previous operation's amount
step out of its navigation stack (`setViewControllers` without animation:
the new operation is about to push or present) and unhooks its delegate.
The amount delegate names its screen, the gate binds a step to the
operation that pushed it (`bind(_:to:)` / `admits(screen:)`, cleared when
the operation is superseded or ended), and an amount from a step that is
not the current operation's is logged, ignored, and the step's activity
indicator hidden.

Tests: the gate refuses A's step once B began — before and after B bound
its own — a step never bound, a binding to an obsolete operation, and an
ended operation's step.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified the supplied findings against head 668888c and independently revalidated all ten prior findings as fixed. One new blocking defect remains: settling a superseded payment synchronously can re-enter payment initialization, overwrite a queued payment, and lose its queue completion. This verification used source and regression-test inspection; reviewer-reported simulator and build results were not independently rerun.

🔴 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: critical by gpt-6-astra (effort low) — The intricate cross-cutting serialization changes in PaymentController.swift alter payment processor ownership, amount-to-operation binding, and the processor used to confirm payment outputs, directly affecting funds-movement authorization rather than only deep-link presentation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-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/Payment Controller/PaymentController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payment Controller/PaymentController.swift:123-126: Make predecessor settlement non-reentrant during payment replacement
  `previous.settle()` synchronously invokes the root controller's completion, which immediately calls `dispatchNextLinkIfReady`, before this method installs the replacement operation. This is reachable when payment A is awaiting a BIP70 fetch, payment C is queued behind it, and the user scans payment B through Home's scan shortcut. The scanner dismisses before starting B, so settling A can synchronously dispatch C through `afterDismissingPresented` and recursively enter this same controller. C installs its operation and, for a plain address, pushes its amount step. The outer B call then resumes, removes C's step, and overwrites C's operation without settling it. C's later presentation completion calls `settlePresentation()` on B instead, leaving C's queue dispatch active until the watchdog releases it and silently discarding C's payment flow. Make operation replacement and predecessor notification reentrancy-safe so an outer invocation cannot overwrite an operation installed during its callback. Add a controller-level regression for A preparing → C queued → manual scan B, checking both operation ownership and exactly-once queue settlement.

Comment on lines +123 to +126
private func performPayment(with input: DWPaymentInput, presentationSettled: (() -> Void)?, isAbandoned: (() -> Bool)?) {
if let previous = operation {
gate.end(previous.token)
previous.settle()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Make predecessor settlement non-reentrant during payment replacement

previous.settle() synchronously invokes the root controller's completion, which immediately calls dispatchNextLinkIfReady, before this method installs the replacement operation. This is reachable when payment A is awaiting a BIP70 fetch, payment C is queued behind it, and the user scans payment B through Home's scan shortcut. The scanner dismisses before starting B, so settling A can synchronously dispatch C through afterDismissingPresented and recursively enter this same controller. C installs its operation and, for a plain address, pushes its amount step. The outer B call then resumes, removes C's step, and overwrites C's operation without settling it. C's later presentation completion calls settlePresentation() on B instead, leaving C's queue dispatch active until the watchdog releases it and silently discarding C's payment flow. Make operation replacement and predecessor notification reentrancy-safe so an outer invocation cannot overwrite an operation installed during its callback. Add a controller-level regression for A preparing → C queued → manual scan B, checking both operation ownership and exactly-once queue settlement.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this was real. With nothing presented, the next link's hand-over ran inside the call that was replacing the payment, and that call then overwrote the newly installed operation. Fixed in 42de471.

What changed

  • Replacement and link settlement now go through a small type, PaymentOperationSequence, next to PaymentOperationGate.
  • The new operation becomes current before any predecessor is notified.
  • A replaced operation's completion is detached immediately, so it runs exactly once whoever replaces it. It is delivered on the next main-queue turn, so the queue's next dispatch can never run inside performPayment.
  • As a second guard, performPayment re-checks its token after the begin and again after removing the old amount step from the stack, before it installs its operation. If it was replaced in the meantime, it stops.
  • Every presentation completion (alert, confirmation, amount-step push, cancel, failure, send, abandonment) now settles its own operation's token rather than whichever operation is current. A late completion from C can no longer settle B.

Tests
PaymentController has no seam for the processor or the navigation stack, so this is not a UIKit-level test. The regression drives the production PaymentOperationSequence together with the real DeepLinkQueue, plus a copy of the root controller's completion that dispatches the next link synchronously, as afterDismissingPresented does with nothing presented. It covers A preparing, C queued, manual B:

  • C does not start inside B's start;
  • B is current when that start returns;
  • A settles once, on the next turn;
  • C then owns the controller, with its dispatch still in flight;
  • each link settles exactly once.

A second test runs the same scenario with synchronous delivery (the old ordering) and checks that the outer call stops instead of overwriting C. Neither test exercises performPayment itself, the screens or DWPaymentProcessor.

Behavioural note
In this scenario C now runs after B has started and, like any link, replaces what is on screen, so B's amount step gives way to C's. Nothing is dropped silently and each dispatch settles once. Whether a queued link should wait while a manual payment is open is a separate product question, and this change does not alter it.

Scope
After this round, #1159's scope is frozen at 42de471. Further handler-specific findings (the question above, the watchdog versus slow BIP70/BIP73 requests, and presentation-level test coverage) are tracked in #1160 and are not added to this PR.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 42de471d): Your replacement sequence now makes the new token current before detaching predecessor settlement, delivers that settlement on the next main-queue turn, and rechecks admission before installing the processor. I verified the controller's token-scoped presentation completions and reran the sequence/queue regressions; these establish the ordering fix without claiming controller-level UIKit coverage.

…es, and deliver that settlement on the next turn

Settling a replaced payment's link hands the queue's next link over, and
with nothing presented that link starts a payment on the same controller
synchronously. It ran inside the replacing call, which then overwrote the
new operation and removed its amount step.

PaymentOperationSequence now owns replacement and link settlement: the
new operation is current first, every replaced operation's completion is
detached at once and delivered on the next main-queue turn, and a caller
whose token was replaced meanwhile stops. Presentation completions settle
their own operation's link, never whichever is current by then.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Reviewed the complete base-to-head diff at 42de471: ten prior findings are fixed, watchdog liveness remains explicitly deferred, and one new DashConnect request-ownership defect is confirmed. Independent validation passed 23 existing isolated queue/payment/ViewModel tests and 50 wallet-preparation checks; an additional harness using unchanged production ConnectionsViewModel and DeepLinkQueue sources reproduced the lost completion. The canonical app build stopped at dependency resolution because DashUIKit requires Swift tools 6.3 while the installed Xcode supplies 6.1, so full-app and end-to-end presentation validation remain unverified.

🔴 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); 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: normal by gpt-6-astra (effort low) — The diff is intricate and cross-cutting but changes deep-link queueing, presentation lifecycle, and payment callback ownership rather than transaction construction, funds movement, coin selection, cryptography, key handling, network deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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/DashConnect/ConnectionsViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashConnect/ConnectionsViewModel.swift:161-166: Make DashConnect request replacement non-reentrant
  `settle()` invokes the predecessor's completion synchronously before this call installs its own settlement or request generation. When DashConnect link A is awaiting metadata, link C is queued behind it, and the user scans request B from Connections, the scanner dismisses before invoking `onQRScanned`. Settling A therefore immediately drains C through the root completion and `afterDismissingPresented`, recursively entering this same ViewModel. C installs its completion and starts its request; the outer B invocation then overwrites that completion with nil and increments `requestGeneration`, so C's result is discarded without settling its queue dispatch.

  An independent isolated harness using this head's unchanged ViewModel and queue, an injected delayed data source, and the root's synchronous completion ordering reproduced B's approval publishing while only A completed, C remained in flight, and following link D remained pending. Reporting B's appearance did not release C. This is a lost-request/exactly-once settlement defect introduced by the new completion handling, not the deferred product question of whether queued links should interrupt manual activity. Install replacement ownership before notifying the predecessor, make notification reentrancy-safe, and associate settlement with the originating request generation. Add the A resolving → C queued → manual scan B regression.
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.

  • Watchdog liveness for slow BIP70/BIP73 beyond 45 seconds — PaymentProtocolTransport permits a URI-list hop with two sequential 30-second requests, so healthy preparation can exceed the root's 45-second watchdog. Operation-scoped abandonment checks prevent stale presentation, but the legitimate request can still be discarded. The PR description explicitly assigns this liveness problem to #1160.
    • Follow-up: Keep handler-liveness tracking or explicit cancellation in #1160; do not expand this PR to implement it.

Comment on lines +161 to +166
func onQRScanned(_ content: String, settled: (() -> Void)?, isAbandoned: (() -> Bool)?) {
// A request still resolving is superseded below; it will publish
// nothing, so it is settled here.
settle()
settlement = settled
self.isAbandoned = isAbandoned

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Make DashConnect request replacement non-reentrant

settle() invokes the predecessor's completion synchronously before this call installs its own settlement or request generation. When DashConnect link A is awaiting metadata, link C is queued behind it, and the user scans request B from Connections, the scanner dismisses before invoking onQRScanned. Settling A therefore immediately drains C through the root completion and afterDismissingPresented, recursively entering this same ViewModel. C installs its completion and starts its request; the outer B invocation then overwrites that completion with nil and increments requestGeneration, so C's result is discarded without settling its queue dispatch.

An independent isolated harness using this head's unchanged ViewModel and queue, an injected delayed data source, and the root's synchronous completion ordering reproduced B's approval publishing while only A completed, C remained in flight, and following link D remained pending. Reporting B's appearance did not release C. This is a lost-request/exactly-once settlement defect introduced by the new completion handling, not the deferred product question of whether queued links should interrupt manual activity. Install replacement ownership before notifying the predecessor, make notification reentrancy-safe, and associate settlement with the originating request generation. Add the A resolving → C queued → manual scan B regression.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is the same shape as the payment re-entrancy, and it is fixed the same way in 41ad7bb.

What changed

  • The sequencer from the payment fix is now shared: it is renamed LinkOperationSequence, and ConnectionsViewModel runs its link settlements through it.
  • onQRScanned makes the new request current before anything is notified.
  • A superseded request's completion is detached at once, so it runs exactly once. It is delivered on the next main-queue turn, so the queue's next hand-over can no longer run inside the call that superseded it.
  • A call that finds its token replaced in the meantime stops.
  • Every settle site now names the token of the request it belongs to: the sheet appearance, the refusal while a sheet is up, the unavailable feature, the key-registration refusal, abandonment, the published login sheet, the state-transition outcome and the error. A late report therefore settles that request or nothing.
  • requestGeneration stays as the publish gate, separate from the settlement token, so a refusal during key registration still does not supersede the transition in flight.

Regression
Added to ConnectionsViewModelTests. It uses the delayed data source, the real DeepLinkQueue, and a root-style completion that dispatches the next link synchronously. Setup: A is resolving, C and D are queued, then the user scans B manually. The test checks that:

  • B's start neither settles A nor dispatches C inside the call;
  • A settles once on the next turn, and C is dispatched;
  • B's and A's lookups publish nothing when they return;
  • C's sheet is the one that gets published;
  • D is dispatched only after C's sheet appears, and is refused because C's sheet is up;
  • A, C and D each settle exactly once, and the queue ends idle.

The existing view-model tests now await settlement instead of expecting it inside the call.

This fixes a regression introduced by this PR, which is why it goes in despite the scope freeze. Handler-specific follow-ups remain in #1160.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 41ad7bb0): The shared LinkOperationSequence installs ownership before detaching predecessor settlement and delivers that settlement asynchronously; the ViewModel also checks admission and names the originating token at settlement sites. Your A/C/D/manual-B regression covers the reported recursive-overwrite failure; the refusal-before-appearance issue is a separate path.

…ne it supersedes, and settle each request by its own token

Settling a superseded DashConnect request's link hands the queue's next
link over, and with nothing presented that link calls back into the same
view model synchronously. It ran inside the superseding call, which then
overwrote the new request's settlement and generation, so that link was
never settled and the queue stalled behind it.

The view model now runs its link settlements through the sequence the
payment controller uses, renamed LinkOperationSequence: the new request
is current first, a superseded request's completion is delivered on the
next main-queue turn, and every settle site (sheet appearance, refusal,
unavailable feature, abandonment, error) names its own request's token.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Preliminary review — Phase 1 blocker gate

At head 41ad7bb, the shared sequencer fixes synchronous replacement re-entrancy, and the previously added queue, payment-isolation, and presentation-owner safeguards remain present. One in-scope blocker remains: refusing a DashConnect request can release the existing request's presentation gate before its sheet appears. Verification was by source and regression-test inspection; no build or runtime tests were executed.

Validated blockers were found by the Phase-1 review and confirmed by a fresh verifier. Phase 2 is deferred until a fresh same-head revalidation clears the blocker gate.

🔴 1 blocking

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-gate-verifier, role: verifier)

  • Triage: normal by gpt-6-astra (effort low) — The diff is intricate and cross-cutting but changes deep-link queueing, presentation lifecycle, and payment-operation callback ownership rather than transaction construction, funds movement, coin selection, cryptography, key handling, network deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — verifier; agent astra-gate-verifier
  • Phase 2 reviewers: not run (deferred by blocker gate)
🤖 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/DashConnect/ConnectionsViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashConnect/ConnectionsViewModel.swift:174-175: Refused DashConnect link settles the on-screen request before its sheet appears
  Starting an operation here settles the predecessor and clears its appearance gate before checking whether the newcomer must be refused. If a deep-linked request has published pendingRequest but its sheet has not called presentationDidAppear(), a manual scanner callback entering onQRScanned takes this path: the existing request's completion is scheduled, awaitingPresentation is cleared, and the newcomer is refused without replacing the pending sheet. This can occur when the existing lookup finishes while the manual scanner is being dismissed. The root can then dispatch the next queued screen without waiting for the pending approval's appearance. Deferring settlement to the next main-queue turn prevents re-entrancy but does not establish ordering with SwiftUI presentation. Preserve the existing operation and appearance gate when refusing a newcomer; settle only the refused request's completion. Add a regression that publishes C's approval, delivers a refused manual scan before presentationDidAppear(), and verifies that C and the following queued link remain blocked until that appearance. The current regression delivers its refused request only after C's appearance, so it does not cover this ordering.

Comment on lines +174 to +175
let token = operations.begin(settled: settled, isAbandoned: isAbandoned)
awaitingPresentation = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Blocking: Refused DashConnect link settles the on-screen request before its sheet appears

Starting an operation here settles the predecessor and clears its appearance gate before checking whether the newcomer must be refused. If a deep-linked request has published pendingRequest but its sheet has not called presentationDidAppear(), a manual scanner callback entering onQRScanned takes this path: the existing request's completion is scheduled, awaitingPresentation is cleared, and the newcomer is refused without replacing the pending sheet. This can occur when the existing lookup finishes while the manual scanner is being dismissed. The root can then dispatch the next queued screen without waiting for the pending approval's appearance. Deferring settlement to the next main-queue turn prevents re-entrancy but does not establish ordering with SwiftUI presentation. Preserve the existing operation and appearance gate when refusing a newcomer; settle only the refused request's completion. Add a regression that publishes C's approval, delivers a refused manual scan before presentationDidAppear(), and verifies that C and the following queued link remain blocked until that appearance. The current regression delivers its refused request only after C's appearance, so it does not cover this ordering.

source: muse-spark-1.3-contributor (phase1-reviewer: security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This one came from my previous fix: the newcomer was started before the refusal was decided, which settled the request on screen and cleared its appearance wait. Fixed in f537806.

What changed

  • onQRScanned now decides every refusal first: the feature is unavailable, a sheet is up or pending, or key registration is in flight.
  • A refused newcomer never starts. It gets a token that is never current and carries only its own completion. That completion settles on the next turn, or, for the key-registration refusal, when its alert appears. A manual scan has no completion.
  • The request that owns the screen stays current. It keeps its settlement and its place in the appearance wait, so it still settles only when its sheet appears.
  • Only a newcomer that actually replaces a resolving request goes through begin. Even then, a predecessor whose alert is published but not yet shown keeps waiting for its own appearance.
  • Appearance waits are now a queue and settle oldest first.
  • PaymentController has no refuse-after-begin path. Every payment replaces the previous one by design, and its token checks after begin are only re-entry guards.

Regression
The test uses the delayed data source, the real DeepLinkQueue, and a root-style synchronous completion. C's approval is published but not yet shown. Before presentationDidAppear(), two newcomers arrive and are refused: a manual scan, and a newcomer carrying a completion. The test checks that:

  • the newcomer's completion settles once;
  • C is not settled, D is not dispatched, and the queue stays busy;
  • C's approval stays on screen, with the refusal shown on it;
  • no lookup starts.

After presentationDidAppear(), C settles once, D is dispatched (and refused, since C's sheet is up) and settles once, and the queue ends idle. Two pure tests cover refuse() and begin(keeping:) on the sequence.

This fixes a regression introduced by this PR, which is why it goes in despite the scope freeze.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at f537806a): Your refusal checks now precede begin(), and refuse() issues a never-current token without changing the existing request's settlement or appearance wait. The added regression covers both manual and completion-bearing newcomers before C's appearance, while C and the following queued link remain blocked.

… request on screen keeps its settlement until its sheet appears

onQRScanned started the newcomer, which settled the current request and
cleared its appearance gate, before deciding the newcomer had to be
refused. With an approval published but not yet on screen, a refused
scan let the queue hand the next link over before the sheet appeared.

Refusals are now decided first and a refused newcomer never starts: it
takes a token that is never current, carrying only its own completion,
and the request that owns the screen keeps its settlement and its place
in the appearance queue. A newcomer that does replace a resolving
request leaves a predecessor whose alert has yet to appear waiting for
that appearance. Appearance waits are a queue, settled oldest first.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified the complete base-to-head diff at f537806: 12 prior findings are fixed, and the remaining watchdog-liveness item is explicitly deferred to #1160. One non-blocking suggestion remains: unsupported-link coalescing excludes the active dispatch, allowing an additional alert from the same burst. Validation passed 20 isolated queue/operation tests, an additional coalescing reproduction, 50 wallet-preparation tests, accessibility checks, and diff whitespace checks; the canonical simulator build is blocked by DashUIKit requiring Swift tools 6.3 while the installed toolchain provides 6.1, so full-app runtime behavior remains unverified.

🟡 1 suggestion(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: 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: normal by gpt-6-astra (effort low) — The diff is intricate and cross-cutting, but its changes center on deep-link queuing, presentation lifecycle, and payment-operation callback ownership rather than transaction construction, funds movement, coin selection, signing, key handling, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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/DeepLinkQueue.swift`:
- [SUGGESTION] DashWallet/Sources/UI/RootNavigation/DeepLinkQueue.swift:112-113: Coalesce unsupported links while one is already being handled
  The coalescing check only examines pending links, but takeNext removes the active unsupported link before its alert is shown. An unsupported URL arriving while that alert is open is therefore queued, and the alert's OK handler releases another unsupported dispatch. An isolated test using the unchanged queue reproduced this, including an identical URL being admitted again. Subsequent arrivals are coalesced behind that second link, so a finite burst can produce two alerts rather than the documented one. Include the active unsupported dispatch in the coalescing decision, clear it when that dispatch finishes, and add a regression covering arrivals before the first alert's completion.
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.

  • Slow-but-healthy preparation beyond the 45s watchdog is silently dropped — PaymentProtocolTransport permits a BIP73 URI-list fetch followed by a second fetch, each with a 30-second timeout. Two healthy 25-second responses can therefore outlast the root's 45-second watchdog; token-specific abandonment prevents stale UI, but the payment can still disappear without confirmation. The PR explicitly excludes this liveness policy and tracks it in #1160.
    • Follow-up: Keep the handler-liveness or explicit cancellation policy in #1160 rather than extending this PR.

Comment on lines +112 to +113
if link.isUnsupported, pending.contains(where: { $0.isUnsupported }) {
return .droppedUnsupportedCoalesced

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Coalesce unsupported links while one is already being handled

The coalescing check only examines pending links, but takeNext removes the active unsupported link before its alert is shown. An unsupported URL arriving while that alert is open is therefore queued, and the alert's OK handler releases another unsupported dispatch. An isolated test using the unchanged queue reproduced this, including an identical URL being admitted again. Subsequent arrivals are coalesced behind that second link, so a finite burst can produce two alerts rather than the documented one. Include the active unsupported dispatch in the coalescing decision, clear it when that dispatch finishes, and add a regression covering arrivals before the first alert's completion.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed in fc4f602.

The queue now remembers the unsupported link it has handed over and treats it as still pending until that dispatch finishes. This applies to both finish paths, including the watchdog. While that alert is up:

  • another unsupported link is coalesced into it;
  • an identical URL is dropped as a duplicate.

So the alert's OK no longer releases a second unsupported dispatch for the same burst. Supported links are unaffected.

A new pure queue test covers links that arrive before the first alert completes:

  • the identical URL and two other unsupported links are dropped;
  • a supported link that arrives meanwhile is still queued, and is dispatched after the alert;
  • no second unsupported dispatch happens;
  • a later unsupported link starts a new burst with its own alert.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at fc4f602e): Your activeUnsupported tracking keeps the dispatched unsupported link in the coalescing decision until either finish path clears it. The new exact-source regression passed, including supported-link preservation and accepting a later unsupported burst.

…shown

takeNext removes the unsupported link it hands over, so the coalescing
check, which looked only at pending links, admitted unsupported links
that arrived while that alert was up (an identical URL included), and
the alert's OK released a second one: two alerts for one burst.

The queue now remembers the unsupported dispatch in flight and treats it
as pending for coalescing and for the identical-URL check, until that
dispatch finishes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified fc4f602 against the supplied findings and prior review threads: all 14 prior defects are addressed. One blocking routing gap remains: parser-rejected URLs still present directly from AppDelegate, and removing the wallet gate newly permits that presentation during walletless setup or migration. The exact-source queue/operation harness passed 21 tests and the wallet-preparation harness passed 50 tests; this verification did not perform a full iOS application build or presentation-level smoke test.

🔴 1 blocking

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Route rejected URLs through the deep-link queue
DashWallet/AppDelegate.m:389-402

The removed allowsURLHandling check previously rejected URLs before presenting anything when no wallet existed. This remaining branch now presents the “Not a Dash URL” alert directly over setup or the migration hold, without consulting the root queue's wallet, attachment, launch-hold, or dispatch gates. This is reachable through a registered scheme: dashid://invalid is registered in Info.plist but rejected by DWURLParser.canHandleURL and is not an invitation. Because the alert is not represented by a queue dispatch, completing migration/setup can also advance queued work independently of it. Preserve the rejection and existing alert text, but deliver a rejected-URL item through the initial controller and root-owned serialized path rather than presenting here. The confirmed new regression is the walletless setup/migration path; presentation over an already-existing wallet's lock screen was possible before this PR and is not the basis for this blocker.

source: gpt-6-astra (phase2-reviewer: general, security-auditor)

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: normal by gpt-6-astra (effort low) — The diff is intricate and cross-cutting but changes deep-link queuing, presentation lifecycle, and payment-operation callback ownership rather than transaction construction, funds movement, coin selection, cryptography, key handling, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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 verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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/AppDelegate.m`:
- [BLOCKING] DashWallet/AppDelegate.m:389-402: Route rejected URLs through the deep-link queue
  The removed `allowsURLHandling` check previously rejected URLs before presenting anything when no wallet existed. This remaining branch now presents the “Not a Dash URL” alert directly over setup or the migration hold, without consulting the root queue's wallet, attachment, launch-hold, or dispatch gates. This is reachable through a registered scheme: `dashid://invalid` is registered in Info.plist but rejected by `DWURLParser.canHandleURL` and is not an invitation. Because the alert is not represented by a queue dispatch, completing migration/setup can also advance queued work independently of it. Preserve the rejection and existing alert text, but deliver a rejected-URL item through the initial controller and root-owned serialized path rather than presenting here. The confirmed new regression is the walletless setup/migration path; presentation over an already-existing wallet's lock screen was possible before this PR and is not the basis for this blocker.
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.

  • Watchdog liveness for slow BIP70/BIP73 fetches — A BIP73 request with sequential transport hops can outlast the 45-second watchdog. Operation-bound abandonment now prevents stale UI from appearing afterward, but the healthy request can still be discarded. The PR description explicitly excludes this liveness question and tracks it in #1160.
    • Follow-up: Keep the handler-liveness work in the existing #1160 follow-up; no additional change is requested here.

…e instead of alerting from the app delegate

With the wallet gate gone, application:openURL: presented its "Not a
Dash URL" alert on the spot for a registered scheme the parser rejects
(dashid://invalid), over setup or the migration hold, outside the
queue's wallet, attachment, unlock and launch-hold gates, and not as a
dispatch, so queued work could advance while it was up.

The app delegate now hands such a URL to the initial controller like
any other link (and a replayed one no longer disappears silently). The
root controller classifies it as unsupported, since a URL the parser
does not accept has no action, and its queued alert keeps the "Not a
Dash URL" title with the URL as message, ending the dispatch on OK.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@romchornyi

Copy link
Copy Markdown
Contributor Author

@thepastaclaw re the body-level finding in review 5342933730 ("Route rejected URLs through the deep-link queue", AppDelegate.m:389-402):

This was a real regression from removing the wallet gate. The "Not a Dash URL" alert for a rejected registered scheme, such as dashid://invalid, was presented straight from the app delegate, over setup or the migration hold, outside the queue. Fixed in 9812e08.

What changed

  • application:openURL: no longer presents anything. A URL the parser rejects is still reported as not handled, but it is delivered like any other link: to the initial controller, and from there to the root's queue.
  • The replay after a deferred launch now routes a rejected URL the same way, instead of dropping it.
  • The root classifies a URL the parser does not accept as unsupported. Its action lookup now requires the parser to accept the URL first, so no text inside such a URL can produce an action.
  • The queued alert keeps the "Not a Dash URL" title, with the URL as the message. "Unsupported URL" stays for Dash URLs that have no action.
  • The alert is now a normal dispatch. It waits for a presented, attached, unlocked wallet with no launch hold pending, is coalesced to one alert per burst, and completes on OK.
  • continueUserActivity and the initial controller never presented rejected links, so nothing changed there.

Tests
A new pure queue test queues dashid://invalid as unsupported:

  • it stays pending through setup, the migration hold and the lock screen;
  • a second rejected URL joins it;
  • exactly one alert is dispatched once the gates open, and nothing follows after its OK.

Not covered: the classification step lives in the Objective-C root and has no unit test, and there is no app-level run of the migration-hold scenario.

🤖 Addressed with Claude Code

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The complete base-to-head diff and relevant callers support resolving all 15 prior findings; no additional in-scope defect was confirmed. Independent validation passed 22 isolated queue/operation tests using unchanged production sources, all 50 wallet-preparation checks, and git diff --check. Full application and end-to-end presentation validation remain unverified: the canonical simulator build stopped during dependency resolution because DashUIKit requires Swift tools 6.3 while installed Xcode supplies 6.1, and the DashSDKFFI binary artifact could not be resolved.

🔴 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: 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: normal by gpt-6-astra (effort low) — The diff is intricate and cross-cutting but changes deep-link queuing, presentation lifecycle, and payment-operation callback ownership rather than transaction construction, funds movement, signing, key handling, network deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — security-auditor (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-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; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6-astra — general (completed, effort high); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort high); agent phase2-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.

…ize-deep-links

Brings in develop (UIScene life cycle, #1145) through the base PR. Links
now arrive through SceneDelegate → handleOpenURL: / handleUserActivity:,
which return nothing: the handler keeps this branch's ungated routing
(every link joins the root controller's queue, a non-Dash URL included)
and drops the BOOL result the app delegate callback used to report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romchornyi

Copy link
Copy Markdown
Contributor Author

Merged the base PR (ee6b76a), which now carries develop's UIScene life cycle (#1145). Two conflicts:

  • AppDelegate: links reach the app delegate through SceneDelegate → handleOpenURL: / handleUserActivity:, which return nothing. The handler keeps this PR's ungated routing (every link joins the root controller's queue, a non-Dash URL included, and nothing is presented from the app delegate); the BOOL it returned to application:openURL:options: is gone. develop's own gate + "Not a Dash URL" alert in the old handler stays removed, as before this merge. The deferred-launch replay keeps this PR's ordered takePendingLinks().
  • DWInitialViewController.handleURL:: comment only (links arrive after the scene made the window key).

Unit tests at this head: DeepLinkQueueTests, PaymentOperationGateTests, PresentationOwnerTests, ConnectionsViewModelTests pass; SwiftDashSDKCoreLifecycleTests keeps the same two existing balance-message failures as before the merge.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The complete base-to-head diff and all 15 prior findings were independently checked; no remaining in-scope defect was confirmed. The rejected-link routing, bounded admission, presentation-owner lookup, and operation-specific settlement changes address the previously reported failures. Validation was static only: the supplied exact-head CI snapshot reports successful accessibility, PR-title, and CodeRabbit checks, but contains no app-build or XCTest results.

🔴 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: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The intricate, cross-cutting changes in PaymentController.swift and the deep-link queue alter operation ownership and presentation sequencing, not transaction construction, coin selection, signing, key handling, or other qualifying critical surfaces.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% 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.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-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.
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.

  • Track handler liveness independently of the watchdog deadline — The root watchdog can abandon an otherwise healthy preparation after 45 seconds without a presentation, while PaymentProtocolTransport permits a BIP73 URI-list hop consisting of two sequential requests with 30-second timeouts. Operation-specific abandonment and callback admission prevent the previously reported stale confirmation, but a legitimate slow request can still be discarded; the PR explicitly tracks this liveness policy separately in #1160.
    • Follow-up: Continue the separately tracked #1160 work with handler-liveness or cancellation semantics and delayed BIP73 regression coverage.

jeanpierreroma and others added 2 commits October 3, 2026 23:10
…ize-deep-links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The bounded queue and operation-ownership fixes are present: 13 prior findings are fixed, and the watchdog-liveness follow-up remains explicitly deferred. Two in-scope blockers remain: DashConnect does not reliably acknowledge completed presentation, and payment replacement suppresses terminal outcomes of already-confirmed sends. This was static verification only; the supplied exact-head CI snapshot shows successful accessibility, title, and CodeRabbit checks, but no build or runtime-test evidence.

🔴 2 blocking

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This intricate, cross-cutting change modifies funds-movement routing in PaymentController.swift, including which payment processor receives confirmed payment output and user-entered amounts while asynchronous operations replace one another.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-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/DashConnect/ConnectionsScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashConnect/ConnectionsScreen.swift:77-86: Wait for DashConnect request resolution before releasing the queue
  The new presentation wait still lacks a reliable completed-presentation acknowledgement. Native SwiftUI alerts consume the message as alert text rather than hosting it as an ordinary view, so the Text's onAppear is not a reliable alert lifecycle callback. Error and key-registration outcomes nevertheless depend exclusively on that callback to settle their operation; both OK and the presentation binding only clear message. A malformed dash-key: link followed by a scanner link can therefore leave the scanner waiting for watchdog recovery even after OK.

  For the approval and token-purchase sheets, content onAppear can execute before the animated UIKit presentation finishes. It immediately settles the operation, and LinkOperationSequence delivers the root completion on the next main-queue turn. The following scanner can consequently reach afterDismissingPresented while the sheet is still being presented; that helper waits for dismissal but does not first wait for the outstanding presentation transition. Use an operation-bound acknowledgement of completed presentation, or completed dismissal for native alerts, instead of content appearance. This is the remaining presentation-ordering defect from the prior finding, not merely the presentation-level test-seam follow-up in #1160.

In `DashWallet/Sources/UI/Payment Controller/PaymentController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payment Controller/PaymentController.swift:311-314: Preserve terminal outcomes of already-confirmed payments
  The new processor-identity guard also rejects results from payments that have already crossed the confirmation boundary. For example, Home's payment A can be authenticated and awaiting the merchant ACK in BIP70PaymentService.confirmAndSend when payment link B arrives. Starting B replaces the current operation, but DWPaymentProcessor.performBIP70Send retains A through its asynchronous completion and does not cancel its send. After the merchant releases the ACK, A can broadcast successfully while this guard discards its success notification. The corresponding guard at lines 291–292 also hides failure and unknown-broadcast warnings; ordinary asynchronous broadcasts have the same admission problem.

  This newly suppresses terminal callbacks that the base delivered. A replacement showing the same invoice can then invite another confirmation without telling the user that A succeeded or has an uncertain outcome. The per-confirmation send guard does not protect a newly fetched confirmation for B. Keep obsolete preparation callbacks rejected, but track committed sends independently and deliver their terminal outcomes without mutating B's processor, screens, or queue completion—or prevent replacement until the committed send has a terminal result. Add coverage for A confirmed and awaiting ACK → B starts → A reports success or an uncertain outcome. This is separate from the deferred question of whether queued links should interrupt an unconfirmed manual payment.

Comment on lines +77 to +86
} message: { message in
// The deep-link queue waits for this: the alert is on screen.
Text(message.text)
.onAppear { viewModel.presentationDidAppear() }
}
.sheet(isPresented: isApproveSheetPresented) {
if let request = viewModel.pendingRequest {
approveSheet(for: request)
// The deep-link queue waits for this: the sheet is on screen.
.onAppear { viewModel.presentationDidAppear() }

@thepastaclaw thepastaclaw Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 9ff2681e; see the replies below.

🔴 Blocking: Wait for DashConnect request resolution before releasing the queue

The new presentation wait still lacks a reliable completed-presentation acknowledgement. Native SwiftUI alerts consume the message as alert text rather than hosting it as an ordinary view, so the Text's onAppear is not a reliable alert lifecycle callback. Error and key-registration outcomes nevertheless depend exclusively on that callback to settle their operation; both OK and the presentation binding only clear message. A malformed dash-key: link followed by a scanner link can therefore leave the scanner waiting for watchdog recovery even after OK.

For the approval and token-purchase sheets, content onAppear can execute before the animated UIKit presentation finishes. It immediately settles the operation, and LinkOperationSequence delivers the root completion on the next main-queue turn. The following scanner can consequently reach afterDismissingPresented while the sheet is still being presented; that helper waits for dismissal but does not first wait for the outstanding presentation transition. Use an operation-bound acknowledgement of completed presentation, or completed dismissal for native alerts, instead of content appearance. This is the remaining presentation-ordering defect from the prior finding, not merely the presentation-level test-seam follow-up in #1160.

source: gpt-6.1-sol (phase2-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on both halves — fixed in 24e33dc.

  • Alerts: the alert Text's onAppear is gone. An error, a key-registration success and the refusal during key registration now settle when the alert is dismissed — message's didSet settles every token waiting for dismissal once message becomes nil, which both OK and the presentation binding do. That also removes the stale-token problem: a watchdog-released alert token used to stay first in the FIFO and the next sheet's appearance settled it instead of its own.
  • Sheets: a single slot (awaitingSheet, settled by sheetDidAppear) instead of the FIFO; a request is refused while a sheet is pending, so there is never more than one.
  • Presentation still animating: PresentationOwner.step(from:) returns .wait(owner) while the presentation over the owner isBeingPresented || isBeingDismissed; afterDismissingPresented then waits for that transition (the presented controller's transitionCoordinator completion, else a 0.1 s poll) and decides again, dismissing anyway after ~2 s. So a scanner link right behind a sheet whose content already appeared no longer issues a dismissal UIKit refuses.

Tests: ConnectionsViewModelTests — testAFailedLinkSettlesWhenItsAlertIsDismissed, testAKeyRegistrationSettlesWhenItsSuccessAlertIsDismissed, testALinkRefusedDuringAKeyRegistrationSettlesWhenItsAlertIsDismissed, testASheetAppearanceSettlesItsOwnLinkWhileAnEarlierAlertIsUp; PresentationOwnerTests — step for nothing presented, a presentation in transition at the root (waited for, then dismissed) and at a descendant. All pass. The UIKit side of the wait (coordinator completion) is not unit-tested; there is no window host in the unit target.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 9ff2681e): Your alert settlement now follows message becoming nil through either OK or the presentation binding, and sheet appearance settles its separate awaitingSheet token. The normal next-handler path also waits for the presentation owner's incoming or outgoing transition before dismissal, addressing both ordering defects; the coordinator-driven UIKit behavior remains unverified at runtime in this lane.

Comment on lines 311 to +314
func paymentProcessor(_ processor: DWPaymentProcessor, didSendWithTxidWire txidWire: Data) {
guard let operation = admitted(processor) else { return }
presentationAnchor?.topController().view.dw_hideProgressHUD()
settlePresentation(of: operation.token)

@thepastaclaw thepastaclaw Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 9ff2681e; see the replies below.

🔴 Blocking: Preserve terminal outcomes of already-confirmed payments

The new processor-identity guard also rejects results from payments that have already crossed the confirmation boundary. For example, Home's payment A can be authenticated and awaiting the merchant ACK in BIP70PaymentService.confirmAndSend when payment link B arrives. Starting B replaces the current operation, but DWPaymentProcessor.performBIP70Send retains A through its asynchronous completion and does not cancel its send. After the merchant releases the ACK, A can broadcast successfully while this guard discards its success notification. The corresponding guard at lines 291–292 also hides failure and unknown-broadcast warnings; ordinary asynchronous broadcasts have the same admission problem.

This newly suppresses terminal callbacks that the base delivered. A replacement showing the same invoice can then invite another confirmation without telling the user that A succeeded or has an uncertain outcome. The per-confirmation send guard does not protect a newly fetched confirmation for B. Keep obsolete preparation callbacks rejected, but track committed sends independently and deliver their terminal outcomes without mutating B's processor, screens, or queue completion—or prevent replacement until the committed send has a terminal result. Add coverage for A confirmed and awaiting ACK → B starts → A reports success or an uncertain outcome. This is separate from the deferred question of whether queued links should interrupt an unconfirmed manual payment.

source: gpt-6.1-sol (phase2-reviewer: security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, and a regression of this PR — fixed in 2c29cfd by not replacing a payment once it crossed the confirmation boundary.

  • PaymentOperationGate gains committed / commit(_:) (current token only) / finishCommitted(_:) (that token only). confirmPaymentViewControllerDidConfirm commits; the terminal callbacks (didSendWithTxidWire, didFailWithError incl. the nil-error path, paymentProcessorDidCancelTransactionSigning) clear it, and so do a new amount or confirmation request from the processor, a cancelled confirmation and an abandoned operation — none of those leaves a send in flight, and a commit that is never cleared would refuse every later payment.
  • While committed, performPayment refuses the newcomer with "A payment is still being sent. Open the link again once it finishes." (new key, English in all catalogs until Transifex delivers it); its link settles once that alert is on screen. Payment A stays current, so its success, failure and unknown-broadcast callbacks are admitted exactly as on the base.
  • MainTabbarController.performPay checks hasPaymentInFlight before afterDismissingPresented and dismisses nothing then, so A's authentication prompt is not torn down by B.

Tests: PaymentOperationGateTests.testAConfirmedSendIsNotReplacedAndItsOutcomeIsAdmitted (A begins and commits; B is refused and never admitted; A's outcome is admitted; after it finishes B can begin) and testOnlyTheCurrentOperationCommitsAndOnlyItsOutcomeFinishesTheCommit. Not covered: a PaymentController-level test with a stub processor (A confirmed → B arrives → A reports success / unknown broadcast) — the controller builds its processor internally and there is no seam yet; the gate test covers the admission rule it relies on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 9ff2681e): Your commitment check now refuses replacement before begin(), preserving the confirmed payment's processor and token until its admitted success, failure, or authentication-cancellation callback clears the commitment. The tab-controller guard also avoids dismissing its authentication; the refusal's presentation-transition race is a separate new finding, not a recurrence of the terminal-callback suppression.

jeanpierreroma and others added 3 commits October 4, 2026 01:24
… a presentation still animating

A native SwiftUI alert hosts its message as alert text, not as a view, so
the `onAppear` the deep-link queue waited for never reliably fired: an
error or key-registration alert held the next link until the watchdog,
and its token stayed first in the FIFO, so the next sheet's appearance
settled the stale token instead of its own.

- Alerts now settle when they are dismissed (`message` cleared by OK or by
  the binding). The approval and token-purchase sheets settle from a single
  slot (`sheetDidAppear`); a request is refused while a sheet is pending, so
  there is never more than one.
- A sheet's content can appear before its presentation transition ends.
  `PresentationOwner.step(from:)` now answers `.wait` while the presentation
  over the owner is still being presented or dismissed (UIKit refuses a
  dismissal then), and `afterDismissingPresented` waits for that transition
  (its coordinator's completion, or a short poll) before dismissing, giving
  up after about 2 s.

Tests: ConnectionsViewModelTests cover a failed link, a key-registration
success and a refusal during key registration settling only on dismissal,
and a sheet settling its own link while an earlier alert is up;
PresentationOwnerTests cover the step for nothing presented, a presentation
in transition at the root and at a descendant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each payment has its own processor, and a payment link that arrived while
an earlier payment's confirmed send was still in flight (awaiting the
broadcast or a BIP70 merchant ACK) replaced it: the earlier processor
still sent, but its success, failure and "transaction status unknown"
callbacks were no longer admitted, so the user never learned the outcome
and could pay again.

- The payment gate now marks the current operation committed when the user
  confirms, and clears it on the processor's terminal callbacks (sent,
  failed, signing cancelled), on a new amount or confirmation request, on a
  cancelled confirmation, and when the queue abandons the operation.
- While a send is committed, `performPayment` refuses a new payment with
  "A payment is still being sent. Open the link again once it finishes."
  (a new key, English in every catalog until Transifex delivers it); the
  committed payment stays current and reports its outcome as before.
- `MainTabbarController.performPay` checks `hasPaymentInFlight` first and
  dismisses nothing then, so an authentication prompt that is up is not
  torn down.

Tests: PaymentOperationGateTests cover a confirmed send that a newcomer
cannot replace and whose outcome is admitted, and that only the current
operation commits and only its outcome clears the commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ize-deep-links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Verified the supplied reviewer claims and all 17 prior findings against head 9ff2681. The prior defects are addressed in the current source, but the new confirmed-payment refusal path bypasses presentation-transition waiting and can lose its alert while blocking subsequent links. This was a static-only verification; the exact-head CI snapshot shows successful accessibility, PR-title, and CodeRabbit checks, but no app-build or XCTest evidence.

🔴 1 blocking

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate operation-state rewrite in PaymentController.swift changes which payment processor receives amounts and confirmed-send instructions, directly affecting funds movement and preservation of in-flight send outcomes.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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/Payment Controller/PaymentController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payment Controller/PaymentController.swift:127-134: Wait for confirmation dismissal before presenting a payment refusal
  The operation becomes committed in confirmPaymentViewControllerDidConfirm before its animated dismissal finishes (lines 251–254). A payment link arriving during that dismissal passes the root's normal readiness gates, takes MainTabbarController.performPay's hasPaymentInFlight branch, and reaches this refusal without the transition wait in afterDismissingPresented. showAlert then calls presentationAnchor.topController().present immediately; topController follows presentedViewController without excluding a controller being dismissed, so it can select the outgoing confirmation. UIKit can reject that presentation or remove it with the outgoing sheet. The newcomer has already been taken from the queue, but its settlement runs only in the refusal alert's presentation completion, leaving no visible refusal and subsequent links waiting for watchdog recovery. Keep the committed payment and its authentication intact, but wait for the existing transition to complete, resolve a stable presenter again, and present the refusal with settlement bound to the refused token. Add a regression for a link delivered while the confirmed payment's confirmation is dismissing.

Comment on lines +127 to +134
guard !operations.isCommitted else {
DWLogger.log("PAY a payment arrived while a confirmed send is in flight; refused")
let refused = operations.refuse(settled: presentationSettled)
showAlert(with: nil,
message: NSLocalizedString("A payment is still being sent. Open the link again once it finishes.",
comment: "Payment: a payment link arrived while a send is in flight"),
for: refused)
return

@thepastaclaw thepastaclaw Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at c99b7bff; see the replies below.

🔴 Blocking: Wait for confirmation dismissal before presenting a payment refusal

The operation becomes committed in confirmPaymentViewControllerDidConfirm before its animated dismissal finishes (lines 251–254). A payment link arriving during that dismissal passes the root's normal readiness gates, takes MainTabbarController.performPay's hasPaymentInFlight branch, and reaches this refusal without the transition wait in afterDismissingPresented. showAlert then calls presentationAnchor.topController().present immediately; topController follows presentedViewController without excluding a controller being dismissed, so it can select the outgoing confirmation. UIKit can reject that presentation or remove it with the outgoing sheet. The newcomer has already been taken from the queue, but its settlement runs only in the refusal alert's presentation completion, leaving no visible refusal and subsequent links waiting for watchdog recovery. Keep the committed payment and its authentication intact, but wait for the existing transition to complete, resolve a stable presenter again, and present the refusal with settlement bound to the refused token. Add a regression for a link delivered while the confirmed payment's confirmation is dismissing.

source: gpt-6-astra (phase2-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c99b7bf. The commit stays at the confirmation's tap (that is the boundary we want to protect), but the refusal no longer presents blindly:

  • showRefusal(for:) resolves presentationAnchor.topController() and, while that top is being presented or dismissed (isBeingPresented || isBeingDismissed, or it has a transitionCoordinator — which also covers a child of the outgoing confirmation), waits for the transition (coordinator completion, else a 0.1 s poll) and resolves the top again. After about 2 s it presents anyway.
  • With nothing in a window to present from, the refused link settles at once instead of waiting for the watchdog.
  • The committed payment and its authentication are untouched; settlement stays bound to the refused token (the alert's presentation completion, or the no-alert path).

Regression: RefusalPresentationTests covers the decision (RefusalPresentation.decide) — wait while the top is in transition, present from a stable top in a window, stop waiting after the last attempt, settle without an alert when nothing is in a window. The UIKit part (a real confirmation dismissing while the link arrives) is not unit-tested; the unit target has no window host.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at c99b7bff): Your showRefusal now waits on the resolved top's presentation/dismissal state or transition coordinator and resolves the top again before presenting, while keeping settlement bound to the refused token. The no-window path settles without presenting; the decision tests cover those branches, though they do not establish window-hosted UIKit behavior.

… transition

The send is committed at the confirmation's tap, before its animated
dismissal ends, so a payment link refused in that window presented its
alert from the outgoing confirmation: UIKit could reject it or take it
down with the sheet, the refused link (settled only by the alert's
presentation completion) stayed unsettled, and later links waited for the
queue's watchdog.

The refusal now resolves the top again once its transition has ended
(the coordinator's completion, else a short poll, bounded at about 2 s),
and settles the link without an alert when nothing in a window can
present it. The decision is `RefusalPresentation.decide`, covered by
RefusalPresentationTests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Static verification at c99b7bf confirms fixes for 17 prior findings; slow-handler watchdog liveness remains explicitly deferred to #1160. One blocking presentation-ordering defect remains: queued unsupported links bypass the transition-aware presentation boundary. The supplied exact-head CI snapshot passes title, accessibility, and CodeRabbit checks but provides no build, XCTest, or runtime-smoke evidence.

🔴 1 blocking

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Apply the presentation-transition gate to unsupported links
DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:241-243

This no-action branch presents directly instead of using the transition-aware boundary used by the scanner, payment, and invitation handlers. On testnet, queue a malformed dash-key: link followed by dashid://invalid. The first link produces a native DashConnect error alert; tapping OK clears ConnectionsViewModel.message and schedules the link's settlement on the next main-queue turn through LinkOperationSequence. Clearing that binding does not wait for the alert's animated dismissal. The next dispatch can therefore reach this call while the preceding alert is dismissing, and topController() follows presentedViewController without excluding dismissing controllers. UIKit can reject the new presentation or remove it with the outgoing presenter. The unsupported link has already been consumed, but its completion runs only from its alert's OK action, so the refusal can be lost and subsequent links stall until watchdog recovery. This is an ordering gap in the PR's new serialized dispatch contract, not the deferred slow-handler or presentation-test-seam work. Route unsupported alerts through a shared transition-aware presentation boundary, resolve the stable presenter again after waiting, and add a DashConnect error → rejected URL regression.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate operation-lifecycle changes in PaymentController.swift alter which payment processor receives confirmation and amount callbacks and prevent replacement of a confirmed send, directly changing funds-movement control.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-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:241-243: Apply the presentation-transition gate to unsupported links
  This no-action branch presents directly instead of using the transition-aware boundary used by the scanner, payment, and invitation handlers. On testnet, queue a malformed dash-key: link followed by dashid://invalid. The first link produces a native DashConnect error alert; tapping OK clears ConnectionsViewModel.message and schedules the link's settlement on the next main-queue turn through LinkOperationSequence. Clearing that binding does not wait for the alert's animated dismissal. The next dispatch can therefore reach this call while the preceding alert is dismissing, and topController() follows presentedViewController without excluding dismissing controllers. UIKit can reject the new presentation or remove it with the outgoing presenter. The unsupported link has already been consumed, but its completion runs only from its alert's OK action, so the refusal can be lost and subsequent links stall until watchdog recovery. This is an ordering gap in the PR's new serialized dispatch contract, not the deferred slow-handler or presentation-test-seam work. Route unsupported alerts through a shared transition-aware presentation boundary, resolve the stable presenter again after waiting, and add a DashConnect error → rejected URL regression.

jeanpierreroma and others added 6 commits October 14, 2026 13:21
…ize-deep-links

# Conflicts:
#	DashWallet/Sources/UI/Main/MainTabbarController.swift
A link settles at the tap that ends its screen, such as an alert's OK or a
dismissed DashConnect error, while that screen is still animating away.
The next link's handler then presented from a controller in transition,
which UIKit refuses or takes down with it. For an unsupported link, which
settles only at its alert's OK, that meant waiting for the watchdog.

The queue now defers the hand-over while anything under the root or the
main controller is being presented or dismissed, found by walking the
active chains and every presentation over them
(PresentationOwner.nodeInTransition). It asks again every 0.1 s and
after about 2 s hands the link over regardless. One gate covers every
handler, so none of them needs its own wait for this race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the hand-over gate:
- The gate is LinkHandOverGate (Swift, next to the queue) instead of
  state on the root controller, and it is unit-tested.
- It waits on the transition coordinator's completion when there is
  one, else a 0.1 s poll, and asks again. A sheet held mid-drag holds
  the link until it is let go. Only a transition still running after
  about 10 s lets the link through, and the watchdog covers that.
- Pushes, pops and tab switches (a transition coordinator) count as a
  transition too, not only presentations.
- The queue answers hasNext with takeNext's own rule. The gate is
  consulted only when a link would really be handed over, and its count
  starts afresh whenever there is nothing to hand over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Second review of the hand-over gate:
- The gate polls every 0.1 s and caps one hold at 10 s measured from
  its start. A coordinator's completion that never comes can no longer
  hold a link indefinitely, and the per-retry count that a long run of
  transitions never exhausted is gone.
- The root container's child swap, a plain view animation with no
  coordinator, holds the link too (DWContainerViewController
  isTransitioning).
- A hold is logged when it starts, so an exported log tells a held link
  from a dropped one.
- The gate lives next to the transition walk in PresentationOwner.swift;
  DeepLinkQueue.swift stays free of UIKit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Third review of the hand-over gate:
- The root container's swap flag is dropped. Container swaps are plain
  view animations the gate cannot see reliably (a parent container, the
  extended container's modal slide). Setup waits for its swap where it
  starts, and the gate's doc says what it does not see.
- The hold is measured on the monotonic clock (systemUptime), so a
  change of the wall clock neither stretches nor cuts it.
- The queue's watchdog asks the same transition question as the gate
  (LinkHandOverGate.isInTransition) instead of a narrower one of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fourth review of the hand-over gate:
- The watchdog keeps a link while anything is presented over the roots,
  including a screen a tab or a stack presents on its own
  (PresentationOwner.find), not only the window root's presentation.
- The gate and the watchdog look under the same roots
  (linkHandOverRoots).
- With nothing to hand over the dispatch returns before takeNext.
- The transition walk dedups by object identity in a set.
- The comments say what the gate does not hold: container swaps, and a
  link past maxHold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@romchornyi

Copy link
Copy Markdown
Contributor Author

@thepastaclaw re the blocking finding in review 5403398162 ("Apply the presentation-transition gate to unsupported links", DWAppRootViewController.m:241-243):

Real. Fixed at the queue rather than in that one handler, in c201a80..60b6c07 (after merging the base PR, 4aff598):

  • Cause: a link settles at the tap that ends its screen (an alert's OK, a dismissed DashConnect error) while that screen is still animating away, and the next hand-over ran immediately. Any handler that presents right away could then present from a controller in transition, not only the unsupported-link alert.
  • dispatchNextLinkIfReady now asks LinkHandOverGate before taking a link. While anything under the root or the main controller is being presented, dismissed, pushed or popped (PresentationOwner.nodeInTransition, which walks the active chains and every presentation over them), the hand-over is deferred and asked again every 0.1 s. One hold is capped at 10 s on the monotonic clock, after which the link is handed over and the watchdog covers it.
  • The queue answers hasNext with takeNext's own rule, so the gate only runs when a link would really be handed over. A hold is logged when it starts.
  • The watchdog's "busy" test now uses the same roots and walk, plus PresentationOwner.find, so a screen that a tab or stack presents on its own keeps the link too.

Tests: PresentationOwnerTests (a dismissing DashConnect alert holds the next link, at the root presenter or down the chain; one retry at a time; the hold ends at maxHold measured from its start), DeepLinkQueueTests (hasNext agrees with takeNext without taking). 46/46 in the touched suites.

Not covered by the gate, and tracked in #1160 rather than here (scope freeze): the root containers' own child swaps (plain view animations, no coordinator); a sheet held mid-drag past the 10 s hold, where afterDismissingPresented's 2 s wait then dismisses into the transition; and the two wait loops with different limits.

@thepastaclaw

Copy link
Copy Markdown
Contributor

@romchornyi on it — I've queued this as job cj-20261014-130003-3fe8 and will reply here or link a PR when there's something to look at.

@thepastaclaw

Copy link
Copy Markdown
Contributor

@romchornyi Re-checked #1159 at 60b6c07fb, including the diff from 4aff598d2. The queue-level fix addresses the specific blocking finding in review 5403398162; no handler-local change is needed for it.

  • dispatchNextLinkIfReady checks hasNext, then the transition gate, before takeNext consumes the URL. That includes the unsupported-link branch: its presenter is resolved only after the gate admits the dispatch, rather than being captured before the wait.
  • The walk covers both the root and the main controller, their active tab/navigation chains, and nested presentations. An outgoing DashConnect alert therefore holds the next URL while its dismissal is visible through the UIKit transition flags/coordinator.
  • hasNext and takeNext share nextIndex, and the watchdog uses the same roots plus the presentation-owner/transition checks, as described.

Validation: 27/27 tests passed (13 DeepLinkQueueTests, 14 PresentationOwnerTests) in a temporary macOS SwiftPM model-only harness. The harness removed the Obj-C annotations and UIKit adapter methods and stubbed logging; it does not validate UIKit presentation or app integration. I also attempted the canonical arm64 simulator app build, but package resolution stopped because the expected sibling platform/packages/swift-sdk is absent in this worktree environment. I cannot independently claim the reported simulator results or an end-to-end DashConnect error → rejected-URL run.

The plain-animation container swaps, forced hand-over after the 10 s cap, and differing handler wait limit remain real limitations, not guarantees supplied by this fix. I verified that your follow-up comment on #1160 records all three, and am leaving them there rather than expanding this PR's frozen scope. This is a focused re-validation of the cited finding, not a fresh review of the entire PR.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Static verification of the complete base-to-head range at 60b6c07 confirms that 18 prior findings are addressed; slow-preparation watchdog liveness remains explicitly deferred to #1160. One non-blocking issue remains in the newly introduced committed-payment refusal path: successive links can accumulate refusal alerts outside the pending-queue bound. No builds or tests were run in this static-only lane; the supplied exact-head CI snapshot shows accessibility and title checks queued, CodeRabbit successful, and no build or runtime-test results.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate cross-controller refactor changes funds-movement gating in PaymentController.swift, including confirmPaymentViewControllerDidConfirm, payment-operation replacement, and binding entered amounts and asynchronous callbacks to the correct send operation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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/Payment Controller/PaymentController.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payment Controller/PaymentController.swift:253-257: Coalesce payment refusals instead of accumulating alerts
  While a confirmed payment is in flight, each incoming payment creates another refusal alert. MainTabbarController.performPay deliberately skips dismissal in its hasPaymentInFlight branch, and show(modalController:for:) presents from topController(), which recursively follows existing presentations. The refused dispatch settles when its alert finishes presenting, so the next queued payment can present another refusal above it without waiting for dismissal. The ten-item pending capacity therefore does not bound the retained refusal stack: repeated dash: links during authentication or a pending merchant ACK can leave the user clearing multiple identical prompts. Coalesce refusals into one existing alert, or retain the refused dispatch until that alert is dismissed, while preserving the committed payment and its authentication. Add regression coverage for multiple refused links that checks exactly-once settlement and a bounded number of live refusal presentations.

Comment on lines +253 to +257
case .present:
showAlert(with: nil,
message: NSLocalizedString("A payment is still being sent. Open the link again once it finishes.",
comment: "Payment: a payment link arrived while a send is in flight"),
for: token)

@thepastaclaw thepastaclaw Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 2a5fb160; see the replies below.

🟡 Suggestion: Coalesce payment refusals instead of accumulating alerts

While a confirmed payment is in flight, each incoming payment creates another refusal alert. MainTabbarController.performPay deliberately skips dismissal in its hasPaymentInFlight branch, and show(modalController:for:) presents from topController(), which recursively follows existing presentations. The refused dispatch settles when its alert finishes presenting, so the next queued payment can present another refusal above it without waiting for dismissal. The ten-item pending capacity therefore does not bound the retained refusal stack: repeated dash: links during authentication or a pending merchant ACK can leave the user clearing multiple identical prompts. Coalesce refusals into one existing alert, or retain the refused dispatch until that alert is dismissed, while preserving the committed payment and its authentication. Add regression coverage for multiple refused links that checks exactly-once settlement and a bounded number of live refusal presentations.

source: gpt-6.1-sol (phase2-reviewer: security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2a5fb16.

PaymentController keeps a weak reference to the refusal alert it presented. While that alert is still visible — the top controller, in a window, not being dismissed (RefusalPresentation.isShown) — a further refused payment settles at once (.alreadyShown) without presenting another; the committed send and its authentication are untouched. Each refused link settles exactly once, and since the queue hands a link over only after the previous one settles, a run of refused links leaves one alert on screen. Once the user taps OK (or something covers it), the next refusal is shown again.

Tests: RefusalPresentationTests cover .alreadyShown (mid-transition included) and the visibility rule; the #1159 suites are 48/48.

🤖 Addressed with Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 2a5fb160): I verified your weak refusal-alert reference and visibility check: a further refusal takes .alreadyShown and settles only its own token without presenting another alert or replacing the committed payment. The new tests check that decision and its visibility conditions; they do not exercise a live UIKit refusal stack.

While a confirmed send is in flight, each refused payment link presented
its own "A payment is still being sent" alert over the previous one. A
refused link now settles without a second alert while the earlier refusal
is still visible (the top, in a window, not being dismissed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Independent static review of the complete base-to-head range found no remaining actionable in-scope defects at 2a5fb16, and all 20 prior findings were revalidated against the current source. The bounded queue, operation-specific settlement, shared transition gate, committed-payment protection and refusal coalescing address the reported failures; the explicitly deferred watchdog-liveness and presentation-testing work remains outside this review's scope. No builds or tests were executed: the supplied exact-head CI snapshot reports successful accessibility, PR-title and CodeRabbit checks, but contains no build, XCTest or runtime-smoke verification.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate changes in PaymentController.swift directly alter funds-movement authorization and execution by changing which payment operation receives confirmation, amounts, and signing or send callbacks while preventing replacement of committed sends.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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.

This branch has not been deployed

No deployments
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.

3 participants