Skip to content

[AI:zf-builder] fix: webRTC SDP wire encoding corrupts ICE candidate protocol tokens (UDP->udpDP) breaking peer connectivity - #144

Merged
ntsd merged 2 commits into
mainfrom
task/zf-zs-7781a546
Nov 4, 2026
Merged

ntsd merged 2 commits into
mainfrom
task/zf-zs-7781a546

Conversation

@ntsd

@ntsd ntsd commented Nov 4, 2026

Copy link
Copy Markdown
Owner

[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

ntsd added 2 commits November 4, 2026 19:47
…(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 ntsd left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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-compact codec in an isolated scratch workspace: a candidate-bearing SDP round-trips to a=candidate:123 1 udpDP ... and m=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/SCTP tokens survive. sdpEncode output is RFC3986-unreserved-only ([A-Za-z0-9-._~]), confirmed by test.
  • sdpDecode still throws synchronously on empty / invalid-base64 / non-SDP (missing v=) input; both user-controllable call sites (the s link param on the receive page, the pasted/QR-scanned answer code on the offer page) remain wrapped in try/catch with 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 transitive pako) are dropped from package.json and package-lock.json (lockfile regenerated; npm ls sdp-compact is clean, so npm ci on the CI gate will not fail on lock/package drift). The replacement uses only built-in btoa/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. The bytesToBinary chunked loop (8192-byte slices) is justified: it avoids the String.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 isOffer second 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 legacy sdp-compact/isOffer codec. 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-written README.md was 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.

@ntsd
ntsd merged commit 0fb5310 into main Nov 4, 2026
1 check passed
@ntsd
ntsd deleted the task/zf-zs-7781a546 branch November 4, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant