feat(platform)!: deletable charter team changes and lookups on deletableDocument references (PV14) - #4967
Conversation
…bleDocument references (PV14) addedModerator and removedModerator are deletable: deleting an addition takes the member off and frees its maxAddedModerators slot, deleting a removal puts the elected member back. A removal names an elected member only (a listElement into the charter's members), so the seat check is one point read and the cap counts the additions that exist. refersTo takes a lookup on a deletableDocument reference (DeletableDocumentLookup, appended variant 10): the document exists now, every replace re-validates it, an immutable property may not hold it, and it is an expression operand and an ownerRefersTo target (never creatorRefersTo). The resignation request's added-member operand uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (39)
✨ Finishing Touches📝 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-24T05:40:44.747Z |
|
🕓 Queued for automated review — 6th in line, estimated start in ~1.7 h (commit 5c59672)
|
… reference Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Issue being fixed or feature implemented
Follow-up to #4952 (elected moderation teams moderate from their stored charter), part of #4865.
In the moderation charters contract every team change was final. The leader took an added member off by filing a
removedModeratorfor them, so:addedModeratorstayed forever and kept itsmaxAddedModeratorsslot;This PR makes
addedModeratorandremovedModeratordeletable, so deleting a team change undoes it. A removal may now only name an elected member. The one reference that has to follow a deletable addition is a resignation request's membership check, so this PR also adds a document reference found through alookupon adeletableDocumenttarget.What was done?
Moderation charters contract (
moderation-charters-contract, PV14 genesis)addedModerator:canBeDeleted: true. Deleting an addition takes the member off the team and frees its cap slot. The member can then be added again.removedModerator:canBeDeleted: true. Deleting a removal puts the elected member back.memberIdnow carriesrefersTo: { type: "listElement", documentType: "electedCharter", propertyAgreement: { electedCharterId: "$id" }, inList: "members" }, so a removal names an elected member and nobody else.resignationRequest.ownerRefersTo.anyOf[1]is now adeletableDocumentreference through the samebyElectedCharterMemberlookup, so an added member can file a request only while their addition exists. Its oldpermanentDocumentform could not register against a deletableaddedModerator.docs/protocol/moderation-charters.mdand the book chapter describe the new rules.Seating (drive-abci)
SeatedModerationCharter::seatsdoes one point read:removedModeratorexists for them;addedModeratorexists for them.maxAddedModeratorscap counts the additions that exist now, using the same equality query as before. Deleting an addition frees its slot.refersTowith alookupondeletableDocument(rs-dpp, PV14)DocumentPropertyReferenceTarget::DeletableDocumentLookup, appended as variant 10 (the enum is encoded inside consensus errors), serialized under thedeletableDocumenttag.binds_a_changed_property);immutableproperty may not hold it, alone or as an expression operand, because the clearing exception reads a document id and a lookup key is not one;anyOf/allOf) takes as an operand;ownerRefersTotakes it. The writer never changes, so every replace gates on the writer's document still existing.creatorRefersTorefuses it. A transfer would leave the new owner unable to replace a document once the creator's document is gone.ReferencedDocumentTypeNotDeletableError(40131), as the by-id form already is.Referencesurface (lookupondeletableDocument, and operands that includelistElementanddeletableDocument), and the book's documents chapter are updated.SDK
Sdk::fetch_pending_resignation_requests(pendingResignationRequestsin JS) keeps the requests whose writer is still on the team. It reads the charter and both team-change lists, because an added member now leaves when their addition is deleted, which no removal records.Before and after
Taking an added member off:
Undoing a removal:
The cap (
maxAddedModerators: 2):The seat check for a non-elected identity:
A lookup on a
deletableDocumentreference:How Has This Been Tested?
--all-features --lib):reference_lookup_tests: a deletable lookup parses, its referenced side is checked, it is refused in an immutable property, and element lookups work.owner_reference_tests:ownerRefersTotakes a deletable lookup alone and inanyOf;creatorRefersTorefuses it through the meta-schema and the parser; the by-id messages are updated.reference_expression_tests: a deletable lookup operand parses and is refused in an immutable property.system_data_contracts: the three deletable team-change types,removedModerator.memberIdas alistElementintomembers, and the resignation's deletable lookup.state_error: the new variant is pinned at 10.seated_team:should_remove_only_an_elected_member(40120 for an added member and for a stranger);should_cap_the_members_a_leader_adds_and_free_a_slot_when_an_addition_is_deleted.owner_reference:should_check_a_deletable_owner_lookup_on_every_replacechecks create acceptance and refusal, the lookup billed on a replace that leaves its keys alone, and the refusal after the seat is deleted.moderation,batch::tests,data_contract,genesisandcharterfiltered runs: 1012 passed.moderation_charters: 12 passed.DocumentPropertyReference.spec.tswere updated (deletable types, the removal'slistElement, and a deletable lookup operand reported with its lookup). They were not run locally.cargo clippy -p dpp -p drive -p drive-abci -p dash-sdk --all-targets --all-features -- -D warningspasses.Breaking Changes
Protocol version 14, which is unreleased:
listElementreference onremovedModerator.memberId, and adeletableDocumentlookup inresignationRequest.DocumentPropertyReferenceTargetgains an appended variant. A client built before it cannot decode a consensus error that carries a deletable lookup target.lookupondeletableDocument.In-place changes to shipped generations
These can't change consensus at any shipped protocol version, because only the generation 3 document type parser (protocol version 14) produces
DeletableDocumentLookup, and nothing before it produces any lookup:create_document_types_from_document_schemasv1: skips the referenced-side lookup check when the reference kind and the target's deletability disagree (permanent == deletable) rather than whenever the target is deletable. Before protocol version 14 no lookup exists for this loop to see.document_reference_validationv0 anddata_contract_reference_validationv0: the new variant joins the arms of the other document references.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 ·
5c59672/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/moderation_charters.rs) — shumkovdpp— you own itrs-drive-abci— you own itrs-drive— you own itrust-sdk(packages/rs-sdk/src/platform/moderation_charters/mod.rs,packages/rs-sdk/src/platform/moderation_charters/readers.rs,packages/rs-sdk/src/platform/moderation_charters/team.rs) — lklimek or shumkovWhen every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit