Skip to content

実装(#646): issue-refinement-loop 終了レポートの guard 互換 renderer ライブラリ新設 #656

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#646"
goal_ref: "issue-refinement-loop の終了レポートを guard 互換 renderer ライブラリとして新設し、TERMINATION_REPORT_RENDER_RESULT_V1 JSON を返す deterministic template + dry-run + 上限付き再生成を実装する"
change_kind: code

Parent Issue

#646

Parent Goal Ref

  • Goal: issue-refinement-loop の終了レポート(human_escalation / needs-fix / max_iterations)を guard 互換 template から生成し、投稿前 dry-run guard に失敗したら本文回避ではなく再生成へ戻す
  • Desired Destination: 終了レポートは deterministic template から生成され、投稿前に同一 classifier で dry-run され、失敗時は上限付きで再生成し、上限超過時は公開投稿せず reason_code を local artifact / stderr に残す

Current Validated Scope

  • .claude/skills/issue-refinement-loop/scripts/render_termination_report.py の新設(3 種終了レポートの deterministic 生成 + dry-run + 上限付き再生成)
  • .claude/skills/issue-refinement-loop/references/termination-policy.md への dry-run guard / 再生成上限 / 非投稿 reason_code の規約追記
  • 対応する unit test の追加
  • 本 Issue は renderer ライブラリの新設のみを対象とする。callsite integration(loop 本体の Step 5 への組み込み)は follow-up Issue に委譲する
  • TERMINATION_REPORT_RENDER_RESULT_V1 JSON のみを stdout に出力し、投稿可能 markdown 本文を stdout / stderr に出さない
  • prose_boundary_policy の公開 API(classify_block 等)のみを import し、guard 判定 regex / block classifier を再実装しない
  • attempt 1: normal deterministic template、attempt 2: fallback minimal template の最大 2 試行のみ(LLM / ask / network / gh command なし)
  • GFM fence injection への防御(dynamic fence)

Remaining Parent Gaps

  • shadow / enforce mode は child-4 に委譲する
  • 公開 mutation route matrix の整備は child-2 に委譲する

Outcome

.claude/skills/issue-refinement-loop/scripts/render_termination_report.py が、human_escalation / approved の終了レポートを guard 互換の deterministic template から生成し、TERMINATION_REPORT_RENDER_RESULT_V1 JSON を stdout に返す。termination_reason(approved / human_escalation / superseded_by_decision)と termination_cause(needs_fix_at_iteration_limit / max_iterations_exceeded 等)を分離した構造を持つ。生成後に child-0 #653 の prose_boundary_policy 公開 API で dry-run guard を実行し、失敗した場合は 1 回だけ fallback minimal template に切り替え、なお失敗なら publishable=false、body=null、固定 reason_code を返す。stdout は常に machine JSON のみ、stderr は diagnostics のみ。GFM fence injection を防ぐ dynamic fence を使用する。無制限 regeneration / LLM / ask / gh command を呼ばないことが unit test で固定される。termination-policy.md に本フローが規約として記載される。callsite integration は follow-up Issue に委譲する。

Background

#646 の reviewer Blocker 6 は、終了レポートの dry-run guard 失敗時の上限が無く、無制限再生成や人間確認への逃げが起きうると指摘している。実際に #646 の refinement では、checker が要求する英語見出しや必須 marker <!-- LOOP_HANDOFF_RESULT_V1 --> を guard が prose として block する現象が観測された。本 Issue は終了レポート生成を deterministic template + 上限付き dry-run へ寄せて解消する。child-0(#653)の prose classifier SSOT を dry-run に使う。

In Scope

  • 3 種終了レポートの deterministic template 生成関数
  • 投稿前 dry-run guard(child-0 SSOT の classifier 使用)
  • 上限付き(1 回)template-safe regeneration
  • 上限超過時の公開非投稿と reason_code 出力
  • 無制限 regeneration / ask escape hatch を持たないことのテスト
  • TERMINATION_REPORT_RENDER_RESULT_V1 schema の定義(publishable / body / reason_code / attempts / classifier フィールド)
  • termination_reason(approved / human_escalation / superseded_by_decision)と termination_cause(needs_fix_at_iteration_limit / max_iterations_exceeded / human_judgment_required 等)の分離
  • stdout: machine JSON のみ / stderr: diagnostics のみ の出力契約
  • prose_boundary_policy 公開 API のみ import(分類 regex を再実装しない)
  • attempt 1: normal template、attempt 2: fallback minimal template の最大 2 試行
  • GFM fence(``` / ~~~)/ HTML marker(<!-- LOOP_HANDOFF_RESULT_V1 -->)/ 英語 stack trace を含む adversarial input に対する dynamic fence
  • simulated replay evidence(GitHub mutation が発火しない証跡)

Out of Scope

Acceptance Criteria

  • AC1: render_termination_report.py が存在し、TERMINATION_REPORT_RENDER_RESULT_V1 JSON を stdout に返す
  • AC2: publishable=true かつ body != null の場合のみ公開投稿用 body が存在する。publishable=false のとき body は null
  • AC3: renderer は prose_boundary_policy の公開関数(classify_block 等)のみを import し、guard 判定 regex / block classifier を再実装しない
  • AC4: template は deterministic であり、attempt 1(normal template)と attempt 2(fallback minimal template)の最大 2 試行のみを実行する。LLM / ask / network / gh command を呼ばない
  • AC5: 2 試行後も guard fail の場合、publishable=false、body=null、固定 reason_code を返す
  • AC6: stderr / local artifact にも投稿可能 markdown 本文を出さない
  • AC7: needs-fix / max_iterations は termination_reason ではなく termination_cause として扱い、termination_reason は approved / human_escalation / superseded_by_decision のみとする
  • AC8: GFM fence(``` / ~~~)/ HTML marker(<!-- LOOP_HANDOFF_RESULT_V1 -->)/ 英語 stack trace を含む adversarial input でも template 構造が壊れない(dynamic fence 使用)
  • AC9: simulated replay evidence を PR に添付し、GitHub mutation が発火していないことを示す(RVA: simulated replay required; no real GitHub mutation)
  • AC10: 既存の issue-refinement-loop テストが回帰なく PASS する

Verification Commands

# AC1
# preflight-scope: pr_review_only
$ rg -n "human_escalation|needs-fix|max_iterations" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

# AC1
# preflight-scope: pr_review_only
$ rg -n "TERMINATION_REPORT_RENDER_RESULT_V1" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

# AC2
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k "termination_report"

# AC3
# preflight-scope: pr_review_only
$ rg -n "from.*prose_boundary_policy import|import prose_boundary_policy" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

# AC3
# preflight-scope: pr_review_only
$ rg -cn "re\.compile|re\.search|re\.match" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

# AC4
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k "no_llm or no_ask or no_network or attempts"

# AC5
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k "guard_fail_publishable_false or limit_exceeded"

# AC6
$ rg -n "dry.run|再生成|reason_code|TERMINATION_REPORT_RENDER_RESULT_V1" .claude/skills/issue-refinement-loop/references/termination-policy.md

# AC7
# preflight-scope: pr_review_only
$ rg -n "termination_reason.*needs.fix|termination_reason.*max_iterations" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

# AC7
# preflight-scope: pr_review_only
$ rg -n "termination_cause" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

# AC8
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k "fence or adversarial or injection"

# AC9
# preflight-scope: pr_review_only
$ rg -n "TERMINATION_REPORT_RENDER_RESULT_V1|publishable|body.*null|reason_code" .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py

# AC10
$ uv run pytest .claude/skills/issue-refinement-loop/tests/ -q

Allowed Paths

  • .claude/skills/issue-refinement-loop/scripts/render_termination_report.py
  • .claude/skills/issue-refinement-loop/references/termination-policy.md
  • .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py
  • .claude/skills/create-issue/scripts/prose_boundary_policy.py(読み取り参照のみ。変更不可)

Stop Conditions

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

Required Skills

  • Python(pytest / unittest)
  • issue-refinement-loop の終了 marker / 終了レポート仕様の理解
  • guard classifier の dry-run 連携

Scope Delta(任意)

N/A

Delivery Rule

Source(重複排除キー)

follow-up:squne121/loop-protocol:issue/646:child-3-termination-report-dry-run

関連

Runtime Verification Applicability

rva_schema_version: v1
applicability: deferred
decision: deferred
reason: "render_termination_report.py の終了レポート生成・dry-run・上限付き再生成・非投稿経路は unit test で決定論的に検証できる。ただし GitHub mutation が発火しないことは simulated replay evidence で確認する(実 GitHub 投稿は不要)"
deferred_destination:
  destination_type: pr_evidence
  destination_ref: "PR 本文の Evidence セクション"
deferred_verification_condition: "simulated termination input で renderer stdout JSON / publishable=false 証跡 / classifier failure 証跡 / GitHub mutation 非発火証跡を PR に添付する"

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    area/ai-ops
    on Jun 4, 2026
  2. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    判定:REQUEST_CHANGES

    Issue #656 は、親 Issue #646 の Blocker 6「終了レポートを deterministic template → same guard dry-run → bounded regeneration → 失敗時 no public post + reason_code」に対応する方向性としては妥当です。#656 自体も、child-0 #653 の SSOT classifier を使い、1回だけ再生成し、それでも失敗したら公開本文を返さない、という契約を明記しています。([GitHub]1)

    ただし、現状の Issue 契約のまま実装すると、**「テストだけ通る未接続レンダラ」「非終端状態の終了レポート化」「guard 失敗時の本文漏洩」「親 #646 の runtime evidence 未充足」**が残ります。実装着手前に Issue を修正すべきです。


    致命的ブロッカー

    B1. render_termination_report.py が実運用に接続されない可能性が高い

    #656 の Allowed Paths は、新規 render_termination_report.py、termination-policy.md、テストだけです。([GitHub]1)
    一方、現在の issue-refinement-loop/scripts には planner 系スクリプトしかなく、終了レポート投稿経路にこの新規 renderer を呼ばせる既存変更点が Issue 上に定義されていません。([GitHub]2)

    これは実装事故になります。PR が「renderer と unit test を追加しました」で終わると、実際の loop は従来どおり危険な本文を生成・投稿し得ます。

    修正案

    #656 の scope に次を追加してください。

    - issue-refinement-loop の終了処理が public GitHub mutation body を組み立てる直前に、
      render_termination_report.py の result.publishable == true の body だけを使用する。
    - publishable != true または body == null の場合、GitHub comment / issue / PR body mutation を行わない。
    - 既存 callsite 変更が必要な場合は Allowed Paths に該当ファイルを追加する。
    

    既存 callsite を今回変更しないなら、Issue 名を「renderer library の追加」に縮小し、別 Issue で wiring を必須化すべきです。


    B2. needs-fix / max_iterations を「終了レポート種別」として扱う設計が危険

    #656 は report type として human_escalation / needs-fix / max_iterations を並べています。([GitHub]1)
    しかし現在の termination-policy.md では、needs-fix + max_iterations は human_escalation にルーティングされる条件であり、終端 reason は approved / human_escalation / superseded_by_decision の体系に寄っています。([GitHub]3)

    このままだと、本来は loop 継続判断である needs-fix を終端コメントとして投稿する実装が入り得ます。

    修正案

    termination_reason と termination_cause を分けるべきです。

    termination_reason: approved | human_escalation | superseded_by_decision
    termination_cause:
      - needs_fix_at_iteration_limit
      - max_iterations_exceeded
      - human_judgment_required
      - superseded_by_parent_decision
      - approved_with_materialized_followup

    #656 の対象が失敗系のみなら、approved を out-of-scope と明記してください。逆に「終了レポート全体」を扱うなら、既存 LOOP_HANDOFF_RESULT_V1 / FOLLOW_UP_MATERIALIZATION_RESULT_V1 との互換性を AC に入れる必要があります。([GitHub]3)


    B3. guard 失敗時の出力契約が弱く、本文漏洩を防げない

    #656 は「上限超過時に no public body returned、reason_code を local artifact/stderr」と書いています。([GitHub]1)
    しかし、CLI が stdout に markdown 本文を一度でも出す設計だと、呼び出し側が誤ってその本文を GitHub に投稿できます。

    Claude Code hooks では、コマンド hook は stdin で JSON を受け取り、exit code / stdout / stderr / JSON で制御する設計です。特に exit code 2 はブロック、JSON output は exit 0 のとき処理されるため、exit code と JSON を混在させる設計は明確に決める必要があります。([Claude Code]4)

    修正案

    renderer の stdout は常に machine JSON のみにしてください。

    {
      "schema": "TERMINATION_REPORT_RENDER_RESULT_V1",
      "publishable": false,
      "body": null,
      "reason_code": "termination_report_guard_failed_after_regeneration_limit",
      "attempts": 2,
      "classifier": {
        "name": "prose_boundary_policy",
        "passed": false
      }
    }

    公開可能なときだけ:

    {
      "schema": "TERMINATION_REPORT_RENDER_RESULT_V1",
      "publishable": true,
      "body": "<markdown body>",
      "reason_code": null
    }

    stderr は diagnostics のみに限定し、投稿可能な markdown 本文を絶対に出さない、という AC を追加すべきです。


    B4. 「child-0 SSOT classifier を使う」が API レベルで未定義

    #653 は prose_boundary_policy.py を新設し、validate_japanese_content.py の分類をそこへ委譲する scope でした。([GitHub]5)
    PR #658 でも SSOT 化自体は merge 済みですが、レビュー上では split_markdown_blocks の完全 SSOT 化が別 Issue #659 に切り出され、GFM fence 周辺の限界が明示されています。([GitHub]6)

    #656 側で「同一 classifier」とだけ書くと、実装者が以下のどれでも通せてしまいます。

    • shell guard を subprocess で呼ぶ
    • validate_japanese_content.py の private 関数を叩く
    • regex を再実装する
    • classifier 結果を mock して実質未使用にする

    修正案

    Issue に exact API 契約を追加してください。

    render_termination_report.py は prose_boundary_policy の公開関数だけを import する。
    guard 判定用 regex / block classifier を issue-refinement-loop 側で再実装してはならない。
    unit test は monkeypatch で classifier 呼び出し回数と入力本文を検証する。
    

    さらに、split_markdown_blocks の未解決分は #659 依存にするか、#656 側で「fence 埋め込みを避ける / dynamic fence を使う」方針を明記すべきです。


    B5. 「template-safe regeneration」が未定義で、LLM 再生成の抜け道になる

    #656 は「1回だけ template-safe regeneration」と書いていますが、何を変える再生成なのか定義されていません。([GitHub]1)
    deterministic template が guard に落ちるなら、同じ入力から同じ本文を出す限り再生成しても再失敗します。ここに LLM を挟むと、親 #646 の「no ask / deterministic repair signal」方針と衝突します。([GitHub]7)

    修正案

    再生成は有限個の deterministic template variant に限定してください。

    attempt 1: normal deterministic template
    attempt 2: fallback minimal template
    - no LLM
    - no user ask
    - no network
    - no gh command
    - no unbounded retry
    

    テストでは attempts <= 2、input() / ask 相当 / subprocess 投稿呼び出しがないことを検証すべきです。


    B6. 親 #646 の runtime verification 条件と #656 が矛盾している

    親 #646 は child-0〜child-4 について、CI unit tests に加えて shadow または Claude Code replay evidence を PR evidence として要求しています。([GitHub]7)
    #656 は child-3 ですが、Runtime Verification Applicability を not_applicable としています。([GitHub]1)

    これは親 Issue の closure criteria を満たさない可能性があります。

    修正案

    実 GitHub 投稿は不要です。ただし、少なくとも次を PR evidence に要求してください。

    - simulated termination input
    - renderer stdout JSON
    - publishable=false 時に body=null である証跡
    - classifier failure after 2 attempts の証跡
    - GitHub mutation command が呼ばれていない証跡
    

    not_applicable ではなく、simulated replay required; no real GitHub mutation が妥当です。


    B7. Markdown / GFM fence injection への備えが不足

    GFM の fenced code block は、開始 fence と同じ文字で、かつ同じ長さ以上の closing fence で閉じます。閉じられない fence は文書末尾まで code block になります。([GitHub Docs]8)
    終了レポートは reviewer comment や blocker summary を取り込む可能性があるため、入力に ````` や <!-- LOOP_HANDOFF_RESULT_V1 --> が含まれると、template の YAML / markdown 構造を壊せます。

    #658 のレビューでも、4-backtick fence を 3-backtick で誤って閉じる問題が指摘され、follow-up に回されています。([GitHub]6)

    修正案

    renderer には dynamic fence を実装し、外部テキストをそのまま template 構造に混ぜないでください。

    def markdown_fence_for(text: str) -> str:
        longest = max((len(m.group(0)) for m in re.finditer(r"`{3,}", text)), default=2)
        return "`" * (longest + 1)

    追加すべき adversarial test:

    - blocker summary に ``` / ```` / <!-- LOOP_HANDOFF_RESULT_V1 --> を含む
    - 英語のみの stack trace を含む
    - YAML front matter 風の `---` を含む
    - guard failure 時に publishable body が null
    

    追加の改善点

    VC の grep が曖昧

    #656 の VC にある needs.fix は regex の . が任意1文字になるため、意図が曖昧です。([GitHub]1)
    needs[-_]fix または needs-fix|needs_fix にしてください。

    pytest のテスト名依存が強い

    pytest は test_*.py / *_test.py の discovery と assert に基づいて動きます。([pytestドキュメント]9)
    -k "limit_exceeded_no_publish and reason_code" のような VC は、実装者がテスト名を合わせるだけで中身が弱くなります。VC には具体的な期待値も書くべきです。

    pytest ... -k "termination_report"
    期待:
    - publishable=false
    - body is None
    - reason_code == termination_report_guard_failed_after_regeneration_limit
    - attempts == 2
    - classifier called twice
    

    修正後の AC 案

    #656 の AC は次のように置き換えるのが安全です。

    AC1. render_termination_report.py は TERMINATION_REPORT_RENDER_RESULT_V1 JSON を stdout に返す。
    AC2. public GitHub mutation に渡してよい本文は publishable=true かつ body != null の場合だけである。
    AC3. renderer は child-0 の prose_boundary_policy 公開 API を直接 import し、分類 regex を再実装しない。
    AC4. template は deterministic であり、通常 template と fallback minimal template の最大2試行だけを許可する。
    AC5. 2試行後も guard fail の場合、publishable=false、body=null、固定 reason_code を返す。
    AC6. stderr / local artifact にも投稿可能 markdown 本文を出さない。
    AC7. needs-fix / max_iterations は termination_reason ではなく termination_cause として扱う。
    AC8. GFM fence / HTML marker / 英語 stack trace を含む adversarial input でも構造が壊れない。
    AC9. simulated replay evidence を PR に添付し、GitHub mutation が発火していないことを示す。
    

    採用判断

    この Issue は、親 #646 の方針を実装する重要 Issue としては必要です。
    ただし現状のままだと、guard 互換 renderer という部品は作れても、実際の公開投稿経路の安全性を保証できません。

    最小修正は次の4点です。

    1. callsite 接続または別 Issue 化を明記
    2. TERMINATION_REPORT_RENDER_RESULT_V1 の stdout JSON 契約を固定
    3. termination_reason と termination_cause を分離
    4. 親 導入: guard-japanese-prose と issue contract authoring boundary の統合修正 #646 に合わせて simulated replay evidence を必須化

    この修正なしなら、#656 は実装 Issue として merge 不可です。

  3. changed the title [-]実装(#646): issue-refinement-loop 終了レポートの guard 互換 dry-run と上限付き再生成[/-] [+]実装(#646): issue-refinement-loop 終了レポートの guard 互換 renderer ライブラリ新設[/+] on Jun 6, 2026
  4. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    Issue Refinement Loop 終了レポート(人間エスカレーション)

    schema: LOOP_HANDOFF_RESULT_V1
    issue_number: 656
    termination_reason: human_escalation
    termination_cause: needs_fix_at_iteration_limit
    status: human_judgment_required
    iterations_completed: 3
    max_iterations: 3

    Issue #656 の refinement loop が最大反復回数(3 回)に達しました。VC preflight の機械チェックが最終反復でブロックしています。


    全反復のブロッカー履歴

    反復 内容
    0 アンカーコメント B1〜B7 の反映が未適用。Step 4 で修正済み
    1 C5: AC5/AC7/AC9 の VC コメント欠落、C10: RVA deferred フィールド欠落、C13: 複合コマンドと広すぎるパス指定。Step 4 で修正済み
    2 C13: パス指定が広すぎる(9 件)、バックスラッシュ付きパイプ(4 件)。最大反復回数に到達

    残存ブロッカー(反復 2 終了時点)

    パス指定が広すぎる(9 件)

    check_issue_contract.py が VC 内の rg コマンドのパスを「広すぎる」と判定しています。具体的なファイルパスを指定していますが、Allowed Paths との照合方式に解釈差異があります。

    バックスラッシュ付きパイプ(4 件)

    VC 内の rg コマンドのパターンに \| が含まれています。| に修正してください。対象箇所は prose_boundary_policy import の検索パターンと termination_reason 系のパターンです。


    推奨アクション

    残存問題はいずれも機械的な修正です。

    1. VC 内のバックスラッシュ付きパイプ \| を | に置換(4 箇所)
    2. パス指定の形式をチェッカーが期待する書式に合わせる

    人間が Issue 本文を直接修正するか、ループを再実行してください。


    アンカーコメント対応状況

    B1〜B7 の全ブロッカーは反復 0→1 の書き換えで反映済みです。

    ブロッカー 対応状況
    B1: callsite の別 Issue 化 Out of Scope に追記済み
    B2: termination_reason/cause の分離 AC7 と Outcome で対応済み
    B3: stdout は機械 JSON のみ AC1 と AC6 で対応済み
    B4: prose_boundary_policy 公開 API のみ使用 AC3 と Allowed Paths で対応済み
    B5: 再生成の定義(2 試行上限) AC4 で対応済み
    B6: simulated replay evidence 必須化 AC9 と RVA deferred で対応済み
    B7: dynamic fence による injection 防御 AC8 で対応済み
  5. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    コントラクトレビュー: BLOCKED (2026-06-06T00:45:00Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: blocked
      generated_at: "2026-06-06T00:45:00Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/656
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: false
          vc_failed_as_expected: 5
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 1
          vc_skipped: 0
          status: human_judgment
          human_judgment_count: 7
        ac_verifiability: fail
        product_spec_check:
          applicability: not_applicable
          decision: pass
        worktree_branch_collision: clear
      next_action: propose_refinement_loop
      blocked_reasons:
        - "AC_UNKNOWN: AC マーカーが全て未認識(# AC1 - description 形式はパーサ非対応)"
        - "human_judgment: render_termination_report.py(未作成ファイル)を対象とする rg コマンド 7 件が exit_code=2 → classifier が expected_baseline_fail と認識できない"

    不足項目

    1. AC マーカー形式の不一致(全 VC が AC_UNKNOWN)

    パーサが認識する AC マーカー形式: # AC1 または # AC1: のみ(行末まで)

    現在の Issue では # AC1 - 日本語説明 形式を使用しており、説明付きサフィックスは認識されません。

    修正方法: AC 番号行を # AC1 のみの行にする(説明はその次の行に # description として記載)。

    例:

    # AC1
    # render_termination_report.py が 3 種終了レポートを扱う
    $ rg -n "human_escalation|needs-fix|max_iterations" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py
    

    # AC2, AC5 - ... のような複数 AC 指定もパーサ非対応です。各コマンドに単一 AC マーカーを付けてください。

    2. 未作成ファイルへの rg コマンドが human_judgment 分類

    render_termination_report.py(実装対象の新規ファイル)を指定した rg コマンドは baseline では exit_code=2(No such file or directory)を返します。classifier は rg exit_code=2 を unknown/human_judgment として分類します(exit_code=1 = no match の場合のみ expected_baseline_fail/go)。

    修正方法: 新規作成ファイルを対象とする rg コマンドには # preflight-scope: pr_review_only マーカーを追加する(VC の意味論は変わらず、PR レビュー時に検証される)。

    例:

    # AC1
    # preflight-scope: pr_review_only
    $ rg -n "human_escalation|needs-fix|max_iterations" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py

    推奨アクション

    issue-refinement-loop の起動を推奨します(承認後に実行可能です)。

    修正スコープ(VC セクションのみ、Issue 意味論の変更なし):

    1. 全 AC マーカー行を # ACN 形式(説明なし単一行)に統一
    2. render_termination_report.py / test_render_termination_report.py を対象とする rg・pytest コマンドに # preflight-scope: pr_review_only を追加
    3. termination-policy.md を対象とする AC6 rg コマンドも同様に対応(ファイル既存のため不要かもしれないが確認が必要)
  6. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    コントラクトスナップショット (2026-06-06T00:50:29Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-06T00:50:29Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/656
      body_sha256: "sha256:f86d736b3ca56e16efa3c7f5472128f685749baf4bcb2366cacc971d5acb3658"
      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: 5
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 1
          vc_skipped: 7
          status: pass
          classifications:
            - ac: AC1
              command: "rg -n \"human_escalation|needs-fix|max_iterations\" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC1
              command: "rg -n \"TERMINATION_REPORT_RENDER_RESULT_V1\" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC2
              command: "uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k \"termination_report\""
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC3
              command: "rg -n \"from.*prose_boundary_policy import|import prose_boundary_policy\" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC3
              command: "rg -cn \"re\.compile|re\.search|re\.match\" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC4
              command: "uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k \"no_llm or no_ask or no_network or attempts\""
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC5
              command: "uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k \"guard_fail_publishable_false or limit_exceeded\""
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC6
              command: "rg -n \"dry.run|再生成|reason_code|TERMINATION_REPORT_RENDER_RESULT_V1\" .claude/skills/issue-refinement-loop/references/termination-policy.md"
              exit_code: 1
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC7
              command: "rg -n \"termination_reason.*needs.fix|termination_reason.*max_iterations\" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC7
              command: "rg -n \"termination_cause\" .claude/skills/issue-refinement-loop/scripts/render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC8
              command: "uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q -k \"fence or adversarial or injection\""
              exit_code: 4
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC9
              command: "rg -n \"TERMINATION_REPORT_RENDER_RESULT_V1|publishable|body.*null|reason_code\" .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py"
              exit_code: null
              category: preflight_scope_pr_review_only
              scope_class: pr_review_only
              confidence: low
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "VC marked pr_review_only; verification deferred to PR review"
              runtime_verification_required: false
            - ac: AC10
              command: "uv run pytest .claude/skills/issue-refinement-loop/tests/ -q"
              exit_code: 0
              category: regression_gate
              scope_class: regression_gate
              confidence: low
              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
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "pr_review_only VCs (AC1, AC3, AC7, AC9) は PR レビュー時に pr-review-judge が検証する"

    コントラクト要約

    • Outcome: render_termination_report.py が終了レポートを guard 互換 deterministic template から生成し、TERMINATION_REPORT_RENDER_RESULT_V1 JSON を返す
    • Acceptance Criteria: AC1〜AC10(10 件)
    • Verification Commands: baseline 5 件 pass、pr_review_only 7 件(PR レビュー時検証)、regression_gate 1 件 pass(212 テスト)
    • Allowed Paths:
      • .claude/skills/issue-refinement-loop/scripts/render_termination_report.py(新設)
      • .claude/skills/issue-refinement-loop/references/termination-policy.md(規約追記)
      • .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py(新設)
      • .claude/skills/create-issue/scripts/prose_boundary_policy.py(読み取り参照のみ)
    • Worktree: .claude/worktrees/issue-656-issue-refinement-loop-guard-renderer
    • Branch: worktree-issue-656-issue-refinement-loop-guard-renderer
    • VC preflight: baseline fail = 5、想定外 pass = 0、実行不可 = 0、skipped (pr_review_only) = 7、regression_gate pass = 1
  7. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-06-06T01:02:29Z)

    • PR: feat(#656): render_termination_report.py guard-compatible renderer 新設 #688
    • Worktree: .claude/worktrees/issue-656-issue-refinement-loop-guard-renderer
    • Branch: worktree-issue-656-issue-refinement-loop-guard-renderer
    • Verification: 266 PASS(新規 54 + 既存 212)、pnpm typecheck/lint/test/build 全 PASS
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  8. added a commit that references this issue on Jun 6, 2026
  9. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    PR #688 の人間レビュー REQUEST_CHANGES 対応完了。commit: 2720c8f

    修正概要:

    B1 - _make_dynamic_fence() を blocker rendering に使用: _render_normal_template() の blockers_summary 出力を箇条書き形式から json.dumps と dynamic fence で包んだ literal block 形式に変更した。

    B2 - adversarial input regression tests 追加: tilde fence injection、triple backtick injection、HTML marker injection、改行込みスタックトレース、5 バッククォートシーケンスの 5 ケースを追加。各テストで _run_guard(body) が ok を返すこと、shell_command / vc_command block が現れないことを確認する。

    B3 - blockers_summary 要素型の厳密 validation: 全要素が str であることを確認(None・dict・int を拒否)、issue_number / iteration は type() チェックで bool を拒否。テスト 7 件追加。

    N1 - render() 先頭で _validate_input() を呼び出し: import 経由の直接呼び出しでも validation が完結する。

    B4 - CI workflow に pytest ステップ追加: python-test ジョブに .claude/skills/issue-refinement-loop/tests/ の pytest ステップを追加した。

    検証結果: 全 275 テスト pass。pnpm typecheck / lint / test / build も全て pass した。

  10. added a commit that references this issue on Jun 6, 2026
  11. squne121 commented on Jun 6, 2026

    @squne121
    OwnerAuthor

    PR #688 マージ後クリーンアップ完了 (2026-06-06T05:10:00Z)

    クリーンアップ完了。follow-up Issue #692(callsite integration)を起票済み。親 Issue #646 は他の子 Issue が未完了のため open 継続。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues:
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issue/656:callsite-integration-step5"
          status: created
          issue:
            number: 692
            url: "https://github.com/squne121/loop-protocol/issues/692"
          reason: "PR #688 Delivery Rule に明記された callsite integration 起票。render_termination_report.py を issue-refinement-loop Step 5 に統合し schema-governance.md に登録する。"
    
      note_only_observations:
        - dedupe_key: "branch:worktree-issue-656-issue-refinement-loop-guard-renderer"
          source_url: "https://github.com/squne121/loop-protocol/pull/688"
          source_note_id: "cleanup-branch"
          summary: "ローカル branch と worktree を削除済み。worktree の unstaged 削除ファイルを restore してから除去した。"
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

    agent/implementerarea/ai-opsenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions