feat: add clear_pending_commit for publish failure recovery#192
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughA new public method Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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 |
Add `MDK::clear_pending_commit(group_id)` to allow callers to roll back an uncommitted pending MLS commit. Without this, a single failed relay publish permanently blocks all future group operations with "Can't execute operation because a pending commit exists". Wraps OpenMLS's `MlsGroup::clear_pending_commit` with MDK's group- loading and error handling. Discovered from: VectorPrivacy/Vector#46 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f321a69 to
92ec6a4
Compare
dannym-arx
left a comment
There was a problem hiding this comment.
LGTM, I wonder tho if we should expose clear_pending_commit in the uniffi bindings too?
Don't let that stop the merge tho, can be another PR
Problem
MDK documents that
merge_pending_commitshould be called after publishing the Kind:445 message. But if the publish fails (relay down, network error, auth rejection after retries), the pending commit remains in storage permanently. Every subsequentadd_members,remove_members, orself_updatecall fails with:The group is stuck with no recovery path. The only option is to create a new group.
This was discovered while implementing MIP-02/MIP-03 relay-confirmation-before-merge ordering in Vector: VectorPrivacy/Vector#46
Fix
Expose OpenMLS's existing
MlsGroup::clear_pending_commit(which already persists the state change viaStorageProvider::write_group_state) as a one-line wrapper:This returns the group to its pre-commit state — no epoch advance, no member changes. Clients call it when publish exhausts retries, then surface the error to the user who can retry the operation.
Usage
Test plan
cargo check -p mdk-coreclear_pending_commitcalled → group remains functional → re-enable relays → retry kick → succeeds🤖 Generated with Claude Code
This PR exposes OpenMLS's existing
MlsGroup::clear_pending_commitvia a new MDK wrapper method to enable recovery from failed relay publishes. When a publish fails after creating a pending commit, the group becomes stuck and unable to perform any operations; this method allows clients to roll back the pending commit and retry the failed operation.What changed:
MDK::clear_pending_commit(&self, group_id: &GroupId) -> Result<(), Error>public method to mdk-core that loads the MLS group and delegates to OpenMLS's clear_pending_commit, returning the group to its pre-commit state without advancing epoch or applying member changes.API surface:
clear_pending_commit(group_id)allows explicit rollback of uncommitted pending MLS commits.Testing: