Skip to content

実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
change_kind: code
stage: 1
blocked_by: [920, 1027]
dedupe_key: "ops-improvement:loop-protocol:scope-signal-guard-lane-split:2026-06"

Parent Issue

なし(standalone issue)

Background

#985 では EnemySpawnSystem.ts が Allowed Paths 外であることが new_allowed_path_layer として検出された。#1060 でも deterministic check は APPROVE だが、新規 skill directory に対する scope_signal_guard が human judgment を要求した。

現在の挙動では、危険な runtime scope expansion と docs/skill/policy 追加のような管理対象 scope expansion が同じ human escalation に寄りやすい。anchor comment による reframe / Scope Delta Approval があれば proceed できるよう、契約と checker lane を明確化する必要がある。

本 Issue は #920(anchor reframe schema)および #1027(scope_signal_delta 差分ベース判定)の実装完了を前提とする(blocked_by: [920, 1027])。

Parent Goal Ref

  • Goal: scope_signal_guard が new_runtime_path_layer, new_skill_or_docs_layer, new_hook_or_agent_layer, missing_scope_delta_approval を分けて出力し、人間判断が必要なケースと proceed_with_notes 可能なケースを区別する
  • Desired Destination: 実装: existing enemy_chaser を new taxonomy へ非破壊移行する #985 / 実装: CI test lane policy docs と ci-test-performance skill を追加する #1060 の scope_signal_guard 誤停止が regression fixture として再現可能で、anchor comment reframe がある場合は proceed_with_notes が返される状態
  • 注意: proceed_with_notes は「このまま実装してよい」ではない。issue-contract-review での current-body status: go を再取得する必要がある。anchor approval があっても contract-review rerun は必須であり、proceed_with_notes は「anchor approval を確認した上で contract-review を再実行してよい」の意味に留まる。

Current Validated Scope

Remaining Parent Gaps

なし(このIssue単独で完結)

Outcome

scope_signal_guard が new_runtime_path_layer, new_skill_or_docs_layer, new_hook_or_agent_layer, missing_scope_delta_approval を分けて出力し、人間判断が必要なケースと proceed_with_notes 可能なケースを区別する。

proceed_with_notes は contract-review の rerun required を示すステータスであり、実装 go ではない。anchor approval があっても、issue-contract-review の current-body status: go を別途取得しなければ実装フェーズに進んではならない。

SCOPE_SIGNAL_GUARD_DECISION_V2 schema により、raw_signal / scope_context / scope_delta_approval / route の各フィールドを artifact に保存し、decision traceability を確保する。

In Scope

Out of Scope

Acceptance Criteria

Stop Conditions

Required Skills

  • Python
  • issue-refinement-loop architecture
  • scope_signal_guard semantics

Verification Commands

# AC1
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC2
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC3
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC4
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC6
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC7
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

# AC8
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC9
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC10
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC11
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC12
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

# AC13
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q

Allowed Paths

  • .claude/skills/issue-refinement-loop/references/scope-signal-guard.md
  • .claude/skills/issue-refinement-loop/references/loop-state.md
  • .claude/skills/issue-refinement-loop/references/termination-policy.md
  • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
  • .claude/skills/issue-refinement-loop/scripts/build_loop_state.py
  • .claude/skills/issue-refinement-loop/fixtures/

Runtime Verification Applicability

Related Issues

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    on Jun 21, 2026
  2. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。#1090 の問題意識は正しいが、現契約のまま実装すると、scope_signal_guard の誤停止を減らすどころか、既存の anchor reframe / scope_context / fail-closed 系と競合する危険が高いです。

    #1090 は、#985 で EnemySpawnSystem.ts が Allowed Paths 外の new_allowed_path_layer として検出された件、#1060 で新規 skill directory 追加が human judgment を要求した件を直接の背景にし、new_runtime_path_layer / new_skill_or_docs_layer / new_hook_or_agent_layer / missing_scope_delta_approval へ lane 分割する Issue です。コメントは現時点で 0 件です。

    ただし、関連履歴を見ると、#1090 は 単独の新判定器として作るべきではありません。#550/PR #554 で既に「語彙一致ではなく scope_context / domain_flags / ordering_constraint で構造的に判定する」「security gate とは分離する」という方針が merged されています。 さらに #920 は excluded_by_anchor_reframe を扱う anchor reframe schema の未整備を既に Issue 化しており、#1027 は scope_signal を差分ベース診断にする Issue です。


    Blocker 1: #1090 は #920 / #1027 と順序依存を明示していない

    #1090 は Scope Delta Approval / Allowed Paths Expansion Rationale という新しい marker を契約化しようとしていますが、既存には #920 の anchor scope reframe comment schema があり、excluded_by_anchor_reframe=true、対象 Issue 外 URL の fail-closed、OWNER 相当 author が必要、という前提が既に定義されています。

    加えて、検索上 Scope Delta Approval / Allowed Paths Expansion Rationale は #1090 以外に実績がありません。 つまり現契約のままでは、既存の ANCHOR_SCOPE_REFRAME 系と新 marker 系が並立し、agent が「どちらを正本にすべきか」を誤読します。

    修正要求:

    preconditions:
      - "#920 の anchor reframe schema と互換にする。新 marker を追加する場合も既存 ANCHOR_SCOPE_REFRAME を破壊しない。"
      - "#1027 の scope_signal_delta / before-current-after 差分証跡が未実装なら、本 Issue は lane 分類だけで new/既存再掲を判定しない。"
    blocked_by:
      - 920
      - 1027

    または、#1090 に #920/#1027 相当の実装まで含めるなら、Allowed Paths と AC を拡張し、C2/C3 scope collision として contract-review をやり直すべきです。


    Blocker 2: proceed_with_notes が hard gate を迂回する危険がある

    #1090 は anchor comment reframe があれば proceed_with_notes を返す設計ですが、現行 workflow では issue-contract-review status: go が実装着手の hard gate であり、Issue body が human escalation 後に変わった場合、過去の contract-review result は stale と明記されています。

    したがって proceed_with_notes は「実装してよい」ではなく、contract patch を作って再レビューへ進めてよい程度に抑える必要があります。そうしないと、#1071 のレビューコメントで出ていたような「Allowed Paths 外ファイルを Scope Delta 人間承認で進める」経路が、承認済み gate と未承認 gate の混在を起こします。

    修正要求:

    route_action:
      proceed_with_notes:
        meaning: "contract rewrite/review may continue"
        does_not_mean:
          - "implementation may start"
          - "issue-contract-review status: go is implied"
          - "Allowed Paths violation is waived"
        required_next_gate:
          - "rerun issue-contract-review against current issue body"

    Blocker 3: #1086 とファイル・fixture が衝突している

    #1086 は build_refinement_phase_state.py、issue-refinement-loop tests、#985 再現 fixture を扱う一方で、Out of Scope に scope_signal_guard 変更を明示しています。 #1090 も build_refinement_phase_state.py、fixtures/golden、#985/#1060 regression fixture を扱うため、同時進行すると「compact/replay 側の human escalation」と「scope_signal_guard 側の human escalation」が同じ fixture を別の意味で直す状態になります。

    修正要求:

    related_blocking_context:
      - "#1086 touches build_refinement_phase_state.py and #985 fixtures but explicitly excludes scope_signal_guard."
      - "#1090 must either sequence after #1086 or define a C1 benign overlap with non-overlapping assertions."

    #1086 が未完なら、#1090 は build_refinement_phase_state.py 変更を避け、plan_refinement_loop.py と scope-signal-guard.md の contract/schema 追加に絞る方が安全です。


    Blocker 4: lane 分類が path prefix ベースだけだと再び false positive になる

    #1090 の lane 案は runtime/docs/skill/hook/agent/test の分類ですが、#550/PR #554 の教訓は「単語一致・同一ファイル一致・prefix overlap だけでは不十分」という点です。PR #554 では same_anchor_conflicting_operation / same_file_disjoint_anchor / uncertain のような scope_context.conflict_type と、security_match_evidence は audit 記録のみという設計で approve されています。

    #1090 も同じ構造に寄せるべきです。推奨 schema:

    SCOPE_SIGNAL_GUARD_DECISION_V2:
      schema_version: 2
      raw_signal:
        legacy_reason_code: new_allowed_path_layer
        changed_paths: []
        added_allowed_paths: []
      scope_context:
        path_layer: runtime | docs | skill | hook | agent | test_fixture | unknown
        conflict_type: none | same_anchor_conflicting_operation | same_file_disjoint_anchor | prefix_overlap_uncertain | uncertain
        domain_flags: []
        escalation_required: true | false
      scope_delta_approval:
        status: present | missing | invalid | not_required
        marker: ANCHOR_SCOPE_REFRAME | SCOPE_DELTA_APPROVAL | ALLOWED_PATHS_EXPANSION_RATIONALE
        anchor_comment_url: null
        author_association: OWNER | COLLABORATOR | MEMBER | NONE
        target_issue_match: true | false
      route:
        action: proceed_with_notes | request_contract_patch | human_judgment_required | block
        reason_code: new_runtime_path_layer | new_skill_or_docs_layer | new_hook_or_agent_layer | missing_scope_delta_approval | invalid_scope_delta_approval

    JSON Schema を使うなら、未知 field を許すか閉じるかを明示してください。additionalProperties: false は未定義 property を不正にできますが、allOf などで schema を拡張する場合は意図せず拡張 property を拒否しやすい点に注意が必要です。(JSON Schema)


    Blocker 5: security / secret / permission を Scope Delta Approval で承認してはいけない

    #558 は、#550/PR #554 の結果として「scope rollup は security gate ではない」「real-security-risk は別 gate の責務」と明示しています。

    したがって #1090 の new_hook_or_agent_layer や new_runtime_path_layer が secret / token / GitHub Actions secrets / permission / access-control に触れる場合、Scope Delta Approval だけで proceed させてはいけません。これは scope expansion ではなく security/permission risk です。

    修正要求:

    fail_closed_overrides:
      - if domain_flags contains security_sensitive or permission_surface:
          route.action: human_judgment_required
          reason_code: security_risk_gate_required
          scope_delta_approval_may_not_override: true

    Python 側の JSON artifact では NaN/Infinity を出さないようにしてください。Python の json.dump(s) は allow_nan=False で NaN/Infinity の直列化を ValueError にでき、parse_constant で NaN / Infinity / -Infinity を reject できます。([Python documentation]2)


    Blocker 6: anchor comment の author / target issue 検証が AC に不足している

    #920 は anchor comment が対象 Issue 外なら fail-closed、OWNER 相当 author が必要、scope 拡張の自動承認は禁止、という条件を持っています。 #1090 もこれを AC に入れるべきです。

    GitHub REST の issue comment response には issue_url と author_association が含まれるため、少なくとも「コメントが同一 Issue のものか」「author association が許可された値か」は deterministic に検証できます。([GitHub Docs]3)

    追加 AC:

    - [ ] AC8: Scope Delta Approval は対象 Issue の comment URL のみ有効。別 Issue / PR / 外部 URL は invalid_scope_delta_approval として fail-closed。
    - [ ] AC9: `author_association` が OWNER / MEMBER / COLLABORATOR のいずれでもない場合、approval は invalid。
    - [ ] AC10: approval comment の body hash / comment id / author / created_at / issue_url を artifact に保存する。

    Blocker 7: Verification が弱い

    #1090 の現 VC は pytest ... -k "scope_signal_guard or loop_state or termination" という広めの指定と canonical gates 中心です。これだと、対象 fixture が実際に #985/#1060 を再現しているか、anchor approval が target issue / owner / stale body を検証しているかが抜けます。

    最低限、次の targeted tests を AC に落とすべきです。

    uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_termination.py -q
    uv run pytest .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py -k "scope_delta or anchor_reframe or new_allowed_path_layer" -q
    uv run pytest .claude/skills/issue-refinement-loop/tests/test_refinement_phase_gate.py -q
    uv run pytest tests/test_issue_refinement_ops_review.py -k "scope_signal_guard or human_escalation" -q

    加えて、CI artifact を evidence にするなら、artifact name、artifact-id、artifact-url、artifact-digest、retention-days、run id を出すべきです。actions/upload-artifact は artifact-id / artifact-url / artifact-digest を output として提供し、retention-days は通常 1〜90 日の範囲で指定できます。([GitHub]4) ([GitHub]4)


    推奨する #1090 契約修正

    ## Required Contract Changes
    
    1. #920 compatibility
       - Existing `ANCHOR_SCOPE_REFRAME` / `excluded_by_anchor_reframe` を破壊しない。
       - `Scope Delta Approval` は alias または v2 marker として追加する。
       - target issue URL / author_association / comment id / body hash を artifact に保存する。
    
    2. #1027 dependency
       - `scope_signal_delta` が利用可能な場合は before/current/after 差分で new layer を判断する。
       - 利用不可なら #1027 を blocked_by に置き、本 Issue では lane naming だけを定義する。
    
    3. #550/PR #554 alignment
       - `scope_context` / `domain_flags` / `ordering_constraint` に統合する。
       - path layer は `scope_context.path_layer` として出す。
       - 語彙一致や path prefix だけで escalation しない。
    
    4. Security separation
       - security / token / permission / access-control / secret exposure は #558 系の別 gate required。
       - Scope Delta Approval では override 不可。
    
    5. Route semantics
       - `proceed_with_notes` は implementation go ではない。
       - issue-contract-review の current-body `status: go` を必須にする。

    そのまま貼れるレビューコメント案

    ## 判定
    
    REQUEST_CHANGES。
    
    #1090 の方向性は妥当です。#985 の `EnemySpawnSystem.ts` 追加、#1060 の新規 skill directory 追加のように、危険な runtime scope expansion と管理対象 docs/skill/policy expansion が同じ `new_allowed_path_layer` / human escalation に落ちる現状は直すべきです。
    
    ただし、現契約のまま実装すると既存の #550/#920/#1027/#1086 と衝突します。
    
    ### Blockers
    
    1. #920 の anchor reframe schema と互換性が未定義です。
       - `Scope Delta Approval` / `Allowed Paths Expansion Rationale` を新規 marker として追加するなら、既存 `ANCHOR_SCOPE_REFRAME` / `excluded_by_anchor_reframe` を壊さないこと。
       - target issue URL、author_association、comment id、body hash を artifact に保存してください。
    
    2. #1027 の差分ベース判定が prerequisite です。
       - before/current/after の差分証跡なしに lane split だけを入れると、既存 layer の再掲をまた `new_allowed_path_layer` 扱いします。
       - #1027 を blocked_by にするか、本 Issue の Allowed Paths / AC に `scope_signal_delta` 実装を含めてください。
    
    3. #550/PR #554 の `scope_context` 設計と統合してください。
       - runtime/docs/skill/hook/agent/test は独立した判定器ではなく、`scope_context.path_layer` として出すべきです。
       - `domain_flags` は audit 用、`conflict_type` / `escalation_required` が routing 主因、という既存方針を維持してください。
    
    4. #1086 と fixture / state builder が衝突しています。
       - #1086 は `build_refinement_phase_state.py` と #985 fixture を扱い、scope_signal_guard を Out of Scope にしています。
       - #1090 は #1086 後に sequence するか、C1 benign overlap を明示してください。
    
    5. `proceed_with_notes` は implementation permission ではありません。
       - anchor approval があっても、current issue body に対する `issue-contract-review status: go` を再取得するまでは実装開始不可としてください。
    
    6. security / permission / secret 系は Scope Delta Approval で override 不可にしてください。
       - #558 の通り、scope rollup は security gate ではありません。
       - secret/token/permission/access-control は別 gate required として fail-closed にしてください。
    
    ### 追加 AC 案
    
    - AC8: Scope Delta Approval は対象 Issue の comment URL のみ有効。別 Issue / PR / 外部 URL は invalid。
    - AC9: author_association が OWNER / MEMBER / COLLABORATOR でない場合は invalid。
    - AC10: `SCOPE_SIGNAL_GUARD_DECISION_V2` artifact に raw_signal / scope_context / scope_delta_approval / route を保存する。
    - AC11: #985 fixture は runtime path expansion + approval missing で human_judgment_required、approval present でも contract-review rerun required になる。
    - AC12: #1060 fixture は docs/skill layer + deterministic approval + no security flag で proceed_with_notes になる。
    - AC13: security-sensitive path/term がある場合、Scope Delta Approval があっても security_risk_gate_required になる。

    結論として、#1090 は 必要だが、先に契約を tightening すべき Issue です。特に #920 と #1027 を前提化し、#550/PR #554 の scope_context に統合するのが最短です。

  3. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard_triggered: new_allowed_path_layer が検出された(アンカーコメント Blocker 7 で要求されたテストファイル 2 件が Allowed Paths に追加された)"
    
    "excluded_by_anchor_reframe=false: アンカーコメント(#issuecomment-4761615763、OWNER by squne121)は明示的に test ファイルを要求したが、ANCHOR_SCOPE_REFRAME / Scope Delta Approval マーカーが使用されていないため planner が reframe を認識できなかった"
    
    "注記: この停止は Issue #1090 が解決しようとしている誤停止パターン(docs/skill layer の過剰 human escalation)の典型例。Issue #1090 マージ後は proceed_with_notes で継続できる見込み。次ステップ: アンカーコメントに ANCHOR_SCOPE_REFRAME マーカーを追加するか、Allowed Paths からテストファイルを除外して再実行してください。"
    
  4. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    ANCHOR_SCOPE_REFRAME

    Scope Delta Approval — Allowed Paths へのテストファイル追加を承認する。

    本コメントは issue-refinement-loop の scope_signal_guard 停止(iteration 0)への応答として、以下の Allowed Paths 追加を明示的に承認する:

    • .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_termination.py(新規作成 AC 検証用)
    • .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py(既存テスト拡張)

    これらは anchor comment(#issuecomment-4761615763)の Blocker 7 で明示的に要求されたテストファイルであり、AC8〜AC13 の検証に必要。runtime scope expansion ではなく test/docs layer の追加であるため proceed_with_notes 対象とする。

    Allowed Paths Expansion Rationale: 実装 AC の verification test files 追加は scope_context.path_layer = test_fixture に分類される。security-sensitive path は含まない。

  5. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard.excluded_by_anchor_reframe が現行 plan_refinement_loop.py では常に false を返す(ANCHOR_SCOPE_REFRAME マーカー検出ロジック未実装)"
    
    "これは Issue #1090 自身が修正しようとしている pre-fix 動作であるため、本 loop では突破できない"
    
    "改善済み Issue body は check_issue_contract.py の全 C1-C13 を通過している(VERDICT: approve)。issue-contract-review を人間が手動実行するか、#1090 マージ後に refinement-loop を再実行することを推奨する"
    
  6. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  7. squne121 commented on Jun 21, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot — Issue #1090

    status: go

    チェック 結果
    template_compliance ✅ pass
    state_label ✅ pass(state/needs-human なし)
    allowed_paths_present ✅ pass
    vc_present ✅ pass
    stop_conditions_complete ✅ pass(7 件)
    blockers(native API) ✅ pass
    vc_preflight ✅ pass(AC1-AC13 全 go)
    ac_verifiability ✅ pass
    product_spec_check ✅ pass
    worktree_branch_collision ✅ pass

    VC Preflight 集約

    AC コマンド 結果 scope_class
    AC1–AC6, AC8–AC13 uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_lane_split.py -q exit 4(ファイル未存在) baseline_fail_expected / go
    AC7 pnpm typecheck exit 0 regression_gate / go
    AC7 pnpm lint exit 0 regression_gate / go
    AC7 pnpm test exit 0(922 passed) regression_gate / go
    AC7 pnpm build exit 0 regression_gate / go

    Worktree / Branch

    • Branch: worktree-issue-1090-scope-signal-guard-lane-split
    • Worktree: .claude/worktrees/issue-1090-scope-signal-guard-lane-split
    • 既存 worktree 衝突: なし

    Outcome

    scope_signal_guard が new_runtime_path_layer, new_skill_or_docs_layer, new_hook_or_agent_layer, missing_scope_delta_approval を分けて出力し、人間判断が必要なケースと proceed_with_notes 可能なケースを区別する。

    Acceptance Criteria(13件)

    Allowed Paths

    • .claude/skills/issue-refinement-loop/references/scope-signal-guard.md
    • .claude/skills/issue-refinement-loop/references/loop-state.md
    • .claude/skills/issue-refinement-loop/references/termination-policy.md
    • .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
    • .claude/skills/issue-refinement-loop/scripts/build_loop_state.py
    • .claude/skills/issue-refinement-loop/fixtures/

    ⚠️ 実装前提注意

    blocked_by: [920, 1027] が本 Issue の Machine-Readable Contract に宣言されており、両 Issue (#920, #1027) は現在 OPEN。GitHub native dependency API はこれを自動検出しないが、実装着手は #920 と #1027 の完了後とする。

  8. squne121 commented on Jul 1, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-01T17:48:25Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1090
      body_sha256: "sha256:4048e559d165b8c36cd81f89bcff66b3c1b0653bc2e7730b482917dc1860647f"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  9. added a commit that references this issue on Jul 2, 2026
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

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions