Skip to content

feat(platform-wallet): report whether a failed payment may have left the wallet - #5928

Merged
romchornyi merged 6 commits into
v5.2-devfrom
feat/platform-wallet-payment-delivery
Dec 1, 2026
Merged

romchornyi merged 6 commits into
v5.2-devfrom
feat/platform-wallet-payment-delivery

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Part of #5926. Whether a failed payment may have left the wallet was decided by every host from lists of error codes (Swift, Kotlin isRetryable, the apps), with different defaults per platform, while rs-platform-wallet already knows it and kept it crate-private (BroadcastDelivery). Rust now owns the answer; FFI, JNI, Swift and Kotlin only carry it.

Stack

This is part 1 of 4 of #5928, split for review (about 3–5k lines each). Each part builds and tests on its own base and is safe to merge into v5.2-dev alone; merge them in order.

# PR Part
1 #5928 Rust core: the payment class, the funded-lock seam and the flows built on it
2 #6379 The remaining wallet paths, and the FFI result carrying the class
3 #6380 Swift SDK and SwiftExampleApp
4 #6381 JNI, Kotlin SDK, KotlinExampleApp and the SDK parity manifest

What was done?

  • rs-platform-wallet: public PaymentDelivery { NotSent, MaybeSent, LockHeld(OutPoint) }, PlatformWalletError::payment_delivery() and held_asset_lock() -> Option<OutPoint> (the LockHeld outpoint, read from payment_delivery). The match is exhaustive (no _ arm), so a new variant cannot ship without a class. The class of an SDK failure (sdk_payment_delivery) names every dash_sdk::Error variant too, so a new pre-send SDK refusal cannot fall into MaybeSent silently.
    • NotSent: validation, lookups, selection, build, persister, sync, contact-request gates, TransactionBroadcast (a Core rejection), ShieldedBroadcastFailed, signer key unavailable, ProtocolVersionNotActive.
    • NotSent and not retryable: a request another payment blocks (InputMidBroadcast, PrivateContactRequestPending, ShieldedIdentityDebitPending, the recovery refusals): nothing of this request left the wallet.
    • MaybeSent: the unconfirmed variants, unproved consensus verdicts, string catch-alls, other Sdk errors, and the asset-lock errors that name no lock this payment can resume (AssetLockAlreadyConsumed, AssetLockTooManyInputs, AssetLockProofWait, AssetLockExpired, AssetLockNotChainLocked).
    • LockHeld: FinalityTimeout, AssetLockInputContested, AssetLockRecipientMismatch (resumed with the recorded recipient). The host resumes the named lock and never funds a new one.
    • The table test has a row for every PlatformWalletError variant (130), guarded by an exhaustive ordinal match, so a wrong class in any arm fails.
  • After a dispatch (one seam): once an asset lock is broadcast or resumed, no later error is NotSent. Every funded flow (registration, identity top-up, platform-address and shielded fundings, invitation, resume, seed pool) runs its later steps through AssetLockManager::with_funded_lock, which names the lock as held while it is tracked and resumable and reports MaybeSent once it is consumed or consumption-unknown (handoff_failure). A multi-step payment (DPNS after its preorder, the seed pool after its first batch) is MaybeSent after its first dispatch (after_dispatch()). The FFI never decides a class: an output that cannot be handed back after a successful call takes the wallet's class (handoff_failure for a lock, MaybeSent otherwise), and every Core payment export's refusal carries one.
  • Retry: is_retryable() states a decision for every variant, with no wildcard arm.
  • Flows in this part: the funded-lock seam (AssetLockManager::with_funded_lock) and the flows built on it: identity registration, the external identity top-up from addresses, invitation create and claim, the Platform-address and shielded fundings from an asset lock (wallet drain included). The remaining paths (DPNS, contact requests, shielded spends and tips, the seed pool, masternode withdrawals) follow in part 2.
  • FFI in this part: only adapts to the new variant shapes, and the blanket conversion and every result mapper read a wallet error through its payment-class wrapper (without_payment_class), so hosts keep the codes they get today until part 2 carries the class.
  • Since the last review of feat(platform-wallet): report whether a failed payment may have left the wallet #5928: a wallet drain refused before its lock is NotSent (as its operation records); RefusedBeforeDispatch is never retryable and its docs say so; the resume-refusal check names every variant; an invitation claim whose ChainLock fallback fails after a possibly sent InstantSend claim stays unconfirmed.

How Has This Been Tested?

  • cargo test -p platform-wallet --all-features --lib 2990, -p platform-wallet-ffi --lib 641, -p rs-unified-sdk-jni --lib 154, -p dash-sdk --lib --all-features 1085: all green.
  • cargo clippy -p platform-wallet -p platform-wallet-ffi -p rs-unified-sdk-jni -p dash-sdk --all-features --all-targets -- -D warnings clean; cargo fmt --all.
  • Swift and Kotlin are unchanged in this part and build against an unchanged FFI ABI.

Breaking Changes

  • Rust API: dash_sdk::platform::dashpay::invitation::InvitationError::NotChainLocked and PlatformWalletError::AssetLockNotChainLocked are struct variants { message, after_broadcast } (were a tuple of the message), and InvitationError::AlreadyClaimed gains after_broadcast. Code 66 is NotSent and retryable only before the claim was sent (funding transaction not found, ChainLock invitation not chain-locked yet). A claim sent with its islock proof and refused (stale islock, input cap, or size, which a node and the SDK's own check report alike) is MaybeSent, not retryable, and its message says to check the original claim first. An already-claimed invitation (codes 24, 64) is NotSent when the preflight found it, MaybeSent after a submission; neither is retryable.
  • Rust API: a refusal of the recipient, the amount or the note reservation by shielded_transfer_to (and, for the shielded tip through transfer_once_claimed, of its once_claimed check) is NotSent. One whose variant is otherwise classed possibly sent (a zero amount, an invalid recipient, a tip source that no longer stands) arrives wrapped in PlatformWalletError::RefusedBeforeDispatch: match the diagnostic on error.dispatched_source() and read delivery and retry from the outer error (payment_delivery(), is_retryable()). A later failure keeps its own class, even one before the build: a failed recorded-anchor fetch is an SDK error, classed MaybeSent. The same wrapping applies to PlatformWallet::shielded_plan_spend (a zero amount, an inactive spend kind, a network version that does not support the spend) and to shielded_fund_from_asset_lock refusing an oversized shield batch on a fresh lock. The module-level planners (wallet::shielded::operations::plan_spend, note_selection::plan_spend) keep returning the bare error with its conservative class; the classed entry point is shielded_plan_spend. The token pool spend preview follows the same split: token_pool_spend_preview_for (and so ShieldedTokenPurchaser::preview_spend and platform_wallet_manager_shielded_token_spend_preview) wraps a zero amount or a failed store read in RefusedBeforeDispatch (NotSent), while token_pool_spend_preview keeps the bare error.
  • Retry is decided in Rust: PlatformWalletError::is_retryable() sits next to payment_delivery(), and its answer crosses as retryable. Hosts only read it.
  • Class changes: InputMidBroadcast, PrivateContactRequestPending, ShieldedIdentityDebitPending and the recovery refusals are NotSent and not retryable (were MaybeSent). An unverified Swift or Kotlin broadcast timeout is not retryable. ReservationTokenConsumed (35) is MaybeSent: an earlier broadcast of the token may have sent the payment, so a host that took it as not broadcast and released the reservation must stop doing so. Kotlin's per-class isRetryable overrides (e.g. codes 58, 80) are gone: the native flag decides, and Rust marks those two retryable.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

🤖 Generated with Claude Code

PR Hygiene · 81671e6

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/error.rs, packages/rs-platform-wallet-ffi/src/shielded_send.rs, packages/rs-platform-wallet-ffi/src/shielded_tip.rs and 1 more) — approved by HashEngineering, llbartekll
    • rs-platform-wallet (packages/rs-platform-wallet/src/broadcaster.rs, packages/rs-platform-wallet/src/error.rs, packages/rs-platform-wallet/src/lib.rs and 17 more) — approved by HashEngineering, llbartekll
    • rust-sdk (packages/rs-sdk/src/platform/dashpay/invitation.rs) — approved by lklimek

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • Bug Fixes
    • Wallet errors now preserve their original details through payment and invitation flows, including when wrapped by other errors.
    • Payment outcomes now distinguish transactions not sent from those that may have been sent or have a resumable lock, with retry guidance reflecting the outcome.
    • Shielded funding now checks batch size, available funds, and lock status before proceeding, and handles uncertain results more clearly.
    • Invitation claims distinguish refusals before submission from outcomes that may occur after submission, helping avoid unsafe retries.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The wallet now classifies payment errors as not sent, possibly sent, or associated with a held asset lock, and classifies retryability separately. Asset-lock, identity, address, invitation, and shielded flows apply these classifications. FFI mappings unwrap classification wrappers before mapping the underlying error.

Changes: Payment delivery classification

Layer / File(s) Summary
Payment outcome and retry classification
packages/rs-platform-wallet/src/error.rs, packages/rs-platform-wallet/src/lib.rs, packages/rs-platform-wallet/src/wallet/signed_payment_registry.rs
Wallet errors now expose delivery, held-lock, and retry classifications. Signed-payment errors provide corresponding classification methods.
Invitation claim dispatch outcomes
packages/rs-sdk/src/platform/dashpay/invitation.rs, packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs
Invitation errors record whether an outcome was found before or after broadcast. Wallet claim and invitation-creation paths use funded-lock handling and preserve that distinction.
Asset-lock delivery and recovery
packages/rs-platform-wallet/src/wallet/asset_lock/*, packages/rs-platform-wallet/src/broadcaster.rs
Asset-lock build, submission, proof, and resume paths classify delivery and held-lock state. Resume metadata includes lock status and the recorded shielded recipient.
Identity and address funding outcomes
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs, packages/rs-platform-wallet/src/wallet/identity/network/top_up_from_addresses*, packages/rs-platform-wallet/src/wallet/platform_addresses/fund_from_asset_lock.rs, packages/rs-platform-wallet/src/wallet/platform_wallet.rs
Registration, top-up, and address-funding flows route submission and reconciliation errors through funded-lock handling or mark pre-dispatch failures.
Shielded funding and drain outcomes
packages/rs-platform-wallet/src/wallet/shielded/*, packages/rs-platform-wallet/src/wallet/asset_lock/funded_lock_tests.rs
Shielded funding classifies fresh and resumed lock failures, checks batch capacity, and tracks drain completion. Tests cover proof failures, recipient mismatches, and delivery classes.
FFI error mapping through payment wrappers
packages/rs-platform-wallet-ffi/src/error.rs, packages/rs-platform-wallet-ffi/src/shielded_send.rs, packages/rs-platform-wallet-ffi/src/shielded_tip.rs, packages/rs-platform-wallet-ffi/src/shielded_wallet_drain.rs
FFI conversion removes payment-class wrappers before applying existing typed error mappings. Tests verify mapped codes and messages for wrapped errors.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant WalletOperation
  participant AssetLockManager
  participant Platform
  participant PlatformWalletError
  WalletOperation->>AssetLockManager: run funded operation for outpoint
  AssetLockManager->>Platform: submit transition
  Platform-->>AssetLockManager: submission result
  AssetLockManager->>PlatformWalletError: classify delivery and held-lock state
  PlatformWalletError-->>WalletOperation: return classified error
Loading

Possibly related issues

Possibly related PRs

  • dashpay/platform#5865: Adds shielded spend planning and its FFI mappings, which this PR updates to classify planning failures as not sent.
  • dashpay/platform#5465: Adds a wallet error variant that the new exhaustive delivery classification must account for.
Merge Risk: Low · up to 81671

This change adds Rust-side classification of whether a failed payment may have left the wallet, plus retry decisions. FFI and host layers still return existing codes until the follow-up PRs land, so hosts cannot yet see the new classes. The remaining issues are narrow misclassifications, all on the conservative side, and one documentation inaccuracy. Merging is low risk, with these items to follow up.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(platform-wallet): report whether a failed payment may have left the wallet" matches the main change. The PR adds PaymentDelivery classification (NotSent, MaybeSent, LockHeld) to Platfo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(platform-wallet): report whether a failed payment may have left the wallet" matches the main change. The PR adds PaymentDelivery classification (NotSent, MaybeSent, LockHeld) to PlatformWalletError and SDK invitation errors, and wires it through funded-lock flows. The title names the core purpose and the affected crate. Its scope is slightly narrower than the full changeset, which also covers FFI mapping, invitation errors, and shielded funding, but it is not misleading.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3b8e007 and 81671e6.

Files selected for processing: 1

  • packages/rs-sdk/src/platform/dashpay/invitation.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 14, 2026
@thepastaclaw

thepastaclaw commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 81671e6) · triage: critical

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

The Rust-owned delivery classification is exhaustive and is propagated through most JNI and FFI paths, but several adapters still discard or reconstruct authoritative metadata. Swift loses precise per-result delivery, shielded asset-lock funding can flatten a NotSent error to MaybeSent, and Kotlin implements retry policy in the binding layer rather than receiving a Rust-owned disposition. The CI snapshot contains no failed code checks; Kotlin tests passed while Rust and Swift jobs were skipped.

🔴 3 blocking | 🟡 4 suggestion(s)

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

🔴 Blocking: Shielded asset-lock funding drops the wallet error's delivery class
packages/rs-platform-wallet-ffi/src/shielded_send.rs:886-889

The fallback arm of map_asset_lock_funding_result has the original typed PlatformWalletError, but constructs ErrorWalletOperation without stamping e.payment_delivery(). The constructor therefore supplies the shared code default, MaybeSent, even for a NotSent error such as ShieldedNoUnspentNotes, ProtocolVersionNotActive, or another pre-dispatch SDK refusal. The same unstamped fold exists in the shielded seed-pool export around lines 2158-2161. Both fresh and resumed asset-lock funding can therefore contradict the Rust classifier and make hosts wait for sync instead of retrying a payment that never dispatched.

Err(e) => {
            let delivery = e.payment_delivery();
            PlatformWalletFFIResult::err(
                PlatformWalletFFIResultCode::ErrorWalletOperation,
                format!("{operation} failed: {e}"),
            )
            .with_payment_delivery(delivery)
        }

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general)

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: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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 large diff changes payment error classification and retry behavior across rs-platform-wallet, FFI, JNI, Kotlin, and Swift, directly affecting funds-movement outcomes and wallet recovery decisions, including coin-selection and held-lock handling in packages/rs-platform-wallet/src/error.rs.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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 — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (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 (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:995-999: Swift discards the result-specific payment-delivery class
  `PlatformWalletResult.paymentDelivery` reads the precise `inner.payment_delivery` value, but `PlatformWalletError.init(result:)` drops that field and `PlatformWalletError.delivery` reconstructs delivery from the result code. Shared codes such as `ErrorWalletOperation` and `ErrorUnknown` can carry a Rust-proven `NotSent` result, for example after a pre-dispatch transaction-build or persistence failure, but Swift reports `.maybeSent` because those codes also represent ambiguous failures. Kotlin preserves the native value through `DashSDKException`, so the two host APIs disagree and Swift cannot offer a safe retry that Rust has already authorized. Preserve the result-level delivery value in the Swift error representation instead of recomputing it from `resultCode`.

In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/shielded_send.rs:886-889: Shielded asset-lock funding drops the wallet error's delivery class
  The fallback arm of `map_asset_lock_funding_result` has the original typed `PlatformWalletError`, but constructs `ErrorWalletOperation` without stamping `e.payment_delivery()`. The constructor therefore supplies the shared code default, `MaybeSent`, even for a `NotSent` error such as `ShieldedNoUnspentNotes`, `ProtocolVersionNotActive`, or another pre-dispatch SDK refusal. The same unstamped fold exists in the shielded seed-pool export around lines 2158-2161. Both fresh and resumed asset-lock funding can therefore contradict the Rust classifier and make hosts wait for sync instead of retrying a payment that never dispatched.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:130-136: Kotlin binding implements retry policy from delivery metadata
  `unlessMaybeSent` and the changed `isRetryable` overrides turn the native delivery signal into a retry decision inside the Kotlin SDK, including a Kotlin-specific exception for `AssetLockInputContested`. The repository's mobile-layer rule places orchestration and decisions in `rs-platform-wallet`; FFI crates and Swift/Kotlin SDKs marshal Rust-owned decisions. `PaymentDelivery` only describes whether a payment may already exist; it does not express whether a retry resumes a held lock or creates a second payment. Emit the required retry/resume disposition from the Rust wallet and marshal it, rather than deriving policy from error subclasses in Kotlin.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:60-66: Shielded identity-create errors lose delivery metadata in Kotlin
  `DashSdkError.delivery` only reads metadata from a `DashSDKException` cause. The shielded identity-create JNI path handles code 17 separately, returning a tagged `[tag || identity_id || diagnostic]` payload; `decodeShieldedCreatePayload` then constructs `ShieldedCreateUnconfirmed` without a native exception cause. Consequently, this genuinely ambiguous payment exposes `delivery == null` instead of `PaymentDelivery.MAYBE_SENT`, so callers cannot use the new delivery property consistently for this important path. Carry the delivery value through the tagged payload or attach an equivalent native error cause when constructing the typed exception.

In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:996-1001: Document or version the by-value FFI ABI change
  `PlatformWalletFFIResult` is `#[repr(C)]` and returned by value from C functions. Adding `payment_delivery` changes its size and can change the platform-specific aggregate return ABI; a caller compiled against the previous header can misinterpret the returned value even though a coordinated source rebuild works. The comment currently describes appending the field as source-compatible rather than an ABI break, while the repository's own FFI documentation recognizes field additions to C structs as ABI breaks. Add an explicit ABI/version coordination guarantee or expose a versioned result shape, and do not imply compatibility with already-built host binaries.

In `packages/rs-platform-wallet/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:1500-1511: Wire the held asset-lock accessor to a typed host field
  `held_asset_lock()` is a new public helper, but the repository has no non-test caller and `PlatformWalletFFIResult`/JNI do not carry an outpoint. Hosts therefore still have to recover the resume outpoint from the formatted error message if they need this information. That leaves the new structured accessor disconnected from the mobile paths that need to resume a held lock. Either carry the optional outpoint through the FFI result and JNI/SDK adapters, or keep the helper private until a typed consumer exists.
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:2377-2466: Payment-delivery tests do not cover most classified variants
  The exhaustive match forces new variants to receive a class, but the table test pins only a small subset of the wallet error variants. It does not exercise several safety-relevant arms, including persistence failures, asset-lock proof/expiry failures, `QuorumNotVerified`, `SpvError`, `TokenError`, shielded sync/tree failures, and contact-request gates. A mistaken class in any uncovered arm still compiles and passes. Add table rows for every variant, or generate the coverage table from the same classification source so the safety contract cannot silently drift.

@romchornyi romchornyi changed the title feat(platform-wallet): report whether a failed payment may have left the wallet feat(platform-wallet)!: report whether a failed payment may have left the wallet Nov 15, 2026
@romchornyi romchornyi changed the title feat(platform-wallet)!: report whether a failed payment may have left the wallet feat(platform-wallet): report whether a failed payment may have left the wallet Nov 15, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

On the finding about shielded asset-lock funding: fixed in cb8b995. A new PlatformWalletFFIResult::err_from_wallet_error stamps the wallet error's delivery class on a folded result. It is used in the map_asset_lock_funding_result fallback, the seed-pool export, the shielded identity create and the asset-lock catch-up arm. A test checks that NotSent stays NotSent through the fallback.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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

Most of the payment-delivery transport is now present, but this head still leaves retry/resume policy in Kotlin and maintains a second code-based delivery policy in the FFI adapter. Swift's special shielded identity-create error also drops the delivery field, and the exhaustive FFI mapping has only sample coverage. No code check is failing in the supplied CI snapshot; Kotlin passed, while Rust and Swift checks are skipped and review/hygiene checks remain pending.

🔴 2 blocking | 🟡 1 suggestion(s)

Still open from earlier rounds (1)

  • 🔴 Blocking: Kotlin binding implements retry policy from delivery metadata — packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:144-163 (thread)
Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Swift shielded identity-create error drops Rust payment-delivery metadata
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift:1542-1551

The regular PlatformWalletError path now preserves wrapped.paymentDelivery, but the special Type-20 unconfirmed path constructs ShieldedIdentityCreateUnconfirmedError with only identityId and message. This important ambiguous-payment result therefore does not expose the Rust-owned delivery classification to Swift callers, unlike the corresponding Kotlin path and ordinary wallet errors. Add a delivery property to the custom error and pass wrapped.paymentDelivery when throwing it.

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

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: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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 large cross-language diff changes payment failure recovery and asset-lock resumption behavior, directly affecting funds movement and whether wallets fund new payments or resume held locks.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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)
  • Code unchanged since the last final review (36f17e01): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • 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 — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (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 (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/error.rs:796-888: FFI result-code mapping reimplements the wallet's delivery policy
  `PlatformWalletFFIResultCode::payment_delivery()` is a second delivery-policy table in the FFI adapter. `PlatformWalletFFIResult::err` stamps this code-derived class onto raw results, while `From<PlatformWalletError>` later overwrites it with the wallet error's more precise classification; consequently, the same FFI code has multiple semantic sources, and raw or future FFI paths can silently expose a class that does not describe the underlying operation. This is business policy in the adapter rather than marshaling. Have the owning Rust operation provide an explicit disposition and have FFI copy it; use an explicit unknown/non-payment state for results that have no wallet error instead of maintaining a second policy table.
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:3705-3740: Exhaustive FFI delivery-code mapping is only partially tested
  `PlatformWalletFFIResultCode::payment_delivery()` is a safety-sensitive code-only fallback used by `PlatformWalletFFIResult::err` and the exported `platform_wallet_ffi_result_code_payment_delivery` helper, but the test covers only five of the mapping's many codes. The separate exhaustive `PlatformWalletError` table cannot detect an incorrect class for groups such as persister codes 49–54, deferred-reservation codes 34–36, or contact-request codes 68–76. Add a table covering every `PlatformWalletFFIResultCode` and assert both the result constructor and exported helper against it.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:144-163: Kotlin binding implements retry policy from delivery metadata
  (carried; thread: https://github.com/dashpay/platform/pull/5928#discussion_r4578895207)

@romchornyi

Copy link
Copy Markdown
Contributor Author

Also fixed: the Swift ShieldedIdentityCreateUnconfirmedError dropped the delivery class (suggestion at a8f1385465). In c7910c4 it now carries the result's payment class (delivery and retry), like PlatformWalletError. Breaking Changes in the description are updated for the retryable field, Unknown = 4 and the Swift case shapes.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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 Rust, FFI, JNI, and Kotlin paths preserve the wallet-owned delivery and retry metadata, but Swift still drops it for several result-derived NotSent failures. Panic fallbacks also return Unknown metadata despite using operation-specific ambiguous-payment error codes. Kotlin tests passed in CI; Rust and Swift checks were skipped, with no failed code checks reported.

🔴 1 blocking | 🟡 1 suggestion(s)

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

🟡 Suggestion: Ambiguous panic fallbacks lose payment-delivery metadata
packages/rs-platform-wallet-ffi/src/error.rs:1791-1799

catch_panic_to_code converts every panic to PlatformWalletFFIResult::err, which now deliberately sets payment_delivery to Unknown and retryable to false. However, catch_spend_panic and catch_funding_panic select ErrorShieldedSpendUnconfirmed and ErrorTransactionBroadcastUnconfirmed specifically because a panic may occur after note reservation or broadcast; their documented contracts identify an ambiguous payment outcome. Hosts therefore cannot distinguish these known ambiguous payment failures from an unclassified FFI-boundary error. Pass an explicit payment class to the panic helper for these payment wrappers, using MaybeSent with retryable = false, while retaining Unknown for read-only or non-payment panic paths, and assert the fields in the panic tests.

source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)

Still open from earlier rounds (1)

  • 🔴 Blocking: Swift discards the result-specific payment-delivery class — packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:1264-1267 (thread)
Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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 is a large, intricate cross-language change that alters failed-payment handling, asset-lock resumption, and wallet funds-flow classification across Rust, FFI, JNI, Kotlin, and Swift.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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 — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (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 (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:1791-1799: Ambiguous panic fallbacks lose payment-delivery metadata
  `catch_panic_to_code` converts every panic to `PlatformWalletFFIResult::err`, which now deliberately sets `payment_delivery` to `Unknown` and `retryable` to false. However, `catch_spend_panic` and `catch_funding_panic` select `ErrorShieldedSpendUnconfirmed` and `ErrorTransactionBroadcastUnconfirmed` specifically because a panic may occur after note reservation or broadcast; their documented contracts identify an ambiguous payment outcome. Hosts therefore cannot distinguish these known ambiguous payment failures from an unclassified FFI-boundary error. Pass an explicit payment class to the panic helper for these payment wrappers, using `MaybeSent` with `retryable = false`, while retaining `Unknown` for read-only or non-payment panic paths, and assert the fields in the panic tests.

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:1264-1267: Swift discards the result-specific payment-delivery class
  (carried; thread: https://github.com/dashpay/platform/pull/5928#discussion_r4578895203)

@romchornyi

Copy link
Copy Markdown
Contributor Author

Also done in 1924bc2 (the panic suggestion at c7910c4e86): the panic helper now takes the payment class explicitly. The spend and funding wrappers report MaybeSent and not retryable, since a panic may come after the reservation or the broadcast; the read and reconcile wrappers keep Unknown. The panic tests assert the fields.

@romchornyi
romchornyi marked this pull request as ready for review November 15, 2026 23:47
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-self-review Waiting for the author to post /self-reviewed label Nov 15, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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 Rust wallet classification and FFI/JNI/SDK transport are consistent on this head, and the ten prior findings are fixed. However, Swift and Kotlin example applications still derive payment outcomes from error subclasses, while FFI panic wrappers hard-code payment policy outside the wallet owner; both can undermine the PR's stated duplicate-payment safety goal. The public AddressNonceMismatch guidance also contradicts its new MaybeSent/non-retryable classification. The Rust workspace check remains in progress; no failed code checks are present in the CI snapshot.

🔴 2 blocking

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

🔴 Blocking: Application layers still derive payment delivery from error-type lists
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestOutcomes.swift:120-138

The Swift helper returns mayHaveGoneThrough only for .shieldedSpendUnconfirmed and .transactionBroadcastUnconfirmed, then treats every other PlatformWalletError as an ordinary failure. The Kotlin equivalent at packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ContactRequestOutcomes.kt:116-128 has the same issue, and the shielded send helpers at packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/ViewModels/SendViewModel.swift:849-857 and packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:804-813 enumerate subclasses instead of reading native metadata. A shared result code can carry a Rust-classified MaybeSent or LockHeld result that is not represented by the selected subclass, causing the UI to present an uncertain payment as a normal failure and permit a fresh submission. These application consumers must honor PlatformWalletError.delivery/isRetryable and DashSdkError.delivery/isRetryable first; retain only application-specific states such as contact-request holds after checking the native class.

source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: AddressNonceMismatch documentation still promises an unsafe retry
packages/rs-platform-wallet/src/error.rs:834-842

payment_delivery() classifies AddressNonceMismatch as MaybeSent, and is_retryable() therefore returns false. The public documentation and rendered error still tell callers to rebuild and retry with the expected nonce. Following that text instead of the new Rust-owned retry field can resubmit a transition after an earlier dispatch and potentially create a duplicate payment. The documentation and error text must require reconciliation before another submission.

/// Platform rejected an address-funds transition because a spent address's
/// provided nonce did not equal its expected next value (DPP consensus code
/// 40603, `AddressInvalidNonceError`). An endpoint verdict may follow an
/// earlier dispatch, so the wallet classifies this as
/// [`PaymentDelivery::MaybeSent`]; reconcile the original operation before
/// submitting another transition.
#[error(
    "Address nonce mismatch for {address}: submitted nonce {provided_nonce}, \
     Platform expected {expected_nonce}; reconcile the original operation \
     before submitting another transition"
)]

source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, 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: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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) — This is a large, intricate cross-language change that alters platform-wallet payment delivery classification and retry/resume behavior for funds movement and asset-lock handling, particularly in packages/rs-platform-wallet/src/error.rs and its FFI/JNI/Swift/Kotlin boundary code.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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)
  • Code unchanged since the last final review (c7910c4e): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • 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 — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (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 (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestOutcomes.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestOutcomes.swift:120-138: Application layers still derive payment delivery from error-type lists
  The Swift helper returns `mayHaveGoneThrough` only for `.shieldedSpendUnconfirmed` and `.transactionBroadcastUnconfirmed`, then treats every other `PlatformWalletError` as an ordinary failure. The Kotlin equivalent at `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ContactRequestOutcomes.kt:116-128` has the same issue, and the shielded send helpers at `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/ViewModels/SendViewModel.swift:849-857` and `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:804-813` enumerate subclasses instead of reading native metadata. A shared result code can carry a Rust-classified `MaybeSent` or `LockHeld` result that is not represented by the selected subclass, causing the UI to present an uncertain payment as a normal failure and permit a fresh submission. These application consumers must honor `PlatformWalletError.delivery`/`isRetryable` and `DashSdkError.delivery`/`isRetryable` first; retain only application-specific states such as contact-request holds after checking the native class.

In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/shielded_send.rs:762-766: FFI panic guards still decide the payment-delivery policy
  `catch_spend_panic` and `catch_funding_panic` pass `Some((PaymentDelivery::MaybeSent, false))` directly into the FFI panic guard. Because the guard wraps the entire export body, a panic during argument decoding, wallet/coordinator lookup, or another pre-dispatch step is classified by the FFI layer rather than by the Rust wallet operation. This leaves payment-delivery and retry policy in an FFI crate, contrary to the PR's ownership boundary, and future changes to the export lifecycle can silently make the hard-coded tuple incorrect. The wallet operation should provide an explicit disposition to the boundary, or an FFI-only panic should remain `Unknown` and fail closed; the FFI wrapper should only marshal that disposition.
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.

  • Kotlin does not persist the recorded shielded recipient for asset-lock recovery — Kotlin's AssetLockEntity, persistence bridge, and persistence handler do not carry the optional shielded recipient sidecar that Swift persists. After a restart, the Kotlin shielded resume screen allows a new recipient to be selected for a held lock, weakening recipient-mismatch protection. This is an adjacent pre-existing recovery issue rather than a defect introduced by the payment-class transport.
    • Follow-up: Open a follow-up PR adding the Kotlin asset-lock sidecar schema, bridge callbacks, persistence handling, migration coverage, and recipient-bound resume validation.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Addressed in this push (head 345ef0e):

  • Application layers derive delivery from error types (blocking) — f19e808: the Swift and Kotlin example apps read PlatformWalletError.delivery / DashSdkError.delivery first (ContactRequestOutcomes in both apps, SendViewModel, SendTransactionScreen). Only the contact-request holds, which the wallet also classes as maybe sent, are matched by type before it so the views can mark the contact pending; Kotlin's rs-sdk-ffi StateTransitionResultUnconfirmed, which carries no native class, keeps its own arm. Tests cover a MaybeSent and a LockHeld result under an unrelated error type.
  • FFI panic guards decide the class (blocking) — 79d5fe4, answered on the thread.
  • AddressNonceMismatch promises a retry (suggestion) — 1bf00e8: the Rust doc and rendered error, the FFI code's doc and the Swift case's doc now ask to reconcile the original operation before submitting another transition.
  • Merged v5.2-dev: its new DocumentEraseBusy (refused before anything is sent) is classed NotSent, not retryable, with a row in the every-variant table.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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 head has two blocking Swift regressions: the new associated value on PlatformWalletError leaves existing enum-case callbacks and pattern matches uncompilable, and the generic Swift error adapter can override Rust-owned retry decisions with message-based inference. Rust also omits transient PersisterFlush failures from its retry policy, causing a real safe-retry path to be reported as non-retryable. The Swift SDK CI check fails on this head; Rust and Kotlin checks pass.

A pattern across this PR's review rounds

This is review round 5, and the PR has drawn 8 blocking findings so far. 8 of them share 2 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Payment policy is still duplicated across the boundary (1 new in this round, 7 earlier finding(s))

PlatformWalletError.payment_delivery() and is_retryable() are intended to be the source of truth, but FFI error folding, panic guards, Kotlin, Swift, and application helpers still contain their own decisions or fallbacks. Each fix repairs one route while leaving another result-code, panic, alternate-payload, or generic-error route that can classify the same payment differently, so the next review finds another copy of the policy.

In this round: Swift's generic error adapter still derives retryability from error types and messages

2. Host error construction was not migrated as one API (1 new in this round, 2 earlier finding(s))

Adding the payment class to PlatformWalletError changed both its associated-value shape and the required metadata carried through alternate construction paths. Direct Swift callbacks, enum patterns, and the Kotlin shielded-create payload were treated as isolated call sites rather than one compatibility boundary, which causes both compilation failures and loss of Rust's classification in different consumers.

In this round: Swift enum-case arity change leaves existing FFI helper call sites uncompilable

Suggested decision (redesign the component): Redesign the platform-wallet error propagation component around one typed payment disposition containing delivery, retryability, and the held outpoint. Every wallet operation should produce that disposition before crossing FFI; FFI panic and argument-validation paths with no wallet error should remain explicitly Unknown, while FFI, JNI, Swift, Kotlin, and applications only marshal and read it. Do not continue adding per-code or per-call-site policy patches until this single boundary is enforced.

🔴 3 blocking

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

🔴 Blocking: Swift enum-case arity change leaves existing FFI helper call sites uncompilable
packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift:336-430

Adding payment: PlatformPaymentClass? = nil changes PlatformWalletError.invalidParameter from a one-argument constructor to a two-argument function when referenced as a callback. The seven withDecisionProposalCString calls in this file still pass PlatformWalletError.invalidParameter directly, although the callback accepts (String) -> PlatformWalletError; Swift therefore reports conversion errors and the Swift SDK build fails. The same associated-value arity change also requires updating the unchanged transactionBroadcastUnconfirmed(_) catch patterns in DocumentsView.swift and TransitionDetailView.swift, plus the one-value invalidParameter pattern in MultipleChoiceProposalMarshallingTests.swift. Wrap each callback in a one-argument closure and match both associated values at the affected patterns.

invalid: { PlatformWalletError.invalidParameter($0) }

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)

🔴 Blocking: Swift's generic error adapter still derives retryability from error types and messages
packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:341-362

PlatformWalletError now carries Rust's payment class and retry decision, but this adapter hard-codes false only for transactionBroadcastUnconfirmed and routes every other PlatformWalletError through ErrorCategorizer and ErrorRecovery.isRetryable. A Rust-classified MaybeSent error can contain words such as network or timeout and become retryable in UserFacingError, while a Rust-approved transient NotSent error can be suppressed by a storage or unknown category. BaseViewModel.isErrorRetryable exposes this value to the application, so the mismatch can either invite a second payment or hide a safe retry. When the error carries a native payment class, the adapter must use walletError.isRetryable and must keep unclassified Swift-created errors non-retryable; generic category inference may remain only for presentation.

Raised on code unchanged since the last review, and confirmed by an independent pass: A result-built PlatformWalletError.shieldedSpendUnconfirmed("timeout", payment: .maybeSent) is categorized as .timeout because ErrorCategorizer examines the case description, so toUserFacingError returns UserFacingError.isRetryable == true even though Rust supplied retryable == false for MaybeSent. BaseViewModel exposes that value as isErrorRetryable, allowing a resubmission while the original payment may already have been sent; conversely, a Rust-approved NotSent retry can be suppressed by a non-retryable inferred category.

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

Still open from earlier rounds (1)

  • 🔴 Blocking: Payment-delivery tests do not cover most classified variants — packages/rs-platform-wallet/src/error.rs:1546-1557 (thread)
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: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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) — This is a large, intricate cross-language change that changes wallet payment-delivery classification and retry/resume behavior around asset locks, funds movement, and coin selection in packages/rs-platform-wallet/src/error.rs and related FFI/JNI/Swift/Kotlin boundaries.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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)
  • Code unchanged since the last final review (730a1527): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • 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 — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (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
Several findings on this PR share an underlying cause (the review's "pattern" section): Payment policy is still duplicated across the boundary; Host error construction was not migrated as one API. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Redesign the platform-wallet error propagation component around one typed payment disposition containing delivery, retryability, and the held outpoint. Every wallet operation should produce that disposition before crossing FFI; FFI panic and argument-validation paths with no wallet error should remain explicitly Unknown, while FFI, JNI, Swift, Kotlin, and applications only marshal and read it. Do not continue adding per-code or per-call-site policy patches until this single boundary is enforced. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift:336-430: Swift enum-case arity change leaves existing FFI helper call sites uncompilable
  Adding `payment: PlatformPaymentClass? = nil` changes `PlatformWalletError.invalidParameter` from a one-argument constructor to a two-argument function when referenced as a callback. The seven `withDecisionProposalCString` calls in this file still pass `PlatformWalletError.invalidParameter` directly, although the callback accepts `(String) -> PlatformWalletError`; Swift therefore reports conversion errors and the Swift SDK build fails. The same associated-value arity change also requires updating the unchanged `transactionBroadcastUnconfirmed(_)` catch patterns in `DocumentsView.swift` and `TransitionDetailView.swift`, plus the one-value `invalidParameter` pattern in `MultipleChoiceProposalMarshallingTests.swift`. Wrap each callback in a one-argument closure and match both associated values at the affected patterns.

In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:341-362: Swift's generic error adapter still derives retryability from error types and messages
  `PlatformWalletError` now carries Rust's payment class and retry decision, but this adapter hard-codes `false` only for `transactionBroadcastUnconfirmed` and routes every other `PlatformWalletError` through `ErrorCategorizer` and `ErrorRecovery.isRetryable`. A Rust-classified `MaybeSent` error can contain words such as `network` or `timeout` and become retryable in `UserFacingError`, while a Rust-approved transient `NotSent` error can be suppressed by a storage or unknown category. `BaseViewModel.isErrorRetryable` exposes this value to the application, so the mismatch can either invite a second payment or hide a safe retry. When the error carries a native payment class, the adapter must use `walletError.isRetryable` and must keep unclassified Swift-created errors non-retryable; generic category inference may remain only for presentation.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: A result-built PlatformWalletError.shieldedSpendUnconfirmed("timeout", payment: .maybeSent) is categorized as .timeout because ErrorCategorizer examines the case description, so toUserFacingError returns UserFacingError.isRetryable == true even though Rust supplied retryable == false for MaybeSent. BaseViewModel exposes that value as isErrorRetryable, allowing a resubmission while the original payment may already have been sent; conversely, a Rust-approved NotSent retry can be suppressed by a non-retryable inferred category._

In `packages/rs-platform-wallet/src/error.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/error.rs:1546-1557: Payment-delivery tests do not cover most classified variants
  (carried; thread: https://github.com/dashpay/platform/pull/5928#discussion_r4578895214)

@romchornyi

Copy link
Copy Markdown
Contributor Author

Round 5, at 0864058:

  • Swift enum-case arity (blocking): fixed in a6b101c. The seven withDecisionProposalCString calls that came in with the v5.2-dev merge pass { PlatformWalletError.invalidParameter($0) }, and the DocumentsView/TransitionDetailView catches and the MultipleChoiceProposalMarshallingTests pattern match both associated values. This was the Swift SDK CI failure; packages/swift-sdk/run_tests.sh now builds and passes locally (BUILD SUCCEEDED, TEST SUCCEEDED).
  • Swift generic error adapter (blocking): fixed in e98ba29. ErrorCategorizer.toUserFacingError takes isRetryable from the wallet error's Rust class for every PlatformWalletError (false when unclassified); the inferred category now only shapes the presentation. testShouldTakeTheUserFacingRetryFromTheWalletErrorsClass pins a maybe-sent "timeout", a Rust-approved retry with a "storage" message, and an unclassified error.
  • Payment-delivery test coverage (carried): already resolved on its thread at a8f13854 (a row for every variant, plus ordinal and count guards). Resolving the thread.
  • PersisterFlush in the retry policy (summary): declined, now spelled out in 0864058. A transient flush means the operation's record is still buffered and may commit at a later flush, so running the operation again could write a second record (a second prepared payment) next to it. The retry a transient flush allows is another flush, not the operation. should_not_retry_an_operation_whose_flush_failed pins it for every kind.
  • Suggested redesign: the disposition is already one Rust-owned value (payment_delivery() + is_retryable(), with the held outpoint) that FFI, JNI, Swift and Kotlin copy; this round's two Swift findings were a call site that did not compile and an adapter that did not read it yet, both fixed above. A broader reshaping of the error propagation would be a separate follow-up PR, not this one.

Rust: CI clippy set (--all-features), cargo test -p platform-wallet -p platform-wallet-ffi --all-features (2105 + 591) and fmt pass.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 18, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

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

One in-scope blocking security issue remains in the Swift generic error adapter. It forwards Rust's retry flag for LockHeld failures but drops the held-lock delivery and outpoint, so generic callers can mistake a resume-only retry for permission to submit a new payment; no CodeRabbit findings were present, and CI shows no failed code checks, with Rust workspace tests still in progress.

A pattern across this PR's review rounds

This is review round 6, and the PR has drawn 9 blocking findings so far. 8 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. The host error path still carries a retry bit instead of the payment disposition (1 new in this round, 10 earlier finding(s))

Rust now knows a coupled disposition—delivery, retryability, and the held outpoint—but the boundary exposes and reconstructs those pieces independently. PlatformWalletError carries PlatformPaymentClass, while ErrorCategorizer.toUserFacingError copies only isRetryable into UserFacingError; a LockHeld retry therefore reaches generic callers without the outpoint and can be mistaken for permission to run the original payment again. Earlier fixes repair individual FFI, JNI, Swift, Kotlin, and application routes, but the absence of one end-to-end typed contract leaves another adapter to drop or reinterpret a field.

In this round: Swift's generic user-facing error drops LockHeld semantics while exposing retry=true

Suggested decision (redesign the component): Redesign the host error-propagation component around one typed payment disposition carried from Rust through FFI/JNI/Swift/Kotlin and into UserFacingError, including delivery, retryability, and the held outpoint. Generic retry handling must preserve that disposition, and LockHeld must dispatch only to the named-lock resume path rather than rerunning the original payment. Do not add another per-layer conversion or retry-bit fallback until this contract is enforced.

🔴 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: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate cross-language change to platform-wallet payment failure handling that directly controls retry, asset-lock resumption, and whether funds may be sent or funded again.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): The host error path still carries a retry bit instead of the payment disposition. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Redesign the host error-propagation component around one typed payment disposition carried from Rust through FFI/JNI/Swift/Kotlin and into UserFacingError, including delivery, retryability, and the held outpoint. Generic retry handling must preserve that disposition, and LockHeld must dispatch only to the named-lock resume path rather than rerunning the original payment. Do not add another per-layer conversion or retry-bit fallback until this contract is enforced. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:357-360: Swift's generic user-facing error drops LockHeld semantics while exposing retry=true
  `ErrorCategorizer.toUserFacingError` copies `PlatformWalletError.isRetryable` into `UserFacingError`, but `UserFacingError` carries neither `PlatformPaymentDelivery` nor the held asset-lock outpoint. Rust sets `isRetryable == true` for `LockHeld` only because the retry must resume the named lock; it must never create or fund a new payment. The generic adapter therefore exposes `UserFacingError.isRetryable == true` without the information needed to perform the required resume, and a caller such as a generic retry handler can rerun the original payment operation, potentially creating a second payment while the first lock remains resumable. Preserve the payment class and outpoint through this adapter, or fail closed for `LockHeld` until a resume-specific API is available.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 18, 2026
The ChainLock fallback's error is wrapped as unconfirmed, which hid
Platform's consumed-outpoint verdict from the adoption check, so a claim
whose InstantSend primary had landed reported a failure instead of its
identity. The check now reads the verdict through the wrapper and keeps the
wrapper when nothing is adopted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
romchornyi added a commit that referenced this pull request Nov 28, 2026
…ror to the hosts

Second part of the split of #5928, on top of the payment class itself.
The remaining wallet paths now set their class (DPNS and the
marketplace, contact requests, credit and token shielded spends and
plans, shielded tips, the shielded seed batch and the wallet drain,
masternode withdrawals), and every FFI result carries Rust's class:
`payment_delivery`, `retryable` and the held asset lock's outpoint on
`PlatformWalletFFIResult`, set from the wallet error by the blanket
conversion and every result mapper, never inferred from the code. A
panic in a payment export is classed as possibly sent.
ERROR_CODE_REGISTRY.md documents the class per code. Swift and Kotlin
read it in the next two PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
romchornyi added a commit that referenced this pull request Nov 28, 2026
Third part of the split of #5928. `PlatformWalletError` carries the FFI
result's `PlatformPaymentClass` (delivery, retry, and the held asset
lock under `LockHeld`) on every case, read from the result and never
derived from the code; texts and recovery suggestions follow it, and a
guard that throws after a successful FFI call carries a class too.
SwiftExampleApp presents a payment failure by its class: it holds a
payment's slot unless nothing was sent, names a held voucher or lock,
and releases a hold only once the user reconciled it.

BREAKING CHANGE: `PlatformWalletError` cases gain a `payment:` field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
romchornyi added a commit that referenced this pull request Nov 28, 2026
Last part of the split of #5928. The JNI bridge carries the FFI result's
payment class into `DashSDKException`, including the error beside a
wallet drain's packed outcome, and `DashSdkError.PlatformWallet` exposes
`delivery`, `isRetryable` and `heldAssetLock` from it; `PaymentRecovery`
reads it for hosts, and texts follow it. KotlinExampleApp's payment
screens follow the class: a payment's slot is held unless nothing was
sent, a held invitation voucher is reclaimed and named, and a reconciled
hold is released only after confirmation. The SDK parity manifest gets
the `errors.payment_class` capability (Swift and Kotlin).

BREAKING CHANGE: `DashSDKException` gains the payment class fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown
Collaborator

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

GitHub still shows changes requested by this bot (review of 3b8e0079). Nothing on this head blocks except the disputed finding(s) below, which are left to the maintainers: a maintainer can dismiss that earlier review if they agree it no longer applies.

Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.

New on this head: This head only updates invitation-claim adoption so a consumed-outpoint verdict remains visible through the unconfirmed ChainLock fallback wrapper, and adds regression coverage for adoption and non-adoption outcomes. CI has no reported failures; Rust workspace tests and review-policy checks are still in progress.

🔴 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: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This large and intricate diff changes wallet funding, asset-lock tracking, coin-selection flows, payment dispatch classification, and recovery behavior in functions such as AssetLockManager::with_funded_lock and shielded funding, directly affecting funds movement.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 quota lookup failed), 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.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-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.

Not approved: 1 blocking finding(s) are disputed and left to the maintainers.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@romchornyi
romchornyi dismissed thepastaclaw’s stale review November 28, 2026 11:32

Superseded: the blocking finding was fixed in 81671e6 and thepastaclaw confirmed it resolved at that head.

@romchornyi

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review — rust-sdk: lklimek or shumkov.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 30, 2026

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed after the split at 81671e6. I compared this stack with what I approved at 5f5b560: the only differences are the five new commits and v5.2-dev drift, so nothing was lost or added. The invitation-claim commits look right to me and don't open a double-claim path. Locally, platform-wallet 2990/2990, dash-sdk invitation tests 95/95 and platform-wallet-ffi 641 passed; clippy is clean.

Worth a small follow-up commit:

  1. rs-sdk/src/platform/dashpay/invitation.rs:1507-1509: 3b8e007 wraps every ChainLock-fallback error as unconfirmed, but keys_taken_on_broadcast (:1205) reads consensus_error(), which returns None through that wrapper (rs-sdk/src/error.rs:327). A fallback refused with 40207 is therefore reported as code 20 instead of KeysAlreadyRegistered (63). The class is MaybeSent either way, so only the diagnostic is lost. Unwrapping before the check, as 81671e6 does for the consumed check, would fix it, and there is no test for this path yet.
  2. invitation.rs:1591-1598 reports_consumed_out_point only looks through an outer unconfirmed wrapper. An unconfirmed error nested inside NoAvailableAddressesToRetry wouldn't be adopted. I haven't confirmed the retry layer produces that shape.
  3. Stale docs:
    • submit_claim_with_chain_lock_fallback still says fallback errors propagate as InvitationError::Sdk.
    • platform_wallet.rs:2394-2401 promises a zero-amount transfer arrives as RefusedBeforeDispatch, but that wrapping only lands in #6379.

PR text:

  • Breaking Changes lists items that are in #6379–#6381 rather than here: retry over the FFI, Swift/Kotlin timeout retry, the Kotlin isRetryable overrides, token_pool_spend_preview_for, and the code-35 host behaviour.
  • The title needs ! for the InvitationError / AssetLockNotChainLocked shape changes.
  • dash-sdk --lib has 1086 tests, not 1085, and the JNI count doesn't apply to this part.

@github-actions
github-actions Bot removed the request for review from ZocoLini November 30, 2026 17:00

@lklimek lklimek 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.

reviewed rs-sdk only

@github-actions
github-actions Bot removed the request for review from shumkov December 1, 2026 11:13
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Dec 1, 2026
@romchornyi
romchornyi merged commit 81fc62e into v5.2-dev Dec 1, 2026
42 checks passed
@romchornyi
romchornyi deleted the feat/platform-wallet-payment-delivery branch December 1, 2026 11:16
romchornyi added a commit that referenced this pull request Dec 1, 2026
#5928 was squashed into v5.2-dev, so error.rs and shielded_send.rs keep this
branch's side. map_tip_send_result reads through the payment-class wrapper, as
the other mappers do, so a wrapped refusal keeps its code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
llbartekll added a commit that referenced this pull request Dec 1, 2026
…t class

#5928 added matches without a wildcard arm over PlatformWalletError.
WithdrawalAmountOutOfRange is raised while the withdrawal is planned,
so it is NotSent, not retryable with the same amount, and does not
refuse the resume of a tracked asset lock, like its shielded sibling.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
HashEngineering added a commit that referenced this pull request Dec 1, 2026
…latform-wallet-top-up-someone-elses-identity-fr

Resolves the conflicts with #5928 (payment delivery classes):
- payment_delivery, is_retryable, refuses_resume and the variant table
  classify this PR's asset-lock variants: AssetLockIdentityRecipientMismatch
  and AssetLockIdentityNotLoaded hold the lock (LockHeld), as
  AssetLockRecipientMismatch does; AssetLockRecipientUnknown and
  AssetLockAbandonedBeforeSend are NotSent and refuse a resume;
  AssetLockConsumptionUnknown is MaybeSent.
- The post-acceptance conversion to TransactionBroadcastUnconfirmed runs
  inside the funded-lock seam, and only once the wallet or row is gone,
  so a failed read of a still-tracked lock keeps naming it as held.
- tracked_resume_metadata keeps returning TrackedResumeMetadata, which
  carries the shielded recipient the upstream tuple added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

5 participants