2.5 KiB
2.5 KiB
T2.3 — Plumb BWE into AdaptiveQualityController
Status: Pending Review Agent: Kimi Code CLI Started: 2026-05-11T17:13Z Completed: 2026-05-11T17:20Z Commit: 846c98e PRD: ../PRD-transport-feedback-bwe.md
What I changed
crates/wzp-proto/src/quality.rs—AdaptiveQualityController:- Added
bwe: Option<Arc<BandwidthEstimator>>field. - Added
set_bandwidth_estimator(&mut self, bwe: Arc<BandwidthEstimator>)setter. - Added
tier_ceiling_bps(tier: Tier) -> u64helper usingQualityProfile::total_bitrate_kbps(). - In
try_transition(), before upgrading to a higher tier, check BWE headroom:This requiresif let Some(ref bwe) = self.bwe { let required = (Self::tier_ceiling_bps(next_tier) * 130) / 100; if bwe.target_send_bps() < required { self.consecutive_up = 0; return None; } }target_send_bps() >= 130%of the next tier's bitrate ceiling (including FEC overhead).
- Added
Why these choices
The 130% headroom factor is a safety margin: we only upgrade if the bandwidth estimate comfortably exceeds the target tier's requirement, preventing flapping when BWE is borderline. Resetting consecutive_up to 0 on BWE block gives the estimator time to converge before the next upgrade attempt.
Checking the next tier's ceiling (not the current tier) is correct: the guard answers "can we afford the tier we're trying to move into?"
Deviations from the task spec
None.
Verification output
$ cargo test -p wzp-proto quality
running 24 tests
...(all 24 pass)...
test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 95 filtered out; finished in 0.10s
Test summary
- Tests added: 1
bwe_guard_blocks_upgrade_when_bandwidth_insufficient— verifies low BWE blocks upgrade, high BWE allows it after counter reset
- Tests modified: 0
wzp-prototest count: 119 (was 118 before T2.3)cargo clippy -p wzp-proto --all-targets -- -D warnings: passcargo fmt --all -- --check: pass
Risks / follow-ups
BandwidthEstimatoris attached viaset_bandwidth_estimator(); call sites inwzp-client(send/recv loops) will create and wire it in a future task.- The BWE guard only applies to upgrades. Downgrades are unchanged — they react quickly to quality reports regardless of BWE.
Reviewer checklist (filled in by reviewer)
- Code matches PRD intent
- Verification output is real
- No backward-incompat surprises
- Tests cover the new behavior
- Approved