Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "anchor scope reframe comment の機械可読 schema (ANCHOR_SCOPE_REFRAME_V1) を追加し、GitHub API 由来の author_association を信頼境界として、scope_delta_decision を生成する最小実装を固定する"
change_kind: codeParent Issue
なし(standalone implementation issue)
Parent Goal Ref
なし
Background
scope_signal_guard は excluded_by_anchor_reframe=false の場合に human_escalation で停止するが、人間がどの形式で anchor comment を書けば excluded_by_anchor_reframe=true として扱われるかが未定義・未文書化である。
Issue #907 の停止では、OWNER が anchor comment を書いていたにもかかわらず、planner が excluded_by_anchor_reframe=false を返したことで loop が停止し、次のアクションが不明確になった。
anchor comment の現状分析 (#920 anchor comment):
plan_refinement_loop.pyは raw comment body から marker を直読みする実装ではなく、known_context.classificationやknown_context.anchor_reframeを参照しているexcluded_by_anchor_reframe=trueだけで閉じると 実装: fix(issue-refinement-loop): anchor_comment schema を docs の Required flow と一致させる #1010 / 実装: run_refinement_preflight が trusted anchor scope amendment を planner known_context に渡せるようにする #1008 / 実装: issue-refinement-loop に phase gate を追加し preflight 直後の誤った human_escalation を防ぐ #1013 / 実装: scope_signal_guard の escalation lane を分割し scope delta approval を契約化する #1090 が確立した安全境界を壊すauthor_associationは GitHub API response の metadata を信頼境界にすべきであり、コメント本文の自己申告を信じてはいけない- trusted anchor の効果は
implementation_go=false+required_rerun付きのscope_delta_decisionとすべき
Outcome
ANCHOR_SCOPE_REFRAME_V1 schema が存在し、OWNER/MEMBER/COLLABORATOR の GitHub API author_association を持つ anchor comment が schema validation を通過したとき、scope_delta_decision.status=approved_by_trusted_anchor(implementation_go=false、required_rerun 付き)が生成されることが pytest fixture で固定される。後方互換として excluded_by_anchor_reframe=true を出力する場合でも、primary contract は scope_delta_decision とする。
Current Validated Scope
ANCHOR_SCOPE_REFRAME_V1schema の定義(必須フィールド・required・additionalProperties:false・enum)scope-signal-guard.mdへの copy/paste 可能 template の追加- trusted anchor の判定ロジック(GitHub API
author_associationを SoT として使用) scope_delta_decisionartifact 生成(implementation_go=false+required_rerun必須)- fail-closed fixture(untrusted author / wrong issue / wrong repo / multiple URL / malformed schema / quoted/fenced marker)
- phase-sensitive semantics の固定(preflight/investigation/review では hard stop せず)
In Scope
.claude/skills/issue-refinement-loop/references/scope-signal-guard.mdANCHOR_SCOPE_REFRAME_V1schema の copy/paste template を追加するplan_refinement_loop.pyが期待する marker / field を文書化する- trusted anchor 判定の信頼境界(GitHub API
author_association)を明記する
.claude/skills/issue-refinement-loop/references/anchor-comment-handling.md- raw anchor body と planner input の境界を明記する
- normalized decision / hash / provenance のみ planner へ渡す仕様を追記する
.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py_is_anchor_reframe_contextが期待 marker を検出できる場合は既存実装を document する- 期待 schema が未実装の marker がある場合は最小限の deterministic parser を追加する
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py- GitHub API
author_associationを anchor trust 判定に使用する
- GitHub API
.claude/skills/issue-refinement-loop/schemas/anchor_scope_reframe_v1.schema.jsonrequired/additionalProperties:false/ enum / null handling を固定する
.claude/skills/issue-refinement-loop/tests/new_allowed_path_layerを明示的に許可する anchor comment fixture でexcluded_by_anchor_reframe=true/scope_delta_decision.status=approved_by_trusted_anchorになること- anchor comment が対象 Issue 外の URL の場合は従来どおり fail-closed すること
- untrusted author / wrong issue / wrong repo / multiple URL / malformed schema / quoted/fenced marker のすべてが fail-closed になること
- phase-sensitive routing の fixture(preflight では hard stop せず、post_rewrite_check では hard stop すること)
Allowed Paths
.claude/skills/issue-refinement-loop/references/scope-signal-guard.md.claude/skills/issue-refinement-loop/references/anchor-comment-handling.md.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/schemas/anchor_scope_reframe_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_loop_plan_v1.json.claude/skills/issue-refinement-loop/tests/.claude/skills/issue-refinement-loop/fixtures/
Acceptance Criteria
- AC1:
ANCHOR_SCOPE_REFRAME_V1の copy/paste template がscope-signal-guard.mdに存在し、target repo / issue_number / allowed_path_deltas / rationale / required_rerun を含む - AC2: template は
schemas/anchor_scope_reframe_v1.schema.jsonで validation され、required/additionalProperties:false/ enum / null handling が固定される - AC3: GitHub API 由来の
author_association in OWNER|MEMBER|COLLABORATOR、target issue 一致、target repo 一致、単一 anchor URL の場合だけ trusted anchor とする - AC4:
CONTRIBUTOR/NONE/ missing metadata / wrong issue / wrong repo / multiple anchor URL / malformed schema / quoted marker / fenced-code marker は fail-closed - AC5: trusted anchor は
implementation_go=falseかつrequired_rerun付きのscope_delta_decisionを生成する。scope 拡張の自動実装許可は禁止 - AC6: planner input に raw anchor comment body を流さない。raw snapshot は artifact 境界に残し、planner へは normalized decision / hash / provenance のみ渡す
- AC7: phase-sensitive semantics を固定する。preflight / investigation / review では hard stop せず、
post_rewrite_check/decide_next_actionでのみ hard stop 判定する - AC8: 後方互換 adapter として必要な場合だけ
excluded_by_anchor_reframe=trueを出すが、primary contract はscope_delta_decision.status=approved_by_trusted_anchorとする
Verification Commands
# AC1
$ rg -n "ANCHOR_SCOPE_REFRAME_V1" .claude/skills/issue-refinement-loop/references/scope-signal-guard.md
# AC2
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_schema.py -q
# AC3
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py -q -k "trusted_anchor"
# AC4
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py -q -k "fail_closed"
# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_scope_reframe_preflight.py -q -k "scope_delta"
# AC6
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py -q -k "anchor_reframe or scope_delta"
# AC7
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_anchor_phase_sensitive.py -q
# AC8
# baseline-expect: pass
$ rg -n "excluded_by_anchor_reframe" .claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py
$ pnpm typecheck
$ pnpm lintRemaining Parent Gaps
なし(standalone issue)
Required Skills
- Python / pytest(schema validation・fail-closed fixture)
- JSON Schema Draft 2020-12(required・additionalProperties・enum・null)
- GitHub REST API(issue comments
author_associationmetadata) issue-refinement-loopスキル実装(scope_signal_guard・phase gate・planner known_context)
Stop Conditions
- AC1〜AC8 の全 pytest fixture が pass すること
pnpm typecheck/pnpm lintが pass すること- raw anchor comment body が planner input に含まれないこと(AC6 fixture)
- phase-sensitive routing の regression がないこと(AC7 fixture)
run_refinement_preflight.pyおよびplan_refinement_loop.pyの Allowed Paths 外変更がないこと
Non-Goals
- anchor comment を自動生成するツールの追加
- scope 拡張の自動実装許可(
implementation_go=falseは固定) superseded_by_decisionの anchor comment format(別責務)#1008の trusted anchor → plannerknown_context伝播の実装(実装: run_refinement_preflight が trusted anchor scope amendment を planner known_context に渡せるようにする #1008 の責務)- anchor comment template の多言語化
run_refinement_preflight.pyへの既存 anchor comment 正規化 API の変更(実装: fix(issue-refinement-loop): anchor_comment schema を docs の Required flow と一致させる #1010 の責務)
Out of Scope
- anchor comment を自動生成するツールの追加
- scope 拡張の自動実装許可
superseded_by_decisionの anchor comment format#1008/#1010が担う planner known_context 伝播・正規化 API の変更
Activity
squne121 commentedon Jun 21, 2026
判定
#920 は方向性は正しいが、現状の Issue 契約のまま実装すると危険です。
「anchor comment に marker があれば
excluded_by_anchor_reframe=true」という単純化に寄ると、#1010 / #1008 / #1013 / #1090 で分離されている安全境界を壊します。実装前に Issue 本文を更新し、“人間コメントによる scope delta approval” は実装許可ではなく、再チェック要求つきの構造化入力として扱う契約に直すべきです。#920 自体は open で、本文は「anchor reframe comment template を追加し、
anchor_comment_url経由でexcluded_by_anchor_reframe=trueになる fixture を固定する」Issue です。直接コメントはありません。主要な危険点
1. #920 は現在の repo reality に対して古い
#920 は
scope-signal-guard.md/plan_refinement_loop.py/ tests / schemas に閉じた修正として設計されていますが、後続の #1010 / PR #1043 でanchor_commentはrun_refinement_preflight.pyが GitHub issue comment API response から正規化する契約に移っています。#1043 は required metadata、enum、複数 anchor URL fail-closed、raw snapshot と planner input の境界を扱っています。このため、#920 で
plan_refinement_loop.pyが raw comment body から marker を直読みする実装に寄せるのは逆行です。現在のplan_refinement_loop.pyはknown_context.classification in ("feedback_update_required", "reframe_in_place")またはknown_context.anchor_comment_url && known_context.anchor_reframeで anchor reframe を見る実装になっており、raw comment marker parser ではありません。2.
excluded_by_anchor_reframe=trueは「実装してよい」ではない#1090 は #920 を blocker にしており、より新しい整理では
ANCHOR_SCOPE_REFRAME/Scope Delta Approval/Allowed Paths Expansion Rationaleを検出した場合でも、結果はproceed_with_notesであり、「contract-review rerun required、実装 go ではない」と定義しています。したがって #920 の Outcome / AC は、
excluded_by_anchor_reframe=trueだけで閉じるべきではありません。最低でも以下の語彙に変えるべきです。3. author_association をコメント本文から信じる設計は不可
GitHub issue comments API は comment response に
id,url,html_url,body,user,created_at,updated_at,issue_url,author_associationを返します。author_associationは API 由来の metadata として扱うべきで、コメント本文に書かれたauthor_association: OWNERのような値を信じてはいけません。([GitHub Docs]1)#920 の AC4 は「OWNER 相当の author_association が必要」とだけ書いていますが、source of truth が GitHub API response であること、
CONTRIBUTOR/NONEは fail-closed であること、off-repo / wrong issue / multiple anchor URL / stale snapshot を拒否することまで AC に入れるべきです。4. phase gate と衝突する可能性がある
現在の
scope-signal-guard.mdは phase-sensitive です。preflight / investigation / review phase ではdecide_next_loop_action.pyを呼ばず、scope_signal_guard.triggered=trueでも hard stop ではありません。hard stop eligible なのはpost_rewrite_check/decide_next_actionです。#920 の fixture は「
excluded_by_anchor_reframe=trueになる」だけでは不足です。少なくとも phase 別に以下を固定すべきです。なお #1030 のレビューでは、phase gate 実装時に
approve verdict + max_iterationsの既存動作を壊す out-of-scope regression が実際に指摘されています。#920 でも routing / phase / iteration に触るなら、同種 regression を明示的に防ぐ必要があります。外部実装調査からの改善点
JSON Schema では
propertiesに書いただけでは必須にならず、requiredが必要です。またadditionalProperties: falseを入れない限り未知 field は許可されます。([JSON Schema]2) (JSON Schema)enumには JSON のnullを値として含められます。"null"という文字列ではなく、本物のnullを許可する設計にすべきです。([JSON Schema]3)さらに Python の
jsonschemaはformatkeyword をデフォルトでは検証しません。date-timeを enforcement claim にするならFormatCheckerを使う必要があります。([jsonschema]4)したがって #920 で schema を追加するなら、最低限こうするべきです。
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "anchor_scope_reframe_v1.schema.json", "title": "ANCHOR_SCOPE_REFRAME_V1", "type": "object", "additionalProperties": false, "required": [ "schema_version", "target", "decision", "allowed_path_deltas", "rationale", "required_rerun" ], "properties": { "schema_version": { "const": "anchor_scope_reframe/v1" }, "target": { "type": "object", "additionalProperties": false, "required": ["repo", "issue_number"], "properties": { "repo": { "type": "string", "const": "squne121/loop-protocol" }, "issue_number": { "type": "integer", "minimum": 1 } } }, "decision": { "enum": ["approve_scope_delta"] }, "allowed_path_deltas": { "type": "array", "minItems": 1, "items": { "type": "object", "additionalProperties": false, "required": ["path", "reason"], "properties": { "path": { "type": "string", "minLength": 1 }, "reason": { "type": "string", "minLength": 1 } } } }, "rationale": { "type": "string", "minLength": 1 }, "required_rerun": { "type": "array", "items": { "enum": ["contract_review", "refinement_preflight", "allowed_paths_gate"] }, "minItems": 1, "uniqueItems": true } } }#920 本文への修正案
Allowed Paths を修正
現状の Allowed Paths は狭すぎます。#1010 / #1008 との境界を守るなら、
plan_refinement_loop.pyだけでなく preflight 正規化・schema・reference・fixtures を明示すべきです。ただし、
run_refinement_preflight.pyまで入れるなら #1008 との責務重複を避けるため、#920 は「schema + normalized decision artifact 生成まで」、#1008 は「planner known_context への伝播」と切るのが安全です。#1008 は明示的に #920 に依存しており、trusted anchor comment を plannerknown_contextに渡す責務を持っています。AC を差し替え
Verification Commands を強化
pytest の
--import-mode=importlibはsys.pathを変更せず、test module 名の重複を避けられる一方で、test module 同士の直接 import には制約があります。#1100 で importlib mode を採用しているため、新規テストはconftest.py/ helper 配置に注意が必要です。([pytestドキュメント]5)最終レビューコメント案
結論として、#920 は 実装前に契約更新が必要です。特に
excluded_by_anchor_reframeを primary contract にしないこと、API metadata を信頼境界にすること、phase gate と raw body 境界を壊さないことが必須です。squne121 commentedon Jun 21, 2026
squne121 commentedon Jun 21, 2026
squne121 commentedon Jun 21, 2026
feat(#920): add ANCHOR_SCOPE_REFRAME_V1 schema and trusted anchor fix…
feat(#920): implement ANCHOR_SCOPE_REFRAME_V1 production logic (itera…
squne121 commentedon Jun 21, 2026
post-merge-cleanup: 完了 (2026-06-21)
cleanup 内容:
/.claude/worktrees/issue-920-anchor-scope-reframe削除 ✓worktree-issue-920-anchor-scope-reframe削除 ✓