Repository navigation
Fix nested model selectors in Pi exports - #8287
Conversation
Co-authored-by: Juan Fernando Huenchun Barra <jhuenchunbarra@gmail.com>
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
✅ Deterministic PR hygiene checks passed. |
Pi now receives a raw nested selector only when the serving proxy's own configuration and inventory prove it reaches the encoded key's model and account, Fast row included, with no other row claiming it. Cold, ambiguous, colliding and wrong-model routes keep the encoded key. ocx export --client pi takes its document from /api/client-config, and a managed Pi write refuses when a captured selector stopped proving.
Maintainer judgment: hold (not merging)The rework at
Fixing either one means choosing who owns Pi's catalog, and each choice changes something users see:
The branch is left as a draft at |
…ws in Codex Direct Pi may carry raw nested selectors that only the serving proxy can prove (#8172), but ocx sync rebuilt the Pi file in the CLI process from the CLI's saved configuration and router cache, and the write guard re-proved against the same snapshot. ocx sync now leaves Pi out of its local refresh and asks the running proxy to refresh an owned Pi file through POST /api/client-integrations/pi/sync, which builds it from that process's own configuration, router and roster; a refusal or an older proxy is reported as a Pi outcome with no local fallback. The Pi export moved onto the serving proxy's roster, which kept native OpenAI rows in Codex Direct mode; Direct forwards the caller's own bearer and Pi sends a placeholder key, so those rows only answered 401. The Pi builder now drops them in Direct mode, as the CLI-built export did.
Maintainer judgment: mergeHead reviewed: Value. Fixes #8172. A routed model whose upstream ID contains a slash was exported to Pi only under its encoded key, which routes only while the router's inventory can decode it. Pi now gets the raw Owner rule and decision applied (option a). The serving proxy is authoritative, so every Pi document is now built inside it:
User-visible change.
omo, prime, aside, gentle-shell, Hermes and Command Code exports are unchanged. Docs: No regression for existing users.
Windows. No platform-specific code changed. Evidence.
NOT RUN: full |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d76a420fb
ℹ️ 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".
| const omitNative = options.omitNativeInCodexDirect === true | ||
| && providerCodexAccountMode("openai", ctx.config?.providers?.openai) === "direct"; | ||
| for (const model of normalizeExportModels(roster)) { | ||
| if (omitNative && model.native === true) continue; |
There was a problem hiding this comment.
Retain account-qualified native rows in Direct mode
When a Direct-mode configuration exposes account-qualified native models, this filter removes working models from dashboard exports and managed Pi refreshes. listManagementModelRows also marks account-bound rows as native: true, but the account-namespace branch in src/router.ts explicitly sets codexAccountMode: "pool" and pins the stored account even when the provider globally uses Direct mode. Those rows therefore do not depend on Pi supplying an OpenAI credential. Restrict the omission to rows whose resolved route actually uses Direct mode, preserving account-qualified rows.
Useful? React with 👍 / 👎.
Summary
Pi exports routed models under the proxy's encoded key, so OpenRouter's nested
openrouter/freeis exported asopenrouter/openrouter-free. That key routes only while the router's inventory can decode it; with a cold inventory the proxy forwardsopenrouter-freeand the upstream rejects it (#8172).Following the owner decision on #8172 (the serving proxy is authoritative; ambiguous, colliding, wrong-model and cold-inventory routes are refused), Pi now gets the raw selector only where the serving proxy proves it:
src/clients/config-export/nested-selectors.tsruns insideloadExportModelsagainst the admitted configuration and router inventory of that load. The raw selector, and its--fastform for a Fast row, must reach the encoded key's provider, model and account, and no other row of the full roster may claim it. The proof is the alias proof, factored out ofalias-selectors.tsintoproveExportSelectoranduniqueExportCandidates.acme/org/modelnext toorg/model), a policy or combo result, or a collision keeps the encoded key, which is today's output.ocx export --client pifetches its document from/api/client-config, the route the dashboard download already uses, so the CLI's saved configuration never proves a selector.model-name-guard.ts) and refuses withconflictif one changed.structure/clients/export-model-names.mddescribe the rule.Carries the approach from #8171; the first commit includes the original author's
Co-authored-bytrailer.Closes #8172
Verification
All runs used Bun 1.4.4 with
env -iand temporaryHOME,OPENCODEX_HOME,CODEX_HOMEandCLAUDE_CONFIG_DIR.tests/cli/cli-export-command.test.ts"the serving proxy proves the raw selector…" (serving config knowsorg/free, saved config does not) fails with either the CLI routing change or theloadExportModelsattachment reverted, and passes with both. The guard case intests/clients/client-export-model-names.test.tsfails withmodel-name-guard.tsreverted.tests/config/client-config-export.test.ts: proven with Fast, cold inventory, self-namespaced collision, roster collision, explicit alias and a stale candidate on reload.client-config-export100/0,cli-export-command33/0,client-export-model-names12/0,management-client-config-route43/0,api-catalog-route9/0,loopback-listener-integration38/0.tests/clientsplus the export and management route files in one process: 3029 pass, 9 fail. All nine pass when their files run alone (cross-file state in a single process).bun run typecheck,bun run structure:check,bun run privacy:scanandgit diff --checkpass.bun run test, the docs-site build, and a live Pi client against OpenRouter.--no-verify; the repository has no pre-push hook.Checklist