Repository navigation
fix(e501_migration_guard): TypeIgnore 意味論的正規化と --coverage scope モード追加(#1163) - #1179
Conversation
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-1179/ The preview will be removed when this PR is closed. |
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: eb33eed
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: BEHIND
blockers: []
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue.update_branch
blocking_merge_ready: true
mechanical: true
expected_head_sha: eb33eed
reason: python-test required CI が FAILURE。実テストは全 pass だが step25 ci_test_selection artifact 生成が失敗。BEHIND 状態起因、update_branch で解消見込み。
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files: [scripts/e501_migration_guard.py, scripts/tests/test_e501_migration_guard.py]
contract_allowed_paths: [scripts/e501_migration_guard.py, scripts/tests/test_e501_migration_guard.py]
contract_source_kind: issue_comment
source_id: 4804618088
expected_contract_fingerprint: body_sha256:c3e29b13b33c012f31132aa3fe8fc878f431ee77c7250703e302d31f298be9c9
LOOP_VERDICT_V2verdict: REQUEST_CHANGES
reviewed_head_sha: 9a37d4422b3ee8cac7411ab283c1977dd08a0521
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers:
- id: allowed_paths_gate_fail_closed
detail: .github/ci/python-test-plan.json は Contract Snapshot issuecomment-4804618088 の Allowed Paths に含まれない。PR 本文の Scope Delta 宣言は CONTRACT_REVIEW_RESULT_V1 更新を伴わないため contract amendment 不成立。
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: fail_closed
producer_role: review_subagent
worker_report_used_as_canonical: false
changed_files:
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
- .github/ci/python-test-plan.json
contract_allowed_paths:
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
out_of_contract_files:
- .github/ci/python-test-plan.json
contract_source_kind: issue_comment
source_id: 4804618088
expected_contract_fingerprint: body_sha256:c3e29b13b33c012f31132aa3fe8fc878f431ee77c7250703e302d31f298be9c9
fail_reason: .github/ci/python-test-plan.json が Contract Snapshot の Allowed Paths に存在しない。PR 本文 Scope Delta 宣言は CONTRACT_REVIEW_RESULT_V1 更新なしのため contract amendment 不成立。CI 証拠サマリーCI_CHECK_RUN_SCOPED(head: 9a37d44): python-test SUCCESS / node-backed-hook-tests SUCCESS / typecheck/lint/test/build/e2e SUCCESS / actionlint/ci-verdict-summary SUCCESS / PR Body Japanese Check SUCCESS。CI 全 SUCCESS。ただし allowed_paths_gate fail_closed のため merge_ready は false。 解消手順以下のいずれかを実施する。推奨: Issue 1163 本文の Allowed Paths に .github/ci/python-test-plan.json を追加して contract-review を再実行し、新しい CONTRACT_REVIEW_RESULT_V1 を取得する。代替: .github/ci/python-test-plan.json の変更を別 PR に分離し本 PR を Allowed Paths 2 ファイルのみに戻す。 AC Coverage(参考)PR 本文の AC1-AC12 自己申告が揃い CI 証跡も対応。allowed_paths_gate を除けば APPROVE 条件を満たしている。 |
LOOP_VERDICT_V2verdict: REQUEST_CHANGES
reviewed_head_sha: 9a37d4422b3ee8cac7411ab283c1977dd08a0521
merge_ready: false
mergeability:
mergeable: CONFLICTING
merge_state_status: DIRTY
blockers:
- CONFLICTING: .github/ci/python-test-plan.json にマージコンフリクトがある。PR #1168 が同ファイルの targets 配列に scripts/tests/test_pr_body_validator.py を追加してメインにマージされ、PR #1179 は同配列への scripts/tests/test_e501_migration_guard.py 追加と競合している。リベース後に両エントリを保持するよう解消すること。
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue.update_branch
mechanical: true
blocking_merge_ready: true
expected_head_sha: 9a37d4422b3ee8cac7411ab283c1977dd08a0521
note: .github/ci/python-test-plan.json の targets 配列に両エントリを保持してリベース後プッシュする
- kind: update_pr_body_hygiene
executor: implementation-worker
skill: open-pr.update_pr
mechanical: true
blocking_merge_ready: true
note: AC9 証跡補完。Schema Change Applicability(not_schema_change: v1 変更なし、v2 は --coverage scope 専用新規追加)と既存 consumer 一覧(ci.yml / generate_ci_test_selection_artifact.py は v1 を消費)および互換性判断(backward-compatible additive)を PR 本文に明記する。
auto_fix_applied: []
follow_up_issue_requests: [] |
判定根拠(pr-review-judge 証跡)CI 証拠(CI_VERDICT_SUMMARY_V1)ci_verdict_summary.py 実行済み(head SHA: 9a37d44) status: all_pass
head SHA 一致確認済み。 Mergeability 判定gh pr view 1179 --json mergeable,mergeStateStatus が DIRTY / CONFLICTING を返した。 PR base SHA 0051eab(旧 main HEAD)に対し、main HEAD 2c280ce(PR #1168 マージ済み)が .github/ci/python-test-plan.json を変更したため競合が発生。PR #1168 は scripts/tests/test_pr_body_validator.py を同ファイルの targets 配列に追加済み。 Contract Snapshot 確認Contract Snapshot: #1163 (comment)
Allowed Paths Gate(ALLOWED_PATHS_GATE_RESULT_V1)status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
expected_contract_fingerprint: 410eabd9a1a74563e5c3f818bb36be7a15a8c9b574ca4356d4af45884e7b7957
contract_source_kind: issue_comment
contract_source_id: 4809938513
allowed_paths:
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
- .github/ci/python-test-plan.json
changed_files:
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
- .github/ci/python-test-plan.json
violations: []全変更ファイル 3 件が Allowed Paths 内。逸脱なし。 AC Coverage 確認
AC9 スキーマ証跡の補完が必要AC9「report schema 変更について consumer inventory と互換性判断を明記する」の PR 証跡が rg -n e501-migration-guard/v2 の存在確認のみ。 PR 本文に以下の追記が必要:
実装的には backward-compatible であることは確認済み。 Safety-sensitive 判定変更パス(scripts/、.github/ci/)は safety boundary 対象外。Safety Claim Matrix 不要。 |
…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
9a37d44 to
a80eaf6
Compare
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2 (iteration 0, 2回目レビュー)
verdict: APPROVE
reviewed_head_sha: a80eaf6
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
schema: ALLOWED_PATHS_GATE_RESULT_V1
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
contract_source_kind: issue_comment
contract_source_id: 4809938513
expected_contract_fingerprint: body_sha256:410eabd9a1a74563e5c3f818bb36be7a15a8c9b574ca4356d4af45884e7b7957
allowed_paths:
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
- .github/ci/python-test-plan.json
changed_files:
- .github/ci/python-test-plan.json
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
violations: []
squne121
left a comment
There was a problem hiding this comment.
判定根拠(verdict: APPROVE)
前回 REQUEST_CHANGES の解消確認:
- CONFLICTING 解消: mergeStateStatus=CLEAN / mergeable=MERGEABLE 確認済み(head SHA a80eaf6 でのリベース完了)
- AC9 証跡補完: PR 本文に schema_change_applicability=not_schema_change・既存 consumer (#1156 PR reviewer / e501-guard-report.json schema フィールド)・互換性判断(backward-compatible additive、v1 は --coverage changed 既定値で継続)が明記済み
CI 証拠(CI_CHECK_RUN_SCOPED / head SHA a80eaf6 一致):
run 28241492944(workflowName=ci)conclusion=success
- python-test: success(pytest parallel + serial lane 含む)
- build: success, lint: success, typecheck: success, test: success
- e2e: success, actionlint: success, ci-verdict-summary: success
- node-backed-hook-tests: success
run 28241492912(check-hook-integrity)conclusion=success
run 28241493074(agent-session-manifest)conclusion=success
run 28241510690(Check Japanese Content)conclusion=success
Allowed Paths Gate: 変更 3 ファイル全て contract Allowed Paths 内。contract snapshot #4809938513(status=go)確認済み。contract binding 確立(body_sha256=410eabd9a1a74563e5c3f818bb36be7a15a8c9b574ca4356d4af45884e7b7957 一致)。
AC coverage: 全 AC1-AC12 が PR 本文に根拠付きで記載。CI python-test job での pytest parallel success により AC2(44 passed)・AC12(pnpm typecheck/lint/test/build 全 pass)が独立検証済み。
Closing keyword: Closes #1163 確認済み。
Safety Claim Gate: scripts/ の tooling 変更のみ(.claude/skills 非対象・権限サンドボックス系差分なし)。safety-sensitive 非該当。
Schema Consumer Gate: not_schema_change 宣言・consumer 一覧・互換性判断が PR 本文に記載済み。gate 通過。
テスト削除なし確認: PR 本文「既存 32 テストは削除・変更なし。新規 12 テストを追加」の記載を CI python-test 44 passed(32+12)で裏付け。
blockers: なし。merge_ready: true。
判定: REQUEST_CHANGES最新の PR コメント上は、以前の allowed paths 不整合、 PR #1179 自体は draft/open で、変更は 3 ファイル、主目的は #1163 の 良い点設計方針そのものは妥当です。Python AST は
また、E501 の成功条件を「物理的に全行 120 文字以下」ではなく「固定 Ruff 条件で E501 diagnostic 0 件」とするのも正しいです。Ruff の E501 には長い単語、閾値前から始まる末尾 URL、pragma、SPDX 等の例外があります。([Astral Docs]3) Blocking findingsB1.
|
…ide 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).
squne121
left a comment
There was a problem hiding this comment.
LOOP_VERDICT_V2 (iteration 1)
verdict: APPROVE
reviewed_head_sha: ad0561df0320102fbe97a52b8d01a4a22256d0f2
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: CLEAN
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
schema: ALLOWED_PATHS_GATE_RESULT_V1
status: ok
producer_role: review_subagent
worker_report_used_as_canonical: false
contract_source_kind: issue_comment
contract_source_id: "4809938513"
expected_contract_fingerprint: "body_sha256:410eabd9a1a74563e5c3f818bb36be7a15a8c9b574ca4356d4af45884e7b7957"
allowed_paths:
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
- .github/ci/python-test-plan.json
changed_files:
- .github/ci/python-test-plan.json
- scripts/e501_migration_guard.py
- scripts/tests/test_e501_migration_guard.py
violations: []判定根拠
CI 証拠(head SHA: ad0561d、run 28243707251)
gh api repos/squne121/loop-protocol/commits/ad0561df/check-runs で全 18 check-run を確認。全 required CI チェック SUCCESS: python-test / typecheck / lint / build / test / e2e / node-backed-hook-tests / check-hook-integrity / PR Body Japanese Check / ci-verdict-summary / actionlint / validate-generated-artifact / deploy-pr。
Allowed Paths Gate
contract snapshot issuecomment-4809938513(body_sha256: 410eabd9a1a74563e5c3f818bb36be7a15a8c9b574ca4356d4af45884e7b7957、status: go)の Allowed Paths 3 ファイルと PR diff 3 ファイルが完全一致。逸脱なし。
OWNER REQUEST_CHANGES(issuecomment-4810243186)Blocker 解消確認
B1: TypeIgnoreSignature に path: str 追加、ファイル間移動を検出
guard.py 行 358-365: TypeIgnoreSignature に path: str フィールド追加済み。check_ast_equiv() は各ファイルの signature を path 付きで集約しグローバル比較する。path が異なれば sorted() 比較で不一致になるため、ファイル間移動を確実に検出する。テスト test_type_ignore_move_between_files_fails(行 1105)が存在し、a.py の type: ignore を b.py に移動するシナリオで type_ignore_equiv.ok=False を検証。RESOLVED。
B2: preceding_token_fingerprint: str 追加、multiline statement 内 sub-expression 間移動を検出
guard.py 行 365、401-443、479-482: preceding_token_fingerprint フィールド追加。_compute_preceding_token_fingerprint() が tokenize で直前 3 非trivial トークンの fingerprint を生成、line_bound 分類時に使用。テスト test_type_ignore_move_within_multiline_statement_fails(行 1136)が存在。RESOLVED。
B3: _get_stmt_at_line が None のとき ambiguous でなく file_wide に分類
guard.py 行 473-478: result is None 分岐で kind=file_wide、owner_ast_path=file、preceding_token_fingerprint=file を設定。ambiguous は False のまま(B3 要求通り)。テスト test_file_wide_type_ignore_same_top_position_passes(行 1163)と test_line_bound_to_file_wide_fails(行 1189)が存在。RESOLVED。
B4: main() の except GuardError で coverage==scope なら REPORT_SCHEMA_V2 を出力
guard.py 行 1288-1300: error_schema = REPORT_SCHEMA_V2 if ns.coverage == scope else REPORT_SCHEMA_V1。error report に mode、coverage、scope_prefixes も含む。テスト test_coverage_scope_tool_error_uses_v2_schema(行 1217)が存在し、report[schema]==e501-migration-guard/v2 と report[coverage]==scope を検証。RESOLVED。
H1: empty changed_targets with cleanup or completion mode gives RatchetResult(ok=False)
guard.py 行 1027-1037: if not targets and mode in the set implements policy fail. テスト test_empty_changed_targets_cleanup_fails 行 1244、test_empty_changed_targets_completion_fails 行 1263、test_empty_changed_targets_ratchet_passes 行 1279 が存在。RESOLVED。
H2: _inventory_sha256_from_entries で git blob SHA を hash に含める
guard.py 行 979-986: _inventory_sha256_from_entries が mode+obj_type+obj_sha+tab+path の sorted lines から SHA256 を生成。blob OID が変われば digest が変わる。テスト test_scope_inventory_digest_changes_when_blob_changes 行 1299 が存在。RESOLVED。
H3: checks.full_scope_e501.diagnostics フィールドを追加(最大 100 件 cap)
guard.py 行 1200-1210: full_scope_diags = head_scope_ruff.diagnostics[:100] を report に含める。テスト test_full_scope_failure_reports_diagnostics 行 1337 が存在し、各 diag の row/column/path フィールドを検証。RESOLVED。
新規テスト 10 件すべて確認済み
OWNER REQUEST_CHANGES 要求の 10 テストすべて存在確認済み: 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。既存テスト削除なし。CI python-test SUCCESS が全テスト pass を裏付ける。
AC Coverage
AC1-AC12: PR 本文の全 AC 記載済み。CI python-test SUCCESS が AC2、CI typecheck/lint/build/test SUCCESS が AC12 を裏付ける。
Safety-sensitive 判定
変更 3 ファイルはすべて scripts/ または .github/ci/ 配下。.claude/skills、hook、permission sandbox 系の変更なし。Safety Claim Gate 不要。
Closes #1163 確認済み。
post-merge-cleanup: 完了 (2026-06-26T14:50Z)
FOLLOW_UP_MATERIALIZATION_RESULT_V1:
schema_version: 1
materialized_by: post-merge-cleanup
follow_up_issues: []
note_only_observations:
- dedupe_key: "unresolved:cleanup:pr_head_oid_mismatch:pr1179"
source_url: "https://github.com/squne121/loop-protocol/pull/1179"
source_note_id: "cleanup_exec_refused"
summary: >
cleanup_exec が pr_head_oid_mismatch で拒否。原因: GitHub の Update Branch
ボタンが merge commit (8077f40b) を追加したため、local branch tip (ad0561df)
と PR headRefOid が不一致。手動削除が必要:
git worktree remove .claude/worktrees/issue-1163-e501-migration-guard-typeignore
git branch -d worktree-issue-1163-e501-migration-guard-typeignore確認済み状態
|
fix(e501_migration_guard): TypeIgnore 意味論的正規化と --coverage scope モード追加(#1163)
概要
scripts/e501_migration_guard.pyに以下の機能を追加する。linenoの代わりに最小 stmt への構造パス(owner_ast_path)でアンカーを決定する--coverage scopeオプション:git ls-treeで scope 全体の*.pyを NUL-safe に列挙し、変更ファイル以外も E501 ゼロを要求する full-scope completion モード--coverage scope使用時にe501-migration-guard/v2を出力し、checks.full_scope_e501とchecks.type_ignore_equivを含む変更内容
guard 本体の変更(scripts/e501_migration_guard.py)
TypeIgnoreSignature(frozen=True, order=True)dataclass を追加kind:"file_wide"|"line_bound"tag: type: ignore のタグ文字列owner_ast_path: 最小 stmt への構造パス(例:"body[0].body[1]")occurrence_index: 同一アンカーに複数ある場合の順序_build_type_ignore_signatures(): AST を走査して TypeIgnore の構造アンカーを特定_compare_type_ignore_signatures(): ソートして集合比較(mismatch / ambiguous_anchor を報告)ast_fingerprint(): 3-tuple(dump, type_ignore_sigs, ambiguous)を返すように更新tree.type_ignores = []してから dump → lineno 影響を排除check_ast_equiv():type_ignore_equivcheck を追加して返すenumerate_scope_py_files():git ls-tree -r -z --full-tree ... :(literal)<scope>で NUL-safe に列挙verify_diff():coverageパラメータ追加changed: 既存の v1 動作(後方互換)scope: full scope 列挙 +checks.full_scope_e501+ v2 schemabuild_parser():--coverage {changed,scope}オプション追加テストファイルの変更(scripts/tests/test_e501_migration_guard.py)
既存 32 テストは削除・変更なし。新規 12 テストを追加:
test_type_ignore_line_shift_same_anchor_passestest_type_ignore_move_between_statements_failstest_type_ignore_tag_change_failstest_file_wide_type_ignore_move_failstest_multiple_type_ignores_preserve_multiplicitytest_full_scope_fails_on_unchanged_e501test_full_scope_passes_when_entire_head_scope_cleantest_full_scope_uses_literal_pathspectest_full_scope_handles_unusual_filenames_nul_safelytest_full_scope_empty_inventory_failstest_duplicate_or_nested_scopes_failtest_full_scope_real_ruffAC 証跡(全 AC 実行確認済み)
test -f scripts/e501_migration_guard.pyuv run --locked pytest -q scripts/tests/test_e501_migration_guard.pyrg -c "test_type_ignore_line_shift_same_anchor_passes" ...rg -c "test_type_ignore_move_between_statements_fails" ...rg -c "test_full_scope_uses_literal_pathspec" ...rg -c "test_full_scope_fails_on_unchanged_e501" ...rg -c "test_full_scope_empty_inventory_fails" ...rg -c "test_full_scope_passes_when_entire_head_scope_clean" ...rg -n "e501-migration-guard/v2" scripts/e501_migration_guard.pyrg -c "test_full_scope_real_ruff" ...rg -c "test_full_scope_handles_unusual_filenames_nul_safely" ...Scope Delta: python-test-plan.json への追加
PR #1148 マージ時に
scripts/tests/test_e501_migration_guard.pyがpython-test-plan.jsonへの登録が漏れていた。本 PR でテストを追加するため Scope Delta として追加する。Allowed Paths 準拠の確認
変更ファイルは以下の 3 ファイルのみ:
scripts/e501_migration_guard.py✓(Allowed Paths)scripts/tests/test_e501_migration_guard.py✓(Allowed Paths).github/ci/python-test-plan.json✓(Scope Delta: python-test CI unblock)Closes #1163(本 Issue の実装完了)