chore(lint): env名/エラーコードの領域跨ぎ SSoT drift 検知を追加#424
Conversation
env_keys.py(正本)の定数が docker-compose.yml に全注入されているか、 errors.py の ErrorCode と errorCodes.ts の ERROR_CODES が一致するかを scripts/lint-env-keys.sh で機械検証する。言語境界上リテラル複製は消せ ないため「複製が正本と一致するか」を検証する方針。 - scripts/lint-env-keys.sh 新設(rg/comm のみ依存) - make lint-env-keys ターゲット + lint 集約に追加 - CI(test.yml の test-backend ジョブ)に fail-fast ステップ配線 - env_keys.py / errors.py の docstring に自動 drift 検知への参照を追記 起動時内部フラグ APP_BOOTSTRAPPED は COMPOSE_ALLOWLIST で除外。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 51 minutes and 15 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughA new Bash script ChangesSSoT Drift Lint
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
GitHub ランナー(ubuntu-latest)と flake.nix の devshell に ripgrep が 入っておらず、test-backend の Lint SSoT ステップが rg コマンド不在で 落ちていた。抽出を grep -E + sed -E に置き換え PCRE / rg 依存を除去。 ローカル(macOS)・CI(GNU)の両方で動く。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@scripts/lint-env-keys.sh`:
- Around line 43-47: The compose key scan in lint-env-keys.sh is too broad
because it collects every uppercase YAML key from docker-compose.yml, so matches
from other services or sections can hide missing backend env vars. Update the
compose_names extraction to limit the rg/parse logic to the backend service’s
environment block only, keeping the rest of the expected_in_compose and
missing_in_compose checks unchanged.
- Around line 42-47: The env-name extraction in the lint script is comparing the
left-hand identifier instead of the actual env string literal, so it can miss
real value changes and flag harmless symbol renames. Update the logic around
env_names/expected_in_compose to parse and compare the quoted env value itself
from the source entries, then keep compose_names and missing_in_compose checks
working off those literal values. Ensure the comparison remains sorted/unique
and still respects COMPOSE_ALLOWLIST.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5b387e59-e548-4a97-ab31-631c0734ba00
📒 Files selected for processing (5)
.github/workflows/test.ymlMakefilebackend/app/core/env_keys.pybackend/app/core/errors.pyscripts/lint-env-keys.sh
PR #424 のレビュー指摘 2 件を反映: - env_keys.py は symbol 名ではなく文字列値(NAME = "VALUE" の VALUE)を 比較対象にする。symbol だけ rename しても誤検知せず、値だけ変えた drift も 取りこぼさない - docker-compose.yml の env 名抽出を api サービスの environment ブロックに 限定する。全 YAML の大文字キーを拾うと他サービス(libsql の SQLD_NODE 等)の 名前で検知漏れが起きるため ネガティブテスト: (a) 他サービスのみに存在する名前, (b) 値のみの drift, いずれも exit 1 で検知することを確認。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(lint): env名/エラーコードの領域跨ぎ SSoT drift 検知を追加 env_keys.py(正本)の定数が docker-compose.yml に全注入されているか、 errors.py の ErrorCode と errorCodes.ts の ERROR_CODES が一致するかを scripts/lint-env-keys.sh で機械検証する。言語境界上リテラル複製は消せ ないため「複製が正本と一致するか」を検証する方針。 - scripts/lint-env-keys.sh 新設(rg/comm のみ依存) - make lint-env-keys ターゲット + lint 集約に追加 - CI(test.yml の test-backend ジョブ)に fail-fast ステップ配線 - env_keys.py / errors.py の docstring に自動 drift 検知への参照を追記 起動時内部フラグ APP_BOOTSTRAPPED は COMPOSE_ALLOWLIST で除外。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(lint): lint-env-keys を ripgrep 非依存にして CI fail を解消 GitHub ランナー(ubuntu-latest)と flake.nix の devshell に ripgrep が 入っておらず、test-backend の Lint SSoT ステップが rg コマンド不在で 落ちていた。抽出を grep -E + sed -E に置き換え PCRE / rg 依存を除去。 ローカル(macOS)・CI(GNU)の両方で動く。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(lint): CodeRabbit 指摘対応(env 値比較 / compose スコープ限定) PR #424 のレビュー指摘 2 件を反映: - env_keys.py は symbol 名ではなく文字列値(NAME = "VALUE" の VALUE)を 比較対象にする。symbol だけ rename しても誤検知せず、値だけ変えた drift も 取りこぼさない - docker-compose.yml の env 名抽出を api サービスの environment ブロックに 限定する。全 YAML の大文字キーを拾うと他サービス(libsql の SQLD_NODE 等)の 名前で検知漏れが起きるため ネガティブテスト: (a) 他サービスのみに存在する名前, (b) 値のみの drift, いずれも exit 1 で検知することを確認。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
概要
領域跨ぎ(BE / FE / infra / local)の SSoT drift を機械検知する
scripts/lint-env-keys.shを新設しました。env 名・エラーコードは言語境界(Python / YAML / TS)上リテラル複製を消せないため、複製を消すのではなく「複製が正本と一致しているか」を検証する方針です。XR_refacterレビューで唯一残っていた SSoT 弱点(env 名リテラルに自動 drift 検知が無い)への対応です。検証内容
backend/app/core/env_keys.py(正本)の定数値がdocker-compose.ymlの environment にすべて存在するかAPP_BOOTSTRAPPED(entrypoint.shが export)はCOMPOSE_ALLOWLISTで除外env_keys ⊆ compose(compose 側のSQLD_NODEは libsql サイドカー用で env_keys 対象外)backend/app/core/errors.pyのErrorCode値集合とweb/src/constants/errorCodes.tsのERROR_CODESが完全一致するかRecord<ErrorCodeKey,...>型縛りは FE 内で完結し、BE 起点の追加漏れを拾えないため、それを補完変更点
scripts/lint-env-keys.sh新設(rg/commのみに依存)make lint-env-keysターゲット新設 +lint集約 + help に追加test.ymlのtest-backendジョブ)に「Lint SSoT」ステップを fail-fast で配線(rg はランナープリインストール、nix 非経由)env_keys.py/errors.pyの docstring に自動 drift 検知への参照を追記検証
make lint-env-keys: pass(ネガティブテストで偽 env 定数・偽 ErrorCode を注入 → 両 drift を検知し exit 1、revert 後 OK を確認)make lint-backend: passmake codegen-types→web/src/api/generated.ts: drift なし(docstring 変更は OpenAPI に非伝播)test.yml: valid YAMLFollow-ups(別 PR)
cloud_run/main.tf)/ CI の env 突き合わせまで拡張(allowlist 設計を伴う)lint-web-messages.shの CI 配線も検討余地あり(本 PR で grep 系 lint を CI で走らせる前例ができた)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Chores