Skip to content

feat(control-plane): expose route decision explanations - #1016

Draft
Wibias wants to merge 10 commits into
lidge-jun:devfrom
Wibias:feat/ri-09-route-explainability-api
Draft

feat(control-plane): expose route decision explanations#1016
Wibias wants to merge 10 commits into
lidge-jun:devfrom
Wibias:feat/ri-09-route-explainability-api

Conversation

@Wibias

@Wibias Wibias commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

RI-09 of the Router Intelligence / Routing Control Plane programme. Exposes
why-this-route explanations from the durable trace + attempt history:

  • GET /api/request-history/:requestId/route-decision - requested model,
    route kind, profile + revision, requirements, candidates with exclusions
    and score components, selected candidate + tie-break, actual attempt
    sequence, and final outcome.
  • GET /api/routing-profiles (RI-04) and POST /api/routing-profiles/dry-run
    remain the profile inspection surfaces; the dry-run endpoint now also
    assembles canonical capability/health/quota/cost evidence when no candidate
    evidence is supplied ("evaluate" mode).
  • CLI: ocx logs explain <request-id> and ocx route policy evaluate <profile> (an alias of dry-run with auto-evidence).

The API returns stable structured codes + display-ready summaries - never
localized prose as the only contract.

Scope

  • src/server/management/request-history-routes.ts - the
    /route-decision subroute (checked before the generic :requestId
    branch): merges the persisted RI-01 trace, the execution attempts[], and
    a summary/outcome block. Pre-trace rows answer with routeDecision: null
    and their attempts/outcome (honest, not fabricated).
  • src/server/management/routing-profile-routes.ts - dry-run auto-evidence:
    candidates omitted -> canonical capability (catalog/registry/native),
    health (index), quota (caches), cost (price model + profile limit)
    evidence per profile candidate.
  • src/cli/observe.ts - ocx logs explain <id> [--json].
  • src/cli/route-policy.ts - ocx route policy evaluate <id> [--json].
  • tests/route-explainability.test.ts - 4 tests.

Privacy / security

  • The explanation surfaces only data already bounded by the trace and the
    usage entry: no prompts, credentials, or raw responses.
  • bun run privacy:scan passes.

Compatibility

  • Additive endpoints and CLI subcommands; /api/logs and /api/request-history
    unchanged.

Dependency

Non-goals

  • No GUI (RI-10).
  • No localized prose as the API contract (stable codes + summaries only).

Local verification (exact)

  • bun x tsc --noEmit -> PASSED (0 errors)
  • bun run test tests/route-explainability.test.ts -> 4/4 pass
  • Focused regression suites -> 70/70 pass across 8 files
  • bun run privacy:scan -> passed

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fa7ba5b4-2eb7-437c-9f29-b1d86a70c50e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant