Repository navigation
fix(voice-call): bind realtime streams to signed calls - #136506
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR binds Twilio realtime stream sessions to the call identity in the verified webhook and rejects missing or mismatched identities. Example: A stream URL issued for signed CallSid CA22222222222222222222222222222222 receives a start frame naming CA33333333333333333333333333333333.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current call-identity boundary defect. The prior lookup-assertion finding is resolved, no new actionable defects were found, and current-head CI is still pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe voice-call plugin converts verified carrier webhooks into one-time WebSocket sessions, then admits carrier audio into the call manager and realtime voice bridge. flowchart LR
A[Carrier webhook] --> B[Signature verification]
B --> C[Call identity and inbound policy]
C --> D[One-time stream session]
D --> E[WebSocket start identity check]
E --> F[Call manager]
F --> G[Realtime voice bridge]
Technical reviewBest possible solution: Retain the focused signed-call binding and boundary regression, then land through the normal current-head CI gates. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the unbound Twilio path, and the contributor reports that reverting only the production fix makes all three retained boundary cases fail; this review did not execute tests. Is this the best way to solve the issue? The smallest complete repair uses the existing webhook verifier, one-time session metadata, and stream admission owner; the classification helper preserves existing predicates, and fixture updates serve the strengthened identity contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6c7483ee34c4. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +12, Tests +450, Other +4. Total +466 across 12 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (10 earlier review cycles; latest 8 shown)
Reviewed November 19, 2026, 1:07 PM ET / 18:07 UTC (Revision 11). |
Implemented the requested rank-up move in The new regression crosses the real server boundary: it sends an actually signed Twilio webhook I also reverse-applied only the production hunk while retaining this test. It failed on the old |
b143321 to
0222d07
Compare
Round-2 executed evidence is now included in the PR body. The new boundary test drives both identities through the real signed webhook, listening server, WebSocket upgrade, call manager, lookup, and bridge boundary: the matching The only behavioral doubles are the external This evidence does not include a live Twilio Media Streams session; provider wire behavior is covered by the adapter tests rather than a live call. |
0222d07 to
b05ba58
Compare
The blank- The branch is rebased onto current main. Core lint stripes 2–5 pass; stripe 1's only finding is the pre-existing This evidence does not include a live Twilio Media Streams session; provider wire behavior is covered by the adapter tests rather than a live call. Verified new SHA: |
Pushed This evidence does not include a session originated by Twilio's servers; the carrier side is a simulator that follows Twilio's documented webhook parameters, signature scheme, and Media Streams message formats, and signs requests with Twilio's official SDK. Wire contracts: https://www.twilio.com/docs/voice/twiml#twilios-request-to-your-application · https://www.twilio.com/docs/usage/webhooks/webhooks-security · https://www.twilio.com/docs/voice/media-streams/websocket-messages · https://www.twilio.com/docs/voice/twiml/stream |
31eb248 to
e1c301b
Compare
|
@clawsweeper re-review
|
|
🦞👀 Re-review progress:
|
…ovider ID (follows openclaw#136506)
* fix(voice-call): bind realtime streams to signed calls * test(voice-call): cover signed stream binding boundary * test(voice-call): drive documented Twilio stream frames through the signed boundary * test(voice-call): account for admission persistence recheck
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
…ovider ID (follows openclaw#136506)
* fix(voice-call): bind realtime streams to signed calls * test(voice-call): cover signed stream binding boundary * test(voice-call): drive documented Twilio stream frames through the signed boundary * test(voice-call): account for admission persistence recheck (cherry picked from commit 3b8b74f) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 53b683162748a2e369707ed56704b8d4218b11b3) (cherry picked from commit 39f662b12c15883376b1e85281a9add08a2ceb8f)
Baseline adaptation: Keep the existing stable TwiML selector, replay and inbound admission gates, and Telnyx pre-dial manager identity semantics. Bind Twilio issuance and admission to the accepted signed CallSid and adapt the stable realtime fixtures, including native playback, to supply matching call identities. (cherry picked from commit 3b8b74f) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 5a149e635c85342115102f147f75a992e87dba1b)
What Problem This Solves
Twilio realtime stream startup could associate a WebSocket with a call identity different from the signature-verified webhook request that generated its TwiML. A signed webhook with an absent or whitespace-only
CallSidcould also mint an unbound one-time stream URL.Why This Change Was Made
The TwiML path now trims and requires the signature-verified
CallSidbefore any<Stream>response or one-time stream session is issued. A missing or blank signedCallSidreceives the existing non-disclosing rejection response. Valid Twilio stream metadata always carries the bound call identity, so the WebSocket start-frame comparison is unconditional. Telnyx retains its existing internal-call binding flow.User Impact
Realtime Twilio audio can attach only to the call that received the corresponding signed TwiML response. Missing or blank call identities are rejected before stream issuance. A mismatched start frame is closed with policy code
1008and reasonCall identity does not match stream session, before call lookup, event processing, or external realtime bridge creation.Evidence
Carrier simulator run against the built product
This run was captured on
b05ba58e, before the branch was rebased onto current main. It has not been repeated on the current heade1c301bc; the current head is covered by the committed boundary regression in the next section.The built product was run with the bundled Twilio voice-call path and bundled OpenAI realtime provider. A local fake OpenAI Realtime endpoint acknowledged
session.update, counted input audio, and emitted one audio delta.The invalid-signature status is the product's existing HTTP 401 contract; this change does not alter it.
Start frame that reached bridge setup:
{"event":"start","sequenceNumber":"1","start":{"accountSid":"AC…redacted","streamSid":"MZ…redacted","callSid":"CA…redacted","tracks":["inbound"],"customParameters":{"proof":"carrier-sim-989"},"mediaFormat":{"encoding":"audio/x-mulaw","sampleRate":8000,"channels":1}},"streamSid":"MZ…redacted"}Contract sources:
This evidence does not include a session originated by Twilio's servers; the carrier side is a simulator that follows Twilio's documented webhook parameters, signature scheme, and Media Streams message formats, and signs requests with Twilio's official SDK.
Committed boundary regression
The boundary test drives the documented Twilio message sequence (
connected→ fullstart→media→stop, with the full webhook parameter set) through the realCallManager,TwilioProvider,VoiceCallWebhookServer,RealtimeCallHandler, listening HTTP server, WebSocket upgrade, and production SQLite state store. The trace below is from the focused test executed on the current heade1c301bc(Node v24.22.2); call identities, signing material, and one-time URLs are redacted.The matching path performs two call lookups before bridge entry: the initial resolution, and the live-call recheck after admission persistence. The test now expects both. The mismatch path still requires zero lookups, events, and bridges.
With only the production changes of this pull request reversed (
webhook.ts,realtime-handler.ts,realtime-inbound-admission.ts) and every test left in place, the same file fails all three tests; with the changes restored it passes 3/3.The remaining behavioral test doubles are the external
RealtimeVoiceProviderPluginand itsRealtimeVoiceBridge; manager spies are call-through observers.Rebase onto current main
The branch is rebased onto current main. Main had since split the realtime inbound admission logic out of
webhook.ts; the initial-TwiML-request classification now lives beside it asgetRealtimeTwimlParamsinrealtime-inbound-admission.ts, which keepswebhook.tsunder its line cap. The binding behavior is unchanged: a signedCallSidis required and trimmed before stream issuance, recorded on the one-time session, and compared against the Twilio start frame before lookup or bridge creation. Telnyx keeps its internal-call binding.Existing fixtures that started Twilio sessions without a matching provider call identity now supply one. The boundary test is registered with the database-worker test configuration because it uses the SQLite store.
config/test-lines-allocations/136506-signed-realtime-boundary.txtrequests 49 test lines above the standard allowance for the signed HTTP/WebSocket/SQLite boundary test.Validation
All on the current head
e1c301bc, Node v24.22.2, pnpm 12.15.0:Not covered: a session originated by Twilio's servers, and a repeat of the carrier simulator run on the current head.
Twilio carrier simulator used for the run
Install
wsandtwilioin a scratch npm project, configure the product webhook plus a fake realtime metrics endpoint, and run this script. Synthetic TLS uses a locally trusted test certificate; the lookup hook maps the synthetic proof hostname to loopback.