Skip to content

fix(platform-wallet): report a token pool tree that does not build as a store error - #6309

Merged
romchornyi merged 11 commits into
v5.2-devfrom
fix/token-pool-tree-build-error
Nov 27, 2026
Merged

romchornyi merged 11 commits into
v5.2-devfrom
fix/token-pool-tree-build-error

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Follow-up to #6276, from @HashEngineering's review there. spend_paths in token_pool.rs mapped every CommitmentTreeError from rebuilding a token pool's tree (append, checkpoint, anchor, witness) to ShieldedMerkleWitnessUnavailable. #6276 gave that variant code 88 ("wallet is still syncing, try again shortly"), so a token transfer or unshield whose pool tree does not build told the host to retry after sync. No sync repairs such a tree, so every retry failed the same way. Nothing was broadcast, so no funds were at risk.

What was done?

  • A token pool tree that does not build from its kept leaves is now ShieldedStoreError (generic code 6), like the note pool's store faults (tree_build_error).
  • A note past the leaves the pool's scan kept ("sync the shielded pools first") stays ShieldedMerkleWitnessUnavailable (88): a sync does fix that one.
  • ERROR_CODE_REGISTRY.md:
    • Row 88 lists the token pool spends (token transfer, unshield) and the token purchase from the pool among the operations that return it.
    • Row 88 also lists the tree-build failure among the store faults.
    • The numbering notes now say 80 and 83–88 are merged on v5.2-dev.
  • The Rust variant doc says the same.

How Has This Been Tested?

  • New should_report_a_token_pool_tree_that_does_not_build_as_a_store_error.
  • The existing past-the-leaves test still pins 88.
  • cargo test -p platform-wallet --features shielded (2840) and -p platform-wallet-ffi (640) pass, as do clippy, fmt and the parity manifest check.

Breaking Changes

A token transfer or unshield whose token pool tree does not build returns code 6 (ErrorWalletOperation) instead of 88. Hosts should not have been retrying it.

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 · 3918bca

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • kotlin-sdk (packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt, packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/errors/DashSdkErrorTest.kt) — approved by HashEngineering
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md, packages/rs-platform-wallet-ffi/src/error.rs, packages/rs-platform-wallet-ffi/src/shielded_send.rs) — approved by HashEngineering
    • rs-platform-wallet (packages/rs-platform-wallet/src/error.rs, packages/rs-platform-wallet/src/wallet/shielded/operations.rs, packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs and 1 more) — approved by HashEngineering
    • swift-sdk — you own it

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
    • Token-pool tree construction failures are reported as wallet storage errors rather than unavailable witnesses.
    • Unavailable-witness errors now show the wallet diagnostic without suggesting that every case will be resolved by retrying after a sync.
  • Documentation
    • Clarified that credit-pool notes may become available after a shielded sync, while token-pool gaps require a scan to reach the missing position. Clearing shielded data restarts scanning from the beginning.
    • Clarified that other witness-path failures remain generic wallet errors.

… a store error

A token pool's commitment tree that does not build from the leaves its scan
kept (append, checkpoint, anchor or witness failing) came back as
ShieldedMerkleWitnessUnavailable, which #6276 made code 88: "still syncing,
try again shortly". No sync repairs such a tree, so every retry failed the
same way. It is now ShieldedStoreError (the generic code), like the note
pool's store faults. A note past the leaves kept stays code 88.

Registry: row 88 names the token pool case (token transfer, unshield) and
the token purchase from the pool among the spends that raise it, and the
numbering notes say 80 and 83-88 are merged on v5.2-dev.

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

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The token-pool spend path now reports commitment-tree build failures as ShieldedStoreError and missing witnesses as ShieldedMerkleWitnessUnavailable. Error messages and SDK documentation distinguish recovery conditions for credit-pool and token-pool notes.

Changes: Shielded witness errors

Layer / File(s) Summary
Token-pool witness handling
packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs, packages/rs-platform-wallet/src/wallet/shielded/token_pool_tests.rs, packages/rs-platform-wallet/src/wallet/shielded/operations.rs
spend_paths maps tree-build failures to ShieldedStoreError. Missing-witness messages describe scan guidance, and tests check the error details and classifications. The depth-0 missing-witness message adds next-sync guidance.
FFI error mapping and registry
packages/rs-platform-wallet-ffi/src/error.rs, packages/rs-platform-wallet-ffi/src/shielded_send.rs, packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md
FFI conversion and shielded-send mapping use the wallet diagnostic without the code-19 retry prefix. Tests check the message. The registry updates allocation statuses and the code 88 description.
SDK error documentation and tests
packages/rs-platform-wallet/src/error.rs, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt, packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/errors/DashSdkErrorTest.kt, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift, packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ErrorHandlingTests.swift
Documentation distinguishes credit-pool checkpoint recovery from token-pool scan recovery. Kotlin and Swift tests update expected witness-error details.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

  • dashpay/platform issue 6256: The PR changes the witness error mapping and distinguishes tree-build failures from unavailable witnesses, but the described root-cause fix is not included.
  • dashpay/platform issue 5926: The PR changes error classification for tree-build failures and documents retry conditions, which relates to host retry decisions.
  • dashpay/platform issue 6360: The PR updates registry statuses and the code 88 description.

Suggested reviewers: quantumexplorer

Merge Risk: Minimal · up to 3918b

This change reclassifies token-pool tree-build failures as store errors so hosts stop retrying them. It also clarifies the recovery guidance for code 88 across the Rust, FFI, Kotlin and Swift docs. The risk is low: the changes are limited to error mapping, messages and documentation, with tests covering the new mapping.

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 names the main change: a token-pool tree that cannot be built from the kept leaves is now reported as a ShieldedStoreError instead of ShieldedMerkleWitnessUnavailable. The raw summary confir…
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 names the main change: a token-pool tree that cannot be built from the kept leaves is now reported as a ShieldedStoreError instead of ShieldedMerkleWitnessUnavailable. The raw summary confirms that token_pool.rs now routes tree_build_error to ShieldedStoreError, and token_pool_tests.rs adds a test asserting 'does not build' maps to ShieldedStoreError. The title also has the conventional fix(scope) form. The rest of the changeset (error docs, FFI message change, registry updates, Swift and Kotlin doc updates) supports the change but is not named in the title, which is acceptable.

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 c857680 and 3918bca.

Files selected for processing: 11

  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/errors/DashSdkErrorTest.kt
  • packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md
  • packages/rs-platform-wallet-ffi/src/error.rs
  • packages/rs-platform-wallet-ffi/src/shielded_send.rs
  • packages/rs-platform-wallet/src/error.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/token_pool_tests.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ErrorHandlingTests.swift
Files skipped from review as they are similar to previous changes: 5

  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt
  • packages/rs-platform-wallet-ffi/src/shielded_send.rs
  • packages/rs-platform-wallet/src/error.rs
  • packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift

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

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 25, 2026
@thepastaclaw

thepastaclaw commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 3918bca) · triage: low

@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

Token transfers and unshields now return store error code 6 when the wallet cannot rebuild the token-pool tree, while a selected note beyond the retained leaves still returns code 88 before anything is broadcast. Linux wallet tests and Kotlin SDK checks passed; the Swift SDK check failed because the simulator could not launch the example app’s test runner, with no evidence tying that failure to the patch. PR Hygiene and the automated review check remain pending.

🟡 3 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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

  • Triage: low by gpt-6.2-sol (effort low) — The change only reclassifies tree-build failures in spend_paths, leaving tree construction, spend behavior, and the retryable case for notes beyond the stored leaves unchanged.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (zai below 15% reserve: 5h 72% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); 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/token_pool_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool_tests.rs:941-952: The regression test passes even if an invalid retained leaf still returns code 88
  Impact: If `spend_paths` starts returning code 88 for an invalid retained leaf again, hosts will tell users to sync and retry a token transfer or unshield that still cannot complete, without this test catching the regression.
  The test would stay green if `spend_paths` stopped using the new mapper and returned `ShieldedMerkleWitnessUnavailable` again. It calls `tree_build_error` directly with constructed errors, while the FFI tests start with errors that are already classified. Insert a noncanonical 32-byte commitment such as `[0xff; 32]` at position zero in the in-memory SQLite fixture and assert that `spend_paths` returns `ShieldedStoreError`. The value passes the wallet’s length check but makes GroveDB’s `append` return `InvalidFieldElement`, exercising the production mapping without a prover or network call. Keep the existing past-the-leaves test for the retryable case.

In `packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md:216: The code 88 guidance promises the next sync will fill gaps in the token-pool leaves
  Impact: Hosts following the registry can tell users to retry after the next sync even when a gap in the retained token-pool leaves falls before the range that sync reads.
  A token spend can return code 88 again after a successful incremental sync. `spend_paths` stops at the first missing leaf, while `scan_pool` resumes from the lowest participating account’s watermark rounded down to a chunk boundary. A gap before that starting point is not reread. The registry now applies the credit-pool checkpoint explanation to both cases. In the registry and the Rust variant docs, distinguish a credit-pool note that needs a checkpoint from a token-pool note that needs a scan to fill the missing range. Both refusals happen before broadcast, so retrying is safe, but the next sync is not guaranteed to clear both.
- [SUGGESTION] packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md:216: The registry still lists code 88 as proposed and free after it merged on v5.2-dev
  Impact: Maintainers resolving an error-code collision on `v5.2-dev` get conflicting guidance about whether code 88 is already assigned or can still move.
  The detailed entry can lead maintainers to treat an assigned code as movable. The updated numbering notes correctly record that #6276 merged code 88 on `v5.2-dev`, but the row still says “Proposed” and “free on both release lines” under a heading that says proposal numbers may move. Record the entry as merged on `v5.2-dev` outside the open-proposals table, and remove the availability claim or label it as historical. A merge on that branch does not imply a stable SDK release.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
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 25, 2026
…aths and correct the code 88 notes

The regression test called the error mapper directly, so it stayed green if
spend_paths stopped using it. It now keeps a leaf that is not a field
element and asserts spend_paths returns ShieldedStoreError.

Code 88 docs (registry row and the Rust variant): the next sync clears the
credit pool case, but a token pool note past the kept leaves is cleared only
when the scan reads the missing positions. The scan resumes from the lowest
account watermark, so a gap below it stays until the pool is scanned from
the start.

Registry: rows 80 and 83-88 say where they are merged instead of
"Proposed", row 88 no longer says its number is free, and the proposals
heading says a merged row's code no longer moves.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

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

New on this head: This revision clarifies the code 88 registry and retry guidance, and updates the regression test to exercise the store-error mapping through spend_paths. Rust workspace tests, Kotlin SDK build and tests, and the Swift frozen-schema check passed; the Swift SDK build and tests are pending.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff narrowly changes how spend_paths classifies tree-rebuild failures, leaving tree construction, spend logic, and the retryable missing-leaf case unchanged.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); 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 (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); 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/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:1401-1403: Code 88 guidance calls for a full rescan when an ordinary sync can refill the gap
  Impact: An app developer troubleshooting code 88 after a token transfer or unshield may advise users to clear and rescan their shielded state even when an incremental sync can restore the missing leaves.
  A full rescan is unnecessary if the missing leaf is in the first chunk the next sync rereads. `scan_pool` rounds the lowest account watermark down to a chunk boundary (`token_pool.rs:1522–1528`), and `apply_chunk` inserts missing leaves before the per-account watermark check that skips note decryption (`token_pool.rs:1387–1408`). In this Rustdoc and in registry row 88, use the rounded-down scan start as the cutoff: a gap before that point needs a scan that starts at or before the gap and reads it. A shielded Clear is one way to restart from zero, not a requirement.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
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 26, 2026
… as the code 88 cutoff

A sync rereads from the lowest account watermark rounded down to a chunk boundary, so it does refill a gap in the kept leaves at or after that point. Only a gap before it needs a scan that starts at or before the gap; a shielded Clear is one way to get one, not a requirement.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

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

New on this head: This docs-only revision clarifies that token-pool sync resumes at the lowest participating account watermark rounded down to a chunk boundary. Both references now explain that recovery requires a scan that reads the gap, and that clearing shielded state is one way to restart from position zero. Rust workspace tests and the Swift and Kotlin SDK checks passed; review and PR Hygiene checks remain pending.

🔴 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-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff narrowly reclassifies tree-build failures in spend_paths while preserving the retryable path for notes beyond the scanned leaves, without changing tree construction or spend logic.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); 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 (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); 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.

QuantumExplorer and others added 2 commits November 26, 2026 20:54
…ee-build-error

# Conflicts:
#	packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md
… are merged

Row 88 still said #5865's plan-spend mapper must map the code when it lands. It landed, and its plan spends go through map_spend_result, which keeps 88.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

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.

@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: The latest commit documents that executing a shielded spend against a plan still returns code 88 when a Merkle witness is unavailable, before proof construction or broadcast. Linux Rust wallet tests and the Kotlin SDK build and tests passed; the Swift SDK build and tests are pending.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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

  • Triage: low by gpt-6.2-sol (effort low) — The diff narrowly changes how token-pool tree build failures are reported, with tests distinguishing those failures from retryable sync errors and no change to tree construction or spend execution.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); 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 (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); 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/ERROR_CODE_REGISTRY.md`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md:224: The registry treats spend-plan codes 77–79 and 81 as movable after they merged
  Impact: When resolving a collision on `v5.2-dev`, maintainers get guidance that can lead them to renumber an assigned spend-plan code instead of the open PR's code.
  Renumbering the merged assignment would change the integer that existing bindings expect. This commit updates row 88 to say that #5865 merged, but the same row still describes codes 77–79 and 81 as held by open branches. Their individual rows and the numbering notes also still say “Proposed,” even though base commit `6d9e346d383` (#5865) assigns all four values in `PlatformWalletFFIResultCode`. The table says the open PR renumbers when it collides with a row marked “Merged on.” Mark the four assignments as merged on `v5.2-dev` in their rows and the numbering notes, and make row 88’s allocation explanation explicitly historical. Leave the numeric values unchanged.

@github-actions

Copy link
Copy Markdown
Contributor

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

…efore it, not from the start

The code 88 diagnostic said a gap before the token scan's resume point
needs a scan from the start. A pass that starts at or before the gap
reads the missing leaves too (apply_chunk stores every leaf); a shielded
Clear is one way to restart at position 0. The host docs already said so.

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

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

New on this head: This update clarifies that recovering from a token-pool scan gap requires a scan that starts at or before the gap; Clear is one way to restart at position zero. The Kotlin SDK emulator check failed with “User not authenticated” in the unchanged masternode voting-key signing test, outside the shielded spend path; PR Hygiene is pending.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Still open from earlier rounds (1)

  • 🟡 Suggestion: A token spend blocked by an older scan gap tells users both to retry shortly and to start over — packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:1253-1257 (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.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff makes a small, targeted change to error handling in spend_paths, with regression coverage and matching SDK documentation, without changing tree construction or transaction behavior.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); 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 (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); 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/token_pool.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:1253-1257: A token spend blocked by an older scan gap tells users both to retry shortly and to start over
  (carried; thread: https://github.com/dashpay/platform/pull/6309#discussion_r4719367376)

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: address HashEngineering left a review thread unresolved, then post /self-reviewed.
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 27, 2026
…thout code 19's retry prefix

A token pool note past a scan gap returns code 88 after every sync, so
"try again shortly" was wrong advice for it. Code 88 now carries the
wallet's Display alone on every path (map_spend_result, which the
identity create also uses, and the blanket conversion); code 19 keeps
its prefix. The credit pool's 88 text now says to retry after the next
shielded sync, the token pool's already says how to get past a gap.
Registry row 88, the FFI, Rust, Swift and Kotlin docs say so; tests pin
that both wallet texts carry their guidance and no 88 path adds the
prefix.

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

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

New on this head: Code 88 now forwards the wallet’s own diagnostic through both FFI paths: credit-pool notes advise retrying after the next shielded sync, while token-pool gaps require a scan that reaches the missing leaves. Code 19 keeps its existing wording, and token-pool tree-build failures still return code 6. The Kotlin SDK emulator build and tests passed; PastaClaw review and PR Hygiene were pending, and no local builds or tests were run.

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

  • Triage: low by gpt-6.2-sol (effort low) — The change is confined to classifying shielded wallet failures and exposing that classification consistently across SDKs, without changing tree construction or transaction execution.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); 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 (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Other codes shipped in v5.1.0 are still listed as proposals — The stable v5.1.0 tag contains codes 47–61 and 68–76, but their unchanged registry rows still label them as proposed. That can mislead maintainers into treating shipped ABI values as available for renumbering.
    • Follow-up: Use #6360 to move these codes to the shipped table and update its heading.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: address HashEngineering left a review thread unresolved, then post /self-reviewed.
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 27, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review — kotlin-sdk: HashEngineering · rs-platform-wallet-ffi: HashEngineering or ZocoLini or llbartekll · rs-platform-wallet: HashEngineering or ZocoLini or llbartekll · resolve every review thread HashEngineering left open.
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 27, 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-approving at 3918bca. All three follow-ups from my earlier review are addressed: 83–87 moved to the shipped table as released in v5.1.0 (the rest of the shipped-in-5.1.0 cleanup is tracked in #6360), the code 88 docs in the FFI enum and Kotlin KDoc now cover the token pool cases and the scan-gap recovery, and CommitmentTreeError is imported.

The extra change in 3918bca looks right to me: code 88 now carries only the wallet's diagnostic on both mapping paths (map_spend_result, used by identity create too, and the blanket conversion), code 19 keeps its prefix, and both places that construct ShieldedMerkleWitnessUnavailable now say how to get past the refusal (credit pool: retry after the next shielded sync; token pool: a scan that starts at or before the gap, or a Clear). Kotlin changes are doc and test fixture only; isRetryable is unchanged.

Locally at 3918bca: platform-wallet token_pool + select_recorded_spends tests 45/45, platform-wallet-ffi witness tests 3/3 (--all-features), clippy -D warnings clean on both crates.

@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 Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@romchornyi
romchornyi merged commit a8660ff into v5.2-dev Nov 27, 2026
38 checks passed
@romchornyi
romchornyi deleted the fix/token-pool-tree-build-error branch November 27, 2026 18:41
romchornyi added a commit that referenced this pull request Nov 27, 2026
Brings in #6309 (code 88 carries the wallet's own diagnostic without
code 19's prefix; token pool scan gap guidance; codes 83-87 shipped in
v5.1.0). Conflicts were docs and fixtures only: the code 88 docs in
Swift, Kotlin and the registry keep #6309's text plus this PR's
NotSent class and `payment:` field; the host test fixtures take the
real 88 message with this PR's classed constructors; registry row 76
keeps this PR's RefusedBeforeDispatch sentence.

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.

4 participants