Skip to content

feat(swift-example-app)!: unshield tokens from a token shielded pool to an identity (type 27) - #6133

Merged
QuantumExplorer merged 57 commits into
v5.1-devfrom
feat/swift-example-shielded-token-unshield
Nov 23, 2026
Merged

QuantumExplorer merged 57 commits into
v5.1-devfrom
feat/swift-example-shielded-token-unshield

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

A wallet can now move tokens it holds in a token's shielded pool into an identity's ordinary token balance. This is a TokenUnshieldWithShieldedFee, state transition type 27. The fee is paid from the wallet's credit shielded pool notes. Both token spend forms now also show the fee before sending.

Before: tokens in a token shielded pool could only be seen (#6116) or sent to another shielded address (#6132). The send form gave no fee.

After:

  • Unshield action. Each token row has an Unshield action. Its form takes:
    • a recipient: one of the wallet's identities, or a pasted base58 id;
    • an amount in the token's smallest units.
  • Fee line. Both the Send and the Unshield forms show the fee Rust previews as the amount changes, or the reason Rust would refuse.
  • Activity. An unshield appears in Shielded Activity as "Token Unshield", with its credited identity.

This PR is stacked on #6132, which is stacked on #6116.

Issue being fixed or feature implemented

Test plan row SH-27: unshield a token to an identity. It was blocked on the token pool note sync (#6116) and on the token pool spend machinery (#6132).

What was done?

rs-platform-wallet

One spend function for both types

  • The type 26 operation becomes one token pool spend, token_pool_spend, with a target: an Orchard address in the pool (type 26) or an identity's token balance (type 27).
  • token_shielded_transfer and the new token_unshield are thin wrappers over it.
  • Both share:
    • the token note reservation;
    • the Merkle paths and their recorded-anchor check;
    • the re-check of both anchors and the network version after proving;
    • the credit pool fee bundle, the record, the redrive and the settlement.
  • What differs per target:
    • the DPP builder (build_token_unshield_with_shielded_fee_transition);
    • the protocol gate;
    • the fee: type 27 also prices the recipient's token balance write (DPP's compute_token_unshield_with_shielded_fee_fee);
    • the size bound;
    • the activity kind.

Fee kinds and limits

Activity

  • ShieldedActivityKind::TokenUnshield { identity_id }, persisted with tag 12. Its counterparty is the token id, and it carries the credited identity the way IdentityTopUp does.

What the proof binds

  • Type 27's proof is the recipient's token balance at the proof's block, which binds nothing of this unshield.
  • An accepted unshield therefore stays pending (ShieldedTokenSpendOutcome::Submitted) until the scans see it, like types 26 and 28. feat(swift-example-app)!: send tokens within a token shielded pool (type 26) #6132's settlement rules cover it: from protocol 15 an unshield that can no longer execute is marked failed and its notes released; at 14 its notes stay held once its fee anchor was pruned.

Fee preview

  • token_pool_spend_preview, exposed as ShieldedTokenPurchaser::preview_spend, picks the token and fee notes the spend would pick.
  • It returns their counts and the fee, or the refusal the spend would meet on these notes.
  • It reads no network and reserves nothing.

Other changes

  • Saved recovery records accept type 27.
  • The activity row is keyed by the fee bundle.
  • PlatformWallet::shielded_token_unshield and ShieldedTokenPurchaser::unshield are the entry points. Like the transfer, the unshield holds the operation guard through settlement and checks the wallet is still bound to the coordinator under the shielded config lock. The purchaser requests the follow-up sync.

rs-sdk

  • token_unshield_with_shielded_fee_requirement() (protocol 14) is registered in the broadcast gate.

rs-platform-wallet-ffi, Swift SDK, SwiftExampleApp

  • FFI exports. Two new exports only marshal: the unshield, and the preview.
  • Shared result mapping. The transfer's result mapping is shared with the unshield.
  • Persisted activity. Decoding maps tag 12 and its identity, which may be absent.
  • Swift wrappers. Added for both exports, admitted as native operations so shutdown waits for them.
  • App:
    • the Unshield form, with an identity picker;
    • a debounced fee line on both forms, which only shows what Rust returns;
    • the "Token Unshield" activity label in token units.
  • SwiftData: no @Model change.
  • Docs: TEST_PLAN SH-27 is updated, and SH-26 now mentions the fee line. The parity manifest gains shielded.token_unshield.

New public interfaces

C FFI

PlatformWalletFFIResult platform_wallet_manager_shielded_token_unshield(
    Handle handle, const uint8_t *wallet_id_bytes,
    MnemonicResolverHandle *mnemonic_resolver_handle, uint32_t account,
    const uint8_t *data_contract_id, uint16_t token_contract_position,
    const uint8_t *recipient_identity_id /* 32 bytes */, uint64_t amount);

PlatformWalletFFIResult platform_wallet_manager_shielded_token_spend_preview(
    Handle handle, const uint8_t *wallet_id_bytes, uint32_t account,
    const uint8_t *data_contract_id, uint16_t token_contract_position,
    uint8_t kind /* 0 shielded transfer, 1 unshield */, uint64_t amount,
    uint64_t *out_fee, uint32_t *out_token_notes, uint32_t *out_fee_notes);
  • Unshield: maps its outcome as the transfer does.
  • Preview, check order: null pointers, then the kind byte (anything else is ErrorInvalidParameter), then the handle.
  • Preview refusal: returns ErrorWalletOperation with Rust's message, and leaves the out values untouched.

Swift

  • shieldedTokenUnshield(walletId:resolver:account:dataContractId:tokenContractPosition:recipientIdentityId:amount:) async throws
  • shieldedTokenSpendPreview(walletId:account:dataContractId:tokenContractPosition:kind:amount:) async throws -> ShieldedTokenSpendPreview
  • enum ShieldedTokenPoolSpendKind: UInt8 { shieldedTransfer = 0, unshield = 1 }
  • struct ShieldedTokenSpendPreview { tokenNotes: UInt32, feeNotes: UInt32, fee: UInt64 }

Rust (platform-wallet)

  • token_unshield(...), PlatformWallet::shielded_token_unshield(...), ShieldedTokenPurchaser::unshield(...)
  • token_pool_spend_preview(store, id, token_id, kind, amount, platform_version), ShieldedTokenPurchaser::preview_spend(...), ShieldedTokenSpendPreview { token_notes, fee_notes, fee }
  • TokenPoolSpendKind { ShieldedTransfer, Unshield }, with fee, max_token_notes and max_fee_notes
  • ShieldedFeeKind::TokenPoolSpend { kind, token_actions }
  • ShieldedActivityKind::TokenUnshield { identity_id }, tag 12

Rust (dash-sdk)

  • token_unshield_with_shielded_fee_requirement()

Rust (dpp)

  • TokenUnshieldWithShieldedFeeTransitionV0::is_valid_amount(amount): see "In-place changes to shipped generations".

Persisted state

  • Activity tag 12 in the existing kindTag column, with the credited identity in the existing identity column.

App accessibility identifiers

  • Row action: shieldedTokens.unshieldButton
  • Unshield form: shieldedTokenUnshield.form, .identityPicker, .recipient, .recipientName, .pasteButton, .amount, .fee, .submit, .result, .error, .close
  • Send form fee line: shieldedTokenSend.fee

How Has This Been Tested?

  • cargo test -p platform-wallet --features shielded --lib -- token_pool token_shielded token_unshield token_pool_spend coordinator note_selection: 94 passed on the latest head. They include:
    • should_refuse_and_release_a_token_unshield_as_the_transfer_does: a token shortfall holds nothing, and a failure before the broadcast releases both reservations;
    • should_preview_a_token_pool_spend_without_reserving: for both kinds, the preview picks the notes the spend would, its fee equals the consensus fee, it refuses a token shortfall, and it holds nothing;
    • should_bound_token_pool_spends_and_price_them_as_consensus_does: both kinds fit at least one token note and one fee note, and the fee kind equals DPP's formula;
    • the settlement test, run for both kinds at protocol 14 and 15, for a spend whose fee anchor was pruned and for one cut off before it was saved.
  • cargo test -p dpp --lib -- token_unshield: 20 passed.
  • cargo test -p dash-sdk --lib should_refuse_a_generic_broadcast: 5 passed, including the type 27 gate.
  • cargo test -p platform-wallet-ffi --features shielded --lib -- token_transfer token_unshield token_spend_preview token_pool_spend shielded_token_pools: 23 passed. The new ones cover:
    • unshield result mapping, null pointers and an unknown manager;
    • preview null pointers, including each out pointer;
    • a bad kind, and an unknown manager.
  • cargo clippy with CI's flags on platform-wallet and platform-wallet-ffi, and cargo fmt --all: clean on the latest head.
  • packages/swift-sdk/build_ios.sh --target sim (release): BUILD SUCCEEDED, including SwiftExampleApp built with warnings as errors, before the latest review round. That round's Swift change is one default argument value.

Not yet verified

  • No simulator run and no broadcast against a network. SH-27 says so.
  • No real-prover build of type 27 in the wallet crate. DPP's builder has its own tests.
  • No FFI test reaches a successful preview, because that needs a configured shielded manager. The success path is covered by the Rust test above.
  • The fee line refreshes when the amount changes, not when a sync changes the notes while the form is open.
  • The SwiftExampleAppTests target was not run.

In-place changes to shipped generations

TokenUnshieldWithShieldedFeeTransitionV0::validate_structure is structure validation v0, which shipped protocol version 14 selects. It now asks !Self::is_valid_amount(self.amount) instead of self.amount == 0 || self.amount > MAX_DISTRIBUTION_PARAM.

The new predicate is amount != 0 && amount <= MAX_DISTRIBUTION_PARAM, so its negation is exactly the old condition. The order of checks and the error built (InvalidTokenAmountError(MAX_DISTRIBUTION_PARAM, amount)) are unchanged, so no transition is accepted or refused differently.

should_bound_the_unshield_amount_at_the_shipped_protocol_version pins this at PlatformVersion::get(14): amounts 0 and max + 1 are refused, and max is accepted. This is the same refactor #6090 made for type 28's is_valid_token_count.

The predicate exists so the wallet and DPP's unshield builder can ask the same rule instead of repeating it. DPP's unshield builder is client code, not consensus. It now also refuses an amount over the limit before proving.

Breaking Changes

Rust source only: new variants on the public ShieldedFeeKind and ShieldedActivityKind enums, which are not #[non_exhaustive], so Rust code that matches them exhaustively must add them. Nothing changes at the protocol, consensus, C ABI (additive) or SwiftData level.

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · cb2a14f

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build running
  • Approvals
    • sdk-parity — you own it
    • kotlin-sdk (packages/kotlin-sdk/PARITY_SUMMARY.md) — HashEngineering
    • dpp — you own it
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/persistence.rs, packages/rs-platform-wallet-ffi/src/shielded_persistence.rs, packages/rs-platform-wallet-ffi/src/shielded_send.rs) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • rs-platform-wallet (packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs, packages/rs-platform-wallet/src/wallet/platform_wallet.rs, packages/rs-platform-wallet/src/wallet/shielded/activity.rs and 7 more) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • rust-sdk (packages/rs-sdk/src/platform/transition/broadcast.rs, packages/rs-sdk/src/sdk/protocol_gate_tests.rs) — lklimek or shumkov
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentShieldedActivity.swift, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift and 3 more) — llbartekll or romchornyi

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.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6559041 and cb2a14f.

Files selected for processing: 26

  • docs/sdk/sdk-parity-manifest.json
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/rs-dpp/src/shielded/builder/token_pool_paid.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/token_unshield_with_shielded_fee_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/token_unshield_with_shielded_fee_transition/v0/state_transition_validation.rs
  • packages/rs-platform-wallet-ffi/src/persistence.rs
  • packages/rs-platform-wallet-ffi/src/shielded_persistence.rs
  • packages/rs-platform-wallet-ffi/src/shielded_send.rs
  • packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs
  • packages/rs-platform-wallet/src/wallet/platform_wallet.rs
  • packages/rs-platform-wallet/src/wallet/shielded/activity.rs
  • packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs
  • packages/rs-platform-wallet/src/wallet/shielded/file_store.rs
  • packages/rs-platform-wallet/src/wallet/shielded/mod.rs
  • packages/rs-platform-wallet/src/wallet/shielded/note_selection.rs
  • packages/rs-platform-wallet/src/wallet/shielded/operations.rs
  • packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs
  • packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs
  • packages/rs-sdk/src/platform/transition/broadcast.rs
  • packages/rs-sdk/src/sdk/protocol_gate_tests.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentShieldedActivity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift
  • packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
  • 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

@thepastaclaw

thepastaclaw commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress (commit cb2a14f) · live progress

@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 607b0ea to f077a6e Compare November 23, 2026 09:55
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 53d823e to 6274695 Compare November 23, 2026 10:32
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 5527386 to 1c17c4d Compare November 23, 2026 10:34
@QuantumExplorer
QuantumExplorer marked this pull request as ready for review November 23, 2026 10:36
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 6274695 to 764dc02 Compare November 23, 2026 10:55
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 1c17c4d to 0200250 Compare November 23, 2026 10:59
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 764dc02 to d4641ac Compare November 23, 2026 11:01
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 0200250 to eccc2ca Compare November 23, 2026 11:01
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from d4641ac to 73d63a8 Compare November 23, 2026 11:04
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from eccc2ca to 24e3c40 Compare November 23, 2026 11:04
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 73d63a8 to 4fad076 Compare November 23, 2026 11:11
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 24e3c40 to e759e0f Compare November 23, 2026 11:12
@QuantumExplorer QuantumExplorer added this to the v5.1.0 milestone Nov 23, 2026
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 4fad076 to 6d9d794 Compare November 23, 2026 11:16
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from e759e0f to 9666c3c Compare November 23, 2026 11:16

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

⚠️ DEGRADED — Final validation — Phase 2 only (queue backlog)

⚠️ DEGRADED review. The primary review models were unavailable (gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models: gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped at high effort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.

Nothing blocks: no blocking finding stands on this head.

Stacked change adds type-27 token unshield as a unified token-pool spend with a local fee preview plus FFI/Swift wiring. CI shows CodeRabbit success with remaining checks queued or pending.

🟡 2 suggestion(s) | 💬 1 nitpick(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: platform-versioning); reviewer 5: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 6: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 9: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 10: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: platform-versioning); reviewer 11: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 12: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: security-auditor); final verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: sol-verifier, role: final-verifier)

  • Degraded mode: gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-11-23T09:07:27Z); stand-ins gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor; Phase 1 effort capped at high
  • Triage: critical by muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (effort low) — Large +2000-line change whose token_pool_spend in operations.rs directly changes shielded funds movement, note selection, and fee handling.
  • Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — final-verifier; agent sol-verifier
  • Phase 2 reviewers: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — ffi-engineer (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — platform-versioning (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — rust-quality (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — security-auditor (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — ffi-engineer (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — platform-versioning (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — rust-quality (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for 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 (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/src/manager/shielded_token_purchase.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs:186-206: Fee preview quotes a fee the spend refuses when SDK and network versions disagree
  Impact: A wallet whose SDK version differs from the verified network version sees a preview fee and then gets a ShieldedProtocolVersionMismatch refusal at submit time.
  The form can show a fee for a spend that cannot proceed. The spend resolves its version with token_pool_paid_signing_version(sdk.version(), verified_version) before reserving anything and refuses on SDK/network skew, while preview_spend passes self.wallet.sdk().version() straight into token_pool_spend_preview with no equivalent check. Fee and max-note bounds are version-dependent, so counts can also diverge. The preview docs disclose SDK-version pricing and that network/config/anchor refusals stay spend-only, but the cached verified version needs no network read. Resolve the preview through the same helper using only cached state, or name the version-mismatch case explicitly in the preview docs so the fee line and submit path agree.

In `packages/rs-platform-wallet/src/wallet/shielded/operations.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:10190-10237: Preview tests miss documented fee-shortfall and too-many-notes refusals
  Impact: A regression in the preview fee-credit or note-cap branches ships with the fee-line tests still green.
  The form's fee line depends on refusal paths with no coverage. token_pool_spend_preview documents four local refusals, but should_preview_a_token_pool_spend_without_reserving exercises only the happy path and the token-shortfall error. Add preview cases for amount zero, credit notes that cannot cover the fee, and dust notes forcing more fee notes than max_fee_notes allows, plus one parity assertion that the preview fee/counts match the spend reservation on the same fixture.

In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [NITPICK] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1939-1941: Preview note counts saturate to u32::MAX instead of failing on overflow
  Impact: If a note count ever exceeded u32 range, Swift would read 4294967295 as a valid count on a Success result instead of getting an error.
  An unreachable overflow becomes a successful preview with sentinel counts. u32::try_from(preview.token_notes).unwrap_or(u32::MAX) and the fee-notes twin silently saturate; counts are small today so this cannot trigger, but sentinels then flow into ShieldedTokenSpendPreview as if real. Return ErrorWalletOperation on conversion failure instead of saturating, preserving the export's contract that out values are untouched on refusal and meaningful on success.

@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 6d9d794 to f47751a Compare November 23, 2026 12:22
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from f90c26a to d9c0d55 Compare November 23, 2026 12:22
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from f47751a to 8b6d786 Compare November 23, 2026 12:24
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from d9c0d55 to 285f692 Compare November 23, 2026 12:24
QuantumExplorer and others added 2 commits November 23, 2026 19:31
… 26)

The wallet builds a TokenShieldedTransferWithShieldedFee from an
account's notes in a watched token pool, paying the fee from its credit
pool notes. Token notes are reserved in the token pool tables, largest
first and bounded by what fits one transition; their Merkle paths come
from the leaves the scan kept, and their root must be an anchor the
token pool records. An accepted transfer stays pending: its proof shows
its token nullifiers spent, which does not bind this transfer. A sync
pass releases the token notes of a spend that holds no saved record and
is not in flight. The SDK gates the transition at protocol version 14.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he Shielded Tokens screen

FFI export platform_wallet_manager_shielded_token_transfer marshals a
type 26 transfer (raw 43-byte Orchard recipient) to the manager's
purchaser, which requests the follow-up sync itself. The balances row
gains reserved_balance. The Swift SDK wraps the transfer, and the
Shielded Tokens screen gets a Send form per token row, a Pending line
for reserved tokens, and a "Token Transfer" label for activity tag 11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-spend branch from 8b6d786 to 0011c08 Compare November 23, 2026 12:34
@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 285f692 to 6d130cf Compare November 23, 2026 12:35

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

⚠️ DEGRADED — Re-review — Final validation — Phase 1 + Phase 2

⚠️ DEGRADED review. The primary review models were unavailable (gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models: gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped at high effort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.

Nothing blocks: no blocking finding stands on this head.

New on this head: This stacked PR unifies the type-26/27 token pool spends behind one reservation path and adds a store-only fee preview with a type-27 unshield exposed through FFI and Swift. CI at this head shows policy, title and explorer checks passing with PastaClaw review in progress and Kotlin queued and no failed code checks.

🟡 1 suggestion(s) | 💬 2 nitpick(s)

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

💬 Nitpick: ShieldedActivityFFI identity_id docs still claim only IdentityCreate carries an identity while four kinds now do
Impact: A host reading the generated C header for kind 12 rows may ignore the credited identity this PR delivers because the docs say identity_id is only meaningful for kind 6.
packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:162-166

Hosts coding against the C header will mis-handle tag 12 activity because the contract they read is wrong. The encoder (packages/rs-platform-wallet-ffi/src/persistence.rs:3629-3641) now sets identity_id with has_identity_id = 1 for kinds 6, 8, 9 and new 12, and the kind_tag doc above was updated to say 12 carries the credited identity, but the identity_id/has_identity_id docs below still say meaningful only for kind 6 / IdentityCreate. Reword both comments to name the four identity-bearing kinds to match the encoder and the Swift-side doc already corrected.

    /// Identity id when `has_identity_id` is 1: the created identity for
    /// `kind_tag == 6`, the debited identity for 8, the topped-up identity
    /// for 9 and the credited identity for 12; all-zero otherwise.
    pub identity_id: [u8; 32],
    /// `1` when `identity_id` is meaningful (kinds 6, 8, 9 and 12), else `0`.
    pub has_identity_id: u8,

source: glm-5.3-flash (phase1-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: security-auditor); reviewer 6: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 7: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); final verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: sol-verifier, role: final-verifier)

  • Degraded mode: gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-11-23T09:07:27Z); stand-ins gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor; Phase 1 effort capped at high
  • Triage: critical by muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (effort low) — Large wallet change adds funds-moving token_pool_spend in shielded/operations.rs with note selection and fee-bundle signing.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 64% left, weekly 93% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — final-verifier; agent sol-verifier
  • Phase 2 reviewers: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — ffi-engineer (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-astra) — rust-quality (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for 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 (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/shielded_persistence.rs`:
- [NITPICK] packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:162-166: ShieldedActivityFFI identity_id docs still claim only IdentityCreate carries an identity while four kinds now do
  Impact: A host reading the generated C header for kind 12 rows may ignore the credited identity this PR delivers because the docs say identity_id is only meaningful for kind 6.
  Hosts coding against the C header will mis-handle tag 12 activity because the contract they read is wrong. The encoder (packages/rs-platform-wallet-ffi/src/persistence.rs:3629-3641) now sets identity_id with has_identity_id = 1 for kinds 6, 8, 9 and new 12, and the kind_tag doc above was updated to say 12 carries the credited identity, but the identity_id/has_identity_id docs below still say meaningful only for kind 6 / IdentityCreate. Reword both comments to name the four identity-bearing kinds to match the encoder and the Swift-side doc already corrected.

In `packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs`:
- [NITPICK] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:831-864: select_token_notes keeps a vestigial scope block left over from the reserve split
  Impact: A future editor of note selection must waste time proving the inner braces scope nothing before changing the selection logic.
  Reader cost with no behavior: the extraction of select_token_notes out of reserve_token_notes kept the inner `{ ... }` block from the original closure body, and the block is now the whole function body. Nothing borrows `conn` across the edge (`notes()` returns an owned Vec) and no guard is dropped early, so the braces scope nothing while suggesting a lifetime constraint that does not exist. Delete the braces and dedent the body; behavior-preserving and mechanical.

In `packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs:199-214: The preview's version-mismatch refusal has no test to keep it from regressing
  Impact: A future edit reverting preview_spend to SDK-version pricing would silently reintroduce fee-line/submit disagreement with all tests still green.
  The fee line can drift from the submit path again with no test failing. The fix routes ShieldedTokenPurchaser::preview_spend through token_pool_paid_signing_version from cached verified state, but every preview test calls token_pool_spend_preview directly with PlatformVersion::latest(), so the purchaser-level delegation at lines 205-213 executes in no test while the manager tests cover only purchase_needs_shielded_sync. Add a test that builds the purchaser with sdk version != verified version and asserts ShieldedProtocolVersionMismatch from preview_spend, locking fee line and submit path together.

@QuantumExplorer
QuantumExplorer force-pushed the feat/swift-example-shielded-token-unshield branch from 7008a42 to f1a2284 Compare November 23, 2026 14:36

@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

Changes requested: 4 blockers

  • On protocol 14, an executed unshield can appear failed and be paid again — packages/rs-platform-wallet/src/wallet/shielded/operations.rs:339 (new)
    Impact: A sender can see “no tokens left this wallet” even though the recipient was credited, then send the same payment again from other notes.
  • The unshield form silently sends less than entered when the amount has excess precision — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift:772-775 (new)
    Impact: A sender who enters 1.239 for a two-decimal token can submit that displayed amount while the recipient receives 1.23.
  • Unshields above the per-transition limit get a fee quote but cannot execute — packages/rs-platform-wallet/src/wallet/shielded/operations.rs:2502-2505 (new)
    Impact: A holder with enough spendable notes can get a fee quote for more than 281,474,976,710,655 smallest units and wait for two proofs before Platform rejects the unshield.
  • Restoring an unshield with no saved recipient invents a credited identity — packages/rs-platform-wallet-ffi/src/persistence.rs:4262-4264 (new)
    Impact: A wallet restoring a tag-12 activity whose host did not preserve the recipient can show an all-zero identity as the destination of the payment.

New on this head: This head adds a regression test for SDK/network version mismatch in the fee preview and removes a redundant scope in token-note selection. The PR adds type 27 token unshielding through the shared wallet spend path and shows Rust-calculated fees in both Swift spend forms. The Kotlin SDK emulator build and tests passed, and no code checks have failed on this head.

🔴 4 blocking | 🟡 4 suggestion(s) | 💬 2 nitpick(s)

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

💬 Nitpick: ShieldedActivityFFI identity_id docs still claim only IdentityCreate carries an identity while four kinds now do
Impact: A persistence host following the field comments can discard the credited identity when saving a token unshield.
packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:162-166

The field comments contradict both the tag table and the encoder. The table says tag 12 carries the credited identity, and the encoder sets has_identity_id = 1 for tags 6, 8, 9, and 12, but these two comments say only tag 6 has a meaningful ID. Document the presence flag as authoritative and describe what the ID means for each tag.

    /// Identity created (tag 6), debited (tag 8), or credited (tags 9 and 12).
    /// Meaningful only when `has_identity_id == 1`.
    pub identity_id: [u8; 32],
    /// `1` when `identity_id` is present, else `0`.
    pub has_identity_id: u8,

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: general, architecture-layering, rust-quality, security-auditor)

💬 Nitpick: The C activity contract labels token unshield amounts as credits
Impact: A C host following the field documentation can display a token unshield principal as a DASH amount.
packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:138-140

A tag-12 activity passes the token’s smallest-unit amount unchanged through ShieldedActivityFFI.amount, just as tag 11 does. The comment calls both amounts credits. Document the two token exceptions on amount; fee remains denominated in credits.

    /// Principal in the token's smallest unit for tags 11 and 12; otherwise
    /// credits. Excludes self-change and zero-value fillers.
    pub amount: u64,

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

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The shared token_pool_spend path in operations.rs changes how wallet funds move by adding identity unshielding and reworking token and fee note selection, reservation, and settlement across both spend types.
  • 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 — platform-versioning (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 (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/src/wallet/shielded/operations.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:339: On protocol 14, an executed unshield can appear failed and be paid again
  Impact: A sender can see “no tokens left this wallet” even though the recipient was credited, then send the same payment again from other notes.
  Expiry of the wallet’s original fee bundle does not establish that its token payment failed. Protocol 14 is allowed by the wallet, but its token bundle does not bind the fee bundle, so the same signed token payment can land with a different valid fee bundle. The activity here tracks only the original fee actions, and `save_spend_then_broadcast` records the original credit anchor and credit-note nullifiers. Those notes remain unspent in this case, so when their anchor is pruned, `release_stranded_spends` marks the activity `Failed`; the Swift detail then says no tokens left. Require fee-bundle binding for wallet unshields, or keep the payment outcome unknown on protocol 14 unless recovery has evidence about the token spend itself. Test that expiry of the original fee bundle cannot turn an executed payment into a retryable failure.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:2502-2505: Unshields above the per-transition limit get a fee quote but cannot execute
  Impact: A holder with enough spendable notes can get a fee quote for more than 281,474,976,710,655 smallest units and wait for two proofs before Platform rejects the unshield.
  A holder can enter a covered balance that type 27 cannot move in one transition. For example, two notes of 2^47 units cover a request for 2^48, but `TokenUnshieldWithShieldedFeeTransitionV0::validate_structure` rejects amounts above `MAX_DISTRIBUTION_PARAM`. Both preview and submission check only positivity. The builder can represent this amount, proves both bundles, and calls `try_from_bundles`, which constructs the transition without that structure check. Expose the existing amount predicate from DPP, as type 28 does for its count, and use it for type 27 in preview and submission before reserving or proving. Cover the limit and limit plus one without imposing this transparent-amount cap on type 26.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift:772-775: The unshield form silently sends less than entered when the amount has excess precision
  Impact: A sender who enters `1.239` for a two-decimal token can submit that displayed amount while the recipient receives `1.23`.
  The user can authorize a different principal from the one shown in the amount field. `parseTokenAmount` rounds down, `canSubmit` accepts any non-nil result, and both the preview and `submit()` use that rounded integer without changing the text or warning the user. The same problem occurs when someone pastes a fractional amount into the smallest-unit form. Use the existing `hasDigitsBeyondPrecision` check to show a precision error and withhold the parsed amount from both preview and submission until it is exactly representable; trailing zeros such as `1.230` can still pass.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift:613-616: An open spend form keeps its old fee or refusal after a shielded sync changes the notes
  Impact: A sender who leaves the form open while sync finds fee credits can still see an insufficient-balance refusal until they edit the amount or reopen the form.
  The amount can stay the same while the wallet’s ability to pay changes. The fee task is keyed only by `amount`, so the wallet-scoped sync completions and local-state clears that refresh the parent balance list do not refresh the quote. Include a local-state revision driven by those events in the task identity, preserving the debounce and cancellation checks and leaving pricing in Rust.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift:759-761: Pasting an oversized recipient can make the unshield form unresponsive
  Impact: A user who pastes a long string made of Base58 characters can stall the form before submitting anything.
  The decoded-length check comes too late to bound the work. The form decodes `recipientId` while rendering, and `Data.identifier(fromBase58:)` repeatedly walks a byte array that grows with the input. Reject trimmed input longer than 44 UTF-8 bytes before decoding, then keep the 32-byte decoded-length check.

In `packages/rs-platform-wallet-ffi/src/persistence.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/persistence.rs:4262-4264: Restoring an unshield with no saved recipient invents a credited identity
  Impact: A wallet restoring a tag-12 activity whose host did not preserve the recipient can show an all-zero identity as the destination of the payment.
  An absent recipient becomes a definite recipient on restore. `loadShieldedActivity()` sends a zero-filled buffer with `has_identity_id = 0` for an empty or malformed SwiftData identity blob; a C host can also omit the ID by following the current field documentation. The new tag-12 arm ignores the presence flag, and the encoder marks the placeholder as present if the entry is emitted again. Check the presence flag before constructing an identity-bearing kind and report an inconsistent record without turning it into a real-looking recipient. Cover both an absent recipient and a valid 32-byte recipient on restore.

In `packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:831-835: Editing a spend amount reloads spent token notes on every fee preview
  Impact: A wallet with a long token history but few spendable notes copies historical blobs while holding the store read lock on each debounced amount edit.
  The preview does work proportional to the account’s note history just to return counts and a fee. `notes()` materializes all matching rows, including note bytes, commitments, and nullifiers, before selection discards spent and reserved rows. Filter out those rows in the selection query. Keep the shared largest-first selector and position tie-breaker, and load full note data only where reservation needs it.

In `packages/rs-platform-wallet/src/wallet/shielded/note_selection.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/note_selection.rs:194-196: The note cap will still measure a V0 unshield after DPP changes the wire version
  Impact: After a wire-version change, a spend near the size limit can be refused even though it fits or reserve notes for a transition that is too large.
  The sizing sample explicitly constructs `TokenUnshieldWithShieldedFeeTransition::V0`, while the real builder calls DPP’s `try_from_bundles`, which selects the wire generation from `platform_version`. They agree today, but the cap’s version argument only affects the limits it checks, not the transition it measures. Have DPP select the generation for the size sample as it does for construction, for both spend kinds.

In `packages/rs-platform-wallet-ffi/src/shielded_persistence.rs`:
- [NITPICK] packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:162-166: ShieldedActivityFFI identity_id docs still claim only IdentityCreate carries an identity while four kinds now do
  Impact: A persistence host following the field comments can discard the credited identity when saving a token unshield.
  The field comments contradict both the tag table and the encoder. The table says tag 12 carries the credited identity, and the encoder sets `has_identity_id = 1` for tags 6, 8, 9, and 12, but these two comments say only tag 6 has a meaningful ID. Document the presence flag as authoritative and describe what the ID means for each tag.
- [NITPICK] packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:138-140: The C activity contract labels token unshield amounts as credits
  Impact: A C host following the field documentation can display a token unshield principal as a DASH amount.
  A tag-12 activity passes the token’s smallest-unit amount unchanged through `ShieldedActivityFFI.amount`, just as tag 11 does. The comment calls both amounts credits. Document the two token exceptions on `amount`; `fee` remains denominated in credits.

QuantumExplorer and others added 3 commits November 24, 2026 01:10
…s signed at

A spend signed at protocol 14 does not bind its token bundle to its fee
bundle, so its token bundle can land with another fee bundle, before or
after its own fee side goes. The hold now records whether its spend was
signed bound, and the sweep reads whether any note it holds was spent:

- signed bound: released once its record is gone; failed when its fee
  anchor was pruned or none of its notes were spent;
- signed unbound with a note spent: released, outcome left unknown, as
  it may have been delivered with another fee bundle;
- signed unbound with no note spent: failed and released only once the
  pool's own scan is at a binding version; held until then, including
  when another device spent its fee note.

A partial index finds a spend's holds without reading the account's
token note history.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t-example-shielded-token-unshield

# Conflicts:
#	packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs
#	packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs
…inding a Clear dropped

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

@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 2 only (queue backlog)

Changes requested: 1 blocker

  • An interrupted sync can show a completed protocol-15 unshield as failed — packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:349-350 (new; not shown inline, see below)
    Impact: A sender who reopens the app while a node is one block behind can be told that no tokens left the wallet even though the recipient was credited, and pay the same identity again.

New on this head: This head records whether each token spend was signed with fee-bundle binding and adds a regression test for both public spend methods after the wallet binding is cleared. The Kotlin SDK emulator build and tests and the review check are still pending; no completed code check is failing.

🔴 1 blocking | 🟡 1 suggestion(s)

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

🔴 Blocking: An interrupted sync can show a completed protocol-15 unshield as failed
Impact: A sender who reopens the app while a node is one block behind can be told that no tokens left the wallet even though the recipient was credited, and pay the same identity again.
packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:349-350

A successful unshield can be recorded as Failed and its already-spent token notes returned to the local spendable balance. The public unshield leaves the activity pending and requests a follow-up sync. If the payment lands at height H, the credit scan can see its fee nullifier and FileShieldedStore::mark_spent deletes the SQLite recovery record immediately (file_store.rs:1078–1100). The coordinator raises the durable sweep floor only after awaiting the token scans (coordinator.rs:1957–1968), and queues the credit changeset later still. If the app is terminated before the token scan records the spend, reopening restores the pending row and the token hold, but not the recovery record or the new floor. The SDK permits one-block lag for both note queries, so completed credit and token scans at H−1 can satisfy the old floor without seeing the token spend. The restored owner is eligible, no live record or in-flight marker excludes it, and the new !orphan.any_spent branch writes Failed and releases the hold. The previous fee-note-spent branch did not infer failure from an absent token spend. Persist the proof height before or atomically with retiring the recovery record, and leave the row pending and the hold intact until token evidence reaches that height. Add a reopen test that interrupts after record deletion, returns H−1 proofs first, then catches up to H.

Confirmed by an independent pass: A user submits a protocol-15 token unshield that lands at height H, and the app is terminated during the follow-up sync after the credit scan deletes the saved spend record but before the token scan records the spend or the coordinator saves the new sweep floor. On reopen, both scans can accept valid H−1 proofs, leaving the restored pending activity and token hold eligible for settlement without evidence from H. The wallet then records the successful unshield as Failed and makes its already-spent token notes available for balance reporting and spend selection until a later scan catches up.

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

🟡 Suggestion: The recovery test passes even if the spend saves the wrong fee-binding flag
Impact: A regression that records a protocol-14 unshield as fee-bound could make a delivered payment appear failed after an upgrade without failing the settlement test.
packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:4213-4218

The matrix checks how recovery reads signed_bound, but writes the expected bit directly into SQLite. It bypasses both the signing-version lookup in token_pool_spend and the TokenNoteReservation::rekey write. Exercise that production lookup and write through a shared helper: reserve an unspent note, rekey it at protocol 14 or 15, then mark the token input spent and run the pruned-anchor sweep at 15. The same scan should leave the protocol-14 row pending and fail the protocol-15 row. This can cover the persistence boundary without generating an Orchard proof.

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

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: 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) — The shared token_pool_spend path in operations.rs and the note-selection changes alter funds movement by coordinating token and fee note selection, reservation, proof construction, and pending settlement for both transfers and unshields.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • New since the last final review (82bb64c7): 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.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 — platform-versioning (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 (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/src/wallet/shielded/coordinator.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:349-350: An interrupted sync can show a completed protocol-15 unshield as failed
  Impact: A sender who reopens the app while a node is one block behind can be told that no tokens left the wallet even though the recipient was credited, and pay the same identity again.
  A successful unshield can be recorded as `Failed` and its already-spent token notes returned to the local spendable balance. The public unshield leaves the activity pending and requests a follow-up sync. If the payment lands at height H, the credit scan can see its fee nullifier and `FileShieldedStore::mark_spent` deletes the SQLite recovery record immediately (`file_store.rs:1078–1100`). The coordinator raises the durable sweep floor only after awaiting the token scans (`coordinator.rs:1957–1968`), and queues the credit changeset later still. If the app is terminated before the token scan records the spend, reopening restores the pending row and the token hold, but not the recovery record or the new floor. The SDK permits one-block lag for both note queries, so completed credit and token scans at H−1 can satisfy the old floor without seeing the token spend. The restored owner is eligible, no live record or in-flight marker excludes it, and the new `!orphan.any_spent` branch writes `Failed` and releases the hold. The previous fee-note-spent branch did not infer failure from an absent token spend. Persist the proof height before or atomically with retiring the recovery record, and leave the row pending and the hold intact until token evidence reaches that height. Add a reopen test that interrupts after record deletion, returns H−1 proofs first, then catches up to H.

  _Confirmed by an independent pass: A user submits a protocol-15 token unshield that lands at height H, and the app is terminated during the follow-up sync after the credit scan deletes the saved spend record but before the token scan records the spend or the coordinator saves the new sweep floor. On reopen, both scans can accept valid H−1 proofs, leaving the restored pending activity and token hold eligible for settlement without evidence from H. The wallet then records the successful unshield as Failed and makes its already-spent token notes available for balance reporting and spend selection until a later scan catches up._
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:4213-4218: The recovery test passes even if the spend saves the wrong fee-binding flag
  Impact: A regression that records a protocol-14 unshield as fee-bound could make a delivered payment appear failed after an upgrade without failing the settlement test.
  The matrix checks how recovery reads `signed_bound`, but writes the expected bit directly into SQLite. It bypasses both the signing-version lookup in `token_pool_spend` and the `TokenNoteReservation::rekey` write. Exercise that production lookup and write through a shared helper: reserve an unspent note, rekey it at protocol 14 or 15, then mark the token input spent and run the pruned-anchor sweep at 15. The same scan should leave the protocol-14 row pending and fail the protocol-15 row. This can cover the persistence boundary without generating an Orchard proof.

QuantumExplorer and others added 5 commits November 24, 2026 01:30
…er spend used

A spend's bundle spends all its token notes at once, so a hold with some
notes spent and some not belongs to a spend that did not land and can no
longer, at any protocol version: its row is marked failed before its notes
are released, instead of being left pending with no hold to revisit.

Also test that the re-key to a record keeps the signing era the sweep reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d cases into one branch

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t-example-shielded-token-unshield

# Conflicts:
#	packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs
…fore dropping its record

The credit scan marks a fee note spent, which drops the saved record of the
spend it paid for, before the sweep raised its floor. An interruption in
between lost that height, so a later pass answered one block below could
settle the spend from token evidence that did not reach it. The scan now
keeps the highest height of its batches durably before it applies any
spend (`ShieldedStore::note_spend_scan_height`).

The signing era kept on a hold now comes from one helper,
`token_bundle_binds_fee_bundle`, tested at protocol 14 and 15.

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

Copy link
Copy Markdown
Member Author

On thepastaclaw's review of 9e0fd16 (both findings were outside the diff):

  • 🔴 An interrupted sync can show a completed protocol-15 unshield as failed: fixed in feat(swift-example-app)!: send tokens within a token shielded pool (type 26) #6132's 6094cea, merged here in 49b953e. Before it marks any note spent, the credit note scan now durably keeps the highest height its batches were proven at (ShieldedStore::note_spend_scan_height, which raises the token sweep's stored floor). Marking the fee note spent, which drops the saved record, can no longer leave that height unrecorded across an interruption: a pass answered one block below cannot settle the spend from token evidence short of that height. The new should_keep_the_height_a_fee_note_was_seen_spent_at_before_dropping_its_record test runs the same sequence:

    1. it keeps the height (11), then marks the fee note spent, which drops the record;
    2. a sweep whose token scan is at 10 leaves the row Pending with the hold kept;
    3. reopening the store on the same file reads 11;
    4. once the token scan reaches 11 and shows the note spent, the hold is released and the row is left for its confirmation.

    The test calls the store hook directly rather than running a full note sync.

  • 🟡 The recovery test passes even if the spend saves the wrong fee-binding flag: the production lookup is now one helper, token_bundle_binds_fee_bundle, which token_pool_spend passes to the re-key. should_record_a_token_spend_as_bound_only_from_protocol_version_15 checks it at 14, 15 and latest. feat(swift-example-app)!: send tokens within a token shielded pool (type 26) #6132's should_keep_the_signing_era_a_rekey_records checks that the real rekey writes both values and that the sweep reads them back.

@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 2 only (queue backlog)

Changes requested: 1 blocker

  • A one-block lag between token scan pages can mark a completed unshield as failed — packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:314 (new)
    Impact: A sender whose protocol-14 unshield landed with another fee bundle can be told that no tokens left the wallet and pay the already-credited identity again.

New on this head: This round updates shielded token spend recovery to persist the credit proof height before retiring fee records, adds coverage for the signing-era flag, and brings partial-spend settlement into the unshield path. The Kotlin SDK emulator build and tests passed, as did the other completed checks; the review check is still pending.

🔴 1 blocking

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: 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) — The refactor of token_pool_spend in operations.rs intricately changes funds movement by sharing token and fee note selection, reservation, and settlement between shielded transfers and identity unshields.
  • Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
  • New since the last final review (9e0fd162): 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.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 — platform-versioning (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 (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/src/wallet/shielded/coordinator.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:314: A one-block lag between token scan pages can mark a completed unshield as failed
  Impact: A sender whose protocol-14 unshield landed with another fee bundle can be told that no tokens left the wallet and pay the already-credited identity again.
  The sweep can persist `Failed` for an unshield that already credited the recipient. This PR routes `TokenUnshield` through the shared sweep, which now treats a mix of spent and unspent flags as proof that a competing spend used some of the inputs. A two-input spend submitted through `shielded_token_unshield` at protocol 14 stays pending when its original fee anchor is pruned; the signed token bundle can still land with another valid fee bundle while its token anchor remains valid. If it lands at H+1 with its two actions on opposite sides of a page boundary, `apply_chunk` can commit the first nullifier from a full page proved at H+1. The next peer can return a valid empty page at H, where that offset is still past the tree end; the SDK's default freshness check permits a one-block lag. The wallet keeps the first spent flag but overwrites `scanned_height` with H and counts the short page as completion. With the credit floor at H, the sweep takes the `partly_spent` branch and fails the row even though both inputs were consumed at H+1. Persist the highest token proof height whose spend observations were applied and require end-of-pool coverage at or above it before treating mixed flags as failure. Add a two-page regression, including a restart between pages, that keeps the row pending until the newer tail is read.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: A user submits a two-note unshield through `PlatformWallet::shielded_token_unshield` on protocol 14; if the unconfirmed spend's fee anchor expires, the credit scan at height H can drop its saved record while a relay that received the signed transition can still submit the token bundle with a replacement fee bundle and a still-valid token anchor. If that unshield lands at H+1 across a token scan page boundary, the first page can record one input as spent while a peer one block behind returns a valid empty tail at H, which the SDK accepts. The sweep treats the mixed flags as a competing spend, persists `Failed`, and releases the hold even though the recipient was credited._

QuantumExplorer and others added 4 commits November 24, 2026 02:00
…the largest tree seen

A page answered by a node a block behind proves a shorter tree. After a
full page proved the pool larger, such a page ended the scan as if it were
the pool's end, lowered the recorded height and count, and let the sweep
judge holds from a scan that missed a spend. The recorded count, height and
version now only rise, and a pass counts the pool complete only when it
reaches the highest count a page has proved.

The credit note sync keeps its highest batch height before it saves or
records anything else, so a failed write leaves nothing half recorded for a
retry to skip; a synthetic stream test checks the highest, not the last,
batch height is kept across a reopen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as the highest proven

The recorded count and height only rise, so the Rust, C and Swift fields
say so, and that neither certifies a scan reached the pool's end. A
failure-path test checks a failed spend-scan height write leaves the fee
note unspent and the saved spend's record in place.

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

@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

New on this head: This head merges the shared wallet scan fix: token pools retain their highest proof-backed count, height, and protocol version, and a scan cannot settle reservations until it covers that count. The credit scan also persists its highest batch height before saving receipts or applying spends. The Kotlin SDK build and emulator tests passed, runner selection passed, and the automated review check is still pending; this verification was static.

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

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The shared token_pool_spend path in operations.rs adds shielded-to-identity funds movement and coordinates token and fee note selection, reservation, anchor rechecks, and settlement across two pools.
  • 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 below 15% reserve: models 0% 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.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 — platform-versioning (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.

@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

New on this head: Since the last full review, this head clarifies that the token-pool count and height are the highest proven values, not proof of complete account coverage, and adds a regression test for a failed spend-scan height write. The delta does not change production behavior. This was a static review: the Kotlin SDK build and tests are pending, and no code checks have failed.

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

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — In rs-platform-wallet's operations.rs, token_pool_spend refactors the existing shielded transfer path and adds unshielding, changing how token and fee notes are selected, reserved, and settled across two pools.
  • 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 below 15% reserve: models 0% 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.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 — platform-versioning (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.

…e-shielded-token-spend

# Conflicts:
#	docs/sdk/sdk-parity-manifest.json
#	packages/kotlin-sdk/PARITY_SUMMARY.md
…t-example-shielded-token-unshield

# Conflicts:
#	docs/sdk/sdk-parity-manifest.json
#	packages/kotlin-sdk/PARITY_SUMMARY.md
#	packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
…e-shielded-token-spend

# Conflicts:
#	docs/sdk/sdk-parity-manifest.json
#	packages/kotlin-sdk/PARITY_SUMMARY.md
…t-example-shielded-token-unshield

# Conflicts:
#	docs/sdk/sdk-parity-manifest.json
#	packages/kotlin-sdk/PARITY_SUMMARY.md
Base automatically changed from feat/swift-example-shielded-token-spend to v5.1-dev November 23, 2026 21:14
@github-actions

github-actions Bot commented Nov 23, 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 the waiting-bots Waiting for the review bots to report on this head label Nov 23, 2026
…e-shielded-token-unshield

# Conflicts:
#	docs/sdk/sdk-parity-manifest.json
#	packages/kotlin-sdk/PARITY_SUMMARY.md
#	packages/rs-platform-wallet-ffi/src/persistence.rs
#	packages/rs-platform-wallet-ffi/src/shielded_persistence.rs
#	packages/rs-platform-wallet-ffi/src/shielded_send.rs
#	packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs
#	packages/rs-platform-wallet/src/wallet/platform_wallet.rs
#	packages/rs-platform-wallet/src/wallet/shielded/activity.rs
#	packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs
#	packages/rs-platform-wallet/src/wallet/shielded/file_store.rs
#	packages/rs-platform-wallet/src/wallet/shielded/mod.rs
#	packages/rs-platform-wallet/src/wallet/shielded/note_selection.rs
#	packages/rs-platform-wallet/src/wallet/shielded/operations.rs
#	packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs
#	packages/rs-sdk/src/platform/transition/broadcast.rs
#	packages/rs-sdk/src/sdk/protocol_gate_tests.rs
#	packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentShieldedActivity.swift
#	packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift
#	packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift
#	packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.swift
#	packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift
#	packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
…e-shielded-token-unshield

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
@github-actions

github-actions Bot commented Nov 23, 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.

@QuantumExplorer
QuantumExplorer merged commit 54002f8 into v5.1-dev Nov 23, 2026
18 of 20 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/swift-example-shielded-token-unshield branch November 23, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants