Skip to content

fix(models): bound alias collision construction and reuse listing views - #8812

Merged
lidge-jun merged 5 commits into
lidge-jun:devfrom
luvs01:fix/model-alias-listing-work
Nov 18, 2026
Merged

lidge-jun merged 5 commits into
lidge-jun:devfrom
luvs01:fix/model-alias-listing-work

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

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.

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

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

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

  • 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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed 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.

Share

Recent review info

Run configuration

Commits

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.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@luvs01
luvs01 marked this pull request as ready for review November 18, 2026 00:22
@lidge-jun

Copy link
Copy Markdown
Owner

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.

@lidge-jun
lidge-jun merged commit b7519e8 into lidge-jun:dev Nov 18, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants