Registry Mirror
Skip to content

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

The "Swift SDK build + tests" job fails on every pull request based on v5.1-dev. First the app does not compile: the Swift compiler gives up on the send screen because its body is one very large expression. Once that is fixed, three app tests fail, and they point at two real defects: a refreshed contract did not show on the screen that asked for the refresh, and the removal records preview went over its size limit. This PR fixes all three so the job can pass.

Issue being fixed or feature implemented

1. Compile error. The job stops with:

SwiftExampleApp/Core/Views/SendTransactionView.swift:80:16: error: the compiler is unable to
type-check this expression in reasonable time; try breaking up the expression into distinct
sub-expressions

SendTransactionView.body was a single expression of about 365 lines. #6051 added about 180 lines to it. #6085, #6013 and #6093 all failed on this line, while pull requests based on v5.2-dev pass.

2. A refreshed contract stays stale. ContractRefreshApplyTests (from #6053) failed twice and then crashed the test host:

testShouldRecordAFirstTokenAndClearAnAbsentDescription: XCTAssertTrue failed (fixture.contract.hasTokens)
testShouldRefreshTheDescriptionAndKeywordsOfAMetadataOnlyChange: ("Optional(2)") is not equal to ("Optional(3)")
SwiftData/BackingData.swift:1145: Fatal error: This model instance was invalidated because its backing data could no longer be found the store. (PersistentKeyword)

ContractDownloader.apply saves the refreshed contract in a context of its own. The caller's context kept its old copy, because a context does not take in another context's save until it fetches. So after a refresh the update screen's contract still showed the old version and description, and its keywords could still point at a row the refresh had deleted, which crashes when read.

3. The removal records preview passes its limit. RemovalsPreviewFormatterTests (from #6056) failed with ("2668") is greater than ("2600") for a 2,000 byte limit. The formatter counted each record as encoded on its own, but the text it returns indents every record line, separates the records, and wraps them in the inputs and a cursor or note.

The same three tests already failed on #6056 before it merged. The compile error then hid them.

What was done?

1. Send screen (SendTransactionView.swift). body is split into small members. The screen looks and behaves the same.

Before:

var body: some View {
    let coreBalance = coreBalanceSnapshot()
    let sources = availableSources(coreBalance: coreBalance)
    return NavigationStack {
        Form {
            Section("Recipient") { ... }
            Section("Amount") { ... }
            // five more sections and conditions, inline
        }
        .toolbar {
            // Cancel, and Send with its ~90 line action inline
        }
        .alert("Error", ...) { ... }
        // three more alerts, onAppear, three onChange, sheet
    }
}

After:

var body: some View {
    let coreBalance = coreBalanceSnapshot()
    let sources = availableSources(coreBalance: coreBalance)
    return NavigationStack {
        presentedForm(coreBalance: coreBalance, sources: sources)
            .interactiveDismissDisabled(viewModel.isSending)
            .onAppear { ... }
            .onChange(of: sources, initial: true) { ... }
            // two more onChange
            .sheet(isPresented: $showQRScanner) { qrScannerSheet }
    }
}
  • presentedForm applies the title, toolbar, sending overlay and alerts to sendForm, in the same order as before.
  • sendForm holds the Form and its conditions. Each section is its own member: recipientSection, amountSection(coreBalance:), memoSection, sendFromSection(sources:coreBalance:), transactionTypeSection(flow:), next to the three that already existed.
  • sendToolbar, sendingOverlay and qrScannerSheet hold the toolbar items, the progress overlay and the scanner.
  • sendTapped() is the Send button's action, moved unchanged. It still refreshes the shielded fees first and reads the tapped flow, recipient, identity and amount before its Task starts.
  • SendResultAlerts is a file-private view modifier with the four alerts in their original order. The screen passes its own dismiss in, so the "Done" buttons close the same sheet.

The Core balance is still read once per render and passed down. All existing comments moved with their code. Strings, accessibility identifiers and labels are unchanged.

2. Contract refresh (ContractDownloader.swift). apply now takes the caller's ModelContext instead of its container. It still writes in a context of its own and saves only its own rows. After the save it fetches the contract again in the caller's context, with its keywords, tokens and document types (and their indexes and properties), so the copies the caller already holds show the refresh when apply returns. A fetch leaves the caller's pending edits alone. If that fetch fails, the refresh is saved but the caller's copies are stale, so apply reports it. The update screen's existing refresh failure state shows the message and offers the refresh again, which accepts the version just saved and fetches the rows again.

Before, after refreshPersistedContract returned for an update to version 3:

contract.version             -> 2      (the store has 3)
contract.contractDescription -> "Old"  (the store has "New")
contract.keywords            -> crash when a keyword was removed

After: 3, "New" and the new keywords, as soon as the call returns.

The tests used to run the main run loop for up to two seconds waiting for the main context to pick up the save, which never happens. They now check the main context right after apply returns.

3. Removal records preview (QueryDetailView.swift). The budget now starts at the size of the text around the records and charges each record as it is emitted, with its indentation and separator. The text produced for a given set of records is unchanged; only where the preview stops changes. Records are counted against the whole page's text first, so a page that fits its limit exactly is shown whole with its cursor; only when it does not fit does the note replace the cursor, and records are dropped from the end until the text with the note fits. The inputs and the note are always shown, even if they alone pass the limit, and the doc comment says so. The test now checks the limit it passes in (2,000) instead of 2,600, and new tests cover a page at exactly its size and one byte under.

How Has This Been Tested?

  • Built the simulator framework at this base (build_ios.sh --target sim --profile dev), then ran the job's app build command with warnings as errors: ** BUILD SUCCEEDED **, with no warning from the changed files.
  • The first push of this PR (send screen only) got past the compile step on the runner: ** BUILD SUCCEEDED **, then the three tests above failed. That run is https://github.com/dashpay/platform/actions/runs/45078895991/job/137382534279.
  • Reproduced the three failures locally, each test alone as well, so they are not caused by test order.
  • Checked with a throwaway test that a held row keeps its old values after another context saves, for an in-memory store and for an on-disk one, and that one fetch in the holding context updates it and leaves an unrelated pending edit pending.
  • After the fixes, on an iPhone 17e simulator, serial: ContractRefreshApplyTests (5), RemovalsPreviewFormatterTests (5) and InputBoundSubmissionsTests (6, also covers QueryDetailView): Executed 16 tests, with 0 failures. The new contract refresh test holds a document type, its properties and its index in the main context and checks they show the refreshed definition.
  • Type-check time for the send screen with -warn-long-function-bodies=20 -warn-long-expression-type-checking=20:
Slowest item in the file
Before body: 126 ms
After sendTapped(): 22 ms, sendFromSection: 21 ms, everything else under 20 ms

The local machine has a newer Xcode than the runner (which uses the iOS 18.5 simulator SDK), so this PR's own Swift job is the proof for the runner.

Not changed here: the review pointed out that Core sends are funded from one BIP44 account chosen from Platform address rows. Those lines are only moved by this PR and behave as on v5.1-dev; #6105 tracks the fix.

Not done: the send flows and the contract update screen were not exercised by hand in the simulator, and the full app test suite was not run locally.

Breaking Changes

None. ContractDownloader.apply is internal to the app; its only caller is refreshPersistedContract.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · c8b37fd

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build running
  • Approvals
    • swift-sdk (packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/SendTransactionView.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/ContractDownloader.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift and 2 more) — llbartekll or romchornyi

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.

… compiles again

The Swift job on v5.1-dev fails with "the compiler is unable to type-check
this expression in reasonable time" at SendTransactionView.swift:80. The
view's body was one expression of about 365 lines: the whole form, the
toolbar with the Send action inline, four alerts and the change handlers.

Each form section, the toolbar, the sending overlay, the scanner sheet and
the Send action are now their own members, and the four result alerts are
a view modifier. The view tree, modifier order, strings and identifiers
are unchanged, and the Core balance is still read once per render.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 22, 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 27 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 d4f5951 and c8b37fd.

Files selected for processing: 5

  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/SendTransactionView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/ContractDownloader.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ContractRefreshApplyTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/RemovalsPreviewFormatterTests.swift
  • 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

@github-actions github-actions Bot added this to the v5.1.0 milestone Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 22, 2026
@thepastaclaw

thepastaclaw commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress (commit c8b37fd) · live progress

QuantumExplorer and others added 2 commits November 23, 2026 06:20
…text

ContractDownloader.apply saves the refreshed contract in a context of its
own, and the caller's context kept its old copy: a context does not take in
another context's save until it fetches. The update screen's contract
stayed at the old version, and its keyword relations could still point at a
keyword row the refresh deleted, which crashes on read.

apply now takes the caller's context and, after its save, fetches the
contract, its keywords, tokens and document types again there. The tests
no longer wait on the run loop for a merge that never comes; they check the
main context as soon as apply returns.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…yte limit

The preview's budget counted each record as encoded on its own, but the
text it returns indents every record line, separates records, and wraps
them in the inputs and a cursor or note. With a 2,000 byte limit it
returned 2,668 bytes.

The budget now starts at the size of the text around the records and
charges each record as emitted. The emitted text for a given set of records
is unchanged. The test checks the limit it passes in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@QuantumExplorer QuantumExplorer changed the title fix(swift-example-app): split the send screen's body so the Swift job compiles again fix(swift-example-app): fix the compile error and the three failing tests in the Swift job Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Changes requested: 1 blocker

  • Core payments can fail because Send picks the funding account from Platform balances — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/SendTransactionView.swift:442-454 (new)
    Impact: A wallet owner with enough confirmed Core funds outside the selected BIP44 account can tap an enabled Send button and have the payment fail before broadcast.

This PR splits the SwiftExampleApp send screen into smaller view builders, reloads saved contract data in the caller’s SwiftData context, and counts the bytes actually rendered in removal previews. On b4128cd, the Swift build and tests passed with warnings treated as errors, and the frozen-schema check passed. PR Hygiene and PastaClaw review were pending; no code checks were failing.

🔴 1 blocking | 🟡 3 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The PR combines a substantial SwiftUI refactor with fixes to SwiftData refresh behavior and preview byte accounting, but it does not change transaction or coin-selection logic, protocol rules, or storage schemas.
  • 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.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (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 `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/SendTransactionView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/SendTransactionView.swift:442-454: Core payments can fail because Send picks the funding account from Platform balances
  Impact: A wallet owner with enough confirmed Core funds outside the selected BIP44 account can tap an enabled Send button and have the payment fail before broadcast.
  A user who received enough DASH through a DashPay contact but has an empty BIP44 account can open Wallet Details → Send, enter a valid Core recipient and amount, and still get an insufficient-funds error. The screen offers Core based on confirmed balances across accounts, but the branch moved into `sendTapped()` takes an index from the first funded key-class-0 Platform address, or defaults to zero. `SendViewModel.swift:788–792` then asks Rust to fund from exactly that BIP44 account, excluding the contact funds. The other branch also makes a funding decision in the view: it can reject a Platform transfer using cached balances and an estimated fee before Rust checks proof-verified balances. Use the existing `.allSpendable` scope and matching `pooledSpendableBalance` for ordinary Core payments, and put automatic Platform payer selection in `rs-platform-wallet` alongside transfer planning. The view should pass a specific account only when the user chose it.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/ContractDownloader.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/ContractDownloader.swift:525-531: The update screen dismisses as successful when the caller’s contract reload fails
  Impact: If SwiftData cannot reload the caller’s models after saving a contract update, the owner can be returned to details that still show the old version or relationships.
  A successful save does not mean the models already held by the screen are current. Both reload fetches discard errors with `try?`, so `UpdateContractView.refreshStoredContract` returns no failure and the confirmation dismisses back to a view that holds the same contract. If the contract fetch failed, that model can still hold old metadata or relationships to rows the save deleted. Keep the committed save, but return a distinct reload-only failure so the screen can retry the local read or rebind its models before dismissing, without resending the Platform update or discarding unrelated edits.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift:1576-1589: A removal page can lose records and its cursor even when the full preview fits
  Impact: When a complete removal page fits the byte limit with its cursor but not with the longer truncation note, the query catalog hides records and tells the user to rerun the query.
  Users can lose the page’s continuation cursor even though nothing needed to be cut. The formatter reserves the longer truncation note before counting records, then drops the cursor as soon as that inflated budget forces a cut. With the existing whole-page fixture, set `maxBytes` to the complete output’s UTF-8 count: the short cursor fits, but the note makes the final record exceed the budget. Count against the actual complete-page framing first; only if that cannot fit, switch to the truncation note and trim the buffered suffix as needed. Add an exact-fit test that checks both the record count and the cursor.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ContractRefreshApplyTests.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ContractRefreshApplyTests.swift:182-184: The refresh tests do not exercise document types the caller already holds
  Impact: A regression that leaves a previously loaded document type or its index and property relationships stale would pass the current cross-context tests.
  The new document-type prefetch has no test that distinguishes refreshed caller objects from correctly saved rows. These tests cover contract metadata, replaced keywords, and insertion of a first token; the parser’s own tests write and read in the same context. Seed an existing document type, load its indices and properties in the caller’s context before `apply`, then assert that the same held type reflects the changed definition and relationships immediately afterward while the unrelated edit remains pending.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 23, 2026
QuantumExplorer and others added 2 commits November 23, 2026 07:44
…t be read again

After a refresh is saved, the caller's context fetches the refreshed rows.
A failure of that fetch was dropped, so the update screen could close on a
contract it still held stale. It is now thrown: the screen's existing
refresh failure path shows it and offers the refresh again, which accepts
the version just saved and fetches the rows again.

Adds a test that a document type, its properties and its index held by the
caller's context show the refreshed definition as soon as apply returns.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…it exactly

The preview reserved room for the truncation note before counting any
record. A page that fit the limit with its cursor, but not with the longer
note, was cut and lost its cursor.

Records are now counted against the whole page's text first. Only when the
page does not fit does the note replace the cursor, and records are dropped
from the end until the text with the note fits.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 23, 2026
@QuantumExplorer
QuantumExplorer merged commit 78ec947 into v5.1-dev Nov 23, 2026
29 of 31 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/swift-example-send-view-type-check branch November 23, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants