Skip to content

feat(xmtp_api_d14n): XmtpMlsBidiStreams trait + v3 Subscribe transport#3771

Merged
tylerhawkes merged 2 commits into
mainfrom
tyler/xip83-3-bidi-api
Jun 25, 2026
Merged

feat(xmtp_api_d14n): XmtpMlsBidiStreams trait + v3 Subscribe transport#3771
tylerhawkes merged 2 commits into
mainfrom
tyler/xip83-3-bidi-api

Conversation

@tylerhawkes

@tylerhawkes tylerhawkes commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Stack 3/4 of the XIP-83 bidi client lane: #3769#3770#3771#3772.

Native-only XmtpMlsBidiStreams trait in xmtp_proto::api_clientsubscribe_bidi(BoxStream<SubscribeRequest>) -> Stream<Result<SubscribeResponse>> — and its V3Client implementation: prost-encode outbound frames over bidi_stream("/xmtp.mls.api.v1.MlsApi/Subscribe"), decode inbound via the existing XmtpStream. Browsers stay on XmtpMlsStreams + watchdog (gRPC-Web cannot full-duplex).

🤖 Generated with Claude Code

Note

Add XmtpMlsBidiStreams trait and bidirectional streaming support to the v3 Subscribe transport

  • Introduces the XmtpMlsBidiStreams trait in xmtp_proto (native-only) defining a subscribe_bidi method for full-duplex MLS subscriptions per XIP-83.
  • Implements subscribe_bidi for V3Client in bidi.rs, encoding outbound SubscribeRequest frames and decoding inbound SubscribeResponse frames over the underlying Client::bidi_stream.
  • Adds bidi_stream to the Client trait with a default implementation returning "not supported"; GrpcClient overrides this on native targets using tonic bidirectional streaming.
  • Propagates bidi_stream through all middleware layers: AuthMiddleware, MultiNodeClient, ReadWriteClient, ReadonlyClient, and BoxedClient.
  • Behavioral Change: ReadonlyClient now enforces write-deny checks on bidirectional streaming paths; wasm targets always return an unsupported error.

Macroscope summarized c793213.

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown

Claude finished @tylerhawkes's task —— View job


Code Review Completed

Review Date: June 25, 2026

Summary

This PR successfully introduces the XIP-83 bidirectional streaming capability for native-only targets. The author has already addressed multiple rounds of feedback, including the critical AuthMiddleware forwarding issue mentioned in the most recent comment. The implementation is thorough and follows existing patterns well.

✅ What's Good

  1. Consistent middleware implementation — All middleware wrappers (AuthMiddleware, ReadonlyClient, ReadWriteClient, MultiNodeClient) now properly forward bidi_stream with appropriate semantics (auth/readonly/routing, etc.), mirroring their stream implementations (crates/xmtp_api_d14n/src/middleware/auth.rs:185-197)

  2. Proper blanket implsBox<T>, Arc<T>, and &T forwarders for both Client::bidi_stream and XmtpMlsBidiStreams ensure type erasure works seamlessly (crates/xmtp_proto/src/traits.rs:199-206, crates/xmtp_proto/src/api_client/impls.rs:407-443)

  3. Native-only gating — Appropriate use of if_native! prevents compilation on platforms without full-duplex support, with clear documentation explaining the limitation (crates/xmtp_api_grpc/src/grpc_client/client.rs:196-224)

  4. Comprehensive test coverage — The bidi transport implementation has solid unit tests verifying encoding/decoding, error handling, and middleware forwarding (crates/xmtp_api_d14n/src/queries/v3/bidi.rs:52-175, crates/xmtp_api_d14n/src/middleware/auth.rs:291-312)

  5. RPC instrumentation — The #[xmtp_common::rpc_span] annotation on subscribe_bidi provides observability at the appropriate boundary layer (crates/xmtp_api_d14n/src/queries/v3/bidi.rs:29)

📊 Test Coverage Note

Codecov reports 72.56% patch coverage with 31 lines missing. Most uncovered lines are:

  • Default trait implementations (expected — only exercised when a concrete type lacks full-duplex support)
  • Error path in traits.rs:157-159 (the "unsupported transport" default)
  • Some blanket impl forwarding paths (also expected — these are fallback code paths)

This is acceptable given these are defensive/fallback code paths that are difficult to meaningfully test.

🟢 Verdict

Ready to merge. All previous review comments have been addressed, the implementation is sound, and test coverage is appropriate for the changes. No blocking issues remain.


Comment thread crates/xmtp_api_d14n/src/queries/v3/bidi.rs
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-2-bidi-transport branch from 5329964 to ba3c4de Compare June 12, 2026 21:33
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-3-bidi-api branch from 22b2c8b to a9ffc28 Compare June 12, 2026 21:33
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.56522% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.44%. Comparing base (1e1a195) to head (c793213).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/xmtp_api_grpc/src/grpc_client/client.rs 22.22% 14 Missing ⚠️
crates/xmtp_proto/src/traits.rs 0.00% 8 Missing ⚠️
crates/xmtp_api_d14n/src/middleware/auth.rs 77.77% 4 Missing ⚠️
crates/xmtp_proto/src/api_client/impls.rs 0.00% 4 Missing ⚠️
...es/xmtp_api_d14n/src/middleware/readonly_client.rs 0.00% 3 Missing ⚠️
crates/xmtp_api_d14n/src/queries/v3/bidi.rs 96.29% 3 Missing ⚠️
...pi_d14n/src/middleware/multi_node_client/client.rs 0.00% 2 Missing ⚠️
...pi_d14n/src/middleware/read_write_client/client.rs 0.00% 2 Missing ⚠️
crates/xmtp_proto/src/traits/boxed_client.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3771      +/-   ##
==========================================
- Coverage   84.44%   84.44%   -0.01%     
==========================================
  Files         408      409       +1     
  Lines       59880    60013     +133     
==========================================
+ Hits        50567    50675     +108     
- Misses       9313     9338      +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tylerhawkes tylerhawkes force-pushed the tyler/xip83-2-bidi-transport branch from ba3c4de to cf43cdd Compare June 12, 2026 21:59
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-3-bidi-api branch 2 times, most recently from 249cf99 to 13bce00 Compare June 15, 2026 20:20
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-2-bidi-transport branch from cf43cdd to 7ef18f0 Compare June 15, 2026 20:20
Comment thread crates/xmtp_proto/src/api_client.rs
tylerhawkes added a commit that referenced this pull request Jun 16, 2026
…#3769)

**Stack 1/4** of the XIP-83 bidi client lane: #3769#3770#3771#3772.

Regenerated `xmtp.mls.api.v1` from xmtp/proto#337: the bidirectional
`Subscribe` RPC with versioned `SubscribeRequest`/`SubscribeResponse`,
id-based `Mutate` (cursors, `history_only`), `Ping`/`Pong`,
`TopicsLive`, `CATCHUP_COMPLETE`, and STARTED `capabilities`. Purely
additive (+1,896 generated lines); `proto_version` pinned to that
branch's sha — draft until the proto PR merges.
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-2-bidi-transport branch from 7ef18f0 to af6ab11 Compare June 16, 2026 21:04
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-3-bidi-api branch from 13bce00 to 0f1cead Compare June 16, 2026 21:04
…efault-unsupported elsewhere)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-2-bidi-transport branch from af6ab11 to 74f05a8 Compare June 24, 2026 20:29
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-3-bidi-api branch from 0f1cead to 8bd3ec0 Compare June 24, 2026 20:29
tylerhawkes added a commit that referenced this pull request Jun 24, 2026
**Stack 2/4** of the XIP-83 bidi client lane: #3769#3770#3771#3772.

Adds one primitive to the protocol-agnostic `Client` trait:
`bidi_stream(request, path, BoxDynStream<Bytes>) ->
http::Response<BytesStream>` — outbound stream of encoded protobuf
messages in, inbound message stream out. Default implementation errors
("not supported by this transport"), so gRPC-Web/wasm and mocks are
untouched; forwarded through the `&T`/`Box`/`Arc`/boxed-client impls.
`GrpcClient` overrides it natively via tonic `Grpc::streaming` + the
existing `TransparentCodec`, reusing the NonBlocking stream machinery
verbatim. `build_tonic_request` made generic over the body type.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Base automatically changed from tyler/xip83-2-bidi-transport to main June 24, 2026 21:38
@tylerhawkes tylerhawkes marked this pull request as ready for review June 24, 2026 22:20
@tylerhawkes tylerhawkes requested a review from a team as a code owner June 24, 2026 22:20
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 24, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces new bidirectional streaming infrastructure (XIP-83 trait and v3 Subscribe transport) which represents a new feature capability. While the implementation is well-structured and the author owns all changed files, new features introducing new communication patterns warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@cameronvoell cameronvoell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bidi finally! i'll leave the claude comment about test coverage up to your discretion 🙏

Comment thread crates/xmtp_api_d14n/src/queries/v3/bidi.rs
…t (XIP-83, native-only)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-3-bidi-api branch from b65f00e to c793213 Compare June 25, 2026 19:13
@tylerhawkes tylerhawkes enabled auto-merge (squash) June 25, 2026 19:16
@tylerhawkes tylerhawkes merged commit cc24cc4 into main Jun 25, 2026
46 checks passed
@tylerhawkes tylerhawkes deleted the tyler/xip83-3-bidi-api branch June 25, 2026 19:45
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.

3 participants