Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "scope_signal_guard の差分判定仕様を安全化し、既存 layer 再掲や並び替えで false positive を出さない deterministic な delta facts を追加する"
change_kind: workflowParent Issue
なし(standalone issue)
Parent Goal Ref
- Goal: issue-refinement-loop の scope_signal 判定を再現可能な差分事実に基づいて評価できるようにする
- Desired Destination:
new_allowed_path_layerの false positive を減らし、後続 issue が consume 可能な差分 artifact と planner projection を固定する
Background
- 現行
plan_refinement_loop.pyのscope_signal_guardは before/current/after の差分ではなく、Allowed PathsやIn Scopeの語彙・prefix に強く依存しており、既存 layer の再掲や順序変更でもnew_allowed_path_layerを起こし得る。 - owner comment では、実装: agent-ops: scope_signal_guard を差分ベース診断にして In Scope 語彙追加停止ループを防ぐ #1027 をこのまま実装すると feat: issue-refinement-loop に anchor scope reframe comment schema を追加する #920 の trusted anchor 境界、実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 の lane split 前提、既存 preflight/planner の raw comment 分離境界を壊すと指摘されている。
- current repo では feat: issue-refinement-loop に anchor scope reframe comment schema を追加する #920 が
scope_delta_decisionの normalized contract を導入済みで、実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 は 実装: agent-ops: scope_signal_guard を差分ベース診断にして In Scope 語彙追加停止ループを防ぐ #1027 が出す差分 fact を consume して lane split する前提にある。したがって 実装: agent-ops: scope_signal_guard を差分ベース診断にして In Scope 語彙追加停止ループを防ぐ #1027 は lane split 自体ではなく、差分判定仕様と artifact 契約の固定に責務を限定する。
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.pyを追加し、SCOPE_SIGNAL_DELTA_INPUT_V1を read-only / stdin JSON / stdout canonical JSON の deterministic CLI と library API として固定する.claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.jsonを追加し、before/current/after の body hash・source_refs・normalized delta facts・legacyscope_signal_guardprojection を固定する.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.pyで top-level prefix 数え上げベースのnew_allowed_path_layer判定を廃止し、scope_signal_deltaprojection を consume する.claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py/tests/test_plan_refinement_loop.py/tests/test_scope_signal_guard_termination.py/tests/test_anchor_scope_reframe_preflight.py/tests/test_anchor_comment_artifact_boundary.pyとtests/fixtures/scope_signal_delta/**を追加・更新し、既存 layer 再掲・並び替え・空白差分・trusted anchor projection・raw anchor 非注入・非自動修正 policy の回帰を固定する.claude/skills/issue-refinement-loop/references/scope-signal-guard.mdを更新し、trusted anchor は raw comment body ではなく既存の normalizedknown_context.scope_delta_decisionのみを参照し、approved_by_trusted_anchorかつimplementation_go=falseの境界を維持することを明記する- 実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 が consume できる最小 artifact/schema/test だけを追加し、lane split 自体は out of scope に残す
Remaining Parent Gaps
なし(standalone issue)
Outcome
scope_signal_delta が before/current/after の section delta を deterministic に算出し、plan_refinement_loop.py はその projection に基づいて new_allowed_path_layer を判定する。既存 layer の再掲、並び替え、空白差分、fenced code 内の path mention では false positive を出さず、trusted anchor がある場合も raw comment body を再 parse しない。
Source Of Truth
SCOPE_SIGNAL_DELTA_INPUT_V1
before_body: string
current_body: string
after_body: string
source_refs:
before: string | null
current: string | null
after: string | nullbefore_body: rewrite 前の canonical issue bodycurrent_body: planner / checker が評価対象として読む current snapshot bodyafter_body: proposed rewrite body または fixture が与える candidate bodysource_refs.*: issue URL / artifact path / fixture path / comment id のいずれかを表す provenance
production path で raw anchor comment body を before/current/after に流してはならない。anchor 由来の抑止条件は、既存 preflight が生成する normalized known_context.scope_delta_decision のみを consume する。
In Scope
.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.pyの追加.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.pyのscope_signal_guard判定をscope_signal_deltaprojection 経由へ置換.claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.jsonの追加.claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.pyの追加・更新.claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.pyの差分判定 / anchor projection 回帰追加.claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_termination.pyの回帰追加.claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.pyの trusted anchor projection 回帰追加.claude/skills/issue-refinement-loop/tests/test_anchor_comment_artifact_boundary.pyの raw anchor 非注入回帰追加.claude/skills/issue-refinement-loop/tests/fixtures/scope_signal_delta/**の追加.claude/skills/issue-refinement-loop/references/scope-signal-guard.mdの契約更新
Out of Scope
- 実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 の lane split 実装(
new_runtime_path_layer/new_skill_or_docs_layer/new_hook_or_agent_layerへの分類) - raw anchor comment の parser / schema / trust boundary 自体の再設計(feat: issue-refinement-loop に anchor scope reframe comment schema を追加する #920 の責務)
run_refinement_preflight.pyの GitHub comment 取得経路変更build_loop_state.py/ command registry / execute-mode triage の変更- orchestrator や reviewer が
In Scope/Allowed Pathsを自動修正する実装
Acceptance Criteria
- AC1:
SCOPE_SIGNAL_DELTA_INPUT_V1とSCOPE_SIGNAL_DELTA_V1が追加され、before/current/afterの body hash・source_refs・normalized delta facts・legacyscope_signal_guardprojection を含む - AC2: 既存 layer の再掲、並び替え、空白差分、fenced code 内の path mention では
legacy_scope_signal_guard.triggered == falseになる fixture が追加される - AC3:
new_allowed_path_layerはafter.allowed_path_layers - before.allowed_path_layersが非空の場合にのみ発火する - AC4:
excluded_by_anchor_reframe=trueはknown_context.scope_delta_decision.status == "approved_by_trusted_anchor"かつimplementation_go == falseかつrequired_rerun保持時だけ出る - AC5:
plan_refinement_loop.py/scope_signal_delta.pyは raw anchor comment body を読まず、normalizedscope_delta_decisionだけを consume する - AC6:
scope_signal_deltaは lane split を行わず、実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 が consume 可能な normalized delta facts(added / removed / repeated_existing / triggering_lines)だけを出力する - AC7:
scope_signal_guardが発火しても orchestrator がIn Scope/Allowed Pathsを自動修正しない既存 policy を回帰テストで維持する
Verification Commands
# AC1
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py -q -k "schema or artifact"
# AC2
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py -q -k "repeated or reordered or whitespace or fenced_code"
# AC3
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py -q -k "new_allowed_path_layer"
# AC4
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py -q -k "approved_trusted_anchor_scope_delta_decision"
# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_comment_artifact_boundary.py -q
# AC6
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_delta.py -q -k "projection or repeated_existing"
# AC7
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_scope_signal_guard_termination.py -qAllowed Paths
.claude/skills/issue-refinement-loop/scripts/scope_signal_delta.py.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py.claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.json.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_scope_signal_guard_termination.py.claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py.claude/skills/issue-refinement-loop/tests/test_anchor_comment_artifact_boundary.py.claude/skills/issue-refinement-loop/tests/fixtures/scope_signal_delta/**.claude/skills/issue-refinement-loop/references/scope-signal-guard.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- 実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 の lane split 実装まで同時に要求され、責務分離が維持できない場合
- feat: issue-refinement-loop に anchor scope reframe comment schema を追加する #920 の trusted anchor 境界を壊さずに
scope_delta_decisionprojection を consume できないと判明した場合 before/current/afterの SoT を定義するために raw anchor comment body や GitHub mutation 経路の再設計が必要になった場合- 新規 Issue の起票が必要な scope split が発生した場合
scope_signal_deltaartifact を planner / tests の既存 consumer が deterministic に consume できず、別 schema migration issue が必要と判明した場合
Runtime Verification Applicability
decision: not_applicable
reason: "workflow script / schema / fixture / reference の変更のみを対象とし、runtime gameplay や CI workflow lane split 自体は変更しない"
deferred_destination: n/aRelated Issues
- feat: issue-refinement-loop に anchor scope reframe comment schema を追加する #920: trusted anchor /
scope_delta_decisionの信頼境界 - 実装: agent-ops: issue-refinement-loop の LOOP_STATE builder を追加し手書き JSON routing を禁止する #1024: LOOP_STATE builder の先行整備
- 実装: agent-ops: issue-refinement-loop command registry を追加し誤パス・誤引数・quote 迷走を防止する #1026: command registry の先行整備
- 実装: agent-ops: contract_readiness execute-mode human_judgment を環境 triage に正規化する #1028: execute-mode triage の sibling issue
- 実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090: 実装: agent-ops: scope_signal_guard を差分ベース診断にして In Scope 語彙追加停止ループを防ぐ #1027 の normalized delta facts を consume する後続 issue
Required Skills
- Python(JSON / delta 計算 / pytest)
- issue-refinement-loop architecture
- JSON Schema
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 1, 2026
判定: REQUEST_CHANGES
#1027 の問題意識は妥当です。現行
plan_refinement_loop.pyのscope_signal_guardは、Allowed Pathsの top-level prefix が 2 種以上あるだけでnew_allowed_path_layerを出す構造で、before/current/after 差分を見ていません。つまり「既存 layer の再掲」や「順序変更」でも停止し得るため、差分ベース化は必要です。ただし、#1027 はこのまま実装に入るべきではありません。Issue 契約が曖昧なままだと、#920 の trusted anchor 境界、#1090 の scope lane split 前提、既存 preflight/planner の raw comment 分離境界を壊す可能性が高いです。
致命的指摘
1. Parent contract が破綻している
#1027 の Machine-Readable Contract は
parent_issue: "none"なのに、本文の## Parent Issueは#964です。さらに #964 はPR body hygiene 更新は update_pr.py wrapper 経由に限定するIssue で、directgh pr editbody mutation の hook/wrapper 制御が主題です。scope_signal_delta / issue-refinement-loop の親としては意味が合いません。同じ agent-ops 系の #1024 は LOOP_STATE builder、#1026 は command registry で、#1027 はそれらと並ぶ「scope_signal 差分ベース化」slot に見えます。#1024 も Remaining Parent Gaps で scope_signal 差分分類を別 Issue として扱っており、#1026 も scope_signal guard 変更を Out of Scope にしています。
修正要求:
parent_issueを実際の agent-ops rollup に直すか、standalone としてrelated_issues: [1024, 1026, 1028, 920, 1090]を明示してください。現状のままだと、contract lineage / Remaining Parent Gaps / stop condition の解釈が壊れます。2.
before/current/afterの SoT が未定義#1027 は「before/current/after のハッシュと差分行」を要求していますが、3 つの本文がどこから来るのかを定義していません。現行
run_refinement_preflight.pyは repair dry-run を実行しても、planner には original Issue body を渡す設計です。このままでは実装者が次のどれを
afterとみなすべきか判断できません。issue-author が提案した rewrite 後 body
repair_issue_contract.pyの dry-run resultGitHub 上の current issue body
preflight fixture 内の proposed body
planner 実行時に main thread が保持しているローカル draft
修正要求:
scope_signal_delta.pyの入力契約を固定してください。最低限、以下のように明示すべきです。after_bodyを production preflight から生成するなら、#1027 の Allowed Paths にはrun_refinement_preflight.pyか rewrite producer 側が必要です。Allowed Paths を増やせないなら、#1027 はscope_signal_delta.pyの純粋 CLI + planner integration に限定し、after は fixture/stdin から受ける契約にしてください。3. Artifact schema がないため #1090 が消費できない
#1090 は #1027 を blocked_by にしており、
new_allowed_path_layerを runtime / docs / skill / hook / agent / test などへ lane split する前提として、#1027 の差分ベース診断を要求しています。しかし #1027 は
scope_signal_deltaartifact を追加するとだけ書いており、schema_version、必須 field、互換性、legacyreason_codeとの関係を固定していません。これでは #1090 側が安定して consume できません。修正要求: Allowed Paths に schema を追加してください。
推奨する最小 schema は次です。
JSON Schema で
allOfなどの composition を使う場合、additionalProperties: falseは subschema をまたぐ拡張と衝突しやすいため、Draft 2019-09 以降のunevaluatedProperties: falseを検討すべきです。(JSON Schema)4. 現行 guard の置換単位が曖昧
現行
plan_refinement_loop.pyは_detect_scope_signals(issue_body, known_context)を直接呼び、scope_signal_guard.triggered/reason_code/excluded_by_anchor_reframeを組み立てています。#1027 は「scope 判定を差分ベース API 経由へ移行」と書いていますが、次が未定義です。
_detect_scope_signalsを削除するのか_detect_scope_signalsがscope_signal_delta.pyの library API を呼ぶのかscope_signal_delta.pyは CLI 専用なのか、import 可能 module なのかlegacy
scope_signal_guard出力を誰が生成するのかdiff artifact は planner output に埋め込むのか、artifact path 参照にするのか
修正要求: production path は次のように固定してください。
CLI は
--helpと stdin/stdout の deterministic interface を持つべきですが、planner が shell out する設計は避けるべきです。planner 内部で subprocess を挟むと、失敗分類と artifact hash が複雑になります。5. Anchor reframe の境界を壊す危険がある
#920 / PR #1119 後の current repo では、trusted anchor は
run_refinement_preflight.pyが GitHub issue comment を取得し、author_association、target repo/issue、schema validation を見たうえでknown_context.scope_delta_decisionに正規化する構造になっています。scope-signal-guard.mdも、trusted anchor はimplementation_go=falseで、contract review / refinement preflight / allowed_paths_gate の再実行が必要だと明記しています。#1027 の AC4 は「anchor が明示的に再フレーム許可している場合のみ
excluded_by_anchor_reframe=true」とだけ書いています。これだと実装者がplan_refinement_loop.pyで raw comment body を再 parse し、#920 の raw-body 境界を破る危険があります。修正要求: AC4 を次のように狭めてください。
GitHub issue comments API は
bodyだけでなくissue_urlとauthor_associationを返します。trusted 判定はこの API metadata を SoT にすべきで、コメント本文の自己申告を信じる設計に戻してはいけません。(GitHub Docs)6. #1090 との責務境界が危ない
#1090 は #1027 完了後に
new_runtime_path_layer/new_skill_or_docs_layer/new_hook_or_agent_layer/missing_scope_delta_approvalへ lane split する Issue です。#1090 のレビューコメントでも、path prefix だけで lane 分類すると false positive を再発させると指摘されています。#1027 がやるべきことは lane split ではなく、lane split 可能な normalized delta facts を出すことです。
#1027 側で出すべきもの:
#1090 側に残すべきもの:
この分離を #1027 本文に入れないと、#1027 が #1090 の lane split まで先取りして scope creep します。
実装品質に関する外部調査ベースの改善点
差分判定は unified diff 文字列ではなく、正規化 set/opcode で行う
Python
difflibは human-friendly な差分生成に向いていますが、SequenceMatcherは最小 edit script を保証しないうえ、繰り返し要素に対する heuristic があります。unified_diffは人間向け evidence としては有用ですが、判定ロジックの唯一の SoT にすべきではありません。(Python documentation)推奨:
difflib.unified_diff(..., n=0 or 3, lineterm="")は artifact のhuman_diffとして残す程度に留めるべきです。Git-like artifact を出すなら patch 適用可能性を主張しない
Git の
diff --git a/file b/file形式は traditional unified diff と細部が異なり、rename/copy/path quoting などもあります。#1027 の artifact が Git patch ではなく issue body section diff なら、git diff compatibleと主張しない方が安全です。(Git)推奨 field:
JSON は load/dump の両方で strict にする
Python
json.dumps(..., allow_nan=False, sort_keys=True)は regression artifact に適しています。読み込み側ではparse_constantを使ってNaN/Infinity/-Infinityを reject できます。(Python documentation)現行
plan_refinement_loop.pyは decode 後に NaN/Infinity を再帰検査していますが、parse_constantを使えば decode 時点で fail-closed にできます。追加すべき fixture
最低限、次の fixture が必要です。
特に最後の AC5 は
plan_refinement_loop.py単体では証明しにくいです。scope-signal-guard.mdは orchestrator が planner output を consume するだけで判定を再実装しない、scope 拡張を自動承認しない、と明記しています。Allowed Paths を増やせないなら、AC5 は「既存 policy に対する regression assertion」に弱めるか、別 Issue に分割してください。
Verification Commands の問題
#1027 の現行 Verification Commands は AC と対応していません。
AC2 の command が
scope_signal_delta.py --helpになっており、「before 既存 layer を new 扱いしない fixture」の検証になっていません。AC3 は
plan_refinement_loop.py < input_existing_layers.jsonだけで、stdout のreason_code/triggeredassertion がありません。AC5 の
pnpm typecheck/lint/test/buildは repo-wide gate であり、「orchestrator が In Scope を自動修正しない」証明にはなりません。推奨:
repo-wide gates は最後に残してよいですが、AC の primary evidence にしてはいけません。
そのまま貼れる修正版レビューコメント案
結論
#1027 は 必要だが、契約修正が先 です。特に修正すべきは、親子関係、before/current/after の入力契約、
SCOPE_SIGNAL_DELTA_V1schema、#920 trusted anchor 境界、#1090 との責務分離です。現行のまま実装すると、
## 判定: REQUEST_CHANGESnew_allowed_path_layerの false positive を減らす目的に対して、artifact 非互換・anchor bypass・scope creep のリスクが高いです。#1027 の問題意識は妥当です。現行
plan_refinement_loop.pyのscope_signal_guardは、Allowed Pathsの top-level prefix が 2 種以上あるだけでnew_allowed_path_layerを出す構造で、before/current/after 差分を見ていません。つまり「既存 layer の再掲」や「順序変更」でも停止し得るため、差分ベース化は必要です。ただし、#1027 はこのまま実装に入るべきではありません。Issue 契約が曖昧なままだと、#920 の trusted anchor 境界、#1090 の scope lane split 前提、既存 preflight/planner の raw comment 分離境界を壊す可能性が高いです。
致命的指摘
1. Parent contract が破綻している
#1027 の Machine-Readable Contract は
parent_issue: "none"なのに、本文の## Parent Issueは#964です。さらに #964 はPR body hygiene 更新は update_pr.py wrapper 経由に限定するIssue で、directgh pr editbody mutation の hook/wrapper 制御が主題です。scope_signal_delta / issue-refinement-loop の親としては意味が合いません。同じ agent-ops 系の #1024 は LOOP_STATE builder、#1026 は command registry で、#1027 はそれらと並ぶ「scope_signal 差分ベース化」slot に見えます。#1024 も Remaining Parent Gaps で scope_signal 差分分類を別 Issue として扱っており、#1026 も scope_signal guard 変更を Out of Scope にしています。
修正要求:
parent_issueを実際の agent-ops rollup に直すか、standalone としてrelated_issues: [1024, 1026, 1028, 920, 1090]を明示してください。現状のままだと、contract lineage / Remaining Parent Gaps / stop condition の解釈が壊れます。2.
before/current/afterの SoT が未定義#1027 は「before/current/after のハッシュと差分行」を要求していますが、3 つの本文がどこから来るのかを定義していません。現行
run_refinement_preflight.pyは repair dry-run を実行しても、planner には original Issue body を渡す設計です。このままでは実装者が次のどれを
afterとみなすべきか判断できません。repair_issue_contract.pyの dry-run result修正要求:
scope_signal_delta.pyの入力契約を固定してください。最低限、以下のように明示すべきです。after_bodyを production preflight から生成するなら、#1027 の Allowed Paths にはrun_refinement_preflight.pyか rewrite producer 側が必要です。Allowed Paths を増やせないなら、#1027 はscope_signal_delta.pyの純粋 CLI + planner integration に限定し、after は fixture/stdin から受ける契約にしてください。3. Artifact schema がないため #1090 が消費できない
#1090 は #1027 を blocked_by にしており、
new_allowed_path_layerを runtime / docs / skill / hook / agent / test などへ lane split する前提として、#1027 の差分ベース診断を要求しています。しかし #1027 は
scope_signal_deltaartifact を追加するとだけ書いており、schema_version、必須 field、互換性、legacyreason_codeとの関係を固定していません。これでは #1090 側が安定して consume できません。修正要求: Allowed Paths に schema を追加してください。
+ .claude/skills/issue-refinement-loop/schemas/scope_signal_delta_v1.schema.json推奨する最小 schema は次です。
JSON Schema で
allOfなどの composition を使う場合、additionalProperties: falseは subschema をまたぐ拡張と衝突しやすいため、Draft 2019-09 以降のunevaluatedProperties: falseを検討すべきです。(JSON Schema)4. 現行 guard の置換単位が曖昧
現行
plan_refinement_loop.pyは_detect_scope_signals(issue_body, known_context)を直接呼び、scope_signal_guard.triggered/reason_code/excluded_by_anchor_reframeを組み立てています。#1027 は「scope 判定を差分ベース API 経由へ移行」と書いていますが、次が未定義です。
_detect_scope_signalsを削除するのか_detect_scope_signalsがscope_signal_delta.pyの library API を呼ぶのかscope_signal_delta.pyは CLI 専用なのか、import 可能 module なのかscope_signal_guard出力を誰が生成するのか修正要求: production path は次のように固定してください。
CLI は
--helpと stdin/stdout の deterministic interface を持つべきですが、planner が shell out する設計は避けるべきです。planner 内部で subprocess を挟むと、失敗分類と artifact hash が複雑になります。5. Anchor reframe の境界を壊す危険がある
#920 / PR #1119 後の current repo では、trusted anchor は
run_refinement_preflight.pyが GitHub issue comment を取得し、author_association、target repo/issue、schema validation を見たうえでknown_context.scope_delta_decisionに正規化する構造になっています。scope-signal-guard.mdも、trusted anchor はimplementation_go=falseで、contract review / refinement preflight / allowed_paths_gate の再実行が必要だと明記しています。#1027 の AC4 は「anchor が明示的に再フレーム許可している場合のみ
excluded_by_anchor_reframe=true」とだけ書いています。これだと実装者がplan_refinement_loop.pyで raw comment body を再 parse し、#920 の raw-body 境界を破る危険があります。修正要求: AC4 を次のように狭めてください。
GitHub issue comments API は
bodyだけでなくissue_urlとauthor_associationを返します。trusted 判定はこの API metadata を SoT にすべきで、コメント本文の自己申告を信じる設計に戻してはいけません。([GitHub Docs]2)6. #1090 との責務境界が危ない
#1090 は #1027 完了後に
new_runtime_path_layer/new_skill_or_docs_layer/new_hook_or_agent_layer/missing_scope_delta_approvalへ lane split する Issue です。#1090 のレビューコメントでも、path prefix だけで lane 分類すると false positive を再発させると指摘されています。#1027 がやるべきことは lane split ではなく、lane split 可能な normalized delta facts を出すことです。
#1027 側で出すべきもの:
#1090 側に残すべきもの:
この分離を #1027 本文に入れないと、#1027 が #1090 の lane split まで先取りして scope creep します。
実装品質に関する外部調査ベースの改善点
差分判定は unified diff 文字列ではなく、正規化 set/opcode で行う
Python
difflibは human-friendly な差分生成に向いていますが、SequenceMatcherは最小 edit script を保証しないうえ、繰り返し要素に対する heuristic があります。unified_diffは人間向け evidence としては有用ですが、判定ロジックの唯一の SoT にすべきではありません。([Python documentation]3)推奨:
difflib.unified_diff(..., n=0 or 3, lineterm="")は artifact のhuman_diffとして残す程度に留めるべきです。Git-like artifact を出すなら patch 適用可能性を主張しない
Git の
diff --git a/file b/file形式は traditional unified diff と細部が異なり、rename/copy/path quoting などもあります。#1027 の artifact が Git patch ではなく issue body section diff なら、git diff compatibleと主張しない方が安全です。([Git]4)推奨 field:
JSON は load/dump の両方で strict にする
Python
json.dumps(..., allow_nan=False, sort_keys=True)は regression artifact に適しています。読み込み側ではparse_constantを使ってNaN/Infinity/-Infinityを reject できます。([Python documentation]5)現行
plan_refinement_loop.pyは decode 後に NaN/Infinity を再帰検査していますが、parse_constantを使えば decode 時点で fail-closed にできます。追加すべき fixture
最低限、次の fixture が必要です。
existing_allowed_path_repeated.jsontriggered=falseallowed_paths_reordered.jsontriggered=falseallowed_paths_whitespace_only.jsontriggered=falsenew_allowed_path_same_layer.jsonnew_allowed_path_new_layer.jsonnew_allowed_path_layermixed_existing_and_new_layers.jsonfenced_code_mentions_path.jsonmarkdown_table_allowed_paths.jsonanchor_trusted_suppresses_signal.jsonexcluded_by_anchor_reframe=trueanchor_fail_closed_does_not_suppress.jsonjson_nan_rejected.jsonorchestrator_no_auto_scope_rewrite.json特に最後の AC5 は
plan_refinement_loop.py単体では証明しにくいです。scope-signal-guard.mdは orchestrator が planner output を consume するだけで判定を再実装しない、scope 拡張を自動承認しない、と明記しています。Allowed Paths を増やせないなら、AC5 は「既存 policy に対する regression assertion」に弱めるか、別 Issue に分割してください。
Verification Commands の問題
#1027 の現行 Verification Commands は AC と対応していません。
scope_signal_delta.py --helpになっており、「before 既存 layer を new 扱いしない fixture」の検証になっていません。plan_refinement_loop.py < input_existing_layers.jsonだけで、stdout のreason_code/triggeredassertion がありません。pnpm typecheck/lint/test/buildは repo-wide gate であり、「orchestrator が In Scope を自動修正しない」証明にはなりません。推奨:
repo-wide gates は最後に残してよいですが、AC の primary evidence にしてはいけません。
そのまま貼れる修正版レビューコメント案
結論
#1027 は 必要だが、契約修正が先 です。特に修正すべきは、親子関係、before/current/after の入力契約、
SCOPE_SIGNAL_DELTA_V1schema、#920 trusted anchor 境界、#1090 との責務分離です。現行のまま実装すると、
new_allowed_path_layerの false positive を減らす目的に対して、artifact 非互換・anchor bypass・scope creep のリスクが高いです。squne121 commentedon Jul 1, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 1, 2026
Contract Review Result
docs(agent-ops): localize scope signal guard headings (#1027)
test(agent-ops): fix scope signal delta import order (#1027)
test(agent-ops): wrap scope signal fixture strings (#1027)
fix(agent-ops): harden scope signal delta consume path (#1027)
fix(agent-ops): scope_signal_delta を追加して scope_signal_guard を差分判定化 (#…
squne121 commentedon Jul 2, 2026
PR #1276 のマージに伴う post-merge cleanup を完了したためクローズします。dedicated worktree は既に消えており、残っていた local branch も canonical cleanup 経路で削除済みです。