ci: run conversion accuracy tests with cached mozc snapshot#275
Conversation
CI ランナーの匿名 GitHub API 枠 (60 req/h、IP 共有) では Commits/Contents API が事実上常に rate limit に当たるため、 慣例の GITHUB_TOKEN 環境変数が設定されていれば api.github.com へのリクエストに Bearer トークンを付ける。 raw.githubusercontent.com のダウンロードは API rate limit の 対象外なので、資格情報は意図的に送らない。 空値・空白のみの値は匿名扱い、前後の空白は trim する (シェル置換由来の改行でヘッダが壊れないように)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ローカルの mozc-raw キャッシュ (2026-02-21 取得) と最新上流 スナップショット (7c1e06d3) の間の辞書コスト・エントリ変更により 6 ケースが fail、history コーパスの baseline 1 件がずれていた。 - 6 ケースを skip + issue #273 リンクに変更 (上流 drift の再調整は #273 で追跡) - おねがいします の baseline を お願いします に更新 (CLAUDE.md の運用ルール: baseline がずれた場合は値を更新) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
accuracy ジョブを追加: lex-core / lex-cli / testcorpus / mise.toml の 変更で発火し、mise run accuracy と accuracy-history を実行する。 - Mozc raw スナップショット (~90MB) は actions/cache の restore/save 分割でキャッシュ。キーは .stamp 1 行目の 上流 commit SHA で、上流スナップショットごとに 1 エントリのみ 保存 (毎 run 保存によるキャッシュ枠の浪費を回避) - 古いキャッシュが restore されても dictool の stamp 機構 (#266) が 毎回上流と照合し、最新なら Commits API 1 回の fast path、 ずれていればトランザクショナルに再取得するため安全 - GITHUB_TOKEN をジョブに渡し、共有ランナー IP の匿名 rate limit (60 req/h) を回避 (dictool 側は前コミットで対応) - needs は changes のみ (lint に依存させると corpus-only 変更で lint が skip → accuracy も skip になるため) - rust-cache は release プロファイル用に shared-key: accuracy を分離 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds the project’s key regression suite (conversion accuracy tests) to CI while making Mozc snapshot fetching practical and reliable by caching the raw Mozc TSV snapshot and authenticating GitHub API requests to avoid anonymous rate-limit failures. It also updates the accuracy corpora to account for upstream Mozc snapshot drift (skipping 6 newly failing cases and updating one history baseline) so the new CI gate can run green while drift is tracked in #273.
Changes:
- Add a new CI
accuracyjob that restores/savesengine/data/mozc-rawviaactions/cacheand runsmise run accuracy+mise run accuracy-history. - Update the Mozc fetcher to attach
Authorization: Bearer $GITHUB_TOKENforapi.github.comrequests (but not for raw downloads), with unit tests. - Adjust accuracy corpora for the newer Mozc snapshot: skip 6 drifted cases (linked to #273) and update the
accuracy-historybaseline for “おねがいします”.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
engine/testcorpus/accuracy-corpus.toml |
Marks 6 drifted cases as skip = true with issue = "#273" and updates notes to reflect Mozc snapshot drift. |
engine/testcorpus/accuracy-corpus-history.toml |
Updates one baseline to match new Mozc snapshot behavior and annotates the change with #273 context. |
engine/crates/lex-cli/src/dict_source/mozc.rs |
Adds authenticated GitHub API GET helper + github_auth_header to mitigate CI rate limits, plus unit tests. |
.github/workflows/ci.yml |
Adds corpus change filter output and introduces an accuracy job with Mozc snapshot caching and GITHUB_TOKEN wiring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
概要
プロジェクトで最も重要な回帰スイートである変換精度テスト (
mise run accuracy/mise run accuracy-history) を CI に組み込む。辞書ビルドに Mozc の fetch (~90MB) が必要なため見送られていたが、#266 で fetch が commit SHA ピン +.stamp(SHA + マニフェスト) 化されキャッシュが安全になったため導入する。設計
accuracy ジョブ (ubuntu-latest)
core || cli || corpus(changes フィルタにcorpus: engine/testcorpus/** + mise.tomlを追加)needs: changesのみ (lint に依存させない): corpus-only 変更では lint が skip され、needs 連鎖で accuracy まで skip されてしまうためshared-key: accuracyを分離。debug 用engineキャッシュとの相互汚染を避けるMozc スナップショットのキャッシュ戦略
actions/cacheの restore/save 分割でengine/data/mozc-rawをキャッシュする。restore-keys: mozc-raw-prefix で最新エントリを復元.stamp1 行目の上流 commit SHA を読み、mozc-raw-<sha>キーで保存。restore したキーと一致する場合は保存しない → 上流スナップショットごとに 1 エントリのみで、毎 run ~90MB を保存してリポジトリの 10GB キャッシュ枠 (rust-cache 含む) を churn しない.stampの mtime は保存時点 (checkout した sources より古い) ため、fetch-dict-mozcタスクは CI では常に実行され、dictool が検証を担う。lexime.dict/lexime.connはキャッシュせず毎回 compile (数十秒)GitHub API rate limit 対応
fetch の Commits / Contents API は非認証 ureq で、Actions ランナーの共有 IP では匿名枠 (60 req/h/IP) が事実上常に枯渇している。対応として:
GITHUB_TOKEN環境変数が設定されていればapi.github.comへのリクエストにAuthorization: Bearerを付ける (5000 req/h)。raw.githubusercontent.comのダウンロードは API rate limit 対象外のため、資格情報は意図的に送らない。空値は匿名扱い・前後空白 trim。単体テスト追加GITHUB_TOKEN: ${{ github.token }}を渡すコーパスの上流 drift 再調整 (副次的発見)
ローカルの mozc-raw は 2026-02-21 取得で、最新上流スナップショット (
7c1e06d3) では辞書コスト・エントリ変更により 6 ケースが fail、history baseline 1 件がずれていた (まさにこの CI が検出すべき事象)。CLAUDE.md の運用ルールに従い:テストプラン
mise run accuracy— Pass 101 / Fail 0 / Skip 33 (pass rate 100%)mise run accuracy-history— Pass 7 / Fail 0 (pass rate 100%)cargo fmt --all --check/cargo clippy --workspace --all-features -- -D warningscargo test -p lex-cli(64 passed、github_auth_headerの単体テスト含む)🤖 Generated with Claude Code