test: property-check model-map resolution invariants
Summary
- Adds a fast-check property suite for the model resolution pipeline in
lib/request/helpers/model-map.ts— the parser every request's model routing flows through (resolveNormalizedModel→getModelProfile). The #574 suite property-checked the unsupported-model fallback chain; this one pins the resolution layer beneath it.
What Changed
New test/property/model-map.property.test.ts (6 properties). Inputs mix known MODEL_MAP aliases, synthesized GPT-5 spellings (minors 0–9, mini/nano/pro/codex variants, -/./space separators, version suffixes), provider prefixes (openai/, models/, nested), random per-character casing, and raw garbage strings:
- Closed world — every resolution lands on a
MODEL_PROFILESkey, provinggetModelProfile'sDEFAULT_MODELfallback is pure defence (no reachable input needs it; aMODEL_MAPvalue or catalog entry without a profile would be found instantly). - Idempotence — normalized outputs are fixpoints of the resolver.
- Spelling invariance — provider prefixes and arbitrary casing never change the resolution, for any input including garbage.
- Codex dominance — unmapped ids mentioning
codexresolve toCURRENT_CODEX_MODEL, never a general model. - The inverse — unmapped general GPT-5 spellings stay codex-free and in the
gpt-5family: a general-purpose request can never silently route to a codex-tuned model. - Alias fidelity — every explicit
MODEL_MAPalias resolves to its mapped target under any prefix/casing spelling (sweeps the whole map every iteration, so a future alias edit that breaks case-insensitive lookup fails immediately).
No SUT bugs found.
Validation
- [x]
npm test -- test/property/model-map.property.test.ts test/model-map.test.ts— 21/21 (new 6 + existing 15 untouched) - [x]
npm run typecheck(also via pre-commit hook) - [x]
npx eslint test/property/model-map.property.test.ts --max-warnings=0
Docs and Governance Checklist
- [x] Test-only; no behavior or docs surface changed
Risk and Rollback
- Risk level: minimal — additive test file; conventions match the existing
test/property/suites. - Rollback plan: revert the single commit.
https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.
Greptile Summary
adds test/property/model-map.property.test.ts — a six-property fast-check suite that pins the resolution layer of resolveNormalizedModel / getModelProfile (the path every request's model routing flows through). no sut or production code is changed.
- closed-world + idempotence (props 1–2): every input, including garbage, lands on a
MODEL_PROFILESkey, and normalized outputs are fixpoints of the resolver. - spelling invariance (prop 3): three independent assertions — prefix-only, casing-only, and combined prefix+casing — confirm
stripProviderPrefix+ case-fold runs safely as one path for synthesized, mapped, and garbage inputs. - codex/general separation (props 4–5) and alias fidelity (prop 6): unmapped codex ids always route to
CURRENT_CODEX_MODEL; general GPT-5 spellings never silently route to a codex-tuned model; everyMODEL_MAPalias resolves to its declared target under any prefix or casing.
Confidence Score: 5/5
test-only addition with no production code changes; safe to merge
single additive test file; all six properties are logically sound against the sut — every resolveNormalizedModel exit path returns a MODEL_PROFILES key, all catalog outputs are self-aliases in MODEL_MAP ensuring idempotence holds, and the combined prefix+casing assertion in property 3 closes the gap flagged in the previous review thread
no files require special attention
Important Files Changed
| Filename | Overview |
|---|---|
| test/property/model-map.property.test.ts | adds 6 fast-check property tests covering closed-world resolution, idempotence, spelling/prefix invariance, codex dominance, general-gpt5 inverse, and full alias fidelity for the model-map pipeline; no sut changes |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
IN["arbModelId\n(MAP_KEY | synthesized GPT-5 | garbage)\n+ arbPrefix"] --> RNM["resolveNormalizedModel"]
RNM --> SPP["stripProviderPrefix\n(take last '/' segment)"]
SPP --> LMM{"lookupMappedModel\n(exact, then case-insensitive)"}
LMM -->|hit| OUT1["MODEL_MAP value"]
LMM -->|miss| RCC{"resolveCodexCatalogModel\nincludes('codex')?"}
RCC -->|yes| OUT2["CURRENT_CODEX_MODEL"]
RCC -->|no| RGC{"resolveGeneralGpt5CatalogModel\ntokenize to GPT-5 family?"}
RGC -->|yes| OUT3["catalog entry"]
RGC -->|no| OUT4["DEFAULT_MODEL (gpt-5.5)"]
Reviews (2): Last reviewed commit: "test: combine prefix and casing mutation..." | Re-trigger Greptile
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. Credits must be used to enable repository wide code reviews.
[!WARNING]
Review limit reached
@ndycode, we couldn't start this review because you've reached your PR review rate limit.More reviews will be available in 29 minutes and 44 seconds. Learn how PR review limits work.
Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).
⌛ How to resolve this issue?
After more reviews become available, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.
🚦 How do rate limits work?
CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.
For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.
Please see our Fair Usage Limits Policy for further information.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID:
f370576b-c0ac-4ba8-b9be-9f7e00570368📥 Commits
Reviewing files that changed from the base of the PR and between fa9bde30aea8a966d717907cb005dea514d59927 and ae47c9e8031b0af0772c5bf12ca7cf11e57fd145.
📒 Files selected for processing (1)
test/property/model-map.property.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Commit unit tests in branch
claude/audit-78-model-map-property
✨ Simplify code
- [ ] Create PR with simplified code
- [ ] Commit simplified code in branch
claude/audit-78-model-map-property
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.
Comment @coderabbitai help to get the list of available commands and usage tips.