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

fix(router): prefer exact tier match over word-prefix fallback in parseTier#538
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
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