Conversation
…unconfirmed send A public contact request whose broadcast may have been delivered is held until a proved read settles it. While it is held or being sent: - Its signed bytes are broadcast again only where a public request to the recipient would still go out by what the wallet tracks: not once a private request holds the pair or their requests came or went privately, not while the sender's read of the private store is rewound, not while private payments may be unrestored, and never from a private send. A public send does it only after its own store read succeeded. - One public send holds a pair at a time: a second to the same recipient is refused with PublicContactRequestUnconfirmed, with nothing signed. - A send that finds its unconfirmed request on Platform records it and returns it as the request sent, instead of building another past it. Also: - The lost-writes flag is read again after the flush, in note_read_back_once_durable and settled_requests_durable. - register_contact_account, register_external_contact_account and the accept path's adopted request act only on the handle's wallet generation. - A private request paid for whose read-back fails on the handle is reported pending. The README, the error's documentation and the FFI code registry describe what code 76 now also covers, when held bytes are broadcast again, and that a request which never lands and whose nonce is never used stays held for the life of the process. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…holds - A request recorded as sent is returned whether or not its receiving account could be registered: a registration that fails is logged and left to the next sync. Its error used to send a retry on to sign a second request past the one just recorded. - The repeat broadcast of a held public request takes the wallet generation's lifecycle gate before its check and keeps it through the dispatch, so nothing goes out for a wallet that is being removed. - note_external_account_registered, store_contact_account_label and the external registration's early already-exists check act only on the handle's wallet generation. - Durability is certified in one place, WalletPersister::flush_durably. A flush is counted as in progress from before the backend is called until its outcome is recorded, and a flush is trusted only when, after it, none is in progress and none has failed for good. A flush that had failed in the backend but not yet recorded it could otherwise be missed. A read-back noted while another flush is in progress is kept for a later call. Tests cover each, and the restoration path's use of the durability check. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…sh of a wallet id together - A settle of an unconfirmed public request records the request it found on Platform only while its own hold still stands, checked in the lock it records in. Its reads run with no lock held, so another settle of the same hold can record the request and release the hold first, and a request sent after that is the one tracked: the later settle used to record the older request over it. It now records nothing, and answers the request only when that is still the one tracked. - The flushes of the records under a wallet id are counted in one ledger per id, kept with the manager's per-wallet state: how many are in progress and how many failed for good. A wallet's persister, the persister of a wallet removed or created under the same id, and the manager's own flush of a replaced backfill record all go through it. The count used to live in each wallet's persister, so a flush made anywhere else could drop the buffer without that wallet knowing, and a later flush of its own would vouch for records that were gone. A wallet made after such a failure starts clean, as it tracks what it read from disk. Tests cover each: a settle parked between its reads and its recording, the manager's flush, and a removed wallet's flush against its successor. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…is known to be on disk Before a private contact request is paid for, the wallet stores a marker that the identity holds a payment that may be unresolved, and flushes it on a backend that does not commit a store inline. It trusted that flush as soon as it succeeded. A flush that succeeds proves nothing by itself: another flush of the wallet's records may take what was buffered and fail for good, dropping it, and the marker's own flush then succeeds over a buffer that no longer holds it. `WalletPersister::store_durably` stores a changeset and answers for it only when, after its flush, no other flush of the wallet id's records is in progress and none failed for good since before the store, read from the ledger that counts every flush of the id. The marker is stored through it, so a marker that may have been dropped refuses the payment with nothing paid. Unlike `flush_durably` it answers for the one changeset: a flush that failed for good before the store does not refuse it. `NotDurable::Flush` becomes `NotDurable::Backend`, as it now carries a failed store too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…r request when a held one settles Two gaps in the contact request holds. A flush that fails transiently takes the wallet's buffered records and puts them back when it fails. A flush made meanwhile succeeds over a buffer those records are not in, and once the other one had returned nothing showed it: no flush in progress, none failed for good. The flush ledger now counts every failed flush, and `store_durably` and `flush_durably` trust their own flush only when none failed while they ran. They answer `NotDurable::OtherFlushUnsettled` (was `OtherFlushInFlight`) for a flush in progress or one that put back what it took: the caller asks again, and that flush writes it. A settle that found its held request on Platform recorded it whenever its own hold still stood. A sweep may have read in a newer request by then, one that another device of the identity sent while the hold stood, and recording the older one over it had the next rotation build from a reference already used. `record_settled_public_request` now passes over a request older than the one tracked, as the sweep's ingest does (`predates`): the hold is released and nothing is recorded. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…dropped it Five places store a record, flush it on a backend that does not commit a store inline, and then act as if the record were on disk: the address reservation a contact payment stores before its broadcast, the address `reserve_payment_address` hands out, the invitation funding index, the row of a funding that pays a shielded recipient, and the record of a funded invitation voucher. A flush that succeeds proves nothing by itself: another flush of the wallet's records may take what was buffered and fail for good, dropping it, and the site's own flush then succeeds over a buffer that no longer holds the record. A restart would then pay a contact's address twice, export an invitation's one-time key twice, lose the address a shielded funding pays, or lose track of a funded voucher. Each of them now goes through `WalletPersister::store_durably`, which answers for the record only when no other flush can have dropped it. The sites that have sent nothing yet abandon what they built, as they do for a failed flush. The voucher's record is stored once more first, as the voucher is already funded, and only then reported as not persisted, with no link. `NotDurable::Backend` is split into `Store` and `Flush`, so a site keeps reporting a failed store and a failed flush the way it did. Wallet drains, the consumption-unknown marker, the cleared private payment marker, the balance retry and the manager's backfill replace are left as they are: a drain runs only where a store is the commit, and a record lost at the others is repaired by a later sync or fails closed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tform-wallet-durable-store-sites The base now answers `NotDurable::OtherFlushUnsettled` where it answered `OtherFlushInFlight`, and counts transient flush failures too. The conflict in `persister.rs` keeps the base's ledger reads with this branch's `NotDurable::Store` and `NotDurable::Flush`, and the two sites that named the old variant name the new one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The base branch now answers `NotDurable::OtherFlushUnsettled` when another flush of the wallet's records failed transiently while the call ran and put back what it had taken, as well as when one has not returned. Neither is a lost record: a later flush writes it. Two tests pin how the changed sites treat it. A prepared contact payment whose reservation another flush took and put back sends nothing and reports a flush to be tried again (`PersisterFlush` of kind `Transient`), not a discarded round. A funded invitation's record that another flush took and put back is stored once more, and the flush that follows writes it. The comments on both sites say what the answer covers now, and an unused import in the invitation tests goes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit 80004d2) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The PR improves several wallet durability gates and the new overtaken-flush handling is generally correct. One blocking lifecycle bug remains: the shielded-recipient failure path can leave a durable resumable Built row while releasing its funding inputs, allowing recovery to rebroadcast a transaction after the caller was told the build failed. The Kotlin SDK check failed during an external Gradle action download timeout before build execution and is unrelated to this Rust-only change.
🔴 1 blocking | 🟡 2 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Failed recipient durability can leave a resumable Built lock
packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1527-1548
store_durably can return NotDurable::Lost or OtherFlushUnsettled even when this call's asset-lock row was committed: an overlapping flush may take the buffered row, fail or remain in progress, and the row's own flush can then complete after the buffer was emptied. This branch queues the removal with queue_asset_lock_changeset, which only calls plain store and does not flush it, then abandon_unsent_build releases the transaction inputs. If the process exits before another flush, the persisted row remains Built with no proof while its inputs are reusable. Recovery explicitly treats (AssetLockStatus::Built, None) as requiring a broadcast, so a later restart can send the supposedly abandoned transaction; a retry can independently build and send another transaction with different inputs. Make the removal durable before releasing the reservation, or retain the reservation and transition the persisted row to a non-resumable/tombstoned state when durable cleanup cannot be established.
source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, rust-quality, security-auditor)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate wallet diff changes payment broadcasting, address reservation, invitation funding, and one-time key handling, directly affecting funds movement and key safety. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1527-1548: Failed recipient durability can leave a resumable Built lock
`store_durably` can return `NotDurable::Lost` or `OtherFlushUnsettled` even when this call's asset-lock row was committed: an overlapping flush may take the buffered row, fail or remain in progress, and the row's own flush can then complete after the buffer was emptied. This branch queues the removal with `queue_asset_lock_changeset`, which only calls plain `store` and does not flush it, then `abandon_unsent_build` releases the transaction inputs. If the process exits before another flush, the persisted row remains `Built` with no proof while its inputs are reusable. Recovery explicitly treats `(AssetLockStatus::Built, None)` as requiring a broadcast, so a later restart can send the supposedly abandoned transaction; a retry can independently build and send another transaction with different inputs. Make the removal durable before releasing the reservation, or retain the reservation and transition the persisted row to a non-resumable/tombstoned state when durable cleanup cannot be established.
In `packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs:109-113: Retry a non-transient own-flush failure before abandoning the funded invitation record
`record_funded_invitation` retries when an overlapping flush reports `Lost` or `OtherFlushUnsettled`, but not when its own `store_durably` call returns a non-transient `NotDurable::Flush`. In both cases the funded voucher can remain absent from durable Sent-invitation records, making it unreclaimable after restart. The row is keyed by outpoint, so retrying the identical changeset is idempotent; a constraint or fatal backend error can fail again without creating a duplicate. Either retry once for non-transient flush failures or document why this backend failure is intentionally definitive while the overlapping-flush cases are retryable.
In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1571-1577: Preserve typed Fatal versus Transient classification for payment-address reservations
The new `store_durably` result distinguishes a dropped buffered round (`Lost`, fatal) from a round another flush still holds or restored (`OtherFlushUnsettled`, transient). This call site converts both, along with ordinary flush failures, into `PlatformWalletError::Persistence(String)`, so Rust callers cannot inspect the typed source or retry classification. The shared prepared-payment path preserves this information as `PersisterFlush`, and the reservation path should use the same typed mapping rather than erasing the distinction and relying on a wildcard arm.
The flush ledger counts a flush as in progress until its outcome is recorded, so that while none is in progress its counts tell of every flush that failed. A backend that panicked in its flush broke that: the flush stopped being counted with nothing recorded, and a caller that caught the panic and carried on could then trust a later flush over records the panicking one had taken. A flush that ends without its outcome recorded is now counted as failed for good before it stops being in progress, as what its backend did with what it took is not known. Also brings the FFI, Swift and Kotlin descriptions of result code 76 in line with the wallet's and the registry's: it is also what a public send or accept gets while another public request to the identity is being sent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…al before releasing its inputs A funding that pays a shielded recipient is abandoned when its row is not known to be on disk. The row may be there all the same: its own flush wrote it while another flush of the wallet's records failed or was in progress beside it. The removal of the row was only queued, so a process that ended before the next flush left a Built row behind, and the restart sent a funding that had been reported as not made. The removal now goes through WalletPersister::store_durably before the inputs are released. When it is not known to be on disk either, the error says a restart may still resume the lock. The inputs are released in both cases: nothing was sent, and the reservation does not outlast a restart. Also documents why record_funded_invitation stores the record again for a flush another one overtook, but not for a store or flush of its own that the backend failed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tform-wallet-durable-store-sites Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The shared durability checks and invitation-record retry policy are implemented consistently, and the payment-address mapping preserves its existing public error contract. One blocking lifecycle issue remains: when compensating removal of an abandoned shielded-funding row is not durable, the code still releases the inputs while the persisted Built row may remain resumable, allowing a later retry or restart to create conflicting funding.
🔴 1 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate Rust wallet change that directly alters funds movement, payment-address and invitation key reservation durability, and persistence behavior in asset-lock and payment flows. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1540-1559: Failed recipient durability can leave a resumable Built lock
When the initial `store_durably` fails, the code correctly attempts a durable removal of the shielded-recipient row. However, it unconditionally calls `abandon_unsent_build` even when that removal returns an error. That helper releases the selected inputs and settles the broadcast fence as released, while the row can still remain durable and be loaded as `Built` after restart. The regression test at `should_say_a_restart_may_resume_a...` confirms this exact state and then confirms that a new funding can immediately use the released inputs. A subsequent restart can resume the old Built transaction while the retry has already spent those inputs or other funds, violating the invariant that a resumable row must not coexist with re-spendable inputs. If removal durability cannot be confirmed, retain the reservation and pending fence, or persist and enforce a non-resumable terminal state before releasing them.
… the broken-channel mark Two gaps a review of 901eeec found. The manager replaces the host's DashPay backfill record before it publishes a wallet, and on a backend that buffers it flushed that replacement itself and trusted the flush when it succeeded. The flush was counted in the wallet id's flush ledger, but nothing read the ledger afterwards: a flush by a handle of an earlier wallet under the id could take the replacement first and fail, and the manager's own flush then succeeded over a buffer that did not hold it. The replacement now goes through `WalletPersister::store_durably` on that ledger, as a wallet's handle stores a record it acts on, and the wallet is not published when the record is not known to be on the host. On such a backend the replacement is always an empty record with no cursor, so what was at stake is a record an earlier run left staying on the host. `NotDurable::Backend` is split into `Store` and `Flush`, as the stacked store-site change already has it, so the manager keeps reporting a failed store and a failed flush as it did. `WalletPersister:: classify_not_durable` maps the four answers to the wallet error: a record another flush dropped is `PersisterFlush` of kind `Fatal`, one still buffered is `PersisterFlush` of kind `Transient`. `mark_contact_channel_broken` looked the wallet up by id alone, where the two completions beside it already check the handle's generation. Work that found a permanent fault for a wallet since removed and created again under its id could mark the new wallet's contact broken and store that. It now checks the generation too. Tests: should_not_publish_over_a_backfill_record_another_flush_took, should_break_no_channel_on_a_replacement_from_a_stale_handle. Each fails with its fix taken out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…le its row may outlive its removal A funding that pays a shielded recipient is abandoned before its broadcast when its row is not known to be on disk, and the row's removal is then written before the inputs are released. Where that removal was not known to be on disk either, the inputs were released all the same and the call failed with a persistence error, while a restart could still find the row and send it: a caller told the funding failed builds it again, and the restart sends the first lock beside the second. The inputs now stay reserved and fenced there, and the call returns TransactionBroadcastUnconfirmed. They are still released where the row cannot outlive the call without its removal: the removal is on disk, the backend refused the row, or the row's own flush failed and the removal's did too, the two then being kept, written or dropped together. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tform-wallet-durable-store-sites Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… through the shared mapping `DashPayView::store_durably` wrote out how each `NotDurable` answer becomes a wallet error. The base branch now has that mapping as `WalletPersister::classify_not_durable`, so the view calls it and the mapping lives in one place. What a caller gets back is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The normal flush-ledger race is addressed, but the shielded-recipient cleanup still releases reserved inputs when a non-atomic persistence round may have partially written the Built row. The same safety gap exists when an initial flush fails after a concurrent flush commits the row; no failed code checks are reported, with only the review check still in progress.
🔴 1 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large and intricate wallet change that alters payment preparation, address reservation, invitation funding, and asset-lock handling on a critical funds-movement and key-handling surface, particularly in prepared_payment.rs and asset_lock/build.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1558-1571: Non-atomic recipient persistence failure can still release inputs for a resumable shielded lock
The release arms treat `(NotDurable::Store(_), Err(_))` and `(NotDurable::Flush(_), Err(NotDurable::Flush(_)))` as proof that no Built row can survive. That proof does not follow from these error types. The FFI persistence contract permits a backend to expose `ASSET_LOCK_SHIELDED_RECIPIENTS` without `ATOMIC_CHANGESETS`; its legacy store invokes the base asset-lock callback before the recipient sidecar callback, so a later callback failure can return `NotDurable::Store` after the Built row was already persisted. If removal then fails, `abandon_unsent_build` releases the inputs even though restart can load the row and resume it. Likewise, `store_durably` returns immediately on its own flush error before consulting the flush ledger, so a concurrent flush may commit the row while the initial call returns `NotDurable::Flush`; the matching failed-flush removal arm then releases the same inputs. Require an atomic/no-partial-write guarantee before using these release cases, or conservatively retain the reservation and pending-spend fence whenever removal durability is not confirmed. Add regression coverage for a partial store that persists the row before returning an error, followed by failed removal, and for a concurrent flush that commits the row before both calls report failure.
… the wallet id fails for good The persister remembers which marker each identity's position record was last stored with, so a record is stored again only when its marker changed. A flush that fails for good drops what the backend buffered, and a store remembered that way may still have been in it. The remembered markers were cleared only where this handle's own flush failed for good while read-backs were being noted. A loss the shared flush ledger reported (another handle's flush, or the manager's) left them in place, so the next comparison found the marker "already stored" and did not store it again. The remembered markers now carry the ledger's count of flushes that failed for good, and are forgotten whenever that count has moved: whoever made the flush, and whether or not anything asked for a durable flush since. The explicit clear in the read-back path goes, as the ledger counts that flush too. Test: should_forget_stored_markers_once_any_flush_of_the_wallet_id_fails_for_good, which fails with the check taken out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…only once its row's removal is on disk An abandoned shielded funding still handed its inputs back, with the removal of its row not known to be on disk, where the backend had refused the row, and where the row's own flush and the removal's had both failed. Neither proves the row is gone. A host that does not roll a failed round back may have written the row before a later part of the store failed (the FFI persister calls the asset-lock callback before the recipient sidecar's), a backend that keeps a failed store or flush for later writes the row then, and a flush that failed may have run beside another that wrote it. A restart that finds the row resumes and sends it. The inputs are now released only when the removal is known to be on disk. Every other failed gate keeps the reservation, leaves the fence pending and returns TransactionBroadcastUnconfirmed. should_abort_typed_amount_funding_when_the_recipient_cannot_be_made_durable pinned the hand-back for a backend that failed the removal too. It now fails the row's store or flush once and lets the removal through, which still hands the inputs back. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
A blocking concurrency race remains in the new shielded-row cleanup path: the flush ledger detects overlapping flushes only while they are in flight or when they fail, so a successful late flush can recreate a row after its removal and after inputs are released. The FFI built-observer documentation also omits the new durability-abort outcomes, where the row may be absent in-session despite a non-rejection error. No failed code checks are present in the CI snapshot; Kotlin passed, while the Rust review check was still queued.
🔴 1 blocking
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: Observer contract does not cover durability-abort outcomes
packages/rs-platform-wallet-ffi/src/asset_lock/built_callback.rs:20-27
The callback runs at line 1514 before the shielded recipient row is durably stored. If the initial store_durably fails and the removal returns Ok(()), abandon_unsent_build releases the inputs and no track_asset_lock call occurred; the FFI funding mapper reports this persistence failure as ErrorWalletOperation, not ErrorTransactionBroadcastRejected. If removal durability is also uncertain, the result is ErrorTransactionBroadcastUnconfirmed, but the row still is not tracked in memory during this call; only a restart may reload it. Therefore the statement that every non-rejection failure leaves the lock tracked and resumable in-session is false. Update the callback contract to describe these two durability-abort cases and the possibility of ErrorAssetLockNotTracked on an immediate resume.
/// Record the outpoint before returning (durably, if it has to survive a
/// restart): the lock's row is persisted immediately after the callback. The
/// result determines whether the row is available for resume:
/// `ErrorTransactionBroadcastRejected` (26) means a tracked row was removed;
/// other broadcast failures normally leave it tracked and resumable by this
/// outpoint (a resume may find it already consumed).
///
/// Shielded funding can abort before broadcast while making its recipient row
/// durable. If row removal succeeds, the row is gone and an in-session resume
/// may return `ErrorAssetLockNotTracked`; if removal is not confirmed, the
/// result is `ErrorTransactionBroadcastUnconfirmed` (20), and a restart may
/// recover the row even though this session has not tracked it. A persistence
/// abort whose removal succeeded may be reported as `ErrorWalletOperation` (6).
/// The row store and removal are best-effort, so after a restart a failed store
/// can leave no row for a broadcast lock, or a row of a removed one.
source: muse-spark-1.3-contributor (phase1-reviewer: general)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate wallet change that alters funds movement, address reservation, shielded funding, invitation recovery, and one-time key handling across multiple persistence and concurrency paths. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Code unchanged since the last final review (
366ef664): 1 new suggestion(s) listed as follow-up candidates, not posted inline - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1540-1564: A successful overlapping flush can recreate the row after its removal
The `Ok(())` arm treats `store_durably` for the removal as proof that the `Built` row is gone, but `store_durably` only checks `in_flight`, `failed`, and `lost`; `FlushLedger` records no successful-flush ordering or generation. A valid interleaving is: another flush takes the original row and pauses; the row's own durability call observes that overlap and fails; the removal is queued and its flush commits the tombstone; the first flush then successfully commits the old row and returns before the removal call reads the ledger. At that point there is no failure delta and no flush in progress, so this code releases the inputs even though the old row is durable again. After restart, the `Built` row can be resumed with inputs that the wallet has already made reusable. Serialize per-wallet flushes, or add an ordering/generation check that revalidates the removal after every earlier flush has settled, and add coverage for a late successful flush.
…is recorded as sent, and note a marker only when no flush dropped its record Two gaps a review of 9aa9a1b found, and two smaller points. `record_sent_contact_request` recorded the request it was given whatever the wallet tracked for the pair. A send looks the request up on Platform, or broadcasts it, with no lock held, and a sweep may read in a newer request meanwhile, one another device of the identity sent. Recording the older one over it would have the next rotation build from a reference already used. An older request is now passed over (`predates`, as the settle and the sweep already do): the tracked request is answered as the request sent, and its account is left to the sweep that read it in. The previous commit made the persister forget the markers it remembers as stored once a flush of the wallet id's records fails for good. One window was left: a position record is stored and its marker is noted afterwards, so a flush that failed for good in between moved the ledger's count before the note and the marker looked stored although its record may have been dropped. `WalletPersister:: store_private_marker_record` reads the count before the store and notes the marker only when the count is still the same, compared under the lock the marker is noted in. `store_private_position` goes through it. `FlushLedger`, `FlushLedgers` and `WalletPersister::with_flush_ledger` are now visible inside the crate only: nothing outside uses them, and a ledger made elsewhere would count some of a wallet id's flushes apart from the rest. The Kotlin doc of `publicContactRequestUnconfirmed` said the held bytes are always broadcast again; it now says when. Tests: should_keep_a_newer_tracked_request_when_an_older_one_is_recorded_as_sent, should_not_note_a_marker_whose_store_another_flush_dropped. Each fails with its fix taken out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tform-wallet-durable-store-sites Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ush that may hold the row is in progress An abandoned shielded funding releases its inputs once the removal of its row is known to be on disk. That removal went through `store_durably`, which answers for the removal alone. A flush still in progress may have taken the row before the removal was stored, and nothing says a backend writes what that flush took before what a later one takes: it could write the row after the removal and return before the ledger was read, and a flush that succeeded is counted nowhere. The inputs were then released with the row on disk for a restart to resume. The removal now goes through `WalletPersister::withdraw_durably`, which also refuses to answer, and flushes nothing, while a flush is in progress once the removal is stored. With none in progress then, every flush that could hold the row alone has returned, and one that begins later takes the removal with whatever of the row is still buffered. The `AssetLockBuiltFn` comment said every failure but a rejection leaves the lock tracked and resumable in the session. A shielded funding abandoned before its broadcast is not tracked, and the comment now says so. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The final Rust persistence behavior is internally consistent and no remaining blocking correctness or security defects were identified. One in-scope public callback contract remains stale in the Swift and Kotlin SDKs: it does not describe the new pre-broadcast untracked outcome; no code checks are failing in the supplied CI snapshot, although the review check is still queued.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(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.
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: Mirror the new pre-broadcast untracked outcome in mobile callback contracts
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/AssetLockBuiltCallback.swift:41-51
The Swift documentation still says that every callback failure other than transactionBroadcastRejected leaves the lock tracked and resumable. The Rust callback contract now has an exception: shielded funding can invoke the callback, fail to durably persist the recipient row, and abandon the funding before tracking or broadcasting it, producing the untracked outcome (ErrorAssetLockNotTracked, code 23) or an uncertain outcome (ErrorTransactionBroadcastUnconfirmed, code 20) when row removal cannot be confirmed. Kotlin's corresponding documentation at ManagedPlatformWallet.kt:907-914 likewise says the callback cannot stop funding and that the lock is still broadcast and submitted. A host following these contracts can persist a stale outpoint and offer a resume for a lock that was never broadcast, or assume funding occurred when the result is unconfirmed. Update both public contracts and outcome guidance to document the pre-broadcast untracked case and that code 20 is resumable after restart only if the row survived.
source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate changes in wallet payment, invitation funding, asset locking, and shielded-fund persistence directly affect funds movement and one-time key handling, including concurrency and durability races. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Code unchanged since the last final review (
88b8cba5): 1 new suggestion(s) listed as follow-up candidates, not posted inline - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
…n the identity state A review of 76c5630 noted that "an older request is not recorded over a newer one" was checked by each caller: the sweep's ingest, the settle of a held request, and the send's record. The mutation itself, `ManagedIdentity::add_sent_contact_request`, took any differing account reference as a rotation, so a caller without the check could still replace a newer tracked request. The rule now lives where the request is recorded. `ManagedIdentity::track_sent_contact_request` passes over a request older than the one tracked for its recipient (`predates`, moved here with `freshness`) and answers what became of the request: recorded, already tracked, or superseded. `add_sent_contact_request` goes through it and keeps its signature. The three callers read the answer and no longer compare for themselves. Also says, where the manager is made and where the flush ledgers live, that a storage backend serves one manager: the order of durable cursor writes and the count of flushes are kept per manager, so a second manager over the same backend instance, or a wallet handle of an earlier manager still storing through it, is not supported. The README says the same. Test: should_pass_over_a_sent_request_older_than_the_one_tracked, which fails with the check taken out, as the two caller-level tests do. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Static review of this head found two blocking wallet-persistence races. A successful SQLite delete pre-flush can still remove a record without increasing the loss counter, and private-payment marker acknowledgement has a similar unsynchronized loss window. No code check is reported failed in the supplied CI snapshot, although several checks remain pending.
🔴 2 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: A private-payment recovery marker can be certified after a concurrent flush drops it
packages/rs-platform-wallet/src/wallet/persister.rs:363-367
store_private_marker_record snapshots losses() before the store and then calls stored_markers(), which reads the loss count and returns the marker mutex before line 367 inserts the acknowledgement. That mutex does not synchronize backend drains. On SQLite Manual mode, a host commit_writes() or direct flush can take and drop the buffered position changeset after stored_markers() observed the old loss count but before the marker is inserted. The drop counter then changes, but store_private_payment_marker follows this path with a plain persister.flush() at lines 705–706; an empty flush succeeds without checking the counter, leaving the in-memory marker recorded as durable. If the dropped record was the unresolved (true) marker, restart can load the older or absent marker and fail to raise the private-payment recovery hold while the unresolved shielded payment remains. A final durability/loss check must cover the acknowledgement insertion, or a later observed loss must invalidate the marker before it can suppress the next rewrite.
source: gpt-6.1-sol (phase2-reviewer: security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate change to wallet persistence and payment/invitation flows that directly affects funds movement and one-time key handling under concurrent flush races. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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-storage/src/sqlite/persister.rs`:
- [BLOCKING] packages/rs-platform-wallet-storage/src/sqlite/persister.rs:922-924: An unledgered SQLite commit can still certify a dropped reservation
The fatal `commit_writes` drain is now counted, but `delete_wallet_inner` still has an uncounted successful pre-flush drain. In Manual mode, a concurrent `store_durably` can place a reservation or other record in the buffer; deletion takes it at line 827, writes it successfully in the pre-flush transaction, then deletes the wallet. Because `drained_slot` was consumed before the cascade, the post-commit check at lines 922–924 does not call `note_dropped`. The waiting durable store then flushes an empty buffer, observes no loss or failure delta, and can return `Ok` even though its record was deleted. The storage API explicitly permits a racing store to return `Ok` while deletion discards it, so the caller can broadcast or hand out a value whose reservation is gone after restart. Count this successful pre-flush deletion as invalidating concurrent durable operations, or serialize deletion with them, and add a regression for the pre-flush-success interleaving.
In `packages/rs-platform-wallet/src/wallet/persister.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/persister.rs:363-367: A private-payment recovery marker can be certified after a concurrent flush drops it
`store_private_marker_record` snapshots `losses()` before the store and then calls `stored_markers()`, which reads the loss count and returns the marker mutex before line 367 inserts the acknowledgement. That mutex does not synchronize backend drains. On SQLite Manual mode, a host `commit_writes()` or direct flush can take and drop the buffered position changeset after `stored_markers()` observed the old loss count but before the marker is inserted. The drop counter then changes, but `store_private_payment_marker` follows this path with a plain `persister.flush()` at lines 705–706; an empty flush succeeds without checking the counter, leaving the in-memory marker recorded as durable. If the dropped record was the unresolved (`true`) marker, restart can load the older or absent marker and fail to raise the private-payment recovery hold while the unresolved shielded payment remains. A final durability/loss check must cover the acknowledgement insertion, or a later observed loss must invalidate the marker before it can suppress the next rewrite.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…had buffered The SQLite persister counted what a deletion could not write, and not what its pre-flush wrote and the cascade then deleted with the wallet's rows. A store made durable across the delete found an empty buffer, no counted flush failed and no drop was reported, so it was answered for with its record on no disk. A deletion that commits now counts as a drop for the wallet whatever it had staged. Also pins, with a test and a doc note, that the note of a stored private payment marker is forgotten once the backend reports a drop, and says why the plainly flushed marker store is safe: it never writes the first unresolved marker. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
On the review of 126ffd1, the finding without an inline thread, "A private-payment recovery marker can be certified after a concurrent flush drops it" (
🤖 Addressed by Claude Code |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Updated after discussion: 1 finding(s) of this review were settled in the inline threads; no blocking finding remains.
- ✅ Withdrawn: 🔴 A Manual-mode store can enter after deletion's final drain and resurrect deleted state
The flush ledger, backend-drop accounting, deletion invalidation, and shielded cleanup changes address the previously identified durability races. One blocking storage race remains: Manual-mode non-identity stores are not excluded from the interval between deletion’s final buffer drain and the deletion call returning, so a late changeset can be flushed after a successful wallet deletion and recreate deleted state. CI has no reported failed code checks, but the Kotlin build and policy/PR-hygiene checks were still pending in the supplied snapshot.
A pattern across this PR's review rounds
This is review round 10, and the PR has drawn 9 blocking findings so far. 9 of them share 2 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. No serialized durability boundary (1 new in this round, 6 earlier finding(s))
WalletPersister tries to certify a changeset by sampling FlushLedger and SQLite's dropped counter around separate store, flush, commit, and delete operations. PlatformWalletPersistence does not provide one per-wallet linearizable operation that binds the stored generation to the durable result: an older successful flush, an external drain, or a deletion can race the check. Each counter or ordering patch therefore closes one interleaving while leaving another way for the reported durable state to differ from the state on disk.
In this round: A Manual-mode store can enter after deletion's final drain and resurrect deleted state
2. Partial changesets have no reliable durable outcome (2 earlier finding(s))
The wallet interprets Store and Flush errors as if they describe the whole changeset, but a backend or FFI host can persist the Built row before a sidecar callback or later part of the store fails. Without an enforced atomic-change-set guarantee, cleanup may release inputs while restart still sees a resumable row, so each cleanup path needs another exception.
Suggested decision (land the prerequisite first): Land a per-wallet atomic durability primitive in PlatformWalletPersistence and SqlitePersister before this PR: it must serialize store, flush, external commit, and deletion, bind the exact changeset generation to its commit result, and make sidecar writes atomic. WalletPersister should consume that result instead of inferring durability from counters and post-hoc observations. Until that primitive exists, this PR should drop or gate the operations that require the unsupported concurrent-buffering guarantee.
🔴 1 0 blocking
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate change to wallet persistence and concurrency that directly affects funds movement, coin/input reservation, payment address and invitation key handling, and durable storage correctness. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): No serialized durability boundary; Partial changesets have no reliable durable outcome. When you fix the findings below, fix the cause, not only the reported case. The review suggests (land the prerequisite first): Land a per-wallet atomic durability primitive in PlatformWalletPersistence and SqlitePersister before this PR: it must serialize store, flush, external commit, and deletion, bind the exact changeset generation to its commit result, and make sidecar writes atomic. WalletPersister should consume that result instead of inferring durability from counters and post-hoc observations. Until that primitive exists, this PR should drop or gate the operations that require the unsupported concurrent-buffering guarantee. If that decision is not yours to make, say so to the PR's author or maintainer.
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-platform-wallet-storage/src/sqlite/persister.rs`:
- [BLOCKING → WITHDRAWN in discussion; do not fix] packages/rs-platform-wallet-storage/src/sqlite/persister.rs:927-935: A Manual-mode store can enter after deletion's final drain and resurrect deleted state
The post-commit `take_for_flush` only removes changesets already present in the buffer. During `delete_wallet_inner`, the connection mutex does not serialize all Manual-mode stores: the Manual branch of `store` acquires `conn` only when the changeset contains identities, while non-identity changesets merge under the buffer mutex alone. A non-identity store can therefore merge after this final drain returns but before deletion releases `conn` and returns success. That changeset is not discarded by the final drain and a later flush can write it after the wallet cascade; `wallet_metadata` is upserted by the changeset writer, so this can recreate the deleted wallet, while other wallet-scoped rows can resurrect stale state. Serialize all buffer merges with the deletion window or add a deletion generation/barrier that rejects or drains stores arriving before deletion returns, and add a regression for a late non-identity Manual-mode store.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review after discussion — commit 3eb8f51
Standing review was CHANGES_REQUESTED; this re-review is COMMENT: no blocking findings remain.
Not approved yet: on a later review round an approval needs the fresh Phase-2 audit of the whole change, which the review of this commit skipped because it had found a blocker. That audit is queued for this commit and approves if it finds nothing.
No longer blocking:
- A Manual-mode store can enter after deletion's final drain and resurrect deleted state
Same commit as the standing review; the inline threads above carry the per-finding outcome. This follow-up exists only to correct the verdict.
Review provenance
Source: conversation lane gpt-6.1-sol (agent: conversation); no reviewer or verifier lanes ran for this follow-up
- Verdict moved because the inline discussion withdrew or deferred findings of the standing review of this commit; the code was not re-reviewed
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review after discussion — commit 3eb8f51
Standing review was COMMENTED; this re-review is REQUEST_CHANGES: 1 blocking finding(s) now stand.
🔴 1 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
No longer blocking:
- Failed recipient durability can leave a resumable Built lock
- Non-atomic recipient persistence failure can still release inputs for a resumable shielded lock
- A successful overlapping flush can recreate the row after its removal
- A successful stale flush can still roll back the invitation funding index
- An unledgered SQLite commit can still certify a dropped reservation
- An unledgered SQLite commit can still certify a dropped reservation
- A Manual-mode store can enter after deletion's final drain and resurrect deleted state
The current head closes the previously identified wallet durability and cleanup races, with the Rust workspace test check passing and no failed code check caused by the change. One blocking invitation-state race remains: a transient error from the invitation call's own flush is returned before the flush ledger is reconciled, so a concurrent fatal flush can subsequently drop the funded invitation record without triggering the retry path; the Swift build and policy checks are still pending.
Same commit as the standing review; the inline threads above carry the per-finding outcome. This follow-up exists only to correct the verdict.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate change across wallet persistence, payment and invitation flows, coin reservation, and key/address handling, including funds-movement surfaces in packages/rs-platform-wallet/src/wallet/identity/network/payments.rs and packages/rs-platform-wallet/src/wallet/asset_lock/build.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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/identity/network/invitation.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs:119-123: A concurrent fatal flush can drop the funded invitation record while an own transient flush suppresses the retry
`record_funded_invitation` retries only `NotDurable::Lost` and `NotDurable::OtherFlushUnsettled`. A valid interleaving is that another flush takes the newly stored invitation record and remains in progress, while this call's `store_durably` invokes its own flush; that flush sees no buffered record and returns a transient error, which `flush_what_was_stored` propagates immediately at `persister.rs:878` before checking the ledger. The other flush can then fail fatally and drop the record, but this function has already returned the transient error without storing the idempotent invitation row again. Because the asset lock was already broadcast, a process exit can leave the funded voucher absent from Sent invitations and unreclaimable. Reconcile the flush ledger/backend loss state before returning an own flush error, or retry the invitation record whenever that reconciliation shows another flush could have taken it, and add a regression for this ordering.
…re's own flush fails `store_durably` and `withdraw_durably` returned the failure of the flush they make before reading the flush ledger. That failure says what became of the stored record only when the flush that failed is the one that took it. With another flush of the wallet's records holding the record, a flush of the call's own that failed transiently over nothing read as "kept buffered", though the other flush could still fail for good and drop it. `record_funded_invitation` stores a funded voucher's record once more only on `Lost` and `OtherFlushUnsettled`, so in that ordering the record was not stored again and could be left in no buffer. When the call's own flush fails, the counts are now read first. With another flush in progress, one returned since before the store, or a drop the backend reports, the answer is the one a flush that succeeded would get there: `OtherFlushUnsettled`, or `Lost`. With none of those the failure is the answer, as before. A flush of the call's own that failed for good answers `Lost` when another flush crossed the call, so it still reads as a failure for good. No call site changes: every one refuses on any of these answers, and the invitation record is the only one that stores again on two of them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
On the re-review of 3eb8f51, the finding without an inline thread, "A concurrent fatal flush can drop the funded invitation record while an own transient flush suppresses the retry" (
The fix is in
Tests, each failing with the fix reverted:
🤖 Addressed by Claude Code |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The complete diff centralizes durability decisions in WalletPersister, accounts for backend-side SQLite drops, and conservatively retains shielded-funding reservations whenever row removal cannot be certified. The reviewed current head has no additional in-scope correctness, security, layering, or quality findings. Rust workspace tests and the review check were still in progress in the supplied CI snapshot; no local builds or tests were run in this static-review lane.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate wallet and persistence change that directly affects funds movement, coin reservation, and one-time key handling across concurrent flushes. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
#5923 merged into v5.1-dev and edits the functions this branch edits. The conflicts were in `store_durably`, in the docs of `flush_durably`, `classify_not_durable`, `NotDurable::Flush` and the flush ledger, and in the persistence trait, where both sides add methods. Resolved by keeping both: a backend that offers the atomic step is asked for it first, and any other backend runs #5923's code unchanged. Beyond the resolution, so that the two meet: - `withdraw_durably`, which #5923 added, takes the step too where it is offered. That nothing writes the record after its withdrawal is the step's contract there. - `losses_of` reads the backend's `buffered_writes_dropped` for every backend that keeps a buffer (`keeps_a_buffer`), where #5923 left it out for one whose store is the commit. SQLite in immediate mode is such a backend and still holds a changeset whose commit failed transiently, so a plain store that fails for good there drops it, which only the backend counts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Resolves the conflicts with #5536, #6143, #5282, #5923, #5951 and the v5.1-dev merge: - Durable writes use v5.2-dev's `store_and_commit` (#6143) in place of this branch's `commit_durably`, which did the same; the recipient assignment stays counted in the flush ledger. - An abandoned unsent lock's row is removed through `withdraw_durably`. A shielded funding whose removal is durable releases its inputs and hands its funding index back, so a retry rebuilds the same lock. - The identity-recipient migration is renumbered V023 -> V024 after v5.2-dev's V021-V023; schema fingerprints updated. - The SQLite asset-lock funding pool restore uses `AddressPool::insert` and `mark_used` after the rust-dashcore bump made the pool fields private. - `on_dispatch` runs after the generation check, right before the send. - Error codes 81 and 82 kept; the registry lists 83-87 from v5.2-dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Basic explanation
What this does: Before the wallet sends a payment to a contact, hands out a payment address, or funds an invitation, it writes a record to disk first (which address is taken, which key index was used, who a funding pays). On a storage backend that collects writes and commits them later ("flush"), the wallet asked for a flush and trusted it when it succeeded. That is not enough: another flush of the same wallet can pick up the waiting record first and fail, which throws the record away or leaves it waiting again, and the wallet's own flush then succeeds with nothing left to write. This PR makes five such places check that no other flush can have taken their record before they go on.
Value: A contact's payment address is not paid twice after a restart, an invitation's one-time key is not exported twice, a shielded funding does not lose the address it was meant to pay, and a funded invitation does not disappear from the list it can be reclaimed from.
Risks: Low. Wallet code only, no consensus change. The Swift and Kotlin hosts commit every write when it is stored, so for them only the case at the end of this paragraph changes. On a backend that commits at flush, a send, an address reservation or an invitation that overlaps another flush of the same wallet is now refused before anything is sent and has to be tried again. The contact request journal's durability check is refused in the same case and asks again later. The SQLite persister gains a counter and nothing else: no schema, write or commit path changes. One case holds funds back, on every host: a shielded funding that is abandoned because its row could not be made durable, and whose row's removal then cannot be confirmed on disk either (the backend fails twice in a row), keeps its inputs reserved until the wallet restarts and is reported as an unknown outcome, where it used to hand the inputs back. Nothing here was run against a live network.
Issue being fixed or feature implemented
Follow-up to #5908, which added the per-wallet flush ledger and
WalletPersister::store_durablyand moved one site (the marker a private contact request stores before paying) onto it. #5908 is merged, so this PR now targetsv5.1-devdirectly. It goes through the other places that store a record, flush it, and then act as if it were on disk.The case, on a backend whose
storeonly buffers:Every site that flushes a wallet's records, and what was decided for it:
network/prepared_payment.rsDashPayView::store_durably: the address reservationsend_paymentandsend_prepared_paymentstore before the broadcastnetwork/payments.rsreserve_payment_addressasset_lock/build.rsinvitation funding index (the pool stored before the broadcast)asset_lock/build.rsrow of a funding that pays a shielded recipientnetwork/invitation.rsrecord of a funded voucherasset_lock/build.rsdrain funding indices, drain row, rejected drain removal;asset_lock/operation.rscomplete_wallet_drain,persist_drain_lock_snapshotrequire_wallet_drain_persistence), so nothing is buffered and the flush only notifies the hostasset_lock/sync/tracking.rsmark_asset_lock_consumption_unknownnetwork/private_contact_requests.rsstore_private_payment_marker(clearing the marker)state/managed_identity/sync.rsretry_pending_balancemanager/mod.rssettle_published_backfill(the manager's replacement of the host's backfill record)WalletPersister::store_durablyplatform_wallet.rsflush_persistDashPayView::store_durablyis shared, so the three other stores that go through it get the same check: an address found already paid on chain (prepare_payment,send_payment, and a refusedsend_prepared_payment) and the release of a reservation whose payment was not sent. A lost mark is found again from the transaction history at the next send, and a lost release reloads the address as reserved, which skips an index and reuses nothing.What was done?
wallet/persister.rs:WalletPersister::withdraw_durably, used for the abandoned shielded funding below;store_durablygains one refusal, described with the flush ledger in the next item. The split ofNotDurable::BackendintoNotDurable::StoreandNotDurable::Flush, which lets a site keep reporting a failed store and a failed flush the way it did, started here and is now inv5.1-devthrough fix(platform-wallet): keep contact request holds consistent after an unconfirmed send #5908, together withWalletPersister::classify_not_durable.changeset/flush_ledger.rs: the ledger also counts every flush that has returned, whatever its outcome (FlushLedger::returned), and counts it before the flush stops being counted as in progress.store_durablyandwithdraw_durablyboth read it.store_durablynow refuses when a flush other than its own returned since before the store, even with none in progress and none failed: one that took an older state of the same record before the store may have written it after the call's own flush wrote the newer, and a restart would then find the older state (the funding pool an invitation's key index comes from, a contact's address reservation). The answer isNotDurable::OtherFlushUnsettled, as for a flush still in progress, and every site already handles it. It refuses whatever that flush took, because the ledger does not know.flush_durably, which fix(platform-wallet): keep contact request holds consistent after an unconfirmed send #5908 uses for the contact request journal, gets the same comparison for its own flush. Nothing stores those records again after a refusal, so a later call answers for whatever was written last: there it rests on the backend writing what flushes took in the order they took it.changeset/traits.rs, comment only: theflushcontract now states that order as a requirement. What a flush took from the buffer must reach the disk before anything a later flush takes. Both backends in this repository already keep it: SQLite holds its connection across the take and the write, and the Swift and Kotlin hosts' store is the commit. A store made durable does not rest on it; everything else that is stored and then flushed does, and did before this PR.changeset/traits.rs: newPlatformWalletPersistence::buffered_writes_dropped, defaultNone. The wallet counts only the flushes it makes itself. A backend whose buffer can be drained another way reports here how many changesets it dropped without writing them.WalletPersisteradds that to the losses every durable check compares (store_durably,withdraw_durably,flush_durably, the private marker record), except for a backend whose store is the commit.rs-platform-wallet-storage: the SQLite persister counts every changeset it drops without writing, whichever call drained the buffer (aflushorcommit_writesthat fails for good, a failed restore, the discard once the connection is lost), and reports the count. A wallet's deletion counts too, whatever it had staged: what it wrote first went with the wallet's rows, so a store made durable across the delete is refused. Before, acommit_writesthe host made while the wallet stored a reservation could take it and fail for good, and the wallet's own flush then succeeded over an empty buffer without any flush it had counted failing. The drop is counted while the connection is held, so before any later flush of the wallet can run. A commit that keeps or writes what it took needs no count: SQLite takes, writes and restores under one connection lock.network/private_contact_requests.rs, comment only:store_private_payment_marker, which flushes plainly, says why a record dropped after it was stored is harmless there. It never writes the first unresolved marker (that one goes throughstore_durablybefore anything is paid), so a dropped record either repeats a marker the disk has or clears one, and the note that it was stored is forgotten once the loss is counted.network/prepared_payment.rs:DashPayView::store_durablygoes throughWalletPersister::store_durablyand reports its answer throughWalletPersister::classify_not_durable, the mapping fix(platform-wallet): keep contact request holds consistent after an unconfirmed send #5908 shares with the manager. A failed store is stillPersisterStore(throughclassify_store_failure) and a failed flush stillPersisterFlushwith the backend's kind. A record another flush dropped (NotDurable::Lost) isPersisterFlushof kindFatal, the buffered round discarded. Another flush that is still in progress, or that failed and put back what it took (NotDurable::OtherFlushUnsettled), isPersisterFlushof kindTransient: the round is still buffered and a later flush writes it. Both are returned before the broadcast, with the address and the inputs released as for any failed flush.network/payments.rs:reserve_payment_addressgoes throughWalletPersister::store_durably. A failed store is stillPersisterStore; everything else is stillPersistence("failed to flush payment-address reservation: ..."). The address stays used in memory and is not handed out.asset_lock/build.rs: the invitation funding index gate and the shielded recipient row go throughWalletPersister::store_durably, with their error texts unchanged (nothing is on the wire at either point). The invitation gate aborts as it did; what the shielded row's abort now does is the next item. The drain branch of the pool gate is written out on its own and does what it did.asset_lock/build.rs, the abandoned shielded funding: a row that is not known to be on disk may still be there (its own flush wrote it while another flush failed or was in progress beside it). The removal of the row was only queued, so a process that ended before the next flush left aBuiltrow, and the restart sent a funding that had been reported as not made. The removal now goes throughWalletPersister::withdraw_durably, before the inputs are released. That isstore_durablywith one more refusal: it does not answer, and flushes nothing, when a flush was inside the backend while the removal was stored, whether it is still in progress afterwards or has returned meanwhile. Such a flush may have taken the row without its removal and may write the row after the removal, and a flush that succeeded shows in no count of failures. One that returns right after the store, behind another flush that took the removal and wrote it first, leaves no flush in progress and an empty buffer, so the ledger's count of returned flushes is compared across the store. Any flush that returned across the store refuses the removal, whatever it took: the ledger does not know what a flush took. With the removal on disk the inputs are released and the call fails as before. Without it nothing proves the row is gone, however its own store or flush failed: a host that does not roll a failed round back may have written the row before a later part of the store failed, a backend that keeps a failed store or flush for later writes the row then, and a flush that failed may have run beside another that wrote it. The call then returnsTransactionBroadcastUnconfirmed(asset lock ... was not sent, but its row may be on disk and the removal of that row is not known to be, so a restart may still resume it; its inputs stay reserved) and the inputs stay reserved and fenced, as after a send whose outcome is unknown. Reported as a failure with the inputs released, the funding would be built again, and where the rebuild takes other inputs a restart would send the first lock beside the second. The inputs stay held until the wallet restarts: a restart that finds the row resumes it, one that does not finds the inputs free. That is fund safety chosen over availability, and it changes one case from before this PR: a backend that fails the row and then fails its removal too used to get the inputs back.should_abort_typed_amount_funding_when_the_recipient_cannot_be_made_durablenow fails the row's store or flush once and lets the removal through, which still hands the inputs back.rs-platform-wallet-ffi/src/asset_lock/built_callback.rs, comment only: theAssetLockBuiltFncontract said every failure but a rejection leaves the lock tracked and resumable in the session. A shielded funding abandoned before its broadcast is not tracked, and the comment now says so for both of its outcomes.swift-sdkAssetLockBuiltCallback.swift, comment only: theAssetLockBuiltHandlercontract mirrors that one, and the Swift host stores shielded recipients, so it now says the same. The Kotlin SDK needs no change: it passes this callback only for platform-address funding, which has no shielded recipient, and its host does not declare the shielded recipient capability.network/invitation.rs: the funded voucher's record moves intorecord_funded_invitation, which usesWalletPersister::store_durably. When the answer is that another flush dropped the record, still holds it or put it back, the record is stored once more (the row is keyed by outpoint, so a second copy changes nothing, and the flush that follows writes what was put back). If that fails too, the error is the one a failed flush always gave, and no link is returned.wallet/persister.rs: when the flush thatstore_durablyorwithdraw_durablymakes fails, that failure is the answer only when no other flush could have taken the record. Before, it was returned at once. A flush that failed transiently over nothing, while another flush held the record, then read as "kept buffered", though the other flush could still drop it, and the funded voucher's record was not stored again. Now the flush counts are read first: with another flush in progress, one returned since before the store, or a drop the backend reports, the answer is the one a flush that succeeded would get there (OtherFlushUnsettledorLost), andrecord_funded_invitationstores the record once more on either. A flush of the call's own that failed for good still reads as a failure for good (Lost). One that failed transiently while another flush dropped the buffer now reads as a loss too, where it read as transient. No other site tells these answers apart: each refuses on any of them.On a backend that commits a store inline,
store_durablyreturns after the store, so these five sites no longer callflushthere. The Swift host registers no flush callback and the Kotlin host's is a no-op.How Has This Been Tested?
Twenty-eight new tests, most of them over a backend that buffers and whose next flush is overtaken by another one. Each was run with its fix reverted and fails there.
The other flush fails for good and drops the record:
should_send_nothing_when_another_flush_dropped_a_prepared_reservationshould_send_nothing_when_another_flush_dropped_a_send_s_reservationshould_not_hand_out_a_payment_address_whose_reservation_another_flush_droppedshould_abort_an_invitation_whose_funding_index_another_flush_droppedshould_not_send_a_shielded_funding_whose_recipient_row_another_flush_droppedshould_record_a_funded_invitation_again_when_another_flush_dropped_its_recordshould_report_a_funded_invitation_unrecorded_when_another_flush_dropped_it_twiceThe other flush fails transiently and puts the record back:
should_send_nothing_when_another_flush_took_a_prepared_reservation_and_put_it_backshould_record_a_funded_invitation_another_flush_took_and_put_backshould_leave_no_row_on_disk_for_a_shielded_funding_abandoned_after_its_row_was_writtenThe removal of an abandoned row cannot be confirmed either:
should_keep_the_inputs_of_an_abandoned_shielded_funding_whose_removal_is_not_durableshould_keep_the_inputs_of_an_abandoned_shielded_funding_whose_removal_was_refused(the row's own flush fails transiently, the backend refuses the removal, and a later flush writes the row alone)should_keep_the_inputs_of_an_abandoned_shielded_funding_whose_refused_store_wrote_its_row(a host that does not roll a failed round back: the store is refused with the row on disk, and so is the removal)should_keep_the_inputs_of_an_abandoned_shielded_funding_whose_row_another_flush_wrote(another flush writes the row, the row's own flush then fails, and so does the removal's)should_report_a_typed_amount_funding_as_unconfirmed_when_its_row_removal_fails_too(throughshielded_fund_from_asset_lock, for a store and for a flush that keep failing)should_keep_the_inputs_of_an_abandoned_shielded_funding_whose_row_a_flush_in_progress_took(a flush on another thread takes the row and stalls; let go, it writes the row behind the removal)should_not_answer_for_a_withdrawal_stored_while_another_flush_has_not_returned(wallet/persister.rs:withdraw_durablyrefuses and flushes nothing;store_durablyflushes and refuses too)should_not_answer_for_a_store_when_a_flush_returned_while_it_was_made_durable(wallet/persister.rs: a flush that took the older state writes it after the call's own flush wrote the newer, and returns first; the older state is on disk and the store is refused)should_not_answer_for_the_wallets_records_when_a_flush_returned_during_the_call(wallet/persister.rs: the same flush, againstflush_durably)should_not_answer_for_a_store_the_backend_dropped_in_a_drain_of_its_own(wallet/persister.rs: a commit the host makes on the backend drops what was stored; no flush the wallet made failed, and only the backend's count refuses the store)should_count_a_changeset_dropped_by_a_commit_the_wallet_did_not_make(rs-platform-wallet-storage:commit_writesandflushthat fail for good are counted, one that is kept for a retry or written is not)should_count_a_deletion_that_wrote_the_buffered_changeset_first(rs-platform-wallet-storage: a wallet's deletion counts as a drop though its pre-flush wrote the buffered changeset)should_forget_a_stored_marker_once_the_backend_reports_a_drop(wallet/persister.rs: the note that a private payment marker was stored is not made, or is forgotten at the next read, once the backend reports a drop)should_record_a_funded_invitation_again_when_its_flush_failed_while_another_held_it(a flush on another thread takes the record and stalls; the record's own flush fails transiently; let go, the other flush fails for good; the record stored once more is written by the next flush)should_not_answer_with_its_own_flush_failure_while_another_flush_has_not_returned(wallet/persister.rs: with another flush inside the backend, a flush of the call's own that fails transiently answersOtherFlushUnsettledand one that fails for goodLost; alone, each answers with its own failure as before)should_not_answer_with_its_own_flush_failure_when_another_flush_returned_during_it(wallet/persister.rs: the same for another flush that returned during the call's own, whether it succeeded or failed for good)should_not_answer_for_a_withdrawal_when_a_flush_returned_while_it_was_stored(wallet/persister.rs: a flush that took the record writes it after another flush wrote the withdrawal, and both return before the ledger is read; the record is on disk and the withdrawal is refused)should_count_a_flush_as_returned_once_it_has_whatever_its_outcome(changeset/flush_ledger.rs)Run locally:
cargo test -p platform-wallet --libfor the touched modules (wallet::identity::network::payments,prepared_payment,invitation,contact_requests,private_contact_requests,wallet::asset_lock,wallet::persister,manager), and the same pluswallet::shieldedwith--features shieldedcargo fmt --all -- --checkcargo clippy --package platform-wallet --package platform-wallet-ffi --all-targets --all-features --locked -- --no-deps -D warningscargo check --package platform-wallet --all-targets --locked(noshieldedfeature)The full workspace suite was not run, and nothing was run against a live network.
Breaking Changes
None. No consensus change.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
80004d2/self-reviewedrs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/src/asset_lock/built_callback.rs) — HashEngineering or ZocoLini or llbartekll or romchornyiwallet-storage(packages/rs-platform-wallet-storage/README.md,packages/rs-platform-wallet-storage/src/sqlite/buffer.rs,packages/rs-platform-wallet-storage/src/sqlite/persister.rsand 2 more) — lklimekrs-platform-wallet(packages/rs-platform-wallet/src/changeset/flush_ledger.rs,packages/rs-platform-wallet/src/changeset/traits.rs,packages/rs-platform-wallet/src/error.rsand 7 more) — HashEngineering or ZocoLini or llbartekll or romchornyiswift-sdk(packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/AssetLockBuiltCallback.swift) — llbartekll or romchornyiWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit
Bug Fixes
Documentation