Skip to content

feat(voting): expand duplicates in place, open Request details from a row, keep contests until voting ends - #1328

Open
romchornyi wants to merge 4 commits into
feat/voting-filtersfrom
feat/voting-duplicates-and-details
Open

romchornyi wants to merge 4 commits into
feat/voting-filtersfrom
feat/voting-duplicates-and-details

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Stacked on the stage 2 PR (filters). A name with several requests can now be decided from the list, Request details opens straight from a row, and an open contest no longer disappears mid-session. Voting state moves into one shared store. Feature summary: docs/features/username-voting/README.md.

What was done?

  • Shared store (VotingStore) owns contests, masternodes, the vote history and the five-vote limit; the list gets its own VotingListViewModel (ADR-0014, docs/adr/0014-…). The limit lives in a pure VoteLimit; the caster takes the vote history by injection and re-checks the votes left before each cast.
  • Contests stay until their voting end. A later read that comes back empty or fails keeps the last known votes; a contest Platform closed early stays (closed = no vote); newer data always wins over an older read, so a refresh that started before a vote cannot undo its counts.
  • Try again. A list that cannot load shows a full-screen message with Try again instead of an empty list; a failed refresh with rows on screen keeps them and offers Try again above them.
  • Several requests expand in place: «N requests» under the name, a chevron expand pill, one approve pill per request (animated; instant under Reduce Motion).
  • Request details opens from a row (username, link or "Not provided", identity, voting end); the separate contest screen is removed.
  • A filled pill stays enabled; tapping it takes my vote back (abstain), and VoiceOver says so.
  • Votes still go through the existing cast sheet in this stage; voting straight from the pills, the vote-limit and lock-is-final dialogs come in stage 4. Request dates, "Link included" and the voting period start come in stage 5b.
  • ADR-0013 and ADR-0014 added to the decision log as Proposed; the feature summary added.

How Has This Been Tested?

  • DashWalletTests (scheme dashwallet-dashpay, Debug, iPhone 17 simulator, iOS 26.5) on the tip of the stack, rebased on develop 7defb24: 1849 tests, 0 failures, 1 skipped; new tests for the store (keep-until-voting-end, newer-data-wins, load queue), VoteLimit, the caster's history injection, the list view model (load states, filled-pill take-back, VoiceOver hint), expand-in-place and Request details.
  • Live run on testnet with test contests (2026-11-07): the failed list load and the failed refresh (network cut), expand/collapse in place with per-request pills, Request details from a row and from an expanded request.
  • Not run live yet: a contest whose voting end passes while open on screen.
  • scripts/a11y_audit.py --check: no new findings.

Screenshots

Before (develop) After
List
Details from a row

Not captured: the expanded several-request row — no contest with several requests was open on the network on 2026-11-09 (checked live on testnet on 2026-11-07, see How Has This Been Tested?).

Captured on an iPhone 17 simulator with a new wallet (no voting keys) against the mainnet contests open on 2026-11-09; how and what: docs/review/username-voting/README.md (added in the stage 3 PR). Some captures are cropped to leave out offensive usernames that were open on the network.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • ADR (ADR-0001): ADR-0013 added, ADR-0014 added
  • Nothing in this PR holds customer data, unfixed vulnerability detail, secrets, or step-by-step attack detail against keys, PIN or encryption (ADR-0001, rule 2)

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Redesigned username voting with expandable contest requests, request details, and controls to approve or cancel an approval.
    • Added clearer vote availability, progress, refresh, and error feedback.
    • Voting lists now support improved filtering, search, and distinct empty and error states.
  • Bug Fixes
    • Clarified when contests are unavailable for voting and when vote history is incomplete; refreshed contest data is handled more reliably.
    • Requests with no vote or only an abstention remain visible under “Not voted.”
  • Documentation
    • Added documentation for username voting and related design decisions.

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

CodeRabbit ASCII loading animation

Currently processing new changes in this PR. This may take a few minutes, please wait...

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8a11d894-2b6a-40fa-941c-ec2ffb2d997f
Commits

Reviewing files that changed from the base of the PR and between a893475 and 9d219ea.

Files ignored due to path filters: 8

  • docs/review/username-voting/before-details.png is excluded by !**/*.png
  • docs/review/username-voting/before-list.png is excluded by !**/*.png
  • docs/review/username-voting/stage1-list.png is excluded by !**/*.png
  • docs/review/username-voting/stage2-filtered.png is excluded by !**/*.png
  • docs/review/username-voting/stage2-list.png is excluded by !**/*.png
  • docs/review/username-voting/stage2-sheet.png is excluded by !**/*.png
  • docs/review/username-voting/stage3-details.png is excluded by !**/*.png
  • docs/review/username-voting/stage3-list.png is excluded by !**/*.png
Files selected for processing: 76

  • DashWallet.xcodeproj/project.pbxproj
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/ContestedNamesService.swift
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoterRegistry.swift
  • DashWallet/Sources/Models/Voting/VoteHistoryDAO.swift
  • DashWallet/Sources/UI/DashPay/Voting/CastVoteSheet.swift
  • DashWallet/Sources/UI/DashPay/Voting/ContestDetailScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailField.swift
  • DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsViewModel.swift
  • DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift
  • DashWallet/Sources/UI/DashPay/Voting/Store/VoteErrorMessage.swift
  • DashWallet/Sources/UI/DashPay/Voting/Store/VoteLimit.swift
  • DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift
  • DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/VoteFlow.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingContestCard.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingFilter.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingViewModel.swift
  • DashWallet/ar.lproj/Localizable.strings
  • DashWallet/bg.lproj/Localizable.strings
  • DashWallet/ca.lproj/Localizable.strings
  • DashWallet/cs.lproj/Localizable.strings
  • DashWallet/da.lproj/Localizable.strings
  • DashWallet/de.lproj/Localizable.strings
  • DashWallet/el.lproj/Localizable.strings
  • DashWallet/en.lproj/Localizable.strings
  • DashWallet/eo.lproj/Localizable.strings
  • DashWallet/es.lproj/Localizable.strings
  • DashWallet/et.lproj/Localizable.strings
  • DashWallet/fa.lproj/Localizable.strings
  • DashWallet/fi.lproj/Localizable.strings
  • DashWallet/fil.lproj/Localizable.strings
  • DashWallet/fr.lproj/Localizable.strings
  • DashWallet/hr.lproj/Localizable.strings
  • DashWallet/hu.lproj/Localizable.strings
  • DashWallet/id.lproj/Localizable.strings
  • DashWallet/it.lproj/Localizable.strings
  • DashWallet/ja.lproj/Localizable.strings
  • DashWallet/ko.lproj/Localizable.strings
  • DashWallet/mk.lproj/Localizable.strings
  • DashWallet/ms.lproj/Localizable.strings
  • DashWallet/nb.lproj/Localizable.strings
  • DashWallet/nl.lproj/Localizable.strings
  • DashWallet/pl.lproj/Localizable.strings
  • DashWallet/pt.lproj/Localizable.strings
  • DashWallet/ro.lproj/Localizable.strings
  • DashWallet/ru.lproj/Localizable.strings
  • DashWallet/sk.lproj/Localizable.strings
  • DashWallet/sl.lproj/Localizable.strings
  • DashWallet/sl_SI.lproj/Localizable.strings
  • DashWallet/sq.lproj/Localizable.strings
  • DashWallet/sr.lproj/Localizable.strings
  • DashWallet/sv.lproj/Localizable.strings
  • DashWallet/th.lproj/Localizable.strings
  • DashWallet/tr.lproj/Localizable.strings
  • DashWallet/uk.lproj/Localizable.strings
  • DashWallet/vi.lproj/Localizable.strings
  • DashWallet/zh-Hans.lproj/Localizable.strings
  • DashWallet/zh-Hant-TW.lproj/Localizable.strings
  • DashWallet/zh.lproj/Localizable.strings
  • DashWallet/zh_TW.lproj/Localizable.strings
  • DashWalletTests/MasternodeVoteCasterTests.swift
  • DashWalletTests/RequestDetailsViewModelTests.swift
  • DashWalletTests/VoteHistoryDAOTests.swift
  • DashWalletTests/VoteHistoryPersistenceTests.swift
  • DashWalletTests/VoteLimitTests.swift
  • DashWalletTests/VotingFilterTests.swift
  • DashWalletTests/VotingListSectionTests.swift
  • DashWalletTests/VotingListViewModelTests.swift
  • DashWalletTests/VotingStoreTests.swift
  • docs/adr/0013-treat-dashuikit-and-swiftdashsdk-as-library-surfaces.md
  • docs/adr/0014-split-voting-state-into-a-shared-store-and-per-screen-view-models.md
  • docs/adr/README.md
  • docs/features/username-voting/README.md
  • docs/review/username-voting/README.md

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

@romchornyi
romchornyi added this pull request to stack #1329 November 9, 2026 12:36
@thepastaclaw

thepastaclaw commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 9d219ea. Normal review starts when eligible; priority review starts as soon as a slot is available.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Verified the findings against the exact head, its base, and the pinned Platform sources. Two correctness issues remain: overlapping history loads can double-count an accepted cast, and SDK-suppressed query failures bypass the new retry states; authoritative vote-count reconciliation and Request details success feedback also need attention. Current CI reports passing simulator tests, target-membership validation, and accessibility auditing; this verification was static, with no local builds or tests.

🔴 2 blocking | 🟡 2 suggestion(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: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI/state-management change with substantial SDK-adjacent vote-casting logic, but it does not itself alter consensus, funds movement, cryptography, key handling, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • 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.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions are optional: fix them forward in a later PR rather than pushing another round just for them.
- Address every current finding in one push: self-review the full diff first, and don't push piecemeal.
- 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 `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:487-492: Make the failed history-reread fallback idempotent
  A failed per-contest read does not establish that the accepted casts are missing from the current in-memory history. A full refresh can already be running while the caster broadcasts and records a vote. That refresh can read the newly written record and install it through performLoadAllVoteHistory() before this queued block executes. If the subsequent per-contest read fails, applyRecordedVotes() unconditionally calls recordCast() again, counting the same accepted vote twice. An actual fourth cast then becomes a cached fifth cast, disabling the remaining vote until another successful history load. The same duplication is possible when the earlier rebuild already incorporated the report's unrecordedCasts. Reconcile accepted casts idempotently against the history snapshot instead of blindly incrementing on read failure, and add a regression covering a full-history load that includes the accepted cast followed by a failed per-contest read.
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:277-281: Propagate partial contest-query failures into the retry state
  The pinned SDK can return successfully even when contest vote-state reads failed. At .platform-ref 1721ca7a8bc962c5c1e1559f65ff433454f57619, packages/rs-sdk/src/platform/dpns_usernames/contested_queries.rs calls non_resolved_dpns_contests(limit, true), whose Err(_) if skip_failed branch silently omits failed contests. The FFI returns that incomplete map as a successful list, and dpnsActiveContests() forwards it without completeness information. If discovery succeeds but all subsequent vote-state reads fail before the overall timeout, these lines clear loadFailed and set didLoadContests for an empty result: the initial screen reports no open contests without Try again, and refreshIfNeeded() stops retrying. With cached rows, the failed-refresh banner is suppressed. This directly affects the retry behavior introduced here. Preserve errors or explicit partial-result status in dashpay/platform's rs-sdk/FFI and SwiftDashSDK, then consume that status in the store. Do not reinterpret every empty array as failure, since a genuinely empty successful result is valid. Add coverage for successful discovery followed by failed vote-state reads; if the upstream fix is deferred, link a tracking issue or follow-up PR covering this gap.

In `DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift`:
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift:238-249: Reconcile the new limit check with authoritative Platform vote counts
  This recheck reads the device's journal, not Platform's spent-cast count. An imported voting key, restored install, or accepted vote whose history write failed can have missing local history even though Platform already holds votes; the missing row here becomes zero casts. The store can consequently keep offering an exhausted node or its existing choice, and rejected attempts do not reconcile that state. The pinned dependency already exposes getContestedResourceIdentityVotes(), backed by packages/rs-sdk-ffi/src/contested_resource/queries/identity_votes.rs, which returns resource_vote_choice and a proof-verified vote_count. The per-contender voters API discussed in VoteHistoryDAO is therefore not the only available read mechanism. Keep the local DAO as a journal, but bridge voter/poll identification and typed authoritative reads through SwiftDashSDK and reconcile the store from those results, preserving unavailable reads as unknown. Platform still enforces the ceiling, so this is not a bypass of the consensus limit, and no repository rule prohibits keeping a local journal; it is a non-blocking source-of-truth gap in the new recheck. If that integration is deferred, link an issue or follow-up PR rather than leaving the local-only limitation untracked.

In `DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift`:
- [SUGGESTION] DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift:62-70: Show successful-vote feedback on Request details
  Request details now presents its own cast sheet and remains on screen after casting. VotingViewModel.cast() reports complete success through list.showToast(), and CastVoteSheet immediately dismisses on that result. Unlike ContestDetailScreen, RequestDetailsScreen does not render voting.toast, so the visual success message stays on the list underneath the navigation destination and expires after three seconds. The previous contender-details flow dismissed back to the contest before presenting the cast sheet, where the toast was visible. Render the shared toast on this destination or return to a destination that presents it so approval and take-back operations receive visible confirmation.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

The complete current-head review found one in-scope blocking responsiveness defect: synchronous Platform vote-state reads still execute on MainActor, freezing contest refreshes and delaying vote-sheet completion. No code checks have failed in the supplied CI snapshot; title validation and CodeRabbit passed, while workflow lint, accessibility, test-target membership, and the review check remain pending.

🔴 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: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change is large and intricate, but its substantive changes concern voting state, asynchronous refresh ordering, vote-limit enforcement and UI rather than cryptography, signing algorithms, key derivation, funds movement or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:392-395: Use the available off-main SDK reads in the store's production adapter
  `VotingStore` is MainActor-isolated, and this `await` does not move the production read off that actor because `ContestedNamesService.voteState()` synchronously calls the blocking `SDK.dpnsContestVoteState` method while retaining MainActor isolation. A contest refresh therefore blocks the UI for the Platform round trip; `send()` also awaits this refresh before publishing its outcome, so the cast sheet remains non-dismissible during the same stall. The pinned SwiftDashSDK exposes off-main contest-read helpers, so update `ContestedNamesService` to use the off-main vote-state and contest-open APIs while keeping state publication serialized on MainActor.

@romchornyi
romchornyi force-pushed the feat/voting-duplicates-and-details branch from eb58414 to bc71fa8 Compare November 11, 2026 21:59

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 2 only (queue backlog)

Two blocking correctness defects remain in the voting store. A failed history refresh marks history unavailable but leaves old per-contest maps usable by vote-pill derivation, and the failed reread fallback still retains temporary casts that a later successful rebuild counts again; resolved contests also keep stale cached tallies. The simulator test check is queued, while the completed accessibility, workflow-lint, target-membership, and CodeRabbit checks are successful.

🔴 2 blocking

Still open from earlier rounds (1)

  • 🔴 Blocking: Make the failed history-reread fallback idempotent — DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:487-492 (thread)
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: Apply the newer resolved vote state before keeping the contest row
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:413-419

When voteState returns a resolved contest, this branch marks the label closed but leaves the cached DPNSContest unchanged. The successful response contains newer final contender, abstain, and lock tallies, so the list and Request details continue displaying pre-resolution counts while the row is retained until its voting end. Update the cached contest from state before marking it closed, preserving the existing requested labels, then retain or remove it according to the voting end.

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

Review provenance

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

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial state-management and UI refactor, but MasternodeVoteCaster.swift preserves the existing SDK signing and voting-key derivation operations rather than changing cryptography, key handling semantics, consensus rules, funds movement, or storage migrations.
  • Phase 1 reviewers: not run (skipped for throughput: 13 PRs queued, above the 10 limit)
  • Code unchanged since the last final review (eb58414b): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed; 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:595-601: Do not offer vote controls from stale history after a failed read
  `performLoadAllVoteHistory()` sets `historyUnavailable` when the DAO read fails but retains the previous `votedProTxHashesByContest` and `voteHistoryByContest` entries. `nodesForVote` checks only whether the per-contest dictionary entry exists, not whether the current history is readable, so the list can continue presenting actionable controls from stale vote counts. `myChoices` has the same issue at lines 657-663, allowing a stale filled pill to request a cancellation for a vote that may no longer be held. Gate vote and cancellation derivation on readable current history, or clear each affected contest into an unknown state on read failure.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: After a successful history load, a later refresh whose history read fails sets historyUnavailable but retains the prior per-contest dictionaries. The list still derives enabled pills from those stale entries, so tapping a filled pill can send an abstain cancellation for a vote no longer held, while tapping another choice can submit based on stale cast counts and live choices, resulting in a rejected or incorrect vote attempt._
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:487-492: Make the failed history-reread fallback idempotent
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1328#discussion_r4529441435)

Comment on lines +595 to +601
guard hasLoadedVoteHistory(for: normalizedLabel) else { return [] }
let chosen = effectiveSelectedNodeIDs
let history = voteHistoryByContest[normalizedLabel] ?? VoteLimit([])
return votableNodes.filter { node in
guard chosen.contains(node.proTxHash) else { return false }
guard (history.votesLeft(node.proTxHash) ?? 0) > 0 else { return false }
return history.liveChoice(of: node.proTxHash) != choice

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Blocking: Do not offer vote controls from stale history after a failed read

performLoadAllVoteHistory() sets historyUnavailable when the DAO read fails but retains the previous votedProTxHashesByContest and voteHistoryByContest entries. nodesForVote checks only whether the per-contest dictionary entry exists, not whether the current history is readable, so the list can continue presenting actionable controls from stale vote counts. myChoices has the same issue at lines 657-663, allowing a stale filled pill to request a cancellation for a vote that may no longer be held. Gate vote and cancellation derivation on readable current history, or clear each affected contest into an unknown state on read failure.

Raised on code unchanged since the last review, and confirmed by an independent pass: After a successful history load, a later refresh whose history read fails sets historyUnavailable but retains the prior per-contest dictionaries. The list still derives enabled pills from those stale entries, so tapping a filled pill can send an abstain cancellation for a vote no longer held, while tapping another choice can submit based on stale cast counts and live choices, resulting in a rejected or incorrect vote attempt.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing this in #1328: the stack merges as a whole, and #1347 gates pill eligibility, Approve, myChoices and every vote attempt on historyUnavailable, so stale maps cannot drive a vote or a cancellation on develop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I checked #1347 at 21817a7ff: it disables pills and Approve when historyUnavailable, suppresses stale myChoices, and makes vote attempts use a fresh history read with an unavailable-history stop. Those changes address this concern for the combined stack. I’ll treat this as fix-pending rather than deferred: the fix is present in the linked PR, but not in the reviewed bc71fa87 head.

The finding stands on this commit until that change is pushed; the push gets a full review.

@romchornyi
romchornyi force-pushed the feat/voting-duplicates-and-details branch from bc71fa8 to c35b756 Compare November 12, 2026 10:20

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

Static review of the exact head found no additional in-scope defects requiring action. The simulator test suite remains queued, while target-membership, accessibility, workflow-lint, PR-title, and CodeRabbit checks completed successfully.

🔴 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: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI, state-management, persistence, and SDK voting-service change, but it does not itself modify the listed critical surfaces such as consensus, funds movement, cryptography, key handling, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@romchornyi
romchornyi force-pushed the feat/voting-duplicates-and-details branch from c35b756 to 6d7195d Compare November 12, 2026 15:27

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

At 6d7195d, the added list guard prevents my-vote filters from displaying partial results while newly discovered contest histories load, with focused regression coverage in source. No new actionable defects were confirmed, and all six prior findings were independently reconciled. Validation was static only: current checks show title validation passing, CodeRabbit completed successfully with a rate-limit notice, and the review pending; no build or XCTest result validates this exact head.

🔴 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: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change is a substantial voting-state and UI refactor, but MasternodeVoteCaster.swift preserves the existing SDK signing and key-derivation operations rather than changing cryptography, consensus, funds movement, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@romchornyi-pitcrew romchornyi-pitcrew left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No blockers, no majors · 4 non-blocking recommendations — reviewed at 6d7195d7fb

Level Verdict
1 · Idea ✅ valid One store for contests, nodes and vote history (ADR-0014) is what lets Request details and the list agree; keeping a contest until its voting end fixes rows vanishing mid-session
2 · Architecture ✅ right layer App-owned state stays in the app; the SDK's silently partial contest listing is pushed to the SDK (dashpay/platform#5872) instead of being guessed at here
3 · Completeness ✅ gaps tracked Partial listing → platform#5872; vote controls on stale history after a failed read and the success toast on Request details → #1347 (checked: #1347 gates on historyUnavailable and adds a "vote cancelled" toast). Not run live: a voting end passing while the screen is open
4 · Code ✅ clean Load queue, newer-data-wins, the failed-reread fallback and the five-cast ceiling hold up; tests cover each new branch

Earlier threads — all six are settled: two fixed (idempotent re-read fallback in eb58414, off-main vote-state reads in bc71fa8), three deferred to tracked work (platform#5872, #1347 twice), one withdrawn (local vote history by design).

4 non-blocking recommendations
  1. New log lines still go through os.Logger —
    let errorType = String(describing: type(of: error))
    let nodeName = node.displayName
    Self.logger.error(
    "🗳️ VOTING :: cast failed on \(normalizedLabel, privacy: .public) with \(nodeName, privacy: .public): \(errorType, privacy: .public)")
    continue
    }
    // Recorded only on success, so the count the UI shows is
    // votes Platform accepted — not votes attempted.
    var historyRecorded = true
    do {
    try await history.record(
    CastVoteRecord(
    proTxHash: node.proTxHash,
    normalizedLabel: normalizedLabel,
    choice: choice,
    castAt: Date()),
    network: Self.networkKey)
    } catch {
    historyRecorded = false
    let errorType = String(describing: type(of: error))
    Self.logger.error(
    "🗳️ VOTING :: history write failed on \(normalizedLabel, privacy: .public): \(errorType, privacy: .public)")
    }
    outcomes.append(VoteOutcome(node: node, failure: nil, historyRecorded: historyRecorded))
    Self.logger.info(
    "🗳️ VOTING :: cast \(choice.logDescription, privacy: .public) on \(normalizedLabel, privacy: .public) with \(node.displayName, privacy: .public)")
    — the cast-failed and the new history-write-failed lines are written with the caster's Logger, so they never reach the log bundle users and QA export; the store in this PR already uses DWLogger. Moving these three lines over would make a "vote counted but not recorded" report checkable.
  2. VoiceOver reads the full identity id on every request —
    var accessibilityLabel: String {
    String(format: NSLocalizedString("Approve %@", comment: "Voting"), identityId)
    }
    — an expanded row's approve pill is labelled "Approve <44-character id>", and the row's text button reads the id again. A short form (first and last few characters) as the label, with the full id left to Request details, would keep a several-request row usable with VoiceOver. (not verified against Figma or Android)
  3. The description says the contest screen is removed; it is not —
    .accessibilityHint(headerHint)
    .contextMenu {
    Button(NSLocalizedString("All outcomes", comment: "Voting"), action: onOpenOutcomes)
    }
    — ContestDetailScreen stays, reachable from the row's context menu "All outcomes"; only the contender details screen went. Worth correcting the description, or saying whether "All outcomes" is meant to stay.
  4. No CI test run at this head — the stacked base means DashWalletTests does not run here, so the 1849 tests are a local run on the stack tip. They will run once the PR retargets develop; worth a glance at that run before merging.
Review details

Layered review (idea → architecture → completeness → code) of this PR's own diff against feat/voting-filters (83 files). Level 4 covered the general code lane plus the concurrency (load queue, @MainActor store, in-flight sends), persistence (the history DAO now throws, cast counts, unrecorded casts) and UI lanes (states, localization in every locale, VoiceOver hints, Reduce Motion, previews). Existing PastaClaw threads were read first and not repeated. No major findings survived verification. Static review only: nothing was built or run.

🤖 Reviewed with Claude Code

… row, keep contests until voting ends

Rebuilt on develop with the fifth PR review round: VoiceOver reads a request by a short identity, and the Request details review line has its catalog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 72a21762ac409d47e3e4ca2c94324c8d023bb71b
@romchornyi
romchornyi force-pushed the feat/voting-duplicates-and-details branch from 6d7195d to 127f7b1 Compare November 12, 2026 21:14
@romchornyi

Copy link
Copy Markdown
Contributor Author

Layered review at 6d7195d (fixed in 127f7b1): VoiceOver reads a request by its first and last four characters. The caster's log lines moved to DWLogger in #1347.

@romchornyi-pitcrew romchornyi-pitcrew left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No blockers, no majors · round 2 — re-reviewed at 127f7b12bf (stack rebased on develop and squashed)

Three of the four round-1 recommendations are closed; the fourth is settled by the stack:

# Round 1 Now
1 Caster log lines on os.Logger ✅ moved to DWLogger in #1347 (checked: MasternodeVoteCaster.swift on #1347); still Logger at this head, fine as long as the stack merges in order
2 VoiceOver reads the 44-character id ✅ fixed — spokenIdentity reads the first and last four characters on the approve pill and the row button, with tests
3 Description says the contest screen is removed ⚪ unchanged — ContestDetailScreen is still reachable from "All outcomes" at this head; it goes in #1347. Fine within the stack; the sentence is only true of the stack tip
4 No CI test run at this head ✅ DashWalletTests on simulator now runs here (pending at review time)

New since round 1: the Request details review line ("Review the posting below…") now has its catalog entry in every locale, English values as the rule asks. CastVoteSheet moved onto DashUIKit.BottomSheet with the rebase onto #1220; close and swipe-down stay disabled while that contest's vote is sending. Nothing else changed in this PR's own diff.

Verdict: ready to merge in stack order (after #1327), once the pending CI run is green.

Static review only: nothing was built or run.

🤖 Reviewed with Claude Code

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

The exact reviewed head implements the shared queued voting store, in-place request expansion, Request details navigation, and contest retention behavior without introducing a new in-scope defect. All supplied code checks passed on this head; only the separate review check remained queued.

🔴 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: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI, state-management, persistence, and SDK-adjacent change, but it does not itself alter consensus, funds movement, cryptography, key handling, network deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved as step 3 of the stack, at 127f7b12b. Nothing blocks it. The one open PastaClaw thread is real at this head and is fixed one PR up.

Checked

  • Store: the load queue (serially), keeping contests until their voting end, newer data winning, the fallback when the re-read fails, and the unrecorded casts. I traced a full refresh that runs while a vote is in flight, both when it sees the new row and when it doesn't. The cast is counted once either way, and the paired tests cover both cases.
  • Five-vote limit: VoteLimit reads the row's castCount. An unrecorded cast adds one on every rebuild. If the same node later casts again and that write succeeds, the count stays right and the later choice wins. The caster checks the stored count again before each node.
  • Open PastaClaw thread (stale per-contest history after a failed full read can still enable pills): #1347 (ea1a555a4) is built on 127f7b12b and checks historyUnavailable in the list, in Request details and in the vote attempt. That's fine as long as the stack merges in order.
  • Error mapping: the consensus codes in VoteErrorMessage match codes.rs at the .platform-ref pin (dabbec09c9).
  • Strings: every NSLocalizedString key in the changed Swift files is in en. All 19 new keys are in each of the 43 Localizable.strings files, and the plural keys are in the stringsdict.

Four non-blocking comments inline. None of them is fixed higher in the stack: castAuthenticated is now internal, error 40304 reads as "try again", the feature summary promises more about the five-vote limit than the code does, and one comment cites a document that isn't in the repo.

ADR-0013 and ADR-0014 stay Proposed. I wrote this review with Claude Code, and ADR-0001 rule 3 says an AI agent's approval doesn't count.

Not done: I didn't build or run anything. This review is static, plus CI: DashWalletTests on simulator, the target check, the VoiceOver/Dynamic Type audit and workflow lint all pass on this head.

/// recorded and the loop continues, so one failure cannot discard the
/// nodes that already succeeded.
private func castAuthenticated(
func castAuthenticated(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion (non-blocking). This went from private to internal so the tests can reach it. That makes a method that signs and broadcasts with the voting keys, with no PIN or biometric prompt, callable from anywhere in the app. The name can also be read as "cast with authentication".

The caster already takes send and votingKey by injection. The steps before the loop could come in the same way: the SDK check, the open-contest pre-flight and the AuthenticationGate call, each defaulting to what runs today. Then the tests could go through cast(...) and this could be private again. If that's more than this stage needs, a name like castAfterAuthentication would at least make a wrong caller stand out. It is still internal at #1347 and #1366.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed at the stack tip in 59f8743 (#1366): it is now castAfterAuthentication. Its doc says it asks no PIN, that it is internal only for the tests, and that app callers go through cast(choice:onNormalizedLabel:with:). I kept the rename and did not inject the pre-flight steps, to keep the change small in the caster.

return NSLocalizedString(
"The vote was not cast. This voting key does not belong to an active masternode.",
comment: "Voting")
default:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion (non-blocking). 40304 (MasternodeVoteAlreadyPresentError) ends up here and reads «The vote was not cast. Please try again.» Trying again gets the same refusal.

The store already leaves out nodes that hold the same choice, so this shows up when the local history is behind Platform: a vote cast from another wallet, or one cast before a reinstall. The feature summary says those votes stay invisible. The old code passed Platform's message through. Now the user is told to retry, and the retry can't succeed. A line for 40304 such as «This masternode already holds this vote.» would keep the reason. 40301 (VotePollNotFoundError) could read as closed too. Neither code is mapped at #1347 or #1366, and VotingStoreTests only checks that 40304 doesn't leak Platform's text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed at the stack tip in 59f8743. 40304 now reads «The vote was not cast. This masternode already holds this vote.», and 40301 reads as closed, like 40302. Both codes match codes.rs at the .platform-ref pin. Tests added.


## What it guarantees

- No masternode of this wallet votes more than 5 times on one contest; the limit is checked again

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit. This promises more than the code does. The five-vote check reads this device's history only. A vote isn't counted if it was cast from another wallet or before a reinstall. It also isn't counted if Platform accepted it, the history write failed, and the screen has since been reopened: unrecordedCasts lives only as long as the store. In each case the app offers that node another vote, and Platform refuses the sixth (shown as «No votes left»).

Something like «The app never offers a node a sixth vote by this device's record of its votes; Platform refuses a sixth in any case» says what actually holds. Line 43 overstates a little too: a contest left out of the list with no known voting end is dropped on the next refresh (testFullRefreshDropsALeftOutContestWithAnUnknownEnd).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed at the stack tip in 59f8743. The README now says the app never offers a sixth vote by this device's record of its votes, and that Platform refuses a sixth in any case. It also says that only a contest with a known voting end is kept until then.


/// The contests on the list: the open ones, plus any Platform closed
/// early or left out of its last answer, until their voting end
/// (sad §4 choice 6). ``closedLabels`` says which are closed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit. sad §4 choice 6 points to a document that isn't in the repo, so a reader can't follow it. The dated "(owner decision, 2026-11-05)" and "(owner, 2026-11-06)" notes on unrecordedCasts (lines 143–145) are the same kind of reference (CLAUDE.md guardrail 6). Link ADR-0014 or docs/features/username-voting/README.md instead, or keep just the reason, which the comments already mostly state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed at the stack tip in 59f8743. The sad §4 reference and the dated owner notes are gone, and the reasons stay in the comments.

romchornyi added a commit that referenced this pull request Nov 13, 2026
A vote Platform already holds (40304) reads as held instead of try again, and 40301 reads as closed; the caster's PIN-less loop is named castAfterAuthentication; the feature summary says what the vote limit and the kept contests guarantee; store comments no longer cite documents outside the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: b2105c399150ff8be02655435a531aca472ef6f7
The nodes read before the wallet's sync is done may not be all of this
wallet's, so the types that read its own votes cannot filter yet and say
the list is still syncing. The store now knows whether the sync was done
when it read the votable nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 25a73a91cd14a95b0f65f55fbe51df90debbe25f
@romchornyi

Copy link
Copy Markdown
Contributor Author

From the review of #1366 (it raised this on code that lives here): filters by my vote now wait for the wallet's sync, since the nodes read before it may not be all of this wallet's; the store records whether the sync was done when it read the votable nodes. Fixed in 48ee23f, with a test.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

The exact head passes the reported simulator, target-membership, accessibility, workflow-lint, and PR-title checks. Four non-blocking issues remain: the sync state is not propagated consistently to voting UI state, the browse-only banner can mislabel a pre-sync empty node list, known Platform refusal codes receive misleading retry text, and an unauthenticated broadcast helper remains callable throughout the app module.

🟡 2 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.

Follow-up candidates (optional) (2)

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: Map known Platform voting refusals to actionable messages
DashWallet/Sources/UI/DashPay/Voting/Store/VoteErrorMessage.swift:68-80

The consensus-code sanitizer maps 40302 to a closed contest and 40303 to no votes left, but 40301 (VotePollNotFoundError) and 40304 (MasternodeVoteAlreadyPresentError) fall through to "The vote was not cast. Please try again." A missing poll should be presented like a closed contest, while retrying a vote that Platform says is already present cannot succeed until local state is reconciled. The generic retry text hides both actionable reasons.

private static func message(forConsensusCode code: UInt32) -> String {
    switch code {
    case votedTooManyTimes:
        return NSLocalizedString("No votes left", comment: "Voting")
    case votePollNotAvailable, 40301:
        return closed
    case voterNotFound, incorrectVotingAddress, incorrectVoterIdentityId:
        return NSLocalizedString(
            "The vote was not cast. This voting key does not belong to an active masternode.",
            comment: "Voting")
    case 40304:
        return NSLocalizedString(
            "The vote was not cast. This masternode already holds this vote.",
            comment: "Voting")
    default:
        return generic
    }
}

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Keep the post-authentication vote loop private
DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift:229-233

castAuthenticated signs and broadcasts votes through the injected send closure without performing authentication or the contest-open preflight. It is internal so the unit tests can invoke the loop, but that access level also lets any production code in the app module call it and bypass both gates. Keep the loop private and provide a test seam that exercises the authenticated entry point, or inject the authentication and preflight boundaries so tests cannot expose an unauthenticated production broadcast API.

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

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: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI and state-management change involving vote casting, persistence, asynchronous refresh ordering, and SDK-facing services, but it does not directly change consensus, funds movement, cryptography, key handling, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Code unchanged since the last final review (127f7b12): 2 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift`:
- [SUGGESTION] DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:236-238: Browse-only banner ignores the new sync gate
  `showsBrowseOnly` checks that the first load completed and that no voting nodes were found, but it does not require `store.nodeListSynced`. When the initial node resolution runs before wallet synchronization completes, the empty result can render "This wallet holds no active masternode voting keys" even though the node list is still incomplete. That directs the user toward adding a key instead of waiting for the existing wallet data to finish syncing.

In `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [SUGGESTION] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:94-99: Publish changes to the sync-completion gate
  `nodeListSynced` is sampled in `refreshVotableNodes()`, but unlike `nodeListMayBeIncomplete` it does not emit `stateDidChange` when its value changes. `VotingListViewModel` uses that subject to recompute `canFilterByMyVotes`, `myVotesKnownForList`, and visible rows. If a refresh before `.syncDone` produces the same node IDs as a later refresh, the node-list value can become synchronized without the list recomputing, leaving the filter in its still-syncing state until the screen is reopened or manually refreshed.

Comment on lines 236 to 238
private var showsBrowseOnly: Bool {
viewModel.hasLoadedOnce && !viewModel.canVote && !viewModel.nodeListMayBeIncomplete
store.hasLoadedOnce && !viewModel.canVote && !store.nodeListMayBeIncomplete
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Browse-only banner ignores the new sync gate

showsBrowseOnly checks that the first load completed and that no voting nodes were found, but it does not require store.nodeListSynced. When the initial node resolution runs before wallet synchronization completes, the empty result can render "This wallet holds no active masternode voting keys" even though the node list is still incomplete. That directs the user toward adding a key instead of waiting for the existing wallet data to finish syncing.

Suggested change
private var showsBrowseOnly: Bool {
viewModel.hasLoadedOnce && !viewModel.canVote && !viewModel.nodeListMayBeIncomplete
store.hasLoadedOnce && !viewModel.canVote && !store.nodeListMayBeIncomplete
}
private var showsBrowseOnly: Bool {
store.hasLoadedOnce && store.nodeListSynced && !viewModel.canVote && !store.nodeListMayBeIncomplete
}

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deferred: tracked in #1424 (re-read the node list when the wallet's sync completes). This banner is replaced by the list's lasting message in #1347, where the same gap is covered by that issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for linking #1424; it is the right follow-up. However, this PR introduces the browse-only banner and can still show the misleading “no active masternode voting keys” message before synchronization completes, so I’m leaving the suggestion open on this head rather than treating the follow-up as resolution.

Comment on lines +94 to +99
@Published private(set) var nodeListSynced = false
/// The wallet's voting-key pool could only be read at its shallow
/// fallback depth and some active registration went unmatched, so a node
/// you can actually vote with may be missing from ``votableNodes``.
@Published private(set) var nodeListMayBeIncomplete = false {
didSet { if nodeListMayBeIncomplete != oldValue { stateDidChange.send() } }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Publish changes to the sync-completion gate

nodeListSynced is sampled in refreshVotableNodes(), but unlike nodeListMayBeIncomplete it does not emit stateDidChange when its value changes. VotingListViewModel uses that subject to recompute canFilterByMyVotes, myVotesKnownForList, and visible rows. If a refresh before .syncDone produces the same node IDs as a later refresh, the node-list value can become synchronized without the list recomputing, leaving the filter in its still-syncing state until the screen is reopened or manually refreshed.

Suggested change
@Published private(set) var nodeListSynced = false
/// The wallet's voting-key pool could only be read at its shallow
/// fallback depth and some active registration went unmatched, so a node
/// you can actually vote with may be missing from ``votableNodes``.
@Published private(set) var nodeListMayBeIncomplete = false {
didSet { if nodeListMayBeIncomplete != oldValue { stateDidChange.send() } }
@Published private(set) var nodeListSynced = false {
didSet { if nodeListSynced != oldValue { stateDidChange.send() } }
}

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deferred: tracked in #1424, which makes the store re-read the node list at sync completion and publish every nodeListSynced change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for linking #1424; it is the right follow-up. This commit adds nodeListSynced as part of the list’s sync gate, but it still does not publish its transition through stateDidChange, so the filter state can remain stale on this head; I’m leaving the suggestion open until that follow-up lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 13e6cedffa572b4c19cd12a41419cd95facbe6d5

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

The reviewed head passes the supplied simulator, target-membership, accessibility, and workflow checks. The voting changes still contain four non-blocking issues: two consensus errors use retry copy, the broadcast helper remains callable without enforcing authentication, the contest list can be silently truncated at 500, and the documentation overstates retention for contests with unknown end times.

🔴 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) (4)

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: Map poll-not-found and duplicate-vote errors to actionable messages
DashWallet/Sources/UI/DashPay/Voting/Store/VoteErrorMessage.swift:68-80

The pinned Platform codes define 40301 as VotePollNotFoundError and 40304 as MasternodeVoteAlreadyPresentError, but the current switch handles neither. Both therefore produce “The vote was not cast. Please try again.” A contest can close between pre-flight and broadcast, or local history can lag a vote cast from another wallet or installation; retrying cannot resolve either condition. Map 40301 to the existing closed message and 40304 to a duplicate-vote message.

private static func message(forConsensusCode code: UInt32) -> String {
    switch code {
    case votedTooManyTimes:
        return NSLocalizedString("No votes left", comment: "Voting")
    case votePollNotAvailable, 40301:
        return closed
    case 40304:
        return NSLocalizedString(
            "The vote was not cast. This masternode already holds this vote.",
            comment: "Voting")
    case voterNotFound, incorrectVotingAddress, incorrectVoterIdentityId:
        return NSLocalizedString(
            "The vote was not cast. This voting key does not belong to an active masternode.",
            comment: "Voting")
    default:
        return generic
    }
}

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Keep the authentication-free broadcast loop private
DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift:229-233

cast performs the contest-open check and AuthenticationGate prompt, but castAuthenticated derives voting keys and invokes the broadcast closure without enforcing either boundary. It is internal, so any source file in the application module can call it directly with a VoterNode array and broadcast a vote without user authentication. The current name also does not make the missing enforcement explicit. Restore a private implementation boundary, or expose an injected authenticated capability/test seam so production callers cannot invoke the signing-and-broadcast loop directly.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Do not present a capped contest list as complete
DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/ContestedNamesService.swift:43-89

activeContests() requests a hard limit of 500 and only logs when the result reaches that limit. It still returns a plain array, so VotingStore.performRefresh() treats the response as a complete successful load, clears loadFailed, and allows the list and counts to describe only those 500 contests. If the active set exceeds the cap, contests after the limit silently disappear with no retry or truncation state. The owning SDK/API should provide pagination or an explicit completeness signal, and the store should surface a non-complete result rather than treating it as the full list.

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

🟡 Suggestion: Scope contest-retention guarantee to known end times
docs/features/username-voting/README.md:40-43

The README says that a contest is not removed before its voting end, but VotingStore.performRefresh() retains an omitted contest only when endTime is present and in the future; an omitted contest with an unknown end time is dropped. The documentation should state the same known-end precondition as the implementation.

- A contest with a known voting end is not removed from the list before then.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

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: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI and state-management change involving vote casting, persistence, concurrency ordering, and extensive new behavior, but it does not itself alter consensus rules, funds movement, cryptography, key handling, or other critical-surface code.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Code unchanged since the last final review (48ee23f4): 4 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

SDD-Published-From: ec3a033a49f3acb98b6a9c03e20f6035e4d6aaed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants