Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

fix(core): canonicalize release suffixes across local model families - #86

Merged
makoMakoGo merged 4 commits into
personal/local-clientsfrom
codex/model-release-suffix-canonicalization
Jul 1, 2026
Merged

fix(core): canonicalize release suffixes across local model families#86
makoMakoGo merged 4 commits into
personal/local-clientsfrom
codex/model-release-suffix-canonicalization

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Canonicalize local source model ids by stripping common release/build suffixes across Qwen, Mimo, Grok, DeepSeek, OpenAI, Kimi, and Longcat families.
  • Keep cleanup in source model canonicalization instead of aggregation or pricing lookup.
  • Update parser-level expectations for canonicalized DeepSeek and Junie/OpenAI models.

Tests

  • cargo test -p tokscale-core model_aliases
  • cargo test -p tokscale-core
  • cargo build -p tokscale-cli

Summary by cubic

Canonicalizes local source model IDs by stripping release/build date suffixes across OpenAI, Qwen, Kimi, Grok, Mimo, DeepSeek, and Longcat. Tightens matching to avoid false positives, enforces ASCII on the terminal segment, and supports scoped Longcat IDs (e.g., meituan/longcat-flash-3b-all-quant-0203-eagle3 → longcat-flash-3b; gpt-4.1-2025-04-14 → gpt-4.1; deepseek-v3-0324 → deepseek-v3).

  • New Features

    • Removes YYYY-MM-DD, YYYYMMDD, MM-DD, and MMDD suffixes for OpenAI dated models, Qwen, Kimi k2.* (incl. instruct builds), Grok grok-code-fast-1, Mimo variants, and DeepSeek (v3 and r1 distill forms); handles scoped Longcat IDs.
  • Bug Fixes

    • Tightens rules: ASCII-only terminal segment, full dates must start with “20”, and stripping limited to known families; unrelated models stay unchanged (e.g., mistral-small-2603).
    • Updates tests and parsers in tokscale-core and tokscale-cli to expect canonical IDs (e.g., gpt-4.1, deepseek-v3).

Written for commit fc2ab2c. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • 增强模型标识归一化:对更多常见前缀模型进行识别,并自动剥离发布日期等后缀,使网关/通道消息中展示的 model_id 更简洁一致(如归一为基础模型名)。
  • Bug Fixes
    • 修正部分解析场景下 model_id 过长或不一致的问题,避免出现未归一化的长标识。
  • Tests
    • 更新并补充相关单元测试期望值,覆盖新增的归一化规则与日期后缀变体。

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

本次变更扩展了模型来源 ID 归一化与发布日期后缀剥离逻辑,并同步调整 model_aliases.rslib.rsjunie.rs 和 CLI 测试中的 model_id 断言,以匹配新的归一化结果。

Changes

模型 ID 归一化逻辑扩展

Layer / File(s) Summary
归一化分派链与 OpenAI 前置截断
crates/tokscale-core/src/model_aliases.rs
canonicalize_source_model_id 新增 kimi/grok/mimo/deepseek/mistral 分派,canonicalize_openai_source_model 新增发布日期后缀前置截断。
各来源模型 canonicalization 函数与发布日期剥离工具
crates/tokscale-core/src/model_aliases.rs
新增或重写多个来源模型 canonicalization 函数,并引入 strip_release_suffix 系列函数处理完整和短发布日期后缀。
新增归一化测试用例
crates/tokscale-core/src/model_aliases.rs
更新 kimi/grok 断言并扩展 release suffix 测试列表,覆盖多组新增模型正例。
下游模块测试断言同步更新
crates/tokscale-core/src/lib.rs, crates/tokscale-core/src/sessions/junie.rs, crates/tokscale-cli/src/tui/data/mod.rs
同步更新网关消息、会话解析和 CLI 数据测试中的 model_id 断言。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Poem

兔耳一抖把长名缩短,
旧后缀悄悄落在风里转,
kimi、grok、deepseek 排队过关,
gpt-4.1 也换上了新标签,
小兔子点头:归一化真圆满 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了本次对多个模型家族发布后缀归一化的核心改动。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/model-release-suffix-canonicalization

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.

@codspeed-hq

codspeed-hq Bot commented Jul 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing codex/model-release-suffix-canonicalization (fc2ab2c) with personal/local-clients (8605498)

Open in CodSpeed

@makoMakoGo makoMakoGo left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Overall this is clean: putting release/build suffix cleanup in source-model canonicalization keeps the aggregation and pricing layers simple, and the parser-level expectation changes line up with the new canonical IDs. No blocking issues from this diff.

One small coverage note inline: Longcat is the only touched family whose canonicalizer still doesn't take the terminal model segment first, so provider-scoped source IDs won't canonicalize the same way Qwen/Mimo/DeepSeek/Mistral do.

Comment thread crates/tokscale-core/src/model_aliases.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/tokscale-core/src/model_aliases.rs (1)

287-337: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

非 ASCII 模型名会在这里触发 panic
model_id 没有 ASCII 约束;这里直接按字节下标切 &str,只要输入里带多字节字符且长度落到这些分支,就会在解析时 panic。入口处先拒绝非 ASCII,或改用 str::get

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tokscale-core/src/model_aliases.rs` around lines 287 - 337, Non-ASCII
model names can panic in the suffix-stripping helpers because
strip_full_release_date_suffix and strip_short_release_date_suffix index into
model by byte offsets without validating ASCII. Fix this by either rejecting
non-ASCII input before these helpers are reached or replacing the direct
slice/index access with safe str::get-based checks. Keep the existing
date-suffix matching behavior intact while ensuring the code never assumes
single-byte characters in model_id.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tokscale-core/src/model_aliases.rs`:
- Around line 148-152: The Kimi source model canonicalization in
canonicalize_kimi_source_model is too strict because strip_release_suffix can
reduce values like kimi-k2-0711 to kimi-k2, which no longer matches
starts_with("kimi-k2-") and causes them to be skipped. Update the matching logic
to accept the base kimi-k2 form as well (for example by loosening the prefix
check in canonicalize_kimi_source_model), and add or adjust a test around this
path to cover the date-only variant and confirm the intended normalization
behavior.

---

Outside diff comments:
In `@crates/tokscale-core/src/model_aliases.rs`:
- Around line 287-337: Non-ASCII model names can panic in the suffix-stripping
helpers because strip_full_release_date_suffix and
strip_short_release_date_suffix index into model by byte offsets without
validating ASCII. Fix this by either rejecting non-ASCII input before these
helpers are reached or replacing the direct slice/index access with safe
str::get-based checks. Keep the existing date-suffix matching behavior intact
while ensuring the code never assumes single-byte characters in model_id.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc268311-8412-4133-b82c-6b0db97a4a3b

📥 Commits

Reviewing files that changed from the base of the PR and between 8605498 and c6ed20a.

📒 Files selected for processing (3)
  • crates/tokscale-core/src/lib.rs
  • crates/tokscale-core/src/model_aliases.rs
  • crates/tokscale-core/src/sessions/junie.rs

Comment thread crates/tokscale-core/src/model_aliases.rs

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread crates/tokscale-core/src/model_aliases.rs Outdated
Comment thread crates/tokscale-core/src/model_aliases.rs Outdated
@makoMakoGo
makoMakoGo force-pushed the codex/model-release-suffix-canonicalization branch from c6ed20a to 16aa4bd Compare July 1, 2026 04:26
@makoMakoGo

Copy link
Copy Markdown
Owner Author

/juya review

@juya-review-bot juya-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenCodeReview found 1 issue(s).

Comment thread crates/tokscale-core/src/model_aliases.rs Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread crates/tokscale-core/src/model_aliases.rs Outdated
@makoMakoGo
makoMakoGo merged commit f8631da into personal/local-clients Jul 1, 2026
9 checks passed
@makoMakoGo
makoMakoGo deleted the codex/model-release-suffix-canonicalization branch July 1, 2026 05:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant