Audit: - docs/AUDIT-2026-05-25.md: full protocol audit covering 8 findings (4 critical, 2 high, 5 medium, 4 low) with code references and fix effort estimates - vault/Audit/Tasks.md: Obsidian Tasks plugin file tracking all audit items with priorities, due dates, and per-step checklists Architecture docs updated for Wire format v2 and Wave 5/6 features: - ARCHITECTURE.md: adds wzp-video to dependency graph and project structure; wire format updated to v2 (16B header, 5B MiniHeader); relay concurrency section corrected (DashMap+RwLock is current, not a future optimization); test count 571→702; Android note - PROGRESS.md: Wave 5 and Wave 6 sections appended; test count 372→702; current status and open blockers as of 2026-05-25 - ROAD-TO-VIDEO.md: implementation status table inserted (✅/🟡/🔴/🔲 per phase); 6-step critical path to first video call - WZP-SPEC.md: MediaHeader updated to v2 (16B byte-aligned); MiniHeader updated to 5B with seq_delta; codec IDs 9-12 added (H.264/H.265/AV1); version negotiation section added Obsidian vault (vault/): - 114 files across Architecture/, PRDs/, Reports/, Android/, Reference/, Audit/ with YAML frontmatter - 00 - Home.md index note with wiki links - .obsidian/app.json config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
75 lines
2.6 KiB
Markdown
75 lines
2.6 KiB
Markdown
---
|
|
tags: [report, wzp]
|
|
type: report
|
|
status: Pending Review
|
|
---
|
|
|
|
# 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) -> u64` helper using `QualityProfile::total_bitrate_kbps()`.
|
|
- In `try_transition()`, before upgrading to a higher tier, check BWE headroom:
|
|
```rust
|
|
if 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;
|
|
}
|
|
}
|
|
```
|
|
This requires `target_send_bps() >= 130%` of the next tier's bitrate ceiling (including FEC overhead).
|
|
|
|
## 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
|
|
|
|
```bash
|
|
$ 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-proto` test count: 119 (was 118 before T2.3)
|
|
- `cargo clippy -p wzp-proto --all-targets -- -D warnings`: pass
|
|
- `cargo fmt --all -- --check`: pass
|
|
|
|
## Risks / follow-ups
|
|
|
|
- `BandwidthEstimator` is attached via `set_bandwidth_estimator()`; call sites in `wzp-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
|