Skip to content

feat: scope-rollup-runner が ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 marker を返さない場合に fail-closed する #841

Closed

Description

@squne121

背景

#824 の impl-review-loop で scope-rollup-runner SubAgent が ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 を返さず、orchestrator が deferred フォールバックしていました。marker 欠落は scope rollup 結果なしではなく、終了契約不成立として扱う必要があります。

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#824"
goal_ref: "scope-rollup marker 欠落を control-plane 失敗として検知し停止する"
change_kind: workflow

Parent Issue

#824

Parent Goal Ref

  • Goal: scope-rollup marker 検証の control-plane 強化
  • Desired Destination: impl-review-loop が marker 欠落時に human_review_required へ停止し、raw fallback を禁止する

Current Validated Scope

  • impl-review-loop/steps/preparation.md の判定で ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 検証を厳格化する
  • marker_missing / marker_malformed / marker_ambiguous を ISSUE_SCOPE_ROLLUP_DECISION_V2.runner_result の status / reject_reason に反映する
  • marker 不在・不正時は human_review_required かつ termination_reason: human_escalation に固定し、raw JSON fallback を禁止する
  • 参照先 .md を .claude/agents/scope-rollup-runner.md に統一する

Remaining Parent Gaps

  • なし

Outcome

impl-review-loop は scope-rollup-runner の最終応答に valid な ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 が欠ける場合、human_escalation へ遷移し、LOOP_STATE の termination_cause と scope_rollup_decision に marker 欠落情報を保存する。

In Scope

  • marker_missing / marker_malformed / marker_ambiguous を runner_result として保存
  • raw result.raw_plan_location の pre-verification 直接読み取り禁止
  • runner_unavailable と marker_* 系を別状態として扱う
  • ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 の validator/parser を追加
  • impl-review-loop 側の human_review_required 経路を追加

Out of Scope

  • ゲームシステム本体の機能追加・修正
  • 大規模な UI やアセット変更
  • 既存テスト大規模追加(新規追加は最小限の fixture に限定)

Acceptance Criteria

  • AC1: scope-rollup-runner の最終応答に valid fenced ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 が存在しない場合、impl-review-loop orchestrator は human_escalation に遷移する。
  • AC2: 遷移時の LOOP_STATE.termination_reason は human_escalation、termination_cause は scope_rollup_marker_missing になる。
  • AC3: ISSUE_SCOPE_ROLLUP_DECISION_V2.runner_result に marker_missing / marker_malformed / marker_ambiguous を保存する。
  • AC4: marker 欠落・不正時に raw result.raw_plan_location の直接読み取りを禁止する。
  • AC5: runner_unavailable は valid marker が返された場合のみ成立する状態として扱う。
  • AC6: scope-rollup-runner で marker 欠落時は human_review_required として停止する。
  • AC7: .claude/agents/scope-rollup-runner.toml 参照の混入を .md 参照へ統一する。

Verification Commands

# AC1
$ uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py \
  --assistant-output-file /tmp/scope_rollup_subagent_output.txt \
  --repo squne121/loop-protocol \
  --issue-number 841 \
  --invocation-id fake-invocation-id \
  --expected-script-sha deadbeef \
  --requested-at 2026-06-13T10:14:29.005846+00:00

# AC2
$ uv run python3 .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py \
  --issue-number 841 \
  --repo squne121/loop-protocol \
  --anchor-comment-url https://github.com/squne121/loop-protocol/issues/841#issuecomment-4698224807

# AC3
$ uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py \
  --assistant-output-file /tmp/scope_rollup_subagent_output.txt \
  --repo squne121/loop-protocol \
  --issue-number 841 \
  --invocation-id fake-invocation-id \
  --expected-script-sha deadbeef \
  --requested-at 2026-06-13T10:14:29.005846+00:00

# AC4
$ uv run python3 .claude/skills/impl-review-loop/scripts/verify_scope_rollup_result.py --help

# AC5
$ uv run python3 .claude/skills/impl-review-loop/scripts/verify_scope_rollup_result.py --help

# AC6
$ uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py \
  --assistant-output-file /tmp/scope_rollup_subagent_output.txt \
  --repo squne121/loop-protocol \
  --issue-number 841 \
  --invocation-id fake-invocation-id \
  --expected-script-sha deadbeef \
  --requested-at 2026-06-13T10:14:29.005846+00:00

# AC7
$ uv run python3 .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・enum / スキーマ・型)変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Runtime Verification Applicability

decision: not_applicable

derived_test_plan:

  • parser/fallback 系の fixture 検証

Allowed Paths

  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
  • .claude/skills/impl-review-loop/scripts/verify_scope_rollup_result.py
  • .claude/skills/impl-review-loop/tests/
  • .claude/agents/scope-rollup-runner.md

Required Skills

  • Python

参考

  • .claude/skills/impl-review-loop/steps/preparation.md
  • .claude/agents/scope-rollup-runner.md

Activity

  1. added
    enhancement
    phase/research
    on Jun 13, 2026
  2. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES

    #841 の方向性は正しいです。scope-rollup-runner の marker 欠落を deferred にして Step 3 へ進める現在設計は、scope collision 検出を「失敗しても進める」扱いにしており、オーケストレーターの control-plane として危険です。#841 は、marker 欠落を fail-closed / human escalation に変える Issue として実装すべきです。#841 自体にコメントはなく、議論の根拠は #824、PR #837、scope-rollup-runner / preparation.md / scope rollup policy 側にあります。

    主要な問題

    1. 現行設計は「marker 検証失敗」と「非ブロッキング skip」を混同している

    preparation.md は marker 検証に失敗した場合、silent fallback は禁じていますが、その後の選択肢として deferred で scope rollup をスキップして Step 3 へ進む経路を許しています。これは #841 の問題そのものです。marker が無い、壊れている、別 invocation のものである、sha が合わない、という事象は「scope rollup の結果が空」ではなく「control-plane の証跡が壊れた」です。

    修正方針は、runner_unavailable と marker_missing を分けることです。runner_unavailable は runner が 有効な marker として 返した状態です。一方、marker 欠落は runner の終了契約そのものが破れている状態なので、deferred ではなく human_review_required に固定すべきです。

    2. human_judgment という AC 表現が既存の termination schema とズレている

    #841 の AC1 は「human_judgment として停止」としていますが、impl-review-loop の termination reason は human_escalation を使っています。既存の LOOP_STATE でも termination reason は null | approved | max_iterations | human_escalation | intake_gate_failed です。

    したがって #841 は次のように書き換えるべきです。

    LOOP_STATE:
      termination_reason: human_escalation
      termination_cause: scope_rollup_marker_missing
      scope_rollup_decision:
        decision: human_review_required
        runner_result:
          status: marker_missing
          reject_reason: marker_missing
    

    「human_judgment」は人間が読む説明語としてはよいですが、machine-readable state では既存 enum に合わせるべきです。

    3. 既存の ISSUE_SCOPE_ROLLUP_DECISION_V2 に marker_missing が存在しない

    現行 schema の runner_result.status は ok | runner_unavailable | rejected、reject_reason は repo / issue / invocation / stale / script sha / result sha mismatch などに限定されています。marker 欠落、marker 重複、marker malformed、raw plan 不正パス、result file 不在が表現できません。

    追加すべき enum は最低限これです。

    runner_result:
      status: ok | runner_unavailable | rejected | marker_missing | marker_malformed
      reject_reason:
        null
        | marker_missing
        | marker_ambiguous
        | marker_malformed
        | repo_mismatch
        | issue_mismatch
        | invocation_id_mismatch
        | stale
        | script_sha_mismatch
        | result_sha_mismatch
        | result_missing
        | raw_plan_location_invalid
        | verify_status_not_verified
    

    decision は既存の human_review_required を使えば足ります。scope rollup policy は、統合実施・未実施にかかわらず ISSUE_SCOPE_ROLLUP_DECISION_V2 を常時記録する要求を持っています。

    4. 「runner 自身に必ず marker を返させる」は単独では不十分

    scope-rollup-runner.md は、確かに ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 を stdout に返す専用 SubAgent と定義し、OUTPUT_BUDGET_V1 でも routing-critical field を削らないとしています。

    しかし Claude Code の subagent は独立 context で動き、最終的にメインへ返すのは要約です。これは「LLM が marker を必ず出す」ことの保証ではありません。公式 docs でも subagent は独自 context / system prompt / tool access を持ち、結果を返す構造です。(Claude API Docs)

    したがって、プロンプト強化だけではなく、orchestrator 側の deterministic parser または SubagentStop hook で検査する必要があります。Claude Code hooks には SubagentStop があり、subagent 終了時の last_assistant_message と agent_type を受け取れます。(Claude API Docs)

    5. raw JSON fallback は明示禁止すべき

    #841 の背景では、marker 欠落後に raw JSON ファイルを直接読む fallback が発生しています。これは危険です。ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 の役割は、raw_plan_location と result_sha256 と invocation_id を結び、現在の run の結果であることを証明することです。現行 preparation.md も marker の repo / issue / invocation / timestamp / script sha / result sha を検証対象にしています。

    修正後は、次を rule として明文化してください。

    raw_plan_location の読取は、
    ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 marker が valid で、
    repo/current_issue/invocation_id/script_blob_sha256/result_sha256 検証が全て pass した場合のみ許可する。
    marker 欠落時に raw JSON を直接読む fallback は常に禁止する。
    

    6. .toml 参照が間違っている

    #841 の参考には .claude/agents/scope-rollup-runner.toml とありますが、実際に repo で見つかる定義は .claude/agents/scope-rollup-runner.md です。Issue 本文の参照は修正してください。

    推奨実装

    A. parser script を追加する

    preparation.md に自然言語で「marker を確認する」と書くだけでは弱いです。次のような script を追加してください。

    .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
    

    入力:

    uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py \
      --assistant-output-file /tmp/scope_rollup_subagent_output_<invocation_id>.txt \
      --repo "$REPO_FULL_NAME" \
      --issue-number "$ISSUE_NUMBER" \
      --invocation-id "$INVOCATION_ID" \
      --expected-script-sha "$SCRIPT_SHA" \
      --requested-at "$REQUESTED_AT"
    

    出力:

    SCOPE_ROLLUP_MARKER_PARSE_RESULT_V1:
      status: ok | marker_missing | marker_malformed | marker_ambiguous | rejected
      routing_action: continue | stop_human
      termination_cause: null | scope_rollup_marker_missing | scope_rollup_marker_malformed
      reject_reason: null | marker_missing | marker_ambiguous | repo_mismatch | issue_mismatch | invocation_id_mismatch | stale | script_sha_mismatch | result_sha_mismatch | result_missing | raw_plan_location_invalid
      raw_plan_location_allowed: true | false
    

    既存の verify_scope_rollup_result.py は JSON result の self-validation、schema、payload hash、script hash を検証する良い土台です。特に duplicate key、non-object、schema mismatch、sha mismatch を分けて fail する設計は #841 側でも踏襲すべきです。

    B. marker は YAML prose ではなく fenced block としてだけ認める

    CONTRACT_REVIEW_RESULT_V1 側では、単に marker 文字列を含むだけでは採用せず、valid fenced YAML block と必須 field を要求しています。同じ思想を scope rollup にも適用してください。ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 という文字列が散文中に出てきただけで pass にしてはいけません。

    可能なら YAML より JSON marker へ寄せる方が安全です。Python 標準ライブラリで strict JSON parsing と duplicate-key detection を実装できるためです。YAML を維持するなら、PyYAML / ruamel.yaml などの依存を明示し、正規表現だけで nested YAML を読まないでください。

    C. SubagentStop hook で二重化する

    Claude Code hooks は lifecycle event の JSON input を受け取り、exit code / stdout で結果を返せます。SubagentStop では subagent の last_assistant_message を検査できます。(Claude API Docs) (Claude API Docs)

    設計案:

    SubagentStop:
      matcher: scope-rollup-runner
      command: >
        uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
        --stdin-json
    

    ただし hook だけに依存せず、preparation.md の routing logic でも同じ parser を呼ぶべきです。hook は早期検知、orchestrator parser は canonical 判定、という分担がよいです。

    D. 「structured output / schema 強制」は現在の Claude Code SubAgent には直接の解ではない

    OpenAI API の Structured Outputs は、JSON mode と異なり schema adherence を保証する仕組みですが、これは API 側の strict: true schema enforcement の話です。Claude Code の project subagent 最終応答にそのまま適用できるとは限りません。(OpenAI Platform)

    したがって #841 の実装方針はこう分けるべきです。

    経路 | 採用可否 -- | -- Claude Code SubAgent prompt に「必ず marker」と書く | 補助策に留める deterministic parser で final response を検査 | 必須 SubagentStop hook で last_assistant_message を検査 | 推奨 OpenAI Structured Outputs による schema 強制 | 将来 API runner 化する場合のみ有効

    #841 の AC 改訂案

    ## Acceptance Criteria
    
    • AC1: scope-rollup-runner の最終応答に valid fenced ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 block が存在しない場合、impl-review-loop orchestrator は Step 3 へ進まず、LOOP_STATE.termination_reason: human_escalation と termination_cause: scope_rollup_marker_missing を記録して停止する。
    • AC2: valid marker が存在し、repo / current_issue / invocation_id / generated_at / script_blob_sha256 / result_sha256 の検証が全て pass した場合、既存 routing に影響を与えない。
    • AC3: fail-closed 時、LOOP_STATE.scope_rollup_decision.runner_result.status と reject_reason に marker_missing | marker_malformed | marker_ambiguous | result_sha_mismatch | raw_plan_location_invalid のいずれかを構造化保存する。
    • AC4: valid marker 検証前に result.raw_plan_location を読んではならない。marker 欠落時の raw JSON fallback は禁止する。
    • AC5: runner_unavailable は valid marker として返された場合のみ runner failure として扱う。marker 欠落とは別 enum にする。
    • AC6: parser unit test が prose-only / marker文字列のみ / malformed YAML / duplicate marker / wrong invocation_id / sha mismatch / invalid raw_plan_location / valid ok marker を fixture で検証する。
    • [ ] AC7: .claude/agents/scope-rollup-runner.toml 参照を実在する .claude/agents/scope-rollup-runner.md に修正する。

    最終コメント案

    #841 は実装する価値があります。ただし、現行の Issue 契約のままだと「runner prompt を強化するだけ」の PR が通る余地があります。それでは再発します。

    実装の核は、scope-rollup-runner の出力を信頼することではなく、impl-review-loop orchestrator が marker 欠落を構造化された control-plane failure として検出し、Step 3 前に停止すること です。特に deferred は削るか、少なくとも valid runner_unavailable marker の場合だけに限定してください。marker 欠落、malformed、ambiguous、sha mismatch はすべて human_review_required です。

    ## 判定: REQUEST_CHANGES

    #841 の方向性は正しいです。scope-rollup-runner の marker 欠落を deferred にして Step 3 へ進める現在設計は、scope collision 検出を「失敗しても進める」扱いにしており、オーケストレーターの control-plane として危険です。#841 は、marker 欠落を fail-closed / human escalation に変える Issue として実装すべきです。#841 自体にコメントはなく、議論の根拠は #824、PR #837、scope-rollup-runner / preparation.md / scope rollup policy 側にあります。

    主要な問題

    1. 現行設計は「marker 検証失敗」と「非ブロッキング skip」を混同している

    preparation.md は marker 検証に失敗した場合、silent fallback は禁じていますが、その後の選択肢として deferred で scope rollup をスキップして Step 3 へ進む経路を許しています。これは #841 の問題そのものです。marker が無い、壊れている、別 invocation のものである、sha が合わない、という事象は「scope rollup の結果が空」ではなく「control-plane の証跡が壊れた」です。

    修正方針は、runner_unavailable と marker_missing を分けることです。runner_unavailable は runner が 有効な marker として 返した状態です。一方、marker 欠落は runner の終了契約そのものが破れている状態なので、deferred ではなく human_review_required に固定すべきです。

    2. human_judgment という AC 表現が既存の termination schema とズレている

    #841 の AC1 は「human_judgment として停止」としていますが、impl-review-loop の termination reason は human_escalation を使っています。既存の LOOP_STATE でも termination reason は null | approved | max_iterations | human_escalation | intake_gate_failed です。

    したがって #841 は次のように書き換えるべきです。

    LOOP_STATE:
      termination_reason: human_escalation
      termination_cause: scope_rollup_marker_missing
      scope_rollup_decision:
        decision: human_review_required
        runner_result:
          status: marker_missing
          reject_reason: marker_missing
    

    「human_judgment」は人間が読む説明語としてはよいですが、machine-readable state では既存 enum に合わせるべきです。

    3. 既存の ISSUE_SCOPE_ROLLUP_DECISION_V2 に marker_missing が存在しない

    現行 schema の runner_result.status は ok | runner_unavailable | rejected、reject_reason は repo / issue / invocation / stale / script sha / result sha mismatch などに限定されています。marker 欠落、marker 重複、marker malformed、raw plan 不正パス、result file 不在が表現できません。

    追加すべき enum は最低限これです。

    runner_result:
      status: ok | runner_unavailable | rejected | marker_missing | marker_malformed
      reject_reason:
        null
        | marker_missing
        | marker_ambiguous
        | marker_malformed
        | repo_mismatch
        | issue_mismatch
        | invocation_id_mismatch
        | stale
        | script_sha_mismatch
        | result_sha_mismatch
        | result_missing
        | raw_plan_location_invalid
        | verify_status_not_verified
    

    decision は既存の human_review_required を使えば足ります。scope rollup policy は、統合実施・未実施にかかわらず ISSUE_SCOPE_ROLLUP_DECISION_V2 を常時記録する要求を持っています。

    4. 「runner 自身に必ず marker を返させる」は単独では不十分

    scope-rollup-runner.md は、確かに ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 を stdout に返す専用 SubAgent と定義し、OUTPUT_BUDGET_V1 でも routing-critical field を削らないとしています。

    しかし Claude Code の subagent は独立 context で動き、最終的にメインへ返すのは要約です。これは「LLM が marker を必ず出す」ことの保証ではありません。公式 docs でも subagent は独自 context / system prompt / tool access を持ち、結果を返す構造です。([Claude API Docs]1)

    したがって、プロンプト強化だけではなく、orchestrator 側の deterministic parser または SubagentStop hook で検査する必要があります。Claude Code hooks には SubagentStop があり、subagent 終了時の last_assistant_message と agent_type を受け取れます。([Claude API Docs]2)

    5. raw JSON fallback は明示禁止すべき

    #841 の背景では、marker 欠落後に raw JSON ファイルを直接読む fallback が発生しています。これは危険です。ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 の役割は、raw_plan_location と result_sha256 と invocation_id を結び、現在の run の結果であることを証明することです。現行 preparation.md も marker の repo / issue / invocation / timestamp / script sha / result sha を検証対象にしています。

    修正後は、次を rule として明文化してください。

    raw_plan_location の読取は、
    ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 marker が valid で、
    repo/current_issue/invocation_id/script_blob_sha256/result_sha256 検証が全て pass した場合のみ許可する。
    marker 欠落時に raw JSON を直接読む fallback は常に禁止する。
    

    6. .toml 参照が間違っている

    #841 の参考には .claude/agents/scope-rollup-runner.toml とありますが、実際に repo で見つかる定義は .claude/agents/scope-rollup-runner.md です。Issue 本文の参照は修正してください。

    推奨実装

    A. parser script を追加する

    preparation.md に自然言語で「marker を確認する」と書くだけでは弱いです。次のような script を追加してください。

    .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
    

    入力:

    uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py \
      --assistant-output-file /tmp/scope_rollup_subagent_output_<invocation_id>.txt \
      --repo "$REPO_FULL_NAME" \
      --issue-number "$ISSUE_NUMBER" \
      --invocation-id "$INVOCATION_ID" \
      --expected-script-sha "$SCRIPT_SHA" \
      --requested-at "$REQUESTED_AT"
    

    出力:

    SCOPE_ROLLUP_MARKER_PARSE_RESULT_V1:
      status: ok | marker_missing | marker_malformed | marker_ambiguous | rejected
      routing_action: continue | stop_human
      termination_cause: null | scope_rollup_marker_missing | scope_rollup_marker_malformed
      reject_reason: null | marker_missing | marker_ambiguous | repo_mismatch | issue_mismatch | invocation_id_mismatch | stale | script_sha_mismatch | result_sha_mismatch | result_missing | raw_plan_location_invalid
      raw_plan_location_allowed: true | false
    

    既存の verify_scope_rollup_result.py は JSON result の self-validation、schema、payload hash、script hash を検証する良い土台です。特に duplicate key、non-object、schema mismatch、sha mismatch を分けて fail する設計は #841 側でも踏襲すべきです。

    B. marker は YAML prose ではなく fenced block としてだけ認める

    CONTRACT_REVIEW_RESULT_V1 側では、単に marker 文字列を含むだけでは採用せず、valid fenced YAML block と必須 field を要求しています。同じ思想を scope rollup にも適用してください。ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 という文字列が散文中に出てきただけで pass にしてはいけません。

    可能なら YAML より JSON marker へ寄せる方が安全です。Python 標準ライブラリで strict JSON parsing と duplicate-key detection を実装できるためです。YAML を維持するなら、PyYAML / ruamel.yaml などの依存を明示し、正規表現だけで nested YAML を読まないでください。

    C. SubagentStop hook で二重化する

    Claude Code hooks は lifecycle event の JSON input を受け取り、exit code / stdout で結果を返せます。SubagentStop では subagent の last_assistant_message を検査できます。([Claude API Docs]2) ([Claude API Docs]2)

    設計案:

    SubagentStop:
      matcher: scope-rollup-runner
      command: >
        uv run python3 .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
        --stdin-json
    

    ただし hook だけに依存せず、preparation.md の routing logic でも同じ parser を呼ぶべきです。hook は早期検知、orchestrator parser は canonical 判定、という分担がよいです。

    D. 「structured output / schema 強制」は現在の Claude Code SubAgent には直接の解ではない

    OpenAI API の Structured Outputs は、JSON mode と異なり schema adherence を保証する仕組みですが、これは API 側の strict: true schema enforcement の話です。Claude Code の project subagent 最終応答にそのまま適用できるとは限りません。([OpenAI Platform]3)

    したがって #841 の実装方針はこう分けるべきです。

    経路 採用可否
    Claude Code SubAgent prompt に「必ず marker」と書く 補助策に留める
    deterministic parser で final response を検査 必須
    SubagentStop hook で last_assistant_message を検査 推奨
    OpenAI Structured Outputs による schema 強制 将来 API runner 化する場合のみ有効

    #841 の AC 改訂案

    ## Acceptance Criteria
    
    - [ ] AC1: `scope-rollup-runner` の最終応答に valid fenced `ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1` block が存在しない場合、impl-review-loop orchestrator は Step 3 へ進まず、`LOOP_STATE.termination_reason: human_escalation` と `termination_cause: scope_rollup_marker_missing` を記録して停止する。
    - [ ] AC2: valid marker が存在し、repo / current_issue / invocation_id / generated_at / script_blob_sha256 / result_sha256 の検証が全て pass した場合、既存 routing に影響を与えない。
    - [ ] AC3: fail-closed 時、`LOOP_STATE.scope_rollup_decision.runner_result.status` と `reject_reason` に `marker_missing | marker_malformed | marker_ambiguous | result_sha_mismatch | raw_plan_location_invalid` のいずれかを構造化保存する。
    - [ ] AC4: valid marker 検証前に `result.raw_plan_location` を読んではならない。marker 欠落時の raw JSON fallback は禁止する。
    - [ ] AC5: `runner_unavailable` は valid marker として返された場合のみ runner failure として扱う。marker 欠落とは別 enum にする。
    - [ ] AC6: parser unit test が prose-only / marker文字列のみ / malformed YAML / duplicate marker / wrong invocation_id / sha mismatch / invalid raw_plan_location / valid ok marker を fixture で検証する。
    - [ ] AC7: `.claude/agents/scope-rollup-runner.toml` 参照を実在する `.claude/agents/scope-rollup-runner.md` に修正する。
    

    最終コメント案

    #841 は実装する価値があります。ただし、現行の Issue 契約のままだと「runner prompt を強化するだけ」の PR が通る余地があります。それでは再発します。

    実装の核は、scope-rollup-runner の出力を信頼することではなく、impl-review-loop orchestrator が marker 欠落を構造化された control-plane failure として検出し、Step 3 前に停止すること です。特に deferred は削るか、少なくとも valid runner_unavailable marker の場合だけに限定してください。marker 欠落、malformed、ambiguous、sha mismatch はすべて human_review_required です。

  3. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    実装の進捗を共有します。#841 の対象範囲に限定して、既存差分の不足精査・最小修正・検証まで完了しました。

    実装概要

    • scope-rollup-runner の ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1 検証を parser 化し、fenced YAML 以外は受け付けないようにしました。
    • marker 欠落 / malformed / ambiguous / replay mismatch などを marker_missing / marker_malformed / marker_ambiguous / rejected として fail-closed で扱い、raw result.raw_plan_location の直接読込は禁止へ統一。
    • runner_unavailable / failed は valid marker として分離し、fail-closed と混同しない。
    • preparation.md Step 2.5 の判断フローに parser 呼び出しと raw fallback 禁止・記録ルールを反映。
    • wrapper で verify_scope_rollup_result.py を委譲して result の self-validation を流用。

    変更ファイル

    • .claude/skills/impl-review-loop/steps/preparation.md
    • .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
    • .claude/skills/impl-review-loop/scripts/verify_scope_rollup_result.py
    • .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py

    AC / VC 対応

    • AC: marker 未存在時に fail-closed へ遷移するフローを導入済み
    • AC: marker 欠落時は human_escalation 前提の停止経路を想定
    • AC: runner_unavailable は valid marker として独立扱い
    • AC: malformed / ambiguous / duplicate / hash mismatch / invalid raw path は parser で拒否
    • AC: .toml 参照の混入は対象差分から除去済み(scope-rollup-runner.md 統一)
    • VC: parser + fixture テストを追加し、最低限の検証を自動化

    実行テスト

    • uv run python3 -m pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py -q => 9 passed
    • uv run python3 -m pytest .claude/skills/impl-review-loop/tests -q => 193 passed, 4 xfailed

    人間が見るべき点(merge前)

    • SCOPE_ROLLUP_MARKER_PARSE_RESULT_V1.status の marker_ambiguous と runner_result.status enum の実運用吸収方針(仕様上の同値化は必要なら追加調整)
    • scope_rollup_plan_ref の実データ連携は実行時の context 側で正常に採用されるか
    • merge は未実施(このIssue作業は PR 準備まで)
  5. added a commit that references this issue on Jun 13, 2026
  6. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    実装再開報告(#841)

    レビューコメント #4698316409 の主指摘(1〜3点)を先に対応しました。

    実装概要

    • parse: marker_missing / marker_malformed / marker_ambiguous / rejected / failed / runner_unavailable を分離し、failed/runner_unavailable を marker_missing と混同しない。
    • failed は status: failed(routing_action: stop_human)。
    • runner_unavailable は status: runner_unavailable(routing_action: deferred)。
    • requested_at を CLI 引数と照合し、不一致は requested_at_mismatch で拒否。
    • raw_plan_location は /tmp 配下・絶対パス・.. 禁止・symlink 禁止・invocation_id 同一性を確認する検証へ更新。
    • YAML duplicate-key を検知する strict loader を導入し、single block 重複 key を marker_malformed 扱い。
    • preparation.md の Step2.5 を runner_unavailable と failed の取扱、marker_ambiguous・requested_at_mismatch を含む enum 更新。

    変更ファイル

    • .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
    • .claude/skills/impl-review-loop/steps/preparation.md
    • .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py

    実行テスト

    • uv run python3 -m pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py -q => 12 passed
    • uv run python3 -m pytest .claude/skills/impl-review-loop/tests -q => 196 passed, 4 xfailed

    反映 PR/コミット

    merge 前の注視点

    • PR のレビューコメントで挙がっていた CI/PREVIEW 由来の「日本語比率」などは、実装範囲外の CI 方針要件として未処理です。
    • SubAgent 最終応答の取得運用は、ドキュメント化まで実施。Hook 実装は follow-up が必要。
  7. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    impl-review-loop 実行結果(2026-06-13T00:00:00Z 想定)

    • 対象 PR: fix(#841): fail closed on missing scope rollup marker #869
    • 実装サブタスク: .claude/skills/impl-review-loop/steps/preparation.md の scope-rollup marker fail-closed 方針に沿った更新反映
    • 現在状態: CLEAN / MERGEABLE
    • PR body 日本語比率ゲート(閾値 0.1)を再実行して成功

    検証

    • CI Checks Summary: Passed 10, Failed 0
    • 主要 CI: actionlint/build/lint/e2e/python-test/test/typecheck/validate-generated-artifact/deploy-pr
    • PR本体検証: uv run python3 -m pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py -q(12 passed)
    • PR本体検証: uv run python3 -m pytest .claude/skills/impl-review-loop/tests -q(196 passed, 4 xfailed)

    補足

    • 最新の実レビューコメントの pending blocker(日本語比率)を PR body 修正で解消済み。
    • 現在まで impl-review-loop と pr-review-judge 経路での再マージ阻害要因は未検出。
  8. added a commit that references this issue on Jun 13, 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

    enhancementphase/research

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions