Skip to content

fix(engine): anchor the text after the last * at the end of a model name - #33

Merged
fylorn merged 1 commit into
mainfrom
fix/glob-suffix
Sep 17, 2026
Merged

fylorn merged 1 commit into
mainfrom
fix/glob-suffix

Conversation

@fylorn

@fylorn fylorn commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

What was wrong

glob_match looked for each literal segment from left to right and stopped at its first occurrence, so the segment after the last * only matched when that first occurrence happened to end the name.

Pattern Name Before After
*-mini gpt-4o-mini-2024-mini no match match
gpt-*-mini gpt-4o-mini-realtime-mini no match match
a*b abab no match match
ab*ba aba no match no match

The same matcher decides a routing rule's when.model, which models a key's allow list shows, and an upstream's models_only. A pattern like the ones above silently left out models it names.

The fix

The first and last segments are anchored to the start and the end and may not overlap. The segments in between are found left to right in what remains, which is enough when * is the only wildcard.

Tests

  • the_part_after_the_last_star_anchors_at_the_end covers the cases in the table.
  • agrees_with_a_backtracking_matcher_on_every_short_input compares the matcher with a character-by-character backtracking matcher on every pattern of up to five characters over a, b, * against every string of up to six characters. The old implementation fails it.

cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace and scripts/smoke.sh pass locally.

Bumps the workspace to 0.2.2 so the desktop app can pin the fix; it mirrors this matcher to show an upstream's enabled scope.

🤖 Generated with Claude Code

… name

`glob_match` looked for each literal segment from left to right and stopped
at its first occurrence. The segment after the last `*` therefore only
matched when its first occurrence happened to end the name: `*-mini` did not
match `gpt-4o-mini-2024-mini`, and `a*b` did not match `abab`.

The same matcher decides a routing rule's `when.model`, which models a key's
`allow` list shows, and an upstream's `models_only`. A pattern written this
way silently left out models it names, and the desktop app mirrors the
matcher to show the enabled scope, so both sides were wrong the same way.

The first and last segments are now anchored to the start and the end and
may not overlap; the segments in between are found left to right in what
remains, which is enough when `*` is the only wildcard. A test compares the
matcher with a backtracking one on every pattern of up to five characters
over `a`, `b` and `*` against every string of up to six characters.

Bumps the workspace to 0.2.2 so the desktop app can pin the fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract.

@fylorn
fylorn merged commit 6cc189f into main Sep 17, 2026
2 checks passed
@fylorn
fylorn deleted the fix/glob-suffix branch September 17, 2026 07:38
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.

1 participant