70 lines
2.4 KiB
Markdown
70 lines
2.4 KiB
Markdown
# 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:** 517d0eb
|
|
**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
|