Skip to content

Expose clear_pending_commit in UniFFI bindings#196

Merged
dannym-arx merged 2 commits into
masterfrom
expose-clear_pending_commit-to-bindings
Feb 23, 2026
Merged

Expose clear_pending_commit in UniFFI bindings#196
dannym-arx merged 2 commits into
masterfrom
expose-clear_pending_commit-to-bindings

Conversation

@dannym-arx

@dannym-arx dannym-arx commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

This PR exposes the clear_pending_commit() method through the UniFFI bindings, allowing foreign language clients to roll back uncommitted pending MLS commits. This is a recovery mechanism for failed relay publishes that would otherwise permanently block group operations.

What changed:

  • Added clear_pending_commit(mls_group_id: String) public method to the Mdk struct in the mdk-uniffi crate, which accepts a hex-encoded MLS group ID and rolls back to the pre-commit state
  • Updated mdk-uniffi CHANGELOG.md to document the new method

API surface:

  • New public method added to mdk-uniffi's Mdk type that mirrors the existing merge_pending_commit() flow but performs a rollback instead of merge
  • The method parses the hex-encoded group ID and delegates to the underlying mdk-core implementation with error handling

@coderabbitai

coderabbitai Bot commented Feb 23, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR adds a new clear_pending_commit method to the MDK uniffi API that allows callers to roll back uncommitted pending MLS commits. This includes a CHANGELOG entry and the method implementation in the library, which parses a hex-encoded group ID and delegates to the internal MDK.

Changes

Cohort / File(s) Summary
Documentation
crates/mdk-uniffi/CHANGELOG.md
Added entry under Unreleased "Added" section documenting the new clear_pending_commit(group_id) method with reference to PR #196.
Implementation
crates/mdk-uniffi/src/lib.rs
Implemented new public clear_pending_commit method that accepts a hex-encoded MLS group ID string, parses it to GroupId, and delegates to internal MDK to clear the pending commit, returning Result with MdkUniffiError on failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Possibly related PRs

Suggested labels

mls-protocol

Suggested reviewers

  • erskingardner
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Expose clear_pending_commit in UniFFI bindings' clearly and concisely summarizes the main change in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
No Sensitive Identifier Leakage ✅ Passed The clear_pending_commit method does not leak sensitive identifiers; it parses hex-encoded group IDs safely and only exposes error descriptions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch expose-clear_pending_commit-to-bindings

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

❌ Coverage: 91.04% → 91.02% (-0.02%)

@github-actions

Copy link
Copy Markdown

❌ Coverage: 91.04% → 91.02% (-0.02%)

@erskingardner erskingardner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, unless you want to add a test, but given it's the thinnest wrapper possible, I'm fine with this.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/mdk-uniffi/src/lib.rs (1)

810-814: Consider adding a unit test for clear_pending_commit.

While the implementation is straightforward and follows the same pattern as merge_pending_commit, adding a test would verify the FFI binding works correctly end-to-end. A test could create a group, verify clear_pending_commit succeeds on a group with a pending commit, and returns an error for a non-existent group.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/mdk-uniffi/src/lib.rs` around lines 810 - 814, Add a unit test for
clear_pending_commit similar to the existing merge_pending_commit test:
instantiate the MdkUniffi object, create a test group (so there is a pending
commit), call clear_pending_commit(&self, mls_group_id: String) and assert it
returns Ok and that the group's pending commit is cleared; then call
clear_pending_commit with a non-existent group id and assert it returns an Err
(or the appropriate MdkUniffiError). Use parse_group_id/lock behavior indirectly
via the public API and mirror the structure/assertions from the
merge_pending_commit test to verify the FFI binding end-to-end.
ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06a0636 and 8469240.

📒 Files selected for processing (2)
  • crates/mdk-uniffi/CHANGELOG.md
  • crates/mdk-uniffi/src/lib.rs
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/mdk-uniffi/src/lib.rs`:
- Around line 810-814: Add a unit test for clear_pending_commit similar to the
existing merge_pending_commit test: instantiate the MdkUniffi object, create a
test group (so there is a pending commit), call clear_pending_commit(&self,
mls_group_id: String) and assert it returns Ok and that the group's pending
commit is cleared; then call clear_pending_commit with a non-existent group id
and assert it returns an Err (or the appropriate MdkUniffiError). Use
parse_group_id/lock behavior indirectly via the public API and mirror the
structure/assertions from the merge_pending_commit test to verify the FFI
binding end-to-end.

@dannym-arx

dannym-arx commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

I don't think we need a test personally, the useful tests are in the PR introducing clear_pending_commit. Any test added here would just be silly imo

@dannym-arx
dannym-arx merged commit 119593a into master Feb 23, 2026
14 of 15 checks passed
@dannym-arx
dannym-arx deleted the expose-clear_pending_commit-to-bindings branch February 23, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants