Skip to content

test: property-check model-map resolution invariants#597

Open
ndycode wants to merge 2 commits into
mainfrom
claude/audit-78-model-map-property
Open

test: property-check model-map resolution invariants#597
ndycode wants to merge 2 commits into
mainfrom
claude/audit-78-model-map-property

Conversation

@ndycode

@ndycode ndycode commented Jun 11, 2026

Copy link
Copy Markdown
Owner

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 (resolveNormalizedModelgetModelProfile). The test: property-check the unsupported-model fallback invariants #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:

  1. Closed world — every resolution lands on a MODEL_PROFILES key, proving getModelProfile's DEFAULT_MODEL fallback is pure defence (no reachable input needs it; a MODEL_MAP value or catalog entry without a profile would be found instantly).
  2. Idempotence — normalized outputs are fixpoints of the resolver.
  3. Spelling invariance — provider prefixes and arbitrary casing never change the resolution, for any input including garbage.
  4. Codex dominance — unmapped ids mentioning codex resolve to CURRENT_CODEX_MODEL, never a general model.
  5. The inverse — unmapped general GPT-5 spellings stay codex-free and in the gpt-5 family: a general-purpose request can never silently route to a codex-tuned model.
  6. Alias fidelity — every explicit MODEL_MAP alias 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

  • npm test -- test/property/model-map.property.test.ts test/model-map.test.ts — 21/21 (new 6 + existing 15 untouched)
  • npm run typecheck (also via pre-commit hook)
  • npx eslint test/property/model-map.property.test.ts --max-warnings=0

Docs and Governance Checklist

  • 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_PROFILES key, 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; every MODEL_MAP alias 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)"]
Loading

Reviews (2): Last reviewed commit: "test: combine prefix and casing mutation..." | Re-trigger Greptile

Six fast-check properties over the model resolution pipeline
(resolveNormalizedModel / getModelProfile / getNormalizedModel),
generating known aliases, synthesized GPT-5 spellings (minors 0-9,
mini/nano/pro/codex variants, -/./space separators, suffixes),
provider prefixes, random casing, and raw garbage:

- closed world: every resolution lands on a MODEL_PROFILES key, so
  getModelProfile's DEFAULT_MODEL fallback is pure defence
- idempotence: normalized outputs are fixpoints
- provider prefixes and casing never change the resolution
- codex dominance: unmapped ids mentioning codex resolve to
  CURRENT_CODEX_MODEL, never a general model
- the inverse: unmapped general GPT-5 spellings stay codex-free and
  in the gpt-5 family (no silent codex routing for general requests)
- every explicit MODEL_MAP alias resolves to its mapped target under
  any prefix/casing spelling

Companion to the property suites in #574/#575/#592-#596.

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
@chatgpt-codex-connector

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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 14 minutes and 14 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

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: 0b756ad7-de91-4dd8-84d0-7a43b9ca712b

📥 Commits

Reviewing files that changed from the base of the PR and between dae10cb and 15447c2.

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

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread test/property/model-map.property.test.ts
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.

2 participants