Conversation
commit: |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
👁️ Cyclops Security Review🧭 Auditing · mode=
⚙️ Controls
📜 3 events🔍 |
|
left some comments on overall design -- especially given sensitivity here for security flows kicked off a cyclops run too can you attach a diagram / flow of the state machine? is hard to understand from code alone |
|
@brendanjryan so I'm thinking of it as implementation-first, not protocol-final:
In other words, it's not “this is now the protocol”. It’s more “this is a concrete state machine that works, and we can use it to decide what the right generalized protocol shape should be.” Added a verbose diagram below since I agree it’s hard to reason about from code alone. stateDiagram-v2
[*] --> Idle
Idle --> Probe402: client GET /ws/chat (HTTP)
Probe402 --> WsConnect: 402 + Payment challenge
Probe402 --> Failed: no challenge / invalid challenge
WsConnect --> AwaitAuthReceipt: open websocket\n send initial authorization frame
WsConnect --> Failed: ws open fails
AwaitAuthReceipt --> Streaming: server verifies open\n sends payment-receipt
AwaitAuthReceipt --> Failed: payment-error / socket close
Streaming --> AwaitVoucher: server sends payment-need-voucher
AwaitVoucher --> Streaming: client sends higher cumulative voucher\nserver verifies + sends payment-receipt
Streaming --> AwaitCloseReady: client requests close
AwaitVoucher --> AwaitCloseReady: client requests close while paused for coverage
AwaitCloseReady --> AwaitCloseReceipt: server stops stream\ncomputes final spent\nsends payment-close-ready\nclient signs final close credential
AwaitCloseReady --> Failed: payment-error / socket close
AwaitCloseReceipt --> Settled: server verifies close\nsettles onchain\nsends payment-receipt
AwaitCloseReceipt --> Failed: payment-error / socket close
Settled --> Closed: websocket closes
Closed --> [*]
Failed --> [*]
|
Adds a working end-to-end websocket transport for
tempo.session().This keeps the initial
402bootstrap over HTTP, then moves the rest of the session flow onto the websocket: initial auth, mid-stream voucher top-ups, final stop/close, and settlement receipt. The app layer only sees streamed content.Also fixes a few issues that showed up once the flow was exercised end to end:
close()on an active websocket now does an explicit stop/finalize handshake before signing the final close credentialIncludes a runnable
examples/session/wsdemo:CleanShot.2026-04-02.at.15.25.31.mp4