Repository navigation
Closed
Labels
phase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "1059"
goal_ref: "Python 静的検査に Ruff を fast fail-fast gate として導入し、pytest より前段で高速に lint エラーを検知できるようにする"
change_kind: ci-optimizationParent Issue
Parent Goal Ref
CI python-test の直列構造を解消し、test lane を分離・pytest を統合・Ruff を導入・ci-test-performance Skill を追加することで、AI エージェントが CI 高速化判断を再現可能に実行できる状態にする。
Current Validated Scope
pyproject.tomlの[dependency-groups].devにruffは未登録uv.lockにruffpackage は含まれていない.github/workflows/ci.ymlのpython-testjob に Ruff step は存在しないdocs/dev/ci-performance.mdの stable phase_id inventory にruff_checkは未登録
Remaining Parent Gaps
- pytest 統合と pytest-xdist 導入(Child 4)
Outcome
pyproject.toml の dev dependency に ruff>=0.5 が追加され、uv.lock が更新され、.github/workflows/ci.yml の python-test job に Ruff check step が pytest より前に追加され、docs/dev/ci-performance.md の stable phase_id inventory に ruff_check が追加され、CI_TEST_PERFORMANCE_DECISION_V1 を付した状態で pnpm typecheck / pnpm lint / pnpm test / pnpm build がすべて通ること。Ruff gate の実行結果は既存 Ruff violations による non-zero exit を fail evidence として記録し、repo-wide cleanup は follow-up issue に分離すること。
In Scope
pyproject.tomlの[dependency-groups].devにruff>=0.5を追加するuv.lockを更新する(uv lockを実行).github/workflows/ci.ymlのpython-testjob に Ruff check step を pytest 前に追加する- Ruff command を
uv run --locked ruff check --select E,F .claude/scripts scripts schemas .claude/skillsに固定する docs/dev/ci-performance.mdの stable phase_id inventory にruff_checkを追加する- PR 本文または実装証跡コメントに
CI_TEST_PERFORMANCE_DECISION_V1を残す
Out of Scope
- Ruff の設定ファイル(
ruff.toml/pyproject.tomlの[tool.ruff])の詳細チューニング - 既存 Ruff violations の repo-wide cleanup / 全修正(fail evidence の記録は行うが、cleanup は follow-up issue に分離する)
- pytest invocation の統合や
pytest-xdistの導入(実装: pytest target plan を SSOT 化し serial→xdist 段階移行と ci_test_selection fail-close 化を行う(python-test 並列化 migration) #1064 scope) docs/dev/ci-performance.md以外の docs 変更
Runtime Verification Applicability
- decision: not_applicable
- reason: Python lint / dependency lockfile / CI workflow / CI baseline inventory の静的変更で完結し、ブラウザやゲーム実行を伴う runtime verification を要求しないため
Acceptance Criteria
- AC1:
pyproject.tomlの[dependency-groups].devにruff>=0.5が追加されていること - AC2:
uv.lockにruffpackage が解決済みであること - AC3:
.github/workflows/ci.ymlのpython-testjob に Ruff check step が存在すること - AC4: Ruff gate step が存在し、Ruff command が
uv run --locked ruff check --select E,F .claude/scripts scripts schemas .claude/skillsであり、--fix/--exit-zero/--add-noqaを使わないこと。実行結果は既存 Ruff violations による non-zero exit を fail evidence として記録し、repo-wide cleanup は Out of Scope であること - AC5:
docs/dev/ci-performance.mdの stable phase_id inventory にruff_checkが追加されていること - AC6:
pnpm typecheckが exit 0 を返すこと - AC7:
pnpm lintが exit 0 を返すこと - AC8:
pnpm testが exit 0 を返すこと - AC9:
pnpm buildが exit 0 を返すこと
Verification Commands
# AC1
# baseline-expect: fail
$ rg -n ruff pyproject.toml# AC2
# baseline-expect: fail
$ rg -n '^name = "ruff"$' uv.lock# AC3
# baseline-expect: fail
$ rg -n 'Ruff check' .github/workflows/ci.yml# AC4
# baseline-expect: fail
# 既存 Ruff violations は fail evidence として記録する。repo-wide cleanup は follow-up issue に分離する。
# preflight-scope: pr_review_only
$ uv run --locked ruff check --select E,F .claude/scripts scripts schemas .claude/skills# AC5
# baseline-expect: fail
$ rg -n 'ruff_check' docs/dev/ci-performance.md# AC6
# baseline-expect: pass
$ pnpm typecheck# AC7
# baseline-expect: pass
$ pnpm lint# AC8
# baseline-expect: pass
$ pnpm test# AC9
# baseline-expect: pass
$ pnpm buildAllowed Paths
.github/workflows/ci.ymlpyproject.tomluv.lockdocs/dev/ci-performance.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 既存 Ruff violations の cleanup が本 Issue の Scope を超えると判明した場合(cleanup は follow-up issue に分離する)
Required Skills
- GitHub Actions YAML
- Python packaging (pyproject.toml / uv)
- Ruff
- ci-test-performance
Delivery Rule
1 Issue = 1 PR。worktree を作成して実装する。Draft PR で起票し、CI が通ったことを確認してから draft を外す。PR 本文または実装証跡コメントに CI_TEST_PERFORMANCE_DECISION_V1 を添付する。Depends on #1061 merge。
Metadata
Metadata
Assignees
Labels
phase/implementationImplementation phase
Activity
squne121 commentedon Jun 22, 2026
結論
#1063 は方向性としては妥当です。Ruff を
python-testの pytest 前段に置く判断は、親 #1059 の「Ruff fast-static lane 付き」「pyproject/uv.lock に ruff 追加」という到達点と整合しています。 Ruff 公式も、Ruff を Rust 製の高速 Python linter/formatter と説明しており、ruff checkはディレクトリを再帰的に lint できます。([Astral Docs]1) ([Astral Docs]2)ただし、現状の #1063 はそのまま実装に流すには弱いです。判定は
REQUEST_CHANGES / 着手前 BLOCKED寄りです。理由は、AC/VC が grep 依存で偽陽性を許し、ci-test-performanceの gate・runtime applicability・CI runtime baseline との整合が不足しているためです。#1063 自体のコメントは空なので、Issue 本文と repo 側の既存契約だけで判断する必要があります。主要 blocker
1.
Runtime Verification Applicabilityが欠落しているこのリポジトリの runtime verification policy は、全 Issue に
not_applicable | immediate | deferredの適用判定を明示することを要求しています。 さらにimplement-issueは、このセクションがない場合にnot_applicableと推定せず停止する設計です。#1063 は CI 静的検査・依存追加なので、以下を追加すべきです。
2.
Required Skillsにci-test-performanceがない#1063 は
.github/workflows/ci.yml、pyproject.toml、uv.lockを触る Issue です。ci-test-performanceSkill は、GitHub Actions、Ruff、pytest、xdist、CI artifact 関連の変更前に読む前提で定義されています。 また consumer routing では、implementation-worker が CI 関連 path 編集前にこの Skill を読み、PR 本文または artifact にCI_TEST_PERFORMANCE_DECISION_V1を残すことになっています。#1060 と PR #1078 で Skill と consumer routing は追加済みですが、Claude Code agent 側の直接 routing 追記は #1097 としてまだ open です。 したがって #1063 側で明示しないと、実装エージェントが読まずに進むリスクがあります。
修正案:
3. 現在の VC は AC を証明できない
#1063 の VC は
rg -c "ruff" pyproject.toml、rg -c "ruff" uv.lock、rg -n "ruff" .github/workflows/ci.yml程度です。 これはコメント・文字列・無関係セクションに反応するため、以下を証明できません。ruffが[dependency-groups].devに入ったことuv.lockに実パッケージとして解決されたことuv run --lockedで lockfile 整合を強制していること--exit-zero、--fix、--add-noqaを使っていないことRuff 公式は
ruff checkの exit code を、違反なし0、違反あり1、設定/CLI/内部エラー2と定義し、--exit-zeroは違反があっても0にする、と説明しています。([Astral Docs]2) ([Astral Docs]2) CI gate では--exit-zeroを明示禁止すべきです。4. Outcome と AC がズレている
#1063 の Outcome は
pnpm typecheck / test / buildが通ることを要求していますが、AC にはpnpm buildがありません。 さらに repo の品質ゲートはpnpm typecheck、pnpm lint、pnpm test、pnpm buildを基本にしています。CI workflow 変更は
ci-test-performanceの判断マトリクス上、fast_static / python_unit / contract_artifact / integration の全レーン対象です。 少なくともpnpm lintとpnpm buildも AC/VC に入れるべきです。5.
ci_runtime_baseline_v1の phase inventory と衝突する現行
docs/dev/ci-performance.mdの stable phase_id 一覧にはruff_check相当がありません。 一方、#1063 は “fast fail-fast gate” として CI に Ruff step を追加します。計測対象にするならruff_checkphase を docs に追加すべきですが、#1063 の Allowed Paths は.github/workflows/ci.yml、pyproject.toml、uv.lockのみです。ここは二択です。
推奨は Allowed Paths に
docs/dev/ci-performance.mdを追加し、ruff_checkphase_id を stable inventory に追記することです。そうしない場合は、PR 本文で「Ruff step は今回 unmeasured guard として扱い、phase inventory 追加は follow-up」と明記する必要があります。ただし #1059 はci_runtime_baseline_v1before/after 比較を親ゴールにしているため、unmeasured 扱いは弱いです。改善後の #1063 契約案
Acceptance Criteria 差し替え案
Verification Commands 差し替え案
uv 側は
[dependency-groups]のdevが development dependencies の標準置き場であり、devgroup は既定でuv run/uv syncに含まれます。([Astral Docs]3) またuv run --lockedは lockfile が最新でなければエラーにするため、CI gate と相性がよいです。([Astral Docs]4)実装時の推奨 CI step
python-testは既にuv sync --locked --group devを実行してから pytest 群に進む構造です。 Ruff はその直後、pytest より前に置くのが自然です。ただし、この
ruff_checkを runtime baseline に入れるならdocs/dev/ci-performance.mdの stable phase_id inventory も同期してください。同期しないなら PR 本文に「unmeasured guard」として扱う理由と follow-up を明記するべきです。#1064 との衝突リスク
#1064 は
pyproject.toml/uv.lock/.github/workflows/ci.ymlを同じく触り、pytest-xdist と pytest invocation 統合を行う予定です。 つまり #1063 と #1064 は Allowed Paths が重なります。#1063 を先に入れ、#1064 側で Ruff step を壊さないようにする順序が妥当です。pytest-xdist は
pytest -n autoで物理 CPU core 数の worker を使い速度改善が見込めますが、--dist loadは順序保証なし、loadscope/loadfileは group 単位で同じ worker に寄せる選択肢です。(pytest-xdist) また xdist では worker 間で test order / amount が一致しないテストは扱えず、unordered set を使った parametrization が典型的な失敗要因です。(pytest-xdist) #1063 の Ruff 追加は #1064 の統合 pytest 作業から明確に分離しておくべきです。最終判断
#1063 は 修正すれば実装価値ありです。ただし現契約のままでは、実装後に「Ruff らしき文字列はあるが CI gate として成立しているか不明」「
CI_TEST_PERFORMANCE_DECISION_V1がない」「runtime baseline inventory が stale」というレビュー不能状態になりやすいです。最低限、次を直してから Claude Code / Codex CLI に渡すべきです。
Runtime Verification Applicability: not_applicableを追加。Required Skillsにci-test-performanceとRuffを追加。uv run --locked ruff checkに変更。pnpm lint/pnpm buildを AC/VC に追加。CI_TEST_PERFORMANCE_DECISION_V1の提出を AC 化。ruff_checkを baseline phase として計測するならdocs/dev/ci-performance.mdを Allowed Paths に追加。squne121 commentedon Jun 22, 2026
編集内容
Delivery Ruleの依存先を#1060から#1061に最小修正しました。依存記述
Depends on #1060 merge.Depends on #1061 merge.Guard 結果
check_vc_scope.py: PASSguard-issue-body.py: all_passedissue_contract_hygiene_autofix.py: no_changecontract_readiness_check.py: goready_tuple: PASSsqune121 commentedon Jun 22, 2026
更新内容
Verification Commandsの注釈だけを最小修正しました。# baseline-expect: failに変更しました。# baseline-expect: deferredに変更し、VC preflight から外しました。確認結果
check_vc_scope.py: PASSguard-issue-body.py: PASSissue_contract_hygiene_autofix.py: no_changecontract_readiness_check.py --mode static: gosqune121 commentedon Jun 22, 2026
Contract Review Result
squne121 commentedon Jun 22, 2026
更新内容
baseline-expect: deferredをfailに変更し、既存 Ruff violations を fail evidence として記録する注記を追加しました。Guard 結果
check_vc_scope.py: PASSguard-issue-body.py: PASScontract_readiness_check.py --mode static: gosha256:80319f92236de245c31c3fdc3b3fa00421ea9ab3882dd0e26b5a75a122298a1dci: add Ruff fast-static gate before pytest (#1063)
squne121 commentedon Jun 22, 2026
CONTRACT_REVIEW_RESULT_V1
status: go
body_sha256: c6efbb7e6751751d60d5304b2cfee236c2be42910820cb5a74f8ffd0a79ed5b5
mode: static
checks:
readiness: go
blockers: pass
product_spec: pass
vc_preflight: pass
AC4 VC preflight-scope: pr_review_only 追加済み。uv run --locked ruff check は preflight skip (pr_review_only)。AC1-AC3/AC5 expected_baseline_fail go。AC6-AC9 regression_gate pass。
ci: add Ruff fast-static gate before pytest (#1129)