Repository navigation
fix(platform-wallet): a failed local key write no longer fails an accepted identity registration - #6143
Conversation
…epted identity registration After Platform accepts a new identity, four flows recorded it locally with their own copy of the same block. The asset-lock flow's copy returned `Err` when a key breadcrumb could not be stored, so an identity that exists on chain was reported as failed and its spent asset lock was never consumed. The other three copies only logged. `IdentityManager::record_new_identity` now owns that step: it adds the identity and stores it with its keys as one changeset, logs every failure under the calling flow's name and returns nothing. Asset-lock registration, invitation claim, address-funded registration and shielded identity creation all call it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 4554448) |
…et-record-new-identity Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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.
Final validation — Phase 2 only (queue backlog)
Changes requested: 1 blocker
- One rejected local write can hide an accepted second identity after restart —
packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:147-155(new)
Impact: A user who registers another identity with an asset lock or claims an invitation can see success, then reopen the wallet and find that identity and its credits missing from the local view even though storage has recovered.
The PR gives four identity-registration flows a shared wallet recorder, batches the identity and its keys into one changeset, and lets asset-lock cleanup proceed after Platform accepts the registration even if the local write fails. Rust wallet tests and Swift SDK build and tests passed; Kotlin stopped before compilation on a stale parity summary inherited from v5.2-dev, and PastaClaw review and PR Hygiene were pending.
🔴 1 blocking | 🟡 2 suggestion(s) | 💬 1 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The change consolidates local identity and key persistence across four flows and changes how writes are batched, but leaves key derivation, signing, funds movement, and consensus rules unchanged. - Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
- Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); 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/state/manager/lifecycle.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:147-155: One rejected local write can hide an accepted second identity after restart
Impact: A user who registers another identity with an asset lock or claims an invitation can see success, then reopen the wallet and find that identity and its credits missing from the local view even though storage has recovered.
The identity remains on Platform, but a single failed save can leave no local identity or key records to reload. An inline host such as SwiftData can roll back the whole round, and `record_new_identity` only logs the error. On the base branch, `add_identity` logged a failed first store and continued to the per-key stores, each of which also wrote the identity snapshot; if only the first store failed, those later stores saved the identity and its derivation metadata. With this change, default discovery starts above the new in-memory slot, and after restart `manager/startup.rs:545–547` skips discovery when an older identity is on file and no incomplete scan was recorded. Keep the atomic batch, successful registration result, and lock cleanup. Retry the local write when the backend guarantees it retained nothing, or make wallet recovery explicitly revisit the affected slot without resubmitting the transition. Add a fail-once test that reloads a wallet with an older saved identity and checks that the new identity and its key derivation records are present.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:119-129: Address-funded and shielded registration omit recovery metadata for wallet-derived keys
Impact: Swift and Kotlin users who register with wallet-derived keys through either flow can sign with a pre-stored private key, but cannot use the normal seed-based signing or repair path if that copy becomes unavailable.
The wallet still has the seed, but the saved rows do not tell it where to derive the keys. Both example apps prepare the registration keys before choosing how to fund the identity. The shared recorder now makes the existing distinction explicit: asset-lock and invitation callers mark every key as derived, while address-funded and shielded callers pass `Unrecorded`. Swift's on-demand signer requires the derivation path, and Kotlin's repair path rejects rows without both derivation indices and omits them from its restart repair scan. The recorder belongs in the wallet layer, but funding source is not proof of key origin: the APIs also accept caller-supplied keys. Pass verified per-key provenance from Rust key preparation or binding verification, and leave external or unverified keys unmarked.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:462-487: The failure test still passes if registration leaves a spent asset lock resumable
Impact: A regression that skips lock cleanup after a rejected identity write could pass this test and leave users with a resume action for funding they already spent.
The test checks that `record_new_identity` keeps the identity in memory, but never exercises the caller's success return or its call to `consume_asset_lock`. Those were the two observable failures this PR set out to fix. Exercise the production post-acceptance path offline with an already-confirmed identity, a tracked lock, and a persister that rejects the identity changeset but accepts the lock update. Assert that the caller returns the identity and that the lock is marked `Consumed` both in memory and in the emitted changeset.
- [NITPICK] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:98-100: The recorder describes an occupied slot as an insertion failure that it does not detect
Impact: Maintainers reading this contract can incorrectly assume that recording a different identity at an occupied slot leaves the existing identity untouched.
The new comment lists an already-held slot as a logged failure. `add_identity_unstored` rejects a duplicate identity ID, but it does not check whether a different identity occupies the index before inserting. Describe the errors the helper actually handles; the slot-placement policy is tracked separately.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Two accepted identities at the same wallet slot can alias — The unchanged
add_identity_unstoredreplaces the identity at an occupied index and leaves the old ID's reverse-index entry pointing at that index, so lookup by the old ID can return the replacement. The base used the same insertion for all four flows.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…refusal The identity and its keys now go out as one changeset, so a single refused store left nothing of the identity on disk, where the earlier per-key writes each carried the identity snapshot again. A refusal the backend classifies as transient and attests it kept nothing of (store_transient_is_reissuable) is issued once more. The doc comment no longer claims an occupied slot is detected or that the next re-sync restores a missed identity: a launch with another identity on file runs no discovery scan. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…et-record-new-identity Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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
Changes requested: 1 blocker
- One rejected local write can hide an accepted second identity after restart —
packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:155-169(thread, carried)
Impact: A Swift SDK user registering a second identity with an asset lock can get a success result after one temporary save failure, then reopen the wallet and find the new identity and its credits missing from the local view.
New on this head: This revision adds one retry for an identity-and-keys changeset when the storage backend reports a transient refusal and confirms it retained nothing. It adds tests for both retry decisions and clarifies the recorder’s documentation. The Linux wallet tests, Kotlin SDK build and tests, and Swift SDK build and tests all passed.
🔴 1 blocking | 🟡 2 suggestion(s)
Still open from earlier rounds (2)
- 🔴 Blocking: One rejected local write can hide an accepted second identity after restart —
packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:155-169(thread) - 🟡 Suggestion: The failure test still passes if registration leaves a spent asset lock resumable —
packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:511-531(thread)
⏸️ Awaiting tracking link (1): Address-funded and shielded registration omit recovery metadata for wallet-derived keys (thread). Link an issue on its thread, or ask there and PastaClaw files it.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The change coordinates four registration paths and adds a conditional retry inIdentityManager::record_new_identity, but it changes only post-acceptance wallet bookkeeping, not key derivation, signing, funds movement, or the persisted schema. - 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(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); 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/state/manager/lifecycle.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:155-169: One rejected local write can hide an accepted second identity after restart
(carried; thread: https://github.com/dashpay/platform/pull/6143#discussion_r4670990007)
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:511-531: The failure test still passes if registration leaves a spent asset lock resumable
(carried; thread: https://github.com/dashpay/platform/pull/6143#discussion_r4670990031)
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:119-129: Address-funded and shielded registration omit recovery metadata for wallet-derived keys
(awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed; thread: https://github.com/dashpay/platform/pull/6143#discussion_r4670990018)
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
…ck when the identity cannot be stored Steps 4 and 5 of register_identity_with_funding move, unchanged, into finish_accepted_registration, so the post-acceptance path can run offline. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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; 1 blocking finding(s) still stand.
- ✅ Withdrawn: 🟡 The cleanup test passes even if registration never attempts to save the identity
Changes requested: 1 blocker
- One rejected local write can hide an accepted second identity after restart —
packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:155-168(thread, carried)
Impact: A Swift SDK user who registers a second identity with an asset lock can see success, then reopen the wallet after a one-off SwiftData save failure and find the new identity and its credits missing from the local view.
New on this head: This head extracts the post-acceptance bookkeeping into a shared helper and adds an offline test that checks whether a spent asset lock is marked consumed both in memory and in the changeset sent to storage after an identity write is refused. The Rust wallet tests and the Swift and Kotlin SDK build-and-test checks passed; PastaClaw review and PR Hygiene remain pending.
🔴 1 blocking | 🟡 1 0 suggestion(s)
Still open from earlier rounds (1)
- 🔴 Blocking: One rejected local write can hide an accepted second identity after restart —
packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:155-168(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The diff consolidates post-acceptance persistence across four wallet flows and changes write batching and failure handling, but it does not change key derivation, signing, funds movement, consensus, or the storage schema. - 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(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); 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/registration.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:602-627: The cleanup test passes even if registration never attempts to save the identity
Impact: A future change that keeps accepted identities only in memory could pass this test while leaving users unable to reload those identities after restart.
The new test catches skipped lock cleanup, but it does not establish that the identity store was attempted and refused. `IdentityRefusingStore` records only accepted changesets, so replacing the recorder call with an in-memory insert would still satisfy every assertion. The fixture also has no public keys, while funded registration requires a master authentication key at ID 0. Give the fixture that key and capture refused changesets separately; assert that the rejected batch contains the new identity and its key before checking the accepted lock update.
In `packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:155-168: One rejected local write can hide an accepted second identity after restart
(carried; thread: https://github.com/dashpay/platform/pull/6143#discussion_r4670990007)
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
The blocking finding was fixed in dd987a1 (one re-issue after a transient refusal). The one remaining suggestion is declined, with the reasoning on its thread.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
record_new_identity stored the identity and its keys as one changeset and re-issued it once after a transient refusal. A host that reports every failed save as fatal (SwiftData) got no second attempt, so one failed save left the new identity in memory only, where the separate writes it replaced would have stored it. It now stores the identity first and then each key with its breadcrumb, each key store carrying the identity snapshot, which is the sequence the asset-lock and invitation flows ran before they shared this method. The re-issue and its tests are removed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
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.
- ✅ Withdrawn: 🟡 A failed initial save is logged without identifying the accepted registration
New on this head: This revision restores the initial identity save followed by one save per key for asset-lock registrations and invitation claims. Each key save carries the identity snapshot, so a failed initial save no longer depends on the host classifying the error as retryable. Kotlin SDK tests and the Swift SDK frozen schema check passed; Rust workspace tests and PR Hygiene were pending, with no failed code checks reported.
🟡 2 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The refactor spans four registration flows and changes how local persistence failures are handled after acceptance, but it does not change key derivation, signing, or on-chain asset-lock spending. - 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(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); 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/state/manager/lifecycle.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:124-137: A failed initial save is logged without identifying the accepted registration
Impact: When the only local save for an address-funded or shielded registration fails, maintainers cannot tell from the wallet's persistence error which flow and identity to investigate.
An accepted identity can be missing after restart, but the wallet's error does not identify it. This revision delegates the initial write to `add_identity`, which logs `Failed to persist changeset` and returns `Ok(())`, so the contextual warning in `record_new_identity` never sees the store error. The `Unrecorded` path then returns without a per-key write. Attach `flow`, `identity_id`, and `identity_index` to the initial store's diagnostic in the wallet layer without changing its best-effort behavior.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:537-565: The tests pass if one failed key save stops all later key saves
Impact: If a rejected key save ever stops the loop, users can reopen an accepted identity with later keys missing derivation metadata even though the store recovered, and the current tests would not catch it.
The restored loop is meant to keep saving later keys after a failed key write, but none of the tests distinguishes that behavior from exiting on the first `add_key` error. The fail-once test rejects the initial identity save, before the loop, and the all-failing test only checks the in-memory identity, which already contains both keys. Add a two-key case that accepts the initial save, rejects the first key save, and checks that the second key's derivation metadata reaches the store.
|
Bots are done — your move: post |
|
/self-reviewed |
romchornyi
left a comment
There was a problem hiding this comment.
✅ no blockers · no majors · 6 non-blocking recommendations · 1 untracked follow-up — reviewed at 573520e6b8
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | The .map_err(...)? under the "must not propagate" comment turned an accepted registration into Err and skipped consume_asset_lock; one owner for the four drifted copies addresses the cause, not the line. |
| 2 · Architecture | ✅ right layer | The decision lives in rs-platform-wallet; FFI / Swift / Kotlin keep marshalling and are unchanged. |
| 3 · Completeness | 🟡 untracked gap | All four production writers of a newly accepted identity go through record_new_identity; every other add_identity caller is test code. The deferred breadcrumb follow-up has no issue yet (below). |
| 4 · Code | ✅ clean | Changeset sequence and content per flow match the base exactly (the dropped wallet_id stamp is already set by add_identity_unstored); Step 5 now always runs. |
Untracked follow-up
- The deferred thread on derivation breadcrumbs for address-funded and shielded creation ("store derivation indices for wallet-derived keys … from per-key provenance verified in Rust") is marked Deferred, but no issue is linked in the PR and I couldn't find one in the repo (#5525 covers a different case). Could you file it and link it here?
6 non-blocking recommendations
- Pre-existing: an occupied HD slot is overwritten silently — —
add_identity_unstoredrejects only a duplicate id; a different identity B recorded at an occupiedidentity_indexreplaces A in the bucket while the location index still maps A to that slot (identity(&A)then returns B). The shielded call site says this case is caught ("e.g. the slot is already occupied locally", ), which it is not. Now that all four flows share one entry point, a slot check there (or a corrected comment) covers them all. - Pre-existing:
Unrecordedflows store the identity exactly once —, — therecord_new_identitydoc says the identity reaches the store "when any one of these stores succeeds", but for address-funded and shielded creation there is only one store. One failed save on a host that reports it as fatal (SwiftData) loses that identity after restart when another identity is on file, the same failure mode the earlier blocker was about, for the other two flows. Worth a line in the doc or a note on the follow-up issue. - Stale "self-heals on the next re-sync" comments — , ,, , , — they contradict the new
record_new_identitydoc (no scan runs when another identity is on file). - Warn text on a failed add — — the only error
add_identityreturns here isIdentityAlreadyExists, i.e. the id is already held (possibly out-of-wallet), so "an identity discovery scan adds it" is misleading in a support log. - No test that the key loop continues after a failed
add_key—— this is the behaviour that is new for asset-lock registration (it used?), and the post-acceptance test uses an identity with no keys, so it never reaches the loop. A two-key case with the first key store failing would pin it. - All breadcrumb stores failing is silent — — returning
Okis right, but the host gets no signal that the identity will come back watch-only after restart. Out of scope here; maybe worth noting on the follow-up. (not verified)
Review details
Layered review: idea → architecture → completeness → code. Level 4 ran a general correctness lane and a persistence lane that diffed the changesets each of the four flows emits at base vs head. Findings 1–5 were checked against the code at the reviewed head.
🤖 Reviewed with Claude Code
Comments at the four registration flows said a missed local add heals on the next re-sync; only an identity discovery scan finds it, as the record_new_identity doc says. The warning for a refused add no longer promises a scan for an id the manager already holds, the shielded flow's comment no longer claims an occupied slot is detected, and the doc notes that Unrecorded flows have a single store. Adds a test that a failed key store does not stop the later keys. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Thanks for the review. The follow-up is tracked in #6281, and 4554448 takes the cheap ones:
Left for #6281 on purpose: the slot check itself (1) and a signal to the host when every breadcrumb store fails (6, recorded there as not verified). |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
romchornyi
left a comment
There was a problem hiding this comment.
✅ no blockers · no majors · all earlier recommendations closed or tracked — re-reviewed at 4554448038
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | Unchanged since the last review. |
| 2 · Architecture | ✅ right layer | Unchanged. |
| 3 · Completeness | ✅ gaps tracked | The deferred breadcrumb follow-up is tracked in #6281, together with the occupied-slot, single-store and host-signal notes. |
| 4 · Code | ✅ clean | The new commit changes only comments and adds one test; nothing new found. |
Closed since the last review
- Untracked follow-up: filed as #6281, with recommendations 1, 2 and 6 recorded there.
- 2: the
record_new_identitydoc saysUnrecordedflows have a single store — - 3: the "heals on the next re-sync" comments now say a routine sync does not restore a missed identity.
- 4: the refused-add warning no longer promises a discovery scan — ; the shielded call site no longer claims an occupied slot is detected.
- 5:
should_store_the_breadcrumbs_of_later_keys_after_one_key_store_fails—— fails the first key's store (keys come from aBTreeMap, so key 0 goes first) and expects two stores, the second carrying key 1's breadcrumb. A loop that stopped at the first failure would leave one store and fail the test.
Recommendations 1 (slot check) and 6 (host signal) stay with #6281, as the author said.
Review details
Re-review of the diff `573520e6b8..4554448` (comments plus one test) and the author's replies. The test's persister counters and key order were checked against the code at the head; levels 1–4 were not re-run in full because no logic changed.🤖 Reviewed with Claude Code
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This revision updates identity recovery guidance and adds a regression test that verifies a rejected key write does not stop later key writes. Rust workspace tests, Kotlin SDK build and tests, and the Swift frozen-schema check passed; the Swift SDK build and tests and PR Hygiene were pending.
🟡 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The diff centralizes post-acceptance persistence across four wallet flows and changes how local write failures affect asset-lock cleanup, but does not change funding, key derivation, signing, or consensus rules. - 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(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); 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/platform_wallet.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:2420-2423: Discovery can miss an accepted shielded identity that was not saved locally
Impact: A caller whose shielded registration succeeds but is not saved locally can run the documented discovery scan and still not see the identity in their wallet.
The revised API docs promise that discovery finds the missing identity, but the scan can return without it. `shielded_identity_create_from_pool` forwards the caller's keys and signer without requiring a match to the wallet's derivation. `IdentityWallet::discover_inner` probes only the wallet-derived authentication key hash at key index 0 for each slot it visits (`discovery.rs:391–418`), and the default scan starts above the highest locally held slot (`discovery.rs:358–366`). State both conditions in the API docs and the shared recorder docs that the revised comments point to: the scan must reach the slot, and Platform must have indexed the hash it probes for that identity. The duplicate-ID warning no longer promises recovery, but the separate wallet-not-found warning at lines 2487–2489 still does; remove that guarantee there too.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
v5.2-dev gained #6143 (a failed local key write no longer fails an accepted identity registration). Two files conflicted: an import list in invitation.rs (both imports kept) and the doc comment of shielded_identity_create_from_pool, which keeps #6143's wording on finding the identity again and v5.1-dev's paragraph on admission. Co-Authored-By: Claude Fable 5.2 <[email protected]>
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 <[email protected]>
Issue being fixed or feature implemented
After Platform accepts a new identity, four flows in
platform-walletrecord it locally, each with its own copy of the same block: asset-lock registration (register_identity_with_funding), invitation claim (claim_invitation), address-funded registration (register_from_addresses) and shielded identity creation (shielded_identity_create_from_pool). The step is meant to be best-effort, because the identity already exists on chain.The copies had drifted. In
register_identity_with_fundingthe per-key breadcrumb write ended in.map_err(...)?, directly under a comment saying a local failure must not propagate. A persister failure on that write therefore:Errto the caller for an identity that is on chain, andconsume_asset_lock), leaving the spent lock in the resumable list, where a resume gets Platform's "lock already consumed" rejection.claim_invitationonly logged a warning for the same failure.What was done?
IdentityManager::record_new_identitynext toadd_identity. It adds and stores the identity at its HD slot throughadd_identity, then stores each key that has a breadcrumb throughManagedIdentity::add_key, logs every failure with the calling flow's name, and returns nothing, so a flow cannot propagate a local failure by accident.NewIdentityKeyOriginsays which breadcrumb the keys get. Asset-lock registration and invitation claim passDerivedAtKeyIdand store(wallet_id, identity_index, key_id)as before. Address-funded and shielded creation passUnrecordedand store keys without a breadcrumb, exactly as they did throughadd_identity.The writes are the ones the asset-lock and invitation flows made before: the identity with breadcrumb-less keys, then one changeset per key, each carrying the identity snapshot again. So one failed store is still covered by the ones after it, on every host. An earlier revision of this PR wrote a single changeset instead; that was reverted, because a host that reports a failed save as fatal (SwiftData) would then lose the identity to one failed save.
Behaviour changes besides the fix:
register_identity_with_fundinga failed key write no longer stops the remaining key writes; each is attempted and a failure is logged, asclaim_invitationalready did.managed.wallet_id = Some(wallet_id)in the two copies is gone;add_identity_unstoredalready sets it.register_identity_with_fundingmoved unchanged intofinish_accepted_registration, so they can be run without the network.Not changed, and worth a decision by someone who knows the hosts: address-funded and shielded identity creation still store no key breadcrumbs. The FFI docs say the host derives those keys at
(identity_index, key_id)too, so this looks like an omission, but I could not confirm it without the SDK/host side, so this PR keeps the current behaviour. Tracked in #6281.How Has This Been Tested?
register_identity_with_fundingsubmits to Platform through the SDK before it reaches this step, so the whole flow cannot be unit-tested without the network. The tests cover the shared method and the part of the flow that follows acceptance.In
wallet::identity::state::manager::lifecycle::tests:should_keep_an_accepted_identity_in_memory_when_its_keys_cannot_be_stored: with a persister whose every store fails, the method returns nothing and the identity is held in memory at its slot.should_store_a_new_identity_and_a_breadcrumb_for_each_of_its_keysshould_store_a_new_identity_and_its_key_breadcrumbs_when_only_the_first_store_fails: failed against the single-changeset revision of this PR, passes now.should_store_the_breadcrumbs_of_later_keys_after_one_key_store_fails: the initial store succeeds, the first key store fails, and the second key's breadcrumb still reaches the store.should_store_no_breadcrumb_for_keys_of_unrecorded_originshould_leave_an_identity_already_held_untouchedIn
wallet::identity::network::registration::tests:should_consume_the_asset_lock_when_the_accepted_identity_cannot_be_stored: runsfinish_accepted_registrationwith a store that refuses identity rows, and checks the lock isConsumedin memory and in the changeset that reaches the store.The shared method is new, so its tests could not be run against the base branch; the old defect is visible in the removed
?inregistration.rs.Ran locally:
cargo test -p platform-wallet --all-features(2215 lib tests plus integration tests pass)cargo clippy -p platform-wallet --all-features --all-targets -- -D warningscargo check -p platform-wallet --all-targets(default features, withoutshielded)cargo fmt -p platform-wallet -- --checkBreaking Changes
None.
register_identity_with_fundingno longer returnsPlatformWalletError::Persistencefor a failed local key write after Platform accepted the registration; it returns the registered identity.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 ·
4554448When every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.