3.3 KiB
T2.4 — Relay conformance: Tier A (bitrate ceiling)
Status: Pending Review Agent: Kimi Code CLI Started: 2026-05-11T17:20Z Completed: 2026-05-11T17:35Z Commit: 846c98e PRD: ../PRD-relay-conformance.md
What I changed
-
crates/wzp-relay/src/conformance.rs(new) — Conformance meter + violation enum:Violationenum:BitrateExceeded,PacketRateExceeded,TimestampDrift.ConformanceMeterwith 1-second sliding window trackingbytes_in_window.ceiling_bps(codec)—nominal * 3 * 115 / 100with floor of 2 kbps.observe()returnsErr(Violation::BitrateExceeded)when window bytes exceedceiling_bps / 8.
-
crates/wzp-relay/src/lib.rs— Addedpub mod conformance;. -
crates/wzp-relay/src/metrics.rs— Addedconformance_violations: IntCounterVec(label:violation_type). -
crates/wzp-relay/src/room.rs— WiredConformanceMeterinto both forwarding loops:run_participant_plainandrun_participant_trunkedeach create a per-participant meter.- On violation: logs
tracing::warn!+ bumps Prometheus counter. - Observe-only — packets are never dropped.
-
crates/wzp-client/src/featherchat.rs— Added missingTransportFeedbackmatch arm (back-fill from T2.1).
Why these choices
Using a plain struct with &mut self (no atomics/mutex) is correct because each participant runs in exactly one async recv task. The meter is never shared across threads.
The * 3 factor accounts for FEC 2.0 (200% overhead = 3× total bitrate). The * 115 / 100 adds a 15% safety margin. The 2 kbps floor prevents ComfortNoise (0 bps nominal) from having a zero ceiling.
Deviations from the task spec
- Task example shows
parking_lot::Mutex<Instant>. We don't haveparking_lotin the relay crate, and it's unnecessary for a single-threaded async loop. Used plainInstantfield instead.
Verification output
$ cargo test -p wzp-relay conformance
running 4 tests
test conformance::tests::bitrate_exceeded_for_opus24k ... ok
test conformance::tests::ceiling_bps_floor ... ok
test conformance::tests::small_packets_stay_within_ceiling ... ok
test conformance::tests::window_resets_after_one_second ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 76 filtered out; finished in 0.00s
$ cargo test -p wzp-relay
running 86 tests
...(all 86 pass)...
test result: ok. 86 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
Test summary
- Tests added: 4
bitrate_exceeded_for_opus24k— 1 MB/s payload declared as Opus24k correctly returnsBitrateExceededsmall_packets_stay_within_ceiling— 100 small packets stay under limitwindow_resets_after_one_second— window rollover worksceiling_bps_floor— ComfortNoise gets 2 kbps floor
- Tests modified: 0
wzp-relaytest count: 86 (was 82 before T2.4)cargo clippy -p wzp-relay --lib: pass (no new warnings)cargo fmt --all -- --check: pass
Risks / follow-ups
- Tier B (packet-rate) and Tier C (timestamp drift) are reserved for T2.5.
- Currently observe-only. Future tasks may add drop/throttle behavior.
Reviewer checklist (filled in by reviewer)
- Code matches PRD intent
- Verification output is real
- No backward-incompat surprises
- Tests cover the new behavior
- Approved