4.8 KiB
4.8 KiB
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 aliasesMediaHeader = MediaHeaderV2,MiniHeader = MiniHeaderV2,MiniFrameContext = MiniFrameContextV2. Addedencode_fec_ratio/decode_fec_ratioandto_bytes()toMediaHeaderV2. Addedlast_header()accessor toMiniFrameContextV2. Fixedencode_compactto usectx.last_header().unwrap(). Updated all tests constructingMediaHeaderto use v2 fields. DeletedMediaHeaderV1,MiniHeaderV1,MiniFrameContextV1structs and impl blocks.crates/wzp-proto/src/jitter.rs— Changed sequence number types fromu16tou32throughout (buffer,next_playout_seq,PlayoutResult::Missing,seq_before). Updated test helpers and calls.crates/wzp-proto/src/lib.rs— RemovedMediaHeaderV1,MiniHeaderV1,MiniFrameContextV1re-exports.crates/wzp-client/src/call.rs— UpdatedCallEncoder.seq: u32,CallDecoder.last_good_dred_seq: Option<u32>. AllMediaHeaderconstructions now use v2 fields. Combinedfec_block/fec_symbolintou16. 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 fromfec_block: u16.MediaHeaderconstruction with v2 fields. Test helper updated.crates/wzp-relay/src/room.rs—last_seq: Option<u32>.send_rawv2 header.debug_taplog. Test helper updated.crates/wzp-relay/src/event_log.rs—seq: Option<u32>,fec_block: Option<u16>, removedfec_sym..is_repair()call.crates/wzp-relay/src/federation.rs—Deduplicator.is_duptakesu32.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
$ 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
$ 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
$ cargo clippy -p wzp-proto --all-targets -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
$ 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
MediaHeaderconstruction tests inpacket.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: passcargo fmt --all -- --check: pass
Risks / follow-ups
- The
wzp-androidcrate referencesMediaHeaderbut 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.rsfile was also updated with.is_repair()andseq: u32changes 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