feat(dev/tunnel): WSS client + frame protocol (Phase 1)#20
Merged
Conversation
4 tasks
e8e77f4 to
1b9777d
Compare
…n yet)
Adds the WebSocket side of `mirrorstack dev`:
- Frame envelope (type, id, corr_id, stream_id, payload) — wire-shape
matches api-platform's internal/dispatch/ws/frames.go
- Connect: opens wss_url?token=ttok, sends register, awaits register_ack
- Background task: pings every 30s, replies to server pings, sends
close frame on shutdown signal
Deferred frame types (rpc.*, sql.*) are enumerated in the FrameType enum
so server frames of those shapes deserialize without forcing a reconnect
once those planes go live.
This module is `#[allow(dead_code)]` for now — it compiles + tests but
isn't wired into the dev lifecycle yet. End-to-end integration requires
two pieces still in flight elsewhere:
- api-platform AWS Sender impl (apigatewaymanagementapi.PostToConnection)
- IaC for the WS API GW + Lambda routing
Once those land, a small follow-up PR plugs this module into dev::run
and adds a --tunnel flag that gates the connect.
Deps added (used only inside this module):
- tokio (rt + macros + time + sync + net + io-util)
- tokio-tungstenite (connect + rustls-tls-webpki-roots)
- futures-util (sink + std)
Test plan:
- [x] cargo test (4 new round-trip + uniqueness tests)
- [x] cargo clippy --all-targets -- -D warnings clean
- [x] cargo fmt --all -- --check clean
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c59ae46 to
03dfe35
Compare
…, observability Five concrete fixes from the multi-agent review: 1. URL building uses url::Url + query_pairs_mut, matching auth::authorize_url (auth/mod.rs:52-61). Drops the brittle "?" vs "&" substring check. 2. Handshake flattened into await_register_ack(sink, stream, register_id) — removes three-level nesting (timeout > async > loop > match). 3. Background task surfaces transport failures via warn_prefix() instead of silently returning. Stream close, send error, server close all log actionable lines now. (Liveness-signal-on-handle queued as #29 — that's a structural change worth its own PR.) 4. WebSocketConfig caps inbound frames at 1 MiB (was: tungstenite default 64 MiB). Per L1.5 a frame is at most 128 KB; 1 MiB gives streaming headroom without exposing a memory-bomb surface. 5. TunnelHandle drops the unused service_token field. RegisterAck still carries it (forward-compat with the wire shape); re-thread to the handle when the RPC plane lands and actually consumes it. Plus: MissedTickBehavior::Delay on the heartbeat interval so a paused runtime (laptop sleep) doesn't burst-ping on resume. Three new tests cover the URL builder. 54 tests pass, clippy + fmt clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds the WebSocket-side building blocks for `mirrorstack dev`:
Module is gated with `#[allow(dead_code)]` — it compiles + tests now but isn't wired into the dev lifecycle yet. End-to-end integration follows once two upstream pieces ship.
Wire-shape mirror
Both sides share the same envelope ordering and the same `type` discriminator strings. Reserved `FrameType::RpcReq` / `SqlReq` / etc. are enumerated client-side so future server frames of those shapes deserialize without forcing a reconnect once those planes go live.
Blocked on
Base branch
Stacks on `feat/dev-shell` (PR #19). Will rebase to main after #19 merges.
Deps added
Test plan
🤖 Generated with Claude Code