Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasestate/queuedQueued for implementation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "プロジェクトに Python 開発依存管理基盤 (pyproject.toml + uv.lock) と CI 実行 job を整備し、必須検証コマンドに Python テストを組み込む"
change_kind: infrastructureParent Issue
なし(単独改善)
Parent Goal Ref
- Goal:
.claude/skills/gemini-cli-headless-delegation/tests/配下の pytest テスト群 (pytest + pyyaml 必須) が CI ゲートとローカル両方で再現可能に実行できる Python 開発依存管理基盤を整備する - 背景: Issue 実装: gemini-cli-headless-delegation のランタイムセットアップテンプレを整備し SubAgent 起動可能状態にする #33 / PR feat: gemini-cli-headless-delegation ランタイムセットアップチェッカーを追加 #38 で gemini-cli-headless-delegation の Python テスト整備が進んだが、依存 (pytest / pyyaml) がプロジェクト依存として固定されておらず、
uv run --with形式の局所指定に依存している。Issue プロジェクトにPython運用基盤を整備 #39 のコメント (プロジェクトにPython運用基盤を整備 #39 (comment)) で「pyproject.toml + uv.lock + CI 別 job」が実務判断として確定 - 関連: PR feat: オーケストレーション skill bash を scripts/ 集約 + allowlist 整備 #37 (
uv run python3wrapper 統一) / PR feat: gemini-cli-headless-delegation ランタイムセットアップチェッカーを追加 #38 (setup_check.py 整備) / Issue 実装: setup_check.py の serena MCP コマンド誤りと trustedFolders.json 破壊バグを修正 (PR #38 hotfix) #41 (setup_check.py hotfix) / Issue 実装: create-issue/references/body-authoring.md に Python テスト系 VC の依存明示パターンを追加する #42 (body-authoring.md VC テンプレ)
Current Validated Scope
- 既存
.claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(pyyaml 必須) をuv run pytest <path>で再現実行できる依存管理を、pyproject.toml+uv.lockで実現 - CI (
.github/workflows/ci.yml) にpython-testjob を pnpm 系 4 job と並列で追加 .claude/rules/project-constitution.mdの必須検証コマンドに Python テスト実行を組み込み
Remaining Parent Gaps
なし
Outcome
pyproject.toml + uv.lock で Python 開発依存 (pytest, pyyaml) が宣言され、uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py がローカルと CI の両方で exit code 0 で完了する。.github/workflows/ci.yml に python-test job が追加されて pnpm 系 4 job と並列実行される。.claude/rules/project-constitution.md の「必須検証」セクションに Python テストコマンドが追記される。
In Scope
pyproject.toml新規作成([project]+[dependency-groups].devに pytest と pyyaml)uv lock実行とuv.lockコミット.github/workflows/ci.ymlにpython-testjob 追加(astral-sh/setup-uv@v5+uv run pytest).claude/rules/project-constitution.mdの必須検証セクションへの Python テストコマンド追記.gitignoreに Python runtime artifacts (.venv/,__pycache__/,.pytest_cache/) 追加(既存確認の上、不足なら追記)
Out of Scope
- 個別 stdlib-only Python script (
edit-issue/open-pr/post-merge-cleanup/create-issue配下) への PEP 723 inline metadata 導入 - pre-commit hook (mypy / black / ruff) 導入
docs/dev/github-ops.mdのuv run python3記載は既存維持(補足追記のみ)- 既存 Python script 群のリファクタリング
Acceptance Criteria
- AC1:
pyproject.tomlが repo ルートに存在し、[dependency-groups].devセクションにpytestとpyyamlが含まれる - AC2:
uv.lockが repo ルートに存在しコミットされている - AC3:
uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pyがローカルで exit code 0 で完了する - AC4:
.github/workflows/ci.ymlにpython-testjob が存在し、astral-sh/setup-uvアクションとuv run pytestステップを含む - AC5: CI 上で
python-testjob が success ステータスになる - AC6:
.claude/rules/project-constitution.mdの必須検証セクションにuv run pytestコマンドが追記されている - AC7:
.gitignoreに.venv//__pycache__//.pytest_cache/が含まれる - AC8: 既存 pnpm 系 4 job (typecheck / lint / test / build) は変更なく pass する
Verification Commands
# AC1
grep -E "pytest|pyyaml" pyproject.toml
# AC2
test -f uv.lock
# AC3
uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py
# AC4
grep -E "python-test|setup-uv" .github/workflows/ci.yml
# AC5
gh run list --workflow=ci.yml --branch=<branch> --limit=1 --json conclusion --jq '.[0].conclusion'
# AC6
grep -E "uv run pytest" .claude/rules/project-constitution.md
# AC7
grep -E "\.venv|__pycache__|\.pytest_cache" .gitignore
# AC8
pnpm typecheck && pnpm lint && pnpm test && pnpm buildAllowed Paths
pyproject.tomluv.lock.github/workflows/ci.yml.claude/rules/project-constitution.md.gitignore
Stop Conditions
- Allowed Paths 外への波及が必要になったら停止し follow-up Issue 起票
- 既存 stdlib-only Python script への PEP 723 metadata 導入の必要が出たら停止(Out of Scope)
- Python script のリファクタリングが必要と判断したら停止(Out of Scope)
- Issue 実装: setup_check.py の serena MCP コマンド誤りと trustedFolders.json 破壊バグを修正 (PR #38 hotfix) #41 (setup_check.py hotfix) が未 merge の場合は 実装: setup_check.py の serena MCP コマンド誤りと trustedFolders.json 破壊バグを修正 (PR #38 hotfix) #41 merge 後に着手する
- CI の pnpm 系 job が regress した場合は即停止
uvバージョン / GitHub Actions のastral-sh/setup-uvバージョン選定で迷ったら停止し人間判断requires-pythonの最低バージョン選定で迷ったら停止し人間判断(参考: 既存 script で使われている stdlib 機能から決定)
Required Skills
- Python packaging (
pyproject.toml, dependency-groups) uvpackage manager (uv lock,uv run)- GitHub Actions (
astral-sh/setup-uv@v5) - pytest
Notes for Reviewer
- 実務判断の根拠コメント: プロジェクトにPython運用基盤を整備 #39 (comment)
- 関連 Issue: 実装: setup_check.py の serena MCP コマンド誤りと trustedFolders.json 破壊バグを修正 (PR #38 hotfix) #41 / 実装: create-issue/references/body-authoring.md に Python テスト系 VC の依存明示パターンを追加する #42 / 実装: gemini-cli-headless-delegation のランタイムセットアップテンプレを整備し SubAgent 起動可能状態にする #33 / 実装: オーケストレーション skill 内 bash を scripts/ 集約 + .claude/settings allowlist 整備で permission prompt を削減する #31
- 関連 ADR / SSOT:
docs/dev/github-ops.md:125,.claude/rules/project-constitution.md
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasestate/queuedQueued for implementation
Activity
squne121 commentedon May 19, 2026
you asked
message time: 2026-05-19 23:39:51
https://github.com/squne121/loop-protocol
● Bash(uv run --with pytest python -m pytest tests/test_model_routing.py::TestLoadModelRouti
ng::test_invalid_yaml_raises_value_error -x 2>&1 | tail -25)
⎿ __________ TestLoadModelRouting.test_invalid_yaml_raises_value_error ___________
● VC preflight 解析: 5 件の既存テスト失敗は pyyaml 未導入が原因(コードバグでなく env
問題)。AC9 は実装者が依存解消(uv run --with pytest --with pyyaml か pyproject.toml
追加)で対処可能 → GO with warning。
上記の問題ってPEP6 ?いくつかでスクリプト本体にライブラリインポートを指定する書き方で解決できるのでは?
それともプロジェクトに仮想環境を導入させたほうが適切か?
chatgpt response
論点は「一時的な実行依存として解くべきか」「プロジェクト依存として固定すべきか」です。まず該当リポジトリの構成と、uv/PEP 723 の仕様を確認して判断します。
現行 main にはその Python テスト名が見えていないため、手元ブランチか未 push 差分の可能性が高いです。ただし原因判定自体は一般化できます。
結論:PEP 6 ではなく、おそらく PEP 723 のことです。
ただし、このケースでは PEP 723 だけで解決するのは不適切寄りです。
PEP 6 は「Bug Fix Releases」の古いプロセス文書で、この話とは関係ありません。(Python Enhancement Proposals (PEPs))
スクリプト本体に依存を書く仕組みは PEP 723 / Inline script metadata です。単一 Python スクリプトに
dependenciesやrequires-pythonを埋め込めます。(Python Packaging)判断
今回のコマンドはこれです。
この場合、
uvが実行している入口は pytest です。つまり、仮に
scripts/model_routing.pyの先頭に PEP 723 メタデータを書いても、pytest実行時に uv がそのスクリプトの依存を自動読取してくれるわけではありません。PEP 723 が効くのは、基本的にこういう実行です。
または uv が対象スクリプトを直接実行する場合です。uv のドキュメントでも、インラインメタデータは「スクリプト自身の依存を宣言し、uv がそのスクリプト実行用環境を作る」用途として説明されています。(Astral Docs)
今回の最小修正
一時的な preflight なら、これでよいです。
uv run --withは呼び出し単位で依存を追加できます。uv 公式ドキュメントでも、依存が必要なスクリプトに対して--with richのように指定する例が示されています。(Astral Docs)ただし、これは 検証コマンドの局所修正であって、プロジェクトの再現性は弱いです。
適切な修正方針
このリポジトリは現行 main では
package.jsonに Vite/Vitest/TypeScript 系の devDependencies が定義されており、Python テスト依存はまだプロジェクト依存として管理されていません。CI も
pnpm install、pnpm test、pnpm buildが中心で、Python/pytest/pyyaml のセットアップは見えません。したがって、Python テストをプロジェクト品質ゲートに含めるなら、pyproject.toml + uv.lock に寄せるべきです。
推奨はこれです。
または手書きなら概ねこうです。
uv は
pyproject.tomlのproject.dependenciesやdependency-groupsをプロジェクト依存として扱えます。開発用依存はdependency-groupsに置ける、という整理です。(Astral Docs)その上で実行はこうします。
CI に入れるなら、Node CI とは別 job で以下を追加します。
使い分け
uv run --with pytest --with pyyaml ...scripts/foo.pypyproject.toml+uv.lock.venv運用実務判断
今回の「5件の既存テスト失敗は pyyaml 未導入が原因」という判定自体は妥当です。
ただし AC9 の対処を 「実装者が
--with pyyamlを付ければよい」だけにするのは弱いです。より良い指示はこうです。
PEP 723 は「単体スクリプトの自己完結性」には有効ですが、pytest で import されるライブラリ/テスト対象コードの依存管理には、プロジェクト依存として固定する方が正しいです。
squne121 commentedon May 19, 2026
Issue 本文 全面リライト完了 (issue-refinement-loop iteration 1)
変更理由
issue-refinement-loop iteration 1 による全面リライト。
元の本文(2 行)は
.github/ISSUE_TEMPLATE/implementation.ymlの必須セクションがすべて欠如しており、#issuecomment-4488974198 の実務判断(pyproject.toml + uv.lock + CI python-test job 追加)が永久仕様として反映されていなかった。変更セクション一覧
## Outcome## In Scope## Out of Scope## Acceptance Criteria- [ ] AC<N>:形式で列挙## Verification Commands## Allowed Paths## Stop Conditions## Required Skills## ReferencesGuard 結果サマリ
# AC<N>8 件 一致)バックアップ
tmp/issue_39_backup_1779205328.mdsqune121 commentedon May 19, 2026
issue-refinement-loop iteration 2: 必須 5 セクション追加 + References → Notes for Reviewer リネーム
変更セクション一覧
## Machine-Readable Contract(contract_schema_version: v1, issue_kind: implementation)## Parent Issue(なし / 単独改善)## Parent Goal Ref(Goal / 背景 / 関連を記載)## Current Validated Scope(検証済みスコープ 3 項目)## Remaining Parent Gaps(なし)## References→## Notes for Reviewer(内容は維持)変更理由
implementation template の必須セクションが 5 つ欠如していたため追加。配置順は
## Outcomeの前(本文先頭)。Issue #42 の単独改善パターンに準拠。Guard 結果
squne121 commentedon May 19, 2026
issue-refinement-loop: 完了 (2026-05-20)
## References→## Notes for Reviewerにリネームしてテンプレ整合issue-contract-reviewskill で着手前 preflight を実施 →implement-issueまたはimpl-review-loopへ🤖 Generated with Claude Code
squne121 commentedon May 19, 2026
Contract Snapshot (2026-05-20)
uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pyがローカルと CI で pass、.github/workflows/ci.ymlに python-test job 追加、.claude/rules/project-constitution.mdの必須検証を更新## Verification Commands参照pyproject.toml,uv.lock,.github/workflows/ci.yml,.claude/rules/project-constitution.md,.gitignore.claude/worktrees/issue-39-python-runtimeworktree-issue-39-python-runtimesqune121 commentedon May 19, 2026
implement-issue: 実装完了 (2026-05-20T00:00:00Z)
.claude/worktrees/issue-39-python-runtimeworktree-issue-39-python-runtimesqune121 commentedon May 19, 2026
impl-review-loop: 完了 (2026-05-20)
次アクション: 人間がマージ判断 (PR #58 にて)。マージ後は post-merge-cleanup skill を起動推奨。
PR 本文末尾に本セッション全体 (refinement-loop + contract-review + impl-review-loop) で観測した運用改善候補 6 件 (観測 A-F) を記載済み。
🤖 Generated with Claude Code
feat: Python 運用基盤整備 (pyproject.toml + uv.lock + python-test CI job) (#39