Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
dupe-check dupe-check-html dupe-clean \
build-web build-backend deploy-web \
gen-redirects codegen-types licenses \
metrics-ai-friendliness \
migrate migrate-create \
infra-fmt infra-fmt-check infra-validate-dev infra-validate-stg infra-validate-prod infra-validate \
clean
Expand Down Expand Up @@ -45,7 +46,7 @@ help:
@echo " typecheck-backend Backend: pyright 型チェック"
@echo " lint-web Frontend: eslint"
@echo " lint-web-messages Frontend: setError等にリテラル日本語が渡っていないか検知"
@echo " lint-env-keys env名/エラーコードの SSoT drift を検知 (env_keys.py↔compose, errors.py↔errorCodes.ts)"
@echo " lint-env-keys env名/エラーコードの SSoT drift を検知 (env_keys.py↔compose/cloud_run 双方向, リテラル参照禁止, errors.py↔errorCodes.ts)"
@echo " lint-fix リント自動修正 (ruff + eslint)"
@echo " format Prettier で整形"
@echo " format-check Prettier チェック"
Expand All @@ -55,6 +56,9 @@ help:
@echo " dupe-check-html 同上 (HTML レポート出力後にパスを表示)"
@echo " dupe-clean report/dupe/ を削除"
@echo ""
@echo "計測"
@echo " metrics-ai-friendliness AI フレンドリーさ指標を GitHub 履歴から集計し docs/metrics/ を再生成"
@echo ""
@echo "ビルド"
@echo " build-web Vite ビルド"
@echo " build-backend Docker イメージビルド"
Expand Down Expand Up @@ -174,7 +178,8 @@ lint-web-messages:
nix develop --command bash scripts/lint-web-messages.sh

# env 名 / エラーコードの SSoT drift を検知。
# env_keys.py↔docker-compose.yml、errors.py↔errorCodes.ts の集合一致を検証する。
# env_keys.py↔docker-compose.yml(双方向)/ cloud_run main.tf(逆方向)、
# backend のリテラル env 参照禁止、errors.py↔errorCodes.ts の集合一致を検証する。
# grep/sed/comm のみに依存(ripgrep 不要)。他 lint と揃えて nix wrap で実行する。
lint-env-keys:
nix develop --command bash scripts/lint-env-keys.sh
Expand Down Expand Up @@ -232,6 +237,16 @@ gen-redirects:
codegen-types:
nix develop --command bash -c "set -e; cd backend && .venv/bin/python scripts/export_openapi.py && cd ../web && node scripts/gen-types.mjs"

# ------------------------------------------------------------------ #
# 計測(AI フレンドリーさダッシュボード)
# ------------------------------------------------------------------ #

# 手戻りコミット率・CodeRabbit 指摘密度等を GitHub 履歴から月次集計し、
# docs/metrics/ai-friendliness.md(ダッシュボード)を再生成する。
# gh の認証(ホスト側 keyring)を使うため nix wrap しない(依存: gh / jq / git のみ)。
metrics-ai-friendliness:
bash scripts/metrics-ai-friendliness.sh

# ------------------------------------------------------------------ #
# 使用 OSS ライセンス一覧
# ------------------------------------------------------------------ #
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GitHub活動分析、ブログ連携による発信力を集計
| [docs/data-model.md](./docs/data-model.md) | Turso (libSQL) 運用・Alembic マイグレーション・データ設計 |
| [docs/adr/](./docs/adr/) | アーキテクチャ判断記録(ADR) |
| [docs/runbooks/](./docs/runbooks/) | 運用 Runbook |
| [docs/metrics/ai-friendliness.md](./docs/metrics/ai-friendliness.md) | AI フレンドリーさ指標の月次ダッシュボード(`make metrics-ai-friendliness` で再生成) |

## 主な機能

Expand Down
17 changes: 13 additions & 4 deletions backend/app/core/env_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@

## drift 検知(自動)

本モジュールの定数値が `docker-compose.yml` の environment にすべて存在するかは
`scripts/lint-env-keys.sh`(`make lint-env-keys` / CI の test-backend ジョブ)で機械検証する。
rename / 追加で compose 追従を忘れると lint が落ちる。ローカル開発で意図的に注入しない
定数(起動時内部フラグ等)は同スクリプトの `COMPOSE_ALLOWLIST` に明示的に追記する。
`scripts/lint-env-keys.sh`(`make lint-env-keys` / CI)が以下を機械検証する:

- 本モジュールの定数値が `docker-compose.yml` の environment にすべて存在するか。
ローカル開発で意図的に注入しない定数(起動時内部フラグ等)は同スクリプトの
`COMPOSE_ALLOWLIST` に明示的に追記する。
- `docker-compose.yml` / `infra/modules/cloud_run/main.tf` に書かれた env 名が
すべて本モジュールに存在するか(rename / 削除時の旧名残留・typo を検知)。
cloud_run は環境変数ごとに注入要否が異なるため逆方向のみ検証する。
- backend/app が `os.getenv("XXX")` 等の文字列リテラルで env を参照していないか
(本モジュールの定数経由を機械強制する)。

`.github/workflows/ci.yml` は検証対象外(実 API を CI から呼ばないため。
OPENAI_API_KEY のコメント参照)。`docs/api.md` の環境変数表は手動同期のまま。

## 関連ドキュメント

Expand Down
Loading
Loading