Skip to content

feat(tokens): create and claim once-per-identity token distributions - #1119

Merged
lklimek merged 33 commits into
v1.0-devfrom
feat/token-once-per-identity
Oct 27, 2026
Merged

lklimek merged 33 commits into
v1.0-devfrom
feat/token-once-per-identity

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: The token creator can add a once-per-identity distribution, a fixed amount every identity may claim exactly once, on networks that support it. The Claim screen claims exactly the distribution the user confirmed, and it notes, without blocking, when an identity may have already claimed.

Stacked atop #1114.

User story

As a token creator, I want every identity to be able to claim a fixed amount of my token exactly once, so that I can run a fair airdrop without a list of recipients (TOK-019).

Scenario

Base flow

  1. Connect to a protocol 14 network. In Tokens → Token Creator, enable "Once-per-identity Distribution", enter an amount and create the token.
  2. With another identity, open the token's Claim screen, choose "Once per identity" and confirm.
  3. Open the Claim screen for the same identity and token again.

Actual

The creator had no once-per-identity option, and the Claim screen could not claim one. The confirmation only asked whether to "claim tokens for this contract". It read the distribution when Confirm was pressed, so a distribution changed while the dialog was open was claimed instead of the one shown.

Expected

  • The creator offers the option only where the network supports it, validates the amount under the field, and includes the extra registration fee in the estimate.
  • My Tokens and the Claim screen show the distribution. A token whose only distribution is once-per-identity has it pre-selected.
  • The confirmation names the distribution and the amount, for example: "You are about to claim this identity's one-time share of 25 base Gold tokens from the once-per-identity distribution. Each identity can claim it only once." Confirming sends exactly that claim.
  • After a successful claim, the Claim screen notes that this identity may have already claimed, and on which date. The note never blocks claiming, and it can be dismissed.
  • A second claim refused by the network says the identity already claimed its share, and Claim stays turned off on that screen, so a retry is not charged again. The refusal is not saved.

Detailed discussion

  • Capability: Capability::OncePerIdentityDistribution / FeatureGate::TokenOncePerIdentityDistribution (src/context/feature_gate.rs), open from protocol 14 (PROTOCOL_VERSION_14). Upstream names no feature constant for it. Claiming needs no gate, because such a token can only exist on such a network.
  • Model (src/model/token.rs):
    • parse_once_per_identity_amount bounds the amount like a token balance (1..=i64::MAX), with a typed OncePerIdentityAmountError.
    • once_per_identity_amount reads the distribution from a configuration.
    • distribution_rules_with_once_per_identity keeps version 0 rules unless the distribution is set, so tokens without it keep the format older networks accept.
  • Creation:
    • ensure_distribution_rules_supported (src/backend_task/tokens/mod.rs) refuses version 1 rules with TaskError::TokenOncePerIdentityNotSupported before signing.
    • The creator refuses locally as well.
    • The registration estimate lives in model::fee_estimation::estimate_token_contract_registration. The creator passes it the fee table of the SDK's current version (platform_version()), so every term, including token_uses_once_per_identity_distribution_fee, comes from one table.
    • The local refusal and the disabled-checkbox hint use TaskError::TokenOncePerIdentityNotSupported's text, so all three read the same.
  • Claim (src/ui/tokens/claim_tokens_screen.rs):
    • The claim is built when the confirmation opens and stored with it (PendingClaim), so confirming sends that exact claim. The confirmation text names the distribution.
    • A TokenOncePerIdentityAlreadyClaimed refusal for the screen's identity and token turns Claim off for the once-per-identity distribution while the screen is open, with a note. It is never written to the hint, because a node's refusal is unproven.
  • Claim hint (src/context/contract_token_db.rs, src/backend_task/tokens/claim_tokens.rs):
    • The hint is stored under the identity's scope as det:token_once_claimed:v1:<token_id>.
    • It is recorded only after a successful, proof-backed claim, at the proved claim document's block time (the local clock when the document carries none).
    • It is advisory. Platform has no proved "has claimed" query, and a node's unproven "already claimed" refusal is never recorded, so a hostile node cannot mark an entitlement as spent.
    • If the claim succeeds but the hint cannot be saved, the result is TaskError::TokensClaimedButClaimNotRecorded. The user learns the claim was made and is told not to claim again.
    • Dismissing the hint goes through TokenTask::ClearOncePerIdentityClaimHint / BackendTaskSuccessResult::OncePerIdentityClaimHintCleared, never a database write from the UI.
  • Errors (src/backend_task/error.rs): TokenOncePerIdentityAlreadyClaimed (token, identity and claim time, from Platform's refusal) and InvalidOncePerIdentityDistributionAmount. Both keep the SDK error as their source.
  • Docs: user story TOK-019.

Testing

  • New unit tests:
    • model::token: amount bounds; rules stay V0 without the distribution and become V1 with it.
    • model::fee_estimation::tests::token_contract_registration_adds_each_feature_fee_from_the_given_table
    • backend_task::tokens::tests::once_per_identity_rules_need_a_network_that_accepts_them
    • backend_task::tokens::claim_tokens::tests: recorded at the proved block time; an unrecordable claim says so; a failed claim or an "already claimed" refusal records nothing.
    • context::contract_token_db: the hint is per identity and token; stored configurations with either rules version round-trip.
    • ui::tokens::claim_tokens_screen::tests: the confirmation names the distribution and amount; confirming claims the distribution the confirmation named; dismissal goes through a backend task; a refused second claim turns Claim off without saving anything.
    • ui::tokens::tokens_screen::tests::once_per_identity_distribution_builds_version_1_rules_only_on_protocol_14
    • backend_task::error: once_per_identity_already_claimed_maps_to_its_variant and the amount case in protocol_v14_consensus_errors_map_to_their_variants.
    • context::feature_gate: the gate is closed at boot and on 13, open on 14, and closed on an unknown future version.
  • Library tests for the touched modules pass (218, every test above included). UI tests (kittest): 502 passed. CI runs the full suite.
  • cargo clippy --all-features --all-targets -- -D warnings and cargo fmt --all pass.
  • No token was created or claimed on a live network.

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q

PR Hygiene · b92dcd0

  • Bots — coderabbitai skipped after its own rate limit · thepastaclaw ✓
  • Self-review — not asked of a bot author
  • Build green
  • Approvals
    • files with no dedicated owner (docs/user-stories.md, src/backend_task/error.rs, src/backend_task/mod.rs and 12 more) — approved by lklimek

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

lklimek and others added 8 commits October 24, 2026 18:21
Pin dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and
platform-wallet-storage to dashpay/platform v5.1-dev 063589bf
(5.0.0-rc.8). The lockfile moves only the Platform packages.

The upstream V019 wallet-storage migration adds a nullable asset-lock
operation id; V001-V018 are unchanged. The compatibility bridge gets the
033ecae destination snapshot it compares against, and the pin guard
records the new revision with an unchanged migration fingerprint.

BREAKING CHANGE: the wallet storage upgrade to V019 is forward only. An
older build cannot open upgraded storage; going back needs a copy of the
data directory taken before the upgrade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new rust-dashcore wraps secp256k1 keys in EcdsaSecretKey and
EcdsaPublicKey, returns secret bytes as Zeroizing, and drops the
Secp256k1 context argument. Signers, single-key wallets, DashPay
derivation, address and QR handling, migrations and their tests follow
the new types. Signing stays on the non-grinding dpp::secp256k1 path,
and a parity test pins the BLS signature bytes the previous SDK made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Handle the dpp and SDK types the new pin adds, keeping today's behaviour:

- Document replace keeps moderated_at and moderated_by; new documents
  start without them.
- The document editor refuses typed-array fields instead of dropping
  their contents, and keeps referenced key ids as numbers.
- Shielded token events show read-only in group actions, and the
  shielded pool token settings are refused before anything is signed.
- Contested document creation states the protocol's base contest fund,
  so the SDK never auto-quotes a larger one.
- Masternode vote reads use ResourceVoteWithCount, the SDK's new vote
  type; the vote count is not used yet.
- New query fields, wallet events, wallet error variants and asset-lock
  funding modes are handled where the SDK now requires them.
- Entropy-only document ids are documented as placeholders from
  protocol 14, and deferred upstream features link to their issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK was pinned to the protocol 13 table, so it could not build any
protocol 14 transition or follow the versioned identity lookup. It now
starts at upstream's per-network minimum and ratchets to what proven
responses report.

- System contracts are cached per protocol version and served through
  accessors. The context provider serves them at the version the proof
  verifier asks for and fails rather than serve another version's.
- A proved epoch sets the fee multiplier and raises the protocol version.
  An older epoch than the adopted one is ignored.
- Rebuilding the connection resets the protocol version, fee multiplier
  and adopted epoch under one lock before the new SDK is published, and
  drops reads begun on the old connection.
- Capabilities read the network's version through a helper that stays
  closed for a version this build does not define.
- Contest timing reads the live version; retired vote schedules keep the
  protocol 13 notice window they were created under.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Compare the protocol 13 client tables with a recorded snapshot, so an
upstream change to them is reviewed, and check that keys and documents
DET builds on a protocol 13 network use encodings protocol 13 decodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals the new protocol adds to flows DET already offers to
dedicated TaskError variants: a full username contest, a vote choice the
contest does not allow, a name someone else asked for first, a token
that cannot be moved, a changed immutable document field, a reference to
a document type that cannot be deleted, and a moderators' fee on a
contract without moderation. Names supplied by the node stay in the
typed source only, never in the message.

Token operations that fail inside the wallet runtime keep their SDK
cause, so they are classified like any SDK error; an unclassified one
names the operation that did not complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Add a dated design note for the pin, the protocol version sources, the
connection state rules and the protocol 13 guards, and point AGENTS.md
at From<SdkError> for TaskError as the SDK error reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Protocol version 14 adds a once-per-identity distribution: every identity
may claim a fixed amount of a token exactly once.

- The token creator offers the distribution with the amount each identity
  can claim, gated on a new OncePerIdentityDistribution capability. Without
  it the rules stay version 0, the format older networks accept. The
  creator and the backend both refuse it on a network that does not accept
  it, before anything is signed. The registration estimate prices every
  term, including the distribution's extra fee, from the fee table of the
  network's confirmed protocol version.
- The Claim screen and My Tokens show the distribution. The claim
  confirmation names the distribution (and, for this one, the amount), and
  confirming sends exactly the claim that was shown.
- A successful claim records an advisory hint per identity and token, at
  the proved claim's block time. The Claim screen shows it without ever
  blocking a claim, and dismissing it is saved through a backend task. A
  node's unproven "already claimed" refusal is never recorded. A claim that
  succeeded but could not be recorded is reported as made, so the user is
  not invited to claim again.
- Platform's refusals (already claimed, invalid amount) map to dedicated,
  actionable errors.
- A protocol 13 guard checks the distribution is never silently dropped
  when encoded for protocol 13.
- User story TOK-019.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next included review available in 18 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between aca9bb4 and b92dcd0.

Files selected for processing: 15
  • docs/user-stories.md
  • src/backend_task/error.rs
  • src/backend_task/mod.rs
  • src/backend_task/tokens/claim_tokens.rs
  • src/backend_task/tokens/mod.rs
  • src/context/contract_token_db.rs
  • src/context/feature_gate.rs
  • src/model/fee_estimation.rs
  • src/model/token.rs
  • src/ui/tokens/claim_tokens_screen.rs
  • src/ui/tokens/tokens_screen/distributions.rs
  • src/ui/tokens/tokens_screen/mod.rs
  • src/ui/tokens/tokens_screen/my_tokens.rs
  • src/ui/tokens/tokens_screen/structs.rs
  • src/ui/tokens/tokens_screen/token_creator.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit b92dcd0) · triage: critical · Phase 2 only (no Phase 1 for this repository)

lklimek and others added 18 commits October 24, 2026 19:36
…it refusals

Protocol version 14 refusals that flows already in DET can hit get
dedicated, actionable messages, each keeping the SDK error as its source:

- an identity banned or suspended (until when) on a moderated contract;
- a gas sponsor short of credits, a gas payer the document type does not
  offer, and mixed gas payers in one batch;
- pre-programmed token distributions of one time over the limit.

An overflowing shielded note total is logged at warn: it means corrupt or
hostile sync data, not routine noise.

Tests cover contracts saved at protocol 12 loading unchanged at 13 and 14,
and contracts saved at 14 decoding at 13 and in full again at 14.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…efusals from the Platform bump

Merges 74695e7 from chore/bump-platform-063589bf.

The conflict in src/backend_task/error.rs keeps both sides: the
once-per-identity refusals and the moderation, gas sponsorship and
distribution limit refusals each keep their variants, match arms and test
cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A lookup at another version, as the proof verifier makes at a response's
version, swapped out the app's set, so each such lookup reloaded the
system contracts and the next app read reloaded them again. Each
version now keeps its own set; the app's reads keep the set they last
got for a failed reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…poch

When the epoch cannot be read, the proved DPNS fallback confirmed the
SDK's version, which starts at the network's upstream minimum (14 on
devnet), as the network's. It now confirms the version of the responses
the SDK verified, and nothing before any.

Restores the completed-withdrawal status list with the reason sending
FAILED to a protocol 13 network is safe, and its test, now comparing the
protocol 13 schema with the latest one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The derived key DET signs with is copied into secp256k1's own type,
which keeps its bytes after use. Wrap it so it is erased on drop, as the
derived key it comes from would be; signatures stay byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… protocol 13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new refusals sent users to another document editor or token client.
They now say the app cannot edit this field type, sign this action or
change this token setting yet, in one wording, and the shielded setting
refusal sits with the token contract errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Also corrects the platform compatibility fixtures README: no code reads
e3cd7cf.sql any more; it is the V001-V018 checksum reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
After the network refuses a second once-per-identity claim, the Claim
screen turns Claim off for that distribution while it is open and says
why, so a retry is not charged again. The refusal is unproven node
output, so it is never saved as the claim hint.

The token creator's registration estimate moves into
model::fee_estimation, the local refusal and the disabled-checkbox hint
reuse TaskError::TokenOncePerIdentityNotSupported's text, and the claim
reuses its token id instead of computing it twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…identity branch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…able one

Both refusals describe the same situation, a network below protocol 14,
so they now open the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The protocol version fallback takes only a version the SDK verified, and
a mock expectation's metadata is never recorded as verified, so the three
headless refresh tests saw the version stay unconfirmed. The mock now has
the SDK accept the version from metadata treated as proved, as after a
live network's signed response, and a new test pins that a response the
SDK never verified leaves the version unconfirmed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK picks each transition's encoding from the platform version DET
passes in, so these tests checked dpp's version tables rather than DET.
The mainnet start version and the contest fund cap stay covered by the
platform_info and fee_estimation tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK at this pin already tracks the version the network has proven:
it records the version of every response whose proof and quorum
signature it verified, and a rebuilt connection is a new SDK that starts
from nothing. DET's own copy, raised from proved epochs and DPNS reads
and reset on every rebuild, duplicated that state. The app now reads the
current SDK's verified version; capabilities still stay closed before a
version is proven and for one this build does not define, and network
info shows the proven number or says none is confirmed. Proved epochs
still set the fee multiplier, in epoch order and only on the current
connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A connection rebuild never changes the chain, the multiplier changes once
per epoch and feeds only fee estimates, so ordering epoch reads and
dropping those begun before a rebuild guarded against nothing worth the
machinery. A proved epoch read sets the multiplier directly again; an
unavailable epoch still keeps the last known value and labels it as
such. A rebuild still reads the epoch, so the new SDK proves the
network's version again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A released protocol's tables and each network's minimum version are
upstream's to keep fixed; DET's start is covered by
platform_version_starts_at_the_network_minimum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The proof verifier asks for contracts at the version it verifies with,
which can be newer than the SDK's. System contracts were already served
at that version; a saved user contract was decoded at the SDK's version
instead, dropping newer-protocol settings such as action fees. The
fallback now decodes it at the version asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
lklimek and others added 4 commits October 26, 2026 10:01
…king

Building the recoverable-signature envelope returns an error upstream;
it is now reported as the existing message-signing failure, with the
detail logged, instead of aborting the signing path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…identity

Keeps #1114's deletion of protocol_13_transitions.rs and drops this
branch's once-per-identity protocol 13 encoding test with it: that
encoding is upstream's to test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…m bump merge

#1114 removed DET's protocol version copy. The token registration fee
estimate reads the SDK's version, and the once-per-identity tests prove
versions through the SDK, which only raises them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Base automatically changed from chore/bump-platform-063589bf to v1.0-dev October 26, 2026 11:17
…entity

The squash commit's tree equals #1114's final head, which this branch
already contains, so the tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@lklimek
lklimek marked this pull request as ready for review October 26, 2026 20:03
@github-actions

Copy link
Copy Markdown
Contributor

@thepastaclaw review

No review for ea0485ec yet, so PR Hygiene is asking once. If nothing arrives, the requirement is dropped for this commit and the pull request is labelled bot-review-skipped.

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 26, 2026
…er-identity

Brings in non-transferable tokens (#1118), the token action layout (#1129),
Rust 1.99 and dependency updates (#1131) and Platform 575d961f with the
protocol_version_info API (#1132). Both protocol-14 token options are kept
side by side: the once-per-identity distribution and non-transferable
tokens each have their own capability, feature gate, backend refusal,
TaskError variant, creator control, test and user story (TOK-019, TOK-020).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot removed the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Oct 26, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (no Phase 1 for this repository)

The PR correctly implements the once-per-identity distribution flow, but three edge cases remain. The UI skips inline validation for an empty amount, the backend accepts malformed version 1 distribution rules until upstream validation, and identity-scoped claim hints are not removed during identity deletion or devnet wiping. CI checks reported for this head are successful.

🟡 3 suggestion(s)

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

🟡 Suggestion: Clear once-claim hints during identity and devnet cleanup
src/context/contract_token_db.rs:742-751

The new claim hint is stored under DetScope::Identity, but devnet cleanup removes only global token keys, global dismissal keys, and the global token order. Likewise, forget_identity_token_state removes an identity's global dismissal markers and token-order entries but does not remove its once-per-identity claim-hint keys. After a devnet reset or identity removal, re-importing the same identity can therefore display an advisory date from the old chain. Add identity-scope prefix cleanup for ONCE_PER_IDENTITY_CLAIM_PREFIX to both cleanup paths and cover it with a persistence regression test.

source: gpt-6.1-sol (phase2-reviewer: general, rust-quality)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that modifies token creation, distribution rules, fee estimation, claim construction, and network-enforced once-per-identity funds movement in src/backend_task/tokens/claim_tokens.rs and related token logic.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/ui/tokens/tokens_screen/distributions.rs`:
- [SUGGESTION] src/ui/tokens/tokens_screen/distributions.rs:1122-1127: Show inline validation when the once-per-identity amount is empty
  When the distribution is enabled and the amount field loses focus while empty, the `!self.once_per_identity_amount_input.trim().is_empty()` guard skips `parse_once_per_identity_amount`. The user therefore sees no validation message under the field and only encounters the invalid value later through the registration flow. Validate on focus loss regardless of whether the field is empty so the required amount error is shown inline.

In `src/backend_task/tokens/mod.rs`:
- [SUGGESTION] src/backend_task/tokens/mod.rs:259-272: Validate the contents of version 1 distribution rules in the backend
  `ensure_distribution_rules_supported` checks only the `V1` enum tag and the protocol capability. A malformed `V1` value with no once-per-identity distribution, a zero amount, or an amount above `i64::MAX` can therefore proceed through the backend task and reach contract construction or signing before upstream validation rejects it. The backend is the authoritative enforcement layer, so it should validate the actual once-per-identity payload with the model validator before building or signing, with regression coverage for malformed `V1` rules.

In `src/context/contract_token_db.rs`:
- [SUGGESTION] src/context/contract_token_db.rs:742-751: Clear once-claim hints during identity and devnet cleanup
  The new claim hint is stored under `DetScope::Identity`, but devnet cleanup removes only global token keys, global dismissal keys, and the global token order. Likewise, `forget_identity_token_state` removes an identity's global dismissal markers and token-order entries but does not remove its once-per-identity claim-hint keys. After a devnet reset or identity removal, re-importing the same identity can therefore display an advisory date from the old chain. Add identity-scope prefix cleanup for `ONCE_PER_IDENTITY_CLAIM_PREFIX` to both cleanup paths and cover it with a persistence regression test.

Comment on lines +1122 to +1127
if response.lost_focus() && !self.once_per_identity_amount_input.trim().is_empty() {
self.once_per_identity_amount_error =
parse_once_per_identity_amount(&self.once_per_identity_amount_input)
.err()
.map(|error| error.to_string());
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 Suggestion: Show inline validation when the once-per-identity amount is empty

When the distribution is enabled and the amount field loses focus while empty, the !self.once_per_identity_amount_input.trim().is_empty() guard skips parse_once_per_identity_amount. The user therefore sees no validation message under the field and only encounters the invalid value later through the registration flow. Validate on focus loss regardless of whether the field is empty so the required amount error is shown inline.

Suggested change
if response.lost_focus() && !self.once_per_identity_amount_input.trim().is_empty() {
self.once_per_identity_amount_error =
parse_once_per_identity_amount(&self.once_per_identity_amount_input)
.err()
.map(|error| error.to_string());
}
if response.lost_focus() {
self.once_per_identity_amount_error =
parse_once_per_identity_amount(&self.once_per_identity_amount_input)
.err()
.map(|error| error.to_string());
}

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

Comment thread src/backend_task/tokens/mod.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: lklimek.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 26, 2026
@github-actions
github-actions Bot requested a review from lklimek October 26, 2026 21:49
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Oct 27, 2026
@lklimek
lklimek merged commit 6d90573 into v1.0-dev Oct 27, 2026
11 checks passed
@lklimek
lklimek deleted the feat/token-once-per-identity branch October 27, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants