Repository navigation
feat(platform)!: let a banned or suspended author retract with a declared replace (PV14) - #5253
Conversation
…ared replace (PV14) A moderated contract's gate refused every document transition of a barred identity except deletions. On a type whose documents the owner can not delete (canBeDeleted: false), the only way to take a document back is a replace that blanks it, so a barred author had no exit at all. A document type may now declare `retractedWhen`, one condition in the grammar of an `immutable` entry's `when`. The gate lets a barred owner's replaces on such a type through with its bar, and once the stored document is fetched the transformer refuses with the bar (41107, 41108), paid, each replace whose written document does not meet the condition. Every other rule of the type still judges the replace, so what a retracted document holds is the contract's to say (a propertyConstraints rule that it is blank, an immutable entry that keeps it retracted). The keyword is refused (10231) on a type whose documents are not mutable and on a contract keeping neither a banlist nor a suspension list, and is fixed on contract update (40212). The condition parse is shared with the immutable entries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-02T15:24:00.922Z |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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 detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
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 (26)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAdds the protocol v14 ChangesBarred-owner retractions
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Batch as Batch transformer
participant Gate as Contract moderation gate
participant Type as DocumentTypeV2
participant Judge as judge_barred_replace
Batch->>Gate: Submit barred owner's replacement
Gate->>Type: Read retracted_when
Type-->>Gate: Return optional condition
Gate-->>Batch: Pass replacement with retraction_bar
Batch->>Judge: Check replacement against condition
Judge-->>Batch: Return condition result or bar error
Merge Risk: ⚪ Minimal · up to No actionable issue remains from this review; the change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new permission is opt-in and remains limited to an author's own documents. Failed conditions preserve the ban or suspension, and ordinary document rules still apply. The principal design risk is contract configuration: declaring a retraction condition does not itself require a blank or irreversible tombstone, and the condition cannot later be changed. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 60.34% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 58 functions across 21 files. (5 skipped: 5 unsupported.) ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
🛠️ Fix failing CI checks 💡
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 |
|
🔍 Review in progress — actively reviewing now (commit 9d2d014) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The protocol-14 retraction implementation is correctly version-gated and preserves the moderation bar when the declaration does not match or cannot be evaluated. Two non-blocking issues remain: the new required public trait method breaks downstream trait implementations, and the fail-closed condition-error branch lacks end-to-end regression coverage.
🟡 2 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: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 4: gemini-3.8-flash-high (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: 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) — This is a large, intricate consensus-rule change that modifies document-type parsing and the contract moderation gate in rs-drive-abci, directly changing state-transition validation for banned or suspended authors. - Phase 1 reviewers:
gemini-3.8-flash-high— general (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
gemini-3.8-flash-high— antigravity quota: weekly 59% left, 5h 39% left - 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— 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 each finding against the current code and only fix it if needed.
In `packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs:146-151: Adding a required public trait method breaks downstream implementations
`DocumentTypeV2Getters` is public and re-exported, so adding `retracted_when` as a required method causes downstream crates that implement this trait to fail compilation with a missing-method error. All in-repository implementations were updated, but the PR's breaking-change description only identifies the protocol consensus change. Give the method a default implementation returning `None`, which matches the documented behavior for pre-keyword types and still allows `DocumentTypeV2` to override it, or explicitly document this Rust API break as part of the release compatibility change.
In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/retraction.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/retraction.rs:45-50: Add integration coverage for fail-closed retraction-condition faults
`judge_barred_replace` deliberately maps a `retractedWhen` evaluation error to `false`, so an overflow or division-by-zero fault must preserve the author's ban or suspension. Every new drive-abci retraction fixture uses a `present` condition, which cannot exercise this branch. The existing immutable-condition fault test covers the opposite policy (`unwrap_or(true)` keeps an immutable field frozen) and therefore does not protect this helper. Add an end-to-end case with a valid condition that faults at runtime, such as division by zero from a zero-valued replacement property, and assert that block processing returns the original moderation error with the paid nonce-bump behavior, leaves the stored document unchanged, and that `check_tx` rejects the transition.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
A barred author's replace whose `retractedWhen` condition divides by zero is refused with the bar in the mempool and in a block, paid with the nonce bumped, and leaves the stored document as it was; the same condition met lets the replace through. Pins the fail-closed branch of `judge_barred_replace`, which the earlier `present` conditions could not reach. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The PV14 gating and fail-closed regression coverage are supported by the source, but the new retraction exception exposes a blocking mixed-result execution path that skips the replacement's remaining validation. A documentation suggestion also remains for the required public-trait method. This verification was static only: the supplied CI snapshot shows Kotlin SDK testing and PR Hygiene pending and contains no completed Rust validation results.
🔴 1 blocking | 🟡 1 suggestion(s)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gemini-3.8-flash-high (agent: phase1-reviewer, role: rust-quality); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (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) — This intricate cross-cutting change alters PV14 consensus acceptance rules in contract_moderation_gate/v0/mod.rs and the batch transformer’s retraction.rs, coordinating conditional authorization of barred authors’ replaces with schema parsing, immutable contract updates, and document validation. - Phase 1 reviewers:
gemini-3.8-flash-high— general (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
gemini-3.8-flash-high— antigravity quota: weekly 37% left, 5h 95% left - 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— 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— 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. 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/transformer/v0/contract_moderation_gate/v0/mod.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/transformer/v0/contract_moderation_gate/v0/mod.rs:202-205: Validate admitted retractions before executing an error-bearing batch
The new exemption can retain a live replacement in a transformer result that also contains consensus errors. The contract transformer merges passed actions with refusals at transformer/v0/mod.rs:493–516, and the outer transformer preserves both action data and errors. processor/v0/mod.rs:288–297 then converts that result directly into an ExecutionEvent, returning before advanced structure and state validation. Those skipped stages enforce propertyConstraints, immutable fields, and document references; satisfying retractedWhen does not replace those checks.
The execution path does not make this safe: retained replacements become UpdateDocument operations, and paid execution applies the operations before reporting the consensus errors. PaidConsensusError outcomes retain their writes. Although this aggregation behavior predates the PR, barred owners' replacements previously became nonce bumps; this exemption newly admits replacement writes into that path and breaks the stated guarantee that every other document rule still applies.
For PV14, ensure error-bearing transformer results cannot execute retained replacements until all applicable advanced structure and state checks have completed. Alternatively, replace unvalidated retained actions with nonce bumps before constructing the failed execution event. Add mixed-result regression coverage asserting that rejected batches cannot persist replacements violating blanking or immutability rules.
In `packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/data_contract/document_type/accessors/v2/mod.rs:146-151: Adding a required public trait method breaks downstream implementations
(existing thread: https://github.com/dashpay/platform/pull/5253#discussion_r4163442958)
Keeping retracted_when required follows the existing getter convention, and all four in-tree implementations are updated. However, DocumentTypeV2Getters is publicly re-exported and unsealed, so external implementations must also add this method to compile; the in-tree implementation count does not establish that external implementations cannot exist.
The book reserves the title's ! marker for consensus-breaking changes, but that does not remove API disclosure from the PR body: .github/PULL_REQUEST_TEMPLATE.md asks for any breaking changes, and the book also directs public API removals to be described there. The current Breaking Changes section describes only consensus activation. Retain the required getter, but add a brief Rust API migration note stating that custom DocumentTypeV2Getters implementations must implement retracted_when, returning None when no condition applies. No default implementation or additional runtime version slot is required.
…one result A transition the moderation gate passes (a deletion, a retraction, what the interim block passes) shares a transformer result with a refusal only in a batch of several transitions, which basic structure refuses while `max_transitions_in_documents_batch` is 1 (10412). Such a result would be executed without the passed transitions' state validation, so the note says what raising the cap must do first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Basic explanation
What this does: On a moderated contract, a banned or suspended user can't post anything new, but has always been allowed to delete their own posts. Some apps make posts undeletable, because replies and quotes point at them. On those apps the only way to take a post back is to overwrite it with a blank "this was deleted" version (a tombstone), and the ban blocked that too. This PR lets a contract name what its tombstone looks like (
retractedWhen). A barred user may then still write a tombstone, and nothing else.Value: Banned or suspended authors get back the one exit they lose on undeletable types: taking down what they wrote. Yappr posts and replies (
canBeDeleted: false, tombstoned withdeleted: true) and the blog contract hit exactly this. Contracts that don't declare the keyword behave as before.Risks: Low to medium. It is a consensus change at protocol version 14 (not yet on mainnet). It touches the moderation gate and the batch transformer shared with every earlier version, but it is inert there: the gate, and so a bar, only exist from version 14. The main risk sits in contracts: the platform only checks the declared condition, so a contract that declares
retractedWhenwithout a rule blanking the retracted document lets a barred author write into it. The book and the meta-schema say so. The keyword is fixed once a type is created, so a mistake can't be patched by an update.Issue being fixed or feature implemented
The moderation gate let a barred identity delete documents but refused every replace (
ContractUserBannedError41107,ContractUserSuspendedError41108). On acanBeDeleted: falsetype a retraction is a replace, so a barred author could retract nothing. Repro: ban Y; Y's tombstone of its own post is refused with 41107, while Y's unlike (a delete) is accepted. Same on the blog contract.What was done?
A document type may declare
retractedWhen: one condition, in the grammar of animmutableentry'swhen(apropertyConstraintscondition,$old.reads the stored document, nocountOf/sumOf). A banned or suspended owner's replace on that type passes when the document it writes meets the condition.Banned author Y, stored post
{ "text": "hello" }:{ "deleted": true }(tombstone){ "text": "edited" }{ "text": "hello", "deleted": true }retractedIsBlank){ "text": "hello" }retractedWhenThe condition picks the replaces a barred owner may make. What a retracted document holds is the type's other rules to say (
propertyConstraints,immutable), and they judge every replace as before.dpp (parser generation 3, meta-schema v3)
retractedWhenin the v3 document meta-schema,property_names::RETRACTED_WHEN,DocumentTypeV2::retracted_whenand theDocumentTypeV2Getters::retracted_whengetter (Noneon V0/V1).apply_retracted_whenintry_from_schema::common. The condition parse is pulled out ofapply_immutable_fieldsintoparse_replace_condition, shared by both keywords; theimmutablemessages are unchanged.InvalidContractStructure(10231), on every parse, on a type whose documents are not mutable and on a contract keeping neither a banlist nor a suspension list.validate_retracted_when_unchanged(DocumentTypeUpdateError, 40212) invalidate_updatev1, and the key joins the schema differ's frozen keywords.propertyConstraintsrule now names both conditions that may read$old..drive-abci
contract_moderation_gatev0: under a bar, a replace on a type declaringretractedWhenpasses next to the deletions.ContractModerationRefusalgainsretraction_bar(the signer's bar), andrefusedbecomes anOption, since a batch of such replaces refuses nothing.judge_barred_replace(newtransformer/v0/retraction.rs) judges the condition as animmutablecondition is judged. A replace that doesn't meet it, or whose condition faults, is refused with the bar, paid, nonce bumped. The mempool runs the same transformer.condition_data,condition_system_values) move from the privateImmutableConditionInputsof replace state validation v1 toReplaceConditionInputs, visible to the batch module. Behaviour unchanged.Docs: a
retractedWhensection in the book's Deletion chapter, the keyword table, the moderation chapter's document gate, the mutability page's$old.rule, and PV14 note 72 inv14.rs.In-place changes to shipped generations
transform_document_transitions_within_contract_v0,transform_document_transitions_within_document_type_v0andtransform_document_transition_v0(the batch transformer shared with protocol versions before 14) take the newretraction_bar. It is only everSomewhencontract_moderation_gatereturns one, and the gate isNonein every table before protocol version 14, so earlier versions run exactly as before.validate_updatev1, schema compatibility v1,contract_moderation_gatev0) is selected by protocol version 14 only, which is not yet released.How Has This Been Tested?
try_from_schema/v3/retracted_when_tests.rs: the condition parsed and judged ($old.included), the refusals on an immutable type, on an unmoderated or warning-only contract, for unparseable conditions and unknown or aggregate reads, a value that is not one condition on both parse paths, and the update rule (add, remove, change refused; unchanged passes). 341 targeted dpp tests pass (retracted_when immutable validate_update validate_schema_compatibility moderator_abilities property_constraints).contract_user_moderation/tests/retraction.rs, end to end throughprocess_raw_state_transitions. A suspended and then a banned author retracts while edits are refused with 41108/41107. A retraction keeping its text is refused by the type's own rule (10422). Taking a tombstone back is refused with the bar, and after the unban byimmutable(40128).check_txlets the retraction in and refuses the edit. A type withoutretractedWhenrefuses a tombstone-shaped replace. A condition that faults (10 / scorewithscore: 0) keeps the bar: refused with 41107 bycheck_txand in a block, paid with the contract nonce bumped, the stored document unchanged; the same condition met passes.contract_moderation_gateunit test: the passed replace carries the bar while a create on the same type and a replace on another type are refused, and a batch of the replace alone refuses nothing.contract_moderation_gate contract_user_moderation immutable_conditions).unwrap_or(true)), the fault test fails.cargo clippy -p dpp -p drive-abci -p platform-version --all-targets --all-features -- -D warningsandcargo fmt --allare clean.Breaking Changes
Consensus, protocol version 14 only: a new document type keyword (meta-schema v3), and a banned or suspended owner's replace on a type declaring it is no longer refused by the moderation gate when it meets the condition. Nothing changes for contracts that don't declare it, or before protocol version 14.
Follow-ups outside this PR: Yappr's
postandreplyneed"retractedWhen": { "present": "deleted" }to use this. wasm-dpp2 does not expose the keyword as a getter; clients read it from the schema. PV14 note 72 assumes #5239 keeps 71.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 ·
9d2d014/skip-botsproceeds without the ones not yet reported/self-reviewedWhen every box is checked the
PR Hygienecheck passes and this can merge.Summary by CodeRabbit
New Features
retractedWhen, allowing a banned or suspended document owner to replace a document only when the replacement meets the document type’s specified condition.Documentation