fix(model-capabilities): harden canonical alias guardrails#2834
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@code-yeongyu this is the follow-up hardening pass for the models.dev capability work. The key change is not more aliasing, but tighter maintenance guardrails:
This should make future alias/snapshot drift fail loudly in CI instead of quietly accumulating maintenance debt. |
There was a problem hiding this comment.
1 issue found across 8 files
Confidence score: 2/5
- High-confidence, high-severity issue in
src/shared/model-capability-aliases.ts: removing thegpt-5.3-codex-sparkalias is likely to break model resolution for Opencode compatibility. - Because the alias is missing from the bundled Opencode snapshot, this change introduces a concrete regression risk rather than a minor cleanup concern.
- Pay close attention to
src/shared/model-capability-aliases.ts- ensuregpt-5.3-codex-sparkremains mapped so model lookup does not fail.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/shared/model-capability-aliases.ts">
<violation number="1" location="src/shared/model-capability-aliases.ts:22">
P1: Custom agent: **Opencode Compatibility**
Do not remove the `gpt-5.3-codex-spark` alias. It does not exist in the bundled Opencode snapshot, so removing this alias will cause model resolution to fail.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
check my replies and recheck everything |
@RaviTharuma I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 8 files
Confidence score: 3/5
- There is concrete regression risk in
src/shared/model-capability-aliases.ts: the canonical ID still points togemini-3.1-pro-preview, while upstream Opencode expectsgemini-3.1-pro, which can break compatibility and model resolution behavior. - A prototype-backed dictionary lookup in
src/shared/model-capability-aliases.tsmay match inherited keys (likeconstructor), potentially returning an undefinedcanonicalModelIDfor invalid aliases. - Given the high-confidence compatibility drift (8/10) plus a user-impacting alias-resolution edge case (6/10), this is mergeable only with moderate caution until these mappings/lookups are corrected.
- Pay close attention to
src/shared/model-capability-aliases.ts- canonical model mapping drift and unsafe direct dictionary lookup can cause incorrect or undefined alias resolution.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/shared/model-capability-aliases.ts">
<violation number="1" location="src/shared/model-capability-aliases.ts:24">
P1: Custom agent: **Opencode Compatibility**
Update the canonical model ID to `gemini-3.1-pro`. The upstream Opencode repository no longer includes a `gemini-3.1-pro-preview` model, making this a drift from the canonical definitions.</violation>
<violation number="2" location="src/shared/model-capability-aliases.ts:30">
P1: Custom agent: **Opencode Compatibility**
Update the canonical model ID to `gemini-3.1-pro` to match the current upstream Opencode definitions.</violation>
<violation number="3" location="src/shared/model-capability-aliases.ts:67">
P2: Direct lookup on a prototype-backed dictionary can match inherited keys (e.g., `constructor`), causing invalid alias resolution and returning `canonicalModelID` as `undefined`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
5cf548e to
5043cc2
Compare
|
@code-yeongyu @cubic-dev-ai I rebased this PR onto current Changes in the new head:
All current cubic threads on this PR are replied to and resolved. |
|
@code-yeongyu I tracked the remaining red Re-verified locally on the new head:
This should let the PR rerun cleanly on GitHub without touching product behavior. |
|
@code-yeongyu current head
This should be ready for normal maintainer merge whenever you are happy with it. |
|
Architecture review: Ravi's concern (#2835) is valid. The explicit alias approach in this PR loses generality — a future Claude variant won't auto-match the pattern anymore. However: This is the right trade-off for this specific layer. Reason:
Recommendation:
This PR is clean. The discussion is the right follow-up. |
@code-yeongyu this is exactly wha i am not sure about. or should we make it simple and more static and accept the maintenance debt? i am not sure what the right way is, that's why i also opened a discussion. because it's a philosophical decision that will also affect other refactors and additions. this is your decision 👍 |
Move from hardcoded exact aliases to pattern-based canonicalization:
- Populate PATTERN_ALIAS_RULES with regex patterns for:
- Claude thinking variants (claude-opus-4-6-thinking → claude-opus-4-6)
- Gemini tier suffixes (gemini-3.1-pro-{high,low} → gemini-3.1-pro)
- Add stripProviderPrefixForAliasLookup() for provider-prefixed models
(anthropic/claude-sonnet-4-6 → claude-sonnet-4-6 for capability lookup)
- Preserve requestedModelID (with prefix) for API transport
- Reduce EXACT_ALIAS_RULES to exceptional cases only
(gemini-3-pro-{high,low} → gemini-3-pro-preview)
- Comprehensive test coverage for patterns, prefix stripping, negatives
Addresses Discussion #2835 (pattern matching architecture)
Related to PR #2834 (alias guardrails)
41 targeted tests pass, 4467 full suite tests pass, tsc clean.
Summary
-thinkingpattern alias with an explicit legacy alias forclaude-opus-4-6-thinkinggpt-5.3-codex-sparkremap now that it exists in the bundled snapshotWhy
The current models.dev integration is much better than the old hardcoded family logic, but the remaining risk is silent alias drift over time. This change makes that drift fail loudly in CI instead of quietly turning into long-term maintenance debt.
Verification
Summary by cubic
Hardened model capability alias guardrails to keep built‑in requirements canonical and catch alias drift or collisions with the bundled
models.devsnapshot. Aligned Gemini tier aliases togemini-3.1-pro, replaced the Claude “thinking” pattern with a single explicit legacy alias, and removed a stale GPT remap.New Features
Refactors
-thinkingpattern with an explicit legacy aliasclaude-opus-4-6-thinking→claude-opus-4-6, and aligned Gemini tier aliases togemini-3.1-pro.gpt-5.3-codex-sparkalias now covered by the bundled snapshot.Written for commit ce877ec. Summary will update on new commits.