Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "scope rollup が同一ファイル・語彙一致だけで停止しないよう、構造化コンテキスト(scope_context / domain_flags / ordering_constraint)に基づいて collision 判定を汎用化する"
change_kind: enhancementParent Issue
none(スタンドアロン改善。関連: #547 phase_instance_id pattern 拡張, #549 root required secret_policy 追加, #537 boundary_enforced 廃止)
Parent Goal Ref
- Goal:
plan_issue_scope_rollup.pyが Issue / PR から構造化コンテキストを生成し、同一ファイル・キーワード一致だけでhuman_review_requiredにならないようにする - Desired Destination: 実装: agent_session_manifest schema の phase_instance_id を CI-native 形式(ci:<workflow>:<run_id>:<run_attempt>)に対応させる #547/実装: agent-session-manifest.schema.json の root required に secret_policy を追加する #549 相当の実例フィクスチャが
continueまたはsequence_after_current_mergeになり、genuine conflict は引き続きhuman_review_requiredになる状態
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py:_is_security_related()/_suggested_action()が security keyword を検出した時点で即時human_review_requiredを返す(L299)ISSUE_SCOPE_ROLLUP_DECISION_V2フォーマットにsecurity_match_evidenceは存在するがscope_context/domain_flags/ordering_constraintは存在しない.claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py:B4: security keyword does not trigger on "issue-author"は存在するが、scope_context / ordering_constraint の回帰テストは未存在
Remaining Parent Gaps
なし(スタンドアロン)
背景
impl-review-loop の preparation で scope rollup が #549(secret_policy フィールド名を含む)を human_review_required に誤分類した。#547 と #549 は同一 schema ファイルを対象とするが、変更対象パスと目的は独立している。
人間コメント(#issuecomment-4592375157)が指摘するように、scope collision は security 文脈に限らず普遍的に発生する。現在の実装は security キーワード一致という単一シグナルで即時停止する設計欠陥を持つ。
問題
現在の plan_issue_scope_rollup.py の scope collision 判定は:
- security キーワード一致だけで
human_review_requiredを返す(_is_security_related→ 即時 return) - 変更対象の構造的位置(JSON path、ファイル内 symbol)を考慮しない
- 順序制約(先行マージ待ちなのか、並行不可なのか)を
suggested_actionと分離しない
その結果、schema property 名・metadata フィールド・docs 内の語彙が一致するだけで作業が止まる。security に限らず、workflow、schema、test、docs でも同様のパターンが起きうる。
目的
scope rollup に汎用の構造化コンテキスト(scope_context)を導入し、continue / sequence_after_current_merge / human_review_required / uncertain の判定を語彙一致ではなく変更対象範囲・意味カテゴリ・影響境界・順序制約で行う。
scope_context の主要要素:
- 変更範囲の構造的位置: JSON Pointer(
/required、/properties/field/pattern等) - 意味カテゴリ(domain_flags): security / schema / metadata / workflow / runtime / docs — audit 用、判定の主因にしない
- 衝突種別: same_anchor_conflicting_operation / same_file_disjoint_anchor / uncertain 等
- 順序制約(ordering_constraint):
suggested_actionとは別フィールド
escalation 停止条件を変更する:
- 現行:
security_match_evidenceが存在するだけで停止 - 変更後:
scope_context.escalation_required == trueまたはscope_context.classification == uncertainのみ停止
Outcome
plan_issue_scope_rollup.py が scope_context(変更範囲・domain_flags・衝突種別)と ordering_constraint を出力し、#547/#549 相当フィクスチャが human_review_required にならない。genuine conflict フィクスチャは引き続き停止する。既存 ISSUE_SCOPE_ROLLUP_DECISION_V2 フィールドは非削除。
In Scope
.claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py.claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py.claude/skills/issue-refinement-loop/references/scope-rollup-policy.md
Allowed Paths
.claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py.claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py.claude/skills/issue-refinement-loop/references/scope-rollup-policy.md
Out of Scope
- security 専用 classifier の実装
- tree-sitter / AST anchor の実装(follow-up)
- OPA/Rego への移行
ISSUE_SCOPE_ROLLUP_DECISION_V2の既存フィールド削除・renaming- LLM / embedding による自由文判断
- human review の廃止
Acceptance Criteria
- AC1:
scope_contextがplan_issue_scope_rollup.pyの出力に含まれる - AC2:
domain_flagsが出力に含まれる(security / schema / metadata 等の分類) - AC3:
ordering_constraintがsuggested_actionとは別フィールドとして出力される - AC4: schema property 名・metadata フィールド名の一致だけでは
human_review_requiredにならない(test_scope_rollup_treats_schema_property_keyword_as_metadata_not_domain_specific_riskが pass) - AC5: genuine conflict(同一 JSON path への競合変更)は
human_review_requiredになる(test_scope_rollup_escalates_uncertain_or_boundary_affecting_changesが pass) - AC6: 既存テスト(B4:
test_issue_author_does_not_trigger_security_auth_keyword/test_token_budget_does_not_trigger_security_token_keyword)が引き続き pass する - AC7: 既存
ISSUE_SCOPE_ROLLUP_DECISION_V2フィールドが出力から消えない(additive 拡張)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- 既存
ISSUE_SCOPE_ROLLUP_DECISION_V2との後方互換を破る変更が避けられない場合 scope_context生成に外部ツール(tree-sitter バイナリ等)が必要と判明した場合(follow-up へ)- 新規 Issue 起票・スコープ分割が必要と判断した場合
- 既存テスト B4 以外のテストが大規模改変を要すると判明した場合(別 Issue へ)
- domain plugin の実装が本 Issue に必要と判明した場合(follow-up へ)
Required Skills
- Python(re / json / dataclass)
- JSON Pointer (RFC 6901) の基本構文(
/区切りのパス) - pytest フィクスチャ設計
Verification Commands
# AC1
$ rg -n "scope_context" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py# AC2
$ rg -n "domain_flags" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py# AC3
$ rg -n "ordering_constraint" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py# AC4
$ rg -n "test_scope_rollup_treats_schema_property_keyword_as_metadata_not_domain_specific_risk" .claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py# AC5
$ rg -n "test_scope_rollup_escalates_uncertain_or_boundary_affecting_changes" .claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py# AC6
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py -v# AC7
$ rg -n "suggested_action\|security_match_evidence" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.pyRuntime Verification Applicability
decision: not_applicable
reason: This issue changes deterministic scope-rollup classification logic and adds repository regression tests. It does not require separate runtime verification beyond repository tests and contract preflight.
参考リンク
- 人間コメント(問題再定義): 実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する #550 (comment)
- AI 敵対レビュー(security 分類詳細): 実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する #550 (comment)
- AI 汎用化提案(構造化手法): 実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する #550 (comment)
- 関連 PR feat(#536): split secret policy runtime and static schema #537: boundary_enforced 廃止
- 関連 実装: agent_session_manifest schema の phase_instance_id を CI-native 形式(ci:<workflow>:<run_id>:<run_attempt>)に対応させる #547 / 実装: agent-session-manifest.schema.json の root required に secret_policy を追加する #549: scope collision 実例
Activity
squne121 commentedon Jun 1, 2026
人間からのコメントです。
「secret」や「security」に特化した内容になっている認識だがscope 衝突は普遍的に起こりうる認識なので特化しないでほしい。特定文脈に特化する時は別エージェントスキルととしてほしい。普遍的な文脈認識をどのように決定論的に行うのか、手法をWEB検索、検討してほしい。
squne121 commentedon Jun 1, 2026
総評
#550 の問題意識は正しいです。ただし、現状のIssue文面は 「
secret_policyという語の誤検知を直す」方向に寄りすぎ です。実際に直すべきは、scope rollup の 候補抽出・セキュリティ分類・停止判断・順序制御 が一つのsecurity_match_evidenceに潰れている設計です。現在のplan_issue_scope_rollup.pyは本文・タイトルからsecret|credential|api_keyなどを正規表現で拾い、その時点でhuman_review_requiredに落とす構造なので、#550 が指摘する false positive は再現性のある設計欠陥です。([GitHub]1)結論として、#550 は着手してよいです。ただし #549 を単純な
false_positiveとして扱うのは危険 です。#549 は secret 値を扱う変更ではありませんが、agent-session-manifestの root required にsecret_policyを追加し、セキュリティ契約メタデータの存在を強制する変更です。これは「セキュリティ無関係」ではなく、低リスクな security metadata contract change と分類すべきです。([GitHub]2)敵対的レビュー
Blocker 1:
secret_policyを allowlist すると別の事故を作る#550 は「schema property name
secret_policyは false positive」と書いていますが、secret_policyは単なる雑多なプロパティ名ではありません。現在の schema ではvalue_exposed:false、mode:presence_only、producer_contract.secret_values_not_serialized、runtime_boundary.attested/evidence_refを持つ、明確なセキュリティ契約フィールドです。([GitHub]3)したがって、実装で
secret_policyを雑に除外すると、たとえば次の変更を見逃します。これは #536 / PR #537 で問題にされた「静的な producer 宣言を runtime attestation のように見せる greenwashing リスク」を再導入します。#537 は
boundary_enforcedを廃止し、producer_contractとruntime_boundaryを分離して、runtime attestation に evidence を要求する設計へ修正しています。([GitHub]4)修正案:
false_positiveだけでなく、少なくとも次の分類を追加してください。#549 は
false_positiveではなく、security_metadata_contract_changeかつescalation_required:falseが妥当です。Blocker 2:
suggested_actionに順序制御を混ぜない#550 は #547 と #549 の回帰テストで「continue または sequencing」と書いていますが、既存の scope rollup policy / script の action enum は
merge_into_current_pr,amend_current_issue,create_parent_rollup_issue,keep_separate_with_reason,human_review_requiredです。sequence_after_current_mergeは既存 action ではありません。([GitHub]5)#547 は
phase_instance_idの CI-native ID 対応、#549 は rootrequiredへのsecret_policy追加であり、どちらも同じ schema file を触りますが、変更対象の論理パスと目的は異なります。#547 はphase_instance_idpattern と generator/validator/workflow、#549 はsecret_policyの root required 追加に限定されています。([GitHub]6)修正案:
security_assessmentと別に、順序制御は別フィールドにしてください。{ "suggested_action": "keep_separate_with_reason", "ordering_constraint": { "required": true, "relation": "sequence_after_current_merge", "reason": "same schema file, disjoint JSON path, avoid concurrent schema edits" } }human_review_requiredは security 停止判断だけに使い、PR順序や同一ファイル競合の表現に流用しない方が安全です。Important 1: #549 は「セキュリティではない」ではなく「secret 値フローではない」
#549 の scope は root
requiredarray に"secret_policy"を足すだけで、producer/consumer script やsecret_policystructure は out of scope です。つまり、secret 値の読み取り・保存・出力・ログ・CI secret injection はありません。([GitHub]2)一方で、JSON Schema の
requiredはインスタンスに当該 property の存在を要求する validation assertion です。propertiesは property name と schema の対応を定義しますが、property 名が存在するだけで secret 値を扱うわけではありません。([JSON Schema]7)レビュー指摘:
#550 の期待値は次のように書き換えるべきです。
Important 2: GitHub Actions / CI secret 周辺は絶対に false positive 側へ倒してはいけない
#550 の positive tests に GitHub Actions secrets が含まれているのは正しいです。GitHub Actions の secrets、environment secrets、OIDC、artifact attestation、provenance は supply-chain security の実体に関わります。GitHub 公式ドキュメントでも Actions secrets と workflow security は独立したセキュリティ領域として扱われ、artifact attestations は build provenance を確立する仕組みです。([GitHub Docs]8)
SLSA provenance でも、provenance は「どの build platform がどの build definition で artifact を生成したか」の attestation であり、build service secrets へのアクセス分離も要求されます。したがって
.github/workflows/**、OIDC permission、secrets.*、artifact attestation の変更は、単語一致ではなく ファイルパスと構文で high-risk に分類してください。([SLSA]9)実装方針
現在の
_security_match_evidence()/_is_security_related()/_suggested_action()の bool 判定を、deterministic な classifier に置き換えるのが妥当です。既存 script はSECURITY_REによる title/body scan で evidence を返し、それだけでhuman_review_requiredに落とします。ここを「検出」と「停止判断」に分離してください。([GitHub]1)推奨出力はこの形です。
{ "security_assessment": { "schema_version": 1, "detected": true, "escalation_required": false, "classification": "security_metadata_contract_change", "matched_terms": ["secret"], "reason_codes": [ "SCHEMA_REQUIRED_ENTRY_ONLY", "NO_SECRET_VALUE_FLOW", "NO_AUTHZ_BOUNDARY_CHANGE", "NO_CI_SECRET_INJECTION" ], "evidence": [ { "source": "issue_body", "path": "docs/schemas/agent-session-manifest.schema.json", "json_pointer": "/required", "role": "schema_required_entry", "term": "secret_policy" } ], "reason": "Adds required presence of secret_policy metadata only; does not read, store, output, log, inject, or validate secret values." } }停止条件は次だけに限定します。
#550 の「
security_match_evidenceがあるだけで止めない」という方針は正しいですが、false_positiveへ寄せすぎず、security_metadata_contract_changeを中間分類として残すべきです。([GitHub]10)追加すべきテスト
最低限、#550 の regression に次を追加してください。
実装: agent_session_manifest schema の phase_instance_id を CI-native 形式(ci:<workflow>:<run_id>:<run_attempt>)に対応させる #547 current + 実装: agent-session-manifest.schema.json の root required に secret_policy を追加する #549 candidate
期待値:
classification: security_metadata_contract_change,escalation_required:false,human_review_required:false,ordering_constraint: sequence_after_current_merge。実装: agent_session_manifest schema の phase_instance_id を CI-native 形式(ci:<workflow>:<run_id>:<run_attempt>)に対応させる #547 はphase_instance_idの pattern/generator/workflow、実装: agent-session-manifest.schema.json の root required に secret_policy を追加する #549 は root required のみなので、同一 schema file でも同一 JSON path ではありません。([GitHub]6)secret_policy.value_exposedをfalseから変更期待値:
real_security_riskまたはuncertain,human_review_required:true。runtime_boundary.attested/evidence_ref要件を緩和期待値:
real_security_riskまたはuncertain。PR feat(#536): split secret policy runtime and static schema #537 の greenwashing 修正を壊さないためです。([GitHub]11).github/workflows/**でsecrets.*,GITHUB_TOKEN,id-token: write, artifact attestation を変更期待値:
real_security_riskまたはuncertain,human_review_required:true。README / schema description に
secret_policyという文字列だけがある期待値:
false_positive,escalation_required:false。title に
secretがあるが allowed paths / body / diff に security 実体がない期待値:
false_positiveかuncertain。title-only は少なくとも即停止にしない。既存の
auth/tokenfalse positive 回帰既存テストには
issue-author,authored PR,token budgetを security 扱いしないケースがあります。実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する #550 の修正でこれを壊さないこと。([GitHub]12)#550 本文への修正提案
Issue #550 には次を追記するのがよいです。
また、Acceptance Criteria は次のように強めるべきです。
最終判定
#550 は 必要 です。ただし、現状のまま実装すると「
secret_policy文字列を無害化するだけ」の雑な修正になり、#536/#537 で潰した runtime attestation / static declaration の混同リスクを再発させます。採るべき方針はこれです。
#549 の期待分類は
false_positiveではなく、security_metadata_contract_change+escalation_required:false。これを #550 に明記した上で、scope rollup の action と security stop を分離して実装するのが安全です。squne121 commentedon Jun 1, 2026
#550 (comment)
結論: 人間コメントは妥当です。#550 は現状、「security keyword」「secret_policy」「security_assessment」に問題設定が寄りすぎています。#547/#549 の実例は、
secret語の誤検知ではなく、同一ファイル・同一 schema artifact 上で、変更対象 JSON path と変更意図が独立しているのに scope collision と誤分類した問題として再定義すべきです。#550 本文も security keyword の文脈分類を主目的にしているため、このままだと core scope rollup に security 専用ロジックが混入します。([GitHub]1)#547 は
docs/schemas/agent-session-manifest.schema.jsonのphase_instance_idpattern 拡張、workflow 生成 ID、generator validation、関連 test 更新が scope です。([GitHub]2) #549 は同じ schema ファイルの rootrequiredに"secret_policy"を追加するだけの scope で、同一ファイルではあるが #547 とは JSON path と目的が別です。([GitHub]3) したがって、core の判定軸はsecurityではなく、file overlap → structural anchor overlap → semantic operation overlap → verification/consumer impact の順に落とすべきです。採るべき決定論的手法
core は LLM・embedding・自然文雰囲気判定を使わず、構造化された
scope_fingerprintを生成して比較します。構造アンカー化
JSON/YAML/schema では JSON Pointer を使い、変更対象を
/required、/properties/phase_instance_id/patternのような決定論的 path に正規化します。JSON Pointer は JSON 文書内の特定値を識別する標準構文です。([RFCエディタ]4) JSON Patch はadd/remove/replace/move/copy/testの操作列として JSON 変更を表現できるため、scope の「どこをどう変えるか」をop + path + value-shapeに落とせます。([IETF Datatracker][5])コード・設定ファイルの AST/CST アンカー化
TS/JS/Python/Shell などは tree-sitter で構文木を作り、関数、export、object property、workflow step などを node anchor として抽出します。tree-sitter はソースから concrete syntax tree を構築し、編集後も効率的に更新できる parser です。([tree-sitter.github.io]6) tree-sitter query は syntax tree node に対する pattern matching なので、単語一致より安定して「どの構造を触るか」を取れます。([tree-sitter.github.io]7)
汎用 rule engine 化
判定は
scope_fingerprint[]を入力にした closed enum の policy decision にします。OPA/Rego は構造化データに対する policy evaluation を目的にした宣言型言語なので、この種のallow / sequence / conflict / human_review判定と相性がよいです。([Open Policy Agent]8)domain-specific skill は plugin に隔離
secret/security/auth/license/assets/runtimeなどの専門判定は core ではなくdomain_analyzersに分離します。たとえば security plugin では Semgrep の AST-aware pattern matching や taint mode、CodeQL の source-to-sink data flow / taint tracking を使う余地がありますが、それは「scope collision 判定の core」ではなく「特定 domain の追加 risk 判定」です。Semgrep はコード pattern を構文的に照合でき、CodeQL は local/global data flow と taint tracking を扱えます。([Semgrep]9)#550 の修正方針
#550 は潰さず、タイトルと本文を汎用化するのがよいです。security 専用要件は Non-goal または follow-up/plugin issue に落としてください。
推奨タイトル
貼り付け用コメント案
この場合、#547 と #549 は同一ファイルだが、JSON Pointer anchor と semantic_axis が異なるため
same_file_disjoint_anchorまたはsame_artifact_disjoint_anchorと判定する。結論はsequence_after_current_mergeまたはcontinue_with_noteであり、単語secretだけでhuman_review_requiredにはしない。判定ルール
scope rollup は以下の順で判定する。
Allowed Paths/ changed files の集合を比較する同一ファイルがある場合、構造アンカーを抽出する
op + pathanchor relation を判定する
operation relation を判定する
semantic relation を判定する
domain-specific risk が必要な場合のみ plugin skill に委譲する
escalation 条件
matched_termsやsame_fileだけでは escalation しない。human_review_requiredにする条件は以下に限定する。risk: highを返したuncertainを返したcore と domain-specific skill の分離
core scope rollup は
secret/securityの意味論を直接持たない。core はあくまで以下を出力する。
security 固有の判定が必要な場合は、別 Issue / 別 agent skill として
security-scope-risk-analyzerを作る。そこでは secret value handling、credential flow、authz/authn、permission、CI secret injection、logging sink などを扱ってよい。ただし core scope collision 判定には混ぜない。受け入れ条件
scope_fingerprint_schema_version: v1が定義されるanchors[]を出力するhuman_review_requiredにならないhuman_review_requiredにならないsame_file_disjoint_anchorになり、停止しないuncertainとして conservative に停止できるdomain_flagsに残すが、core decision の主因にしないNon-goals
secret_policyの allowlist 化[5]: https://datatracker.ietf.org/doc/html/rfc6902 "
[-]scope rollup の security escalation を文脈判定化し、secret_policy フィールド名一致による false positive を抑止する[/-][+]scope rollup の scope collision 判定を構造化コンテキスト化し、同一ファイル・キーワード一致の false positive を抑止する[/+][-]scope rollup の scope collision 判定を構造化コンテキスト化し、同一ファイル・キーワード一致の false positive を抑止する[/-][+]scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する[/+][-]scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する[/-][+]実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する[/+]squne121 commentedon Jun 1, 2026
Contract Snapshot (2026-06-01T12:47:00Z)
plan_issue_scope_rollup.pyがscope_context(変更範囲・domain_flags・衝突種別)とordering_constraintを出力し、実装: agent_session_manifest schema の phase_instance_id を CI-native 形式(ci:<workflow>:<run_id>:<run_attempt>)に対応させる #547/実装: agent-session-manifest.schema.json の root required に secret_policy を追加する #549 相当フィクスチャがhuman_review_requiredにならない。genuine conflict フィクスチャは引き続き停止する。既存ISSUE_SCOPE_ROLLUP_DECISION_V2フィールドは非削除。.claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py/.claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py/.claude/skills/issue-refinement-loop/references/scope-rollup-policy.md.claude/worktrees/issue-550-scope-collisionworktree-issue-550-scope-collisionsqune121 commentedon Jun 1, 2026
IMPLEMENTATION_RESULT_V1
AC 検証結果
変更サマリ
scope rollup の衝突判定を語彙一致ベースから構造化コンテキスト(scope_context / domain_flags / ordering_constraint)ベースへ汎用化。本文中の JSON Pointer・バックティック付きプロパティ名から sub-file anchor を軽量抽出し、同一ファイルでも anchor が disjoint なら escalate しない(#547/#549 パターン)。同一 anchor への競合変更・anchor 抽出不能(uncertain)は引き続き human_review_required。
検証コマンド
uv run pytest .../test_plan_issue_scope_rollup.py -q→ 35 passeduv run pytest .../gemini-cli-headless-delegation/tests/test_model_routing.py -q→ 21 passed(憲法必須回帰)fix(#550): address review — prefix overlap classification, fixture pr…
feat(#550): generalize scope collision detection with scope_context (#…