You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(models): bound alias collision construction and reuse listing views - #8812
A configured provider with an enabled alias template could supply many model IDs that collapse to the same alias. Building those collision buckets repeatedly copied their prefixes, and the OpenAI model-list projection recalculated the entire provider alias view for every visible row. Together these amplified a bounded discovered inventory into excessive allocation and CPU work.
Append candidates to invocation-owned collision buckets for both built-in and template aliases, preserving ordering and collision decisions.
Import the alias helper once and reuse one request-local view per provider in the direct OpenAI row projection, including empty collision results.
Build each view from the existing full known-model roster so hidden IDs still reserve names; recompute on later requests so discovery/configuration changes stay visible.
Preserve manual/built-in/template precedence, reserved names, preferred alias IDs, Fast rows, combo handling and response fields. Update the owning runtime contract.
Verification
Current head 9ce8f43a74cfbb2fbaa1981c1ea3bdfec90fb6f4 integrates dev at 04304da28a2a8c0349f01ad161a58c16dbe8d982 with a normal two-parent merge. The published tree matches the locally validated candidate. Independent integration review found no blocking issue and confirmed preservation of the existing fix and current dev contracts.
The focused regressions cover bounded collision buckets, one request-local alias view per provider, empty-result reuse, visibility of every colliding model, cross-provider manual aliases, and recomputation after discovery changes. Controls preserve precedence, reserved names, collision order independence, preferred IDs, Fast siblings, and Codex/Anthropic listing shapes.
Earlier prepatch evidence: a 128-ID collision bucket recopied 8,128 prior elements, and a local 32-model discovery-to-listing request computed the provider view 33 times. The corrected path is covered by bounded in-memory and loopback fixtures.
bun run typecheck: 2,566 files, no errors.
bun run structure:check, bun run privacy:scan, and git diff --check: passed. The command above includes the file-size ratchet (9 tests / 85 assertions).
Local validation uses the repository's documented resource exception: concurrent validation across large worktrees was scoped to the affected regressions and required static/docs gates. A full local repository suite was not run; broader coverage is provided by the configured pull-request CI. Skipped platform jobs do not establish Windows/macOS or installed/live acceptance.
For the current head, main pull-request CI, Catalog async contracts, and PR gates completed successfully. These are the configured pull-request checks; skipped platform jobs do not establish additional platform acceptance.
CodeRabbit completed its review of this exact head with no actionable comments; its current-head check passed. There are no unresolved review threads. This PR is Ready for review. Explicit maintainer security approval remains required before merge.
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed.
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
The security checkbox records implementation review. Explicit maintainer security review remains required before merge.
Summary by CodeRabbit
Improvements
Model listings now reuse alias calculations for each provider during a request, reducing repeated processing while preserving the existing model results and collision behavior.
Documentation
Clarified how alias collisions and model listings behave.
Reviewing files that changed from the base of the PR and between 46f97c8 and 4eb5d3b.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Alias collision buckets now append entries instead of rebuilding arrays. The /v1/models route computes effective aliases synchronously and caches them per provider for each request. Tests cover collision handling and request-local alias reuse.
Changes: Alias Generation and Model Listing
Layer / File(s)
Summary
Append alias collision candidates src/providers/default-aliases.ts, tests/providers/provider-alias-template.test.ts
Built-in alias claims and template candidates append to existing arrays. The added test checks collision handling across 128 model IDs and counts replaced array elements.
Reuse provider aliases during model listing src/server/index/serve-options.ts, tests/server/prefer-model-alias-ids.test.ts, structure/runtime.md
The /v1/models route computes effective aliases synchronously and reuses each provider’s alias map for the request. The integration test checks alias results, collision behavior, cache clearing, and discovery calls. The runtime documentation describes collision handling and request-local alias reuse.
lidge-jun/opencodex#8512: Introduced the alias-template feature and its collision and reservation logic, which this change extends.
Merge Risk: Minimal · previous review 9ce8f
The change reduces allocations in alias collision handling and in /v1/models listing without changing alias results. No actionable merge-blocking issue was found; remaining confidence rests on full CI completing.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(models): bound alias collision construction and reuse listing views" matches the main change. The PR bounds alias collision bucket construction by appending candidates instead of rebuil…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title "fix(models): bound alias collision construction and reuse listing views" matches the main change. The PR bounds alias collision bucket construction by appending candidates instead of rebuilding arrays, and it reuses one request-local alias view per provider in the OpenAI /v1/models projection. The title names both parts of the change in one concise sentence. It uses the conventional commit prefix. The title does not mention the test-only changes or the runtime documentation update, which is expected for a title.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Reviewing files that changed from the base of the PR and between 04304da and 9ce8f43.
Files selected for processing: 5
src/providers/default-aliases.ts
src/server/index/serve-options.ts
structure/runtime.md
tests/providers/provider-alias-template.test.ts
tests/server/prefer-model-alias-ids.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Maintainer integration (lidge-jun, dev only) at head 4eb5d3bb75: branch merged with dev twice during review; required checks green on this head (gates, test changed). Current dev is one commit ahead (8ff612d, Anthropic pool identity, 7 files disjoint from this PR and from the file-size ratchet, test-layout and exhaustive-union inputs); GitHub reports no BEHIND state. Fresh independent review (gpt-6.2-sol) found no code findings: bun test tests/providers/provider-alias-template.test.ts tests/server/prefer-model-alias-ids.test.ts 30 pass / 0 fail; typecheck, structure:check, file-size ratchet and test-layout guards pass. No CodeRabbit/Codex findings. Not a security-boundary change (request-local alias view reuse in the model listing). scripts/ci/assert-mergeable-review.sh --maintainer-integration 8812 OK.
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
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.
Summary
A configured provider with an enabled alias template could supply many model IDs that collapse to the same alias. Building those collision buckets repeatedly copied their prefixes, and the OpenAI model-list projection recalculated the entire provider alias view for every visible row. Together these amplified a bounded discovered inventory into excessive allocation and CPU work.
Verification
Current head
9ce8f43a74cfbb2fbaa1981c1ea3bdfec90fb6f4integratesdevat04304da28a2a8c0349f01ad161a58c16dbe8d982with a normal two-parent merge. The published tree matches the locally validated candidate. Independent integration review found no blocking issue and confirmed preservation of the existing fix and current dev contracts.bun scripts/test.ts tests/providers/provider-alias-template.test.ts tests/server/prefer-model-alias-ids.test.ts tests/ci-workflows/file-size-ratchet.test.ts --timeout 30000: 39 passed, 0 failed, 187 assertions.bun run typecheck: 2,566 files, no errors.bun run structure:check,bun run privacy:scan, andgit diff --check: passed. The command above includes the file-size ratchet (9 tests / 85 assertions).Local validation uses the repository's documented resource exception: concurrent validation across large worktrees was scoped to the affected regressions and required static/docs gates. A full local repository suite was not run; broader coverage is provided by the configured pull-request CI. Skipped platform jobs do not establish Windows/macOS or installed/live acceptance.
For the current head, main pull-request CI, Catalog async contracts, and PR gates completed successfully. These are the configured pull-request checks; skipped platform jobs do not establish additional platform acceptance.
CodeRabbit completed its review of this exact head with no actionable comments; its current-head check passed. There are no unresolved review threads. This PR is Ready for review. Explicit maintainer security approval remains required before merge.
Checklist
The security checkbox records implementation review. Explicit maintainer security review remains required before merge.
Summary by CodeRabbit