feat(classifier): soft confidence band and shadow encoder labeler (both OFF by default) #115

Merged
alee merged 33 commits from feat/classifier-reliability into main 2026-10-17 20:08:28 +00:00
Owner

Classifier reliability lift, both waves.

Wave 1: soft confidence band (OFF by default)

  • New classifier.decision.soft_confidence_min (None = off, byte-for-byte today's behaviour). A local_decision answer with confidence in [soft floor, confidence_min) is used as source classifier_soft instead of being discarded for a stale session_history / fallback label.
  • classifier_soft is not written to the session cache, is non-attributable for outcomes, counts toward the degraded-share warning, and persists classifier_reject = below_confidence_min.
  • Admin: Controls card field, whole-dict replace semantics pinned, 422 when the floor exceeds confidence_min.
  • Motivation: live data shows ~650 of ~730 declines since 10-10 sit at 0.25-0.45, just under confidence_min 0.5.

Wave 2: shadow encoder (OFF by default)

  • New classifier.shadow_encoder (default false; config load fails if true with no encoder block). Runs the local encoder off the response path via a background task for every routed chat decision and records its label into the new classifier_shadow table. Observe only: never read by routing, never touches the session cache or classifier backoff. Single-flight lock released in a finally; failures are swallowed and counted as rows.
  • Admin control (runtime + persisted) and scripts/shadow_report.py (read-only, 6 sections).

Verification

  • Full suite 2737 passed at head (baseline 2414 at the start of the lift).
  • Mutation checks (scratch copies): removing the wiring, forcing the flag guard on or off, inverting the abstain threshold, and leaking the lock each fail specific tests.
  • ASCII-only diff; no whitespace churn outside touched lines.

Deploy notes

  • Both knobs ship OFF. After merge: pull main, restart llm-router.service, then enable from Controls (soft floor near 0.30; shadow_encoder on). Back up config/config.local.yaml first.
  • classifier_shadow is created lazily on first write (CREATE TABLE IF NOT EXISTS) and is also in schema.sql.

Known follow-ups: session_history has no age bound; a tier overlay for turns below the soft floor.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR

Classifier reliability lift, both waves. ## Wave 1: soft confidence band (OFF by default) - New `classifier.decision.soft_confidence_min` (None = off, byte-for-byte today's behaviour). A local_decision answer with confidence in [soft floor, confidence_min) is used as source `classifier_soft` instead of being discarded for a stale session_history / fallback label. - `classifier_soft` is not written to the session cache, is non-attributable for outcomes, counts toward the degraded-share warning, and persists `classifier_reject = below_confidence_min`. - Admin: Controls card field, whole-dict replace semantics pinned, 422 when the floor exceeds confidence_min. - Motivation: live data shows ~650 of ~730 declines since 10-10 sit at 0.25-0.45, just under confidence_min 0.5. ## Wave 2: shadow encoder (OFF by default) - New `classifier.shadow_encoder` (default false; config load fails if true with no encoder block). Runs the local encoder off the response path via a background task for every routed chat decision and records its label into the new `classifier_shadow` table. Observe only: never read by routing, never touches the session cache or classifier backoff. Single-flight lock released in a finally; failures are swallowed and counted as rows. - Admin control (runtime + persisted) and `scripts/shadow_report.py` (read-only, 6 sections). ## Verification - Full suite 2737 passed at head (baseline 2414 at the start of the lift). - Mutation checks (scratch copies): removing the wiring, forcing the flag guard on or off, inverting the abstain threshold, and leaking the lock each fail specific tests. - ASCII-only diff; no whitespace churn outside touched lines. ## Deploy notes - Both knobs ship OFF. After merge: pull main, restart llm-router.service, then enable from Controls (soft floor near 0.30; shadow_encoder on). Back up config/config.local.yaml first. - `classifier_shadow` is created lazily on first write (`CREATE TABLE IF NOT EXISTS`) and is also in schema.sql. Known follow-ups: session_history has no age bound; a tier overlay for turns below the soft floor. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR
alee added 33 commits 2026-10-17 20:08:01 +00:00
Pin current behavior of _classify_via_local_decision for accepted turn,
below-confidence turn, tier call failing, and tier_enabled=False.
- _outcome_is_attributable docstring: add classifier_soft to non-attributable list
- Session cache write gate: comment that classifier_soft is deliberately excluded
- metrics.py degraded-share SQL: add classifier_soft alongside classifier_cloud
- DEGRADED_CLASSIFICATION_SOURCES: comment explaining classifier_cloud intentional absence
- test_outcome_attribution.py: add classifier_soft to degraded parametrize
- test_route_decisions.py: pin test that _session_history_lookup filters out classifier_soft
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtPLeRkmHJk4VeiTEUfhVR
alee added 10 commits 2026-10-17 20:08:02 +00:00
alee merged commit e91da54999 into main 2026-10-17 20:08:28 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: alee/6krrt#115