Type openrouter_model() as Option, derive native-only from it - #48
Merged
Merged
Conversation
openrouter_model() returned a fake slug ("native-only (no OpenRouter)") for
antigravity, which has no OpenRouter route - a stringly-typed lie the return
type couldn't express, kept honest only by a guard convention at every call
site. Return Option<&'static str> (None for antigravity) so the compiler
forces callers to rule out native-only agents; the guaranteed-Some sites use
.expect() with the invariant that lets them, and codex_exec_command takes the
Option directly (None = no -m, native codex).
Make openrouter_model() the single source: is_native_only() now derives from
it (no model slug => native-only) and supports_openrouter() from that, so the
predicates and the .expect() guards can no longer drift apart.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
openrouter_model()returned a fake slug"native-only (no OpenRouter)"for antigravity (which has no OpenRouter route) — a stringly-typed lie the-> &'static strtype couldn't express, kept safe only by a guard convention repeated at every call site. A future unguarded call would have leaked that string into a-marg /ANTHROPIC_MODELenv → opaque 400, or avia OpenRouter: native-only (no OpenRouter)provenance line.openrouter_model() -> Option<&'static str>(None for antigravity); guaranteed-Some callers use.expect(...),codex_exec_commandtakes theOptiondirectly (None = native codex, no-m)is_native_only()now derives fromopenrouter_model().is_none()(andsupports_openrouter()from that) — the model is the single source, so the predicates and the.expect()guards structurally can't drift apartTwo review passes (code-review flagged the unenforced invariant → fixed by the derivation; postmortemthis proved every
.expect()unreachable-with-None via a strict DAG). Build + clippy clean; antigravity stays native-only, grok stays OpenRouter-capable, provenance verified live.