Skip to content

feat: backend 依存管理の uv.lock 化と devshell の Nix build 化(ADR-0021 Phase 0+1)#499

Merged
yusuke0610 merged 1 commit into
mainfrom
claude/adr021-07btiv
Jul 15, 2026
Merged

feat: backend 依存管理の uv.lock 化と devshell の Nix build 化(ADR-0021 Phase 0+1)#499
yusuke0610 merged 1 commit into
mainfrom
claude/adr021-07btiv

Conversation

@yusuke0610

@yusuke0610 yusuke0610 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

変更概要

ADR-0021 の Phase 0 と Phase 1 の実装(コミットは Phase 単位で分割・独立に revert 可能)。

Phase 0(09970da: backend 依存の SSoT を手書き requirements.txt から pyproject.toml [project.dependencies] + uv.lock へ差し替え。3 経路(ローカル / CI / 本番 Docker)の挙動は不変。

  • pyproject.toml[project] を追加し全 30 依存を == 固定のまま移設(CVE ピン留め根拠コメントも移設 / P7 維持)
  • uv.lock を生成・コミット。旧 requirements.txt の全ピンが同一バージョンで解決されることを機械照合で確認済み
  • Dockerfile: builder で uv export --frozen により lock から requirements.txt をビルド時生成し、従来の pip wheelpip install 経路へ渡す(本番経路の挙動は不変。Nix build 化は Phase 3)
  • CI: uv sync --locked 化(lock drift で fail)。pip-audit は lock の全依存を export して監査(--python 3.13 明示)
  • Renovate: pip_requirementspep621 manager へ

Phase 1(2e44d21: devshell の Python 環境を uv2nix で Nix build 化し、ローカルの backend/.venv を廃止。ADR-0021 の発端(VS Code の .venv 絶対パス直書き)を解消。

  • flake.nix に uv2nix / pyproject-nix / pyproject-build-systems を導入(wheel 優先で uv.lock から pythonSet を構成)。transitive input は全て follows で既存 nixpkgs に集約
  • devshell の python / pytest / ruff / alembic / uvicorn は Nix build の virtualenv(devforge-backend-env)から PATH 解決
  • Makefile の .venv/bin/* 参照 10 箇所を PATH 解決へ置換(migrate / migrate-create の nix wrap 漏れも修正)
  • pyright は venv 参照を撤廃し実行側が --pythonpath を明示(ローカル = devshell python3、CI = uv sync の .venv/bin/python
  • .vscode/settings.jsonpython.defaultInterpreterPath 絶対パス直書きを撤廃(direnv 経由の PATH 解決へ)
  • CI の uv sync 経路は Phase 2 で Nix 化予定のため維持(過渡期の乖離は ADR 記載どおり)

セルフレビューチェックリスト

必須確認

  • make ci が pass している(lint + test + build-web)※作業環境の制約(下記)により CI 相当を個別実行: 新 devshell 内(.venv 削除済み)で ruff / pyright 0 errors / pytest 724 passed / eslint / lint-web-messages / vitest 382 passed / build-web / lint-env-keys / lint-adr-index / lint-tdd すべて pass
  • コメント・ドキュメント・エラーメッセージは日本語で記述した

条件付き確認(該当する場合のみ N/A と記入)

  • N/A — app/schemas/ / app/routers/ の変更なし(codegen-types 不要)
  • N/A — ページ・認証・ナビゲーション・レイアウトの変更なし(E2E 不要)
  • N/A — 新規環境変数なし
  • N/A — web/src/ の変更なし

破壊的変更

  • 破壊的変更なし(API 契約・DB スキーマ・既存の公開インターフェースに変更なし)
  • 破壊的変更あり → 概要: 開発フローの変更のみ(依存追加は pyproject 編集 + uv lock、ローカルは .venv 不要で devshell が全て提供)

ADR(設計判断を伴う変更の場合のみ)

  • 既存 ADR が対応している(ADR-0021 Phase 0+1 の実装。ステータスは Proposed のまま — Accepted 昇格は Phase 2〜3 検証後、その際に ADR-0017 / 0014 の記述追従も実施)
  • N/A — ADR の新規作成・ステータス変更なし

レビュー時の注目点

  • smoke-backend が green であることを必ず確認(Dockerfile の builder 変更が Phase 0 の要。作業環境のネットワークポリシーで Docker Hub pull が拒否されローカル build 未実施)
  • flake.lock の新規 3 ノード: 作業環境では GitHub tarball API が遮断されているため git 経由で同一 rev を取得して narHash を採取し、標準の github 形式に変換して記録した。narHash は tree 内容のハッシュなので両 fetcher で一致する設計だが、手元の nix 環境で nix develop が通ることを一度確認してもらえると確実
  • Phase 1 適用後の初回 nix develop は Python パッケージ群の Nix build が走るため数分かかる(2 回目以降はキャッシュ)

🤖 Generated with Claude Code

https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS

backend 依存の SSoT を手書き requirements.txt から pyproject.toml の
[project.dependencies] + uv.lock へ差し替える。3 経路(ローカル / CI / 本番
Docker)の挙動は変えず、uv2nix 適用(Phase 1 以降)の前提を整備する。

- backend/pyproject.toml: [project] を追加し全依存を == 固定のまま移設。
  CVE ピン留めの根拠コメントも移設(P7 維持)。[tool.uv] package=false
- backend/uv.lock: uv lock で生成しコミット(gitignore から除外)。
  旧 requirements.txt の直接依存 30 件が同一バージョンで解決されることを確認済み
- backend/Dockerfile: builder で uv export により lock から requirements.txt を
  生成し、従来の pip wheel → pip install 経路へ渡す(本番経路の挙動は不変)
- CI(test.yml / mutation.yml): uv sync --locked へ変更(lock drift で fail)。
  pip-audit は lock の全依存(推移的依存込み)を export して監査
- Makefile: install-backend を uv sync 化(.venv は Phase 1 まで維持)
- renovate.json5: pip_requirements → pep621 manager へ(uv.lock も同一 PR で追従)
- scripts/gen-third-party-licenses.py: 収集元を pyproject [project.dependencies] へ
- CLAUDE.md: SSoT 生成物テーブルに pyproject → uv.lock の系統を追加

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmQqSTooETKvU1jDM2mCBS
@github-actions github-actions Bot added the feature 新機能 label Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9dffe61c-7127-4a02-a492-4e3e751abc3d

📥 Commits

Reviewing files that changed from the base of the PR and between 3c34715 and 09970da.

⛔ Files ignored due to path filters (1)
  • backend/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • .claude/CLAUDE.md
  • .claude/skills/SEC_apply/SKILL.md
  • .claude/skills/SEC_review/SKILL.md
  • .github/renovate.json5
  • .github/workflows/mutation.yml
  • .github/workflows/test.yml
  • .gitignore
  • Makefile
  • backend/Dockerfile
  • backend/pyproject.toml
  • backend/requirements.txt
  • scripts/gen-third-party-licenses.py
💤 Files with no reviewable changes (2)
  • backend/requirements.txt
  • .gitignore

📝 Walkthrough

Walkthrough

Backend dependency management now uses backend/pyproject.toml and committed uv.lock as sources of truth. Local setup, Docker builds, CI installation and auditing, license generation, security guidance, and Renovate configuration were updated accordingly.

Changes

Backend dependency migration

Layer / File(s) Summary
Dependency declaration and lock policy
backend/pyproject.toml, .gitignore, .claude/CLAUDE.md, .claude/skills/SEC_apply/SKILL.md
Backend metadata and pinned dependencies now use pyproject.toml; uv.lock is no longer ignored, and lockfile regeneration and pinning guidance were updated.
Local, container, and license integrations
Makefile, backend/Dockerfile, scripts/gen-third-party-licenses.py
Local installation, Docker dependency export, and license generation now consume the updated dependency source and lockfile workflow.
CI synchronization and dependency auditing
.github/workflows/mutation.yml, .github/workflows/test.yml, .claude/skills/SEC_review/SKILL.md
CI installs with uv sync --locked, caches using uv.lock, and audits frozen requirements exported from uv.
Dependency update automation
.github/renovate.json5
Renovate now targets PEP 621 dependencies and documents coordinated uv.lock updates.

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

Possibly related PRs

Suggested labels: refactor

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: migrating backend dependency management to pyproject.toml and uv.lock.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 claude/adr021-07btiv

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.

@github-actions github-actions Bot added documentation Improvements or additions to documentation backend バックエンド ci CI / ワークフロー labels Jul 14, 2026
@yusuke0610
yusuke0610 merged commit 42aa765 into main Jul 15, 2026
24 checks passed
@yusuke0610 yusuke0610 changed the title feat: backend 依存管理を pyproject + uv.lock へ移行(ADR-0021 Phase 0) feat: backend 依存管理の uv.lock 化と devshell の Nix build 化(ADR-0021 Phase 0+1) Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend バックエンド ci CI / ワークフロー documentation Improvements or additions to documentation feature 新機能

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants