Skip to content

feat(xmtp_api_grpc): bidi_stream transport primitive#3770

Draft
tylerhawkes wants to merge 1 commit into
mainfrom
tyler/xip83-2-bidi-transport
Draft

feat(xmtp_api_grpc): bidi_stream transport primitive#3770
tylerhawkes wants to merge 1 commit into
mainfrom
tyler/xip83-2-bidi-transport

Conversation

@tylerhawkes

@tylerhawkes tylerhawkes commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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

Note

Add bidi_stream bidirectional streaming transport primitive to xmtp_api_grpc

  • Adds a bidi_stream method to the Client trait in traits.rs that accepts an outbound BoxDynStream<'static, Bytes> and returns an inbound BytesStream; the default implementation returns an unsupported-transport error.
  • Implements bidi_stream for non-wasm GrpcClient in client.rs using TransparentCodec and NonBlockingStreamRequest over HTTP/2.
  • Delegates bidi_stream through BoxedClient and all blanket forwarding impls (&T, &mut T, Arc<T>).
  • Updates generated protobuf code with new Subscribe bidirectional RPC and associated SubscribeRequest/SubscribeResponse message types including serde impls.
  • Makes build_tonic_request generic over the request body type to support streaming use cases.

Macroscope summarized af6ab11.

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown

Claude finished @tylerhawkes's task —— View job


Code Review Completed

Review checklist:

  • Read changed files (traits.rs, client.rs, boxed_client.rs)
  • Analyze implementation for issues
  • Provide review feedback

Review Feedback

Reviewed: 2026-06-16 21:05 UTC

The implementation is well-structured and follows existing patterns. One observation and minor suggestion:

Correctness & Pattern Consistency

client.rs:194-219 - The bidi_stream implementation follows the same pattern as stream (lines 164-189), which is good for consistency. However, note that build_tonic_request was made generic (line 84) specifically to accept BoxDynStream<'static, Bytes> as the body type. This works because tonic's streaming method accepts this type, but it creates a subtle coupling: if the signature of body in bidi_stream changes, the generic bound on build_tonic_request might need adjustment.

Documentation

Consider adding a brief doc comment on build_tonic_request to clarify that it's generic over body type to support both Bytes (unary/server-streaming) and BoxDynStream (bidirectional) use cases. This would help future maintainers understand why it's generic.

traits.rs:150-160 - Default implementation correctly returns an unsupported-transport error. The parameter suppression via let _ = (request, path, body) is idiomatic.

Coverage: The 14% patch coverage reported by Codecov is expected for this primitive-level infrastructure. Testing will naturally come in stack 3/4 when higher-level subscription logic consumes this transport.

Overall: LGTM - solid foundation for XIP-83 bidi streaming.


@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.28571% with 24 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (tyler/xip83-1-subscribe-protos@21b315c). Learn more about missing BASE report.

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_proto/src/traits/boxed_client.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                        @@
##             tyler/xip83-1-subscribe-protos    #3770   +/-   ##
=================================================================
  Coverage                                  ?   84.41%           
=================================================================
  Files                                     ?      408           
  Lines                                     ?    59796           
  Branches                                  ?        0           
=================================================================
  Hits                                      ?    50477           
  Misses                                    ?     9319           
  Partials                                  ?        0           

☔ 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 5329964 to ba3c4de Compare June 12, 2026 21:33
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-1-subscribe-protos branch from 2a66968 to 5030100 Compare June 12, 2026 21:33
@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-1-subscribe-protos branch from 5030100 to 9eb4ed4 Compare June 12, 2026 21:59
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-2-bidi-transport branch from cf43cdd to 7ef18f0 Compare June 15, 2026 20:20
@tylerhawkes tylerhawkes force-pushed the tyler/xip83-1-subscribe-protos branch from 9eb4ed4 to 21b315c Compare June 15, 2026 20:20
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.
Base automatically changed from tyler/xip83-1-subscribe-protos to main June 16, 2026 20: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 7ef18f0 to af6ab11 Compare June 16, 2026 21:04
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