Skip to content

stream: cross-node bridge — frames cross node-to-node (Phase 10, PR9 — capstone) - #612

Merged
transfix merged 1 commit into
masterfrom
feat/grpc-stream-bridge
Oct 11, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/grpc-stream-bridge

Conversation

@transfix

Copy link
Copy Markdown
Owner

Cross-node streaming critical path — PR9 of 9 — 🎯 the capstone: frames cross node-to-node

Based on master (PR1–8 merged). The control plane (PR1–5) lets a peer discover a stream; the data-plane transport (PR6–8) carries frame bytes over gRPC. PR9 ties them together — a stream produced on one node is consumed on another.

cvc::ariadne::stream::stream_bridge

Maps a cvc::ariadne::stream::frame ↔ the transport envelope (payload = frame bytes; seq/pts ride along; the format comes from the replicated descriptor, not re-sent per frame):

  • serve(local, consumer_endpoint) — the producer opens a StreamChannel to the consumer and pushes local's frames: a pusher subscribes to local.channel() (ring; drop-oldest under overload — drop-at-source) and send()s each frame (chunked by PR8) until the stream closes or the consumer disconnects.
  • receive_into(stream_id, proxy) — the consumer routes inbound frames for stream_id into a local proxy stream via publish_external, so its local consumers observe them like any local stream. The transport sink is a shared router so a frame delivered after the bridge is destroyed hits a live object, not a dangling this.

Roles (a pragmatic refinement)

To reuse the PR7/8 transport unchanged, the consumer runs the gRPC server and the producer is the client that pushes. Wiring the consumer's endpoint via a sendMessage offer/answer handshake (so merely discovering the descriptor auto-serves a consumer), and the conventional producer-serves-a-port model (needs a transport server-push path), are noted as the thin next layers — v1 proves frames cross with the least new code.

One transport fix

Added stream_transport_grpc::set_server_echo(bool) (default ON, preserving the PR7/8 round-trip tests). The bridge turns it OFF: a one-way push never reads echoes, and an unread echo fills gRPC flow control and deadlocks the sender — found and fixed while bringing up the capstone.

Test — stream_bridge_test.FramesCrossNodeToNode

5 frames published into a stream on app A arrive byte-identical and in order in a proxy stream on app B, over the gRPC data plane (36 ms). The PR7/8 transport tests (4) and the control-plane grpc test (21) stay green.

This completes the critical path

Control plane (discover) ✅ · data plane (carry) ✅ · bridge (cross) ✅. A stream opened on one node is now discoverable and consumable on another — the goal the whole 9-PR effort set out to reach.

…ase 10, PR9)

The capstone. The control plane (PR1-5) lets a peer DISCOVER a stream;
the data-plane transport (PR6-8) carries frame bytes over gRPC. PR9 ties
them together so a stream produced on one node is consumed on another.

New cvc::ariadne::stream::stream_bridge (ariadne layer; maps a
cvc::ariadne::stream::frame to/from the transport envelope — payload is
the frame bytes, seq/pts ride along, the format comes from the replicated
descriptor and is not re-sent per frame):
  - serve(local, consumer_endpoint): the PRODUCER opens a StreamChannel to
    the consumer and pushes local's frames — a pusher subscribes to
    local.channel() (ring, drop-oldest under overload) and send()s each
    frame (chunked by the transport) until the stream closes or the
    consumer disconnects.
  - receive_into(stream_id, proxy): the CONSUMER routes inbound frames for
    stream_id into a local proxy stream via publish_external, so its local
    consumers observe them like any local stream. The transport sink is a
    shared router so a frame delivered after the bridge is destroyed hits a
    live object, not a dangling this.

Roles vs the original plan: to reuse the PR7/8 transport unchanged, the
CONSUMER runs the gRPC server and the PRODUCER is the client that pushes.
Wiring the consumer's endpoint via a sendMessage offer/answer handshake
(so merely discovering the descriptor auto-serves a consumer) is the thin
next layer on this bridge; the conventional producer-serves-a-port model
needs a transport server-push path. Both noted as follow-ups; v1 proves
frames cross with the least new code.

Transport: add stream_transport_grpc::set_server_echo(bool) (default ON,
preserving the PR7/8 round-trip tests). The bridge turns it OFF: a one-way
push never reads echoes, and an unread echo would fill gRPC flow control
and deadlock the sender (found + fixed while bringing up the capstone).

Test stream_bridge_test.FramesCrossNodeToNode: 5 frames published into a
stream on app A arrive byte-identical and in order in a proxy stream on
app B, over the gRPC data plane. The PR7/8 transport tests (4) and the
control-plane grpc test (21) stay green.
@transfix
transfix enabled auto-merge (squash) October 11, 2026 17:54
@transfix
transfix merged commit cfbc048 into master Oct 11, 2026
14 checks passed
@transfix
transfix deleted the feat/grpc-stream-bridge branch October 29, 2026 20:52
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.

1 participant