Skip to content

実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する #550

Closed

Description

@squne121

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: enhancement

Parent Issue

none(スタンドアロン改善。関連: #547 phase_instance_id pattern 拡張, #549 root required secret_policy 追加, #537 boundary_enforced 廃止)

Parent Goal Ref

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 判定は:

  1. security キーワード一致だけで human_review_required を返す(_is_security_related → 即時 return)
  2. 変更対象の構造的位置(JSON path、ファイル内 symbol)を考慮しない
  3. 順序制約(先行マージ待ちなのか、並行不可なのか)を 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.py

Runtime 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.

参考リンク

Activity

  1. added
    bug
    on Jun 1, 2026
  2. squne121 commented on Jun 1, 2026

    @squne121
    OwnerAuthor

    人間からのコメントです。
    「secret」や「security」に特化した内容になっている認識だがscope 衝突は普遍的に起こりうる認識なので特化しないでほしい。特定文脈に特化する時は別エージェントスキルととしてほしい。普遍的な文脈認識をどのように決定論的に行うのか、手法をWEB検索、検討してほしい。

  3. squne121 commented on Jun 1, 2026

    @squne121
    OwnerAuthor

    総評

    #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 を雑に除外すると、たとえば次の変更を見逃します。

    secret_policy.value_exposed const false を削除
    producer_contract.secret_values_not_serialized を弱める
    runtime_boundary.attested/evidence_ref の要求を緩める
    

    これは #536 / PR #537 で問題にされた「静的な producer 宣言を runtime attestation のように見せる greenwashing リスク」を再導入します。#537 は boundary_enforced を廃止し、producer_contract と runtime_boundary を分離して、runtime attestation に evidence を要求する設計へ修正しています。([GitHub]4)

    修正案:
    false_positive だけでなく、少なくとも次の分類を追加してください。

    real_security_risk
    security_metadata_contract_change
    false_positive
    uncertain
    

    #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 は root required への secret_policy 追加であり、どちらも同じ schema file を触りますが、変更対象の論理パスと目的は異なります。#547 は phase_instance_id pattern と 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 required array に "secret_policy" を足すだけで、producer/consumer script や secret_policy structure は 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 の期待値は次のように書き換えるべきです。

    - #549 は false_positive
    + #549 は security_metadata_contract_change
    + escalation_required は false
    + 理由: secret 値フロー・認可境界・CI secret 注入の変更ではなく、
    + root required による security policy metadata の存在強制に限定されるため

    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."
      }
    }

    停止条件は次だけに限定します。

    security_assessment.escalation_required == true
    または
    security_assessment.classification == "uncertain"
    

    #550 の「security_match_evidence があるだけで止めない」という方針は正しいですが、false_positive へ寄せすぎず、security_metadata_contract_change を中間分類として残すべきです。([GitHub]10)

    追加すべきテスト

    最低限、#550 の regression に次を追加してください。

    1. 実装: 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)

    2. secret_policy.value_exposed を false から変更
      期待値: real_security_risk または uncertain, human_review_required:true。

    3. runtime_boundary.attested / evidence_ref 要件を緩和
      期待値: real_security_risk または uncertain。PR feat(#536): split secret policy runtime and static schema #537 の greenwashing 修正を壊さないためです。([GitHub]11)

    4. .github/workflows/** で secrets.*, GITHUB_TOKEN, id-token: write, artifact attestation を変更
      期待値: real_security_risk または uncertain, human_review_required:true。

    5. README / schema description に secret_policy という文字列だけがある
      期待値: false_positive, escalation_required:false。

    6. title に secret があるが allowed paths / body / diff に security 実体がない
      期待値: false_positive か uncertain。title-only は少なくとも即停止にしない。

    7. 既存の auth / token false positive 回帰
      既存テストには issue-author, authored PR, token budget を security 扱いしないケースがあります。実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する #550 の修正でこれを壊さないこと。([GitHub]12)

    #550 本文への修正提案

    Issue #550 には次を追記するのがよいです。

    ### Classification model
    
    `secret_policy` を global allowlist してはならない。
    `secret_policy` は security metadata contract であり、変更箇所により分類を分ける。
    
    - `false_positive`
      - title/body/description/code comment に security word があるだけ
      - schema property name の参照のみ
      - README/schema description の説明のみ
    
    - `security_metadata_contract_change`
      - `secret_policy` の presence enforcement
      - root `required` への追加
      - secret 値フローを伴わない metadata contract の追加・整合化
      - 原則 `escalation_required:false`
    
    - `real_security_risk`
      - secret 値の読み取り、保存、出力、ログ
      - credentials/API key/token の検証・注入・伝播
      - authn/authz/permission/access control
      - crypto/signature/verification
      - GitHub Actions secrets/OIDC/artifact attestation/provenance boundary
      - `secret_policy` の runtime boundary / value exposure semantics の緩和
    
    - `uncertain`
      - diff/JSON path/allowed path の解決不能
      - metadata-only か value-flow か判定不能
      - workflow/script/security boundary に触れているが構文判定不能

    また、Acceptance Criteria は次のように強めるべきです。

    - `security_match_evidence` の存在だけでは `human_review_required` にしない。
    - `security_assessment.escalation_required == true` または `classification == uncertain` の場合のみ停止する。
    - `secret_policy` は global allowlist しない。
    - #547 vs #549 は `security_metadata_contract_change`, `escalation_required:false` と判定される。
    - #549 は `false_positive` ではなく、低リスクな security metadata contract change として audit trail に残る。
    - `sequence_after_current_merge` は `suggested_action` ではなく `ordering_constraint` として出力する。
    - 既存 `ISSUE_SCOPE_ROLLUP_DECISION_V2` consumer を壊さない。必要なら additive field か V3 schema を導入する。

    最終判定

    #550 は 必要 です。ただし、現状のまま実装すると「secret_policy 文字列を無害化するだけ」の雑な修正になり、#536/#537 で潰した runtime attestation / static declaration の混同リスクを再発させます。

    採るべき方針はこれです。

    NG: secret_policy を allowlist する
    OK: secret_policy の変更箇所・操作種別・値フロー有無・boundary semantics 有無で分類する
    

    #549 の期待分類は false_positive ではなく、security_metadata_contract_change + escalation_required:false。これを #550 に明記した上で、scope rollup の action と security stop を分離して実装するのが安全です。

  4. squne121 commented on Jun 1, 2026

    @squne121
    OwnerAuthor

    #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_id pattern 拡張、workflow 生成 ID、generator validation、関連 test 更新が scope です。([GitHub]2) #549 は同じ schema ファイルの root required に "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 を生成して比較します。

    1. 構造アンカー化
      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])

    2. コード・設定ファイルの 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)

    3. 汎用 rule engine 化
      判定は scope_fingerprint[] を入力にした closed enum の policy decision にします。OPA/Rego は構造化データに対する policy evaluation を目的にした宣言型言語なので、この種の allow / sequence / conflict / human_review 判定と相性がよいです。([Open Policy Agent]8)

    4. 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 に落としてください。

    推奨タイトル

    scope rollup の scope collision 判定を構造化コンテキスト化し、同一ファイル・キーワード一致の false positive を抑止する
    

    貼り付け用コメント案

    人間コメントを受けて、本 Issue の問題設定を修正する。
    
    現状の Issue は `secret` / `security` / `secret_policy` に特化しているが、これは core scope rollup の責務として狭すぎる。scope collision は security 文脈に限らず、schema、workflow、test、docs、asset、runtime behavior、producer/consumer contract などで普遍的に発生する。
    
    したがって本 Issue の目的は、security keyword の文脈分類ではなく、scope rollup が Issue / PR / diff から決定論的な `scope_fingerprint` を生成し、同一ファイル・同一単語・同一 allowed path だけで停止しないようにすることへ変更する。
    
    ## 修正後の目的
    
    scope rollup に、汎用の構造化コンテキスト判定を追加する。
    
    分類対象は security 固有ではなく、以下のような普遍的な scope relation とする。
    
    - `no_overlap`
    - `same_file_disjoint_anchor`
    - `same_artifact_disjoint_anchor`
    - `ancestor_descendant_anchor_overlap`
    - `same_anchor_same_operation`
    - `same_anchor_conflicting_operation`
    - `producer_consumer_contract_overlap`
    - `verification_surface_overlap`
    - `domain_specific_risk`
    - `uncertain`
    
    ## 決定論的な入力正規化
    
    各 Issue / PR / diff から、以下のような `scope_fingerprint` を生成する。
    
    ```yaml
    scope_fingerprint_schema_version: v1
    issue_or_pr: "#547"
    anchors:
      - file: docs/schemas/agent-session-manifest.schema.json
        anchor_kind: json_pointer
        pointer: /properties/phase_instance_id/pattern
        operation: replace
        semantic_axis: schema.field_constraint
        field: phase_instance_id
      - file: .github/workflows/session-manifest.yml
        anchor_kind: workflow_step_or_env
        symbol: phase_instance_id_generation
        operation: replace
        semantic_axis: ci.generated_identifier
    verification_anchors:
      - command_family: rg
      - command_family: pnpm_test
    domain_flags: []
    scope_fingerprint_schema_version: v1
    issue_or_pr: "#549"
    anchors:
      - file: docs/schemas/agent-session-manifest.schema.json
        anchor_kind: json_pointer
        pointer: /required
        operation: add_array_member
        value_symbol: secret_policy
        semantic_axis: schema.required_membership
        field: secret_policy
    verification_anchors:
      - command_family: python_json_schema_probe
    domain_flags:
      - secret_policy_field_name

    この場合、#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 は以下の順で判定する。

    1. Allowed Paths / changed files の集合を比較する

    2. 同一ファイルがある場合、構造アンカーを抽出する

      • JSON / schema: JSON Pointer
      • JSON/YAML patch: JSON Patch 風の op + path
      • TS/JS/Python/Shell: tree-sitter node anchor
      • Markdown: heading / fenced block / machine-readable contract section
      • GitHub Actions: workflow / job / step / env / permissions anchor
    3. anchor relation を判定する

      • exact same anchor
      • ancestor / descendant
      • sibling / disjoint
      • unknown
    4. operation relation を判定する

      • both add
      • replace vs replace
      • add vs remove
      • constraint tighten / relax
      • rename / migration
      • docs-only
    5. semantic relation を判定する

      • same field
      • same producer / consumer contract
      • same generated artifact
      • same verification command target
      • independent
    6. domain-specific risk が必要な場合のみ plugin skill に委譲する

      • security / secret
      • auth / permission
      • license / asset
      • external service / deployment
      • data persistence / migration

    escalation 条件

    matched_terms や same_file だけでは escalation しない。

    human_review_required にする条件は以下に限定する。

    • same anchor に対する conflicting operation
    • ancestor / descendant anchor で片方が contract shape を変える
    • producer / consumer contract の互換性が不明
    • verification surface が競合し、どちらの AC を満たすべきか不明
    • domain plugin が risk: high を返した
    • anchor extraction が失敗し、かつ同一ファイル・同一 artifact 上の変更である
    • classifier が uncertain を返した

    core と domain-specific skill の分離

    core scope rollup は secret / security の意味論を直接持たない。

    core はあくまで以下を出力する。

    scope_relation:
      classification: same_file_disjoint_anchor
      escalation_required: false
      suggested_action: sequence_after_current_merge
      evidence:
        - current_anchor: docs/schemas/agent-session-manifest.schema.json#/properties/phase_instance_id/pattern
        - related_anchor: docs/schemas/agent-session-manifest.schema.json#/required
        - relation: disjoint_json_pointer
        - reason: same schema file, but different field/operation; no producer-consumer contract overlap detected
    domain_flags:
      - term: secret
        location: related_issue.value_symbol
        action: retained_for_audit_only

    security 固有の判定が必要な場合は、別 Issue / 別 agent skill として security-scope-risk-analyzer を作る。そこでは secret value handling、credential flow、authz/authn、permission、CI secret injection、logging sink などを扱ってよい。ただし core scope collision 判定には混ぜない。

    受け入れ条件

    Non-goals

    • security 判定の完全自動化
    • secret_policy の allowlist 化
    • LLM / embedding による非決定論的な文脈判定
    • すべての scope collision を自動解決すること
    • domain-specific agent skill の実装
    
    ## 実装優先度
    
    最小実装は JSON/schema だけでよいです。今回の #547/#549 は JSON Schema なので、まず `docs/schemas/*.json` に限定して `file + JSON Pointer + op` を取れば回帰テストを作れます。その後、tree-sitter による TS/JS、GitHub Actions YAML、Markdown machine-readable contract へ拡張するのが安全です。
    ::contentReference[oaicite:9]{index=9}
    

    [5]: https://datatracker.ietf.org/doc/html/rfc6902 "

                RFC 6902 - JavaScript Object Notation (JSON) Patch
            
        "
    
  5. changed the title [-]scope rollup の security escalation を文脈判定化し、secret_policy フィールド名一致による false positive を抑止する[/-] [+]scope rollup の scope collision 判定を構造化コンテキスト化し、同一ファイル・キーワード一致の false positive を抑止する[/+] on Jun 1, 2026
  6. changed the title [-]scope rollup の scope collision 判定を構造化コンテキスト化し、同一ファイル・キーワード一致の false positive を抑止する[/-] [+]scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する[/+] on Jun 1, 2026
  7. changed the title [-]scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する[/-] [+]実装: scope collision 判定を構造化コンテキストで汎用化し、単語一致による誤エスカレーションを抑止する[/+] on Jun 1, 2026
  8. squne121 commented on Jun 1, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-06-01T12:47:00Z)

    • Outcome: 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 フィールドは非削除。
    • Acceptance Criteria: AC1(scope_context 追加)/ AC2(domain_flags 追加)/ AC3(ordering_constraint 追加)/ AC4(schema property 名一致で停止しない)/ AC5(genuine conflict は停止)/ AC6(既存テスト pass)/ AC7(既存フィールド非削除)
    • Verification Commands: rg scope_context / rg domain_flags / rg ordering_constraint / rg test_scope_rollup_treats_... / rg test_scope_rollup_escalates_... / uv run pytest(runtime_only)/ rg suggested_action
    • 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
    • Worktree: .claude/worktrees/issue-550-scope-collision
    • Branch: worktree-issue-550-scope-collision
    • VC preflight: baseline fail = 6, 想定外 pass = 0, 実行不可 = 0, runtime_only skipped = 1
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-01T12:47:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/550
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 6
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 1
          classifications:
            - ac: AC1
              command: "rg -n \"scope_context\" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC2
              command: "rg -n \"domain_flags\" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC3
              command: "rg -n \"ordering_constraint\" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC4
              command: "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"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC5
              command: "rg -n \"test_scope_rollup_escalates_uncertain_or_boundary_affecting_changes\" .claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
            - ac: AC6
              command: "uv run pytest .claude/skills/issue-refinement-loop/tests/test_plan_issue_scope_rollup.py -v"
              exit_code: null
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "VC marked runtime_only; verification deferred to post-implementation runtime"
              runtime_verification_required: true
            - ac: AC7
              command: "rg -n \"suggested_action\\|security_match_evidence\" .claude/skills/issue-refinement-loop/scripts/plan_issue_scope_rollup.py"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: false
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: false
          conditions:
            docs_product_requires_spec_evidence:
              status: pass
              evidence: []
            tasks_md_not_direct_source:
              status: pass
              evidence: []
            specify_not_canonical:
              status: pass
              evidence: []
            diff_first_rationale_present:
              status: pass
              evidence: []
            generated_task_trace_present:
              status: pass
              evidence: []
            task_dependencies_materialized:
              status: pass
              evidence: []
          blocked_reasons: []
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  9. squne121 commented on Jun 1, 2026

    @squne121
    OwnerAuthor

    IMPLEMENTATION_RESULT_V1

    status: complete
    pr_url: https://github.com/squne121/loop-protocol/pull/554
    worktree: .claude/worktrees/issue-550-scope-collision
    branch: worktree-issue-550-scope-collision

    AC 検証結果

    • AC1 (scope_context 追加): pass
    • AC2 (domain_flags 追加): pass
    • AC3 (ordering_constraint 別フィールド): pass
    • AC4 (property/metadata 名一致で escalate しない): pass
    • AC5 (genuine conflict は escalate): pass
    • AC6 (既存テスト pass): pass — 35 passed
    • AC7 (既存フィールド非削除): pass

    変更サマリ

    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 passed
    • uv run pytest .../gemini-cli-headless-delegation/tests/test_model_routing.py -q → 21 passed(憲法必須回帰)
  10. added 2 commits that reference this issue on Jun 1, 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

    bugphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions