Skip to content

feat(classifiers): implement ClassifierMetrics with p50/p95 latency ring buffer#2291

Merged
bug-ops merged 1 commit intomainfrom
classifier-metrics-p50-p95
Mar 27, 2026
Merged

feat(classifiers): implement ClassifierMetrics with p50/p95 latency ring buffer#2291
bug-ops merged 1 commit intomainfrom
classifier-metrics-p50-p95

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 27, 2026

Summary

  • Add ClassifierMetrics struct in zeph-llm with per-ClassifierTask VecDeque<Duration> ring buffer (capacity 100), p50/p95 computed on demand via nearest-rank formula
  • Wire Arc<ClassifierMetrics> through AgentBuilder into ContentSanitizer (injection, PII) and LlmClassifier (feedback); metrics pushed eagerly to MetricsSnapshot at 3 sites
  • TUI resources panel shows compact classifier section (calls / p50ms / p95ms per task) when at least one task has been invoked
  • Document FeedbackVerdict/JudgeVerdict coupling with // NOTE: comments; add #[cfg(test)] serde round-trip test that breaks CI if fields diverge

Closes #2249
Closes #2250

Test plan

  • 9 unit tests in crates/zeph-llm/src/classifier/metrics.rs: ring buffer eviction, p50/p95 correctness, empty buffer, single sample, identical values
  • Serde round-trip test in feedback_detector.rs for JudgeVerdictFeedbackVerdict field sync
  • cargo nextest run --workspace --features full --lib --bins — 6837 passed, 22 skipped
  • cargo +nightly fmt --check — PASS
  • cargo clippy --workspace --features full -- -D warnings — PASS

…ing buffer (#2249, #2250)

Add ClassifierMetrics struct in zeph-llm with per-ClassifierTask ring buffer
(default capacity 100), p50/p95 computed on demand via nearest-rank algorithm.
Metrics are emitted as tracing::debug! with structured fields after each
classifier invocation and surfaced in the TUI resources panel.

Wire Arc<ClassifierMetrics> through AgentBuilder into ContentSanitizer (injection,
PII tasks) and LlmClassifier (feedback task). MetricsSnapshot gains a
classifier: ClassifierMetricsSnapshot field pushed eagerly via push_classifier_metrics()
at three sites in the agent loop. TUI resources panel renders a compact classifier
section (calls, p50ms, p95ms per task) when at least one task has been invoked.

Document FeedbackVerdict/JudgeVerdict coupling: add NOTE comments in both structs
explaining the circular-dep mirror relationship (#2250). Add a cfg(test) serde
round-trip test that deserializes JudgeVerdict JSON as FeedbackVerdict, breaking
CI if fields diverge.

Closes #2249
Closes #2250
@github-actions github-actions bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate enhancement New feature or request size/L Large PR (201-500 lines) labels Mar 27, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 27, 2026 22:43
@bug-ops bug-ops merged commit b816b90 into main Mar 27, 2026
25 checks passed
@bug-ops bug-ops deleted the classifier-metrics-p50-p95 branch March 27, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

1 participant