improve(backend): verify の import 名乖離を内部マスタで補正(ADR-0016 #477)#482
Conversation
verify(D6)の辞書レス照合(-→_ 変換)では、配布名と import 名が乖離する PyPI package(PyYAML→yaml, Pillow→PIL, beautifulsoup4→bs4, scikit-learn→sklearn 等) が actual_import へ昇格せず取りこぼしていた。pypi のみ内部マスタで補正する。 - resources/pypi_import_aliases.json(新規): 配布名→import名の内部マスタ。 既知の乖離 17 件を初期集合とする。google.* 等の汎用名前空間は false positive 回避のため意図的に除外 - imports/python.py: lru_cache でマスタを読み、機械変換で当たらない時のみ alias 照合。 連携ホットパスで外部を叩かない(実行時は読むだけ / D4) - D3(辞書を持たない)とのテンションは linguist_master.json と同じ 「ホットパス外で生成する暫定キュレーション」モデルで解消し ADR-0016 に記録 - 昇格のみ・降格なし。マスタ未収録の乖離は従来どおり false negative を受容 TDD(red→green→refactor)で実装。schemas/routers 不変のため codegen・migration 不要。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds an internal alias mapping resource ( ChangesPyPI Import Alias Correction
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
Closes #477
背景
verify(D6)の辞書レス照合(
-→_変換・go 接頭辞一致・npm 完全一致)では、配布名と import 名が乖離する PyPI package がactual_importへ昇格せず取りこぼしていた(PyYAML→yaml,Pillow→PIL,beautifulsoup4→bs4,scikit-learn→sklearn等)。ADR-0016「将来の移行条件」verify 節の残課題。対応(方針 C: オフライン生成の内部マスタ)
linguist_master.jsonの前例に倣い、pypi のみ内部マスタで補正する。resources/pypi_import_aliases.json(新規): 配布名(canonical / PEP503)→ トップレベル import 名 の内部マスタ。既知の乖離 17 件を初期集合とする。google.*のような汎用名前空間へ畳まれる package(protobuf 等)は false positive 回避のため意図的に除外imports/python.py:@lru_cacheでマスタを読み、機械変換で当たらない時のみ alias 照合。連携ホットパスで外部を叩かない(実行時は読むだけ / D4)D3 テンションの整理(ADR に記録)
「辞書を持たない(D3)」と軽くテンションするが、
linguist_master.jsonと同じモデルで解消:top_level.txt由来の機械的事実であり taxonomy 判断を含まないtop_level.txtからのオフライン再生成を想定した暫定キュレーション(実データ拡張は残課題)ADR-0016 の将来条件節 + 改訂履歴を更新済み。
テスト(TDD: red→green→refactor)
PyYAML宣言 +yamlimport →actual_import昇格の end-to-end& imported→| importedミュータントを手動注入し、過剰昇格防止テストが殺すことを実証検証
make cifull green(lint-tdd/lint-adr-index含む)make codegen-types)・migration 不要スコープ外(別途)
mutmutはbackend/mutants/の**古いキャッシュ(messages.jsonが stale)**で baseline が無関係テストで落ちるため scoped 実行不可 → 手動ミュータント検証で代替(本 PR 範囲外・CI の mutation.yml は fresh checkout で無影響)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests
Documentation