Files
wz-phone/docs/PRD/reports/T1.2-report.md
2026-05-11 12:37:32 +04:00

97 lines
3.7 KiB
Markdown

# T1.2 — Add `MediaType` enum
**Status:** Approved
**Agent:** Kimi Code CLI
**Started:** 2026-05-11T06:55Z
**Completed:** 2026-05-11T07:08Z
**Commit:** see git log
**PRD:** ../PRD-wire-format-v2.md
## What I changed
- `crates/wzp-proto/src/media_type.rs:1-55` — created new module with `MediaType` enum (`Audio=0`, `Video=1`, `Data=2`, `Control=3`), `to_wire()`, `from_wire()`, and two unit tests
- `crates/wzp-proto/src/lib.rs:18` — added `pub mod media_type;`
- `crates/wzp-proto/src/lib.rs:28` — added `pub use media_type::MediaType;`
- `crates/wzp-proto/src/packet.rs:4` — added `use crate::MediaType;`
- `crates/wzp-proto/src/packet.rs:168` — changed `MediaHeaderV2.media_type` from `u8` to `MediaType`, resolving the `TODO(T1.2)`
- `crates/wzp-proto/src/packet.rs:184``write_to` now calls `self.media_type.to_wire()`
- `crates/wzp-proto/src/packet.rs:202``read_from` now uses `MediaType::from_wire(buf.get_u8())?`
- `crates/wzp-proto/src/packet.rs:1292` — updated `media_header_v2_roundtrip` test to use `MediaType::Audio`
## Why these choices
Followed steps T1.2.1 through T1.2.2 without deviation. Since `MediaType` now exists, I also resolved the `TODO(T1.2)` placeholder left in `MediaHeaderV2` during T1.1 so the v2 header is internally consistent before moving on.
## Deviations from the task spec
None.
## Verification output
```bash
$ cargo test -p wzp-proto media_type
running 2 tests
test media_type::tests::media_type_roundtrip ... ok
test media_type::tests::media_type_unknown_rejected ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 106 filtered out; finished in 0.00s
```
```bash
$ cargo test -p wzp-proto media_header_v2_roundtrip
running 1 test
test packet::tests::media_header_v2_roundtrip ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 107 filtered out; finished in 0.00s
```
```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
Finished `dev` profile [unoptimized + debuginfo] target(s) in 15.31s
```
```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
...
test result: ok. 567 passed; 0 failed; ...
```
```bash
$ cargo clippy -p wzp-proto --all-targets -- -D warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.57s
```
```bash
$ cargo fmt --all -- --check
# (clean)
```
## Test summary
- Tests added: 2 (`media_type_roundtrip`, `media_type_unknown_rejected`)
- Tests modified: 1 (`media_header_v2_roundtrip` — now uses `MediaType::Audio`)
- Workspace test count before: 565 pass / 0 fail (non-Android subset)
- Workspace test count after: 567 pass / 0 fail (non-Android subset)
- `cargo clippy -p wzp-proto --all-targets -- -D warnings`: pass
- `cargo fmt --all -- --check`: pass
## Risks / follow-ups
None.
## Reviewer checklist (filled in by reviewer)
- [x] Code matches PRD intent
- [x] Verification output is real (re-run if suspicious) — re-ran `cargo test -p wzp-proto` (112 passed across 2 suites), clippy + fmt clean.
- [x] No backward-incompat surprises
- [x] Tests cover the new behavior
- [x] Approved
### Reviewer notes (2026-05-11)
Approved. Bonus that the agent resolved the `TODO(T1.2)` placeholder inside `MediaHeaderV2.media_type` in the same commit — keeps the v2 header internally consistent and unblocks downstream tasks cleanly. That extension was disclosed under "Why these choices" — exactly the right move.
One small follow-up:
1. **T1.2.1 — Add rustdoc on `MediaType` variants and methods.** Same rustdoc-coverage concern as T1.1.1 — coding standard #9. Non-blocking.