Skip to content

feat(platform)!: a moderation reason names the documents it is about - #4884

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/moderation-reason-documents
Sep 21, 2026
Merged

QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/moderation-reason-documents

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Follow-up to #4872 (the warning list), which merged before this landed on its branch. A moderation reason could say why in text and a code, but not which posts it was about. A warning, a ban or a suspension for "these three posts" had nowhere to name them, and the client that shows the warned user its warnings had nothing to link.

What was done?

A reason names the documents it is about, on every action. ContractModerationReason gains documents: Vec<ContractModerationDocument { document_type_name, document_id }>, so a warning, a ban, a suspension and a moderator's document deletion can all cite the posts they are for.

  • Existence is unchecked. Nothing looks a cited document up: it may have been deleted since, by its author or by a moderator whose deletion left a record, or may never have existed. A client that wants to show it fetches it or its removal record.
  • Bounds, all unpaid basic structure: at most SystemLimits::max_contract_moderation_reason_documents (16) per reason, none twice (the same id under another type is another document), and a document type name a contract could admit (1 to 64 bytes). Refused with the new InvalidContractModerationReasonDocumentsError (10904, appended to BasicError, discriminant pinned).
  • Storage: a second bit of the reason's tag byte (bit 1: documents follow), then the count in one byte and each document's type name (length byte, name) and 32-byte id, before the text. Every entry written so far has bit 1 clear and decodes unchanged; a value without a tag still reads as the empty reason.
  • Wire: ContractModerationDocument on the proto, documents on ContractModerationReason, clients regenerated; the proof verifier refuses an id that is not 32 bytes and, as for the text, does not bound the count.
  • JS: documents?: [{ documentTypeName, documentId }] on the reason, ids as base58, present on a reason read back only when it cites any (skip_serializing_if on the Rust side too, so toJSON() of a transition is unchanged for a reason about no document). A document id inside the reason arrives from JavaScript through serde, which refuses a base58 string for a raw Identifier, so wasm-dpp2 reads options through a ContractModerationReasonInput built on the wasm identifier wrapper, and wasm-sdk uses it for its ban, suspend, warn and delete-document options.
  • Book chapter and error table updated.

Also carried here, since they were on the merged PR's branch after the merge:

  • The wasm-dpp2 DataContract config spec expected a moderation declaration without warnings; it now expects the warning list defaulted off (the failing JS packages (@dashevo/wasm-dpp2) / Tests check on v4.2-dev).
  • Two CodeRabbit wordings from feat(platform)!: a warning list for moderated contracts #4872: the book no longer says nothing in consensus reads the warning list (a warn and a clearing do; the document gate does not), and the reason length limit's doc names every action it applies to.

How Has This Been Tested?

  • dpp: the documents round-tripped through JSON and left out when none; the bounds, the duplicate and the name rules; the appended error's discriminant.
  • drive: the codec with and without a code, inside a ban, a suspension and a warning; every cut-short shape refused; the old tags still decoding.
  • proof verifier: a cited document read from an unproved response, a wrong id length refused.
  • drive-abci: a warn and a ban citing a real post and a document that never existed, stored and shown by the ban's proof; too many or a duplicate refused unpaid in the mempool and in a block. The moderation, gate and check_tx suites pass.
  • wasm-dpp2 spec: a reason with documents through the constructor, toJSON() and bytes, and no documents key without any. wasm-sdk unit specs and the js-evo-sdk contracts spec pass.

Breaking Changes

PV14 is unreleased; the reason gains a field in its bincode layout (transitions) and its storage gains a tag bit (backward-readable). The TypeScript reason type gains an optional field only.

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 made corresponding changes to the documentation

🤖 Generated with Claude Code

`ContractModerationReason` gains `documents`, the posts a warning, a ban,
a suspension or a deletion is for, each by document type name and id: at
most `SystemLimits::max_contract_moderation_reason_documents` (16), none
twice, refused unpaid with `InvalidContractModerationReasonDocumentsError`
(10904). Nothing looks a cited document up. Stored under a second tag bit
of the reason, so every entry written so far still decodes; on the proto
and JS reasons, left out when empty. The wasm surfaces read the reason
through an input shape so a document id arrives as an `IdentifierLike`.

Also: the wasm-dpp2 contract config spec expects the warning list to
default off, and two review wordings.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: dashpay/platform/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: ad61f1b6-24e7-4b46-ac2e-f386ece23a43

📥 Commits

Reviewing files that changed from the base of the PR and between c1e577b and d389b79.

📒 Files selected for processing (42)
  • book/src/data-model/contract-moderation.md
  • book/src/error-handling/error-codes.md
  • packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.js
  • packages/dapi-grpc/protos/platform/v0/platform.proto
  • packages/rs-dpp/src/data_contract/config/moderation/mod.rs
  • packages/rs-dpp/src/data_contract/config/moderation/reason.rs
  • packages/rs-dpp/src/errors/consensus/basic/basic_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_moderation/invalid_contract_moderation_reason_documents_error.rs
  • packages/rs-dpp/src/errors/consensus/basic/contract_moderation/mod.rs
  • packages/rs-dpp/src/errors/consensus/codes.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/contract_user_moderation_transition/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/contract/contract_user_moderation_transition/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/contract_user_moderation/tests.rs
  • packages/rs-drive-abci/src/query/contract_moderation_queries/contract_document_removals/v0/mod.rs
  • packages/rs-drive-abci/src/query/contract_moderation_queries/contract_moderation_entries/v0/mod.rs
  • packages/rs-drive-abci/src/query/contract_moderation_queries/contract_moderation_status/v0/mod.rs
  • packages/rs-drive-abci/src/query/contract_moderation_queries/mod.rs
  • packages/rs-drive-proof-verifier/src/types/contract_moderation.rs
  • packages/rs-drive-proof-verifier/src/unproved.rs
  • packages/rs-drive/src/drive/contract/moderation/document_removal_tests.rs
  • packages/rs-drive/src/drive/contract/moderation/tests.rs
  • packages/rs-drive/src/drive/contract/moderation/types.rs
  • packages/rs-platform-version/src/version/mocks/v2_test.rs
  • packages/rs-platform-version/src/version/system_limits/mod.rs
  • packages/rs-platform-version/src/version/system_limits/v1.rs
  • packages/rs-platform-version/src/version/system_limits/v2.rs
  • packages/rs-platform-version/src/version/system_limits/v3.rs
  • packages/rs-platform-version/src/version/system_limits/v4.rs
  • packages/rs-platform-version/src/version/v14.rs
  • packages/wasm-dpp/src/errors/consensus/consensus_error.rs
  • packages/wasm-dpp2/src/data_contract/mod.rs
  • packages/wasm-dpp2/src/data_contract/transitions/user_moderation.rs
  • packages/wasm-dpp2/tests/unit/ContractUserModerationTransition.spec.ts
  • packages/wasm-dpp2/tests/unit/DataContract.spec.ts
  • packages/wasm-sdk/src/state_transitions/contract.rs

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.

@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 21, 2026
@github-actions

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-09-21T12:13:55.571Z

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Hygiene

State: waiting-bots · commit d389b793954be073a7b3f6b9e2fc0051a404316b

  • coderabbitai has not reported for the current head
  • thepastaclaw has not reported for the current head

Self-review is an author attestation that you have read the diff:
/self-reviewed — covers everything pushed so far; post it again after a new push.
/skip-bots — proceed without the bots that have not reported; anyone with write access may, and the report says who did.

This check passes when the policy is satisfied; the repository decides whether merging requires it.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Sep 21, 2026
@thepastaclaw

thepastaclaw commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ DEGRADED — Queued for automated review — 5th in line, estimated start in ~1.9 h (commit d389b79)
Estimated review time once started: ~45 min (two-phase automated review; median of recent runs).
The primary review models are currently out of quota; this review will run on stand-in models and be marked as degraded.

  • Request priority review — click to move this review to the front of the queue.

@QuantumExplorer
QuantumExplorer merged commit 49ca692 into v4.2-dev Sep 21, 2026
18 of 19 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/moderation-reason-documents branch September 21, 2026 12:21
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