Skip to content

fix(router): prefer exact tier match over word-prefix fallback in parseTier - #538

Open
BlueX888 wants to merge 1 commit into
OpenBMB:mainfrom
BlueX888:fix/parse-tier-exact-match
Open

BlueX888 wants to merge 1 commit into
OpenBMB:mainfrom
BlueX888:fix/parse-tier-exact-match

Conversation

@BlueX888

@BlueX888 BlueX888 commented Sep 1, 2026

Copy link
Copy Markdown

What

parseTier now checks whether the cleaned judge output exactly equals a known tier (case-insensitively) before falling back to word-boundary matching, and the fallback iterates tiers longest-first.

Why

The fallback loop iterated knownTiers in configuration order with a \b<tier>\b regex. Since - is a word boundary, a tier that is a word-prefix of a hyphenated tier matched first: with tiers fast and fast-pro, a bare judge output of fast-pro was parsed as fast. Reproduced on main:

parseTier("fast-pro", ["fast", "fast-pro"]) // => "fast", expected "fast-pro"

How verified

  • Added tests/router/parseTier.spec.ts (6 cases: exact match over prefix, case-insensitive exact match, tagged output, free-text longest match, plain fallback mention, no-match returns undefined) — all pass via tsx --test.
  • Existing tests/router/tokenSaver.spec.ts (7 cases) still passes.
  • tsc --noEmit -p tsconfig.json passes.

Fixes #428

…seTier

The token-saver fallback parser iterated knownTiers in order with a
word-boundary regex. Because '-' is a word boundary, a tier that is a
word-prefix of a hyphenated tier (e.g. 'fast' vs 'fast-pro') matched
first and won even when the judge output named the longer tier exactly.

Check exact (case-insensitive) equality against known tiers before the
regex fallback, and sort fallback candidates longest-first so free-text
mentions also resolve to the most specific tier.

Fixes OpenBMB#428
@BlueX888
BlueX888 force-pushed the fix/parse-tier-exact-match branch from e32f81d to ad66203 Compare October 25, 2026 18:11
@BlueX888

Copy link
Copy Markdown
Author

Rebased onto current main. The token-saver fallback now prefers an exact case-insensitive tier match and checks longer hyphenated names first, so a judge output of fast-pro no longer resolves to fast (#428). The new parseTier tests and the existing tokenSaver tests pass, and tsc --noEmit is clean. I can adjust or split it if that makes review easier.

This branch has not been deployed

No deployments
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.

parseTier returns a prefix tier for bare hyphenated tier names

1 participant