Repository navigation
fix(dpp)!: propertyConstraints read empty objects as absent and follow $defs refs (PV14) - #5101
Conversation
…w $defs refs (PV14)
present and absent now count an object with no member present ({}, or
{ "inner": {} } around one) as absent. The document encoding reads such
an object back as no object at all, so a create was judged on meta: {}
as present while its later transfer, purchase or price update, judged on
the stored document, saw it absent.
Parser generation 3 now resolves a property's $ref to the contract's
$defs when it checks rule string constants, listed strings, prefixes and
suffixes, string defaults and contains constants against the property's
enum, and when it checks an encryptedFor key id's bounds. It resolved
them against the bare document type schema, which holds no $defs, and
refused every such contract with a decoding error.
PV14 note 52 covers both.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedNext included review available in 29 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
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. Comment |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-09-28T03:30:38.732Z |
|
✅ Final review complete — no blockers (commit 0f61933) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified both supplied findings against head 222ca90 and retained them as non-blocking suggestions. The fixes align presence checks with storage decoding and keep the schema-resolution changes on PV14-only paths; no blocking defect was identified. Verification used source, caller, version-table, and test inspection plus a passing diff whitespace check; reviewer-reported test runs were not independently rerun.
🟡 2 suggestion(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: platform-versioning); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — The diff changes consensus-visible document presence checks and contract schema reference resolution, but the implementation is contained and straightforward, with most additions being tests and documentation rather than large or intricate critical-surface changes. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— architecture-layering (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— platform-versioning (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 13% left, 5h 100% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-dpp/src/data_contract/document_type/property_constraints/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/property_constraints/mod.rs:2362-2372: Avoid constructing the presence-check worklist for non-map values
Every evaluated `present` or `absent` predicate whose path resolves now constructs a heap-backed worklist, including for scalar values and null, where the result is immediately known. This adds avoidable allocation work to document validation. Return directly for null and non-map values, retaining the iterative traversal for maps so deeply nested input remains stack-safe. This preserves the current predicate semantics.
In `packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/mod.rs:2396-2399: Add regression coverage for references below a definition
The new resolver explicitly supports references below a named definition, but the enum and `encryptedFor` regression tests use only direct references such as `#/$defs/state` and `#/$defs/recipientKey`. They do not exercise the branch that changes the resolution root and reconstructs the remaining URI. Add a case such as `#/$defs/wrapper/properties/inner` through the dispatched parser, checking both an accepted value and a rejected enum constant or key-id bound under full and partial validation. This would protect the sub-path behavior included in this fix.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…efinition present and absent answer null and every value but an object at once, and build the iterative worklist only for an object's members, so a scalar or null costs no allocation. The result is unchanged. Two regression tests cover a $ref that names a schema below one of the contract's $defs (#/$defs/wrapper/properties/inner): a rule's string constant is held to the enum found there, and an encryptedFor key id is read from the integer schema found there, accepted when bounded and refused when not. Both run on the validating and the non-validating path. The resolver already handled this case; no change to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The exact reviewed head correctly aligns property-constraint presence semantics with stored-document serialization and resolves property schemas through contract $defs, including paths below named definitions. The previously identified performance and regression-coverage suggestions are both addressed, and no new actionable in-scope defects were found.
🔴 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: architecture-layering); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: platform-versioning); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
normalbygpt-6-astra(effort low) — The diff changes consensus-relevant PV14 validation in is_present and resolve_schema_ref, but the implementation is small and contained, with most added lines devoted to tests and documentation rather than large or intricate critical-surface changes. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— architecture-layering (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— platform-versioning (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 13% left, 5h 100% left),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-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6-astra— general (completed, effort high); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort high); agentphase2-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.
|
Bots are done — your move: post |
Basic explanation
This fixes two mistakes in
propertyConstraints, the document type rules added for protocol version 14.{}, or{ "inner": {} }) is dropped. The rules checked a create against the data it carried, wheremeta: {}was there, but checked a later transfer against the stored document, where it was gone. So the same document could pass one check and fail the other. Nowpresentandabsentsee an object with nothing in it as absent everywhere.$defs. A contract can define a property as{ "$ref": "#/$defs/state" }. The rules looked theenumof such a property up in the wrong place and refused the whole contract with a decoding error. Now they read the definition, as the rest of the parser already does. The same fix applies to theencryptedForkey id check.Example:
Rule:
"metaOrSeller": { "anyOf": [{ "present": "meta" }, { "equal": ["sellerId", "$ownerId"] }] }Before:
meta: {}. Accepted, becausemetais present.metaOrSellernot met), because the stored offer has nometa.After:
meta: {}is refused with 10422, becausemetahas nothing in it.meta: {}and then transferred to someone who is not the seller is refused the same way. Create and transfer agree.Contract with
"$defs": { "state": { "type": "string", "enum": ["open", "closed"] } }, a property"state": { "$ref": "#/$defs/state" }and the rule{ "equal": ["state", { "const": "closed" }] }:Before: the contract is refused with
unable to get property $defs in $defs.state.After: the contract registers. With
{ "const": "closd" }instead, it is refused with the usualcompares "state" with "closd", which is not one of its enum values.Value: a document's rules give the same answer whether it is being created or moved later, and contracts that share property schemas through
$defscan usepropertyConstraintsandencryptedFor.Risks: Low. Both changes apply only at protocol version 14, which is not released yet. A devnet already running protocol version 14 whose history contains such a create or such a contract would replay differently. That is expected for unreleased protocol version 14 changes.
Issue being fixed or feature implemented
presentandabsentcounted any non-null value as present,{}included. The document encoding reads an object with no member present back as no object, recursively ({ "inner": {} }goes too). A create or replace is judged on the data it carries, while a transfer, purchase or price update is judged on the stored properties (validate_property_constraints_for_system_change). The two could disagree for the same document.enum(const, stringin,startsWith/endsWith, stringifAbsentdefaults,containsconstants), and theencryptedForkey id bounds check, resolved$refagainst the bare document type schema. That schema holds no$defs, so any such property made the contract fail with aValueDecodingError.What was done?
property_constraints/mod.rs:is_presentcounts a value as present only if a stored document keeps it: not null, and for a map, some member that is kept, checked recursively (is_kept_in_storage, written as an iterative walk because a create's data is read before its schema validation is reported). The shipped document decoder is unchanged.try_from_schema/mod.rs:apply_property_constraintsandvalidate_encrypted_for_declarationstake the contract'sschema_defs. The newresolve_schema_refresolves#/$defs/<name>(and a path below it) against them, asenrich_with_base_schemamakes the core parse do, and any other local reference against the schema.schema_at_path,resolve_schema(including a$refunderitems),enum_any,enum_admitsandis_key_id_schemause it.v3/mod.rs:parse_generation_3passes itsschema_defsto both.v14.rs: PV14 note 52 describes both changes.propertyConstraints, the contract keywords table, the documents chapter and the v3 meta-schema descriptions ofpresent/absentnow say that an object with no member present counts as absent.How Has This Been Tested?
New tests. Each one fails without the fix and passes with it:
should_judge_presence_alike_on_the_data_and_on_the_stored_document: formetaset to{},{ "inner": {} }and{ "tag": "x" }, every rule gives the same verdict on the document's data as after a serialize/deserialize round trip.should_tell_a_property_left_out_from_one_set_to_zero: extended with{},{ "inner": {}, "gone": null }and a path inside it.should_hold_string_constants_to_the_enum_of_a_referenced_definition:$refstring and typed array properties. A validconst,in,startsWith,ifAbsentdefault andcontainsregister. Misspelt ones are refused with the normal enum errors. Both parse paths.should_read_an_encrypted_for_key_id_through_a_ref: bounded$refkey ids register, an unbounded one is refused. Both parse paths.should_judge_an_object_without_members_absent_on_create_and_transfer: creates withmeta: {}and{ "inner": {} }by a non-seller are refused. An offer stored withmeta: {}(its owner is the seller) is refused on transfer to a non-seller.{ "tag": "x" }passes both create and transfer.Commands:
cargo test -p dpp --all-features --lib -- property_constraints try_from_schema meta_validators validate_schema_compatibility validate_document: 602 passedcargo test -p dpp --all-features --lib -- document_type document::v0::serialize encrypted: 1588 passedcargo test -p drive-abci --lib -- property_constraints encrypted_for: 33 passed.-- data_contract_create: 140 passedcargo test -p platform-version: passedcargo fmt --all.cargo clippy --tests -- -D warningson dpp (all features), drive-abci and platform-version: cleanBreaking Changes
Consensus changes at protocol version 14 only (unreleased):
encryptedForread a property through a$refto$defs, which was refused with a decoding error, now registers if its constants are valid.A devnet already on protocol version 14 whose history contains either would replay differently.
In-place changes to shipped generations
None.
is_presentis reached only through rules that parser generation 3 builds, andvalidate_property_constraintsisNonebefore protocol version 14.apply_property_constraints,validate_encrypted_for_declarationsand the$refhelpers are called only from parser generation 3. Meta-schema v3, whose descriptions changed, is selected only at protocol version 14, and descriptions do not validate.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
0f61933/self-reviewedWhen every box is checked the
PR Hygienecheck passes and this can merge.