Repository navigation
[AI:zf-builder] fix: webRTC SDP wire encoding corrupts ICE candidate protocol tokens (UDP->udpDP) breaking peer connectivity - #144
Conversation
…(UDP->udpDP) breaking peer connectivity Task: zf-zs-7781a546 bug: WebRTC SDP wire encoding corrupts ICE candidate protocol tokens (UDP->udpDP) breaking peer connectivity
ntsd
left a comment
There was a problem hiding this comment.
[AI:zf-reviewer] [Reviewer Feedback] Round 1: Approved for human review.
Reviewed the P0 fix for WebRTC SDP wire encoding corrupting ICE candidate protocol tokens (UDP -> udpDP). Verified against the repo at task/zf-zs-7781a546 (PR #144).
Correctness (verified by execution, not inspection):
- I reproduced the bug on the pre-fix
sdp-compactcodec in an isolated scratch workspace: a candidate-bearing SDP round-trips toa=candidate:123 1 udpDP ...andm=application 9 UDP/DTLS/SCTP ... IN Iapplication4 0.0.0.0. Confirmed the new byte-exact round-trip assertion FAILS on the old codec — so the new regression guard is a genuine regression detector, not a tautology. - On the new base64url codec, the round-trip is byte-exact and uppercase
UDP/TCP/UDP/DTLS/SCTPtokens survive.sdpEncodeoutput is RFC3986-unreserved-only ([A-Za-z0-9-._~]), confirmed by test. sdpDecodestill throws synchronously on empty / invalid-base64 / non-SDP (missingv=) input; both user-controllable call sites (theslink param on the receive page, the pasted/QR-scanned answer code on the offer page) remain wrapped intry/catchwith their existing toasts — the two static source guards from the prior test are preserved and pass.
Ponytail gatekeeping (7-rung ladder):
- Rung 3/5 (dependency veto): PASS — this change REMOVES a dependency.
sdp-compact(and its transitivepako) are dropped frompackage.jsonandpackage-lock.json(lockfile regenerated;npm ls sdp-compactis clean, sonpm cion the CI gate will not fail on lock/package drift). The replacement uses only built-inbtoa/atob/TextEncoder/TextDecoder. This is the inverse of bloat. - Rung 1/6 (simplicity/YAGNI): PASS — two minimal pure helpers (
toBase64Url/fromBase64Url) plus two exported functions; no classes, no factories, no speculative flags. ThebytesToBinarychunked loop (8192-byte slices) is justified: it avoids theString.fromCharCode(...args)spread-size limit on large trickle payloads. Not over-engineered. - Rung 7 (diff scope/hygiene): PASS — tightly scoped to the codec, the guard test, two call sites (dropping the now-unused
isOffersecond arg), package.json/lock, and the hand-written README. No drive-by reformatting, no leftover debug, no unrelated churn. The now-dead sdp-compact resolve hook in the test was correctly removed.
Gates (all pass in-workspace, CI order): npm run lint ✓ · npx tsc --noEmit ✓ · npm run build (astro) ✓ · npm test → 66/66 pass ✓. PR is MERGEABLE (no conflicts). .github/workflows/ci.yml order (lint -> typecheck -> build -> test) is unchanged.
Notes (non-blocking):
- The
openwiki/prose still describes the legacysdp-compact/isOffercodec. This is expected and not a gate failure: OpenWiki pages are regenerated by the scheduled OpenWiki GitHub Actions workflow and are the scope of the separate doc-sync task (zf-zs-12e6fd1d), not this code PR. No test validates OpenWiki content. The hand-writtenREADME.mdwas correctly updated. - Wire format change: encoded links/answer codes from the old codec will no longer decode (base64url vs the old dictionary+substitution scheme). Acceptable for a P0 correctness fix — both peers must be on the same build; there is no backward-compat requirement in the task.
CONVENTION: Regression guards for source-invariant codec fixes should assert byte-exact round-trip on a realistic candidate-bearing SDP (uppercase UDP + a second TCP token), and additionally assert the encoded output is RFC3986-unreserved-only [A-Za-z0-9-._~] since it embeds in the s/c/p URL params and the answer code.
GOTCHA: Removing a devDependency requires regenerating package-lock.json (drops the entry AND its transitive deps, e.g. sdp-compact -> pako); CI's npm ci fails if the lockfile and package.json drift, so verify with npm ls <pkg> (expect empty) after a dep removal.
GOTCHA: OpenWiki prose (openwiki/*.md, openwiki/.claims/*) lags code changes and is refreshed by the scheduled OpenWiki workflow / a separate doc-sync task — it is NOT a PR review gate, and generated pages must not be hand-edited in a code PR.
Approved for auto-merge.
[AI:zf-builder] Task: zf-zs-7781a546
bug: WebRTC SDP wire encoding corrupts ICE candidate protocol tokens (UDP->udpDP) breaking peer connectivity
Automated PR for task zf-zs-7781a546
Completed by: @zf-builder