Skip to content

feat(dpp): contract corpus test and typed validation schema for document types - #5486

Merged
QuantumExplorer merged 27 commits into
v5.1-devfrom
claude/contract-corpus-typed-constraints
Oct 22, 2026
Merged

QuantumExplorer merged 27 commits into
v5.1-devfrom
claude/contract-corpus-typed-constraints

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Two pieces of groundwork for checking documents with Platform's own code instead of a third-party JSON Schema library. First, a test corpus: every data contract on mainnet and one copy of each distinct contract on testnet, as a node serves them, with a test that loads all of them. Second, a typed copy of each document type's schema that keeps every rule the library checks a document against (lengths, patterns, allowed values and so on) as named fields, built from exactly the schema the library checks documents with today. Rules a document type declares beside its schema, such as propertyConstraints, are checked by document validation in a step of its own and are not part of it.

Value: Later work on contract validation and storage can be tested against the 749 contracts (1,503 document types) the networks actually hold, before it reaches a network. The typed schema is what a native document validator will read, and the tests already prove it holds every JSON Schema rule of every live document type.

Risks: Low. Nothing in consensus calls the new code at any protocol version, and no existing code changes behaviour. The corpus adds about 2.3 MB of JSON test fixtures to the repository. The new tests run in under a second.

Issue being fixed or feature implemented

Document validation runs through a fork of the jsonschema crate, and every stored contract keeps its schemas as raw values that are re-parsed on load. The plan for protocol version 15 is to compile document types at registration and validate documents natively. Both need two things first: a way to check a change against every contract a network holds, and a typed form of the schema that says exactly what the current validator enforces.

Refs #5271: this adds the contract corpus that issue asks for and loads every contract as Drive does. It does not yet load them with full validation, or at the protocol version each was registered under.

What was done?

Contract corpus (packages/rs-dpp/tests/fixtures/contract_corpus/)

  • mainnet.jsonl: all 55 mainnet contracts. testnet.jsonl: 694 testnet contracts, one per distinct set of document schemas, $defs, tokens and groups (testnet holds 3,982, mostly repeats). Each line holds the contract's bytes as a node serves them, base64: the node serializes the stored contract again at its own protocol version, so every line is in the V1 format and the corpus does not exercise decoding the V0 format older contracts are stored in. The README says where they came from and how to regenerate them.
  • tests/contract_corpus.rs loads each contract as Drive does (versioned_deserialize_trusted, no full validation) at protocol version 14 and at the latest version, loads mainnet's also at 13, which mainnet runs, and reloads each after a serialization round trip.

Typed validation schema (data_contract/document_type/schema/validation_schema)

  • ValidationSchema { root, references } and SchemaNode, one typed field per keyword that constrains a value: type, enum, const, properties, required, additionalProperties, min/maxProperties, dependentRequired, items, contains, min/maxItems, uniqueItems, byteArray, min/maxLength, maxBytes, pattern, format, encryptedFor, the numeric bounds and multipleOf. Numbers, enum, const and encryptedFor are read from the JSON the document validator converts the schema to: integers are 64-bit, bytes and identifiers are arrays of integers, a repeated key keeps its last value, and what the conversion cannot represent (a non-finite float, an integer beyond 64 bits) is refused. The field docs say how the validator compares what they hold: enum exactly (1 equals 1.0, objects key by key in written order), a number const in f64 within f64::EPSILON, uniqueItems by value up to 15 elements and by JSON form above, and multipleOf in f64 with a one-sided test under a fractional divisor.
  • $ref, type, enum and const sit inline on the node; every other group's keywords sit in a boxed struct (ObjectConstraints, ArrayConstraints, StringConstraints, NumberConstraints, FormatConstraints) allocated only when the node uses that group. A node is 160 bytes, and the corpus's 13,491 nodes and their groups take 4.06 MB (a flat struct with one field per keyword took 720 bytes a node, 9.71 MB).
  • DataContract::document_type_validation_schema builds it from the schema the document validator compiles: the document type's schema with the contract's $defs and the base schema added, its property type shorthands expanded.
  • It follows JSON Schema where the document type parser differs: keywords beside a $ref are kept with the reference, required is kept per object as the validator compiles it (including names no property carries; at the root, without the system times and heights the base schema enrichment removes), and the root object's own keywords are kept.
  • Each schema a $ref reaches is kept once, under the reference, so cyclic references stay references. Only JSON pointers into the document schema are held: # or #/..., without %, whitespace or control characters, whose text is exactly the pointer the validator follows after it parses the reference into a URL and percent-decodes its fragment. Any other reference is refused: registration resolves every $ref as a pointer below #/ anyway, and all 175 references in the corpus are such pointers. A pointer is followed as the validator follows it: each segment ~0/~1 unescaped, an array index taking no sign or leading zero, and a repeated map key reaching its last entry.
  • maxBytes and encryptedFor, which JSON Schema leaves alone, are read by the document type parser, so the tree holds them only where the parser reads a property. The builder refuses them beside a property's $ref (whose definition the parser reads in its place), below the keywords written beside it, in a schema only the validator reads, and inside contains; maxBytes is also held on the items of a typed array. It refuses byteArray inside contains, where the validator's match check always accepts it, byteArray: false, which the validator checks as true, a property $ref the parser resolves to another schema than the validator does, a property, or the document schema's properties, repeated with maxBytes, encryptedFor or a $ref where the parser reads them (the entry itself, and down its properties and items), whose entries the parser and the validator read differently (of a name the document schema's own properties repeat, the parser keeps the entry with the highest position, so one whose last entry has it builds), and a required repeated with other names, the parser requiring those of the first entry and the validator those of the last. No corpus contract uses any of these forms.
  • Keywords are SchemaKeyword, an enum of groups. Six the node holds: Any ($ref, type, enum, const), Object, Array (byteArray included: it refuses any value that is not an array of bytes), String, Number, and Format (format, encryptedFor: what kind of string or byte array a value is, beyond its JSON type). Four it does not: Relationship (refersTo, distinctFrom, generatedFrom), which consensus checks against more than the value; Resolution ($id), which changes how the validator resolves a $ref; Storage (position, requiredSince, contentMediaType), which say how the document type parser stores the property (draft 2020-12 compiles nothing for contentMediaType; Platform reads it only to type an identifier); and Annotation. SchemaKeyword::checked_by says what checks a value against each keyword: the JSON Schema validator, consensus on the property the parser builds (maxBytes, encryptedFor), consensus against more than the value (relationships), or nothing; the builder reads it, and a test ties it to the validator's keyword table. The builder and SchemaNode::value_of match on the groups exhaustively, so a keyword added to a group without being handled does not compile.
  • Keys: anywhere in the tree, a key the validator compiles there that the tree does not hold (not, anyOf, ...) is refused, and any other key that is not a SchemaKeyword is skipped, as the validator ignores it. then, else, if, minContains, maxContains and additionalItems count as compiled only beside the keyword they work with. The meta-schemas refuse such keys at registration wherever they restrict a schema, and a test ties every key they admit to a SchemaKeyword. At the root, what the validator's draft 2020-12 meta-schema check refuses is refused too, since the validator then compiles nothing: among them a required or type list naming an entry twice, a multipleOf not above 0, annotation and content keywords of the wrong type, and an $id or $ref its uri-reference format refuses (the check runs under draft 7 rules and reaches no schema below the root). Root values are read as the JSON the validator compiles, so bytes are an array. A format, pattern or dependentRequired the pinned validator does not compile is refused: a $ref reaching it refuses every value. A pattern is compiled as the validator of a contract loaded from state compiles it, under the regex crate's default size limit; registration's smaller 5 MiB limit never admits a pattern that limit refuses.
  • $id: the validator resolves a $ref against the $ids above it, looks it up among the schemas an $id names before it follows the pointer, and compiles nothing when an $id does not join. The builder refuses a document schema $id, and any other $id that is not a plain name (ASCII letters, digits, _, -, .), wherever it is written. A plain name resolves to a json-schema: URL, which the validator treats as no $id at all, and names no fragment, so every reference the tree holds reaches the schema at its pointer. Ten corpus document types carry an $id, all plain names in Platform keyword data (a refersTo findBy, an ownerRefersTo where); they build.
  • DataContract::document_type_validation_schema is the entry point (ValidationSchema::try_from_root is crate-private, since it needs the enriched, shorthand-expanded root) and refuses protocol versions before 14, whose parser reads neither maxBytes nor encryptedFor.
  • The module sits behind a new validation-schema feature, which validation enables and which makes url an optional dpp dependency, used to check the URIs the validator's meta-schema check reads at the root. It does not need json-schema-validation (the jsonschema crate), so the native validator can build on it alone, and a default dpp build does not pull in url or its idna/ICU dependencies.

Example: a property that refines a shared definition.

"label": { "$ref": "#/$defs/label", "maxLength": 5, "position": 0 }

Before: the only typed form was the parsed DocumentProperty, which reads #/$defs/label alone; maxLength: 5 existed only in the raw schema value the validator compiles.

After:

SchemaNode {
    reference: Some("#/$defs/label".into()),
    string: Some(Box::new(StringConstraints {
        max_length: Some(5),
        ..
    })),
    ..
}
// and references["#/$defs/label"] holds the definition's own keywords

How Has This Been Tested?

  • cargo test -p dpp --test contract_corpus: all 749 contracts load at protocol version 14 and latest, mainnet's 55 also at 13, and survive a serialization round trip. Every one of the 1,503 document types builds a validation schema, and for each, the tree (and every reference it reaches) holds exactly the validation keywords of the schema the validator compiles, compared as the validator reads both: converted to JSON, whose objects compare regardless of key order.
  • cargo test -p dpp --lib validation_schema: 56 tests in the module. Unit tests cover each keyword and its name, which keyword groups a node allocates, keywords beside a $ref, cyclic references, a reference to the root, escaped pointers and array indices, unresolved references, references that are not JSON pointers and $ids that are not plain names (refused), plain-name $ids above and on the path to a reference (built), protocol versions before 14 (refused) and 14 (accepted), enum/const/bounds/encryptedFor read as the validator's JSON, unknown formats, uncompilable patterns and duplicate dependentRequired names, keys the validator ignores or compiles (keywords it compiles only beside another included) in any schema, at the root and in system-property schemas, what its meta-schema refuses at the root, Platform keywords where consensus checks them (kept) and where it does not (refused, naming the reference that reached them), property references the parser resolves elsewhere or not at all, repeated properties and required, required names no property carries, and the parser's read through referenced schemas and items. Differential tests run cases through the existing validator: references below plain-name $ids, array indices, an unknown format a $ref reaches, patterns (one between registration's 5 MiB limit and the regex default is held), an applicator and what the meta-schema refuses at the root, keywords standing alone, the documented const, multipleOf, uniqueItems and enum comparisons, and the Platform keywords through validate_document_properties on contracts registered with full validation. Probes: every document meta-schema version's keywords are classified; each listed validator keyword constrains a value and each other draft 2020-12 keyword probed is ignored; each format compiles or not as listed; every root key of the bundled draft 2020-12 vocabularies, with values of each JSON type, is refused whenever the validator compiles nothing for it. A generated test builds 600 schemas of the keywords the tree holds, with keys the validator ignores among them: the builder refuses each the validator compiles nothing for, and each of the 581 it builds, written back from the tree, gets the validator's verdict on 34 documents that the original gets.
  • cargo test -p dpp --lib property_type_shorthand_tests: contracts stored at protocol version 13 with a shorthand shadowed by a repeated key build a validation schema.
  • cargo clippy -p dpp --all-features --lib --tests -- -D warnings.

In-place changes to shipped generations

  • DocumentType::expand_property_type_shorthands v0 (schema/expand_property_type_shorthands/v0/mod.rs), selected by protocol versions 14 and 15 through CONTRACT_VERSIONS_V6: its private last_value helper moved to schema/mod.rs as pub(crate) with its body unchanged, and v0 imports it. Consensus cannot change there: the body, the signature and all four call sites are the same, so every output and error is the same. A comment at the import says so, and the helper's doc now says its rule is consensus behavior, so a reader that needs another rule must use a new helper.

Breaking Changes

None.

Checklist:

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

  • Bots — coderabbitai not yet · thepastaclaw ✓ — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Build running
  • Approvals — you own every area touched; none needed

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.

QuantumExplorer and others added 2 commits October 18, 2026 17:43
… corpus

Adds the data contracts registered on mainnet (all 55) and testnet (694,
one per distinct set of schemas, $defs, tokens and groups) as Drive stores
them, and a test that loads each one at protocol version 14 and at the
latest version, and reloads it after a serialization round trip. Changes
to how contracts are parsed, validated, serialized or stored can now be
checked against every contract a network holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds ValidationSchema, a document type's JSON schema as the document
validator compiles it (with the contract's $defs and the base schema added
and its shorthands expanded), held as one typed field per keyword that
constrains a value. It follows JSON Schema where the document type parser
differs: keywords beside a $ref are kept with the reference, `required` is
kept per object as written, and the root object's own keywords are kept.
Every schema a $ref reaches is built once and kept by reference, so cyclic
references stay references.

The builder refuses any keyword below the root that it neither reads nor
lists as an annotation or Platform keyword, and a test fails if a document
meta-schema ever admits a keyword it does not classify. Over the contract
corpus, every one of the 1,503 mainnet and testnet document types builds,
and each tree holds exactly the validation keywords of the schema the
validator compiles today.

Nothing reads it yet at any protocol version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added this to the v5.1.0 milestone Oct 18, 2026
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e816349c-d931-41ce-8be7-16eaa852c51d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

❤️ Share

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

@thepastaclaw

thepastaclaw commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 3002759) · triage: normal

QuantumExplorer and others added 6 commits October 18, 2026 18:30
Replaces the VALIDATION_KEYWORDS and NON_VALIDATING_KEYWORDS string arrays
with SchemaKeyword, an enum of keyword groups: Any ($ref, type, enum,
const), Object, Array, String, Number, Annotation and Platform, each its
own enum. The builder and SchemaNode::value_of match on them exhaustively,
so a keyword added to a group without being handled no longer compiles,
and to_value walks SchemaKeyword::iter() instead of keeping its own order.
SchemaKeyword::constrains_a_value tells the groups the node holds from the
two it ignores.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds FormatKeyword for the keywords that say what kind of string, number
or byte array a value is beyond its JSON type: `format`, `byteArray` and
`contentMediaType`. They move out of StringKeyword and ArrayKeyword, and
SchemaNode's fields follow the group order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hema

`maxBytes` bounds a string's UTF-8 bytes. JSON Schema leaves it unchecked
and the document validator checks it right after, but it is a bound on one
string value like `maxLength`, so it moves from PlatformKeyword to
StringKeyword and SchemaNode holds it as `max_bytes`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n schema

`encryptedFor` is not an annotation: consensus refuses a document whose
encrypted bytes do not have a length the scheme produces (10420), and
registration checks the properties it names. It says what kind of byte
array a value is, so it moves from PlatformKeyword to FormatKeyword and
SchemaNode holds the declaration as the existing EncryptedFor type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PlatformKeyword grouped its keywords by who reads them rather than by what
they are. It becomes two groups: RelationshipKeyword (`refersTo`,
`distinctFrom`, `generatedFrom`), which tie a value to another document,
identity, key or property and which consensus checks, though not from the
value alone; and MetaKeyword (`position`, `requiredSince`), which describe
the property within the schema, its place in the stored document and the
contract version it is required from.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a holds

`TypeKeyword` is the parsed value of the `type` keyword, not a group of
keyword names like the `*Keyword` enums beside it, so it becomes
`JsonTypes`. The module doc now says the validation schema also holds the
two per-value keywords JSON Schema leaves alone, `maxBytes`, which the
document validator checks right after, and `encryptedFor`, which the
validation of a create or replace checks, and names the groups it leaves
out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@QuantumExplorer
QuantumExplorer marked this pull request as ready for review October 18, 2026 17:16
@github-actions

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 the waiting-bots Waiting for the review bots to report on this head label Oct 18, 2026
SchemaNode held one field per keyword, so every node paid for all of them:
720 bytes, most of them empty (the five numeric bounds alone took 240 bytes
on every string and object). The keywords of each group now live in their
own struct, ObjectConstraints, ArrayConstraints, StringConstraints,
NumberConstraints and FormatConstraints, boxed and allocated only when the
node carries a keyword of the group; `$ref`, `type`, `enum` and `const`
stay inline.

A node is now 160 bytes. Over the contract corpus's 13,491 nodes, nodes and
groups take 4.06 MB instead of 9.71 MB, and the largest contract 37 KB.

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

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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 additive schema builder is isolated from current consensus execution and is appropriately placed in DPP. Static verification at head 3025022 confirmed three non-blocking correctness gaps in schema representation and reference resolution. Rust workspace tests and the other completed code checks pass; PR Hygiene remains pending, and no local builds or tests were run.

🟡 3 suggestion(s)

Review provenance

Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change adds substantial typed schema parsing, reference handling, and corpus tests, but does not alter active consensus validation, persisted serialization, or another critical surface.
  • Phase 1 reviewers: gemini-3.8-flash-high — general (completed, effort high); agent phase1-reviewer, gemini-3.8-flash-high — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: gemini-3.8-flash-high — antigravity quota: weekly 71% left, 5h 100% left
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:554-555: Represent the full schema grammar admitted under contains
  The document meta-schemas v0–v3 reference the draft 2020-12 applicator definition for `contains`, rather than restricting its value to Platform's `documentSchema`. That definition admits boolean schemas and general applicators. Consequently, an otherwise valid byte-array property can contain `"contains": true`, `"contains": false`, or `"contains": {"not": {"const": 0}}`. The pinned jsonschema implementation compiles these values, but this builder rejects the booleans because `build_node` requires a map and rejects `not` because it is not classified. The typed representation therefore cannot hold every schema the existing validator accepts. Add a boolean-or-object schema representation and support the broader grammar reachable through `contains`, with registration-to-builder regression coverage. The existing keyword-classification test only inspects the immediate `documentSchema` and `documentArrayItem` property lists, so it cannot detect this gap. This remains non-blocking because the builder has no production callers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:614-620: Percent-decode the fragment before splitting pointer segments
  The pinned jsonschema dependency percent-decodes the complete fragment in `resolver.rs::resolve_fragment` before passing it to JSON Pointer traversal. This implementation instead checks the leading slash and splits first, then decodes each segment. For example, `#/$defs/wrapper%2Fproperties%2Flabel` should traverse `$defs` → `wrapper` → `properties` → `label`, but this code looks for a single definition named `wrapper/properties/label`, either failing or selecting a different schema. A percent-encoded leading slash is also rejected before decoding. Decode the complete fragment first, then check the leading slash, split into tokens, and apply `~1`/`~0` unescaping. Add an encoded-separator regression test; the existing encoded-space test does not exercise this difference.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:231-232: Reuse the root node when resolving a root reference
  `resolve_pointer` explicitly accepts `"#"` and returns the root, but this call then rebuilds that root with `is_root: false`. A root carrying `$schema` or `$defs` consequently fails as an unsupported nested keyword, although its initial construction succeeded. This makes the public builder's cyclic-reference support inconsistent: a cycle through definitions works, while a root cycle fails solely because the root carries metadata. Reuse the already-built root node for `"#"` and add a regression test with root metadata. This concerns direct `try_from_root` behavior, not an existing on-chain failure: current contract admission separately rejects `"#"` through `resolve_uri`'s `"#/"` requirement.

…idator does

- Percent-decode a `$ref`'s whole fragment before splitting it into
  pointer segments, as the pinned jsonschema resolver does, so `%2F`
  separates segments and an encoded leading slash is accepted. A `%` not
  followed by two hex digits is kept as written, as `percent-encoding`
  keeps it.
- Reuse the root node for a `$ref` of `#` instead of rebuilding the root
  as a nested schema, where its `$schema` and `$defs` were refused.
- Document that a `contains` schema is held only when it is made of
  schema keywords, although the meta-schemas admit any schema there.

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

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

At head 7ff5431, the changes are additive DPP groundwork with no production callers or changes to existing consensus execution. The root-reference and fragment-decoding findings are fixed; two non-blocking schema-parity gaps remain involving contains and repeated map keys. Verification was static only; current CI still has Rust workspace tests and the JS build pending, with no failed code checks reported.

🟡 2 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The substantial typed-schema parser and corpus tests require careful logic review, but the diff does not change consensus execution, existing validation behavior, or another critical surface.
  • Phase 1 reviewers: gemini-3.8-flash-high — general (completed, effort high); agent phase1-reviewer, gemini-3.8-flash-high — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: gemini-3.8-flash-high — antigravity quota: weekly 71% left, 5h 100% left
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:520-525: Apply last-wins map semantics before building schema children
  The existing validator's `try_to_validating_json()` collapses repeated map keys to their last value, but this builder visits shadowed entries too. This affects accepted historical inputs: `contracts_with_unread_shorthands` in `class_methods/try_from_schema/v3/property_type_shorthand_tests.rs` constructs contracts registered at protocol 13 with an earlier `type: "bytes"` property shadowed by a valid string property. Those contracts load at protocol 14 with their raw schemas preserved, but this builder visits the shadowed property and rejects its unsupported type. Repeated schema keywords have the same problem: an overwritten `$ref` remains queued and can fail resolution, while `resolve_pointer` selects the first matching map entry rather than the validator's last. Apply last-entry-wins semantics before building schema children or queuing references, and during pointer lookup. Add regressions using explicit repeated-key maps and the existing historical contract cases. This is non-blocking while the representation has no production callers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:564-565: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  The documented restriction still leaves a compatibility gap with admitted contracts. Document meta-schemas v0–v3 take `contains` from the draft 2020-12 applicator vocabulary, which permits boolean schemas and general applicators. The pinned validator compiles these, but `contains: false` fails here because `build_node` requires an object, and an object containing `not` fails as an unsupported keyword. The corpus establishes that its captured contracts do not need this grammar; it does not prevent a contract using it from being registered before the planned v15 restriction. Restricting registration at v15 would not preserve validation for that already-stored contract. Support the admitted grammar or link a follow-up explicitly covering pre-activation compatibility and registration-to-builder regression coverage; the deferral currently has no tracking reference. This remains non-blocking because the builder has no production callers.

The document validator converts a schema map to a JSON object with its
order preserved, so a repeated key keeps the place of its first entry and
takes the value of its last. The validation schema builder visited every
entry instead: a shadowed property or keyword was built (and refused when
its type was unknown), an overwritten `$ref` was still resolved, and a
pointer segment matched the first repeated key rather than the last.

Keyword maps, `properties` and `dependentRequired` are now read last entry
wins in the place of the first, and pointer lookup takes the last matching
key. Contracts stored at protocol version 13 with a shorthand shadowed by
a repeated key now build a validation schema.

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

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

Static verification of head fabf854 confirms that three prior findings are fixed; two non-blocking schema compatibility gaps remain. The new representation has no production callers and does not change existing consensus execution. No builds or tests were run locally; current CI still has Rust workspace tests and the JS build pending, with no failed code checks reported.

🟡 2 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change adds substantial schema parsing and reference-resolution logic plus corpus tests, but does not alter active consensus rules, network deserialization, or persisted storage formats.
  • Phase 1 reviewers: gemini-3.8-flash-high — general (completed, effort high); agent phase1-reviewer, gemini-3.8-flash-high — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: gemini-3.8-flash-high — antigravity quota: weekly 71% left, 5h 100% left
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/keyword.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/keyword.rs:153-156: Resolve named subschemas before discarding $id
  JSON-pointer-shaped references do not make `$id` inert in the pinned jsonschema implementation. At aacc1ab, `Resolver::new` indexes named subschemas and `resolve_fragment` checks that index before traversing a pointer. For example, if `$defs.label` has `maxLength: 10` and a string property declares `$id: "#/$defs/label"` with `maxLength: 1`, another property referencing `#/$defs/label` is checked against the named property by the existing validator. This builder discards `$id` and resolves the structural definition instead, recording 10 rather than 1. Platform's document meta-schemas admit these nested fragment identifiers, and the pinned standard meta-validator does not recursively reject them because its `$dynamicRef` traversal is unsupported. Account for named-schema lookup before dropping identifiers, or explicitly reject collisions that cannot be represented, and add a differential regression against the existing validator. The corpus comparison cannot detect this discrepancy because its expected-value resolver also follows raw pointers and removes `$id`. This is non-blocking while the builder has no production callers.

In `packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:571-572: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  Document meta-schemas v0–v3 delegate `contains` to the general JSON Schema applicator vocabulary, admitting boolean schemas and compositions such as `not` and `anyOf`. This branch instead requires an object containing only classified keywords, so it cannot represent those admitted inputs. The documented absence of `contains` from the captured corpus limits current exposure, but registrations before protocol-15 activation can still introduce these schemas; restricting registration at activation would not address contracts accepted beforehand. Support the admitted grammar or link a tracking issue defining the compatibility policy for pre-activation contracts as a prerequisite for adopting this builder. The documentation acknowledges the limitation, but no such follow-up is linked in the supplied discussion. This remains non-blocking because the representation has no production callers.

…n schema

The pinned JSON Schema validator indexes every object carrying an `$id`
(outside `enum` and `const`) and resolves a `$ref` through that index
before following its pointer, so a subschema with `$id: "#/$defs/label"`
captures references to `#/$defs/label`. The validation schema follows the
pointer only, so it now refuses a schema that reaches a `$ref` while a node
it builds carries an `$id`, or while any `$id` of the schema is a fragment.
An `$id` that is neither, such as the one a reference's `where` condition
matches on testnet, names a URL no fragment reference reaches and is still
built. `$id` moves from the annotation keywords to the meta keywords, since
it is not inert.

A differential test checks the existing validator does resolve through the
`$id`.

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

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

Static verification of head 094bba9 confirms three non-blocking compatibility issues in the new typed-schema builder; its placement in DPP is appropriate and no existing consensus path calls it. Two prior findings are fixed, while identifier resolution, shadowed-map traversal, and contains compatibility remain actionable suggestions. No builds or tests were run locally; current CI shows Rust workspace tests passing, with JavaScript and Swift SDK builds still pending.

🟡 3 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change adds substantial schema-parsing logic and corpus coverage, but the diff does not activate consensus behavior or change another critical runtime surface.
  • Phase 1 reviewers: gemini-3.8-flash-high — general (completed, effort high); agent phase1-reviewer, gemini-3.8-flash-high — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: gemini-3.8-flash-high — antigravity quota: weekly 71% left, 5h 100% left
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:433-438: Resolve named subschemas before discarding $id
  The fragment-prefix check misses absolute identifiers that resolve to the same URL as a fragment reference. For example, a string property's examples can contain {"$id":"json-schema:///#/$defs/label","type":"string","maxLength":1}, while the structural $defs.label has maxLength: 10 and another property references #/$defs/label. The document meta-schema permits arbitrary example values. In the pinned aacc1ab resolver, find_schemas traverses examples and indexes this absolute identifier, and resolve_fragment consults that index before following the pointer. The example is not a built node and its identifier does not start with '#', so neither refusal guard fires: the builder records 10 although the existing validator enforces 1. Determine identifier safety using canonical URLs and resolver scope semantics, preserving harmless identifiers such as the existing where.$id value, and add an absolute-alias differential regression. This remains non-blocking while the builder has no production consumers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:435-438: Apply last-wins map semantics before building schema children
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308203843)
  The builder and pointer lookup now honor last-entry-wins semantics, but the new identifier scan still traverses every raw map entry. For example, let properties contain an earlier p schema with $id: "#ignored", a later p string schema without an identifier, and another property referencing an ordinary definition. JSON conversion removes the earlier p before the existing validator indexes identifiers, and build_node also skips it, but has_fragment_id visits it and rejects the entire schema. Apply last-wins semantics before recursively inspecting identifiers, including maps inside annotation data, and extend the repeated-key regression with a fragment identifier in an overwritten property. This is another occurrence of the original shadowed-entry problem, not a failure in the corrected pointer lookup.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:607-608: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  Document meta-schemas v0–v3 admit boolean schemas and general applicators through contains, but this branch always constructs an object-only SchemaNode and rejects unclassified keywords. Consequently, an otherwise admissible byte-array property with contains: false or contains: {"not":{"const":0}} cannot be represented. The documented fail-closed behavior and lack of contains in the captured corpus make this non-blocking groundwork, but a future protocol-15 registration restriction only controls new registrations; it does not handle schemas admitted before activation. If broader support is postponed, link a tracking issue or PR covering compatibility for previously admitted schemas through representation support or a tested legacy fallback. Documentation and an unlinked future registration plan do not track that compatibility requirement.

The previous guard looked only at `$id`s on built nodes and at fragment
`$id`s, so an absolute `$id` elsewhere, such as
`json-schema:///#/$defs/label` inside an `examples` value, could still name
the schema a `$ref` reaches without being refused. The guard now indexes
`$id`s as the pinned resolver does, with the `url` crate it uses: every map
outside `enum` and `const` names a schema at its `$id` joined against the
enclosing scope (an empty fragment dropped), which also scopes what lies
below it. A reached `$ref` is refused when its URL against its scope differs
from its URL against the root, or when an `$id` names that URL.

This is also narrower than before: an `$id` that names a URL no reached
reference resolves to, or a fragment `$id` above a reference (which leaves
its URL unchanged), no longer refuses the schema. Differential tests check
the existing validator on both an absolute alias and an unredirected
reference.

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

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

At c5abe54, the complete diff is additive groundwork with no production callers or changes to existing consensus behavior; five of the six prior findings are fixed. Three non-blocking schema-compatibility issues remain. Verification was static only: current CI still has Rust workspace tests and JS builds pending, while Kotlin checks passed.

🟡 3 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The substantial typed-schema parser and corpus tests require careful review, but the diff adds no consensus activation or changes to existing validation, network deserialization, or persisted storage behavior.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:685-687: Distinguish effective Platform-only bounds from raw schema siblings
  `maxBytes` is not enforced by JSON Schema: `validate_max_bytes_properties_v0` reads `flattened_properties`, and both property parsers replace a property's keywords with its referenced definition before applying `maxBytes`. For example, a property declaring `{"$ref":"#/$defs/label","type":"string","maxBytes":1,"position":0}`, with a definition containing `{"type":"string","maxLength":10}`, has no effective byte bound in the current document validator, while this builder records `max_bytes: Some(1)`. The same distinction applies to `encryptedFor`, whose runtime check also reads parsed properties. Retaining these raw keywords is useful, but treating every recorded keyword as an effective constraint would tighten validation, contrary to the API's stated purpose. Distinguish raw declarations from effective Platform-only checks using the parsed-property representation, or explicitly refuse mismatches. Add differential coverage through document validation rather than only comparing extracted raw keywords. This remains non-blocking while the representation has no production consumers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:733-734: Use one canonical reference-resolution path for lookup and safety checks
  Target lookup decodes the reference as written, while the pinned validator first constructs a URL through `CompilationContext::build_url` and then decodes that URL's fragment. The URL parser removes literal tabs and newlines and trims trailing control characters and spaces, so these paths can select different schemas without any `$id`. For example, let `$defs.helper.examples[0]` contain `{"label":{"maximum":1},"la\tbel":{"maximum":10}}`, and reference `#/$defs/helper/examples/0/la\tbel` from a byte-array property's `contains`, with `\t` representing an actual tab. This builder records `maximum: 10`; the existing validator canonicalizes the reference to `label` and enforces `maximum: 1`. The identifier guard does not catch this because its two canonical URLs agree and there is no identifier collision. Canonicalize the reference before pointer traversal, sharing that resolution path with identifier-safety checking while retaining the original reference as the map key, and add a differential regression against the pinned validator. This remains non-blocking because the builder has no production callers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:674-675: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  Document meta-schemas v0–v3 admit `contains` through the draft 2020-12 applicator vocabulary, including boolean schemas and compositions such as `{"not":{"const":0}}`. The existing validator handles these schemas, but this branch rejects booleans because `build_node` requires an object and rejects `not` because it is unclassified. The documented refusal and absence of `contains` from the captured corpus make this safe as isolated groundwork, but do not establish compatibility for contracts registered after the snapshot. A protocol-15 admission restriction would govern new registrations, not define what happens to previously admitted schemas. Support the admitted grammar with registration-to-builder regressions, or link a tracking issue covering both the planned restriction and historical-schema compatibility before native validation is activated. No such tracking reference is present in the supplied discussion. This remains non-blocking because there are no production callers.

…orm keywords

A `$ref` is now resolved from the URL the JSON Schema validator parses it
into: the parse drops tabs and newlines and trims trailing spaces and
control characters, the URL must name the document schema itself, the
whole fragment is percent-decoded with `percent_decode_str`, and an array
index takes no sign or leading zero. The `$id` check gives each reference
the URL the validator compiles it with, so a relative `$id` (a
`json-schema:` URL) no longer causes a refusal, and it collects references
below keys named `enum` or `const` too.

`maxBytes` and `encryptedFor` are read by the document type parser, so the
builder refuses them where it does not read them: beside a property's
`$ref`, below the keywords written beside it, through a referenced
property's own `$ref`, and inside `contains`. It refuses `byteArray` inside
`contains`, where the validator's `is_valid` path always accepts it, and a
property `$ref` the parser resolves to another schema than the validator
does.

Differential tests check each case against the existing validator, through
`validate_document_properties` for the Platform keywords.

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

@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

Static verification of 18c9b37 found no blocking consensus or layering regression: the new representation has only test callers, and the existing shorthand helper is moved without behavioral changes. Four non-blocking suggestions remain: referenced bounds bypass the repeated-property safeguard, broader contains schemas remain unrepresentable, the pattern differential uses different compilation options, and the helper extraction lacks the prescribed generation-specific documentation. Current Rust workspace, Swift, Kotlin, and JS code checks pass; PR Hygiene remains pending, and no local builds or tests were run.

🟡 4 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The typed schema parser is substantial and intricate, but the diff does not activate it in consensus or change another critical surface, so it does not meet the critical tier's bar.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/tests.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/tests.rs:1635-1642: Use the configured compilation path in the pattern differential test
  The new compiles_as_validator_pattern check explicitly uses a 5 MiB regex size limit, matching JsonSchemaValidator::compile_v0, which registration invokes through validate_against_meta_schema_and_compile. This differential instead calls compile_and_validate on a fresh validator, whose compilation branch uses RegexOptions::default() without that explicit limit. The short patterns currently tested behave identically, but this probe cannot verify the copied resource limit or catch its drift. Compare the builder's result against JsonSchemaValidator::compile and add a pattern-size boundary case. This strengthens the new compatibility tests without changing either existing validator implementation.

In `packages/rs-dpp/src/data_contract/document_type/schema/expand_property_type_shorthands/v0/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/expand_property_type_shorthands/v0/mod.rs:1-2: Document the behavior-preserving edit to the versioned shorthand expander
  The extracted last_value implementation is identical, so this change does not require a new generation. However, the book's in-place-edit rule requires a comment at the edited lines explaining why the change is inert and an "In-place changes to shipped generations" section in the PR description. Neither is present. Record that expand_property_type_shorthands/v0, selected through Some(0) by the existing protocol-14 and protocol-15 tables, now imports the identical helper and preserves all outputs and errors. This supplies the required audit record without introducing an unnecessary version bump.

In `packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:1082-1084: Distinguish effective Platform-only bounds from raw schema siblings
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308451380)
  The repeated-entry safeguard searches raw entries for maxBytes/encryptedFor but does not follow their references. Consider an object's nested properties stored as a Value::Map with two x entries: first a reference to #/$defs/wide, then a reference to #/$defs/bounded. Both definitions are strings with maxLength 63, but bounded also has maxBytes 1. Neither entry contains a literal parser keyword, so the guard passes and last_wins builds the bounded reference. However, insert_values processes nested entries through a LIFO stack, leaving the first, unbounded entry in flattened_properties; validate_max_bytes_properties_v0 therefore accepts meta.x = "hello" while the built tree records a one-byte bound. Reversing the entries instead loses an enforced bound. The reference-target check cannot catch either case because each surviving reference resolves correctly. Compare Platform-only constraints against the already-parsed effective properties, or make this safeguard account for referenced constraints, and add a registration-to-document-validation regression. This remains non-blocking because the new representation has no production consumers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:1294-1301: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  The document meta-schemas obtain contains from the draft 2020-12 applicator vocabulary, and the pinned validator compiles boolean schemas and applicators such as not and anyOf there. This branch delegates to build_node, which requires an object and rejects those unsupported applicators. The explicit refusal avoids silent misrepresentation, but leaves otherwise-admitted contracts unrepresentable. Zero contains usage in the captured corpus does not cover earlier versions of updated contracts or registrations before native validation activates; restricting new registrations at protocol version 15 would not handle those previously admitted schemas. Support these forms with admission-to-builder regressions, or link tracked work defining a compatibility/fallback path for previously admitted contracts before production adoption. No such tracking reference appears in the supplied discussion. This remains non-blocking while the builder has no production callers.

…alidator does

The builder compiled `pattern` under registration's 5 MiB `regex` size limit,
but every node validates documents against a contract it loaded from state,
whose validator compiles patterns under the `regex` crate's default limit.
A pattern a `$ref` target holds is compiled only then, so the builder refused
registrable patterns consensus compiles. It now uses the default limit, and
the tests cover a pattern between the two limits (registration's compile
refuses it, the loaded-contract compile and the builder accept it) and one
beyond both.

Document the in-place edit of `expand_property_type_shorthands` v0: a comment
at the import says why moving `last_value` is inert for protocol versions 14
and 15, and the helper's doc now scopes its claim to property schemas and
says its rule is consensus behavior.

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

Verified the combined reviewer evidence against exact head 03f1be6. Three non-blocking compatibility issues remain in the new representation; no blocking layering, versioning, or existing consensus-behavior defect was confirmed. This was a static review without builds or tests: current CI shows Rust workspace tests pending, while the JS build/tests, Kotlin checks, and Swift frozen-schema check passed.

🟡 3 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The typed schema parser and extensive corpus tests are substantial and intricate, but the diff does not activate new consensus validation or change another critical surface.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:293-295: Preserve the resolver's resource scope across reference edges
  Every queued reference is resolved against root_url, but the pinned validator compiles a referenced target using the resource URL returned by Resolver::resolve_fragment. For example, set the root $id to https://example.com/root, reference json-schema:///#/$defs/helper from contains, and let helper contain {"type":"string","$ref":"#/$defs/label"}. Give the structural label maxLength: 10, and add an examples entry on another property naming https://example.com/root#/$defs/label with maxLength: 1. The explicit json-schema reference causes the existing resolver to compile helper against the default resource, so its reference follows the structural label and accepts "hello". This builder instead resolves helper's reference against the HTTPS root and records the named example's bound of 1. The final guard misses this because helper's lexical scope agrees with root_url; it does not account for the incoming reference's resource scope. Carry the resolved resource context through traversal and include it in reference-processing identity, or explicitly refuse context-dependent graphs. Add a mixed-resource differential regression. This is non-blocking while the tree has no production consumers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:1079-1085: Distinguish effective Platform-only bounds from raw schema siblings
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308451380)
  The Reading checks handle the reported sibling declarations, but the duplicate-entry guard still misses effective bounds reached through references. Construct an object's nested properties as a raw Value::Map with two x entries: first {"$ref":"#/$defs/bounded","position":0}, then {"$ref":"#/$defs/wide","position":0}. Let bounded declare a string with maxBytes: 1 and wide declare a string without a byte bound. Neither entry literally contains maxBytes, so this guard accepts the duplicate and last_wins builds only wide. However, insert_values pushes nested entries in source order and pops them in reverse, leaving bounded in flattened_properties; validate_max_bytes_properties_v0 therefore rejects a five-byte x while the successfully built tree omits that bound. Reconcile Platform-only constraints against the parsed document type's authoritative properties, or explicitly reject these mismatches, and add a differential regression with duplicate referenced properties. This remains non-blocking because the builder has no production consumers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:1291-1298: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  The document meta-schemas admit boolean schemas and general applicators under contains through the draft 2020-12 applicator vocabulary. This call requires an object, and keyword handling rejects applicators such as not, so the typed representation cannot build some schemas the existing validator accepts. The documented refusal is fail-closed, and the captured corpus needs none of these forms, but a protocol-15 registration restriction would only prevent later admissions: it would not handle contracts admitted before activation, including registrations after the corpus snapshot. Support the admitted grammar or define an explicit legacy fallback before native-validator integration. If that compatibility work remains deferred, it needs a linked tracking issue or PR; none is present in the supplied discussion. This remains non-blocking because no production path consumes the builder.

…nst another URL

The JSON Schema validator compiles the schema a `$ref` reaches, and the `$ref`s
below it, against the reference's own URL without its fragment, where the
builder resolved those nested `$ref`s against the document schema's URL. A
reference that names the default URL outright under a document schema with
an absolute `$id`, for example, sent a nested `$ref` to an `examples` entry
that `$id` names, while the validator followed it to the definition.

The builder now refuses a reference whose target holds a `$ref` when the URL
the validator compiles that target against differs from the document
schema's. A differential test shows the validator holding the nested `$ref`
to the definition.

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

The change remains non-blocking groundwork, but two correctness gaps are still present: root references are rebuilt under the referring schema's reading context instead of reusing the canonical root node, and the typed representation cannot model valid boolean or applicator schemas under contains. No code-check failure is reported; Kotlin SDK is queued and PR Hygiene remains in progress.

🟡 2 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial Rust schema-parsing and validation-model change with broad corpus coverage, but it does not itself alter consensus behavior, funds movement, cryptography, or storage migrations.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:305-318: Reuse the root node when resolving a root reference
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146077)
  The loop still calls build_node(target, ..., reading, ...) when target is the already-built root. Setting OtherKeys::Document preserves root metadata, but it does not preserve the original Reading::Document context: a root reached through a contains reference is rebuilt as Reading::Contains, causing its properties to be processed as Reading::Schema. A root that is valid when initially built can therefore reject or mis-handle context-sensitive Platform keywords such as maxBytes when reached through a reference. Reuse root_node for target == root so all root references share the canonical node and reading context.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:1327-1333: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  The document meta-schemas take contains from the draft 2020-12 applicator vocabulary, which admits boolean schemas and general applicators such as not, anyOf, and allOf. The pinned validator can compile values such as contains: true or contains: {"not": {"const": 0}}, but build_node requires contains to be an object and rejects applicator keywords that are not represented by SchemaNode. The current loud refusal avoids silently producing an incomplete tree, and no corpus contract currently uses these forms, but the public typed representation still cannot model every schema accepted by the validator. Either add a boolean/general-applicator representation or explicitly constrain and version the contract grammar before native validation relies on this conversion, with regression coverage for that boundary.

Correctness:
- Refuse a property name, or the document schema's `properties`, repeated
  with a `$ref` in an entry, which may reach `maxBytes` or `encryptedFor`
  the parser reads from another entry than the validator.
- Refuse building a schema in `enum` or `const` data that carries, or sits
  below, an `$id` that is not a URL reference: the validator may fail to
  enter it on the way to a `$ref` target and refuse every value. This
  replaces the over-broad refusal of references below such an `$id`.
- Read every `$id` even when the schema holds no `$ref`, as the validator's
  resolver does on every compile.
- Refuse at the root what the validator's draft 2020-12 meta-schema check
  refuses there: a repeated `required` or `type` entry, an empty `type`
  list, an annotation of the wrong type.

Simplification:
- One key rule everywhere: refuse a key the validator compiles that is not
  a SchemaKeyword, skip any other. This removes `restricted_schemas`,
  `restrict` and `OtherKeys`, whose extra refusals only hit schemas the
  meta-schemas refuse.
- The reference loop keeps `built` and `nodes` only.
- `CompileScope` becomes `Option<&Url>`.
- `byteArray` is a bool.
- The `\cX` pass mirrors the fork's `replace_all`.
- `carries_parser_keywords` and `Reading::checks` share one predicate, and
  the builder uses the `property_names` constants.

Docs: `uniqueItems`, `multipleOf`, `enum` and `const` say how the validator
compares; the module doc states the `maxBytes`/`encryptedFor`/`byteArray`
rule once, including typed-array items; the corpus README and loader say
the bytes are the served re-serialization, not the stored V0 form.

Tests: `$ref`-reached repeated entries, references into data below a
non-URL `$id` and a non-URL `$id` without references (with differentials),
the root meta-schema checks (with a differential), three untested `Reading`
transitions, two-way keyword probes and more pattern probes against the
validator, positive controls in the `$id` resolution differential,
acceptance at protocol version 14, and a mainnet corpus load at 13.

Pin the jsonschema fork by `rev` to the commit Cargo.lock already used.

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

The current head has no blocking correctness, consensus, layering, or build issues. Two non-blocking schema-representation issues remain: the builder rejects validator-admitted boolean/general applicator schemas under contains, and duplicate-entry safety scanning incorrectly treats keyword-shaped data inside annotations or instance values as parser-sensitive. Rust workspace tests passed; Swift SDK validation and PR Hygiene remain pending.

🟡 2 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial Rust schema-parsing and validation-model addition with extensive fixtures and tests, but it does not itself alter consensus behavior, funds movement, cryptography, or other critical surfaces.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:982-995: Restrict duplicate-entry checks to schema locations
  `carries_parser_keywords` recursively scans every nested map and array, including annotation and instance-data values. Because `refuse_repeated_entries_the_parser_reads_otherwise` uses it to decide whether a duplicate property or `properties` entry must be refused, a valid repeated property can be rejected when an otherwise ignored value contains a schema-shaped key: for example, an `examples` entry such as `{ "maxBytes": 1 }` is not read by either the document parser or the JSON Schema validator, but this traversal still marks the entry as carrying a parser-sensitive keyword. Limit this scan to schema locations the parser follows, skipping annotations, `enum`, `const`, relationship values, and unknown-keyword data, so duplicate entries are refused only when their parser-visible behavior can differ.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:189-195: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  The document meta-schemas admit any draft 2020-12 schema under `contains`, and the pinned validator compiles boolean schemas and general applicators such as `not`, `anyOf`, and `allOf`. `ArrayConstraints::contains` stores only a `SchemaNode`, while `build_node` requires an object and rejects compiled validator keywords that are not represented by `SchemaKeyword`, so a currently registrable schema such as `contains: true` or `contains: {"not": {"const": 0}}` is valid to the existing validator but cannot be represented by this builder. The loud refusal is safer than silently dropping constraints and no live corpus contract currently uses these forms, but the public builder does not yet capture every schema admitted by the validator. Add a boolean/applicator representation, or introduce a tracked, versioned registration restriction before relying on this builder for future contracts.

Builder (validation_schema/mod.rs):
- Check `$id` scoping where it happens: a node the validator may fail to
  enter is refused when it is built, and a `$ref` an `$id` above it may
  rescope when it is queued, so the true reason is reported first. The
  two post-loop passes, `Reached.schemas`, `holds_a_reference` and
  `compile_url` are gone; `resolve_reference` returns the resource the
  validator compiles the target against, compared with the document's
  own (which keeps an opaque path's trailing spaces).
- Mark an `$id` in `enum`/`const` data that resolves to a URL with no
  base (`json-schema:opaque`) unenterable: the validator fails to join a
  relative `$id` onto it.
- Refuse a `required` repeated with different names: the parser requires
  the first entry's names, the validator reads the last.
- Skip `then`, `else`, `if`, `minContains`, `maxContains` and
  `additionalItems` where the validator does not compile them (without
  their partner keyword) instead of refusing them.
- Build a name the document schema's own `properties` repeat when its
  last entry has the highest `position`, which the parser keeps too.
- Read root values as the JSON the validator compiles (bytes become an
  array), and refuse more of what its meta-schema check refuses at the
  root: `multipleOf` not above 0, bad `minContains`/`maxContains`,
  meta-data and content keywords of the wrong type, non-object
  `definitions`/`$defs`/`$vocabulary`, a `$schema` that is not a URI, a
  non plain-name anchor, and an `$id`/`$ref`/`$dynamicRef`/`$recursiveRef`
  the `uri-reference` format refuses. Duplicate checks use one set-based
  helper.
- Messages: a property `$ref` the parser does not resolve says so; a
  Platform keyword refused in a referenced schema names the reference
  that reached it; scope refusals say "may".
- Docs: `propertyConstraints` is checked in its own step; storage
  encoding refuses integers outside the parser's sized width; the
  `multipleOf` overflow path; `byteArray` also fixes the JSON type; a
  relative `$id` under an absolute document `$id`; the complete list of
  `try_from_root` refusals.

Tests (validation_schema/tests.rs): differentials pinning the
documented `const`, `multipleOf`, `uniqueItems` and `enum` comparisons;
a probe writing every key of the bundled draft 2020-12 vocabularies at
the root with values of each JSON type, asserting the builder refuses
whatever the validator compiles nothing for; tests for each fix above;
`existing_validator_compiles` and `validating_json` helpers and
whole-root meta-schema fixtures; a positive control in the `$id`
scoping differential; the meta-schema classification test now requires
`documentSchema` in every version.

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

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.

…them

`carries_parser_keywords` searched every nested map and array of a
repeated property entry, so `maxBytes`, `encryptedFor` or `$ref` shapes
inside `examples`, `enum` or `const` data, or `contains`, refused the
duplicate though the document type parser never reads them. It now
scans the entry itself and its `properties` and `items`, the only
schemas below a property the parser reads, and a repeated document
schema `properties` by its property schemas.

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

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

Verified the complete diff at 5b84694: no blocking defects were confirmed, and one non-blocking contains-grammar compatibility finding remains. All 17 prior findings were revalidated: 13 are fixed, three are withdrawn, and one remains valid. This was a static review; current Rust, JavaScript, Swift, and Kotlin checks pass, PR Hygiene remains pending, and the supplied base-drift evidence reports no conflicting files.

🟡 1 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The substantial typed-schema implementation and corpus tests warrant ordinary review effort, but the diff does not activate new consensus behavior or otherwise change a critical surface beyond moving an existing helper unchanged.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:1426-1428: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  Document meta-schemas v0–v3 still delegate `contains` to the draft applicator grammar, which admits boolean schemas and applicators such as `not` and `anyOf`. This arm passes those values to the object-only `build_node`, which rejects booleans and unsupported applicators. The refusal is explicit and no production path calls this API, so this is not a current consensus regression. However, restricting new registrations in protocol 15 would not cover contracts admitted before activation, including registrations after the corpus snapshot. The new `should_hold_the_formats_and_keywords_the_existing_validator_compiles` test already establishes that `contains: false` is an effective validator constraint; extend that evidence through registration and the public builder, then either represent the admitted forms or link a tracking issue requiring a versioned restriction and a legacy compatibility/fallback decision before native validation is activated. The documented limitation alone does not provide that tracking.

…hema

Registration resolves every `$ref` as a JSON pointer below `#/`, and all
175 references in the contract corpus are one. The builder now holds
only references written `#` or `#/...` without `%`, whitespace or
control characters, the forms whose text is exactly the pointer the
JSON Schema validator follows, and refuses the `$id`s that could make
the validator resolve one elsewhere: a document schema `$id`, and any
other that is not a plain name (ASCII letters, digits, `_`, `-`, `.`).
A plain name resolves to a `json-schema:` URL, which the validator
reads as no `$id` at all, and names no fragment; the corpus uses them
only in Platform keyword data such as a `refersTo` `findBy`. A
differential test pins that the validator resolves references below
and through plain-name `$id`s from the document schema.

This removes the `$id` index, the scope and compile-URL checks, the
unenterable-`$id` tracking, URL parsing of references and
percent-decoding, so `percent-encoding` leaves the `validation-schema`
feature. The tests of that machinery and of the validator behaviour it
modelled go with it.

Also:
- A repeated `required` is refused only when its first and last
  entries name different properties, so lists naming the same ones in
  another order build.
- A generated differential test builds 600 schemas of the keywords the
  validation schema holds, with keys the validator ignores among them,
  and checks that the builder refuses each the validator compiles
  nothing for and that every other, written back from the tree, gets
  the validator's verdict on 34 documents that the original gets.

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

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

Verified the complete diff at 6cb1acf and revalidated all 17 prior findings; no actionable defects remain. The three carried Codex suggestions request broader supported inputs or would bypass necessary context-sensitive checks, rather than correct an incorrectly represented schema. This was a static review with no local builds or tests: current CI reports successful Rust workspace, JavaScript, Swift, and Kotlin checks; PR Hygiene remains pending.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial Rust schema-modeling and contract-corpus test addition that affects validation-related code and serialization representations, but it does not itself change consensus behavior, funds movement, cryptography, or storage migrations.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

…to and who checks them

- `byteArray` moves from `Format` to `Array`, with its field from
  `FormatConstraints` to `ArrayConstraints`: it refuses any value that is
  not an array of bytes, as the meta-schemas say it applies only to
  arrays. `Format` now holds `format` and `encryptedFor`, which say what
  kind of string or byte array a value is beyond its JSON type.
- `Meta` splits into `Resolution` (`$id`, which changes how the JSON
  Schema validator resolves a `$ref`) and `Storage` (`position`,
  `requiredSince`, `contentMediaType`, which say how the document type
  parser stores the property).
- `SchemaKeyword::checked_by` returns a new `CheckedBy`: the JSON Schema
  validator, consensus on the property the document type parser builds
  (`maxBytes`, `encryptedFor`), consensus against more than the value
  (relationships), or nothing. `constrains_a_value` derives from it, and
  the builder reads it where a separate predicate listed the
  parser-read keywords. A test ties it to the validator's keyword table.

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

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

@QuantumExplorer

Copy link
Copy Markdown
Member Author

Reviewed

@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

Static verification of 4296a54 found three non-blocking compatibility issues and no blocking defects. The new representation has no production consensus callers, and the shorthand-helper extraction preserves existing behavior. Current CI shows Rust workspace tests, JavaScript builds/tests, and Kotlin tests passing; Swift SDK build/tests and PR Hygiene remain pending.

🟡 3 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The substantial typed-schema parser and corpus tests warrant ordinary review effort, but the diff does not activate new consensus behavior or change another critical surface, and the existing shorthand helper is moved unchanged.
  • 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 (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:297-300: Check whole-schema JSON representability before extracting keywords
  The existing document-validation path converts the entire enriched, expanded schema with `try_to_validating_json()` before compilation (`validate_document/v1/mod.rs:132–136`). This builder converts only selected keyword values. Consequently, a string property with `Value::Float(f64::NAN)` inside its nested `examples`, or an ignored keyword containing `Value::U128(u128::MAX)`, builds successfully although the existing validator cannot convert that schema. Shadowed entries also matter: the conversion visits every raw value before collecting the JSON object, whereas `last_wins` discards those entries before construction. Trusted loading does not establish this invariant because it skips full validation. Check whole-root JSON representability at the builder boundary before extracting effective keywords, and add regressions for ignored data and shadowed non-representable values. This is non-blocking because no production validation path uses the new representation.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:781-795: Skip enum and const data when collecting schema identifiers
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4310314654)
  The current identifier guard recursively inspects every raw value, reintroducing rejection of identifiers that cannot affect schema resolution. For example, a property's `const: {"x":{"$id":"https://example.com/value"}}`, with no reference into that data, fails this scan even though the pinned resolver's `find_schemas` skips `const` and the compiler treats its contents as instance data. The opaque-identifier-in-const refusal test explicitly requires this behavior. The same raw traversal rejects a nested schema's shadowed non-plain `$id` even when its last `$id` is a permitted plain name: validating JSON discards the earlier entry before resolver traversal. Scan effective, last-entry-wins maps using the resolver's enum/const exclusions, and separately check identifiers on nodes actually compiled, including reference targets. That preserves checks on properties literally named `enum` or `const` without imposing schema-identifier restrictions on literal or discarded data. This is non-blocking while the builder has no production consumers.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:199-205: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  Document meta-schemas v0–v3 still obtain `contains` from the draft-2020-12 applicator vocabulary, admitting boolean schemas and general applicators. The pinned validator compiles forms such as `contains: true` and `contains: {"not":{"const":0}}`, but this representation rejects them because `build_node` requires an object and refuses `not`. Failing closed is safe for this groundwork, but the corpus snapshot does not establish a lasting compatibility invariant: protocol 14 can admit another such contract before native validation activates. Restricting only protocol-15 registration would leave that stored contract unrepresentable. Either support the admitted grammar with registration-to-builder coverage, or link a follow-up explicitly tracking how native activation preserves contracts admitted before activation. The documentation records the limitation, but the supplied discussion has no tracking reference for that compatibility work; #5271 tracks the corpus rather than this activation decision. This remains non-blocking while the builder has no production callers.
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.

  • Do not reject an $id that names the same pointer target — Outdated: the named-URL index and its same-target comparison have been removed. Actual fragment-bearing schema identifiers are explicitly outside the current pointer-only representation; supporting them would require restoring identifier-resolution machinery, rather than correcting an incorrect target comparison still present in this diff.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

…onvert to JSON

The document validator converts the whole enriched, expanded schema to
JSON before compiling it, every value it then ignores and every entry a
repeated key shadows included, and compiles nothing when that fails.
The builder converted only the keyword values it reads, so a schema
holding, say, a NaN in an `examples` entry or a 128-bit integer in an
ignored keyword built. It now converts the whole root first and refuses
such a schema, with regressions for ignored data and a shadowed entry.

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

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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.

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

Static verification of head 3002759 found no blocking defects: the new representation has no production callers, and the shared-helper extraction preserves existing behavior. One non-blocking suggestion remains to track compatibility between the admitted contains grammar and the future native representation, including previously stored contracts. Current CI has no failed code checks, but Rust workspace tests remain in progress; no builds or tests were run locally.

🟡 1 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); 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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The PR adds intricate schema representation and extensive corpus tests, but the new code is not activated in consensus and the existing versioned implementation only relocates an unchanged helper, so the diff does not meet the critical-surface threshold.
  • 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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); 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/schema/validation_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/schema/validation_schema/mod.rs:199-205: Represent the full schema grammar admitted under contains
  (existing thread: https://github.com/dashpay/platform/pull/5486#discussion_r4308146070)
  The documented refusal is safe for this groundwork, and the corpus evidence does not justify implementing another schema language here. However, document meta-schemas v0–v3 still delegate `contains` to the applicator vocabulary, which admits boolean schemas and general applicators, while `build_node` requires an object and rejects unrepresented applicators. Restricting new registrations in protocol 15 would not by itself handle contracts admitted under the existing grammar before activation. Keep the current fail-closed behavior, but link a tracking issue before deferring this compatibility gap: it should cover the admission decision in DPP and how the native reader will handle previously stored schemas outside this representation. The linked corpus issue #5271 does not track that decision. This is non-blocking because no production validation path invokes the builder.

@QuantumExplorer
QuantumExplorer merged commit 3dcb670 into v5.1-dev Oct 22, 2026
41 of 43 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/contract-corpus-typed-constraints branch October 22, 2026 09:44
QuantumExplorer added a commit that referenced this pull request Oct 23, 2026
…protocol version 15

Generation 2 no longer hands a document type its native validator cannot
represent to generation 1's `jsonschema` check. It refuses the type's
documents with `InvalidContractStructure` instead, before any other
check, so no document is checked through the `jsonschema` crate at
protocol version 15.

The refusal of a schema is kept on the document type as the validator
is: the native slot now holds the validator or the `DataContractError`
building it returned; any other error is returned and not kept.

Every document type of the contract corpus builds a validation schema,
so no registered contract is affected today.

Also:
- the validation schema's module doc no longer says nothing reads it;
- the lazy validator's Debug doc is exact about what it prints;
- the structured-error test helper imports its error types instead of
  naming them by path;
- a #5486 test that takes generation 1 as its ground truth now runs it
  at protocol version 14.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
QuantumExplorer added a commit that referenced this pull request Oct 24, 2026
- The tests of `validate_document_properties` at protocol version 15
  against 14, and of the refusals of a type without a validation schema
  or whose references cycle, move to `validate_document/v2/tests.rs`.
- The protocol version 15 against 14 test checks each document on a
  clone of the registered contract, which holds no validator built,
  instead of parsing the document type again.
- The generated differential compiles the existing validator as document
  validation does (`compile_and_validate`), not as registration does.
- The #5486 test of the comparisons the validation schema documents keeps
  only the `enum` key order; its other cases are checked against both
  validators in the native validator's tests.
- Helpers widened for those tests are private again.

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