Conversation
Tempo Lint ResultsSummaryFound 710 issue(s) across 45 file(s)
Issues by Rule Type
|
Foundation for WebSocket support (TOOLS-323). Adds transport traits matching mppx's Transport interface: - server::transport::Transport — get_credential, respond_challenge, respond_receipt with associated Input/Output types - server::transport::HttpTransport — HTTP impl using http crate types - client::transport::Transport — is_payment_required, get_challenge, set_credential with associated Request/Response types - client::transport::HttpTransport — reqwest impl Existing HTTP logic (fetch.rs, axum.rs, middleware.rs) is unchanged; the traits provide a parallel abstraction that WebSocket/MCP transports will implement in follow-up PRs. Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
8a4d1e4 to
aceb75d
Compare
Server-side WS transport implementing the Transport trait with JSON message protocol: - WsMessage (client→server): credential, data variants - WsResponse (server→client): challenge, message, needVoucher, receipt, error variants - WsTransport implements get_credential, respond_challenge, respond_receipt for WS frames - ws feature flag gating tokio-tungstenite + futures-util deps Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
Client-side WS transport implementing the Transport trait: - WsClientMessage (client→server): credential, data variants - WsServerMessage (server→client): challenge, message, needVoucher, receipt, error variants (mirrors server::ws types) - WsTransport implements is_payment_required, get_challenge, set_credential for WS frames Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
db91654 to
808989b
Compare
axum_ws module handles the full WS payment flow: 1. Client connects → server sends challenge frame 2. Client sends credential → server verifies 3. On success, streams application data as message frames 4. Sends final receipt frame before close Uses axum dev-dependency with ws feature. Gated behind cfg(test, ws, axum) until axum becomes a proper optional dep. Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
E2e tests over real WebSocket connections: - Full challenge → credential → data/error flow - Message type serialization over the wire - NeedVoucher roundtrip Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
examples/ws/ with server + client binaries: - ws-server: axum WS endpoint that sends challenge, verifies credential, streams fortunes, sends receipt - ws-client: tokio-tungstenite client handling the full flow Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
5c252a2 to
218a77c
Compare
Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
ws_session module implements the SSE-equivalent metering loop over WS: - ws_session(): deducts tick_cost per value, sends needVoucher when exhausted, waits for channel store update, resumes, emits session receipt on completion - process_incoming_vouchers(): runs on the receiver half, parses voucher credentials from WS frames, calls verify_session() which updates ChannelStore and wakes the sender Usage: split WS into sender/receiver, run ws_session + process_incoming_vouchers concurrently via tokio::select!/join!. Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
- HttpTransport::get_credential() no longer double-prepends 'Payment ' (extract_payment_scheme already returns the full fragment) - axum_ws handler now verifies credential.challenge.id matches the issued challenge before calling verify_payment (prevents replay) - Fix doc: need-voucher → needVoucher (matches serde camelCase output) - Add test for valid Payment header parsing Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
- test_ws_challenge_id_mismatch_rejected: credential with wrong challenge ID is rejected (never succeeds as data/receipt) - test_server_client_wire_type_compat: serialize with server types, deserialize with client types and vice versa (all 7 message variants) Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8
9cec0af to
c39a0fc
Compare
Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
…em helpers Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d1f49-ad9f-74a8-9268-37d860491bb8 Co-authored-by: Amp <amp@ampcode.com>
Co-Authored-By: grandizzy <38490174+grandizzy@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d23a5-8821-747b-bfa0-9ae8abc12fa6
Changes
Adds WebSocket transport for bidirectional session payments (TOOLS-323).
Transport trait abstraction
server::transport::Transport— abstracts credential extraction, challenge response, and receipt attachment (HTTP impl included)client::transport::Transport— abstracts payment detection, challenge extraction, and credential attachment (HTTP impl included)WebSocket transport
server::ws/client::ws— WebSocket transport with JSON message protocol (credential,challenge,message,needVoucher,receipt,error)server::ws_session— metered streaming over genericSink/Stream(framework-agnostic equivalent of SSE metering)wsfeature flag gatingtokio-tungstenite+futures-utilExample & tests
examples/ws/— working server + client example using mock charge method (runs locally out of the box)tests/integration_ws.rs— e2e tests over real WS connectionsTesting
Co-Authored-By: grandizzy 38490174+grandizzy@users.noreply.github.com
Prompted by: georgen