Repository navigation
実装: E501 migration guard tooling — verify-diff 一体検証(#1138 Child 1) - #1148
Conversation
…hild 1) legacy E501 を SHA 固定・merge-base 差分・AST 同値性・suppression 禁止・テスト保全を一体で fail-closed 検証する単一 verify-diff を追加。 Closes #1144 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1148/ The preview will be removed when this PR is closed. |
LOOP_VERDICT: APPROVE(impl-review-loop / control-plane 最終判断)
AC coverage(決定論的に検証)
gate
merge_ready: true / required_auto_actions: なし。マージは人間が実施してください。 |
|
以下、PR #1148 の敵対的レビューです。 取得できた関連情報は、PR本文・差分・変更ファイル本文・PR本文内の参照(#1144 / #1138 Child 1 / PR #1136 型のテスト破壊)です。関連Issue本文・コメント本文そのものは、この実行では取得できませんでした。そのため、Issue/コメント照合はPR本文上の参照範囲に限定しています。 判定REQUEST_CHANGES 相当。Draftのまま維持。 方向性は良いです。特に「E501 cleanup PR がテストや意味論を壊さず、単一 ただし、現状のまま「信頼境界」「gate tooling」として扱うには、少なくとも1件の致命的な穴があります。 Blocking findings1.
|
… scope canonical / semantic suppression / baseline 明示 / audit report PR #1148 レビュー (issuecomment-4778325233) の Blocking 5点 + hardening を反映。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
敵対的レビュー(#issuecomment-4778325233)対応REQUEST_CHANGES の指摘 5 点 + hardening を反映しました。 1.
|
LOOP_VERDICT (iteration 1): APPROVEOWNER 敵対的レビュー(#issuecomment-4778325233, REQUEST_CHANGES)の Blocking 5 点 + hardening を head Blocker 解消の検証対応
gate
merge_ready: true / required_auto_actions: なし。マージは人間が実施してください。 |
…1163) (#1179) * fix(e501_migration_guard): TypeIgnore 意味論的正規化と --coverage scope モード追加(#1163) - TypeIgnoreSignature(frozen, order=True) dataclassによる構造的アンカー比較 - `owner_ast_path`(最小 stmt への構造パス)で lineno シフトを無視した比較 - `checks.type_ignore_equiv` を report に追加(ok / base_count / head_count / mismatches / ambiguous_anchor) - ast_fingerprint() を 3-tuple 返却(dump, sigs, ambiguous)に更新 - `--coverage scope` オプション追加(デフォルト: changed で後方互換) - `git ls-tree -r -z --full-tree` + `:(literal)<scope>` で NUL-safe に *.py を列挙 - 空 inventory は fail-closed(vacuous pass 防止) - `checks.full_scope_e501` チェックと `e501-migration-guard/v2` schema を追加 - changed_targets と head_scope_targets を分離(二重計数禁止) - 新規テスト 12 本追加(既存 32 テストは無変更): TypeIgnore 系 5 本 + full_scope 系 7 本(実 ruff 含む) Closes #1163 * fix(python-test-plan): scripts/tests/test_e501_migration_guard.py を CI 対象に追加(#1163 Scope Delta) PR #1148 マージ時に python-test-plan.json への登録が漏れていた。 本 PR でテストを追加するため Scope Delta として登録する。 * fix(#1163): TypeIgnoreSignature per-file path + token anchor + file_wide B3 + v2 schema B4 + H1-H3 B1: Add path field to TypeIgnoreSignature; move between files now detected. B2: Add preceding_token_fingerprint via tokenize module for sub-expr detection. B3: _get_stmt_at_line returning None -> file_wide (not ambiguous); test fixed. B4: GuardError in main() uses REPORT_SCHEMA_V2 when --coverage scope. H1: empty changed_targets + cleanup/completion -> policy fail in check_ratchet. H2: enumerate_scope_py_files returns (paths, entries); _inventory_sha256_from_entries includes git blob SHA so inventory digest changes when blob changes. H3: full_scope_e501.diagnostics capped at 100 entries. New tests: test_type_ignore_move_between_files_fails, test_type_ignore_move_within_multiline_statement_fails, test_file_wide_type_ignore_same_top_position_passes, test_line_bound_to_file_wide_fails, test_coverage_scope_tool_error_uses_v2_schema, test_empty_changed_targets_cleanup_fails, test_empty_changed_targets_completion_fails, test_empty_changed_targets_ratchet_passes, test_scope_inventory_digest_changes_when_blob_changes, test_full_scope_failure_reports_diagnostics 54 tests pass (was 44).
概要
#1144(#1138Child 1)の実装です。legacy E501 を base/head の SHA 固定・merge-base 差分・AST 同値性・suppression 禁止・テスト保全を一体で強制する単一verify-diffエントリポイントとして提供し、後続の領域別 cleanup child(#1138 Child 2〜4)と final gate child(Child 5)が安全に E501 を ratchet 解消できる検証 tooling を導入します。変更内容
scripts/e501_migration_guard.py(新規): 唯一の合否判定エントリポイントverify-diffを実装。ref→不変 SHA 固定 → merge-base 解決(HEAD^fallback なし)→git diff --name-status -zによる NUL 区切り manifest(splitlines()不使用)→ status/scope 検査(対象 Python はMのみ許可、A/D/R/C/T/U・scope 外・guard 自身の変更を拒否)→type_comments=True+compile(dont_inherit=True)ベースの AST 同値性 → suppression / config 検査 →--isolated固定設定での Ruff 実行(exit 0/1/2 区別、exit2/timeout/JSON decode 失敗を「0 件」扱いしない)→ per-file / scope 合計 ratchet → 版付き reporte501-migration-guard/v1を stdout に JSON のみで出力(人間向けログは stderr)。すべて fail-closed で一体実行します。scripts/tests/test_e501_migration_guard.py(新規): 各ステップの正常系・異常系に加え、一時 Git リポジトリを用いた subprocess 駆動の E2E mutation suite を実装。PR 実装(#1133): staged Ruff E/F gate を green 化 (E501/E402 除外) #1136 型のテスト破壊(assertion/test body 削除)について、通常 pytest が green でもverify-diffが AST 同値性違反として検出することを検証します。設計上のポイント
uv run --lockedで起動し、内側はruff check --isolated --select E501 --line-length 120 --target-version py312 --no-preview --ignore-noqa --no-respect-gitignore --no-cache --output-format jsonに固定。対象 blob は絶対パスで渡すため Ruff の作業ディレクトリは guard 自身の project root(uv.lockのある場所)に固定し、toolchain の再現性を担保します。verify-diffはscripts/e501_migration_guard.pyとその test が merge-base から変更されている場合をguard_self_changeとして拒否します。shell=True禁止・全 subprocess に timeout・stderr サイズ上限・path containment 検証・一時ディレクトリ確実 cleanup・解析不能時 fail-closed の実装規約を満たします。検証
uv run --locked pytest scripts/tests/test_e501_migration_guard.py(各 AC の named test を含む全件 pass)。scripts/e501_migration_guard.py/scripts/tests/test_e501_migration_guard.pyがruff check --select E,F --ignore E402で診断 0 件であることを、実 ruff を subprocess 起動する pytest テストで検証。pnpm typecheck/pnpm lint/pnpm test/pnpm build(いずれも Python 追加のみのため regression-safe)。スコープ境界
pyproject.toml/uv.lock等の設定変更は本 PR の対象外です。scripts/e501_migration_guard.py/scripts/tests/test_e501_migration_guard.pyの 2 ファイルのみです。Closes #1144