feat(mls/api): XIP-83 Subscribe — tag deliveries with wave mutate_id and enforce ordering guarantees#564
Merged
Conversation
ApprovabilityVerdict: Needs human review This PR implements XIP-83 Subscribe protocol features including wave mutate_id tagging, new ordering guarantees, and new validation rules that can fail streams. These are significant runtime behavior changes to the subscription system, and the modified files are owned by xmtp/backend team rather than the PR author. You can customize Macroscope's approvability policy. Learn more. |
tylerhawkes
force-pushed
the
tyler/xip-83-subscribe-delivery-tags
branch
from
July 9, 2026 08:10
8e57941 to
3c0f694
Compare
…and enforce ordering guarantees Replace chunked per-topic catch-up with a per-wave ceiling-pinned merged id-order scan per message kind; gate live delivery for a wave's topics and fold gated arrivals into the wave at completion (tagged, sorted, deduped); stamp every Messages frame with its wave's mutate_id (0 = live); require nonzero mutate_id on adds; ack every Mutate with exactly one CatchupComplete. Welcome wave scans advance from raw rows so unknown message types cannot silently truncate a wave. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tylerhawkes
force-pushed
the
tyler/xip-83-subscribe-delivery-tags
branch
from
July 9, 2026 09:13
3c0f694 to
6a42e51
Compare
neekolas
approved these changes
Jul 9, 2026
neekolas
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements XIP-83 server-tagged deliveries on the v3
Subscribehandler. Spec revision: xmtp/XIPs#139; protos: xmtp/proto#340.Protocol behavior
Messagesframe is stamped with the wave that produced it (mutate_id,0= live); a frame never mixes lanes or waves.CatchupComplete; live for other topics keeps flowing; messages are delivered exactly once across the seam.Mutatewith adds must carry a nonzeromutate_id(INVALID_ARGUMENTotherwise); everyMutateis acked by exactly oneCatchupComplete(immediate when no wave starts).Implementation
QueryGroupMessagesWaveScan/QueryWelcomeMessagesWaveScan: unnest-join per-topic floors, global scan cursor, ceiling pinned at wave start,ORDER BY id LIMIT page).TopicsLive, thenCatchupComplete, then the gates open.message_typecan no longer silently truncate a wave's replay.Mutateprocessing parses and validates all adds before applying removes.Testing
~20 new tests cover the interleavings: tagging under overlapping waves, merged wave order (both kinds), live total order per kind, the seam (made deterministic via fake-store gating), reset and remove mid-wave,
history_onlymid-replay publishes, multi-page tag stamping, disconnect cleanup, and store-level unknown-type paging. The suite was mutation-tested: breaking the fold tag, fold sort (either kind), seam gate, fold dedup, welcome cursor advancement, or waveless acks each fails at least one test.Depends on xmtp/proto#340 — the vendored generated code here matches that branch and regenerates identically from proto@main once it lands.
🤖 Generated with Claude Code
Note
Tag MLS Subscribe delivery frames with wave
mutate_idand enforce catch-up ordering guaranteesSubscribeResponse_V1_Messagesframes now carry amutate_idcorrelating them to the originatingMutatewave; live frames are tagged with 0.QueryGroupMessagesWaveScan,QueryWelcomeMessagesWaveScan), pinned to a ceiling captured at wave start and paged by a configurablescanPageLimit.completeWavehelper beforeTopicsLiveandCatchupCompleteare emitted, ensuring no live frames precede the wave seam.Mutaterequests: nonzeromutate_idrequired when adds are present;mutate_idreuse while a wave is in-flight is rejected withInvalidArgument; adds-per-Mutate are capped bymaxMutateAdds(returnsResourceExhausted).QueryWelcomeMessagesWaveScannow returns raw scan position metadata (lastRawID,rawCount) and advances the cursor via raw row count to avoid truncation when unknownmessage_typerows are skipped.Macroscope summarized 6a42e51.