Skip to content

wire(switchboard): demote on p95 tail latency; drop plan_routes + p50#21

Merged
ProtocolWarden merged 1 commit into
mainfrom
wire/switchboard-p95-demote-and-cleanup
Jun 18, 2026
Merged

wire(switchboard): demote on p95 tail latency; drop plan_routes + p50#21
ProtocolWarden merged 1 commit into
mainfrom
wire/switchboard-p95-demote-and-cleanup

Conversation

@ProtocolWarden

Copy link
Copy Markdown
Owner

Coupled lane/routing-subsystem change from the cross-repo incomplete-integration remediation (Phase 2 WIRE + Phase 3 DELETE in one PR — they touch the same tests).

WIRE — p95 into the demote heuristic

AdjustmentEngine._evaluate gated the latency-demote on mean latency, while ProfileSignals.p95_latency_ms was computed and never read. Now it gates on p95 (tail): a backend whose typical request is fast but whose slow tail is consistently bad still degrades UX, and the mean hides that. Mean is reported alongside in the demote reason for operator context (so it stays used). New test: a low-mean / high-p95 tail now demotes (it wouldn't have under the mean gate).

DELETE — LaneSelector.plan_routes

Redundant wrapper; production constructs DecisionPlanner.plan directly (app.py:49, api/routes_routing.py:62). The RoutingPlanDemote tests used it as the entry point — rewired to DecisionPlanner.plan; the dedicated delegation tests are removed; dropped the now-unused RoutingPlan import.

DELETE — ProfileSignals.p50_latency_ms

Computed but read nowhere (p95 is the signal now). Removed it + its tests + the now-unused median import.

Verified: 345 tests green; ruff check src test + ty + check_docs.sh clean; working-detector audit B2-env-only; doctor OK (no stale exclusions).

🤖 Generated with Claude Code

Coupled lane/routing-subsystem change from the incomplete-integration
remediation:

- WIRE p95: AdjustmentEngine._evaluate gated the latency-demote on the MEAN
  latency, but ProfileSignals.p95_latency_ms was computed and never read. Gate
  on p95 instead — a backend whose typical request is fast but whose slow tail
  is consistently bad still degrades UX, and the mean hides it. Mean is reported
  alongside for operator context (stays used). Adds a low-mean/high-p95 test.
- DELETE LaneSelector.plan_routes: redundant wrapper; production constructs
  DecisionPlanner.plan directly (app.py:49, api/routes_routing.py:62). Rewire
  the RoutingPlanDemote tests to DecisionPlanner.plan; delete the dedicated
  delegation tests; drop the now-unused RoutingPlan import.
- DELETE ProfileSignals.p50_latency_ms: computed but read nowhere; remove it +
  its tests + the now-unused `median` import.

345 tests green; ruff(src+test) + ty + docs + audit(B2 only) + doctor clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ProtocolWarden ProtocolWarden merged commit 2ebc50b into main Jun 18, 2026
5 checks passed
@ProtocolWarden ProtocolWarden deleted the wire/switchboard-p95-demote-and-cleanup branch June 18, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant