|
| 1 | +# Lane I — per-key scope on the unrouted data planes |
| 2 | + |
| 3 | +Status: OPEN. Branch `codex/260920-lane-i-key-scope-dataplane` against `dev`, one pull request, |
| 4 | +ordered commits. Base is `origin/dev` at `043aa435ff`. |
| 5 | + |
| 6 | +Scope is one thing: the part of #5049 that #5265 (`447ac22ca6`) could not reach. That change put |
| 7 | +the model and provider scope on the resolved route, at the single capture point every Responses |
| 8 | +destination passes through, and Chat and Messages inherit it by translating into that path. Four |
| 9 | +authenticated endpoints spend provider quota without ever resolving a model through the router, so |
| 10 | +the predicate never saw them. |
| 11 | + |
| 12 | +## What each surface turned out to be |
| 13 | + |
| 14 | +### Images |
| 15 | + |
| 16 | +`handleImages` can settle on four different destinations, and only two of them use the model the |
| 17 | +caller sent. The ChatGPT forward account and a keyed OpenAI provider relay the body verbatim; the |
| 18 | +xAI Imagine bridge always runs `images.bridgeModel` on the configured xAI provider; the Antigravity |
| 19 | +fallback always runs its own CCA image model. Judging the body would therefore have authorized one |
| 20 | +thing and billed another on two of the four branches, which is the failure the landed design names. |
| 21 | + |
| 22 | +Each branch is checked as it is entered — the bridge and the Antigravity fallback before they |
| 23 | +resolve a credential, the two relays before the forward probe lease is consumed or the keyed picker |
| 24 | +commits a rotation. A refused request spends nothing and mutates nothing. |
| 25 | + |
| 26 | +### Audio and voice |
| 27 | + |
| 28 | +Transcription, the dictation socket, external voice call-create and the external sideband join all |
| 29 | +resolve through `resolveAudioUpstream`, which already receives both the admission and the model the |
| 30 | +upstream will run. One check on each of its two return paths covers all four endpoints. The forward |
| 31 | +path releases its probe lease on refusal, mirroring the adjacent unusable-account branch. |
| 32 | + |
| 33 | +The native `/v1/live` and `/v1/realtime/calls` path does not share that resolver, so it needed its |
| 34 | +own: `resolveLiveRelay` now takes the destination it is resolving for. The model is read where the |
| 35 | +client states it — `session.model` in a JSON or multipart call-create, the `model` parameter of a |
| 36 | +standalone socket query — and a join onto an existing call carries the default, because the call it |
| 37 | +attaches to stated its model when it was created. |
| 38 | + |
| 39 | +### Search |
| 40 | + |
| 41 | +The brief expected the non-account-qualified branch to hand the caller's model to the sidecar. It |
| 42 | +does not, and the distinction matters for where the check belongs. There are two unrouted branches, |
| 43 | +not one: |
| 44 | + |
| 45 | +- the forward relay copies the caller's model to whichever ChatGPT account the upstream resolved, |
| 46 | + and that account is billed for it; |
| 47 | +- the sidecar fallback ignores the caller's model entirely and runs the backend and model the |
| 48 | + operator configured, spending that backend's own credential. |
| 49 | + |
| 50 | +Both are destinations a scoped key must not reach, so both are checked — the first against the |
| 51 | +resolved account and the caller's model, the second against the configured backend and the model |
| 52 | +that backend runs. Exa has no provider entry, so its backend name is its destination. The |
| 53 | +account-qualified branch keeps the single check #5265 gave it and is not judged twice. |
| 54 | + |
| 55 | +## Rules that fell out of the review |
| 56 | + |
| 57 | +A request that names no model has no destination a model list can allow: the relay would copy the |
| 58 | +body and let the upstream pick. `UNNAMED_DESTINATION_MODEL` makes that explicit, so a key scoped by |
| 59 | +model is refused rather than sent to a provider default. A key scoped only by provider is |
| 60 | +unaffected, and a key with no scope at all reaches every surface exactly as before. |
| 61 | + |
| 62 | +No new policy system was introduced. `admissionScopeDenial` is a three-line composition of the |
| 63 | +landed `resolveAdmissionModelScope`, `routeAllowedByScope` and `admissionModelDeniedResponse`, |
| 64 | +shaped for handlers that return a `Response` rather than throwing into a route resolver. Every |
| 65 | +refusal is the same 403 naming the caller's own selector, with the resolved destination left to the |
| 66 | +server log. |
| 67 | + |
| 68 | +## Explicitly out of scope |
| 69 | + |
| 70 | +Redis, multi-tenancy, budgets and RPM/TPM ceilings. Nothing here reads or writes a credential, and |
| 71 | +no new field is logged: a refusal carries the selector the caller already knows and no account |
| 72 | +identifier, provider credential or request body. |
| 73 | + |
| 74 | +## Verification |
| 75 | + |
| 76 | +Static review against the `dev` source plus exact-head hosted CI. Per the lane instruction the |
| 77 | +local suite, focused test files, `typecheck`, `build`, `install` and any running `ocx` were NOT |
| 78 | +RUN; the file-size ratchet and the union-exhaustiveness classes were checked by reading the |
| 79 | +baseline and the changed files instead. No touched file carries a baseline cap, and the largest, |
| 80 | +`src/server/index/serve-options.ts`, stays well under the 2000-line threshold. The four new test |
| 81 | +files are registered in both `scripts/test-layout/layout.json` and |
| 82 | +`tests/fixtures/test-layout-expected.json`. |
| 83 | + |
| 84 | +## Remaining scope on #5049 |
| 85 | + |
| 86 | +The issue stays open for the coordinator to judge. This lane closes the four endpoints named in the |
| 87 | +#5265 adversarial review and nothing beyond them. |
| 88 | + |
0 commit comments