Repository navigation
feat(platform)!: either-kind targets and slot conditions for document-named references (PV15) - #5850
Conversation
…(PV15) A `permanentDocument` or `moderatedDocument` `refersTo` on an identifier property may leave its target to the referring document: `contractIdProperty` and `documentTypeProperty` name the properties holding the contract and the document type, in place of `contractId` and `documentType`, and `documentTypeRequirements` says what the named type must look like: named slots, each a property it must have (`name`: `"$any"`, a property name, or a name read from the referring document; `type`; `maxBytes`; `distinctFrom`), and `require`, `anyOf` / `allOf` over slot names. Version 1 of `apply_property_reference` (protocol version 15) parses the declaration to `DocumentPropertyReferenceTarget::DynamicDocument`, appended, and refuses its keys wherever else a reference sits. Nothing about the target is known at registration, so `document_reference_validation` 1 checks it when a document is written: the contract and the type exist, the type is not private, meets the requirements (`ReferencedDocumentTypeRequirementNotMetError`, 40153) and is of the declared kind, and the document exists. A replace checks the reference again when its value or a property it reads the target from changed. Protocol version 14 and earlier keep `apply_property_reference` 0, which does not read the keys. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…-named references (PV15)
A refersTo naming its target through the referring document may list both
kinds, ["permanentDocument", "moderatedDocument"]: the named type is then
either, and the reference is checked as one of the kind the type is.
A documentTypeRequirements slot may carry `when`, a condition in the forms
of a propertyConstraints condition read against the referenced type:
$kind, $self, $moderatorAbilities.deleteKeepsFields,
$moderatorAbilities.changeFields and { "const": ... }. A property the
condition does not hold for does not fill the slot. So a contract can ask
that a text it points at is one a moderator's removal takes away, only
when the type is a moderated one.
The condition is stored in the compiled contract and carried by consensus
errors, so its decoders refuse a nesting past 16, and the parser holds one
`when` to max_document_type_requirement_condition_nodes (16).
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
Pre-merge checks:
|
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-11-11T13:36:42.548Z |
|
✅ Final review complete — no blockers (commit b8b5a39) · triage: critical |
…n reference inputs Review of the references whose target the document names: - A document naming an indexOnly document type is refused, paid, with ReferencedDocumentTypeIndexOnlyError (40146) before anything is fetched. Drive refuses to fetch such a document by its id, which failed the transition with an internal error and no fee. - The properties a dynamic reference reads its target from (the contract id, the document type name, a slot's name property) can no longer be listed under moderatorAbilities.changeFields: a moderator's change checks no reference again. - A rule reading through a dynamic reference is refused with a message that says why. - The schema shape of documentTypeRequirements is written by rs-dpp (to_schema_value, which the parser reads back); wasm-dpp2 delegates. - A replace changing a slot's name property is covered by a test. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…-when Brings in the review fixes of the base: the indexOnly refusal (40146), the reference inputs a moderator may not write, the rule message, and the schema shape of documentTypeRequirements written by rs-dpp. A slot's `when` follows that shape into rs-dpp (SlotCondition::to_schema_value, which the parser reads back), so wasm-dpp2 no longer builds it itself. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The message refusing a refersTo that names its target through the referring document on a property that is not an identifier held a run of spaces where its two lines join. It travels in a consensus error, so it is fixed before protocol version 15 ships, and its test now holds the whole sentence. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…laude/dynamic-refers-to-when Brings in the restored line continuation of a dynamic reference refusal. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The PV15 activation and layer ownership are consistent with the intended feature, but the new condition evaluation adds repeated validation work without corresponding processing charges. Three non-blocking findings cover consensus-error payload bounds, protocol-limit ownership, and WASM boundary coverage. This was a static review of head 60eef82; current CI has no failed checks, with Kotlin and book checks passing, but provides no Rust or wasm32 validation results.
🔴 1 blocking | 🟡 3 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 13: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 14: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate diff adds schema-condition parsing and evaluation in packages/rs-dpp/src/data_contract/document_type/property/slot_condition.rs and changes consensus-enforced document-reference acceptance in packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v1/mod.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort xhigh); agentphase2-reviewer - Model comparison: every Phase-2 reviewer also ran on
gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-dpp/src/data_contract/document_type/property/dynamic_document_reference.rs`:
- [BLOCKING] packages/rs-dpp/src/data_contract/document_type/property/dynamic_document_reference.rs:436-445: Charge for repeated slot-condition evaluation
Every candidate property admitted by a slot now evaluates its `when` tree. The 16-node cap bounds one tree, not the total work: each reference can have four slots, wildcard slots scan the target type's properties, and a document can carry up to 256 references. References naming the same target share the existing contract/document fetch charges but repeat these evaluations; a same-contract requirements failure also returns before a document fetch adds any charge. `met_by` reports only a boolean, and its caller in `document_reference_validation/v1/mod.rs` records no operation for this added work. Consequently, increasing condition complexity and repeating references increases validation CPU without a corresponding processing fee. The existing `bill_where_list_elements` path already accounts for analogous repeated comparison work. Expose deterministic evaluation-work counts from DPP and bill them in Drive-ABCI through the named PV15 fee schedule, including rejection paths and the applicable fee-estimation treatment, with fee regression coverage.
In `packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs:544-558: Keep admitted condition payloads within the consensus-error decoder budget
Membership lists have no aggregate-size bound, so a valid new condition can exceed the shared client error-decoding budget. For example, `in` comparing `$self` against a list containing `text` and nine distinct 256-character ASCII strings passes this parser and consumes only one condition node; a target with a string property named `text` satisfies it. If the referenced document is missing, `document_reference_validation/v1/mod.rs` embeds the complete declaration in `ReferencedEntityNotFoundError`. Those strings alone exceed the 2000-byte limit on `ConsensusError`, whose generated untrusted deserializer uses `with_limit::<2000>()`. Both WASM error deserializers and the Rust SDK's gRPC-error conversion use that bounded decoder, so consumers receive a decoding failure instead of the intended 40120 consensus error. Reconcile the admitted declaration size with the shared error budget in Rust, through a compact error representation or a suitable aggregate bound, and add an admitted-condition error round-trip regression. The node/depth limit does not constrain total string bytes.
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs:44-46: Put the slot-condition string-length limit in SystemLimits
The 256-character cap controls protocol admission for condition constants and membership-list entries, rather than representing an invariant encoding width. The native schema checker independently repeats it in `slot_condition` and `slot_condition_string`. The book assigns numeric protocol limits to `rs-platform-version` and requires version-selected `SystemLimits` values, so these checks should read one named field instead of separate implementation literals. Add the field, populate the historical and mock tables, and use the active snapshot in both validation paths. The bounds agree today and are reached only through PV15, so this is a maintainability issue rather than a current historical-consensus regression.
In `packages/wasm-dpp2/src/data_contract/document_type_reference.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/data_contract/document_type_reference.rs:964-977: Test either-kind declarations and nested conditions across the WASM boundary
The DPP tests cover parsing and schema-value round trips, but none exercises the new JavaScript `type` array or the conversion of slot `when` objects through `platform_value_to_object`. `DocumentPropertyReference.spec.ts` contains no dynamic-reference fixture, and the PR explicitly identifies this conversion as untested. Extend that suite with a PV15 declaration containing both kinds and a nested `when`, then assert that `documentTypeReferences()` returns the exact two-element array and preserves the condition object. Include a single-kind declaration to protect the existing string representation and a `__proto__`-named slot to exercise the own-property conversion with the new condition payload.
Second review of the references whose target the document names: - `require` is judged on every write that checks the reference, and only the number of slots was bounded. It now names nothing twice: no term, no slot within a group, no group with its slots in another order. With at most four slots that is at most fifteen terms, where a contract could repeat one slot thousands of times. - The book's rule for which property fills which slot now starts by choosing the set of slots, as consensus does, so a client reads every reference Platform accepts. - A test makes the assignment search take a property back and then succeed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…laude/dynamic-refers-to-when Brings in the second review's fixes of the base: `require` names nothing twice, the book's client assignment rule chooses the set of slots first, and a test of the assignment search taking a property back. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…Id and documentType
A refersTo whose target the referring document names no longer has keys of
its own for it. It writes the keys every document reference has, read from
the document:
"contractId": "$self.descriptionContractId",
"documentType": "$self.descriptionDocumentType"
in place of contractIdProperty and documentTypeProperty. `$self` is the
document being written, as `$old` is the stored one in a rule. A slot's
name read from the document follows: "$self.bodyProperty" in place of
{ "property": "bodyProperty" }.
Both are read from the document or neither: one of them literal, or left
out, beside the other is refused, as is documentTypeRequirements beside a
target the schema names. Protocol version 14 gives the prefix no meaning
and refuses such a declaration. What is stored is unchanged.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…laude/dynamic-refers-to-when
Brings in the target read through `$self.` on contractId and documentType,
and a slot name read as "$self.<property>".
With `$self` now the referring document, the operand of a slot's `when`
that reads the property tried for the slot is renamed `$property`:
{ "not": { "contains": ["$moderatorAbilities.deleteKeepsFields", "$property"] } }
so each word means one thing in a declaration. `$self` in a `when` is
refused: a condition on the referenced type does not read the referring
document.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
A string property declaring both maxLength and maxBytes was held to its maxBytes alone when a slot's maxBytes was checked, so one of at most two characters (eight bytes) with a maxBytes of 100 failed a slot of eight bytes it can never exceed. The bound is now the smaller of maxBytes and four bytes a character of maxLength. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…laude/dynamic-refers-to-when Brings in the tighter of a string property's two bounds when a slot's maxBytes is checked. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…rors decodable Review of the references whose target the document names: - Only a contractId or documentType written "$self.<property>" selects the reading this version adds. A contract stored under an earlier protocol version is parsed again whenever it is loaded, and a declaration naming its target in the schema could carry a documentTypeRequirements key that version never read: it made the stored contract fail to load. The key stays unread on a load and is refused at registration, by the native schema check. - ReferencedEntityNotFoundError carries such a target without its requirements. A declaration can be larger than the 2000 bytes a client decodes a consensus error within, and the requirements say nothing of a missing document. - The wasm description of a document-named target, its requirements and a slot named __proto__ are covered at the JS boundary. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…laude/dynamic-refers-to-when Brings in the reading of stored references as registered, the error that carries a document-named target without its requirements, and the wasm boundary tests of the base. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The current head incorporates the $self. target spelling and tighter string-slot bounds while preserving the unreleased PV15 activation boundary; no additional issue was confirmed beyond the four carried findings. Verification was static against 2d7a341, without running builds or tests. Current CI reports Kotlin tests and the book preview passing, no failed code checks, and the review check pending; it provides no Rust or WASM test results.
🔴 1 blocking | 🟡 3 suggestion(s)
Still open from earlier rounds (4)
- 🔴 Blocking: Charge for repeated slot-condition evaluation —
packages/rs-dpp/src/data_contract/document_type/property/dynamic_document_reference.rs:462-471(thread) - 🟡 Suggestion: Keep admitted condition payloads within the consensus-error decoder budget —
packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs:549-564(thread) - 🟡 Suggestion: Put the slot-condition string-length limit in SystemLimits —
packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs:53-55(thread) - 🟡 Suggestion: Test either-kind declarations and nested conditions across the WASM boundary —
packages/wasm-dpp2/src/data_contract/document_type_reference.rs:964-977(thread)
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: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate change adds slot-condition evaluation and either-kind reference matching in rs-dpp's dynamic_reference.rs and slot_condition.rs and changes consensus document-reference validation in rs-drive-abci's document_reference_validation/v1/mod.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-dpp/src/data_contract/document_type/property/dynamic_document_reference.rs`:
- [BLOCKING] packages/rs-dpp/src/data_contract/document_type/property/dynamic_document_reference.rs:462-471: Charge for repeated slot-condition evaluation
(carried; thread: https://github.com/dashpay/platform/pull/5850#discussion_r4532867450)
In `packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs:549-564: Keep admitted condition payloads within the consensus-error decoder budget
(carried; thread: https://github.com/dashpay/platform/pull/5850#discussion_r4532867464)
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/dynamic_reference.rs:53-55: Put the slot-condition string-length limit in SystemLimits
(carried; thread: https://github.com/dashpay/platform/pull/5850#discussion_r4532867474)
In `packages/wasm-dpp2/src/data_contract/document_type_reference.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/data_contract/document_type_reference.rs:964-977: Test either-kind declarations and nested conditions across the WASM boundary
(carried; thread: https://github.com/dashpay/platform/pull/5850#discussion_r4532867481)
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
Review of the either-kind targets and slot conditions: - Judging the document type a reference names against its documentTypeRequirements is billed by the comparisons it may take (each property a slot tries, and each node of the slot's `when` for it), 100 credits each, before the type is judged, so a write refused for a type that does not meet them pays for it too. The work grows with the type's properties, the slots and their conditions, and nothing was charged for it. - Each string an `in` or a `notIn` lists counts toward the node limit of a `when`, checked before the list is read: one condition could otherwise hold any number of them. - The length of a string a `when` is written with is a SystemLimits value, read by the parser and by the native schema check, in place of a literal repeated in both. - The kind list and nested conditions are covered at the JS boundary, and the spec casts a property before reading its reference, which the type-checked run of the base's spec needs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…fers-to-when The references whose target the document names are merged into v5.1-dev (#5849), which this branch is now based on. Every file this branch touches holds on v5.1-dev exactly what this branch already merged from that pull request's head, so each keeps this branch's version; the rest of v5.1-dev comes in unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
…fers-to-when Brings in the keys with a budget or an expiry that sign no data contract (#5861). No conflict. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
At b8b5a39, the either-kind and slot-condition changes remain isolated to unreleased PV15 and respect the protocol, state-validation and binding boundaries; no remaining actionable defects were found. This was static verification only, with no local builds or tests run. Current CI reports passing Rust workspace, wasm32, JS, mobile, Docker, functional and E2E checks; review and hygiene gates remain 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: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The change adds an intricate condition evaluator and alters consensus-critical reference acceptance in packages/rs-dpp/src/data_contract/document_type/property/slot_condition.rs and packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v1/mod.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); 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 |
…ecision-proposal-description-reference Brings in v5.1-dev at 78d691d, which now holds the either-kind targets and slot `when` change (#5850) as a squash, together with the multiple choice proposals branch this one is built on. - Files #5850's squash left identical to its last head keep this branch's version, which adds the type-level `when`, `$electedAbilities` and the `present`/`absent` conditions on top of it. - document_reference_validation 1 keeps reading the elected team's abilities for the named type before judging its requirements. - Protocol version 15 notes read 33 (reference whose target the document names, with the type-level `when`), 34 (keys with a budget), 35 (composite document history), 36 (a contest among documents). - The ten nullifier_batch_guard roots and the activation root are recomputed for this branch's decision proposals schema on the new base. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Basic explanation
What this does: #5849 lets a document point at a document of whatever contract and document type it names, as long as that type "looks right" (for example, it has a text field). This adds two things to that. The pointer may accept a document that is never removed or one that moderators can remove, instead of having to pick one. And the contract may add a condition on the field it is looking for, such as "if moderators can remove these documents, the text must go away with them".
Value: A proposal can take its description from a text hosted anywhere, and be sure of one of two things: the text stays for good, or moderators can take it down completely. What it rules out is a text that stays public after moderators removed the document, or a text field only moderators write.
Risks: Low to medium. It changes consensus at protocol version 15 only, which is unreleased, and only for the references #5849 adds. The condition is a new nested type stored in contracts and carried in consensus errors, so its decoding is depth limited and its size is capped at 16 conditions. It changes the stored form of a type #5849 introduced (merged, unreleased), so it must ship in the same protocol version, and it adds a small processing fee for judging the named type (100 credits a comparison, at most 680,000 for one reference). No full test suite, JS build or mobile build was run locally.
Issue being fixed or feature implemented
With #5849 a reference naming its target through the referring document is
permanentDocumentormoderatedDocument, and adocumentTypeRequirementsslot describes a property by name, type and size. Two things could not be said:moderatorAbilities.deleteKeepsFields) and can reserve fields for moderators (moderatorAbilities.changeFields); a description held in either is not a text its author wrote that moderation can take down.#5849 is merged; this is based on
v5.1-dev, with it merged in.What was done?
The vocabulary
typemay list both kinds, and a slot may carrywhen:whenis written like apropertyConstraintscondition and read against the referenced type's schema, never a document."$kind"permanentDocumentormoderatedDocument"$property"$selfis the referring document, which awhendoes not read)"$moderatorAbilities.deleteKeepsFields""$moderatorAbilities.changeFields"{ "const": "<string>" }Conditions:
equal,notEqual,in,notIn,contains,not,anyOf,allOf,ifThen,ifThenElse, with the same shape rules as inpropertyConstraints(two or more operands, none listed twice, no combinator directly inside itself, nonotofnotornotIn). A property the condition does not hold for does not fill the slot;distinctFrom,requireand the search for an assignment work as before over what is left.Where it lives
rs-dpp:DynamicDocumentReferenceKind::PermanentOrModeratedwithchecked_as, which gives the kind a reference is checked as from the kind the named type is.RequiredPropertySlot::when, aSlotCondition(newproperty/slot_condition.rs) judged byDocumentTypeRequirements::met_byfor each candidate property. The parser (try_from_schema/dynamic_reference.rs) and the native schema check read the list and the condition.SlotConditions, the list a condition holds inside it, decodes through a hand-written decoder that refuses a nesting pastMAX_SLOT_CONDITION_DECODE_DEPTH(16), the wayReferenceOperandsdoes for reference expressions: the condition is embedded in a reference target, which consensus errors carry to clients.rs-platform-version:max_document_type_requirement_condition_nodes(16) andmax_document_type_requirement_condition_text_length(256) inSystemLimits, backfilled;requirement_credits_per_comparison(100) in the document reference fee group; note 33 of protocol version 15 extended.rs-drive-abci:document_reference_validation1 settles the reference's kind once the named type is known, and bills the judging of the named type before it judges it: 100 credits for each property a slot tries and for each node of the slot'swhenfor that property (DocumentTypeRequirements::comparisons), so a write refused with 40153 pays for it too.wasm-dpp2: the declaration is described with itstypelist and each slot'swhen, with TypeScript types. The shape of awhenis rs-dpp's (SlotCondition::to_schema_value, which the parser reads back), like the rest of the requirements since the review of feat(platform)!: document references whose target the document names (PV15) #5849.when)"; the keyword and limit tables and the internals section follow.Before and after
A note pointing at a document of a type it names, under the declaration above:
After a moderator removes the post a note points at, with the either-kind declaration:
A declaration that does not parse:
Choices a reviewer may want to question
$kindcompares only withpermanentDocumentormoderatedDocument. A misspelt kind would otherwise make a condition that silently never holds.permanentDocumentreference, since the declaration has no kind of its own to name in an error.containsmatches a whole entry of the list against the property name. A slot is only ever filled by a top-level scalar property, so a nested path indeleteKeepsFieldsnever names one.whenholds at most 16 conditions, counted with their combinators and with each string aninor anotInlists, and no string in it is longer than 256 characters. The example above is 7. The limit also bounds the nesting, which is why it sits at the decode bound and a test holds every protocol version's limit to it.whenreads the type only. It cannot read a value of the referenced document, so "the document actually has text" is still not expressible.How Has This Been Tested?
Targeted runs only, on macOS:
cargo test -p dpp --lib --features all-system_contracts,fixtures-and-mocks,validation -- data_contract consensus: 3308 passed. New intry_from_schema/v3/dynamic_reference_tests.rs(8 tests: thetypelist and its refusals, the kind a reference is checked as, every form of a condition, every malformed condition, the node limit, a condition narrowing what fills a slot, a moderated type against a permanent one with realmoderatorAbilities, and the platform serialization round trip) and inproperty/slot_condition.rs(5 tests: evaluation of every form, the round trip through every decoder, the refusal past the decode bound with nesting claimed by hand, and the limit held within the bound).RUST_MIN_STACK=16777216 cargo test -p drive-abci --lib -- reference referenced_rules data_contract_create data_contract_update: 434 passed (withtyped_array_whereadded to the filter). New incontract_user_moderation/tests/dynamic_document_reference.rs:should_check_a_reference_of_either_kind_as_the_kind_the_named_type_is(a moderated type whose text a removal takes, one whose removal record keeps it, a permanent type, a deletable type, a missing document, the reference kept after a removal, and a replace pointing it at a permanent type). The larger stack is for an existing contract-creation test that overflows the default test stack in a local debug build.cargo test -p wasm-dpp2 --lib -- consensus_error document_type_reference,cargo test -p platform-version: passed.cargo clippy --all-targets --all-features --locked -- --no-deps -D warningson dpp, drive-abci, platform-version, wasm-dpp2 and wasm-dpp: clean.cargo checkon dash-sdk and drive-proof-verifier: clean.Not run: any full suite, the JS and wasm32 builds, the mobile builds. The JS boundary tests added to
DocumentPropertyReference.spec.ts(the kind list, a nestedwhen, a__proto__slot) were written and syntax-checked but not run locally: there is no wasm build of this branch here, so CI is their first run.In-place changes to shipped generations
Everything this PR reads or writes is reached only through
apply_property_reference1 anddocument_reference_validation1, whichCONTRACT_VERSIONS_V7andDRIVE_ABCI_VALIDATION_VERSIONS_V11(protocol version 15, unreleased) alone select, and which #5849 introduces.SystemLimitsapply_property_reference1 andcheck_document_type_schema1 onlyFEE_DOCUMENT_REFERENCE_VERSION1, the fee group every fee schedule sharesrequirement_credits_per_comparison, read bydocument_reference_validation1 only, the waywhere_list_credits_per_elementwas added to ittuplein the native schema check of constraints (visibility only)DynamicDocumentReferenceKindgains a variant andRequiredPropertySlota field. Both types were introduced by #5849, now onv5.1-devand unreleased, so no released protocol version has stored either; this must reachv5.1-devbefore protocol version 15 is released.Breaking Changes
Consensus changes at protocol version 15 only: a
refersTonaming its target through the referring document may list both kinds and its slots may carrywhen. Protocol version 14 and earlier are unchanged.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 ·
b8b5a39/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.