feat(platform)!: contract references may require the referenced contract to declare elected moderation - #4909
Conversation
…act to declare elected moderation A `contract` refersTo declaration may carry `contractFields`, what the referenced contract must declare beyond existing, each key an aspect of the contract and its value the requirement: `moderation: "elected"` requires an elected moderation team. The document reference validation checks it against the contract it already fetched for the existence check, at no further read, and refuses an unmet requirement with a new state error (40135). A changed `contractFields` is an incompatible schema change on update. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 14 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (17)
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-22T04:46:41.964Z |
|
|
…uirements The object holds what the referenced contract must declare, predicates and not field values, so the key, the types and the field say requirements. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The charter's targetContractId now requires the contract it references to declare an elected moderation team (#4909's contractRequirements), so a charter for a contract that does not exist or is not moderated by an elected team is refused when it is created. The changelog entry becomes item 25 after #4909's 24. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Issue being fixed or feature implemented
Part of #4865 (decentralized moderation teams). The charter system contract (#4898) points at the contract a team applies to moderate with a
refersTo: { "type": "contract" }reference, which proves the contract exists. It cannot say that the contract must declare an elected moderation team; that check was left to the seating PR as custom code.What was done?
A
contractreference may now carry requirements on the referenced contract:contractRequirementsis an object under the reference: each key names an aspect of the referenced contract and its value the requirement on it, a closed set per key.moderation: "elected"is the first and only one: the contract must declareContractModerators::Elected, whatever its interim and whether a team is seated. The next requirement is another key inside the object, not another reference type.contractRequirementsis refused on every other reference type, an empty object is refused, and so are unknown keys and values (parser and meta-schema v3).DocumentPropertyReferenceTarget::Contractbecame a struct variant carryingContractReferenceRequirements { moderation: Option<ContractReferenceModeration> }; the serde form omits the field when it requires nothing, so an existing{ "type": "contract" }round-trips unchanged.first_unmet_by(&contract)answers which requirement a contract fails.ReferencedContractRequirementNotMetError { contract_id, field, required, path }(40135, document state band,StateErrordiscriminant 143). A missing contract stays 40120.contractRequirementsis an incompatible schema change on a document type update, like every other change underrefersTo(pinned by a test).contractRequirements(absent when the declaration carries none) and mirrors the code inDocumentReferenceErrorCode.Once this merges, #4898's charter declares the requirement on
targetContractId.How Has This Been Tested?
contractRequirementsthat are empty, unknown, mistyped or on another reference type; the reference target'sDisplayand mirror tests; theStateErrordiscriminant pin; the update test.cargo checkon wasm-dpp and wasm-dpp2.Breaking Changes
Consensus: a new
refersTosub-keyword in the v3 document meta-schema and a new state error, both at protocol version 14 (unreleased).Checklist
For repository code-owners and collaborators only
🤖 Generated with Claude Code