Skip to content

fix(e501_migration_guard): TypeIgnore 意味論的正規化と full-scope completion モード追加(#1156 前提) #1163

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1138"
goal_ref: "e501_migration_guard.py に --coverage scope モード・TypeIgnore 意味論的アンカー比較(TypeIgnoreSignature)・report v2 schema を追加し、#1156 の前提条件(scope 全体 E501=0 証明・TypeIgnore 偽不一致排除)を決定論的に満たせるようにする"
change_kind: code

Parent Issue

#1138

Parent Goal Ref

Current Validated Scope

  • scripts/e501_migration_guard.py に --coverage scope オプション・TypeIgnore 構造的アンカー比較・report v2 schema を追加する
  • scripts/tests/test_e501_migration_guard.py に OWNER 指定 12 テストを追加する
  • guard 自身の変更 PR は verify-diff で自己証明できないため、専用 pytest suite + 静的 ruff + git diff --check を正本とする

Remaining Parent Gaps

Outcome

scripts/e501_migration_guard.py に --coverage scope オプション(immutable HEAD tree の literal pathspec 列挙)・TypeIgnore 構造的アンカー比較(TypeIgnoreSignature(kind, tag, owner_ast_path, occurrence_index) による Module.type_ignores 除外 + 別途 checks.type_ignore_equiv)・report v2 schema(checks.ratchet / checks.type_ignore_equiv / checks.full_scope_e501)が追加される。guard 変更自体は専用 pytest E2E suite と静的 ruff でテスト済みの状態になる。

In Scope

  • --coverage scope の追加: git ls-tree -r -z --full-tree "$HEAD_SHA" -- :(literal)<scope> で immutable tree から tracked regular *.py を決定論的に列挙する
  • TypeIgnore 意味論的アンカー比較: TypeIgnoreSignature(kind, tag, owner_ast_path, occurrence_index) を用い、Module.type_ignores を除外した通常 AST 比較 + 別途 checks.type_ignore_equiv で比較する
  • report v2 schema: checks.ratchet(changed-file 意味を維持)+ checks.type_ignore_equiv + checks.full_scope_e501(inventory_count / inventory_sha256 / source_sha / head_total / per_file)
  • 空 scope / 重複・nested scope / .py symlink / 解析不能 entry に対する fail-closed guard
  • changed_targets と head_scope_targets の分離(二重計数を排除)
  • 空 target を Ruff に渡す前の明示的 fail-closed チェック
  • OWNER 指定 12 テストの追加

Out of Scope

  • Allowed Paths 3 ファイル以外のファイル変更(.github/ci/python-test-plan.json は Scope Delta として含む)
  • TypeIgnore.lineno の単純 0 置換・Module.type_ignores=[] 単純削除
  • --mode full-scope という名称(--coverage scope を採用)
  • 実装: scripts の E501 cleanup(既存 *.py の行分割のみ・#1138 Child 3) #1156 の残存 blockers(Ruff override hardening / suppression grammar / file mode equality)の本 Issue での解消
  • .pyi / .pyw 等 .py 以外の Python ファイルの scope 対象化

Runtime Verification Applicability

decision: not_applicable
rationale: >
  本 Issue は guard ツールのみを変更する tooling 変更であり、ゲーム runtime(src/state・src/render・src/systems)の挙動には影響しない。
  guard の機能変更は専用 pytest E2E suite と静的 ruff で機械検証する。

Acceptance Criteria

  • AC1: Allowed Paths を guard 本体・専用テスト・python-test-plan.json の 3 ファイルへ固定し、PR に含まれる変更が当該 3 ファイルのみであること(.github/ci/python-test-plan.json は PR 実装: E501 migration guard tooling — verify-diff 一体検証(#1138 Child 1) #1148 マージ時の登録漏れ修正 Scope Delta)
  • AC2: 既存の ratchet・cleanup・completion の changed-file 動作と exit code を維持する(退行テスト pass)
  • AC3: 同一論理文へ結び付いた TypeIgnore の物理行番号のみが変わる reflow は checks.type_ignore_equiv.ok: true となる
  • AC4: TypeIgnore の追加・削除・tag 変更・別文への移動・file-wide 位置変更・重複数変更は checks.type_ignore_equiv.ok: false となる
  • AC5: --coverage scope が immutable head_sha tree から literal pathspec・NUL-safe に tracked regular *.py を列挙する
  • AC6: 変更ファイルが E501=0 でも、未変更 scope ファイルに E501 が残れば decision: fail を返す
  • AC7: 空 scope / 重複・nested scope / .py symlink / 解析不能 entry は fail-closed になる
  • AC8: changed-file ratchet と full-scope completion を別の report field(v2 schema)で出力し、inventory 件数・digest・source SHA を記録する
  • AC9: report schema 変更について consumer inventory と互換性判断を明記する(推奨: v2、checks.ratchet の既存意味は維持)
  • AC10: 固定済み実 Ruff を使う full-scope integration test を追加する(fake Ruff E2E のみでは不十分)
  • AC11: 成功条件を「固定 Ruff 条件で E501 diagnostic 0 件」とし、Ruff 公式除外(長い単語・末尾 URL・pragma・SPDX 等)を前提にする
  • AC12: マージ後に 実装: scripts の E501 cleanup(既存 *.py の行分割のみ・#1138 Child 3) #1156 の Verification Command を --mode completion --coverage scope へ更新する手順を明記する

Verification Commands

# baseline-expect: pass
# AC1
$ test -f scripts/e501_migration_guard.py
# AC2
$ uv run --locked pytest -q scripts/tests/test_e501_migration_guard.py
# AC3
# baseline-expect: pass
$ rg -c "test_type_ignore_line_shift_same_anchor_passes" scripts/tests/test_e501_migration_guard.py
# AC4
# baseline-expect: pass
$ rg -c "test_type_ignore_move_between_statements_fails" scripts/tests/test_e501_migration_guard.py
# AC5
# baseline-expect: pass
$ rg -c "test_full_scope_uses_literal_pathspec" scripts/tests/test_e501_migration_guard.py
# AC6
# baseline-expect: pass
$ rg -c "test_full_scope_fails_on_unchanged_e501" scripts/tests/test_e501_migration_guard.py
# AC7
# baseline-expect: pass
$ rg -c "test_full_scope_empty_inventory_fails" scripts/tests/test_e501_migration_guard.py
# AC8
# baseline-expect: pass
$ rg -c "test_full_scope_passes_when_entire_head_scope_clean" scripts/tests/test_e501_migration_guard.py
# AC9
# baseline-expect: pass
$ rg -n "e501-migration-guard/v2" scripts/e501_migration_guard.py
# AC10
# baseline-expect: pass
$ rg -c "test_full_scope_real_ruff" scripts/tests/test_e501_migration_guard.py
# AC11
# baseline-expect: pass
$ rg -c "test_full_scope_handles_unusual_filenames_nul_safely" scripts/tests/test_e501_migration_guard.py
# AC12
# baseline-expect: pass
$ rg -n "coverage" scripts/e501_migration_guard.py
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

Out-of-Band Verification(マージ後 #1156 PR Reviewer / CI)

マージ後、#1156 の PR reviewer / CI が以下を実行する(AC12)。

ruff clean(AC1 補足検証 / PR レビュー時):

uv run --locked ruff check --select E,F --ignore E402 scripts/e501_migration_guard.py scripts/tests/test_e501_migration_guard.py

verify-diff(#1156 マージ後):

env -u E501_GUARD_ALLOW_TEST_RUFF -u E501_GUARD_RUFF_CMD uv run --locked python scripts/e501_migration_guard.py verify-diff --base-ref "$PR_BASE_SHA" --head-ref "$PR_HEAD_SHA" --scope scripts --mode completion --coverage scope > e501-guard-report.json
import json
report = json.load(open("e501-guard-report.json", encoding="utf-8"))
assert report["decision"] == "pass", report
assert report["schema"] == "e501-migration-guard/v2"
assert report["checks"]["ratchet"]["ok"]
assert report["checks"]["type_ignore_equiv"]["ok"]
assert report["checks"]["full_scope_e501"]["ok"]
assert report["checks"]["full_scope_e501"]["source_sha"] == report["refs"]["head_sha"]
assert report["checks"]["full_scope_e501"]["inventory_count"] > 0
assert report["checks"]["full_scope_e501"]["inventory_sha256"]
assert report["checks"]["full_scope_e501"]["head_total"] == 0

Allowed Paths

Stop Conditions

  • uv run --locked pytest -q scripts/tests/test_e501_migration_guard.py が全 pass
  • git diff --check "$PR_BASE_SHA" "$PR_HEAD_SHA" が exit 0
  • AC1–AC12 の証跡が揃っている
  • pnpm typecheck / pnpm lint / pnpm test / pnpm build が全 exit 0
  • uv run --locked ruff check --select E,F --ignore E402 scripts/e501_migration_guard.py scripts/tests/test_e501_migration_guard.py が exit 0
  • PR diff が Allowed Paths 3 ファイル(scripts/e501_migration_guard.py / scripts/tests/test_e501_migration_guard.py / .github/ci/python-test-plan.json)のみに限定されている

Required Skills

  • Python / ast モジュールの知識
  • git ls-tree によるツリー列挙
  • Ruff E501 診断の仕様理解
  • pytest E2E テスト作成

背景

e501_migration_guard.py verify-diff --mode completion は変更ファイルのみを検査するが、scope 全体(scripts/ 配下の全 Python ファイル)の E501=0 を証明しない。変更されなかったファイルの残存 E501 は検査対象から外れる。

また、ast.parse(type_comments=True) で TypeIgnore ノードが生成されるが、TypeIgnore.lineno は _fields に属するため include_attributes=False では除去されない。これにより # type: ignore コメントより前に行を追加する E501 行分割が AST 同値性を崩す。単純な lineno=0 置換では位置が意味論の一部である # type: ignore の意味変更を見逃すため、構造的アンカー(owner_ast_path / tag / occurrence_index)による比較が必要である。

これらは #1156(scripts/*.py E501 cleanup)の完了を阻む技術的制約であり、この Issue で解消する。

Non-Goals

関連

Scope Delta

本 Issue は OWNER REQUEST_CHANGES(comment #4800694025, 2026-06-25)の 10 Blockers を全て反映:

  1. Allowed Paths を guard 本体 + 専用テストの 2 ファイルに固定(Non-Goals を整合更新)
  2. TypeIgnore 処理を構造的アンカー比較(TypeIgnoreSignature)へ再設計(単純 lineno 削除廃止)
  3. AC3 を「同一論理文の物理行番号のみ変化」に限定、AC4 で否定ケースを明示
  4. CLI を --mode full-scope から --coverage scope へ変更(mode と coverage の 2 軸分離)
  5. scope 列挙を immutable HEAD tree(git ls-tree literal pathspec)に固定
  6. target 集合を changed_targets / head_scope_targets に分離(二重計数排除)
  7. 空 target の Ruff 渡し前 fail-closed を追加
  8. report を v2 schema へ移行(checks.ratchet の既存意味を維持)
  9. 依存を Partially blocks #1156 に修正(全 実装: scripts の E501 cleanup(既存 *.py の行分割のみ・#1138 Child 3) #1156 blockers を本 Issue に含めない)
  10. guard 自己証明境界を 2-stage に再設計(PR 専用 suite + out-of-band)

Activity

  1. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 現契約のまま実装開始不可。

    問題認識自体は正しいです。現行completionは変更ファイルだけをRuffへ渡しており、scope全体の完了を証明していません。また、TypeIgnore.linenoがASTの通常フィールドとして比較されるため、意味を変えない行移動でも偽不一致になります。ところが#1163は、テスト追加とのスコープ矛盾、TypeIgnoreの意味保存方法、full-scopeの列挙方法、レポート互換性、#1156の残存blockerを定義していません。

    Blocking findings

    1. Non-GoalsとAC5が同時達成不能

    #1163は「scripts/e501_migration_guard.py以外を変更しない」としながら、AC5で回帰テスト追加を要求しています。既存テストはtests/test_e501_migration_guard.pyではなく、独立した scripts/tests/test_e501_migration_guard.pyにあります。guard自身もこの2ファイルを一組の自己保護対象として扱い、PR #1148もAllowed Pathsをこの2ファイルに固定していました。

    修正は必須です。

    Allowed Paths:
    - scripts/e501_migration_guard.py
    - scripts/tests/test_e501_migration_guard.py
    
    Non-Goals:
    - 上記2ファイル以外の変更
    

    2. TypeIgnore.linenoを単純に削除すると意味変更を見逃す

    Issueの技術的診断は正しいです。Python 3.12のASTではModuleがtype_ignoresを持ち、TypeIgnoreはlinenoとtagをフィールドとして持ちます。ast.dump(..., include_attributes=False)が除外するのは位置属性であり、TypeIgnore.linenoは残ります。 ([Python documentation]1) ([Python documentation]1) ([Python documentation]1)

    しかし、lineno=0へ置換する、またはModule.type_ignores=[]にして比較するだけでは危険です。# type: ignoreは原則としてエラー対象行へ置く指示であり、ファイル先頭の単独コメントはファイル全体を抑制します。したがって位置は意味論の一部です。 ([Typing]2)

    例えば以下は、通常ASTとTypeIgnoreのtagが同じでも抑制対象が変わります。

    # base
    x = first()  # type: ignore[attr-defined]
    y = second()
    
    # head
    x = first()
    y = second()  # type: ignore[attr-defined]

    さらに以下は、ファイル全体抑制を無効な位置へ移動する例です。

    # base
    # type: ignore
    x = unknown_name
    
    # head
    x = unknown_name
    # type: ignore

    必要な設計は「位置を捨てる」ことではなく、「物理行番号を構造的アンカーへ変換する」ことです。

    推奨する比較単位は次です。

    TypeIgnoreSignature:
    - kind: file_wide | line_bound
    - tag: 完全一致
    - owner_ast_path: 対応する最小のast.stmtへの構造パス
    - token_anchor: 論理文内でコメント直前・直後にある有意tokenの位置
    - occurrence_index: 同一アンカーが複数ある場合の順序
    

    通常AST比較ではModule.type_ignoresを除外し、別のchecks.type_ignore_equivでこのsignatureを比較すべきです。アンカーを一意に決められない場合はpassではなくfail-closedにします。

    3. AC3の「前に行を追加」が曖昧

    「# type: ignoreより前に行を追加」には、空行追加、コメント追加、既存文のE501 reflow、実行文追加が含まれ得ます。実行文追加は通常ASTを変えるため、当然failすべきです。

    AC3は次のように限定すべきです。

    同一論理文へ結び付いた# type: ignoreについて、空行追加またはAST同値なE501 reflowによって物理行番号のみが変化した場合、TypeIgnore意味同値性がpassする。

    併せて、別文への移動、tag変更、bare/coded形式変更、file-wide位置変更をfailさせるACが必要です。

    4. full-scopeはratchetの「mode」ではなく検査対象の「coverage」

    現行modeはratchet、cleanup、completionであり、いずれも診断数に対する事後条件です。これにfull-scopeを同列追加すると、「何件を要求するか」と「どのファイルを測るか」という独立した2軸を混同します。現行実装でもcompletionは単に変更対象のhead_total == 0を要求しています。

    推奨CLIは次です。

    verify-diff \
      --mode completion \
      --coverage scope

    互換性維持のため、--coverageの既定値をchangedにします。

    --mode:
      ratchet | cleanup | completion
    
    --coverage:
      changed | scope
    

    --mode full-scopeを採用するなら、少なくとも名称はfull-scope-completionにしなければ、要求するpostconditionが不明確です。

    5. scope全体のファイル列挙方法が未定義

    full-scopeの入力はworking treeではなく、不変なhead_shaのGit treeから取得すべきです。そうしなければ、未追跡ファイル、dirty working tree、checkout状態によって結果が変わります。

    実装候補は次です。

    git ls-tree -r -z --full-tree "$HEAD_SHA" -- <literal scopes...>

    git ls-tree -rはtreeを再帰列挙し、-zはファイル名をNUL区切りでそのまま出力し、--full-treeは実行時カレントディレクトリの影響を除きます。 ([Git]3)

    さらに、Gitのpath引数は単純な文字列prefixではなくpathspecです。*や?等を含むscopeが展開されないよう、:(literal)<scope>を使うか、pathspec magicを入力時に拒否する必要があります。現行normalize_scope()は絶対パス、..、NUL、backslashしか拒否していません。 (Git)

    inventory契約は少なくとも次へ固定すべきです。

    - source: immutable head SHAのtree
    - 対象: scope配下のtracked regular blob
    - mode: 100644または100755
    - suffix: 厳密に".py"
    - pathspec: literal
    - ordering: bytewiseまたはPOSIX pathで決定論的sort
    - duplicate/nested scope: policy fail
    - 空inventory: typoによるvacuous passを避けるためfail
    - ".py" symlink・非regular entry: fail-closed
    

    「全Pythonファイル」が.pyiや.pywを含むかも明記が必要です。現行guardは.pyだけを対象にしますが、Ruffの通常discoverは.pyiやNotebookも含みます。#1156との整合を優先するなら「tracked regular *.pyのみ」が妥当です。 ([Astral Docs]5)

    なお、現行のscope重複検出はレポートへ出すだけで判定をfailにしていません。full-scopeでは二重計数や意図しない包含を防ぐため、重複・入れ子scopeを明示的なpolicy failureに変える必要があります。

    6. 「変更ファイル+未変更ファイルを合算」は実装表現として危険

    変更ファイルはscope全体の部分集合です。変更分の結果とscope全体の結果を加算すると二重計数になります。

    対象集合は次の2つへ分離すべきです。

    changed_targets = changed_manifest内のscope対象.py
    head_scope_targets = head tree内のscope対象.py

    実行モデルは次が適切です。

    assert set(changed_targets) <= set(head_scope_targets)
    
    base_changed = run_ruff(merge_base_sha, changed_targets)
    head_scope = run_ruff(head_sha, head_scope_targets)
    head_changed = head_scope.subset(changed_targets)
    
    changed_ratchet = check_ratchet(
        base_changed,
        head_changed,
        changed_targets,
        mode,
    )
    
    scope_completion = head_scope.total == 0

    これならhead側を二度lintせず、既存のchanged-file ratchetとscope completionを独立して証明できます。

    7. 空targetではRuffが.を検査する

    現行run_ruff()は対象ファイル一覧をCLI末尾へ追加します。対象が空ならRuffへファイル引数が渡らず、Ruffは既定値.を検査します。これは「対象なし」を「guardプロジェクト全体の検査」へ変える別動作で、診断パスのmapping failureや誤判定を起こします。 ([Astral Docs]5)

    changed_targetsとhead_scope_targetsの空集合を明示検査し、Ruffへ渡す前にfailさせるべきです。scope全体ではファイル数が増えるため、全パスをargvへ展開せず、正確なblob集合だけを一時ディレクトリへmaterializeして、その一時ルートをRuffへ一度だけ渡す設計の方が安全です。

    8. report v1の意味を上書きしてはいけない

    現行reportはe501-migration-guard/v1で、checks.ratchet.head_totalは変更ファイル合計を意味します。ここをscope全体合計へ変更すると、フィールド名が同じまま意味だけが変わる破壊的変更になります。

    推奨reportは次です。

    {
      "schema": "e501-migration-guard/v2",
      "mode": "completion",
      "coverage": "scope",
      "checks": {
        "ratchet": {
          "target_set": "changed",
          "base_total": 34,
          "head_total": 0
        },
        "type_ignore_equiv": {
          "ok": true
        },
        "full_scope_e501": {
          "ok": true,
          "source_sha": "<head sha>",
          "inventory_count": 123,
          "inventory_sha256": "sha256:...",
          "head_total": 0,
          "per_file": {}
        }
      }
    }

    checks.ratchetの既存意味は維持し、新しい完了証明は別フィールドにします。inventory digestは、sort済みのmode + blob oid + pathから生成すると、どのtree内容を検査したかまで固定できます。

    9. Blocks #1156は過大な依存関係表現

    #1156のレビューで要求されている先行hardeningは、full-scopeとTypeIgnoreだけではありません。少なくとも、任意Ruff overrideの信頼境界、Ruff suppressionの公式grammar・作用域、base/head file mode同一性も前提条件として残っています。#1156本文にもこれらが明記されています。

    したがって関係は次のいずれかに修正すべきです。

    Partially blocks: #1156
    Remaining blockers:
    - production Ruff override hardening
    - suppression grammar/range hardening
    - file mode equality
    

    または#1163へこれらを取り込み、guard hardening全体を単一Issueとして完結させます。

    10. guard変更PRはguard自身で自己証明できない

    現行guardはguard本体とそのテストの変更をguard_self_changeとして拒否します。これはcleanup PRからguard弱体化を隔離するための正しい境界ですが、#1163の実装PRに対して新しいverify-diffをそのまま実行して合格証拠にはできません。

    #1163の検証契約は次の二段階にする必要があります。

    1. fix(e501_migration_guard): TypeIgnore 意味論的正規化と full-scope completion モード追加(#1156 前提) #1163 PRでは、専用の一時Git repositoryを使うbehavioral E2E、実Ruff integration、変更2ファイルの静的検査を行う。
    2. #1163マージ後、#1156のimmutable base/head SHAに対して、マージ済みguardをout-of-band実行する。

    修正版Acceptance Criteria

    1. Allowed Pathsをguard本体と専用テストの2ファイルへ固定する。
    2. 既存ratchet、cleanup、completionのchanged-file動作とexit codeを維持する。
    3. 同一論理文へ結び付いたTypeIgnoreの物理行番号のみが変わるreflowはpassする。
    4. TypeIgnoreの追加・削除・tag変更・別文への移動・file-wide位置変更・重複数変更はfailする。
    5. --coverage scopeがimmutable head_sha treeからliteral pathspec、NUL-safeにtracked regular *.pyを列挙する。
    6. 変更ファイルがE501=0でも、未変更scopeファイルにE501が残ればfailする。
    7. scope外のE501は判定に含めず、空scope、重複・nested scope、.py symlink、解析不能entryはfail-closedにする。
    8. changed-file ratchetとfull-scope completionを別のreport fieldで出力し、inventory件数・digest・source SHAを記録する。
    9. report schema変更についてconsumer inventoryと互換性判断を記載する。推奨はv2。
    10. fake Ruff E2Eだけでなく、固定済み実Ruffを使うfull-scope integration testを追加する。
    11. 成功条件を「物理的な全行120文字以下」ではなく「固定Ruff条件でE501 diagnostic 0件」とする。Ruffは長い単語、末尾URL、pragma、SPDX等を仕様上除外します。 ([Astral Docs]6)
    12. マージ後に#1156のVerification Commandを--mode completion --coverage scopeへ更新し、残存hardening blockerを別途解消する。

    最低限必要な新規テストは以下です。

    test_type_ignore_line_shift_same_anchor_passes
    test_type_ignore_move_between_statements_fails
    test_type_ignore_tag_change_fails
    test_file_wide_type_ignore_move_fails
    test_multiple_type_ignores_preserve_multiplicity
    test_full_scope_fails_on_unchanged_e501
    test_full_scope_passes_when_entire_head_scope_clean
    test_full_scope_uses_literal_pathspec
    test_full_scope_handles_unusual_filenames_nul_safely
    test_full_scope_empty_inventory_fails
    test_duplicate_or_nested_scopes_fail
    test_full_scope_real_ruff
    

    推奨Verification Commands

    #1163実装PR自身は自己変更拒否のためverify-diffで検証せず、専用suiteと静的検査を正本にします。

    uv run --locked pytest -q \
      scripts/tests/test_e501_migration_guard.py
    
    uv run --locked ruff check \
      --select E,F \
      --ignore E402 \
      scripts/e501_migration_guard.py \
      scripts/tests/test_e501_migration_guard.py
    
    git diff --check "$PR_BASE_SHA" "$PR_HEAD_SHA"

    マージ後、#1156で次を実行します。

    env -u E501_GUARD_ALLOW_TEST_RUFF \
        -u E501_GUARD_RUFF_CMD \
        uv run --locked python scripts/e501_migration_guard.py verify-diff \
          --base-ref "$PR_BASE_SHA" \
          --head-ref "$PR_HEAD_SHA" \
          --scope scripts \
          --mode completion \
          --coverage scope \
          > e501-guard-report.json
    import json
    
    report = json.load(open("e501-guard-report.json", encoding="utf-8"))
    
    assert report["decision"] == "pass", report
    assert report["mode"] == "completion"
    assert report["coverage"] == "scope"
    assert report["checks"]["ratchet"]["ok"]
    assert report["checks"]["type_ignore_equiv"]["ok"]
    assert report["checks"]["full_scope_e501"]["ok"]
    assert report["checks"]["full_scope_e501"]["source_sha"] == report["refs"]["head_sha"]
    assert report["checks"]["full_scope_e501"]["inventory_count"] > 0
    assert report["checks"]["full_scope_e501"]["inventory_sha256"]
    assert report["checks"]["full_scope_e501"]["head_total"] == 0

    最終結論: #1163は「linenoを消す修正」と「Ruff対象を増やす修正」では不十分です。TypeIgnoreの構造的アンカー、immutable tree inventory、coverage/mode分離、report schema、自己検証境界、#1156の残存blockerまで契約化してから実装すべきです。

  2. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  3. squne121 commented on Jun 25, 2026

    @squne121
    OwnerAuthor

    contract-review: go

    Issue #1163 は実装着手可能です。

    Contract Snapshot

    Outcome: scripts/e501_migration_guard.py に --coverage scope オプション・TypeIgnore 構造的アンカー比較(TypeIgnoreSignature)・report v2 schema が追加され、#1156 の前提条件が満たされる。

    Allowed Paths:

    • scripts/e501_migration_guard.py
    • scripts/tests/test_e501_migration_guard.py

    Worktree / Branch: worktree-issue-1163-e501-migration-guard-typeignore

    VC Preflight 集約

    AC コマンド 分類 decision
    AC1 test -f scripts/e501_migration_guard.py expected_pass go
    AC2 uv run --locked pytest -q scripts/tests/test_e501_migration_guard.py regression_gate (32 passed) go
    AC3 rg -c "test_type_ignore_line_shift_same_anchor_passes" ... expected_baseline_fail go
    AC4 rg -c "test_type_ignore_move_between_statements_fails" ... expected_baseline_fail go
    AC5 rg -c "test_full_scope_uses_literal_pathspec" ... expected_baseline_fail go
    AC6 rg -c "test_full_scope_fails_on_unchanged_e501" ... expected_baseline_fail go
    AC7 rg -c "test_full_scope_empty_inventory_fails" ... expected_baseline_fail go
    AC8 rg -c "test_full_scope_passes_when_entire_head_scope_clean" ... expected_baseline_fail go
    AC9 rg -n "e501-migration-guard/v2" scripts/e501_migration_guard.py expected_baseline_fail go
    AC10 rg -c "test_full_scope_real_ruff" ... expected_baseline_fail go
    AC11 rg -c "test_full_scope_handles_unusual_filenames_nul_safely" ... expected_baseline_fail go
    AC12 pnpm typecheck/lint/test/build regression_gate (1115 passed) go

    全チェック pass。blockers: なし。product_spec: pass。

  4. squne121 commented on Jun 26, 2026

    @squne121
    OwnerAuthor

    contract-review: go(Scope Delta 再レビュー)

    Issue #1163 は Scope Delta 反映後も実装着手可能です。

    Scope Delta 理由

    Contract Snapshot

    Outcome: scripts/e501_migration_guard.py に --coverage scope オプション・TypeIgnore 構造的アンカー比較(TypeIgnoreSignature)・report v2 schema が追加され、#1156 の前提条件が満たされる。

    Allowed Paths:

    • scripts/e501_migration_guard.py
    • scripts/tests/test_e501_migration_guard.py
    • .github/ci/python-test-plan.json(Scope Delta: CI unblock)

    Worktree / Branch: worktree-issue-1163-e501-migration-guard-typeignore

    VC Preflight 集約

    AC コマンド 分類 decision
    AC1 test -f scripts/e501_migration_guard.py expected_pass go
    AC2 uv run --locked pytest -q scripts/tests/test_e501_migration_guard.py regression_gate (44 passed) go
    AC3 rg -c "test_type_ignore_line_shift_same_anchor_passes" ... baseline_expect_pass go
    AC4 rg -c "test_type_ignore_move_between_statements_fails" ... baseline_expect_pass go
    AC5 rg -c "test_full_scope_uses_literal_pathspec" ... baseline_expect_pass go
    AC6 rg -c "test_full_scope_fails_on_unchanged_e501" ... baseline_expect_pass go
    AC7 rg -c "test_full_scope_empty_inventory_fails" ... baseline_expect_pass go
    AC8 rg -c "test_full_scope_passes_when_entire_head_scope_clean" ... baseline_expect_pass go
    AC9 rg -n "e501-migration-guard/v2" scripts/e501_migration_guard.py baseline_expect_pass go
    AC10 rg -c "test_full_scope_real_ruff" ... baseline_expect_pass go
    AC11 rg -c "test_full_scope_handles_unusual_filenames_nul_safely" ... baseline_expect_pass go
    AC12 pnpm typecheck/lint/test/build regression_gate (1115 passed) go

    全チェック pass。blockers: なし。product_spec: pass。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions