Repository navigation
feat(dpp)!: refersTo moderatedDocument, a reference that outlives a moderator's removal (PV14) - #5214
Conversation
…oderator's removal (PV14) A third kind of document reference, between permanentDocument and deletableDocument and disjoint from both. It targets a document type whose documents leave state only through a moderator's recorded removal: canBeDeleted false, no ttl, and moderatorAbilities.delete keeping removal records. - The referenced document must exist when the reference is written. A replace keeps it as a permanent reference is kept; once a moderator removed the document, a value the stored document held resolves to its removal record, and a where entry asked about again is checked against the record's owner and id (40145 otherwise). - Registration refuses a moderatedDocument reference to any other type (40143) and a deletableDocument reference to such a type (40144); the write-time check still lets the latter through for contracts registered earlier. - Chained and composite joins through it prove the removal records of the joined ids beside their documents and report each removed document with its record (proto field 4 on ChainedDocuments and on a composite SubQueryResult, clients regenerated). - Id form only: no findBy, inList or expression operand; a writer gate may compare only the referenced $ownerId or $id. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (66)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds ChangesModerated document references
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant QueryClient
participant DriveDocumentQuery
participant ModeratedJoin
participant ProofVerifier
QueryClient->>DriveDocumentQuery: Request chained or composite query
DriveDocumentQuery->>ModeratedJoin: Fetch removal records for missing joined IDs
ModeratedJoin->>ProofVerifier: Supply removal paths and decoded records
ProofVerifier->>QueryClient: Return verified results with removal records
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change adds a moderated reference kind whose references can outlive a moderator's removal of the target document. Chained and composite queries now return proven removal records. No concrete defects were identified in validation, proofs, or client result shapes, so the change appears ready to merge. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to This changes how references remain valid after moderation and how clients authenticate removal records. The inspected controls preserve identity checks and proof verification, but end-to-end recovery and mixed-version rollback behavior are not fully established. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❓ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 72.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 155 functions across 44 files. (21 skipped: 9 unsupported, 6 too large, 6 over the file limit.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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-30T02:19:22.767Z |
|
🔍 Review in progress — actively reviewing now (commit abf2d00) · triage: critical |
…ers and the JS surface - A reply in another contract keeps its moderated reference to a post the posts contract's moderators removed, its writer gate checked against the record under the posts contract (fails if the record is read from the replying contract); registration refuses the deletableDocument form of the same reference (40144). - The chained and composite query handlers return a removed post's record in `removed_outer_documents` and `removed`, as the removals query writes it, and the proven responses verify to the same record. - wasm-dpp2 reports a moderatedDocument declaration with its contractId, documentType and where, and refuses findBy, an expression operand and a writer gate the record can not answer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dentifier ids The conversions behind getChainedDocuments and getCompositeDocuments are fed a verified result holding a removal record directly (only a proved fetch produces one), in wasm-bindgen tests like the ranked query's: `removedOuterDocuments` and a sub-result's `removed` hold the record, every identifier an `Identifier` object like the missing ids beside it, none a base58 string. Run with CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test -p wasm-sdk --target wasm32-unknown-unknown. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Basic explanation
What this does: A document can point at another document with
refersTo. Until now there were two kinds of pointer:permanentDocument, for documents that can never go away, anddeletableDocument, for documents that might vanish at any time. This adds a third,moderatedDocument, for documents their author can not delete but the contract's moderators can take down, where every takedown leaves a record behind (who removed it, when, why, and a fingerprint of the document). A reply pointing at such a post stays valid after the post is removed: the pointer now leads to the removal record instead of to nothing.Value: Apps like Yappr get a precise reference for posts that only moderators remove. Replies, likes and quotes of a removed post keep working and can still be edited, instead of being forced to drop or repoint their reference. Queries that join through such a reference (a feed that shows the quoted post, the posts I liked) now return each removed post with its proven removal record, so a client can show "removed by moderators for spam" rather than a silent gap.
Risks: Medium. It is a consensus change at protocol version 14 (unreleased on mainnet), edited in place. Registration now refuses a
deletableDocumentreference to a type whose documents only moderators remove on the record, a pairing that was accepted before; writes of a contract registered earlier with that pairing still go through. The join proofs gain one more component, so a join through a moderated reference carries a slightly larger proof. The proto change is additive (a new repeated field 4 on two messages).Issue being fixed or feature implemented
A document type with
canBeDeleted: falseandmoderatorAbilities.deletecould only be referred to withdeletableDocument, which assumes the target can vanish without a trace. Every replace of a referring document then had to repoint or clear the reference once a moderator removed the target, and joins reported a removed target as a bare missing id, although the contract holds a removal record for it that nothing ever deletes.What was done?
A third, disjoint reference kind
Each document type now admits exactly one kind of document reference (
DocumentTypeV2Getters::document_reference_kind, aDocumentReferenceKind):permanentDocumentcanBeDeleted: false, nottl,moderatorAbilities.deletekeeping records (the default)moderatedDocument(new)ttl)deletableDocumentBefore:
"type": "moderatedDocument"was refused by the meta-schema (10101), and a reply to such aposthad to declaredeletableDocument.After: it parses to
DocumentPropertyReferenceTarget::ModeratedDocument(appended to the enum). Registration refuses amoderatedDocumentreference to any other kind of type withReferencedDocumentTypeNotModeratedError(40143), and adeletableDocumentreference to a moderated type withReferencedDocumentTypeModeratedError(40144).It takes
contractId,documentTypeandwhere, by id only:findBy,inList, and use as ananyOf/allOfoperand are refused (a removal frees the post's unique index keys, so a key could come to find another document). A writer gate (whereentry valued"$ownerId") may compare only the referenced$ownerIdor$id(10231 otherwise), since a writer gate is checked on every replace and the record keeps nothing else.Replace keeps the reference; it resolves to the removal record
The document must exist when the reference is written. A replace re-validates it exactly as a
permanentDocumentreference. When the value is the one the stored document held (decided from the stored value, so a reference inside an object or a list is kept too) and a moderator removed the target, the validator reads the removal record (billed) and the reference holds through it. Awherepair asked about again compares the referenced$ownerIdwith the record's document owner and$idwith the id; any other property refuses the replace withReferencedDocumentRemovedError(40145).Before (with
deletableDocument, the only option):After (with
moderatedDocument):Joins report removed documents with their proven records
Chained queries and composite by-id joins through a
moderatedDocumentproperty add one more component to the merged proof: the removal records of the joined ids, under[64, contract, 2, 16, <document type>](query::moderated_join). A composite query builds one records component per referenced type. The component names every joined id, so a prover can pass neither a removed document off as missing without its record, nor a live one off as removed; GroveDB refuses a proof that withholds any of them.Before (join off a
deletableDocumentproperty):After (join off a
moderatedDocumentproperty):A joined id with neither a document nor a standing record is refused as a missing
permanentDocumenttarget is (corrupted state on the server, an invalid proof in the verifier).Wire:
repeated GetContractDocumentRemovalsResponse.ContractDocumentRemoval removed_outer_documents = 4onChainedDocuments,removed = 4on a compositeSubQueryResult; generated clients regenerated.rs-drive-proof-verifierandrs-sdkcarryremoved_outer_documents/sub_result_removals; wasm-sdk returnsremovedOuterDocuments/removedasJoinedDocumentRemovalobjects withIdentifierids, like the joins' other ids.Other surfaces
DocumentReferenceErrorCode).DocumentPropertyReferencegains themoderatedDocumentvariant.In-place changes to shipped generations
validate_data_contract_referencesv0 and the document reference validation v0 (drive-abci) now compare kinds throughdocument_reference_kind_mismatch. Before protocol version 14 no document type carriesmoderatorAbilitiesorttl, so every type admitspermanentDocumentordeletableDocumentexactly asdocuments_can_disappearanswered before, and amoderatedDocumentdeclaration does not parse; both errors are the same as before for those two kinds. The removal record read is reached only for amoderatedDocumentreference, which only the protocol version 14 parser produces.create_document_types_from_document_schemasv1 compares a lookup's kind with the type's instead of a permanent flag with deletability. Lookups (findBy) parse from protocol version 14 only, so the check stays inert before it.moderatedDocumentproperty, which exists from protocol version 14 only; every other join builds and verifies the same merged query as before.How Has This Been Tested?
moderated_document_referencetests (registration kinds, keep on replace, repoint and create refused on a removed target, restore,wherepairs against the record, typed-array elements and a reference inside an object kept after a removal, and a reference from another contract whose writer gate is checked against the record under the posts contract; the last two were confirmed to fail without their fixes); the chained and composite query handlers return a removed post's record inremoved_outer_documents/removedon the unproven wire and verify to it on the proven one; the reference, moderation, query, contract create/update and document batch suites (336 + 805 tests).moderatedDocumentblock: the declaration's JS shape, and refusals offindBy, an expression operand and a writer gate the record can not answer) and wasm-sdk unit suite (455 passing) on fresh builds; the karma browser runs were not. wasm-sdk wasm-bindgen tests feed the chained and composite result conversions a verified result holding a removal record and checkremovedOuterDocuments/removedcarry it withIdentifierids (8 wasm32 tests pass; the new ones fail if the ids go back to base58 strings).Breaking Changes
Consensus, protocol version 14 (unreleased on mainnet):
refersTo: moderatedDocumentis accepted, with the rules above.deletableDocumentreference to a type whose documents only moderators remove on the record (40144); such a reference registered earlier stays writable.moderatedDocumentreference whose target a moderator removed.Wire (additive): new field 4 on
GetDocumentsResponseV1.ChainedDocumentsand onCompositeDocuments.SubQueryResult.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 ·
abf2d00/skip-botsproceeds without the ones not yet reported/self-reviewedonce the bots are donejs-wasm-sdk(packages/js-evo-sdk/README.md,packages/wasm-sdk/src/queries/chained_document.rs,packages/wasm-sdk/src/queries/composite_document.rsand 1 more) — shumkovdpp— you own itrs-drive-abci— you own itrs-drive— you own itrust-sdk(packages/rs-sdk/src/mock/requests.rs,packages/rs-sdk/tests/fetch/document_query_v0_v1.rs) — lklimek or shumkovWhen every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit
moderatedDocumentreferences for documents removable only by moderators when removal records are retained.