Repository navigation
feat(sdk): approvals a settled deletion needs of a team, empty seats documented - #5245
QuantumExplorer wants to merge 1 commit into
Conversation
…documented A settled deletion needs min(approvals, seats) approvals, and a removed elected member keeps its seat, so the leader can not lower the bar by removing members who would not approve. The price is liveness: nobody else takes an elected member's seat, so a team that loses too many elected members for good never meets the rule again. The rule stays; this writes the trade-off down and lets clients read the count. - rs-sdk ModerationTeam::settled_deletion_approvals_needed and wasm/evo settledDeletionApprovalsNeeded, over SettledDeletionRule's approvals_needed and the team's seats, as consensus counts - book: "A team that falls short" under deleteSettled, an authors' note at registration, and the stale "additions ever filed" line fixed (the cap counts the additions that exist now) - dpp, drive-abci and evo-sdk docs carry the same trade-off Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-02T00:52:10.086Z |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)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 (8)
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 changes clarify how declared team seats determine settled-deletion approval requirements. They add an approval-count helper to the Rust SDK and expose the calculation in the WebAssembly SDK with numeric argument validation. ChangesSettled-deletion approval seats
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Feature Merge Risk: ⚪ Minimal · up to The SDK helpers expose the existing approval threshold without changing deletion rules. No actionable merge-blocking risk is identified; merge after normal checks. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The new methods calculate approval counts without authorizing or executing deletions. Existing approval and leader checks remain authoritative. The documented possibility of a team permanently losing its ability to approve deletions predates this PR. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
✅ Final review complete — no blockers (commit 2257ee5) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified the supplied findings against head 2257ee5. The SDK helper matches the existing consensus threshold calculation, and the consensus-adjacent edits are comments only; one non-blocking test-coverage suggestion remains. This was a static review: the supplied CI snapshot shows successful SDK/WASM checks and builds, with Rust workspace tests and two platform test suites still running.
🟡 1 suggestion(s)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, well-contained SDK/API and documentation change that mirrors existing consensus calculations without modifying consensus behavior, funds, cryptography, networking, or storage. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 100% left, weekly 71% left; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 69% left, 5h 11% left) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); 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/wasm-sdk/src/moderation_charters.rs`:
- [SUGGESTION] packages/wasm-sdk/src/moderation_charters.rs:180-196: Add tests for the new approval-count binding and its numeric arguments
The new binding validates two JavaScript numbers before converting them to u16, but neither it nor the extracted u16_argument helper has test coverage. The new dash-sdk test exercises the seat-based arithmetic, while the existing wasm-sdk moderation-charter tests cover page queries, not this method. Add local tests covering fractional, negative, oversized, NaN and infinite arguments, accepted boundaries 0 and 65535, and a valid binding call that preserves the threshold after an elected member is removed. The validation is currently correct; these tests would pin the new API's documented rejection behavior independently of the SDK arithmetic. The pure numeric helper can be tested on the host without introducing JsValue operations, and binding behavior can use the crate's existing wasm32 test harness.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Consolidate numeric-argument validation across wasm crates — Routine adjacent cleanup outside the PR's scope. The cited helpers intentionally have different input types and accepted-input contracts, and the new helper preserves the previous seats() validation. No concrete correctness problem warrants retaining a cross-crate consolidation follow-up.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
| pub fn settled_deletion_approvals_needed( | ||
| &self, | ||
| approvals: f64, | ||
| #[wasm_bindgen(js_name = "maxAddedModerators")] max_added_moderators: f64, | ||
| ) -> Result<u32, WasmSdkError> { | ||
| // The count does not depend on whether the leader must be among the approvals | ||
| let rule = SettledDeletionRule { | ||
| leader: false, | ||
| approvals: u16_argument(approvals, "approvals")?, | ||
| }; | ||
| let needed = self.0.settled_deletion_approvals_needed( | ||
| &rule, | ||
| u16_argument(max_added_moderators, "maxAddedModerators")?, | ||
| ); | ||
| // At most `approvals`, a u16 | ||
| Ok(needed as u32) | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: Add tests for the new approval-count binding and its numeric arguments
The new binding validates two JavaScript numbers before converting them to u16, but neither it nor the extracted u16_argument helper has test coverage. The new dash-sdk test exercises the seat-based arithmetic, while the existing wasm-sdk moderation-charter tests cover page queries, not this method. Add local tests covering fractional, negative, oversized, NaN and infinite arguments, accepted boundaries 0 and 65535, and a valid binding call that preserves the threshold after an elected member is removed. The validation is currently correct; these tests would pin the new API's documented rejection behavior independently of the SDK arithmetic. The pure numeric helper can be tested on the host without introducing JsValue operations, and binding behavior can use the crate's existing wasm32 test harness.
source: glm-5.3-flash (phase1-reviewer: general, rust-quality)
|
Bots are done — your move: post |
Basic explanation
A seated moderation team can delete a settled document (one past its
deleteWithinwindow) only when enough members approve. The number they need is fixed by the team's seats, not by who is on the team right now. A removed member keeps their seat, so removing people never lowers the bar. That stops a leader from removing everyone who would say no and then deleting alone.The downside is that a team can get stuck. If too many elected members are gone for good (removed, lost their keys, or stopped answering), the team can never reach the number again, because nobody else can take an elected member's seat. This PR does not change that rule. It writes the trade-off down where contract authors and client developers will see it, and it adds an SDK read that gives a client the number a team needs.
Issue being fixed or feature implemented
A review found that
needed = min(approvals, seats)counts empty seats and removed members, so a team that shrinks can deadlock its settled deletions. The review asked for either of two fixes:neededby the people who can approve right now, orneededin the team read.This PR does option 2. Option 1 would let the leader remove members until it can approve alone, which defeats the point of a rule like "the leader and two others".
The review's first example is milder than it reads. With a leader, 2 elected members and
maxAddedModerators: 2(5 seats, 3 needed), removing one member leaves 2 people, but the leader can still add 2 members from the proposal's join requests, or delete the removal. Settled deletions stay stuck only until the leader does one of those. The second example does hold: on a team of exactlyapprovalspeople with no additions allowed (maxAddedModerators: 0, the default), one elected member who can't approve stops every settled deletion for good, because a seat is never contested again in protocol version 14.What was done?
ModerationTeam::settled_deletion_approvals_needed(rule, max_added_moderators)returns what a settled deletion needs of the team. It callsSettledDeletionRule::approvals_neededoverseats, the same count consensus uses.ModerationTeam.settledDeletionApprovalsNeeded(approvals, maxAddedModerators)is the same in JavaScript. Au16_argumenthelper now validates both numbers andseats().Before, a client had to know the rule:
After:
deleteSettledsection, a note for authors under "Rules at registration" to leave room for members lost for good, and the same trade-off inSettledDeletionRule::approvals,ElectedCharter::seats, the drive-abci approval comment and the evo-sdkteam()doc.maxAddedModeratorscaps the additions that exist at a time (deleting one frees its slot), not every addition ever filed. Consensus already counts it this way (count_added_moderators), and the same chapter says so further down.How Has This Been Tested?
cargo test -p dash-sdk --lib moderation_charters::team, including a new test: 5 seats with a rule of 3 needs 3, and still needs 3 after the leader removes a member and only 2 people are left. A rule of 31 needs every seat.cargo check -p wasm-sdk --target wasm32-unknown-unknownandcargo check -p drive-abci(dpp builds under both),cargo clippy -p dash-sdk --libclean.Breaking Changes
None. No consensus change: the new code is SDK read helpers, and everything else is comments and docs.
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 ·
2257ee5/self-reviewedjs-wasm-sdk(packages/js-evo-sdk/src/moderation-charters/facade.ts,packages/wasm-sdk/src/moderation_charters.rs) — shumkovdpp— you own itrs-drive-abci— you own itrust-sdk(packages/rs-sdk/src/platform/moderation_charters/team.rs) — lklimek or shumkovWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit
New Features
Documentation