feat(control-plane): expose route decision explanations - #1016
Conversation
|
Warning Review limit reached
Next review available in: 24 seconds Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe PR adds a route-decision history endpoint and CLI explanation command. It extends routing-profile dry runs with cost and capability evidence. It updates policy CLI dispatch and adds explainability tests and acceptance records. ChangesRoute intelligence
Sequence Diagram(s)sequenceDiagram
participant Operator
participant ObserveCLI as observe.ts
participant RequestHistoryAPI as request-history-routes.ts
participant PersistedHistory as Persisted request history
Operator->>ObserveCLI: logs explain request ID
ObserveCLI->>RequestHistoryAPI: Request route-decision history
RequestHistoryAPI->>PersistedHistory: Decode ID and load entry
PersistedHistory-->>RequestHistoryAPI: Trace and attempt data
RequestHistoryAPI-->>ObserveCLI: JSON or formatted route explanation
ObserveCLI-->>Operator: Display route decision
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✅ PR quality gates passed This pull request now targets The title was left unchanged. The pull request has been marked ready for review again. |
[GD] Verdict: changes-requestedTLDR
Full verdictSemantic propagation
UsefulnessDelivers the claimed RI-09 value: a stable-code explainability API ( Bugs / correctness
Security
Spec / standards
Reviews
Base / CI
Simplification (for the PR owner — not applied, foreign PR)
Neither is a correctness issue; both are low-risk cleanups. Gate
Bottom lineThis is genuinely useful, well-tested, privacy-conscious work. Before merge-ready: (1) fix |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e69a4a680
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6e69a4a to
d887c12
Compare
|
✅ Deterministic PR hygiene checks passed. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devlog/_plan/260804_router_intelligence/001_pr_stack_status.md`:
- Around line 263-276: Finalize the RI-09 acceptance record in the findings and
verification section: replace the Base SHA with
410db97e4cd9e9b4f8aba60682d20946e211d6dd, set the Final commit to
d887c120282c8d381f92cd11c1eebe2373a27281, record PR `#1016`, rerun and record the
checks against this head, and update the route-explainability test result from
4/4 to 7/7; do not add a conflict-resolution rebase.
In `@src/cli/observe.ts`:
- Around line 85-94: Add focused regression coverage in
tests/route-explainability.test.ts:90-202 for the CLI behavior. Exercise
src/cli/observe.ts:85-94 through handleObserveCommand to verify request-ID URL
encoding, --json output, and invalid-argument rejection; exercise
src/cli/route-policy.ts:83-90 through handleRoutePolicyCommand to verify
evaluate sends the dry-run request and rejects option-like profile IDs. Keep the
tests near the existing route explainability tests.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: be2b9d61-429b-417e-8d36-1184df61887b
📒 Files selected for processing (7)
devlog/_plan/260804_router_intelligence/001_pr_stack_status.mdsrc/cli/observe.tssrc/cli/route-policy.tssrc/routing/capability.tssrc/server/management/request-history-routes.tssrc/server/management/routing-profile-routes.tstests/route-explainability.test.ts
d887c12 to
ae2c329
Compare
[GD] Verdict: approve-commentTLDR
Full verdictSemantic propagation
UsefulnessRI-09 closes the control-plane explainability gap: operators can inspect why a request routed where it did and evaluate a profile with assembled evidence without inventing a UI. Value is concrete and scoped. Bugs / correctness
Security
Spec / Standards
Reviews
Base / CI
Simplify
Gate
Bottom lineApprove-comment on |
|
[GD] Merge ready
|
[GD] MergeMerging RI-09 route-decision explainability on Why it helps: operators can inspect why a request routed where it did via Ship it. |
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) andPOST /api/routing-profiles/dry-runremain 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).
ocx logs explain <request-id>andocx 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-decisionsubroute (checked before the generic:requestIdbranch): merges the persisted RI-01 trace, the execution
attempts[], anda summary/outcome block. Pre-trace rows answer with
routeDecision: nulland their attempts/outcome (honest, not fabricated).
src/server/management/routing-profile-routes.ts- dry-run auto-evidence:candidatesomitted -> 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
usage entry: no prompts, credentials, or raw responses.
bun run privacy:scanpasses.Compatibility
/api/logsand/api/request-historyunchanged.
Dependency
feat(routing): add cost-aware policy scoring and limits #1015). Branch base:
feat/ri-08-cost-aware-routinghead66ae44aca.Non-goals
Local verification (exact)
bun x tsc --noEmit-> PASSED (0 errors)bun run test tests/route-explainability.test.ts-> 4/4 passbun run privacy:scan-> passedSummary by CodeRabbit
New Features
logs explainto inspect routing decisions by request ID, with formatted and JSON output.route-policy evaluatesupport and cost details to routing profile previews.Bug Fixes
Tests