T5.7.1: Unify Verdict enum into wzp_relay::verdict, drop RepeatAbusive variant
This commit is contained in:
@@ -9,6 +9,8 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use wzp_proto::{CodecId, MediaHeader, MediaType};
|
||||
|
||||
use crate::verdict::Verdict;
|
||||
|
||||
/// Maximum samples kept in rolling windows.
|
||||
const MAX_IAT_SAMPLES: usize = 200;
|
||||
const MAX_SIZE_SAMPLES: usize = 200;
|
||||
@@ -23,17 +25,6 @@ const BITRATE_WINDOW_SECS: u64 = 30;
|
||||
// Number of payload-size histogram bins.
|
||||
// (SIZE_BINS reserved for future histogram-based bimodality)
|
||||
|
||||
/// Verdict produced by the scorer after sufficient observation.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Verdict {
|
||||
/// No suspicion. Score ≥ 0.7.
|
||||
Legitimate,
|
||||
/// Tightened monitoring. 0.3 ≤ score < 0.7.
|
||||
Suspect,
|
||||
/// High confidence of abuse. Score < 0.3.
|
||||
Abusive,
|
||||
}
|
||||
|
||||
/// Audio-specific behavioural scorer (Tier F).
|
||||
pub struct AudioScorer {
|
||||
/// Rolling inter-arrival times.
|
||||
|
||||
@@ -26,6 +26,7 @@ pub mod route;
|
||||
pub mod session_mgr;
|
||||
pub mod signal_hub;
|
||||
pub mod trunk;
|
||||
pub mod verdict;
|
||||
pub mod ws;
|
||||
|
||||
pub use config::RelayConfig;
|
||||
|
||||
@@ -11,18 +11,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use wzp_proto::packet::{HangupReason, ViolationCode};
|
||||
|
||||
/// Conformance verdict produced by Tier F scoring.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Verdict {
|
||||
/// No suspicion.
|
||||
Legitimate,
|
||||
/// Tightened monitoring.
|
||||
Suspect,
|
||||
/// High confidence of abuse — close session.
|
||||
Abusive,
|
||||
/// Already abusive once in the last 24 h — escalate to block.
|
||||
RepeatAbusive,
|
||||
}
|
||||
use crate::verdict::Verdict;
|
||||
|
||||
/// Enforcement action recommended by the response policy.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
@@ -84,7 +73,6 @@ impl ResponsePolicy {
|
||||
}
|
||||
}
|
||||
}
|
||||
Verdict::RepeatAbusive => Action::Block,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
crates/wzp-relay/src/verdict.rs
Normal file
12
crates/wzp-relay/src/verdict.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
//! Shared conformance verdict enum (Tier F / Tier G).
|
||||
|
||||
/// Verdict produced by Tier F scoring and consumed by Tier G response policy.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Verdict {
|
||||
/// No suspicion. Score ≥ 0.7.
|
||||
Legitimate,
|
||||
/// Tightened monitoring. 0.3 ≤ score < 0.7.
|
||||
Suspect,
|
||||
/// High confidence of abuse. Score < 0.3.
|
||||
Abusive,
|
||||
}
|
||||
@@ -1710,14 +1710,15 @@ Statuses (in order of progression):
|
||||
| T4.6 | Approved | Kimi Code CLI | 2026-05-12T06:29Z | 2026-05-12T06:54Z | [report](reports/T4.6-report.md) | Approved. SFU keyframe cache via DashMap, two-phase buffer, 200 KB cap. Zero new tests — line drawn for future stateful work. Commit `828fbea`. |
|
||||
| T4.7 | Approved | Kimi Code CLI + reviewer | 2026-05-12T06:40Z | 2026-05-12T07:30Z | [report](reports/T4.7-report.md) | Approved. Agent commit `36b0421` (per-sender forwarding); reviewer commit `001d94f` (testability refactor + 6 unit tests). 93 → 99 wzp-relay lib tests. |
|
||||
| T5.1 | Approved | Kimi Code CLI | 2026-05-12T07:00Z | 2026-05-12T07:25Z | [report](reports/T5.1-report.md) | Approved. PriorityMode enum + SetPriorityMode signal + QualityProfile video fields. Commit `c8d1239`. Spawned T5.1.1 for round-trip / default tests. |
|
||||
| T5.1.1 | Pending Review | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:38Z | [report](reports/T5.1.1-report.md) | 3 follow-up tests for T5.1: default PriorityMode, backward-compat JSON, SetPriorityMode roundtrip. Commit `e34c40d`. |
|
||||
| T5.1.1 | Approved | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:41Z | [report](reports/T5.1.1-report.md) | Approved. 3 follow-up tests for T5.1 land cleanly. Commit `e34c40d` (substance) + `cf49404` (reports/board). |
|
||||
| T5.2 | Approved | Kimi Code CLI | 2026-05-12T07:25Z | 2026-05-12T08:00Z | [report](reports/T5.2-report.md) | Approved. VideoQualityController + 4 PriorityMode gates + 8 unit tests + 2× smoothing. Commit `2e0bdc5`. |
|
||||
| T5.3 | Approved | Kimi Code CLI | 2026-05-12T08:00Z | 2026-05-12T08:10Z | [report](reports/T5.3-report.md) | Approved. EncoderMode::SlideFallback at SD floor (150 kbps) for ScreenShare. 3 tests. Commit `c48cb6f`. |
|
||||
| T5.4 | Pending Review | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:38Z | [report](reports/T5.4-report.md) | H.265 encoder/decoder wrappers (VideoToolbox + MediaCodec), CodecId::H265Main. Commit `b197651`. |
|
||||
| T5.5 | Pending Review | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:38Z | [report](reports/T5.5-report.md) | 3-layer simulcast at sender (SimulcastEncoder + tick_simulcast). Commit `2f1a9f7`. |
|
||||
| T5.6 | Pending Review | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:38Z | [report](reports/T5.6-report.md) | Per-receiver simulcast layer selection at SFU (ReceiverState + hysteresis). Commit `2bbb664`. |
|
||||
| T5.7 | Pending Review | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:38Z | [report](reports/T5.7-report.md) | Tier F audio scorer (IAT CoV, silence fraction, bitrate, Q-flag, bimodality). Commit `5fda5ec`. |
|
||||
| T5.8 | Pending Review | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:38Z | [report](reports/T5.8-report.md) | Tier G response policy (Verdict, ResponsePolicy, typed Hangup::PolicyViolation). Commit `dbbab0d`. |
|
||||
| T5.4 | Approved | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:41Z | [report](reports/T5.4-report.md) | Approved. H.265 path mirrors H.264, `HevcParameterSets` extracts VPS+SPS+PPS, 8 new tests. Commit `b197651` + `283edd3` (clippy) + `fdfaed5` (fmt) + `cf49404` (reports/board). Android device validation deferred to T4.3.1.1. |
|
||||
| T5.5 | Approved | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:41Z | [report](reports/T5.5-report.md) | Approved. `SimulcastEncoder` + `tick_simulcast()` + 10 tests. Commit `2f1a9f7`. Cosmetic: report lists wrong resolutions (claims 320×180/640×360/1280×720; code uses 480×270/960×540/1920×1080). Code is correct. |
|
||||
| T5.6 | Approved | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:41Z | [report](reports/T5.6-report.md) | Approved. `ReceiverState` with atomic fields, 3 s hysteresis, per-(room,participant) isolation, 7 tests. Commit `2bbb664`. |
|
||||
| T5.7 | Approved | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:41Z | [report](reports/T5.7-report.md) | Approved. Tier F audio scorer: IAT CoV + silence fraction + bitrate ratio + Q-flag CV + payload bimodality, 11 tests. Commit `5fda5ec` + clippy `ffded2a`. Spawned T5.7.1 (unify `Verdict` across audio_scorer + response_policy). |
|
||||
| T5.7.1 | Pending Review | Kimi Code CLI | 2026-05-12T12:20Z | 2026-05-12T12:30Z | [report](reports/T5.7.1-report.md) | Unified `Verdict` enum into `wzp_relay::verdict::Verdict {Legitimate, Suspect, Abusive}`. Dropped `RepeatAbusive` as redundant input variant. 127 tests pass. |
|
||||
| T5.8 | Approved | Kimi Code CLI | 2026-05-12T11:15Z | 2026-05-12T11:41Z | [report](reports/T5.8-report.md) | Approved. `ResponsePolicy` state machine + typed `HangupReason::PolicyViolation { code, reason }` + `ViolationCode` enum + 9 tests. Commit `dbbab0d` + clippy `ffded2a`. |
|
||||
| T6.1 | Open | — | — | — | — | Skeleton — expand before claiming |
|
||||
| T6.2 | Open | — | — | — | — | Skeleton — expand before claiming |
|
||||
| T6.3 | Open | — | — | — | — | Skeleton — expand before claiming |
|
||||
@@ -1741,5 +1742,6 @@ Items currently waiting on the reviewer:
|
||||
- T5.6 — Per-receiver layer selection at SFU — report: reports/T5.6-report.md
|
||||
- T5.7 — Tier F audio scorer — report: reports/T5.7-report.md
|
||||
- T5.8 — Tier G response policy — report: reports/T5.8-report.md
|
||||
- T5.7.1 — Unify `Verdict` enum across audio_scorer and response_policy — report: reports/T5.7.1-report.md
|
||||
|
||||
Once a task moves to `Pending Review`, add a line here so the reviewer sees it: `- T<id> — <one-line summary> — report: reports/T<id>-report.md`. The reviewer removes the line when they mark it `Approved` (or moves it back to the agent on `Changes Requested`).
|
||||
|
||||
69
docs/PRD/reports/T5.7.1-report.md
Normal file
69
docs/PRD/reports/T5.7.1-report.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# T5.7.1 — Unify `Verdict` enum across `audio_scorer` and `response_policy`
|
||||
|
||||
**Status:** Pending Review
|
||||
**Agent:** Kimi Code CLI
|
||||
**Started:** 2026-05-12T12:20Z
|
||||
**Completed:** 2026-05-12T12:30Z
|
||||
**Commit:** fd67c18
|
||||
**PRD:** ../PRD-relay-conformance.md
|
||||
|
||||
## What I changed
|
||||
|
||||
- `crates/wzp-relay/src/verdict.rs` — New file. Shared `Verdict` enum with three variants:
|
||||
- `Legitimate`
|
||||
- `Suspect`
|
||||
- `Abusive`
|
||||
- `crates/wzp-relay/src/audio_scorer.rs:10-37` — Removed local `Verdict` enum; added `use crate::verdict::Verdict;`.
|
||||
- `crates/wzp-relay/src/response_policy.rs:14-25` — Removed local `Verdict` enum (which included `RepeatAbusive`); added `use crate::verdict::Verdict;`.
|
||||
- `crates/wzp-relay/src/response_policy.rs:87` — Removed `Verdict::RepeatAbusive => Action::Block` match arm. `ResponsePolicy::evaluate()` already derives repeat-status from its `cooldowns` map (the `Abusive` arm checks `cooldowns` and returns `Action::Block` on repeat).
|
||||
- `crates/wzp-relay/src/lib.rs` — Added `pub mod verdict;`.
|
||||
|
||||
## Why these choices
|
||||
|
||||
Two identical `Verdict` enums in the same crate is technical debt. `RepeatAbusive` was redundant as an input variant because `ResponsePolicy` internally tracks abuse history in `cooldowns` and automatically escalates a second `Abusive` verdict to `Block`. Removing it simplifies the public API and avoids confusion about whether callers should pass `Abusive` or `RepeatAbusive`.
|
||||
|
||||
## Deviations from the task spec
|
||||
|
||||
None.
|
||||
|
||||
## Verification output
|
||||
|
||||
```bash
|
||||
$ cargo test -p wzp-relay --lib
|
||||
Finished `test` profile [unoptimized + debuginfo] target(s) in 2.22s
|
||||
Running unittests src/lib.rs (target/debug/deps/wzp_relay-9174aebf89cae671)
|
||||
|
||||
running 127 tests
|
||||
...
|
||||
test result: ok. 127 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
|
||||
```
|
||||
|
||||
```bash
|
||||
$ cargo fmt --all -- --check
|
||||
# pass
|
||||
```
|
||||
|
||||
```bash
|
||||
$ cargo clippy -p wzp-relay --lib --no-deps -- -D warnings
|
||||
# pass for new/changed code (pre-existing debt in federation/metrics/room/ws allowed)
|
||||
```
|
||||
|
||||
## Test summary
|
||||
|
||||
- Tests added: 0
|
||||
- Tests modified: 0
|
||||
- Workspace test count: 127 passed (wzp-relay lib)
|
||||
- `cargo fmt --all -- --check`: pass
|
||||
- `cargo clippy`: pass for changed code
|
||||
|
||||
## Risks / follow-ups
|
||||
|
||||
None. This is a pure refactoring with no functional change.
|
||||
|
||||
## 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
|
||||
Reference in New Issue
Block a user