Registry Mirror
Skip to content

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: A document can point at another document through a value it holds. Until now that value had to be an id, or a hash computed by a function (commit and reveal). This PR lets a plain text or binary property do it too. For example, a post can name its author's handle as text. Whenever the post is written, the platform checks that a handle with exactly that name exists, by looking the name up in the handle type's unique name index.

Value: Contracts can point at documents by the values people actually use, such as names, instead of storing a copy of the target's id beside them. This is the second prerequisite for DPNS name tombstones: a tombstone names the domain it buries by its label.

Risks: Medium. This changes consensus rules of protocol version 14, which is unreleased: which contracts are accepted, and how a reference found through an index is judged when a document is written.

  • Two edge cases from review, both fixed here. The index files a few different values under the same key (the empty string and "\0"; an empty byte array and no value), so the platform now checks that the document it finds holds exactly the value. A value too long for an index key used to fail the whole transition with an internal error; it now finds nothing, and the write is refused.
  • Who else the fixes touch. Both checks run for every such lookup. They always pass for ids and hashes, so existing references behave as before. References that read a text or binary property as another part of the key become stricter in those two edge cases.
  • Exact matching. Matching is byte for byte, so "Alice" does not find alice: contracts must store normalized values.
  • What stays the same. No storage layout changes and no new fees.

Issue being fixed or feature implemented

A string or byte array property could carry a refersTo only through a findBy function reading it. A reference by name, the most common key a person types, needed an identifier copy of the target's id instead. A findBy with "." on such a property was refused:

must be a permanentDocument or deletableDocument reference found by a findBy function reading the value

What was done?

  • Parser (apply_revealed_reference_v0): a string or byte array property may carry any permanentDocument or deletableDocument reference found by findBy. inList is still refused, since a list holds ids.
  • Referring side: the refusal of a "." source on such a property is removed.
    • The parse still requires "." to be read exactly once.
    • A function reading the property beside "." counts as a second read and is refused.
  • Referenced side: "." must fill an index property of the carrier's kind, a string a string and a byte array a byte array. DocumentReferenceLookup::referenced_side_error is now told which property carries the reference.
  • Write path (document reference validation 0): a value read as "." is judged as an identifier's value is.
    • It is checked on every create.
    • On a replace, it is checked when the value changes, or a property the key reads changes, or always for a deletableDocument target (binds_a_changed_property).
    • A computed key keeps its create-only rule.
    • The value reaches the lookup as RevealedValue. DocumentReferenceLookup::key_values and fetch_document_through_lookup take "." as a Value.
    • A refusal carries an all-zero entity id beside the property path: the value is no id, and no hash stands for it.
  • The document found must hold the value (fetch_document_through_lookup, holds_key_part). The index finds a document by the key's encoding, which reads the empty string as "\0" and an empty byte array as no value at all. The document the index returns is now a candidate: it must hold each string or byte array part of the key exactly, or the lookup finds nothing (40120). No extra read is made.
  • A value too long for an index key finds nothing. The referring property need not share the referenced one's bounds, so a string or byte array read as is can be longer than an index key may be (255 bytes). Such a key used to fail the transition with an internal error, which drops it from the block. It now finds no document, without a read, and the write is refused paid with 40120.
  • Immutable properties: validate_no_immutable_deletable_element_references now reads revealed references too. A deletableDocument found by a string value can therefore not sit under an immutable property, the same rule as for an identifier.
  • Docs:
    • meta-schema v3 descriptions and v14 note 61;
    • the book: refers-to-lookup gains a new section, "A string or byte array key"; refers-to and documents are updated;
    • the wasm-dpp2 DocumentReferenceFindBy doc.

Before and after

"handle": {
  "documentsMutable": false,
  "canBeDeleted": false,
  "properties": { "name": { "type": "string", "maxLength": 63, "position": 0 } },
  "indices": [{ "name": "name", "properties": [{ "name": "asc" }], "unique": true }],
  "required": ["name"],
  "additionalProperties": false
},
"post": {
  "properties": {
    "authorHandle": {
      "type": "string",
      "maxLength": 63,
      "position": 0,
      "refersTo": {
        "type": "permanentDocument",
        "documentType": "handle",
        "findBy": { "name": "." }
      }
    }
  },
  "required": ["authorHandle"],
  "additionalProperties": false
}
  • Before: registration refused it:

    refersTo on a string or byte array property must be a permanentDocument or deletableDocument reference found by a findBy function reading the value: the value is not an id

  • After: it registers.

    • A post with authorHandle: "alice" is accepted when a handle named alice exists.
    • It is refused with 40120 at authorHandle when no such handle exists. "Alice" finds nothing either, because the key is the value byte for byte.
    • A replace that changes authorHandle is checked again.

In-place changes to shipped generations

  • apply_property_reference 0 and apply_revealed_reference_v0: only protocol version 14 sets apply_property_reference: Some(0), so no earlier contract reaches the changed lines.
  • Document reference validation 0 and fetch_document_through_lookup: every protocol version selects them, but only the protocol version 14 parser produces a revealed reference or a lookup, so nothing before protocol version 14 reaches the changed lines. For lookups that exist today:
    • for an identifier, the lookup receives the same Value::Identifier the old code built, and a function's "." param reads the same identifier;
    • a computed key on a string or byte array keeps its create-only arm, its hash and its error id;
    • the two new checks apply to every lookup, but an identifier, a hash and every kind other than a string or byte array encode one value one way and fit an index key, so both checks always pass for them. A protocol version 14 lookup with a string or byte array property source (findBy from feat(dpp)!: refersTo finds a document with findBy and checks it with where #5197) is held to them too: it no longer accepts the aliased value, and an over-long source finds nothing instead of failing the transition. Protocol version 14 is unreleased.
  • create_document_types_from_document_schemas 1 and data contract reference validation 0: referenced_side_error still gives "." the identifier kind for every carrier except a string or byte array property, and only protocol version 14 parses those.
  • Meta-schema v3, parser generation 3 and v14 note 61: selected only by protocol version 14, which is unreleased.

How Has This Been Tested?

  • dpp, new string_find_by_key_tests:
    • a string and a byte array property each parse with findBy: { "<index property>": "." } into an index property of their kind, judged again on replace;
    • "." into an index property of another kind is refused: a string into an identifier or a byte array, a byte array into a string or an identifier;
    • a deletableDocument found by a string on an immutable property is refused;
    • a value read both as "." and by a function is refused (two reads).
  • dpp, existing tests: the commit-and-reveal refusal test drops the case that now parses, and the list-element test's expected message is updated.
  • drive-abci, through the full ABCI pipeline (commit_reveal_lookup.rs, a handle / post fixture):
    • a post naming an existing handle is accepted;
    • one naming no handle, or the right name in another case, is refused with 40120 at authorHandle with an all-zero id;
    • a replace changing the name to a missing handle is refused, and to an existing one accepted;
    • with deletable handles, a replace keeping a deleted handle's name is refused, and one naming another handle is accepted;
    • a post naming "\0" does not find the handle "", which shares its key, and a post naming "" does;
    • a 130-character, 260-byte name is refused with 40120 on a create and on a replace, where it used to fail the transition with an internal error;
    • with handles unique by name and scope, a replace changing only the post's scope is refused for a combination no handle has and accepted for one that exists.
  • drive-abci, a byte array carrier (a handle with an optional tag of up to 20 bytes, a post whose authorTag holds up to 300):
    • a 20-byte and a 7-byte tag find their handles, the 20 bytes sent as Value::Bytes and as Value::Bytes20;
    • a missing tag is refused with 40120 at authorTag, on a create and on a replace, and a replace naming another existing tag is accepted;
    • an empty tag does not find a handle without one, which shares its key;
    • a 256-byte tag is refused with 40120 on a create and on a replace.
  • Before the fix, the two alias tests and the two over-long tests failed: the aliases were accepted, and the over-long values ended in InternalError("... value must be less than 256 bytes long").
  • Commands:
    • cargo test -p dpp --lib
    • cargo test -p drive-abci --lib -- commit_reveal refers_to reference lookup dpns document moderation data_contract
    • cargo clippy -p dpp -p drive-abci --all-targets
    • cargo check -p wasm-dpp2
    • cargo fmt --all -- --check

Breaking Changes

Consensus-breaking within protocol version 14, which is unreleased: nodes must agree on these rules.

  • Contract admission: a refersTo with findBy reading a string or byte array property as "." is refused by earlier protocol version 14 builds and accepted by this one.
  • Lookups with a string or byte array key part: the document found must hold exactly the key's value, and a key part too long for an index finds nothing. Earlier builds accepted the aliased value and failed the transition on the over-long one.
  • Rust: DocumentReferenceLookup::referenced_side_error now takes the property carrying the reference, and key_values takes "." as a &Value.

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 · aaa831e

  • Bots — coderabbitai ✓ · thepastaclaw not yet — /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.

Summary by CodeRabbit

  • New Features
    • String and byte-array properties can carry document references using their value directly, without a lookup function. Values must match the indexed property’s type and exact stored value.
    • Direct-value references are rechecked on applicable replacements. Deletable-document references of this form are not allowed under immutable properties.
  • Documentation
    • Updated reference and data-model guidance with matching rules and error details.

…rty's value

A string or byte array property could carry a `refersTo` only through a
`findBy` function reading it (commit and reveal). It may now carry any
permanentDocument or deletableDocument reference found by `findBy`, its
value read as is: `"."` fills an index property holding the same kind of
value (a `post` names a `handle` by its unique `name`).

- Parser: `apply_revealed_reference_v0` admits any `findBy` lookup on
  such a property (`inList`, which holds ids, stays refused); the
  referring side drops the refusal of a `"."` source there.
- Referenced side: `referenced_side_error` takes the property carrying
  the reference, so `"."` holds a string or byte array property's kind.
- Write path: a value read as `"."` is judged as an identifier's value
  is, on every create and on the replaces `binds_a_changed_property`
  names; a computed key stays create-only. The value reaches the lookup
  as `RevealedValue`; `key_values` and `fetch_document_through_lookup`
  take `"."` as a `Value`. A refusal carries an all-zero entity id.
- `validate_no_immutable_deletable_element_references` reads revealed
  references too.
- Docs: meta-schema v3, v14 note 61 (in place), the book and the
  wasm-dpp2 findBy doc.

Tests: dpp `string_find_by_key_tests` (parse, kind mismatch, immutable
deletable, "." beside a function); drive-abci `handle`/`post` pipeline
tests (found, not found and case-sensitive 40120 with a zero id, replace
re-validation, deletable target re-checked on every replace).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added this to the v5.0.0 milestone Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

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

Updated at 2026-10-11T05:46:48.404Z

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 10, 2026
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cf02e627-a28c-4516-8129-fdefaa335205



📥 Commits

Reviewing files that changed from the base of the PR and between 107a0e1 and aaa831e.




📒 Files selected for processing (5)
  • book/src/contract-keywords/refers-to-lookup.md
  • book/src/data-model/documents.md
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/fetch_documents.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs
  • packages/rs-platform-version/src/version/v14.rs



🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/rs-platform-version/src/version/v14.rs
  • book/src/data-model/documents.md



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





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

String and byte-array properties can now supply findBy lookup values directly through ".". Schema validation checks value kinds and carrier constraints. Runtime reference validation uses these values for lookups and revalidates direct-value references on applicable replacements. Documentation and tests cover parsing, matching, and replacement behavior.

Changes

Direct-value findBy references

Layer / File(s) Summary
Schema acceptance and validation
book/src/contract-keywords/*, book/src/data-model/documents.md, packages/rs-dpp/schema/meta_schemas/document/v3/document-meta.json, packages/rs-dpp/src/data_contract/document_type/..., packages/rs-dpp/src/data_contract/document_type/property/*, packages/rs-platform-version/src/version/v14.rs, packages/wasm-dpp2/src/data_contract/document_type_reference.rs
Schema parsing accepts string and byte-array properties as direct findBy carriers. Lookup validation checks that the carrier and indexed property use matching value kinds.
Lookup value construction and matching
packages/rs-dpp/src/data_contract/document_type/property/*, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/state/v0/fetch_documents.rs
Lookup construction accepts the carrier value directly. Candidate documents must match string and byte-array key parts exactly. Unrepresentable key parts do not produce a match.
Runtime reference validation
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_common/data_contract_reference_validation/v0/mod.rs
Runtime validation passes revealed values into lookup processing. Direct-value references are checked on applicable replacements. Missing-reference errors for direct values use an all-zero identifier.
Schema and pipeline tests
packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v3/*, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs
Tests cover accepted and rejected schemas, exact string and byte-array matching, missing targets, key limits, and replacement behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: thepastaclaw, shumkov

Sequence Diagram(s)

sequenceDiagram
  participant DocumentReferenceValidation
  participant fetch_document_through_lookup
  participant DocumentReferenceLookup
  DocumentReferenceValidation->>fetch_document_through_lookup: Pass the revealed reference Value
  fetch_document_through_lookup->>DocumentReferenceLookup: Build the lookup key from the reference value and document data
Loading




Merge Risk: ⚪ Minimal · up to aaa83

No identified issue blocks merging after normal validation.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 88.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 15 files. (2 skipped: 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: resolving references by matching string or byte-array property values.

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






🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR





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

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

❤️ Share

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

@thepastaclaw

thepastaclaw commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress — actively reviewing now (commit aaa831e) · triage: critical
██████████████░░░░░░ 70% · taking longer than usual · running for 19 min
✅ triage → ⏳ Phase 2 (5/5 lanes, 1 comparison still going) → ✅ Phase 1 → ▫️ verify 2 → ▫️ fresh Phase 2 → ▫️ fresh verify → ▫️ publish
Estimated from recent reviews of this tier · updated 06:06 UTC · live progress

@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

Verified the combined reviewer findings against exact head 107a0e1. The protocol-14 gating is consistent, but the new direct-value lookup exposes two blocking issues: oversized carriers become internal execution errors, and index-key aliases can satisfy references without actual value equality. This was a static review; the supplied CI snapshot reports successful Rust workspace tests, with the main Test Suite, browser suite (1), and PR Hygiene still pending.

🔴 2 blocking | 🟡 3 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Verify actual property equality before accepting direct-value references
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs:1293-1294

The lookup result establishes encoded index-key equality, not the advertised byte-for-byte property equality. DocumentPropertyType::encode_value_for_tree_keys encodes both the empty string and a one-NUL string as [0]. With the new handle/post fixture, a handle whose name is empty can therefore satisfy a post whose authorHandle is "\u0000", although no handle has that name. There is also a byte-array alias: an empty byte array encodes as the empty key used for an absent property. For an optional target property with a null-searchable unique index, the query's null-key subquery can return a document that has no such property. fetch_document_through_lookup takes the first result, query_documents_v0 only deserializes it, and the subsequent agreement loop checks explicitly declared where pairs rather than the direct lookup condition. Treat the indexed document as a candidate and compare the actual property filled by the direct ReferenceValue source with the carrier using scalar/byte equality; reject absence or mismatch with 40120. Scope the check to the newly admitted direct carriers, preserve the existing index encoding, and add regressions for both aliases.

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

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

  • Triage: critical by gpt-6.1-sol (effort low) — The change intricately alters consensus acceptance rules across schema parsing and document creation/replacement, notably in document_reference_validation/v0/mod.rs and reference_lookup.rs.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort xhigh); agent phase2-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. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs:1279-1285: Handle oversized direct reference values before querying Drive
  The newly accepted carrier need not be indexed or share the target property's size bounds. A contract can therefore admit a non-indexed string or byte-array carrier longer than 255 bytes, while its findBy target uses a bounded unique index. Registration compares value kinds only, and this branch forwards the entire carrier into the equality query. DocumentType::serialize_value_for_key_v0 rejects an encoded key longer than MAX_INDEX_SIZE with DataContractError::FieldRequirementUnmet; fetch_document_through_lookup propagates that error rather than returning a reference miss. Transition processing consequently produces InternalError, which prepare_proposal removes from the block, instead of the paid 40120 refusal promised for a value with no matching target. Check key representability before querying and return a typed reference-validation failure for this input-specific condition, while preserving genuine storage errors. Cover create and replace with oversized bytes and strings, including multibyte UTF-8.
- [BLOCKING] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_reference_validation/v0/mod.rs:1293-1294: Verify actual property equality before accepting direct-value references
  The lookup result establishes encoded index-key equality, not the advertised byte-for-byte property equality. DocumentPropertyType::encode_value_for_tree_keys encodes both the empty string and a one-NUL string as [0]. With the new handle/post fixture, a handle whose name is empty can therefore satisfy a post whose authorHandle is "\u0000", although no handle has that name. There is also a byte-array alias: an empty byte array encodes as the empty key used for an absent property. For an optional target property with a null-searchable unique index, the query's null-key subquery can return a document that has no such property. fetch_document_through_lookup takes the first result, query_documents_v0 only deserializes it, and the subsequent agreement loop checks explicitly declared where pairs rather than the direct lookup condition. Treat the indexed document as a candidate and compare the actual property filled by the direct ReferenceValue source with the carrier using scalar/byte equality; reject absence or mismatch with 40120. Scope the check to the newly admitted direct carriers, preserve the existing index encoding, and add regressions for both aliases.

In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs:1330-1338: Exercise direct byte-array references through the write pipeline
  The new ABCI cases all use the string handle/post fixture. The byte-array case in string_find_by_key_tests only parses the contract and inspects its declaration, so it does not exercise the new RevealedValue path across transition serialization, stored-document decoding, index-key encoding, and replacement validation. Add a byte-array fixture through process_raw_state_transitions covering a matching create, a missing value's 40120/path/zero-id refusal, and replacement with a changed value. Include a non-32-byte key and the binary representations supported by the transition API so the tests protect byte-array behavior rather than implicitly relying on identifier-shaped data.
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/commit_reveal_lookup.rs:1354-1357: Cover replacement when only another lookup key part changes
  This test changes the carrier itself, and the deletable-reference test exercises unconditional revalidation. Neither covers the new PropertyReference::Revealed branch when a permanent reference keeps its carrier but binds_a_changed_property must trigger revalidation because another findBy source changed. Existing identifier-reference tests enter a different branch and would not catch a regression in this new control flow. Add a composite unique-key fixture such as (name, scope), keep the carrier name unchanged, and replace only the referring scope. A nonexistent combination should return 40120 at the carrier path, while an existing combination should succeed.

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:914-918: Mark the contract-admission change as consensus-breaking in release metadata
  This admission change is correctly confined to unreleased protocol 14, but it still changes a protocol rule: old and new protocol-14 implementations disagree about whether the same contract declaration is valid. book/src/contributing/coding-conventions.md reserves the ! marker for protocol-rule changes that nodes must agree on, not merely incompatible client APIs. Update the PR title to feat(dpp)!: and describe the protocol-14 contract-admission change in Breaking Changes instead of saying "None for contracts". This does not require another protocol snapshot; it makes the release classification match the repository's documented convention.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Oct 10, 2026
…ong key finds nothing

The index finds a document by the key's encoding, which reads the empty
string as "\0" and an empty byte array as no value at all. So a post
naming "\0" found the handle "", and an empty byte array found a handle
without a tag. `fetch_document_through_lookup` now treats the document
the index returns as a candidate: it must hold each string or byte array
part of the key exactly (`holds_key_part`), whichever binary form either
side carries, or the lookup finds nothing (40120). No extra read.

A string or byte array read as is need not share the referenced
property's bounds, so its key could exceed MAX_INDEX_SIZE. The query
then failed with FieldRequirementUnmet, an internal error that drops the
transition from the block. A key part `serialize_value_for_key` refuses
now finds no document, without a read: the write is refused paid.

Both checks apply to every lookup; identifiers, hashes and the other
kinds encode one value one way and fit an index key, so they always pass
there. Protocol version 14 only, unreleased.

Tests (drive-abci, through the ABCI pipeline): the "\0" / "" alias, a
260-byte name on create and replace, a key part other than the carrier
changing on replace, and a byte array carrier (20 and 7 bytes, Bytes and
Bytes20 forms, missing, replaced, empty against a tagless handle, 256
bytes on create and replace). The alias and over-long tests failed
before the fix. Docs: the book and v14 note 61.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QuantumExplorer QuantumExplorer changed the title feat(dpp): find a referenced document by a string or byte array property's value feat(dpp)!: find a referenced document by a string or byte array property's value Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Oct 11, 2026
@QuantumExplorer

Copy link
Copy Markdown
Member Author

On the blocking finding without an inline thread (Verify actual property equality before accepting direct-value references): fixed in aaa831e. fetch_document_through_lookup now treats the document the index returns as a candidate. It must hold each string or byte array part of the key exactly (holds_key_part), compared as text or as bytes whichever binary form either side carries; otherwise the lookup finds nothing and the write is refused with 40120. No extra read is made, and the index encoding is unchanged. Every other kind encodes one value one way, so the check always passes for identifiers and hashes. It also applies to string or byte array property sources, which alias the same way.

Regressions: a post naming "\0" no longer finds the handle "" (and "" still does), and an empty authorTag no longer finds a handle without a tag. Both were accepted before the fix.

🤖 Addressed by Claude Code

@QuantumExplorer

Copy link
Copy Markdown
Member Author

Reviewed

@QuantumExplorer
QuantumExplorer merged commit db5dc6d into v5.0-dev Oct 11, 2026
56 of 58 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/string-find-by-key branch October 11, 2026 06:08
QuantumExplorer added a commit that referenced this pull request Oct 11, 2026
Conflicts with #5367, which let a string or byte array property carry a
findBy read as ".", in the same places:
- apply_revealed_reference_v0: #5367 no longer requires a function on a
  string or byte array carrier, so this branch's `hash_key().is_some()`
  there goes; any lookup is admitted.
- Meta-schema v3 findBy description and the book (refers-to-lookup,
  documents): #5367's string-carrier wording beside this branch's
  minimumAgeBlocks/consume and "$ownerId" wording.
- string_find_by_key_tests: `is_checked_on_create_only(true)`, the post
  type being mutable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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