-
Notifications
You must be signed in to change notification settings - Fork 611
feat(routing): add validated routing policy profiles #1011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6392449
feat(routing): add validated routing policy profiles (RI-04)
Wibias d478b39
fix(routing): evaluate request evidence in policy profile dry-run (RI…
Wibias 8e1f1c3
fix(routing): reject provider-namespace profile aliases and drop dead…
Wibias aa9212f
refactor(cli): drop redundant output formatting calls in route policy…
Wibias 27511bf
fix(routing): absent request-evidence flags add no dry-run requiremen…
Wibias ea19ab1
fix(routing): harden policy profiles per review round (RI-04)
Wibias dd10c9a
docs(routing): clarify RI-04 dry-run scope and sync stack ledger (RI-04)
Wibias d313d2b
fix(routing): reject the reserved unknown service tier in profile req…
Wibias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { | ||
| CliUsageError, | ||
| printData, | ||
| rejectArgs, | ||
| runCliAction, | ||
| runtimeRequest, | ||
| takeFlag, | ||
| takeIntegerOption, | ||
| type RuntimeApiDeps, | ||
| } from "./runtime-api"; | ||
|
|
||
| const USAGE = `Usage: | ||
| ocx route policy list [--json] | ||
| ocx route policy show <id> [--json] | ||
| ocx route policy dry-run <id> [--model-context <tokens>] [--tools] | ||
| [--image] [--structured-output] [--json]`; | ||
|
|
||
| interface ProfileRow { | ||
| id?: string; | ||
| model?: string; | ||
| revision?: string; | ||
| } | ||
|
|
||
| async function list(argv: string[], deps: RuntimeApiDeps): Promise<void> { | ||
| const args = [...argv]; | ||
| const wantsJson = takeFlag(args, "--json"); | ||
| rejectArgs(args, USAGE); | ||
| const result = await runtimeRequest<{ profiles?: ProfileRow[] }>("/api/routing-profiles", {}, deps); | ||
| const rows = result.profiles ?? []; | ||
| printData( | ||
| result, | ||
| wantsJson, | ||
| rows.length | ||
| ? rows.map(row => `${String(row.id)} ${String(row.model ?? `policy/${row.id}`)} rev:${String(row.revision ?? "-")}`) | ||
| : ["No routing profiles configured."], | ||
| ); | ||
| } | ||
|
|
||
| async function show(argv: string[], deps: RuntimeApiDeps): Promise<void> { | ||
| const args = [...argv]; | ||
| const id = args.shift(); | ||
| const wantsJson = takeFlag(args, "--json"); | ||
| if (!id) throw new CliUsageError("profile id is required", USAGE); | ||
| rejectArgs(args, USAGE); | ||
| const result = await runtimeRequest<{ profiles?: ProfileRow[] }>("/api/routing-profiles", {}, deps); | ||
| const profile = (result.profiles ?? []).find(candidate => candidate.id === id); | ||
| if (!profile) throw new CliUsageError(`unknown routing profile: ${id}`, USAGE); | ||
| printData(profile, wantsJson); | ||
| } | ||
|
|
||
| async function dryRun(argv: string[], deps: RuntimeApiDeps): Promise<void> { | ||
| const args = [...argv]; | ||
| const id = args.shift(); | ||
| const wantsJson = takeFlag(args, "--json"); | ||
| if (!id) throw new CliUsageError("profile id is required", USAGE); | ||
| const modelContext = takeIntegerOption(args, "--model-context", { min: 1 }); | ||
| const tools = takeFlag(args, "--tools"); | ||
| const image = takeFlag(args, "--image"); | ||
| const structuredOutput = takeFlag(args, "--structured-output"); | ||
| rejectArgs(args, USAGE); | ||
| const result = await runtimeRequest( | ||
| "/api/routing-profiles/dry-run", | ||
| { | ||
| method: "POST", | ||
| headers: { "content-type": "application/json" }, | ||
| body: JSON.stringify({ | ||
| profile: id, | ||
| evidence: { | ||
| ...(modelContext !== undefined ? { contextWindow: modelContext } : {}), | ||
| ...(tools ? { toolsRequired: true } : {}), | ||
| ...(image ? { imageInputRequired: true } : {}), | ||
| ...(structuredOutput ? { structuredOutputRequired: true } : {}), | ||
| }, | ||
| }), | ||
| }, | ||
| deps, | ||
| ); | ||
| printData(result, wantsJson); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| export async function handleRoutePolicyCommand(argv: string[], deps: RuntimeApiDeps = {}): Promise<number> { | ||
| return runCliAction(async () => { | ||
| const [sub, ...rest] = argv; | ||
| if (!sub) throw new CliUsageError("route policy requires a subcommand (list, show, dry-run)", USAGE); | ||
| if (sub === "list") await list(rest, deps); | ||
| else if (sub === "show") await show(rest, deps); | ||
| else if (sub === "dry-run") await dryRun(rest, deps); | ||
| else throw new CliUsageError(`unknown route policy command: ${sub}`, USAGE); | ||
| }); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.