Skip to content

Type openrouter_model() as Option, derive native-only from it - #48

Merged
eirikb merged 1 commit into
mainfrom
feature/eirikb/openrouter-model-option
Jul 2, 2026
Merged

eirikb merged 1 commit into
mainfrom
feature/eirikb/openrouter-model-option

Conversation

@eirikb

@eirikb eirikb commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

openrouter_model() returned a fake slug "native-only (no OpenRouter)" for antigravity (which has no OpenRouter route) — a stringly-typed lie the -> &'static str type 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 -m arg / ANTHROPIC_MODEL env → opaque 400, or a via OpenRouter: native-only (no OpenRouter) provenance line.

  • openrouter_model() -> Option<&'static str> (None for antigravity); guaranteed-Some callers use .expect(...), codex_exec_command takes the Option directly (None = native codex, no -m)
  • is_native_only() now derives from openrouter_model().is_none() (and supports_openrouter() from that) — the model is the single source, so the predicates and the .expect() guards structurally can't drift apart

Two 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.

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.
@eirikb
eirikb merged commit eac98f7 into main Jul 2, 2026
1 check passed
@eirikb
eirikb deleted the feature/eirikb/openrouter-model-option branch July 2, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant