Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Parent Issue
Machine-Readable Contract
contract_schema_version: "1"
issue_kind: implementation
parent_issue: "#1138"
goal_ref: "E501 段階導入の完全完了"
change_kind: cleanupParent Goal Ref
#1138 の Goal: .claude/ と scripts/ 配下の E501 違反を段階的に解消し、CI E501 gate を有効化する。
Current Validated Scope
- Child 1〜4 (実装: E501 migration guard tooling — baseline 再生成 + changed-file ratchet + AST 同値性 + suppression 検出(#1138 Child 1) #1144, 実装:
scriptsの E501 cleanup(既存*.pyの行分割のみ・#1138 Child 3) #1156, fix(e501_migration_guard): TypeIgnore 意味論的正規化と full-scope completion モード追加(#1156 前提) #1163, 実装: .claude/skills の E501 cleanup(313 件・#1138 Child 4) #1187) はマージ済み - 残存する E501 は fresh inventory(2026-06-27)で以下の通り確定:
scripts/agent-guards/local_main_branch_guard.py2 件scripts/agent-guards/skill_runtime_command_policy.py3 件scripts/agent-guards/skill_runtime_exec.py1 件scripts/agent-guards/tests/test_controlled_skill_mutation_exec.py3 件scripts/ci/codex_execpolicy_matrix.py5 件scripts/ci/tests/test_codex_execpolicy_matrix.py1 件scripts/tests/test_pr_body_validator.py3 件.claude/skills/issue-contract-review/scripts/tests/15 件.claude/skills/issue-refinement-loop/tests/5 件.claude/skills/issue-refinement-loop/scripts/tests/0 件(対象外・確認済み)
Remaining Parent Gaps
- 実装: 全領域再検証 + CI global gate 有効化(E501 / #1138 Child 5) #1188(CI ruff E501 gate 追加)は本 Issue マージ後に再 preflight が必要
Outcome
対象 scripts/ 7 ファイルおよび .claude/skills/ テスト 2 ディレクトリで uv run --locked ruff check --select E501 --ignore-noqa が exit 0(0 errors)を返すコミットが main にマージされており、#1188 の 1 行変更(--ignore E501,E402 → --ignore E402)だけで CI gate が有効化できる状態になっている。
In Scope
scripts/agent-guards/local_main_branch_guard.pyの E501 違反修正(2 件)scripts/agent-guards/skill_runtime_command_policy.pyの E501 違反修正(3 件)scripts/agent-guards/skill_runtime_exec.pyの E501 違反修正(1 件)scripts/agent-guards/tests/test_controlled_skill_mutation_exec.pyの E501 違反修正(3 件)scripts/ci/codex_execpolicy_matrix.pyの E501 違反修正(5 件)scripts/ci/tests/test_codex_execpolicy_matrix.pyの E501 違反修正(1 件)scripts/tests/test_pr_body_validator.pyの E501 違反修正(3 件).claude/skills/issue-contract-review/scripts/tests/配下の E501 違反修正(15 件).claude/skills/issue-refinement-loop/tests/配下の E501 違反修正(5 件)- Ruff fixed condition で E501 diagnostic 0 件にする(repo の line-length=120 を維持)
- 物理的な全行長制約(79/120 文字以内)は要求しない
Out of Scope
src/配下の変更- E501 以外の ruff ルールの変更
.claude/skills/issue-contract-review/scripts/(tests/ 以外)の変更.claude/skills/issue-refinement-loop/scripts/(tests/ 以外)の変更.claude/skills/issue-refinement-loop/scripts/tests/(E501 違反 0 件のため対象外)- 実装: 全領域再検証 + CI global gate 有効化(E501 / #1138 Child 5) #1188 の CI gate 追加(実装: 全領域再検証 + CI global gate 有効化(E501 / #1138 Child 5) #1188 の責務)
scripts/配下の上記 7 ファイル以外の変更
Acceptance Criteria
- AC1: 対象
scripts/配下 7 ファイルで E501 が 0 件 - AC2:
.claude/skills/issue-refinement-loop/tests/配下で E501 が 0 件 - AC3:
.claude/skills/issue-contract-review/scripts/tests/配下で E501 が 0 件 - AC4: pnpm typecheck が pass する
- AC5: pnpm lint が pass する
- AC6: pnpm test が pass する
- AC7: pnpm build が pass する
- AC8:
uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/が pass する - AC9:
uv run --locked pytest .claude/skills/issue-refinement-loop/tests/が pass する - AC-H1:
uv run --locked ruff check --select E501 --ignore-noqa .claude/scripts scripts schemas .claude/skillsが exit 0 - AC-H2:
uv run --locked ruff check --select E,F --ignore E402 .claude/scripts scripts schemas .claude/skillsが exit 0 - AC-H3: 実装: 全領域再検証 + CI global gate 有効化(E501 / #1138 Child 5) #1188 は
.github/workflows/ci.ymlの--ignore E501,E402から--ignore E402への 1 行変更だけで実装可能な状態になる - AC-G1:
scripts/e501_migration_guard.py verify-diffの report がdecision == "pass" - AC-G2: 変更ファイルは status M のみ(add/delete/rename/copy なし)
- AC-G3: AST / TypeIgnore equivalence が pass
- AC-G4: suppression / config broadening がない
- AC-G5:
ruff.cmd_source == "default"かつnon_default_ruff_cmd == false
Runtime Verification Applicability
- decision: not_applicable
- reason: E501 の lint-only cleanup であり、実行時挙動・プロセス起動・通信・I/O は変化しない。静的検証(ruff / pnpm typecheck / pytest)のみで完結する。
Verification Commands
# AC1
# preflight-scope: pr_review_only
$ uv run --locked ruff check --select E501 --ignore-noqa scripts/agent-guards/local_main_branch_guard.py scripts/agent-guards/skill_runtime_command_policy.py scripts/agent-guards/skill_runtime_exec.py scripts/agent-guards/tests/test_controlled_skill_mutation_exec.py scripts/ci/codex_execpolicy_matrix.py scripts/ci/tests/test_codex_execpolicy_matrix.py scripts/tests/test_pr_body_validator.py
# AC2
# preflight-scope: pr_review_only
$ uv run --locked ruff check --select E501 --ignore-noqa .claude/skills/issue-refinement-loop/tests/
# AC3
# preflight-scope: pr_review_only
$ uv run --locked ruff check --select E501 --ignore-noqa .claude/skills/issue-contract-review/scripts/tests/
# AC4
# preflight-scope: pr_review_only
$ pnpm typecheck
# AC5
# preflight-scope: pr_review_only
$ pnpm lint
# AC6
# preflight-scope: pr_review_only
$ pnpm test
# AC7
# preflight-scope: pr_review_only
$ pnpm build
# AC8
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/ -x
# AC9
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -x
# AC-H1
# preflight-scope: pr_review_only
$ uv run --locked ruff check --select E501 --ignore-noqa .claude/scripts scripts schemas .claude/skills
# AC-H2
# preflight-scope: pr_review_only
$ uv run --locked ruff check --select E,F --ignore E402 .claude/scripts scripts schemas .claude/skills
# AC-G1
# preflight-scope: pr_review_only
$ uv run --locked python scripts/e501_migration_guard.py verify-diff --base-ref HEAD --head-ref HEAD --scope scripts --mode completion --coverage scopeAllowed Paths
scripts/agent-guards/local_main_branch_guard.pyscripts/agent-guards/skill_runtime_command_policy.pyscripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/tests/test_controlled_skill_mutation_exec.pyscripts/ci/codex_execpolicy_matrix.pyscripts/ci/tests/test_codex_execpolicy_matrix.pyscripts/tests/test_pr_body_validator.py.claude/skills/issue-contract-review/scripts/tests/.claude/skills/issue-refinement-loop/tests/
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
.github/.claude/skills/の SKILL.md や非テストスクリプトを変更する場合は Stop して human 判断を仰ぐ- E501 修正で既存テストの意味が変わる場合は Stop して human 判断を仰ぐ
src/やtests/(ゲームコード) を変更する必要が生じた場合は Stop して human 判断を仰ぐ- 修正によって新規 lint エラーが発生した場合は Stop して human 判断を仰ぐ
- ruff --fix 自動修正が意味のある変更を行う場合は Stop して差分を確認する
- E501 修正で正規表現・argv 順序・パス等の意味が変わる場合は Stop して human 判断を仰ぐ
Required Skills
なし
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR。worktree: worktree-issue-<N>-e501-tests-scripts-cleanup。Draft PR で開始。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Jun 27, 2026
判定: REQUEST_CHANGES
#1213 は方向性としては必要です。#1188 を final gate 専用に戻すため、
scripts/残存 E501 と一部 skill test 配下の E501 を先に潰す判断は妥当です。ただし、現行契約のまま実装すると #1138 の ratchet migration 契約と #1188 の前提証明として弱い です。#1213 自体はコメント 0 件で、本文上は
scripts/、.claude/skills/issue-contract-review/scripts/tests/、.claude/skills/issue-refinement-loop/tests/の E501 cleanup を目的にしています。一方で #1188 は
.github/workflows/ci.ymlの Ruff command だけを変える final gate Issue であり、Python cleanup は Out of Scope です。 #1188 のレビューでも、scripts/残存 5 件を #1188 に持ち込むのは契約衝突だと明確に指摘されています。Blocker
B1. 「79 文字以内」は親契約・実装・Ruff仕様と矛盾する
#1213 の In Scope は「79 文字以内」と書いていますが、親 #1138 と repo 設定は
line-length=120基準です。pyproject.tomlも Ruff line-length を 120 に設定しています。 guard 側も固定 Ruff 引数で--line-length 120 --target-version py312を使っています。さらに Ruff E501 は「物理的に全行を N 文字以下にする」規則ではなく、単一長語、閾値前から始まる末尾 URL、pragma、SPDX / copyright などの例外があります。したがって #1213 の成功条件は 「固定 Ruff 条件で E501 diagnostic が 0 件」 に限定すべきです。([Astral Docs]1)
修正案:
行分割・文字列リファクタリングによる 79 文字以内への収めを削除し、次に置換。B2. #1188 preflight を満たす全領域再検証が AC にない
#1213 の Outcome は 3 scope の E501=0 だけです。しかし #1188 が要求するのは
.claude/scripts scripts schemas .claude/skillsの 4 領域全体で E501=0 と E/F green です。#1213 は #1188 の前提を作る Issue なので、変更対象は限定しつつ、検証 AC は #1188 と同じ全領域 preflight まで含める 必要があります。
追加すべき AC:
B3.
scripts/Allowed Paths が広すぎる#1159 は
scripts/の残存 E501 を 2 ファイル 5 件として記録しています。内訳はscripts/agent-guards/local_main_branch_guard.py2 件とscripts/tests/test_pr_body_validator.py3 件です。 #1187 側も同じ残存 5 件を別 PR / 別 Issue で対応すべきと明記しています。それにもかかわらず #1213 は
scripts/全体を Allowed Paths にしています。これは不要な cleanup、周辺ロジック変更、test plan 変更の混入を許します。修正案:
scripts/は全体許可ではなく、まず以下に絞るべきです。実装開始時の fresh E501 JSON inventory で別ファイルに新規残存が見つかった場合は、#1213 本文を更新してから着手するべきです。
B4. skill test scope が曖昧で、
issue-refinement-loop/scripts/tests/を取りこぼす恐れがある#1213 は
.claude/skills/issue-refinement-loop/tests/を対象にしていますが、repo には.claude/skills/issue-refinement-loop/scripts/tests/test_repair_issue_contract.pyも存在します。 また #1202 のレビュー文脈ではissue-refinement-loop/scripts/tests/周辺の test plan typo が実際に問題化していました。ここは fresh inventory で確定すべきです。対象が本当に
.claude/skills/issue-refinement-loop/tests/だけなのか、scripts/tests/も残存 E501 を持つのかを JSON で出してください。B5. guard
verify-diffが AC にない#1138 は E501 cleanup を単なる Ruff 実行ではなく、AST 同値性・suppression 禁止・ratchet を含む migration として設計しています。 実装済み guard も、
verify-diffを単一 fail-closed entrypoint とし、ref SHA 固定、merge-base、NUL manifest、AST equivalence、suppression scan、Ruff fixed args、ratchet、versioned report を行う設計です。#1213 の AC は直接 Ruff と pytest だけなので、#1138 の安全性契約を満たしません。Ruff は CLI option が設定ファイルより高優先度であり、suppression も
# noqa、file-level suppression、range suppression、config ignore/per-file-ignore など複数あります。([Astral Docs]2) ([Astral Docs]2)追加すべき AC:
B6. 検証コマンドが弱い
現在の #1213 は
pnpm typecheckとpnpm lintだけで、pnpm test/pnpm buildがありません。#1138 系 child では repository 標準 gate としてpnpm typecheck / lint / test / buildを求めてきた流れがあります。また、
uv run pytestは--lockedを付けるべきです。Ruff の exit code 2 は設定・CLI・内部エラーであり、診断 0 件扱いにしてはいけません。([Astral Docs]2)--add-noqaや--exit-zeroも明示的に禁止すべきです。([Astral Docs]2)修正版 Verification Commands 案
issue-refinement-loop/scripts/tests/に残存 E501 がある場合は、上記 scope に追加してください。現時点の #1213 本文だけでは、この取りこぼしを否定できません。実装時の高リスク箇所
local_main_branch_guard.pyは# type: ignore[misc]を含み、TypeIgnore の行位置が AST 比較に絡みます。Python 公式 AST でもTypeIgnore(lineno, tag)はtype_comments=True時に扱われ、単なるコメントではありません。 ([Python documentation]3)また同ファイルは regex、shell command classifier、GitHub CLI 引数分類を多く持つため、文字列・正規表現・argv 順序の変更は AST 同値だけでは安全と言い切れません。
test_pr_body_validator.pyは fixture path、CLI argv、markdown body 期待値を含みます。長いFIXTURE_DIR、helper signature、NamedTemporaryFile、cmdlist は括弧展開で安全に直せますが、パス・引数順・default linked issue を変えてはいけません。#1188 への正しいハンドオフ
現在の CI は
python-testjob でfetch-depth: 0を既に設定しています。actions/checkoutはデフォルトでは単一コミットのみ取得し、fetch-depth: 0で全履歴を取得する仕様なので、#1188 で checkout 設定を追加変更する必要は基本的にありません。([GitHub]4)一方、現行 Ruff step はまだ
--ignore E501,E402です。 #1213 マージ後の #1188 は、原則この 1 行だけを以下に変える Issue に戻すべきです。貼り付け用レビューコメント
最終判断: #1213 は 起票意図は正しいが、契約がまだ実装開始水準に達していません。先に契約を締め直すべきです。
squne121 commentedon Jun 27, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 27, 2026
squne121 commentedon Jun 27, 2026
Issue Contract Review
VC preflight 適用した simple_contract_hygiene_fix
uv run ruff check/uv run python→command_not_allowed→preflight-scope: pr_review_onlyを付与(VC 意味論変更なし)preflight-scope: pr_review_onlyを付与preflight-scope: pr_review_onlyを付与uv run pytest issue-refinement-loop/tests/ -x→ exit 0, 1001 items PASS ✓fix(#1213): scripts/ tests/ 配下の残存 E501 違反を解消
fix(#1213): scripts/ tests/ 配下の残存 E501 違反を解消
fix(#1213): E501 fix for _wbe_exec_command fallback in local_main_bra…
fix(#1213): scripts/ tests/ 配下の残存 E501 違反を解消 (#1218)
squne121 commentedon Jun 28, 2026
post-merge-cleanup: 完了 (2026-06-28T02:30:00Z)