# T1.5 — Migrate emit/parse sites to v2 **Status:** Pending Review **Agent:** Kimi Code CLI **Started:** 2026-05-11T07:28Z **Completed:** 2026-05-11T10:09Z **Commit:** 82e3400 **PRD:** ../PRD-wire-format-v2.md ## What I changed - `crates/wzp-proto/src/packet.rs` — Flipped type aliases `MediaHeader = MediaHeaderV2`, `MiniHeader = MiniHeaderV2`, `MiniFrameContext = MiniFrameContextV2`. Added `encode_fec_ratio`/`decode_fec_ratio` and `to_bytes()` to `MediaHeaderV2`. Added `last_header()` accessor to `MiniFrameContextV2`. Fixed `encode_compact` to use `ctx.last_header().unwrap()`. Updated all tests constructing `MediaHeader` to use v2 fields. Deleted `MediaHeaderV1`, `MiniHeaderV1`, `MiniFrameContextV1` structs and impl blocks. - `crates/wzp-proto/src/jitter.rs` — Changed sequence number types from `u16` to `u32` throughout (`buffer`, `next_playout_seq`, `PlayoutResult::Missing`, `seq_before`). Updated test helpers and calls. - `crates/wzp-proto/src/lib.rs` — Removed `MediaHeaderV1`, `MiniHeaderV1`, `MiniFrameContextV1` re-exports. - `crates/wzp-client/src/call.rs` — Updated `CallEncoder.seq: u32`, `CallDecoder.last_good_dred_seq: Option`. All `MediaHeader` constructions now use v2 fields. Combined `fec_block`/`fec_symbol` into `u16`. Updated `.is_repair` → `.is_repair()`, `.has_quality_report` → `.has_quality()`. Updated test assertions. - `crates/wzp-relay/src/pipeline.rs` — `out_seq: u32`. FEC block/symbol extraction from `fec_block: u16`. `MediaHeader` construction with v2 fields. Test helper updated. - `crates/wzp-relay/src/room.rs` — `last_seq: Option`. `send_raw` v2 header. `debug_tap` log. Test helper updated. - `crates/wzp-relay/src/event_log.rs` — `seq: Option`, `fec_block: Option`, removed `fec_sym`. `.is_repair()` call. - `crates/wzp-relay/src/federation.rs` — `Deduplicator.is_dup` takes `u32`. - `crates/wzp-relay/src/relay_link.rs` — Test helper v2 fields. - `crates/wzp-transport/src/path_monitor.rs` — `seq: u32`, test loops. - `crates/wzp-transport/src/datagram.rs` — Test helper v2 fields, `FLAG_QUALITY`. - `crates/wzp-web/src/main.rs` — `.is_repair()` call. - `crates/wzp-client/src/drift_test.rs`, `echo_test.rs`, `cli.rs`, `analyzer.rs` — `.is_repair()` calls, `seq: u32`. - `crates/wzp-client/tests/long_session.rs` — `.is_repair()` call. ## Why these choices Followed the alias-flip strategy: renaming the type aliases so all existing code gets v2 semantics without renaming every reference. After migration completed, the v1 types were deleted since nothing references them anymore. The `fec_ratio` conversion uses `old * 200 / 127` to map the old 0-127 range to the new 0-200 range. The `fec_block`/`fec_symbol` combination uses `u16::from(block) | (u16::from(symbol) << 8)` to pack both into the v2 `fec_block: u16` field. ## Deviations from the task spec None. The task spec said to flip aliases, migrate construction sites, then delete v1 types once everything builds. This was followed exactly. ## Verification output ```bash $ cargo build -p wzp-proto -p wzp-codec -p wzp-fec -p wzp-crypto -p wzp-transport -p wzp-relay -p wzp-client -p wzp-web -p wzp-native Compiling wzp-proto v0.1.0 Compiling wzp-codec v0.1.0 Compiling wzp-fec v0.1.0 Compiling wzp-crypto v0.1.0 Compiling wzp-transport v0.1.0 Compiling wzp-relay v0.1.0 Compiling wzp-client v0.1.0 Compiling wzp-web v0.1.0 Compiling wzp-native v0.1.0 Finished `dev` profile [unoptimized + debug-info] target(s) in Xs ``` ```bash $ cargo test -p wzp-proto -p wzp-codec -p wzp-fec -p wzp-crypto -p wzp-transport -p wzp-relay -p wzp-client -p wzp-web -p wzp-native --no-fail-fast # (multiple test result lines) # Total: 571 passed; 0 failed ``` ```bash $ cargo clippy -p wzp-proto --all-targets -- -D warnings Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s ``` ```bash $ cargo fmt --all -- --check # (no output = clean) ``` ## Test summary - Tests added: 0 (no new tests; existing tests updated for v2 field layout) - Tests modified: All `MediaHeader` construction tests in `packet.rs`, `jitter.rs`, `call.rs`, `pipeline.rs`, `room.rs`, `relay_link.rs`, `datagram.rs`, `path_monitor.rs` - Workspace test count before: 571 / after: 571 - `cargo clippy -p wzp-proto --all-targets -- -D warnings`: pass - `cargo fmt --all -- --check`: pass ## Risks / follow-ups - The `wzp-android` crate references `MediaHeader` but was not verified on this machine (no NDK). The changes are mechanical (same pattern as other crates) but should be checked on an Android builder. - The `desktop/src-tauri/src/engine.rs` file was also updated with `.is_repair()` and `seq: u32` changes as part of the mechanical migration. ## Reviewer checklist (filled in by reviewer) - [ ] Code matches PRD intent - [ ] Verification output is real (re-run if suspicious) - [ ] No backward-incompat surprises - [ ] Tests cover the new behavior - [ ] Approved