sdk: dial routers over WebSocket, so both SDKs join sam-one #515
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 595 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.382
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #515"
general
weight: 0.35
aojea
Both SDKs now join
sam-one, directly and behind--tunnel cloudflare, and tests hold them to both.Why
sam-one's embedded router listens on WebSocket alone, on the single port that also serves its control plane (/ws, or/wssbehind--tunnel). Both SDKs dialed TCP only, so the "Run your own" path of the Native SDKs guide admitted neither of them. Nothing tested that path.Change
sdk/js/src/host.ts):@libp2p/websocketsjoinstcp()in the host's transports. It is the maintained transport (backpressure,/ws,/wss,/tls/sni/…/ws, listeners), declared inpackage.json; the lockfile gains it and its four dependencies.sdk/python/src/agent_mesh/host.py):new_host(enable_websocket=True)adds py-libp2p 0.7's WebSocket transport; the address filter no longer drops/wsand/wss.sam-one --tunnel cloudflarethe router is/dns4/<host>.trycloudflare.com/tcp/443/wss/p2p/<id>, and Cloudflare selects the origin by TLS SNI and theHostheader. py-libp2p 0.7 resolves the name to its IP before dialing and then puts the IP in both, which Cloudflare answers with403 Forbidden. The Python host now dials a WebSocket address by its name (what go-libp2p and js-libp2p do), anddial_addrsno longer pre-resolves/dns4on WebSocket addresses. This is a py-libp2p bug, present on itsmaintoo; to be reported upstream.wsswithverify_mode=CERT_NONEunless given a TLS client context. The host passesssl.create_default_context(), the system roots, as the JS (ws→ Node TLS) and Go hosts verify.Verified against a real tunnel
bin/sam-one --tunnel cloudflare --tunnel-install, then throughhttps://<x>.trycloudflare.com: JS agent ← Python caller (2.4 s) and Python agent ← JS caller (3.0 s), both answering with the verified caller. The first Python attempt was the 403 above; the fix is what made it pass.Tests
TestStandaloneSDKAgents(~4.5 s): startssam-one, runs each language's A2A agent example against it and calls it with the other language's A2A caller (js-calls-python,python-calls-js). Mutation-checked: with the JS transport removed the JS agent fails with "no router admitted this member"; with the Python transport removed the Python agent fails with "no transport found for …/ws/…".TestStandaloneSDKAgentsBehindTLSEdge(~4.5 s): the same pair behind an in-test TLS-terminating reverse proxy reached ashttps://localhost:<port>that, like Cloudflare, fails the handshake for any other SNI and answers any otherHostwith 403;sam-onegets it asExternalURLand advertises/dns4/localhost/…/wss. Both SDKs trust the edge certificate throughNODE_EXTRA_CA_CERTS/SSL_CERT_FILE. Mutation-checked: without the name-preserving dial the Python agent fails the edge's TLS handshake ("unknown server name"); withoutSSL_CERT_FILEit fails withCERTIFICATE_VERIFY_FAILED.host.test.ts: a mesh host dials/wsand/tcplisteners with TLS+yamux; a/dns4WebSocket dial carries the name inHost.test_host.py:/wsand/tls/wsaddresses are dialable; a host reaches a/wslistener; a/dns4WebSocket dial carries the name inHost(fails with127.0.0.1without the fix); wss is dialed withCERT_REQUIREDand hostname checking (fails without the context).runExampletakes the repository root instead of ansdkMesh.Docs
sdk/README.mdand the Native SDKs guide say the SDKs dial TCP and WebSocket and whatsam-onelistens on. The browser stays out of scope, stated precisely: routers and nodes accept libp2p TLS alone, which a browser cannot speak (that needs Noise on the Go side), and the SDK keeps its state and speaks HTTP on streams with Node's modules.Not in this PR (was in the first version)
@libp2p/websockets.Buffer/node:crypto/node:fsportability refactor: it leftlibp2p-http.tsonnode:http, so it did not make the package browser-loadable, and it imported@noble/curvesand@multiformats/multiaddr-matcherwithout declaring them.tests/ui/agents.spec.jsand the runner split: the sessions ran in the Playwright Node process, not in the browser, and the console coverage exists inconsole.spec.js.session.serve, which the SDK no longer has.Validation:
npm run typecheck,npm test(70),pytest(82),TestStandaloneSDKAgents*|TestStandaloneNodeJoin|TestNativeSDKsMesh|TestNativeSDKA2A|TestNativeSDKExamples|TestSDKCanaryScript,hack/verify-sdk-generated.sh,hack/verify-secrets.sh, golangci-lint v2.14.0 ontests/integration.