Skip to content

実装: scope_signal_guard の new_allowed_path_layer heuristic を Allowed Paths 実差分ベースに修正する #1413

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "scope_signal_guard の new_allowed_path_layer を baseline 付き delta 判定へ固定し、planner evidence の source / 座標 / schema 整合を回復する"
change_kind: code
preflight_scope: implementation

Parent Issue

なし(単独改善)

Parent Goal Ref

なし(単独改善のため親 Goal / Desired Destination は N/A)

Current Validated Scope

  • new_allowed_path_layer は known_context.scope_signal_delta_input.before_body と after_body の Allowed Paths 差分からのみ判定する
  • scope_signal_delta_input が存在しない hard-stop 対象 phase では、new_allowed_path_layer を「変更なし」とみなさず、baseline 欠落として fail-closed にする
  • run_refinement_preflight.py または同等の planner-input producer が、対象 phase で有効な before_body / current_body / after_body / source_refs を planner input に供給する
  • scope_signal_delta.py と plan_refinement_loop.py の evidence span は、source body 全体に対する 1-based 絶対行番号を返し、text_sha256 と raw line が一致する
  • delta positive planner output は refinement_loop_plan_v1.json の schema validation に通る

Remaining Parent Gaps

なし(単独改善)

Outcome

scope_signal_guard の new_allowed_path_layer が、過去 snapshot を参照しない stateless heuristic ではなく、baseline 付き scope_signal_delta_input の実差分から判定される。baseline が無い hard-stop 対象 phase では silent false negative にせず fail-closed に倒し、delta positive の planner output は schema-valid になり、evidence span は source body の raw line と照合できる body-absolute 座標を持つ。Issue #1385 相当の保存済み planner input または再現 fixture を replay し、実際に通った経路と修正後 result を regression test で固定する。

In Scope

  • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py の _detect_scope_signals と known_context.scope_signal_delta_input consumer の修正
  • .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py の section scanner / path extractor / evidence line metadata の修正
  • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py の planner-input producer で scope_signal_delta_input を供給する経路の追加または fail-closed routing の固定
  • .claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json の EvidenceSpan contract 更新
  • .claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.json の source / coordinate / line metadata 更新
  • .claude/skills/issue-refinement-loop/references/refinement-loop-plan-output.md と .claude/skills/issue-refinement-loop/references/scope-signal-guard.md の contract 記述更新
  • .claude/skills/issue-refinement-loop/tests/fixtures/scope_signal_delta/ 配下の delta positive / no-change / blank-line / CRLF / replay fixture 追加
  • .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py、.claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py、.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py、.claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py の regression 追加または更新

Out of Scope

  • new_in_scope_area / new_unverifiable_ac の trigger semantics 変更
  • decide_next_loop_action.py 側の human_escalation routing 方針変更
  • Issue 実装: DOM overlay VRT 用 visual scenario fixture と freeze CSS を追加する #1385 本文・comment の再編集
  • GFM AST parser など新規 Markdown parser dependency の追加
  • scope_signal_guard_decision_v2 の機能拡張。ただし既存 v2 出力が更新後 schema と矛盾する場合の整合修正は In Scope
  • producer 配線に必要な範囲を超える workflow / CI 全体設計変更

Acceptance Criteria

  • AC1: scope_signal_delta_input.before_body と scope_signal_delta_input.after_body が同一で、Allowed Paths に src/** と tests/** の両方が存在する fixture でも、planner output の decisions.scope_signal_guard.triggered が false になり、reason_code が no_scope_signal になる
  • AC2: before_body の Allowed Paths が .claude/** のみで、after_body に docs/** が追加された planner input を与えた場合、planner output は decisions.scope_signal_guard.triggered == true かつ reason_code == "new_allowed_path_layer" を返す
  • AC3: hard-stop 対象 phase の planner input に scope_signal_delta_input が無い場合、new_allowed_path_layer を no_scope_signal として扱わず、baseline 欠落を示す fail-closed reason を返す
  • AC4: production の planner-input producer が、対象 phase で有効な before_body / current_body / after_body / source_refs を known_context.scope_signal_delta_input に供給することを end-to-end test で検証する
  • AC5: new_allowed_path_layer、new_in_scope_area、new_unverifiable_ac の全 evidence span は body-absolute 1-based 座標を持ち、source body の start_line から取得した raw line の sha256 が text_sha256 と一致する
  • AC6: section heading 後の空行が 0 / 1 / 2 行の場合、および LF / CRLF の場合でも、semantic result と absolute line number が一致する
  • AC7: delta positive planner output 全体を .claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json で validation し、validation error が 0 件になる
  • AC8: Issue 実装: DOM overlay VRT 用 visual scenario fixture と freeze CSS を追加する #1385 相当の保存済み planner input または再現 fixture を replay し、実際に使用された経路、修正後の triggered、reason_code、evidence span を regression test で固定する
  • AC9: new_in_scope_area の既存 test ではなく、new_allowed_path_layer 専用の true-positive planner regression test が存在する
  • AC10: .claude/skills/issue-refinement-loop/tests/ 配下の pytest が全件 PASS する

Verification Commands

# AC1
# delta no-change 入力で src / tests が共存しても new_allowed_path_layer が発火しないことを確認する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_delta_no_change_two_top_level_dirs_returns_no_scope_signal
# AC2
# before に無い docs layer が after に追加された場合のみ new_allowed_path_layer が発火することを確認する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_delta_added_docs_layer_triggers_new_allowed_path_layer
# AC3
# hard-stop 対象 phase で scope_signal_delta_input が無い場合に baseline 欠落として fail-closed することを確認する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_missing_delta_input_in_hard_stop_phase_is_fail_closed
# AC4
# preflight wrapper が planner input に before/current/after/source_refs を供給する producer 経路を検証する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_preflight_builds_scope_signal_delta_input_for_hard_stop_phase
# AC5
# evidence span の body-absolute line と text_sha256 が source body raw line に一致することを確認する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_evidence_spans_are_body_absolute_and_hash_raw_lines
# AC6
# heading 後の空行数と LF/CRLF 差分でも line metadata がずれないことを確認する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_section_blank_lines_and_crlf_keep_absolute_line_numbers
# AC7
# delta positive planner output が refinement_loop_plan_v1 schema に通ることを確認する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_delta_positive_planner_output_validates_refinement_loop_plan_schema
# AC8
# #1385 相当 replay fixture で実経路と修正後 result を固定する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_issue_1385_replay_uses_delta_or_fails_closed_without_baseline
# AC9
# new_allowed_path_layer 専用 true-positive planner regression を実行する
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_planner_true_positive_new_allowed_path_layer_not_new_in_scope_area
# AC10
# issue-refinement-loop skill 配下の pytest が全件 PASS すること
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -v

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
  • .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
  • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
  • .claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json
  • .claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.json
  • .claude/skills/issue-refinement-loop/references/refinement-loop-plan-output.md
  • .claude/skills/issue-refinement-loop/references/scope-signal-guard.md
  • .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py
  • .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py
  • .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py
  • .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py
  • .claude/skills/issue-refinement-loop/tests/fixtures/scope_signal_delta/

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 新規 parser dependency または lockfile 更新が必要と判明した場合
  • new_in_scope_area / new_unverifiable_ac の trigger semantics 変更が必要と判明した場合
  • decide_next_loop_action.py の routing 方針変更が必要と判明した場合
  • producer 導入が本 Issue の Allowed Paths だけでは実装不能と判明した場合
  • Issue 実装: DOM overlay VRT 用 visual scenario fixture と freeze CSS を追加する #1385 の保存済み artifact が存在せず、再現 fixture でも AC8 を満たせないと判明した場合

Required Skills

  • ci-test-performance
  • issue-refinement-loop

Required Design References

  • .claude/skills/issue-refinement-loop/references/scope-signal-guard.md
  • .claude/skills/issue-refinement-loop/references/refinement-loop-plan-output.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/test-lane-policy.md

Runtime Verification Applicability

decision: not_applicable
reason: 本 Issue は planner / schema / pytest fixture の contract 修正であり、ゲーム runtime や外部サービスの実動作検証を要求しない。完了判定は parser-safe な pytest と schema validation で行う。

Scope Delta(任意)

N/A

CI_TEST_PERFORMANCE_DECISION_V1

schema: CI_TEST_PERFORMANCE_DECISION_V1
issue_number: 1413
pr_number: null
decision_scope: ci_change
changed_paths:
  - .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
  - .claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py
  - .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
  - .claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json
  - .claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.json
  - .claude/skills/issue-refinement-loop/tests/
lane_classification:
  fast_static:
    applicable: false
    evidence: []
    required_commands: []
  python_unit:
    applicable: true
    evidence:
      - ".claude/skills/issue-refinement-loop/tests/ 配下の pytest が対象"
    required_commands:
      - "uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -v"
  contract_artifact:
    applicable: true
    evidence:
      - "refinement_loop_plan_v1.json と scope_signal_delta_v1.schema.json の schema contract が対象"
    required_commands:
      - "uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v -k test_delta_positive_planner_output_validates_refinement_loop_plan_schema"
  integration:
    applicable: false
    evidence: []
    required_commands: []
baseline_inputs:
  ci_runtime_baseline_v1_available: false
  run_count: 0
  p50_p95_ready: false
artifact_consistency:
  ci_test_selection_v1_checked: false
  missing_pytest_args: []
risk_flags: []
reviewer_gate:
  approve_allowed: true
  required_evidence:
    - TEST_VERDICT_MACHINE
    - CI_CHECK_RUN_SCOPED
follow_up_required: []

Background

Issue #1413 の元 contract は、Allowed Paths に複数トップレベル prefix が存在するだけで new_allowed_path_layer を発火させる legacy heuristic と、section-relative line number を source: issue_body として返す evidence 座標破損を修正対象としていた。対象事象は実在する。

ただし anchor comment(https://github.com/squne121/loop-protocol/issues/1413#issuecomment-4935251250)により、元 contract には次の不整合が確認された。

  • known_context=None の単一 body では「新規追加」と「変更なし」を区別できない
  • producer 未配線のまま legacy trigger だけを止めると silent false negative になる
  • 元 AC3 は new_allowed_path_layer ではなく new_in_scope_area を検証していた
  • evidence 座標破損は legacy 経路だけでなく delta helper 側にも存在する
  • delta planner output は現在の EvidenceSpan.source enum と additionalProperties: false により schema-invalid になる

そのため本 Issue は、legacy heuristic の単純停止ではなく、producer contract、missing-baseline policy、EvidenceSpan schema、target-specific end-to-end test を同じ contract に含める。

Notes for Reviewer

  • new_allowed_path_layer の true-positive は new_in_scope_area の既存 test では代替しない
  • scope_signal_delta_input が無い hard-stop 対象 phase では no_scope_signal と baseline 欠落を同一視しない
  • evidence span の source_ref / body version / coordinate space を schema で表現する場合は、schema と docs と planner output fixture を同じ PR で更新する
  • 新規 Markdown parser dependency は本 Issue のスコープ外とし、line-preserving scanner で対応する

Activity

  1. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 現状の Issue contract のままでは実装着手不可です。

    根本事象は実在します。current main の legacy 経路は、Allowed Paths に複数トップレベル prefix が存在するだけで、過去 snapshot を一切参照せず new_allowed_path_layer を発火させます。また evidence の行番号を section-relative のまま source: issue_body として返しています。Issue #1413 の問題設定自体は正しいです。

    しかし Issue contract には、次の重大な不整合があります。

    1. stateless 入力では「新規追加」を観測できない
    2. delta producer 未配線のまま legacy を止めると、誤検知が恒常的な見逃しに変わる
    3. AC3 が対象 reason code と無関係なテストを指定している
    4. evidence 座標バグは legacy だけでなく delta helper にも存在する
    5. delta 経路の planner output が現在の JSON Schema に違反している

    レビュー基準は、2026年7月10日時点で取得した current main の revision 438ac167a8037d7486115cf7edb3757b40eb0d01 です。Issue #1413 自体には現時点でコメントがありません。

    1. BLOCKER — known_context=None では「new」を判定できない

    Issue #1413 の AC1/AC2 は、known_context=None の単一 body を渡したとき、src/** と tests/** が共存していても no_scope_signal にすることを要求しています。一方、Outcome は「Allowed Paths 実差分ベース」を掲げ、AC3 は真陽性の維持を要求しています。

    しかし _detect_scope_signals(issue_body, None) が受け取るのは現在 body だけです。同一の body は次のどちらにもなり得ます。

    • 前回から src/ と tests/ が存在しており、変更なし
    • 今回初めて tests/ が追加された

    この二つは入力上区別不能です。したがって legacy API のまま実装可能なのは、実差分判定ではなく stateless trigger の無効化だけです。

    さらに delta helper の target 判定は、実際には after - before であり、current_body は snapshot 出力には使われるものの trigger の比較対象には使われていません。Issue は「前回 iteration」「current」「candidate」のどの二点を比較するのかを固定する必要があります。

    修正要求: 次のどちらか一方に contract を固定してください。

    • new_allowed_path_layer は必ず scope_signal_delta_input の before_body と after_body から判定する
    • baseline がない場合は new_allowed_path_layer を判定不能として fail-closed にする

    単に False / no_scope_signal を返す設計は、誤検知は止めますが「変更なし」と「判定不能」を混同します。

    2. BLOCKER — delta producer がないまま legacy を停止すると、真陽性を全停止し得る

    PR #1276 は delta helper と planner consumer を追加しましたが、Safety Claim Matrix で scope_signal_delta_input の producer 自体は追加していないと明記しています。また non-delta 経路の完全撤去も follow-up とされています。

    関連 PR #1276 の敵対的レビューでも、「delta 判定を追加しただけで production path の旧 prefix 判定を置換していない」ことが重大ブロッカーとして指摘されていました。

    その状態で #1413 が legacy trigger だけを無効化すると、production 呼び出しが delta input を供給していない場合に、真の新規 layer 追加も一切検知されなくなります。これは false positive の修正ではなく、silent false negative への置換です。

    Issue の Allowed Paths には planner input を生成する runtime producer が含まれていません。canonical wrapper である run_refinement_preflight.py は planner input を組み立てる entrypoint と説明されていますが、現在の静的検索では scope_signal_delta_input の producer は確認できません。

    修正要求:

    • 実運用の各 phase が before/current/after をどこから取得するかを明記する
    • producer を本 Issue の Allowed Paths に追加するか、producer 導入を prerequisite Issue に分割する
    • producer 未導入のまま legacy 判定だけを削除しない
    • decide_next_action のような hard-stop 対象 phase では、delta 欠落を明示的な判定不能として扱う

    3. BLOCKER — AC3 は対象 reason code の真陽性を検証していない

    AC3 が挙げる既存テストは、名前どおり In Scope 内の .claude/ と docs/ を検出し、次を assert しています。

    reason_code == "new_in_scope_area"

    new_allowed_path_layer は一切検証していません。

    さらに positive/new_allowed_path_layer.md という名前の fixture は In Scope section が欠落しており、対応 golden は no_scope_signal と missing_required_section の fail-closed を期待しています。したがって、これも target reason の真陽性 fixture ではありません。

    delta helper 単体には正しい new_allowed_path_layer テストがありますが、planner、producer、schema を含む end-to-end 回帰ではありません。

    修正要求: AC3 を次に置き換えるべきです。

    before_body の Allowed Paths が .claude/** のみで、after_body に docs/** が追加された planner input を与えた場合、scope_signal_guard.triggered == true かつ reason_code == "new_allowed_path_layer" になることを、planner output の schema validation を含めて検証する。

    4. BLOCKER — evidence の座標破損は delta 経路にも存在する

    Legacy 経路

    legacy 実装は allowed_paths.splitlines() を 1 から数え、その section-relative 行番号をそのまま source: issue_body の行番号として返しています。Issue 本文全体の offset は加算されません。

    同じ実装パターンは new_unverifiable_ac と new_in_scope_area にも存在します。trigger semantics は Out of Scope のままでよいですが、共通 evidence extractor の座標修正は三 reason すべてに適用しないと、同じ破損を残します。

    Delta 経路

    delta helper も正しくありません。

    _extract_sections() は section 内容に .strip() を適用し、先頭の空行を除去します。一方 _find_section_line_offset() は見出しの直後を section 開始位置として返します。

    例えば次の body では、

    1: ## Allowed Paths
    2:
    3: - `docs/dev/workflow.md`
    

    section text は .strip() により bullet から開始します。local_line == 0 に section_start == 2 を足すため、実装は line 2 を返しますが、実際の evidence は line 3 です。_extract_path_items()、_extract_in_scope_layers()、_extract_ac_items() の全てがこの影響を受けます。

    これは推測ではありません。Python の str.strip() は先頭・末尾の whitespace を除去し、splitlines() は元の行区切り単位で文字列を分割します。座標用 text に先に strip() を適用すれば、元の行 index との対応は失われます。([Python documentation]1)

    現行 delta fixture は見出し直後に空行を置いていないため、この off-by-one を隠しています。

    修正要求: section text を再構築してから offset を推測する方式を廃止してください。元 body を一度だけ enumerate(body.splitlines(), start=1) し、各 raw line に絶対行番号を保持する fence-aware iterator に統一すべきです。

    概念的には次の形です。

    @dataclass(frozen=True)
    class SourceLine:
        number: int       # body-absolute, 1-based
        text: str         # raw line; strip しない
    
    def iter_section_lines(body: str, section: str) -> Iterable[SourceLine]:
        # 元 body を絶対行番号付きで走査
        # GFM fence 外の exact `## <section>` で section に入る
        # 次の level-2 heading まで raw line を yield
        ...

    semantic 判定には source_line.text.strip() を使って構いませんが、座標計算は必ず raw line 上で行う必要があります。GitHub Flavored Markdown は CommonMark ベースで、fenced code block 内の内容は literal に扱われるため、既存どおり fence-aware であることも必要です。([GitHub Documentation]2)

    5. BLOCKER — delta planner output が現在の JSON Schema に違反している

    delta projection は evidence の source に、例えば次を出力します。

    scope_signal_delta_after_body
    

    ところが REFINEMENT_LOOP_PLAN_V1 の EvidenceSpan.source enum は次の三値だけです。

    issue_body
    comment
    known_context
    

    また EvidenceSpan は additionalProperties: false です。

    つまり現在の delta positive planner output は、plan schema で validation すると reject されます。それにもかかわらず integration test は source == "scope_signal_delta_after_body" を正解として直接 assert しています。

    原因は test coverage にもあります。test_schema_validation_all_fixtures は delta integration と new_allowed_path_layer 系を validation 対象に含めていません。

    Issue #1413 の AC4 は「座標系を示す別フィールドを追加してもよい」としていますが、additionalProperties: false のため、schema を変更せずに field を足すことはできません。JSON Schema の仕様上も、additionalProperties: false は定義外 property を拒否します。(JSON Schema)

    一方、Issue の Allowed Paths に以下は含まれていません。

    • schemas/refinement_loop_plan_v1.json
    • schemas/scope_signal_delta_v1.schema.json
    • references/refinement-loop-plan-output.md

    したがって AC4 の後半案は現在の scope と Stop Conditions に抵触します。

    修正要求: evidence contract を先に一つに固定してください。

    推奨は次の構造です。

    source: issue_body | comment | known_context | scope_signal_delta_body
    source_ref: <URL / artifact ref / fixture ref>
    body_version: before | current | after | null
    coordinate_space: body_absolute_1_based
    body_sha256: <sha256>
    start_line: <1-based>
    end_line: <1-based>
    text_sha256: <sha256>

    成熟した location contract でも、GitHub SARIF の physicalLocation のように source artifact と region を一体化し、LSP は position の基数と単位を明示します。source_ref、body version、coordinate space、line range を分離不能な一組として扱うべきです。([GitHub Docs]4)

    6. HIGH — #1385 がどちらの経路を通ったかは、かなり絞り込める

    Issue #1413 は、#1385 の実行時に返された evidence が source: issue_body だったと記録しています。一方、current delta projection は source: scope_signal_delta_<version>_body を返します。

    したがって、記録された payload が current implementation と同じ契約で生成されたなら、#1385 は legacy 経路を通った可能性が非常に高いと推定できます。

    これは推論なので、最終確定には当時の planner_input.json または refinement_preflight_result_v1.json の replay が必要です。Issue の「どちらの経路だったか不明」という記述を残すより、実 artifact replay を AC に入れるべきです。

    7. MEDIUM — Allowed Paths の lexical grammar も固定すべき

    legacy regex は backtick 内の最初の / より前だけを取得します。delta の _top_level_layer() は単純に最初の / より前を返します。

    したがって、少なくとも次を fixture 化しないと、実装間 drift が残ります。

    • `src/main.ts`
    • bare path src/main.ts
    • ./src/main.ts
    • src\main.ts
    • tests/**/*.d.ts
    • root file README.md
    • fenced code 内の path
    • Markdown table 内の path
    • 複数 path が同じ bullet にある場合

    現在の Python dependencies は pyyaml と jsonschema のみで Markdown parser はありません。
    この Issue 内では新規 parser dependency を追加せず、共通の line-preserving scanner を実装する方が scope と lockfile 変更を抑えられます。完全な GFM AST/source-map parser を導入するなら、別 Issue として dependency・lockfile・parser compatibility を扱うべきです。

    修正版 Acceptance Criteria

    少なくとも次の形まで具体化する必要があります。

    - [ ] AC1:
      scope_signal_delta_input の before_body と after_body が同一で、
      Allowed Paths に src/** と tests/** の両方が存在しても、
      new_allowed_path_layer は triggered=false / no_scope_signal になる。
    
    - [ ] AC2:
      before_body に src/** のみ、after_body に tests/** が追加された場合、
      planner output は triggered=true /
      reason_code=new_allowed_path_layer を返す。
    
    - [ ] AC3:
      scope_signal_delta_input がない経路の policy を一意に固定する。
      推奨: hard-stop 対象 phase では判定不能として fail-closed。
      少なくとも「no change」と「baseline missing」を同一視しない。
    
    - [ ] AC4:
      production の planner-input producer が、対象 phase で有効な
      before/current/after body と source_refs を必ず供給することを
      end-to-end test で検証する。
    
    - [ ] AC5:
      全 evidence span が body-absolute 1-based 座標を持ち、
      source body の start_line から取得した raw line の sha256 が
      text_sha256 と一致する。
    
    - [ ] AC6:
      section heading 後の空行が 0/1/2 行の場合、および LF/CRLF の場合でも、
      semantic result と absolute line number が正しい。
    
    - [ ] AC7:
      delta positive planner output 全体を
      refinement_loop_plan_v1.json で validation し、error が 0 件になる。
    
    - [ ] AC8:
      #1385 相当の保存済み planner input/artifact を replay し、
      実際に使用された経路と修正後の result を固定する。
    
    - [ ] AC9:
      new_in_scope_area の既存テストではなく、
      new_allowed_path_layer 専用の true-positive regression を持つ。
    
    - [ ] AC10:
      issue-refinement-loop tests 全件 PASS。

    Allowed Paths に追加すべき資産

    contract を整合させるには、現在の Allowed Paths だけでは不足しています。

    .claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json
    .claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.json
    .claude/skills/issue-refinement-loop/references/refinement-loop-plan-output.md
    .claude/skills/issue-refinement-loop/tests/fixtures/scope_signal_delta/
    <実際の scope_signal_delta_input producer>
    <producer の end-to-end test>
    

    producer が run_refinement_preflight.py またはその上流 orchestration に属するなら、そのファイルも明示的に追加する必要があります。これを追加できない場合は、producer 配線を prerequisite Issue に分割し、#1413 を blocked にする方が正確です。

    最終結論

    #1413 は必要な修正ですが、現在の contract は「legacy false positive の除去」しか確定しておらず、「真の新規 layer をどの snapshot から検出するか」「baseline 欠落をどう扱うか」「evidence の source/座標/schema をどう表現するか」が未決定です。

    このまま実装すると、次のいずれかになります。

    • false positive を silent false negative に置き換える
    • delta 経路で schema-invalid な planner artifact を出し続ける
    • blank line を含む通常の Issue Markdownで evidence が別行を指す
    • AC3 が無関係な new_in_scope_area を確認しただけで完了扱いになる

    したがって、producer contract、missing-baseline policy、EvidenceSpan schema、target-specific end-to-end test を Issue 本文に追加した後に実装へ進めるべきです。

    なお、リポジトリ資産は GitHub API から current revision を取得して静的に照合しました。実行環境の外部 DNS 制約により clone と uv run pytest の独立再実行はできていないため、既存テストの PASS 状態そのものは再検証済みとは主張していません。上記ブロッカーはコード・schema・fixture 間の静的な契約矛盾から確定できるものです。

  2. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Issue refinement loop により、anchor comment の REQUEST_CHANGES を反映して本文を更新しました。

    • producer contract、missing-baseline policy、EvidenceSpan schema、new_allowed_path_layer 専用 regression を本文に追加
    • CI_TEST_PERFORMANCE_DECISION_V1 を追加
    • 検証: review-issue approve、contract_readiness_check --mode preflight-static go、contract_readiness_check --mode execute go
  3. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/1413#issuecomment-4935348222
        generated_at: '2026-07-10T12:44:21Z'
        body_sha256: sha256:359ad09e89eeeaa992328e39363110e7e44f8283386e075e8b7df609ff3eb47b
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: '2026-07-10T12:44:21Z'
  4. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-10T12:47:48Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1413
      body_sha256: "sha256:0480b1d568fff62c5e9c5d45b6f716a0cfe718d0ae1eeb10ad1bd053bca21c97"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  5. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    実装を完了し、Draft PR を作成しました。

    • PR: fix: harden scope signal delta provenance (#1413) #1424
    • branch: worktree-issue-1413-scope-signal-guard-new-allowed-path-laye
    • head: bdbbba5f2fc7deae9d0ebc7e38bdb1fa26638f78
    • contract snapshot: 実装: scope_signal_guard の new_allowed_path_layer heuristic を Allowed Paths 実差分ベースに修正する #1413 (comment)
    • verification:
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_new_allowed_path_layer_delta_regression.py -v
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py -v
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py -v -k 'scope_signal_delta or planner_scope_signal_delta_preserves_provenance'
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_anchor_phase_sensitive.py -v
      • uv run --locked pytest .claude/skills/issue-refinement-loop/tests/ -v (1242 passed in 37.49s)
    • allowed_paths_compliance: compliant

    補足:

    • open_pr.py は validate_pr_body.py と validate_japanese_content.py の preflight を通過させようとしましたが、英語固定の必須見出し(Schema Change Applicability など)と日本語比率チェックが衝突し、E_PR_BODY_JAPANESE_VALIDATION_FAILED で fail-closed しました。
    • そのため PR は同一の日本語本文を使って rtk gh pr create で起票しています。実装・検証・Allowed Paths 遵守自体は完了しています。
  6. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-07-10T19:35:14Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      draft_pr_ready: true
      github_merge_ready: true
      merge_ready: true
      pr_url: "https://github.com/squne121/loop-protocol/pull/1424"
      head_sha: "9d41deb76dd5ee148c6b26ceac40d01460b128e2"
      issue_number: 1413
      termination_reason: approved
      iteration: 2
      required_auto_actions: []
      latest_loop_verdict_url: "https://github.com/squne121/loop-protocol/pull/1424#pullrequestreview-4674435699"
      contract_snapshot_url: "https://github.com/squne121/loop-protocol/issues/1413#issuecomment-4935422684"
      checks:
        required_checks: passed
        pr_state:
          is_draft: false
          mergeable: "MERGEABLE"
          merge_state_status: "CLEAN"
          failed_checks: []
          pending_checks: []
        test_runner:
          head_sha: "9d41deb76dd5ee148c6b26ceac40d01460b128e2"
          verdict: PASS
          commands_passed: 5
          commands_failed: 0
          total_tests_passed: 1242
          total_tests_failed: 0
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
  7. squne121 commented on Jul 10, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: 完了 (2026-07-10T21:21:44Z)

    IMPL_REVIEW_LOOP_RESULT_V1:
      schema_version: 1
      status: draft_pr_ready
      draft_pr_ready: true
      github_merge_ready: true
      merge_ready: true
      pr_url: "https://github.com/squne121/loop-protocol/pull/1424"
      head_sha: "058f524808e15f00183efc1dbfb8f4ba5882f96e"
      issue_number: 1413
      termination_reason: approved
      iteration: 4
      required_auto_actions: []
      latest_loop_verdict_url: "https://github.com/squne121/loop-protocol/pull/1424#pullrequestreview-4675059654"
      addressed_comment_url: "https://github.com/squne121/loop-protocol/pull/1424#issuecomment-4939214552"
      contract_snapshot_url: "https://github.com/squne121/loop-protocol/issues/1413#issuecomment-4935422684"
      checks:
        required_checks: passed
        pr_state:
          is_draft: false
          mergeable: "MERGEABLE"
          merge_state_status: "CLEAN"
          failed_checks: []
          pending_checks: []
        test_runner:
          head_sha: "058f524808e15f00183efc1dbfb8f4ba5882f96e"
          verdict: PASS
          commands_passed: 8
          commands_failed: 0
          fallback_pass: false
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: impl-review-loop
      follow_up_issues: []
      note_only_observations: []
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

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions