Skip to content

feat(sdk): read contract moderation and fee pots in the Swift SDK and example app - #6056

Merged
QuantumExplorer merged 26 commits into
v5.1-devfrom
feat/swift-example-contract-moderation
Nov 22, 2026
Merged

QuantumExplorer merged 26 commits into
v5.1-devfrom
feat/swift-example-contract-moderation

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Protocol version 14 lets a data contract have moderators. They can ban, suspend or warn users and delete documents, and fees charged on the contract's documents collect in an owner pot and a moderators pot. Until now only the Rust and JavaScript SDKs could read any of that. This PR lets the iOS SDK and SwiftExampleApp read it: who is on a contract's banlist, suspension list or warning list, one user's status, the records moderators leave when they delete a document, the actions an elected moderation team is voting on, how many actions each team member took, and what the two fee pots hold. It does not add sending a moderation or a fee claim yet (see "What is left").

Value: iOS apps built on the SDK, and QA with the example app, can show moderation state and fee pots without going through JavaScript. Every read is proof-verified by rs-sdk, as all the other reads are.

Risks: Low. This only adds reads: no consensus, state transition or stored-data change, and no existing function changes behaviour, except that wasm-sdk's status read now resolves its lists through the same rs-sdk function (same errors and messages; a network below protocol 14 is refused before the contract is fetched). Two things to know. The new Swift code compiles in every target, but the Swift tests and the app have not run yet, because a local iOS framework with the new symbols was not built (see "How Has This Been Tested?"). And the reads only answer on a network at protocol version 14 or later; below that the node refuses them and the app shows the refusal.

Issue being fixed or feature implemented

There was no mobile surface for contract moderation (transition types 24 and 25 and their seven queries). Searched open PRs and issues first: #4794 touches contract config mirrors in the FFI and #4934 is docs; neither covers moderation reads. The design discussion is #4865. This PR delivers the read side; the write side follows (see below).

What was done?

rs-sdk (single entry points, so the FFI has nothing to stitch or decide):

  • ContractModerationStatusQuery::resolve(sdk, contract_id, identity_id, lists): the lists as given when the caller names them (an empty selection included, which the node judges), else every list the contract keeps (for_contract_id). That path first checks the status request's protocol gate, so a network below 14 refuses with ProtocolVersionNotActive before any contract request. wasm-sdk's status reads now use it too.
  • ContractDocumentRemovalsPageQuery::fetch_with_kept_values(&self, sdk): reads removal records with the field values they keep decoded under the document type, fetching the contract only when a record keeps any. The contract must be answered at a block no older than the records (asked again up to twice, then StaleNode): a contract update can add members to a kept object, and an older schema would drop them. Returns the records and the query of the next page.

rs-sdk-ffi (new module contract_moderation): eight JSON reads, each one rs-sdk call. The shapes follow the wasm bindings.

  • dash_sdk_contract_moderation_get_status
  • dash_sdk_contract_moderation_get_entries
  • dash_sdk_contract_moderation_get_document_removals
  • dash_sdk_contract_moderation_get_document_removals_by_ids
  • dash_sdk_contract_moderation_get_team_actions
  • dash_sdk_contract_moderation_get_team_action_signers
  • dash_sdk_contract_moderation_get_action_counts
  • dash_sdk_contract_get_fee_pots

A list or team action status crosses as a plain byte (0 banlist, 1 suspensions, 2 warnings; 0 active, 1 closed). An unknown value is refused rather than read into a #[repr(u8)] enum, which would be undefined behaviour. The FFI refuses only what an rs-sdk query cannot hold (a null handle, a bad id, an unknown byte, a limit above u16::MAX). The node judges everything else. The decision_proposal FFI helpers became pub(crate) so they are reused, not copied.

Swift SDK (Sources/SwiftDashSDK/ContractModeration/): Codable models and eight async throws SDK methods that marshal the arguments and decode the JSON. A page's cursor is passed back as it came; there are no paging loops or rules in Swift.

SwiftExampleApp:

  • Platform Queries → Data Contract lists the seven queries.

  • Contract detail → Moderation and Fee Pots opens a new screen with:

    • the fee pots;
    • the three lists, paged by the node's cursor;
    • a lookup of one identity's status;
    • removal records per document type;
    • team actions with their signers;
    • action counts.

    Every choice is offered for every contract: which lists a contract keeps, which types keep records and whether the contract is elected are the node's to answer, and its refusal is shown inline. Accessibility identifiers are under contractModeration., for the Android port to reuse.

Docs: TEST_PLAN rows DC-05..DC-10 cover the reads, and DC-11 and DC-12 record the two transitions as not implemented. The read row of each RPC is in Appendix A. The parity manifest gains contracts.moderation_reads (Swift supported, Kotlin unsupported, with the porting notes).

Before / after

Before, an iOS app had no way to ask this. After:

let status = try await sdk.contractModerationStatus(
    contractId: "9Fz…", identityId: "4Qp…")      // lists: nil = every list the contract keeps
// status?.banned == true, status?.banReason?.text == "spam", status?.warnings == [...]

let page = try await sdk.contractModerationEntries(contractId: "9Fz…", list: .suspensions)
let next = try await sdk.contractModerationEntries(
    contractId: "9Fz…", list: .suspensions, startAfter: page?.nextStartAfter)

What the FFI returns for the status:

{"lists": ["banlist", "suspensions", "warnings"],
 "banned": true, "banReason": {"code": null, "text": "spam"},
 "warnings": [{"warnedAt": 1600000000000, "reason": {"code": null, "text": "first"}}]}

A contract that is not moderated, read without naming lists:

before: (no API)
after:  SDKError: invalid request: contract 9Fz… is not moderated

Public interface changes

All additions. No existing item changes, so every existing caller still compiles.

dash-sdk (dash_sdk::platform::contract_moderation)

impl Sdk {
    // Resolves the lists (as `resolve` does) and fetches the status: the one call the FFI makes.
    pub async fn fetch_contract_moderation_status(&self, contract_id: Identifier,
        identity_id: Identifier, lists: Option<Vec<ContractModerationList>>)
        -> Result<Option<ContractModerationListStatuses>, Error>;
}
impl ContractModerationStatusQuery {
    pub async fn resolve(sdk: &Sdk, contract_id: Identifier, identity_id: Identifier,
        lists: Option<Vec<ContractModerationList>>) -> Result<Self, Error>;
    pub async fn for_contract_id(sdk: &Sdk, contract_id: Identifier, identity_id: Identifier)
        -> Result<Self, Error>;
    // Error::ProtocolVersionNotActive below protocol 14 (checked first);
    // Error::MissingDependency("DataContract", id) when absent;
    // Error::InvalidRequest when not moderated or keeping no list.
}
impl ContractDocumentRemovalsPageQuery {
    pub async fn fetch_with_kept_values(&self, sdk: &Sdk)
        -> Result<Option<ContractDocumentRemovalsWithKeptValues>, Error>;
    // Error::StaleNode(StaleNodeError::Height { .. }) when every contract answer is
    // older than the records' (three attempts, through the SDK's read_not_older_than).
}
pub struct ContractDocumentRemovalsWithKeptValues {
    pub removals: Vec<(ContractDocumentRemovalEntry, BTreeMap<String, Value>)>,
    pub next: Option<ContractDocumentRemovalsPageQuery>,
}

rs-sdk-ffi (C header)

DashSDKResult dash_sdk_contract_moderation_get_status(const SDKHandle*, const char *contract_id, const char *identity_id, const uint8_t *lists, uintptr_t lists_count);
DashSDKResult dash_sdk_contract_moderation_get_entries(const SDKHandle*, const char *contract_id, uint8_t list, const char *start_after, const uint32_t *limit);
DashSDKResult dash_sdk_contract_moderation_get_document_removals(const SDKHandle*, const char *contract_id, const char *document_type_name, const char *start_after, const uint32_t *limit);
DashSDKResult dash_sdk_contract_moderation_get_document_removals_by_ids(const SDKHandle*, const char *contract_id, const char *document_type_name, const char *const *document_ids, uintptr_t document_ids_count);
DashSDKResult dash_sdk_contract_moderation_get_team_actions(const SDKHandle*, const char *contract_id, uint8_t status, const char *start_at_action_id, bool start_at_action_id_included, const uint32_t *limit);
DashSDKResult dash_sdk_contract_moderation_get_team_action_signers(const SDKHandle*, const char *contract_id, uint8_t status, const char *action_id);
DashSDKResult dash_sdk_contract_moderation_get_action_counts(const SDKHandle*, const char *contract_id);
DashSDKResult dash_sdk_contract_get_fee_pots(const SDKHandle*, const char *contract_id);

In the removal JSON each kept field value is tagged recursively, {"type": <kind>, "value": <payload>} (128-bit values beyond 64 bits as decimal strings, identifiers base58, bytes base64). The removal pages are serialized straight into the output string, with no intermediate JSON tree, and a kept value that cannot be written (a non-finite float or an enum value) is reported as SerializationError. All eight functions run on the SDK's large-stack worker and return an error instead of aborting if that thread cannot start. Each returns a JSON string (free with dash_sdk_string_free) or no data when rs-sdk returns none. A null limit means the network's page cap; a pointed-to value is sent as it is (0 included, which the node judges). For get_status, a null lists pointer means every list the contract keeps, a non-null pointer with a count of 0 is an explicit empty selection, and a null pointer with a count above 0 is refused. The team actions JSON carries nextStartAtActionIdIncluded beside nextStartAtActionId, to pass back as they are.

SwiftDashSDK (extension SDK, all nonisolated async throws)

func contractModerationStatus(contractId: String, identityId: String, lists: [ContractModerationList]? = nil) -> ContractModerationStatus?
func contractModerationEntries(contractId: String, list: ContractModerationList, startAfter: String? = nil, limit: UInt32? = nil) -> ContractModerationEntriesPage?
func contractDocumentRemovals(contractId: String, documentTypeName: String, startAfter: String? = nil, limit: UInt32? = nil) -> ContractDocumentRemovalsPage?
func contractDocumentRemovals(contractId: String, documentTypeName: String, documentIds: [String]) -> ContractDocumentRemovalsPage?
func contractTeamActions(contractId: String, status: ContractTeamActionStatus, startAtActionId: String? = nil, startAtActionIdIncluded: Bool = false, limit: UInt32? = nil) -> ContractTeamActionsPage?
func contractTeamActionSigners(contractId: String, status: ContractTeamActionStatus, actionId: String) -> ContractTeamActionSigners?
func contractModerationActionCounts(contractId: String) -> ContractModerationActionCounts?
func contractFeePots(contractId: String) -> ContractFeePots?

New public types: the models in ContractModeration.swift (ContractModerationList, ContractModerationStatus, ContractModerationReason, ContractWarning, the page types, ContractTeamActionStatus, ContractTeamActionEvent, ContractFeePots, …). lists: nil reads every list the contract keeps and lists: [] is an explicit empty selection. ContractTeamActionsPage.nextStartAtActionIdIncluded is the cursor's include flag. ContractKeptFieldValue is tagged with its kind both across the C ABI and in its Codable form ({"type": "double", "value": 1.0}), with cases null, bool, int, uint, int128, uint128, double, string, identifier, bytes, array, object; so signed and unsigned integers stay apart, 1.0 and -0.0 stay doubles, and a removal page round-trips losslessly.

wasm-sdk: getContractModerationStatus and its WithProofInfo variant resolve their lists through ContractModerationStatusQuery::resolve. Absent, unmoderated and listless contracts keep their not_found and invalid_argument errors and messages. Without lists, a network below protocol 14 now gets ProtocolVersionNotActive before the contract is fetched.

rs-sdk-ffi error mapping (every FFI caller): dash_sdk::Error::MissingDependency now maps to DashSDKErrorCode::NotFound by its type, before the substring fallbacks. Before, a missing-dependency message usually reached NotFound through the "not found" substring, but one whose id contained "dapi", "timeout" or "connection" came out as NetworkError or Timeout.

A refused request is now reported by its gRPC status, also for every FFI read: a DapiClientError carrying gRPC InvalidArgument maps to InvalidParameter, where it used to be NetworkError. Every other status stays NetworkError, gRPC NotFound included: a node's word that something is absent is not proved, and NotFound is kept for an absence a proof showed. Kotlin's DashSdkError.NetworkError.isRetryable therefore no longer retries a request refused as invalid; the Swift SDK only reports the code. rs-dapi-client also builds a local InvalidArgument when it cannot construct a channel (for example a host that is not a valid TLS server name); that now reads as InvalidParameter too, and separating it at the transport boundary is #6065.

before: MissingDependency("DataContract", "<id containing dapi>")  ->  NetworkError
after:  MissingDependency("DataContract", "<id containing dapi>")  ->  NotFound

before: DapiClientError(gRPC InvalidArgument: "list not kept")      ->  NetworkError
after:  DapiClientError(gRPC InvalidArgument: "list not kept")      ->  InvalidParameter

The moderation catalog routes in the example app show each result with the inputs it was read for ({"inputs": ..., "result": ...}).

Unchanged: stored bytes, proofs, version tables and every existing FFI or Swift symbol.

What is left

  • Write transitions: contract user moderation (type 24) and contract fee claim (type 25). Each needs:

    • a single platform-wallet operation over rs-sdk's ModerateContractUser / ClaimContractFees (signing key choice and contract registration for the proof stay in Rust);
    • its FFI;
    • a Swift wrapper;
    • a production screen signed through KeychainSigner.

    Tracked as TEST_PLAN DC-11 and DC-12 (🚫).

  • wasm-sdk removal reads: read kept values under a contract no older than the records, as the FFI now does: wasm-sdk: read removal records' kept values under a contract no older than the records #6059.

  • rs-dapi-client local setup errors: report a channel construction failure with its own error rather than a gRPC InvalidArgument: rs-dapi-client: report a local channel setup failure with its own error, not a gRPC InvalidArgument #6065.

  • Kept values are read under the current document type, as Drive and every reader read them: a protocol 14 contract update that reordered a kept object's members (refused from protocol 15) reads earlier records under the new names. Documented on fetch_with_kept_values; no SDK can recover the layout a record was written under.

  • Kotlin: a JNI bridge and screens for these reads (out of scope; recorded in the parity manifest with the byte values and identifiers to reuse).

How Has This Been Tested?

Run locally (targeted, CARGO_INCREMENTAL=0):

  • cargo test -p dash-sdk --test main mock_fetch: 28 passed. This includes nine new tests:
    • a status query built from a contract id names exactly the kept lists;
    • an unmoderated, a listless and an absent contract are each refused;
    • an explicit empty list selection passes through unchanged;
    • removals that keep no fields make no contract request;
    • kept values decode, and the next cursor equals after();
    • every contract answer older than the records gives StaleNode, and so does every proof of absence older than them (only a fresh absence is MissingDependency);
    • a member appended to a kept object is dropped when read under the older contract (why the freshness rule exists);
    • fetch_contract_moderation_status resolves omitted lists from the contract and sends named lists as given.
  • cargo test -p dash-sdk --lib contract_moderation: 4 passed. --lib contest (35) and --lib dpns (98) also pass, since the kept-values read now shares their read_not_older_than; the stale tests count three contract requests.
  • cargo test -p rs-sdk-ffi --lib error: 43 passed, including a missing dependency whose id contains "dapi", "timeout" or "connection" mapping to NotFound, a gRPC InvalidArgument refusal mapping to InvalidParameter, and transport failures and a node's NotFound staying NetworkError.
  • cargo test -p dash-sdk --lib below_protocol_14_without_a_contract: 1 passed (status over every list on a network proven at 13: ProtocolVersionNotActive, no contract request, no probe).
  • cargo test -p rs-sdk-ffi --lib contract_moderation: 21 passed, including the tagged kept-value writer checked byte for byte against the fixture the Swift decoder also reads. These cover argument refusal before any request for every function, the JSON shape of every result writer, and two successful reads through the exported C functions against mock answers (a removals page after a cursor with a limit, a team actions page with its cursor and include flag).
  • cargo test -p rs-sdk-ffi --lib decision_proposal: 27 passed, after its helpers became pub(crate).
  • cargo clippy -p rs-sdk-ffi -p dash-sdk --all-targets -- -D warnings: clean. cargo fmt --all --check: clean.
  • cargo check -p wasm-sdk --target wasm32-unknown-unknown: clean.
  • python3 scripts/check_sdk_parity_manifest.py: OK, with the summary regenerated.
  • Swift, with a header swap instead of a full build_ios.sh: I cloned a recent DashSDKFFI.xcframework and confirmed its rs-sdk-ffi.h differs from the fresh header only by the 8 new declarations. Then I copied the fresh header in and built SwiftExampleApp with its test targets, and the SwiftDashSDK unit and integration tests, with xcodebuild build-for-testing.
    • Every Swift file compiled, with no warnings in the new or changed files.
    • Linking failed only on the 8 new dash_sdk_contract_* symbols, because the stale library does not have them.

Not verified yet:

  • the Swift tests have not run (they could not link): the SDK decoding tests, including the new kept-number-kind tests, the Codable round trip of a removal page, the app's InputBoundSubmissionsTests (a late catalog answer after an input edit is dropped) and ContractKeptFieldDisplayTests, and ModerationPagedLoaderTests (with a stub whose responses the test releases explicitly: a stale page or error released after a refresh is ignored; loading belongs to the current request);
  • the app has not been opened on a simulator;
  • no read has been made against testnet or a devnet.

CI's Swift build is the first full link.

Breaking Changes

None at the source or C ABI level: no consensus, protocol or storage change, and every existing Rust, C, Swift and JavaScript symbol keeps its signature. Two observable behaviour changes reach existing callers, and belong in the 5.1 release notes:

  • rs-sdk-ffi error codes, for every existing export (for example dash_sdk_data_contract_fetch): a gRPC InvalidArgument now maps to InvalidParameter instead of NetworkError, and a proved missing dependency (MissingDependency) always maps to NotFound. A client that retries on NetworkError (Kotlin's DashSdkError.NetworkError.isRetryable) no longer retries those. A node's gRPC NotFound stays NetworkError.
  • wasm-sdk getContractModerationStatus and its WithProofInfo variant: without lists, a network below protocol 14 now gets ProtocolVersionNotActive before the contract is fetched. Before, it got a contract-level error. Absent, unmoderated and listless contracts keep their errors and messages.

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 · 222647c

  • 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
    • files with no dedicated owner — you own it
    • sdk-parity — you own it
    • kotlin-sdk (packages/kotlin-sdk/PARITY_SUMMARY.md) — HashEngineering
    • rust-sdk-ffi (packages/rs-sdk-ffi/src/contract_moderation/json.rs, packages/rs-sdk-ffi/src/contract_moderation/mod.rs, packages/rs-sdk-ffi/src/contract_moderation/queries.rs and 4 more) — lklimek or shumkov
    • rust-sdk (packages/rs-sdk/src/mock/sdk.rs, packages/rs-sdk/src/platform/contract_moderation.rs, packages/rs-sdk/src/sdk/protocol_gate_tests.rs and 1 more) — lklimek or shumkov
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/ContractModeration.swift, packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/SDK+ContractModeration.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift and 23 more) — llbartekll or romchornyi
    • js-wasm-sdk (packages/wasm-sdk/src/queries/contract_moderation.rs) — shumkov

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.

Summary by CodeRabbit

  • New Features
    • Added protocol version 14 support in the Swift SDK for reading contract moderation status and entries, document removals, team actions, action counts, and fee pots.
    • Added a contract moderation section to the Swift example app, with searchable and paginated records, status and action details, fee-pot balances, and refresh controls.
    • Added moderation query examples to the platform query browser.
  • Bug Fixes
    • Improved error reporting for missing dependencies and invalid network requests.

QuantumExplorer and others added 3 commits November 22, 2026 17:52
rs-sdk gains the two single entry points the mobile reads need:
ContractModerationStatusQuery::for_contract_id fetches the contract and
names every moderation list it keeps, and
ContractDocumentRemovalsPageQuery::fetch_with_kept_values reads removal
records with their kept field values decoded under the document type,
fetching the contract only when a record keeps any.

rs-sdk-ffi adds eight JSON reads over them: an identity's moderation
status, a page of a moderation list, removal records by page or by ids,
team actions and their signers, moderation action counts, and a
contract's fee pots. Each reads its C arguments, calls one rs-sdk entry
point and writes the result in the shape the wasm bindings use. List and
team action status arguments cross as plain bytes, so an unknown value
is refused instead of being read into an enum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…DK and example app

The Swift SDK wraps the eight rs-sdk-ffi reads as async SDK methods with
Codable models, and decoding tests pin the JSON the Rust shape tests
produce. SwiftExampleApp lists the seven reads in the Platform Queries
Data Contract catalog, and the contract detail screen gets a Moderation
section: fee pots, the three moderation lists with cursor paging, one
identity's status, removal records per document type, team actions with
their signers, and moderation action counts. Every choice is offered
for every contract and the node's refusal is shown where it was asked.
TEST_PLAN rows DC-05..DC-10 cover the reads; DC-11 and DC-12 record the
moderation and fee claim transitions the app does not send yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Swift supports them in the SDK and the example app; Kotlin has no bridge
yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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 5 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 54d4ad0 and 222647c.

Files selected for processing: 41

  • book/src/sdk/protocol-version-15-upgrade.md
  • docs/sdk/sdk-parity-manifest.json
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/rs-sdk-ffi/src/contract_moderation/json.rs
  • packages/rs-sdk-ffi/src/contract_moderation/mod.rs
  • packages/rs-sdk-ffi/src/contract_moderation/queries.rs
  • packages/rs-sdk-ffi/src/decision_proposal/mod.rs
  • packages/rs-sdk-ffi/src/error.rs
  • packages/rs-sdk-ffi/src/lib.rs
  • packages/rs-sdk-ffi/src/runtime.rs
  • packages/rs-sdk/src/mock/sdk.rs
  • packages/rs-sdk/src/platform/contract_moderation.rs
  • packages/rs-sdk/src/sdk/protocol_gate_tests.rs
  • packages/rs-sdk/tests/fetch/mock_fetch.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/ContractModeration.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/SDK+ContractModeration.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractDocumentRemovalsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractFeePotsSection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationActionCountsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationComponents.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationEntriesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationStatusView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractTeamActionDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractTeamActionsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ModerationPagedLoader.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/InputBoundSubmissions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ContractKeptFieldDisplayTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/InputBoundSubmissionsTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ModerationPagedLoaderTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ModerationScopeTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/RemovalsLookupFilterTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/RemovalsPreviewFormatterTests.swift
  • packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ContractModerationDecodingTests.swift
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/Fixtures/ContractModeration/kept_fields.json
  • packages/wasm-sdk/src/queries/contract_moderation.rs
Walkthrough

The pull request adds protocol-version-14 contract moderation and fee-pot reads to the Rust FFI and Swift SDK. The Swift example app adds moderation screens and query-explorer support. The Rust SDK resolves status-list selections and decodes kept values in removal records.

Changes: Contract moderation reads

Layer / File(s) Summary
SDK query resolution and decoding
packages/rs-sdk/src/platform/contract_moderation.rs, packages/rs-sdk/src/sdk/protocol_gate_tests.rs, packages/rs-sdk/tests/fetch/mock_fetch.rs, packages/wasm-sdk/src/queries/contract_moderation.rs
The SDK resolves omitted status-list selections from contract configuration and adds removal reads that decode kept values using the current document type. The WASM status resolver now uses the shared SDK resolver.
FFI JSON output shapes
packages/rs-sdk-ffi/src/contract_moderation/json.rs, packages/rs-sdk-ffi/src/contract_moderation/fixtures/kept_fields.json
The FFI adds JSON output for moderation status, entries, removals, team actions, signers, action counts, and fee pots. Kept values use tagged JSON representations.
FFI read bindings and execution
packages/rs-sdk-ffi/src/contract_moderation/*, packages/rs-sdk-ffi/src/decision_proposal/mod.rs, packages/rs-sdk-ffi/src/runtime.rs, packages/rs-sdk-ffi/src/error.rs, packages/rs-sdk-ffi/src/lib.rs
The FFI adds validated read functions, enum-byte mappings, and query marshalling. The runtime adds fallible worker-thread execution, and error conversion adds mappings for missing dependencies and gRPC InvalidArgument.
Swift models and SDK wrappers
packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/*, packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ContractModerationDecodingTests.swift
The Swift SDK adds Codable models and wrappers for the moderation and fee-pot reads. Tests cover decoding, kept-value tags, argument marshalling, and fee-pot claim metadata.
Example-app moderation screens
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/*, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/InputBoundSubmissions.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/*
The app adds a moderation hub and detail views for moderation data and fee pots. Shared loaders and submission tokens manage asynchronous reads; tests cover stale results, pagination, and kept-value display.
Query explorer and capability records
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformQueriesView.swift, packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md, docs/sdk/sdk-parity-manifest.json, packages/kotlin-sdk/PARITY_SUMMARY.md
The query explorer adds moderation and fee-pot inputs, validation, and result handling. The test plan and parity records add coverage and capability status for these reads.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SwiftExampleApp
  participant SwiftSDK
  participant RustFFI
  participant RustSDK
  participant Platform
  SwiftExampleApp->>SwiftSDK: Submit contract moderation read
  SwiftSDK->>RustFFI: Marshal arguments and call FFI
  RustFFI->>RustSDK: Execute SDK query
  RustSDK->>Platform: Request moderation or fee-pot data
  Platform-->>RustSDK: Return query result
  RustSDK-->>RustFFI: Return SDK result
  RustFFI-->>SwiftSDK: Return serialized JSON
  SwiftSDK-->>SwiftExampleApp: Decode and display result
Loading

Possibly related issues

  • dashpay/platform#6059: This PR adds freshness-aware kept-value decoding in the Rust SDK, but does not change the WASM removal-read paths named by the issue.

Suggested reviewers: lklimek, shumkov, llbartekll

Merge Risk: Low · previous review 54d4a

The change adds read-only moderation and fee-pot queries across the Rust SDK, FFI, Swift SDK and example app, and no defect in those reads is established. One narrow case remains: a status read that omits the list selection can be refused when the network's protocol version is not yet known and the version check fails transiently. Otherwise the remaining items are test-coverage improvements, and the change is mergeable with owner awareness.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: read access to contract moderation state and fee pots in the Swift SDK and example app. The changeset matches this. It also covers the Rust SDK and C FFI layers that t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: read access to contract moderation state and fee pots in the Swift SDK and example app. The changeset matches this. It also covers the Rust SDK and C FFI layers that the Swift work depends on, and the title does not mention them, which is expected for a title. The title is specific and sits within the scope of the PR objectives, which describe the same feature.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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
@thepastaclaw

thepastaclaw commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

⏹️ Not reviewed — PR is closed (merged) (commit 222647c)

@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 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

The new mobile reads use the existing proof-verified SDK paths without changing consensus or storage, but the bindings can broaden explicit requests or lose kept values, and the example app can display verified results under the wrong inputs. Rust workspace and wasm32 checks passed; Swift SDK build and tests were pending at the time of this static review. Three lower-priority findings were omitted under the 10-comment budget.

🔴 5 blocking | 🟡 5 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The change spans Rust query logic, eight FFI entry points, and Swift SDK and UI code, but it exposes existing proof-verified reads without changing consensus, funds movement, cryptography, peer-facing deserialization, or stored state.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (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, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-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 `packages/rs-sdk-ffi/src/contract_moderation/queries.rs`:
- [BLOCKING] packages/rs-sdk-ffi/src/contract_moderation/queries.rs:153-170: Preserve explicit query inputs and let rs-sdk resolve defaults
  Swift collapses `lists: nil` and `lists: []`, and `moderation_lists` treats every zero count as omission. That turns an explicit empty selection, which WASM sends and the node rejects, into a successful read of every list the contract keeps. The three paged Swift wrappers likewise send `limit: 0` as the same sentinel as `nil`, so a supplied zero becomes a maximum-size page instead of reaching the node's bounds check. Give omission its own representation across the C ABI and document the valid pointer/count combinations. Put the complete resolve-and-fetch status operation in rs-sdk: the FFI currently decides whether to fetch the contract, and WASM separately implements the same missing, unmoderated, and listless cases. Apply the existing status request's protocol requirement before the dependency lookup; otherwise the omitted path can return `InvalidParameter` on protocol 13 where the explicit path reports `ProtocolVersionNotActive`. Share the resolver with WASM's proof-metadata path while preserving its public error mapping.
- [SUGGESTION] packages/rs-sdk-ffi/src/contract_moderation/queries.rs:630-642: Test a successful moderation read through the exported C ABI
  The exported-function tests cover argument rejection, while the Rust serializer tests and Swift JSON fixtures bypass the actual C-to-SDK call. Those tests would pass if the bridge dropped a supplied cursor before fetching. Register a mock for the exact paged removals or team-actions request with a non-default cursor and limit, call the exported function, and verify the string result tag and JSON before releasing it with `dash_sdk_string_free`.
- [SUGGESTION] packages/rs-sdk-ffi/src/contract_moderation/queries.rs:602-604: Distinguish fee-pot claims from automatic settlements
  The once-per-epoch check is on explicit claims. An elected team's membership change can also settle the moderators pot: `ModeratorsPotSettlement::into_drive_operations` deducts credits and resets action counts without updating the last-claim fields. Correct the C and Swift field docs and the `ContractFeePotsSection.swift` footer: `lastClaim*` describes the last explicit claim, not the last payout, and the reported credits are the balance, not a guarantee that an elected-team claim will distribute all of it.

In `packages/rs-sdk/src/platform/contract_moderation.rs`:
- [BLOCKING] packages/rs-sdk/src/platform/contract_moderation.rs:325-352: Require a contract proof at least as recent as the removals proof
  The two `Fetch` calls discard proof metadata, and the SDK's default height tolerance lets the second response be one block older than the first. Freezing `deleteKeepsFields` does not freeze the members of a kept object: a compatible contract update can append a member. DPP consumes the entire length-framed object but reads only the members the supplied schema declares, so a lagging contract response can silently omit a member that is present in the verified removal. Compare the verified heights before decoding and retry or report a freshness error if the contract is older. Add a regression test with an appended member, and reuse the height-checked SDK operation in both WASM removal reads, which currently resolve the schema through their cache before fetching records. Keep the no-kept-values path free of a contract lookup.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationStatusView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationStatusView.swift:104-120: Label moderation status with the identity that was queried
  The lookup stores only the returned status, the result is headed just “Status,” and the identity field stays editable. After looking up A, entering B either before or after the response arrives leaves A's ban, suspension, and warnings displayed beneath B's ID. Store the submitted ID with the result and display it, including for an empty result, or invalidate the result on edits and ignore completions for superseded inputs.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractDocumentRemovalsView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractDocumentRemovalsView.swift:138-154: Keep superseded reads from changing moderation pages
  Pull-to-refresh can start an all-records read while an ID lookup is awaiting Rust. `reload()` clears the filter, rows, and cursor, but the earlier lookup can still append filtered rows under “Records” and replace the all-records continuation with `nil`. In `ContractModerationEntriesView.swift:72–99`, a refresh can similarly mix a first page with a stale Load More response. `ContractTeamActionsView.swift:103–125` checks the generation before updating rows or errors, but an older request's `defer` still clears the newer request's loading flag. Make each current request own the rows, cursor, error, and loading state. The concurrent FFI queue does not stop an in-flight read when its Swift task is cancelled, so test a delayed completion after refresh or a mode change.

In `packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/ContractModeration.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/ContractModeration.swift:186-197: Preserve floating-point kept values across the Swift bridge
  DPP preserves the bits of a kept `f64`, and the Rust writer emits `-0.0` as a JSON number. Foundation's integer decoder accepts that token as `Int64(0)`, so the integer-first Swift decoder loses its sign and re-encodes it as `0`. Integral floats such as `1.0` also end up in `.int` rather than `.double`. Preserve the numeric kind in the bridge representation or decode it without coercing floating-point tokens to integers. Test both the `.double` case and the sign of zero while retaining the `UInt64.max` precision test.

In `packages/rs-sdk-ffi/src/contract_moderation/mod.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/contract_moderation/mod.rs:17-19: Document protocol 14 as the minimum for these reads
  All seven RPCs declare `PROTOCOL_VERSION_OF_5_0` (14), and protocol 14's query table accepts V0 for each. The handlers are also present in the stable `v5.0.2` tag. Correct the FFI and Swift docs, catalog labels, test plan, and parity entry so integrators and QA do not skip supported protocol-14 networks.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationEntriesView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationEntriesView.swift:119-124: Show the warning history returned for each warning-list entry
  The SDK returns every warning with its timestamp and reason, and DC-06 says warning rows list every warning. The row shows only the latest reason and a count, with no way to see the earlier reasons or any timestamps. Reuse the warning-history view from the identity status screen.

In `packages/rs-sdk-ffi/src/contract_moderation/json.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/contract_moderation/json.rs:248-253: Return both parts of the Rust team-action continuation
  `query.after(page)` returns an action ID and an inclusion flag, but the JSON writer drops the flag and the Swift example supplies `false`. This is correct today because `ContractTeamActions::next_query` always produces an exclusive continuation. Returning both parts would let Swift and future Kotlin hosts pass the cursor back unchanged instead of depending on how Rust currently constructs it.

@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 22, 2026
QuantumExplorer and others added 2 commits November 22, 2026 19:08
…ues under a fresh contract

Review fixes for the contract moderation reads:

- ContractModerationStatusQuery::resolve takes the caller's lists as
  given (an empty selection included) or, when none are named, checks
  the status request's protocol gate before fetching the contract, so a
  network below protocol 14 refuses with ProtocolVersionNotActive.
  rs-sdk-ffi and wasm-sdk both resolve through it; wasm keeps its
  not_found and invalid_argument errors.
- fetch_with_kept_values reads the contract only from a block no older
  than the removal records, asking again up to twice and otherwise
  failing with StaleNode: a contract update can add members to a kept
  object, and an older schema would drop them silently.
- The FFI paged reads take the limit as a pointer (null for the
  default), a null lists pointer means no selection while a non-null
  one with a count of 0 is an explicit empty selection, and the team
  actions page returns its cursor's include flag.
- The docs say protocol 14, the first version serving these reads, and
  that a fee pot's last claim is the last explicit claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…reads from changing screens

- Kept field values are read from JSONSerialization, which keeps a
  number's kind: 1.0 and -0.0 stay doubles with their sign, UInt64.max
  stays exact.
- An explicit empty list selection and a supplied limit of 0 now reach
  the node instead of reading as the defaults.
- The paged moderation screens share one loader whose generation token
  lets only the current request write rows, cursor, error and loading
  state, with unit tests for a stale completion after a refresh.
- The status screen heads its result with the identity that was looked
  up, clears it on edits and ignores superseded lookups.
- Warning-list rows show every warning with its time and reason.
- Docs and TEST_PLAN rows say protocol 14 and describe the fee pots'
  last claim as the last explicit claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

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 22, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

The public Swift Codable API still changes kept numeric values when a removal page is saved and reopened, even though both live FFI reads preserve them. The review also confirmed gaps in handling stale contract absence proofs, overlapping action-count refreshes, and paging tests that rely on sleep timing. Kotlin CI passed, review and hygiene checks are pending, and no Swift build or test result is listed for this head.

🔴 2 blocking | 🟡 2 suggestion(s)

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: Keep an older action-count read from overwriting a refresh
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationActionCountsView.swift:72-82

The Reload button is disabled while loading, but .task and .refreshable call the same unguarded method. If a refresh shows counts reset by a payout, an earlier request can finish later and put the previous payout period's counts under “Counts Since the Last Payout,” or replace the refreshed result with an error. Guard both success and failure with the current request's generation, as the paged screens do, or serialize the three entry points.

source: gpt-6.2-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a substantial cross-language SDK and UI change, but it adds read paths over existing proof verification without changing consensus rules, funds movement, cryptography, peer-facing deserialization, or persisted state.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 (9363df29): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • 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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-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 `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift:350-356: Label moderation status with the identity that was queried
  The dedicated status screen now labels the submitted identity, but the new Platform Queries route returns only the status JSON, which contains neither the contract nor the identity ID. Execute is disabled while the request runs, but the parameter fields remain editable, and editing them does not invalidate the result. A user can look up A, change the form to B before or after the response arrives, and see A's `banned: false` under B's inputs. Show the submitted contract and identity with the result, or clear the result on edits and discard completions that no longer match the submitted inputs.

In `packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/ContractModeration.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/ContractModeration.swift:191-202: Preserve kept numeric values through the public Codable round trip
  Both live removal reads preserve floating-point kinds, but the returned page and entries also publicly conform to `Codable`. That separate path encodes bare numbers and decodes `Int64` before `Double`, so `.double(1.0)` comes back as `.int(1)`. The encoding test asserts that `.double(-0.0)` writes `-0`, but does not decode it; the same integer branch restores `.int(0)` and loses the sign. Give the public Codable representation an explicit type tag separate from the FFI JSON, or remove the lossy conformance from the removal models. If keeping it, test a full page round trip and check both the numeric case and the sign of zero.

In `packages/rs-sdk/src/platform/contract_moderation.rs`:
- [SUGGESTION] packages/rs-sdk/src/platform/contract_moderation.rs:428-438: Check the proof height before reporting a missing contract
  `DataContract::fetch_with_metadata` returns verified metadata even when it proves the contract was absent. If that proof predates the removal records but falls within the SDK's height tolerance, `ok_or_else` returns `MissingDependency` before the height check and skips the retry. An older absence should follow the same retry path as an older present contract. Add a regression that exhausts the retries with stale absence proofs and expects `StaleNode`, not `MissingDependency`.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ModerationPagedLoaderTests.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ModerationPagedLoaderTests.swift:37-70: Control completion order in the paging race tests
  The sleeps do not establish that both fetches started. In the first test, Load More can start after reload has cleared the cursor and return without fetching, so the test passes without exercising a stale completion. In the second, the old fetch can finish before refresh starts and fail the loading assertion. Use a fetch stub that signals entry and waits for the test to release each response. The same stub can verify that an error from a superseded request is ignored; the current error test runs the failure and success sequentially.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Use height-checked schema reads for WASM removal records — Both pre-existing WASM removal methods still resolve the document schema through the cache before fetching the records. An older schema can silently omit an appended kept member when decoding a newer record.
    • Follow-up: Use the shared Rust SDK operation in both WASM methods under #6059, preserving the records' proof and metadata in WithProofInfo.

@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 22, 2026
QuantumExplorer and others added 2 commits November 22, 2026 19:41
… values

A proof that the contract is absent carries a height too. One older than
the removal records is asked again like an older contract, and only a
fresh absence is reported as MissingDependency.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ration reads off screen

- ContractKeptFieldValue's Codable form is now tagged
  ({"type": "double", "value": 1.0}), so encoding and decoding a removal
  page keeps 1.0 and -0.0 as doubles. The FFI's bare values are read
  only through init(jsonObject:), and removals decode through a private
  wire type without keptFields.
- The catalog's moderation status result names the contract, identity
  and lists it was read for; editing them clears it and drops a late
  answer.
- The fee pots, action counts and team action signer screens read
  through a single-read loader with the paged loader's generation
  token, so an older read cannot replace a refresh.
- The loader tests release each fake response explicitly instead of
  sleeping, so both requests are provably in flight.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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 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 22, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

The moderation reads use the existing proof-verified SDK paths without changing consensus or storage. The status catalog now ties results to the submitted inputs, but six other new routes can still display an earlier answer under edited inputs, including another contract’s fee-pot balance. Kotlin CI passed; the exact-head Tests workflow was pending, with no Swift link or test result available.

🔴 2 blocking | 🟡 4 suggestion(s)

Still open from earlier rounds (1)

  • 🔴 Blocking: Preserve explicit query inputs and let rs-sdk resolve defaults — packages/rs-sdk-ffi/src/contract_moderation/queries.rs:171-176 (thread)
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: Classify a proved missing contract by its typed SDK error
packages/rs-sdk-ffi/src/contract_moderation/queries.rs:171-177

A proved absent contract reaches the shared FFI mapper as Error::MissingDependency, whose message includes the caller’s Base58 contract ID. The mapper scans for timeout, connection, and dapi before it checks for not found, so valid IDs containing those substrings can turn a proved absence into a timeout or network error in Swift. Map the typed variant to DashSDKErrorCode::NotFound before the string fallbacks and add a regression with a colliding ID.

source: gpt-6.2-sol (phase2-reviewer: rust-quality)

🟡 Suggestion: Keep document text distinct from the structure of removal evidence
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationComponents.swift:151-155

displayText inserts kept strings verbatim into the comma-and-colon notation used for object members and array elements. This lets text supplied by a document author look like a separate field that was never in the verified record. The proof and decoded model remain intact; the ambiguity is introduced when ContractDocumentRemovalRow displays the flattened value. Render nested values structurally or quote and escape string values and member names.

source: gpt-6.2-sol (phase2-reviewer: security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The PR adds substantial cross-language read logic, including schema freshness checks and value decoding, but does not change consensus, funds movement, cryptography, peer-facing network deserialization, or storage.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 (4dd9ab0c): 2 new suggestion(s) listed as follow-up candidates, not posted inline
  • 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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-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 `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift:154-159: Invalidate results when inputs change on every moderation catalog route
  `resultFollowsInputs` only covers the status route. On Get Contract Fee Pots, submit contract A and edit the ID to B while the request is pending: the edit does not advance `submission`, so A’s completion passes the guard and displays A’s balances under B’s input. Editing after completion also leaves A’s result on screen. The entries, removals, team actions, signers, and counts routes have the same gap. Apply the existing invalidation guard to all seven routes, capture the submitted inputs at Execute, and test that a delayed fee-pot response is discarded after an edit.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractTeamActionDetailView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractTeamActionDetailView.swift:19-23: Label the team action status and approval count as listing snapshots
  The status and count are captured when the action is listed, but the detail screen fetches signers separately and can reload them. A later approval can produce more signers than the displayed count, and an action that closes can still show “Active” above an empty active-signers result. Label the status and count as values from the listing, and explain that the signer query uses that status and may reflect a different block. The approval-count upper bound is not a comparison across those two reads.

In `packages/rs-sdk/src/platform/contract_moderation.rs`:
- [SUGGESTION] packages/rs-sdk/src/platform/contract_moderation.rs:419-448: Reuse the SDK’s verified-read freshness helper
  `read_not_older_than` in `platform/documents/contest_vote_state.rs`, already used by DPNS, provides the same three-attempt policy and the same zero-tolerance `StaleNode::Height` error. Move it to a shared SDK module and call it here with `|_| false`. Convert `None` to `MissingDependency` only after the helper accepts the proof height, so present and absent contract proofs still follow the same freshness rule.

In `packages/rs-sdk/tests/fetch/mock_fetch.rs`:
- [SUGGESTION] packages/rs-sdk/tests/fetch/mock_fetch.rs:789-812: Assert that a stale contract proof actually triggers retries
  The stale-present and stale-absence tests both use fixed-height responses and assert only the final `StaleNode` error. Both would pass if the SDK returned that error on the first stale proof. Use `sdk.mock().request_count(...)` on the exact `GetDataContractRequest` in both tests to assert one initial request plus `KEPT_VALUES_CONTRACT_RETRIES` retries.

In `packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/SDK+ContractModeration.swift`:
- [SUGGESTION] packages/swift-sdk/Sources/SwiftDashSDK/ContractModeration/SDK+ContractModeration.swift:18-20: Document the protocol-14 refusal as an SDK gate
  The Swift and FFI docs describe a network below protocol 14 as a refusal from the node, but `ensure_network_serves` can reject the request before the moderation RPC is sent. An SDK pinned below 14 can refuse even when the network supports the RPC, and a transient failure to verify the network version maps to `NetworkError`, not `ProtocolError`. Document the distinction so callers know whether to check their SDK pin, retry, or wait for network activation.

In `packages/rs-sdk-ffi/src/contract_moderation/queries.rs`:
- [BLOCKING] packages/rs-sdk-ffi/src/contract_moderation/queries.rs:171-176: Preserve explicit query inputs and let rs-sdk resolve defaults
  (carried; thread: https://github.com/dashpay/platform/pull/6056#discussion_r4657936610)
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Return an error when the shared FFI runtime cannot start a worker thread — The unchanged BigStackRuntime::block_on calls expect on spawn_scoped. An OS thread-creation failure therefore aborts an iOS host built with panic = "abort" instead of returning an SDK error. This affects the shared runtime, not just the new moderation calls.
    • Follow-up: In a separate runtime PR, make worker startup fallible and translate the failure at the C ABI boundary.

@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 22, 2026
QuantumExplorer and others added 3 commits November 23, 2026 01:21
…xture and note the 5.1 behaviour changes

- The removal exports serialize the page and drop its decoded values on
  the large-stack worker and return only the string; a 256-level nested
  kept value is tested.
- The kept-value fixture lives once in the Swift test resources and is
  loaded through Bundle.module; rs-sdk-ffi includes the same file.
- A by-ids removal read with a schema-decoded kept value is tested
  through the exported function, and an unpinned SDK that learns
  protocol 14 from its probe resolves and fetches a status over every
  kept list.
- C and Swift docs say a cursor does not promise another row.
- The protocol 15 upgrade guide lists the FFI error-code changes and the
  wasm status methods' protocol refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…placed SDK connection

AppState counts its SDK connections (sdkGeneration). Every moderation
screen and catalog route captures the connection with its read, shows
an answer only while it is current, and clears rows, cursors and
pending reads when the SDK is replaced, so a result from a previous
network never shows as the current one and Load More never queries a
replaced SDK. The team action detail reads signers only through the
connection its listing came from.

Also: bidirectional controls are shown escaped in reason citations and
as JSON escapes in catalog output, and the catalog's removal preview is
capped at 64 KiB with a note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-contract-moderation

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
#	packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-11-22T19:22:13.752Z

@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 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 22, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Request changes: the contract-detail route can show fee-pot balances from a replacement SDK under contract metadata selected on the previous connection. The assigned diff passes git diff --check, and the Kotlin emulator build and tests and book preview passed; CI did not show a Swift link or test result for this head. No builds or tests were run locally during this static review.

🔴 2 blocking | 🟡 6 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The PR adds substantial cross-language read logic, schema freshness checks, and UI state handling, but it does not change consensus, funds movement, cryptography, peer-facing network deserialization, or stored state.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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.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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-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 `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift:299-304: Bind contract-detail moderation reads to the selected contract's connection
  `ModerationRoute` captures the saved contract ID and document-type names but not their connection. `ContractsTabView.swift:226–234` retains the selected contract in a sheet independently of the filtered list, while `ContractFeePotsSection.swift:53–75` reloads that same ID through the replacement SDK. A devnet edit in another window can leave the network enum unchanged, and the same owner and nonce can produce the same contract ID on both chains. The open drill-down can then show the second chain's verified balance alongside the first chain's document types. Invalidate the selected contract and its moderation drill-down when the connection changes, or re-resolve and replace the contract context before allowing child reads. Cover a same-enum devnet replacement with the same contract ID and different schemas or balances.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractTeamActionDetailView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractTeamActionDetailView.swift:20-45: Bind moderation results and cursors to the SDK that verified them
  The new guards reject old catalog and pager responses and correctly stop signer reads after the listing connection changes. An already-pushed Team Action detail still renders its saved action ID, proposer, approvals and deletion event unconditionally, though: `listingReplaced()` only changes the Signers section. When another window replaces the SDK, the old governance record remains visible under the same title, with the only connection notice below the Action and Event sections. Gate the entire detail on its captured generation, or prominently identify the original connection for the whole snapshot. Add coverage for replacement while the detail is already pushed; the loader tests do not exercise that route.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift:1104-1122: Apply the removal preview budget before formatting the whole page
  `removalsResult` starts with every record and pretty-prints the page and scans its Unicode scalars for bidi controls on the main actor before checking the 64 KiB limit. It repeats that work for smaller prefixes. A large valid page can stall the UI even when very little of it is eventually shown. This is extra catalog formatting work, separate from the decoded-value budget tracked in #6070. Format incrementally off the main actor, stop when the preview budget is spent, and publish only if the submission is still current.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/QueryDetailView.swift:1106-1116: Distinguish the full-page cursor from the truncated removal preview
  The preview drops trailing records but still shows `nextStartAfter` from the full fetched page. Using it as the next Start After skips the records hidden by the preview, even if the user reduces Limit. Leave the SDK cursor unchanged; hide it on a truncated preview or label it as following the entire fetched page. Tell users to reduce Limit and rerun from the original Start After, or to submit fewer IDs in by-ID mode, which does not accept Limit.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationComponents.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractModeration/ContractModerationComponents.swift:98-120: Separate moderator-authored text from structured reason fields
  The UI places unlabeled moderator-authored text beside the structured `Code` and `Reason document` rows. DPP bounds the text length but does not restrict its content, so a line of prose that resembles a citation can be mistaken for the record's structured citation. Put the text in a labeled, visually distinct block, display bidi controls visibly as the view already does for cited type names, and keep structured fields outside the block. Leave the SDK value unchanged.

In `book/src/sdk/protocol-version-15-upgrade.md`:
- [SUGGESTION] book/src/sdk/protocol-version-15-upgrade.md:75-81: Correct the retry guidance for remapped FFI errors
  These codes no longer qualify under retry policies keyed to `NetworkError`, but they do not mean the request must change. A contract proved absent at one block can be present at a later block. The mapper also catches `InvalidArgument` from local channel construction before any RPC is sent; fixing the local TLS configuration can make an unchanged query succeed. Document the retry classification rather than promising a permanent refusal, and note the channel-setup exception tracked in #6065.

In `packages/rs-sdk/src/sdk/protocol_gate_tests.rs`:
- [SUGGESTION] packages/rs-sdk/src/sdk/protocol_gate_tests.rs:707-722: Exercise the protocol-14 probe through the public moderation status read
  The positive test calls `ensure_network_serves` directly, so the public read starts after protocol 14 is already established. Its final probe count cannot detect a resolver that fetches the contract before probing on a cold connection, and the negative test starts with protocol 13 already verified. Prepare the protocol-14 fixtures without advancing the SDK under test, then invoke the public read on an unpinned SDK seeded at 13 with no verified observation. Assert that the probe runs before the contract request.

In `packages/rs-sdk-ffi/src/contract_moderation/json.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/contract_moderation/json.rs:320-323: Identify the record and kept field when removal serialization fails
  An error from one kept value aborts serialization of the whole page. The FFI preserves the `SerializationError` code, but a message such as `NaN is not a finite float` does not identify the record or field; the caller gets neither rows nor a cursor to help isolate the failure. Add the document ID and top-level kept path when propagating the error, without changing the code or building an intermediate JSON tree on success.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Carry the previous verified height across SDK page boundaries — The existing Rust continuations carry key bounds, not the prior proof height. A valid older page within the SDK's freshness tolerance can omit rows visible at a newer height. The new adapters pass through those continuations; a Swift- or FFI-only policy would leave other SDK callers with different behavior.
    • Follow-up: Implement height-aware continuation in the shared SDK paging API under #6081.

@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 22, 2026
QuantumExplorer and others added 3 commits November 23, 2026 02:14
…the protocol 14 probe through the public read

- A kept value the removal JSON cannot write fails with the document id
  and top-level kept path in its SerializationError message.
- The positive protocol-gate test calls fetch_contract_moderation_status
  on an unpinned SDK seeded at 13 and shows the probe precedes the
  contract request (a test-only mock switch encodes fixtures at 14).
- The upgrade guide describes the remapped FFI codes as outside
  NetworkError retry policies rather than as permanent refusals, noting
  later blocks and local channel setup (#6065).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ge and format the removal preview off the main actor

- The contract's moderation hub and every screen pushed from it carry
  the connection they were opened with (ModerationScope); after a
  replacement they show only a notice to reopen the contract, and no
  child reads through the new SDK. The team action detail is gated the
  same way.
- The catalog formats the removal preview record by record off the
  main actor, stops at 64 KiB, drops the full page's cursor when it
  truncates and says how to see every record.
- A reason's moderator-written text sits in its own labelled box with
  bidirectional controls shown, apart from its structured fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-contract-moderation

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

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 22, 2026
…e-contract-moderation

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
#	packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
#	packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
@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.

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