Skip to content

feat(platform)!: compare typed arrays in refersTo where entries (PV14) - #5388

Merged
QuantumExplorer merged 3 commits into
v5.0-devfrom
claude/refers-to-where-typed-arrays
Oct 12, 2026
Merged

QuantumExplorer merged 3 commits into
v5.0-devfrom
claude/refers-to-where-typed-arrays

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

A refersTo reference can say, with where, that the document it points at must hold certain values: "the post this like points at must have the same hashtag as the like". Until now that only worked for single values. A list property (a typed array, such as a post's tags) was refused on either side.

This PR lets where compare lists, in three ways:

  • Same list: "tags": "tags" holds when the like's tags are exactly the post's tags, same elements, same order.
  • contains: "tags": { "contains": "tag" } holds when the post's tags include the document's tag. With "$ownerId" it becomes a writer gate: "members": { "contains": "$ownerId" } means only someone the post lists may write.
  • containsAll: "tags": { "containsAll": "tags" } holds when the post's tags include every one of the document's tags, in any order.

A list a document leaves out counts as an empty list. Elements are compared by value, so an identifier equals its 32 raw bytes and an integer is the same at any width. Protocol version 14 only, which has not shipped.

Before and after

Yappr is moving a post's single hashtag string to tags, a typed array (maxItems 4, uniqueItems, immutable, listed in moderatorAbilities.deleteKeepsFields). Its indexOnly like binds to the post's values through where.

Before, with a single hashtag (registers today):

"postId": {
  "type": "identifier",
  "refersTo": {
    "type": "moderatedDocument",
    "documentType": "post",
    "where": { "hashtag": "hashtag", "$ownerId": "postAuthor" }
  },
  "position": 0
}

Moving the post to tags and the like with it:

"postId": {
  "type": "identifier",
  "refersTo": {
    "type": "moderatedDocument",
    "documentType": "post",
    "where": { "tags": "tags", "$ownerId": "postAuthor" }
  },
  "position": 0
}
  • Before this PR: contract registration refuses it with ReferencedDocumentPropertyAgreementInvalidError (40126), "agreement properties must be single values, not typed arrays". The like has nothing to bind to.
  • After this PR: it registers, and creating a like checks that its tags are the post's tags, in order (40127 when they are not).

The two conditions, before (refused by meta-schema v3, 10101, and by the parser, 10231) and after (registered):

"where": {
  "members": { "contains": "$ownerId" },
  "tags": { "containsAll": "tags" }
}

Issue being fixed or feature implemented

Requested by pasta for Yappr's move from hashtag to tags. The request has three parts; this PR is the where part only:

  • where over typed arrays: this PR.
  • Per-element indexes on indexOnly types: separate work.
  • preallocated / summableOffCountIndex through an array equality: later work, on top of both. This PR keeps both refusing a pair of lists (see below).

What was done?

Types (rs-dpp, property/reference_where.rs)

  • WhereCondition gains two appended variants, Contains(WhereContainsBound) and ContainsAll(String); WhereContainsBound is new and @append_only (Property(path), Writer). Earlier variants keep their encoding.
  • where_lists_equal compares two typed array values as lists, each element pair with Value::same_scalar_data, exactly as a scalar equality compares two values: an integer at any width, bytes whichever variant holds them (an identifier, Bytes, an array of U8s), a string, a boolean. contains compares the same way; containsAll too.
  • containsAll looks each element up in a BTreeSet of the referenced elements, through an order (ListElement) that mirrors same_scalar_data for every value but a float; it looks a wanted float up among the f64 bits of every held number (and a wanted integer among those of every held float), which is exactly how same_scalar_data compares a float, so no input, whole floats carried for an integer list included, makes it quadratic. Both lists can hold up to max_typed_array_items (1024) elements, so a pairwise scan would be up to 1M comparisons per entry, per element reference, all unbilled CPU on block execution. A test checks all three forms against same_scalar_data on a sample of values, floats, -0.0 and integers past 2^53 included.
  • Equalities between lists stay in property_agreement, keyed as today.

Parse and meta-schema (try_from_schema, meta-schema v3)

  • parse_where_condition reads contains (a referring property path or "$ownerId") and containsAll (a referring property path). Both are refused on a referenced $ownerId, $creatorId or $id, and containsAll of the writer is refused. Error messages listing the keys now name both.
  • referenceWhereCondition in meta-schema v3 admits both keys with the same path patterns as the other bounds.

Registration (data_contract_reference_validation v0), all 40126

  • An equality pairs two typed arrays when the referring one is stored (not transient), the elements share one value kind (same_value_kind on items) and are not floats. A typed array paired with anything else is refused.
  • contains: the referenced side is a typed array of non-float elements; the bound is a property of the element kind, or "$ownerId" for identifier elements, never the reference property itself.
  • containsAll: the bound is a stored typed array of the same element kind, never the reference property itself.
  • Through a moderatedDocument reference, a contains of the writer is asked about on every replace, so its list must be kept by every removal record (deleteKeepsFields), the rule orderings bounded by $updatedAt already follow. A rule reading through the reference still keeps every entry to kept fields.
  • const, in, notEqual and the orderings still refuse a typed array.
  • No preallocated or summableOffCountIndex index is keyed through a pair of lists: Index::preallocation_bindings and Index::count_index_derivations bind no index property that is a typed array (a list is no tree key). Both index kinds live only on indexOnly types, which index no typed array today, so this is inert now and keeps them refusing once indexOnly types can index typed arrays, whether the contract is registered or read back. The indexOnly typed-array index refusal is unchanged.

Write time (document_reference_validation v0)

  • The pair loop compares two typed arrays with where_lists_equal, against the document in state and against a moderated document's removal record (a kept field the document held none of is the empty list). Scalar pairs are compared as before.
  • WhereCondition::holds evaluates contains and containsAll; mismatches are 40127 with the condition as written ({ "containsAll": "tags" }).
  • Every list element an entry comparing typed arrays reads is billed before it compares them, against a document in state and against a removal record: both lists for an equality and a containsAll, the referenced list for a contains, at where_list_credits_per_element (100 credits, about a BLAKE3 block's work), a field added in place to FEE_DOCUMENT_REFERENCE_VERSION1, the PV14-only document_reference fee group every schedule carries. Two lists of 1,024 elements bill 204,800 credits.
  • An unreadable referring path for a condition's bound (a path whose way goes through something that is no object) is a mismatch, as an equality's unreadable side already was, rather than absence: a containsAll would otherwise read it as an empty list and hold.
  • Which replace re-checks an entry follows the existing rules: contains of "$ownerId" is re-checked on every replace, like any writer gate; the others when their referring property changes.

Other

  • wasm-dpp2: documentTypeReferences renders contains / containsAll as the schema writes them; TS types updated.
  • Swift (feat(sdk): read the identifier and bytes property type shorthands in long form on iOS and Android #5358 parser) and Kotlin (ParsedContract) do not read where, so nothing changes there.
  • Book: refers-to.md gets a "Typed arrays" subsection, and the registration, replace and error tables are updated; typed-arrays.md no longer says typed arrays cannot appear in where.
  • v14.rs: protocol version 14 note 94.

How Has This Been Tested?

Targeted runs only:

  • cargo test -p dpp --all-features --lib -- reference_where typed_array_where: 19 passed. List equality (order, absence, by-value elements, identifier vs bytes vs U8 array, integer widths, U128 past i128::MAX), contains and containsAll (vacuous empty, absent bound), re-check rules, display, and parse and meta-schema accept and refuse cases.
  • cargo test -p dpp --all-features --lib -- reference where list_element choose_first commit_reveal typed_array: 311 passed.
  • New drive-abci tests (15, all passing):
    • Registration through process_raw_state_transitions: accepted fixture (equality, contains, contains of the writer, containsAll); refused element kind mismatch, list vs scalar, float elements, transient referring list, contains of another kind, of a non-list, of the reference property, of a missing property, writer on non-identifiers, containsAll of a scalar or of another kind, const / notEqual on a list; moderated contains of the writer on an unkept list refused and on a kept one accepted. The old should_reject_agreement_on_typed_array_properties now asserts the fixture registers.
    • Write time: order matters, absent and empty lists, identifier and integer normalization, contains incl. the writer gate, containsAll incl. vacuous empty, a changed list re-checked on replace.
    • Removal record: after a moderator removes the post, a replace keeping the tags is asked only about the writer gate (kept members), reordered tags are refused, and a list the record holds none of equals an empty one.
    • The by-value write test decodes the transition from its bytes as a block does and checks that the create action's data, which the reference check reads, still holds the Bytes and U64 elements as carried.
    • dpp unit test: no preallocation binding or summableOffCountIndex derivation through a pair of typed arrays.
    • Billing, through direct reference validation with the per-element fee at 0 and at 7: each list form bills exactly the elements it reads, a refused write too. An integer list carried as 1,024 Float(1.0) holds against stored [0, 1], and -0.0 does not equal 0.
  • Related existing drive-abci suites (permanent_document_reference_declarations, typed_array_references, agreement, referenced_rules, moderated_document_reference, list_element_reference, preallocated, lookup_reference, owner_reference, reference_expression, deletable_document_reference, commit_reveal): 240 passed.
  • wasm-dpp2: built, DocumentPropertyReference.spec.ts 46 passing (2 new). ESLint could not start in this worktree (an unplugged Yarn package is missing without a full install).
  • cargo clippy -p dpp --all-features --all-targets and cargo clippy -p drive-abci -p wasm-dpp2 --all-targets, -D warnings: clean. cargo fmt --all.

In-place changes to shipped generations

The validation generations below are selected only by protocol version 14, which is unreleased, and are extended in place under their existing gate. The last two rows touch code shipped versions also carry, where the change is unreachable before protocol version 14:

Generation Selected by Why earlier versions are unaffected
Meta-schema v3, parser generation 3 (parse_where_condition) PV14 only Earlier meta-schemas and parsers have no refersTo.
Data contract reference validation 0 Contract create and update state validation 1, PV14 only Not reached before PV14.
Document reference validation 0 Document create and replace state validation, PV14 only Not reached before PV14, and only a PV14 parse produces a where.
FEE_DOCUMENT_REFERENCE_VERSION1 gains where_list_credits_per_element Carried by FEE_VERSION1 to FEE_VERSION3, read by PV14 only The only reader is document reference validation 0, reached from PV14 only; platform states store only fee_version_number, so no stored format changes.
Index::preallocation_bindings and Index::count_index_derivations bind no typed array Unversioned, every PV Only an indexOnly type declares either index, and none can index a typed array (refused under full validation since typed arrays were indexable), so no contract binds through one.

Every contract valid before this PR registers and validates the same way: the only shape that newly registers is a pair of typed arrays (refused with 40126 before), and contains / containsAll were refused by the meta-schema and the parser. Scalar pairs and the existing conditions take the same code path as before.

Breaking Changes

Consensus change at protocol version 14 (unreleased): contracts with the new where shapes register, and writes are judged against them. Appended variants on WhereCondition and the new WhereContainsBound change nothing for existing encodings.

Overlap with other work

Possible follow-ups

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have 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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 8296210

  • Bots — coderabbitai not yet · 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
    • js-wasm-sdk (packages/js-evo-sdk/README.md) — shumkov
    • dpp — you own it
    • rs-drive-abci — you own it

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
    • Document references can now compare typed arrays when both sides use compatible element types. Equality requires the same elements in the same order.
    • Added contains to check for a matching element and containsAll to check that every referring-array element appears in the referenced array, regardless of order.
    • Missing arrays are treated as empty. Moderated references recheck applicable writer conditions on replacement and can validate retained arrays after removal.
  • Documentation
    • Documented supported array conditions, matching rules, and registration constraints.

A refersTo `where` entry may now compare a referenced typed array as a list:
an equality between two typed arrays (same elements, same order),
`{ "contains": b }` (a referring value of the element kind, or "$ownerId" as a
writer gate on identifier elements) and `{ "containsAll": b }` (every element
of a referring typed array). Elements compare by value, and a list a document
leaves out is the empty one.

WhereCondition gains the appended Contains and ContainsAll variants and the
new WhereContainsBound. Meta-schema v3 and parser generation 3 read the keys;
data contract reference validation 0 admits a pair of stored typed arrays of
one non-float element kind and checks the conditions (40126); document
reference validation 0 judges them against the document found or a moderated
document's removal record (40127). A pair of lists never keys a preallocated
or summableOffCountIndex index. All in place under protocol version 14.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 40ae32a8-40cb-4bec-8891-ce058348eaf1

📥 Commits

Reviewing files that changed from the base of the PR and between 371a3b3 and 9298334.


📒 Files selected for processing (19)
  • book/src/contract-keywords/refers-to.md
  • book/src/contract-keywords/typed-arrays.md
  • packages/rs-dpp/schema/meta_schemas/document/v3/document-meta.json
  • packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs
  • packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/mod.rs
  • packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/typed_array_where_tests.rs
  • packages/rs-dpp/src/data_contract/document_type/property/mod.rs
  • packages/rs-dpp/src/data_contract/document_type/property/reference_where.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/typed_array_where.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/typed_array_where.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/data_contract_reference_validation/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs
  • packages/rs-drive-abci/tests/supporting_files/contract/reference-validation/reference-validation-contract-where-typed-arrays.json
  • packages/rs-platform-version/src/version/v14.rs
  • packages/wasm-dpp2/src/data_contract/document_type_reference.rs
  • packages/wasm-dpp2/tests/unit/DocumentPropertyReference.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Reference where declarations now support ordered typed-array equality and the contains and containsAll conditions. Contract registration validates list kinds, bounds, and index constraints. Document validation evaluates these conditions, including against retained fields for moderated references. The conditions are also exposed through WASM and documented.

Changes

Typed-array reference conditions

Layer / File(s) Summary
Define and parse typed-array conditions
packages/rs-dpp/schema/meta_schemas/document/v3/document-meta.json, packages/rs-dpp/src/data_contract/document_type/property/reference_where.rs, packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/..., packages/rs-dpp/src/data_contract/document_type/property/mod.rs
The condition model adds ordered list equality and the contains and containsAll forms. The schema and parser accept the new condition forms. Tests cover parsing and element comparisons.
Validate conditions at registration
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/data_contract_reference_validation/v0/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs, packages/rs-drive-abci/tests/supporting_files/contract/reference-validation/*
Registration accepts compatible typed-array pairs and validates list-condition bounds. It rejects unsupported element kinds, incompatible or transient lists, and list comparisons that fix an index. Moderated references require rechecked fields to be retained in removal records.
Evaluate references during document writes
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/*, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests/*
Document validation compares typed-array agreements and evaluates membership conditions. Removal-record checks compare retained lists. Tests cover equality, membership, replacement, and moderated-document behavior.
Expose and document the conditions
packages/wasm-dpp2/src/data_contract/document_type_reference.rs, packages/wasm-dpp2/tests/unit/DocumentPropertyReference.spec.ts, packages/rs-platform-version/src/version/v14.rs, book/src/contract-keywords/*
The WASM reference type and serializer expose contains and containsAll. The reference documentation and v14 release notes describe list matching, registration constraints, and moderated-reference checks.

Priority: ➖ Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Contract as try_from_schema
  participant Registration as data_contract_reference_validation
  participant Write as document_reference_validation
  participant Record as Moderated removal record
  Contract->>Registration: Parse and validate typed-array conditions
  Write->>Registration: Use registered reference agreements and conditions
  Write->>Record: Read retained list values after moderated removal
  Write->>Write: Compare lists and evaluate contains or containsAll
Loading

Merge Risk: ⚪ Minimal · up to 92983

No actionable issue was established for the typed-array reference conditions; the change is mergeable after normal checks.

Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 84.72% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 72 functions across 15 files. (4 skipped: 4…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding typed-array comparisons to refersTo.where entries for protocol version 14.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 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

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

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai ✓ · 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 Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 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-10-12T19:18:55.524Z

@github-actions github-actions Bot added this to the v5.0.0 milestone Oct 12, 2026
@thepastaclaw

thepastaclaw commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress — actively reviewing now (commit 8296210) · triage: critical
████░░░░░░░░░░░░░░░░ 19% · about 35 min left · running for 8 min
✅ triage → ⏳ Phase 2 (2/6 lanes) → ⏳ Phase 1 (0/2 lanes) → ▫️ verify 2 → ▫️ fresh Phase 2 → ▫️ fresh verify → ▫️ publish
Estimated from recent reviews of this tier · updated 19:28 UTC · live progress

Review follow-ups for refersTo `where` over typed arrays (PV14):

- List equality, `contains` and `containsAll` compare elements with
  `Value::same_scalar_data`, as a scalar equality does. `containsAll` keeps
  its set lookup through an order that mirrors that comparison for every
  value but a float, which it compares one by one.
- A `where` bound whose referring path is no object on the way is refused as
  a mismatch, as an equality's unreadable side is, instead of reading as
  absent (a `containsAll` held on it).
- `Index::preallocation_bindings` and `Index::count_index_derivations` bind no
  typed array index property, replacing the registration-only guard.
- The unreachable list arm in registration is a corrupted-code error, the
  parse comment names the moderated `contains` writer gate, and the
  moderation test helpers are shared from `tests.rs`.
- Tests pin the meta-schema refusal, the stored read-back and the decoded
  action data of the by-value write; js-evo-sdk README lists the new shapes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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

@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 typed-array comparison feature is gated to unreleased PV14, but its new validation work is not metered, and containsAll retains an attacker-reachable quadratic float fallback. One blocking finding and one test-coverage suggestion remain after verification and deduplication. This was a static review of the exact head; the supplied CI snapshot still had Rust workspace tests, JS and Docker builds, and Kotlin build/tests pending.

🔴 1 blocking | 🟡 1 suggestion(s)

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change to consensus-critical document-reference validation and peer-facing contract/schema deserialization, including new protocol-versioned rules and serialized enum variants.
  • 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 below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-dpp/src/data_contract/document_type/property/reference_where.rs`:
- [BLOCKING] packages/rs-dpp/src/data_contract/document_type/property/reference_where.rs:563-579: Meter typed-array where comparisons before executing them
  The new list comparisons run during document-reference state validation without recording their processing work. The state-document pair/condition loops and validate_pairs_against_removal call where_lists_equal or WhereCondition::holds without adding comparison-cost operations; StateTransitionExecutionContext::fee_cost only sums recorded operations. Existing read and hash charges do not account for repeated list scans or BTreeSet construction, so additional where entries and references multiply unmetered validator CPU.

  The float fallback also defeats the intended near-linear containsAll implementation. Refusing float element schemas at registration does not exclude Value::Float(1.0) carried under an integer schema: validate_document_properties_v1 converts it to JSON, and the pinned jsonschema integer validator accepts numbers whose fractional part is zero. The create transformer preserves those original values. A held integer list of 1,023 zeros followed by one, compared against 1,024 copies of Float(1.0) with uniqueItems disabled, therefore performs 1,048,576 scalar comparisons. The field-size check examines individual scalar values rather than the aggregate array, so it does not exclude this example. The sponsor-dependent CheckTx path executes state validation before dry-run fee validation; a later condition mismatch rejects the transaction without committing fees or nonces, allowing this work to be repeated even if integer storage encoding would subsequently reject the floats.

  Add deterministic PV14 processing-cost accounting for equality, contains, and containsAll in both live-document and removal-record validation. Also replace the per-float full-list scan with a numeric lookup preserving same_scalar_data's float-bit semantics, so accounting alone does not leave the unpaid CheckTx rejection path quadratic. Cover the integer-schema/float-bound case through sponsored CheckTx.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/property/reference_where.rs:974-995: Cover the remaining list-element normalization variants
  The cross-product test is the regression guard for ListElement matching same_scalar_data, but its sample omits Bytes20, Bytes32, Bytes36, and EnumString, all of which have explicit normalization arms in the new implementation. In particular, the fixed-size byte variants should be checked against Bytes, Identifier, and U8 arrays, rather than only against themselves. Add these variants and representatives of the remaining signed and unsigned integer widths to the sample so changes to those arms cannot silently alter containsAll relative to scalar equality.

@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 bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 12, 2026
Review follow-ups for refersTo `where` over typed arrays (PV14):

- Document reference validation bills the list elements a `where` entry
  comparing typed arrays reads before it compares them, against a document in
  state and against a moderated document's removal record:
  `where_list_credits_per_element` (100 credits) of the PV14-only
  `document_reference` fee group, added in place to
  `FEE_DOCUMENT_REFERENCE_VERSION1`.
- `containsAll` looks a wanted float up among the `f64` bits of every held
  number, and a wanted integer among those of every held float, instead of
  scanning the list for each float: a list of whole floats carried for an
  integer list stays near-linear, with `same_scalar_data`'s semantics kept.
- Tests: the billed elements for each list form, an integer list carried as
  1,024 floats and as `-0.0`, and the scalar cross-check over every value
  variant (fixed-size byte variants, `EnumString`, each integer width, NaN),
  with the whole sample held at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot 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 bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 12, 2026
@QuantumExplorer
QuantumExplorer merged commit 36c964f into v5.0-dev Oct 12, 2026
17 of 19 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/refers-to-where-typed-arrays branch October 12, 2026 19:27
QuantumExplorer added a commit that referenced this pull request Oct 12, 2026
…-where

#5388 and #5390 are merged (squashed, with their review fixes). Resolved as
v5.0-dev plus this branch's own changes: the export list keeps
where_list_elements beside where_lists_elements_read, note 94 keeps the
element billing and points at 95, note 92 now says preallocated and counter
array indexes follow 95, and the book keeps both the commitment billing and
the per-element keying.
@QuantumExplorer QuantumExplorer mentioned this pull request Oct 13, 2026
8 of 26 tasks
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