Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#646"
goal_ref: "guard-japanese-prose と issue contract authoring の境界を SSOT 化し、公開副作用を伴う GitHub mutation だけを guard しつつ、機械可読契約・テンプレ見出し・一時下書き・終了レポートが guard と両立した状態で issue-refinement-loop / create-issue / edit-issue が実運用で回ることを、運用証跡(shadow ログ / replay transcript)付きで保証する"
change_kind: workflowParent Issue
Parent Goal Ref
- Goal: guard-japanese-prose と issue contract authoring boundary を SSOT 化し、公開副作用を伴う GitHub mutation だけを guard しつつ、機械可読契約・テンプレ見出し・一時下書き・終了レポートが guard と両立した状態で issue-refinement-loop / create-issue / edit-issue が実運用で回ることを、運用証跡(shadow ログ / replay transcript)付きで保証する
- Desired Destination:
issue-refinement-loopStep 5 の終了レポートが guard 互換テンプレートから生成され、投稿前 dry-run guard・上限付き再生成・上限超過時の非投稿 + reason_code 出力が実装されている状態(導入: guard-japanese-prose と issue contract authoring boundary の統合修正 #646 AC5)
Current Validated Scope
.claude/skills/issue-refinement-loop/SKILL.mdの Step 5 記述からrender_termination_report.pyを呼び出す統合手順を追加・修正する.claude/skills/issue-refinement-loop/scripts/配下に callsite integration スクリプト(または step-level invocation wrapper)を作成する.claude/skills/issue-refinement-loop/tests/配下に統合テストを追加するdocs/dev/schema-governance.mdにTERMINATION_REPORT_RENDER_RESULT_V1を正式登録する
Remaining Parent Gaps
- 実装(#646): guard-japanese-prose に shadow / enforce mode と replay 証跡(R1〜R7)を追加 #657 — child-4: shadow/dry-run mode と JSONL 計測・enforce rollback・Claude Code replay 証跡(引き続き OPEN)
Outcome
.claude/skills/issue-refinement-loop/SKILL.md の Step 5 が render_termination_report.py を呼び出す統合手順を持ち、publishable=true 時のみ終了レポートが GitHub へ投稿され、publishable=false 時は reason_code が stderr / local artifact に記録され、かつ TERMINATION_REPORT_RENDER_RESULT_V1 が docs/dev/schema-governance.md に登録されたコミットが存在し、統合テストが PASS している状態。
In Scope
.claude/skills/issue-refinement-loop/SKILL.md(または同等の step 定義ファイル)の Step 5 にrender_termination_report.py呼び出し手順を統合するpublish_termination_report.py(新規作成):render_termination_report.pyを subprocess で呼び出す薄い publishergh issue comment --body-fileによる非対話・shell injection 耐性の投稿経路- renderer 出力の fail-closed 検証(exit code / JSON validity / schema / publishable×body 整合性 / timeout)
docs/dev/schema-governance.mdへのTERMINATION_REPORT_RENDER_RESULT_V1producer/consumer/compatibility/detection 登録- 既存 termination marker(
LOOP_HANDOFF_RESULT_V1/FOLLOW_UP_MATERIALIZATION_RESULT_V1)との共存テスト
Out of Scope
render_termination_report.py本体の変更(実装(#646): issue-refinement-loop 終了レポートの guard 互換 renderer ライブラリ新設 #656 で完成済み)- shadow / enforce mode(実装(#646): guard-japanese-prose に shadow / enforce mode と replay 証跡(R1〜R7)を追加 #657 child-4 担当)
- 公開 mutation route matrix(実装(#646): 公開 mutation route matrix SSOT 化と tmp 下書き / 公開 mutation の分離(REST -f / -F / --input と GraphQL conservative deny) #655 child-2 担当)
prose_boundary_policySSOT 変更(実装(#646): prose / code / machine-readable / heading / tmp draft / public output 分類の prose boundary policy SSOT 化 #653 child-0 で完成済み)- 他 child issue の Allowed Paths(
.claude/hooks/guard-japanese-prose.sh等)
Acceptance Criteria
- AC1: Step 5 の termination flow は
publish_termination_report.pyを経由することをSKILL.mdまたはreferences/termination-policy.mdに明記する(rg "publish_termination_report" .claude/skills/issue-refinement-loop/SKILL.md .claude/skills/issue-refinement-loop/references/termination-policy.mdが 1 件以上 hit する) - AC2:
publish_termination_report.pyはrender_termination_report.pyをsubprocess.run([sys.executable, ...], shell=False, ...)で呼び出し、stdout JSON のschema/schema_version/publishable/body/reason_codeを検証する - AC3:
publishable=trueかつbodyが非空文字列の場合だけgh issue comment --body-fileを呼ぶ(--bodyでの直接渡しは禁止) - AC4:
publishable=false、renderer non-zero exit、invalid JSON、schema/schema_version 不一致、publishable=true/body=null、publishable=false/body 非 null、timeout のすべてでghを呼ばない(fail-closed) - AC5:
publishable=falseまたは異常系ではreason_code/ renderer stderr / returncode / issue_number / timestamp をローカル artifact に記録する。ただし投稿可能本文を stderr へ漏らさない - AC6:
render_termination_report.pyは変更しない - AC7:
docs/dev/schema-governance.mdにTERMINATION_REPORT_RENDER_RESULT_V1の producer / consumer / compatibility / detection を登録する(rg "TERMINATION_REPORT_RENDER_RESULT_V1" docs/dev/schema-governance.mdが 1 件以上 hit する) - AC8: fake
ghと fake renderer による integration tests を追加する(publishable=true正常投稿、publishable=false非投稿、renderer 異常系 fail-closed、既存 termination markerLOOP_HANDOFF_RESULT_V1/FOLLOW_UP_MATERIALIZATION_RESULT_V1との共存を含む) - AC9: 既存の renderer tests と issue-refinement-loop tests が通る(
uv run pytest .claude/skills/issue-refinement-loop/tests/ -qとuv run pytest .claude/skills/issue-refinement-loop/scripts/ -qが PASS)
Verification Commands
# AC1
$ rg "publish_termination_report" .claude/skills/issue-refinement-loop/SKILL.md
# AC2
# preflight-scope: runtime_only
$ rg "subprocess\.run" .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
# AC3
# preflight-scope: runtime_only
$ rg "\-\-body-file" .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
# AC4
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py -q -k "fail_closed"
# AC5
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py -q -k "artifact"
# AC6
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -q
# AC7
$ rg "TERMINATION_REPORT_RENDER_RESULT_V1" docs/dev/schema-governance.md
# AC8
# preflight-scope: runtime_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py -q
# AC9
$ uv run pytest .claude/skills/issue-refinement-loop/tests/ -qAllowed Paths
変更を許可するファイル・ディレクトリは以下に限定する(リスト外のファイルへの変更は Stop Condition)。
.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/scripts/publish_termination_report.py.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.pydocs/dev/schema-governance.md
Forbidden Paths(変更禁止ファイル)
変更禁止ファイル(既存の完成済みコンポーネント)。このパスへの変更は AC6 違反となりアウトオブスコープ。
.claude/skills/issue-refinement-loop/scripts/render_termination_report.py(実装(#646): issue-refinement-loop 終了レポートの guard 互換 renderer ライブラリ新設 #656 で完成済み、変更禁止)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
render_termination_report.py本体の変更が必要と判明した場合(実装(#646): issue-refinement-loop 終了レポートの guard 互換 renderer ライブラリ新設 #656 完成スコープ外の問題が発見された場合)
Required Skills
- Python 3 / pytest
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR原則render_termination_report.py本体(.claude/skills/issue-refinement-loop/scripts/render_termination_report.py)は Allowed Paths 外であることに注意(変更禁止)gh issue commentの body は--body-file経由のみ(--bodyでの直接渡し禁止)subprocess.runはshell=False、capture_output=True、text=True、check=Falseを使うrender_termination_report.pyは Forbidden Paths であり変更禁止(Allowed Paths の.claude/skills/issue-refinement-loop/scripts/publish_termination_report.pyは新規作成のみ)docs/dev/schema-governance.mdは 実装: subagent_execution_ledger/v1 を docs/dev/schema-governance.md の Known Schemas に登録する #193(OPEN:subagent_execution_ledger/v1登録)と同一ファイルを対象とするため、マージ順序に注意すること。並行実装時はコンフリクト回避のため、実装: subagent_execution_ledger/v1 を docs/dev/schema-governance.md の Known Schemas に登録する #193 の merge 状況を確認してから本 Issue を実装する
Background
Issue #656 で render_termination_report.py(TERMINATION_REPORT_RENDER_RESULT_V1 renderer)を新設した(PR #688 でマージ済み)。ただし callsite integration(issue-refinement-loop Step 5 への組み込み)は out-of-scope とし、本 Issue に委譲した(PR #688 Delivery Rule より)。
render_termination_report.py は stdin から TERMINATION_REPORT_INPUT_V1 JSON を受け取り、stdout に TERMINATION_REPORT_RENDER_RESULT_V1 JSON を出力する。publishable フラグにより GitHub 投稿可否を返す設計になっている。
本 Issue はこの renderer を issue-refinement-loop Step 5 の終了判定・レポート出力ステップに接続し、guard 互換の deterministic template から終了レポートを生成するようにする。また TERMINATION_REPORT_RENDER_RESULT_V1 スキーマを schema-governance.md に正式登録する。
スキーマガバナンス登録事項(Schema Governance)
TERMINATION_REPORT_RENDER_RESULT_V1 を schema-governance.md に正式登録する。登録内容は以下のとおり。
- 登録対象スキーマ名:
TERMINATION_REPORT_RENDER_RESULT_V1 - 生成元(Producer):
render_termination_report.py - 利用元(Consumer):
publish_termination_report.py/issue-refinement-loopStep 5 - 互換性方針(Compatibility): additive consumer integration; renderer schema unchanged(レンダラー側スキーマは変更しない)
- 検出コマンド(Detection):
rg "TERMINATION_REPORT_RENDER_RESULT_V1" .claude/skills/issue-refinement-loop docs/dev/schema-governance.mdrg "publishable|reason_code|schema_version" .claude/skills/issue-refinement-loop/scripts .claude/skills/issue-refinement-loop/tests
Note: #193 も docs/dev/schema-governance.md を対象とする。並行実装時は #193 の merge 状況を確認してから本 Issue を実装すること。
Runtime Verification Applicability
decision: immediate
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
- AC7
- AC8
- AC9
execution_environment:
cli_tools:
- uv
- rg
- git
- bash
auth_required: false
network_required: false
skip_conditions:
- "local repository checkout が存在しない場合は environment blocked として扱う(SKIP 不可)"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback 経由の成功を PASS に変換しない"
artifact_requirements:
- "pytest output for test_publish_termination_report.py"
- "rg output for AC1/AC7"Source
follow-up:squne121/loop-protocol:issue/656:callsite-integration-step5
Activity
squne121 commentedon Jun 6, 2026
判定: REQUEST_CHANGES
Issue #692 の目的自体は妥当です。#656 / PR #688 で追加された
render_termination_report.pyを、issue-refinement-loopの Step 5 に接続し、publishable=trueのときだけ GitHub に投稿する、という方向は #646 の親Issueの到達点と整合します。問題は、#692 の契約がまだ粗く、実装者が危険な最小実装でACを満たせてしまうことです。([GitHub]1)最大のブロッカー
1. Allowed Paths が「renderer変更禁止」と矛盾している
#692 は Delivery Rule で
render_termination_report.pyを変更禁止としていますが、Allowed Paths では.claude/skills/issue-refinement-loop/scripts/全体を許可しています。これは実装者に「scripts配下なら変更可能」という誤解を与えます。([GitHub]1)修正案:
さらに Verification にこれを追加すべきです。
2. AC2 が弱すぎる
現在の AC2 は
publishable分岐が「docs/code上で確認できる」程度です。これでは、publishable=falseでもgh issue commentを呼ぶ実装や、renderer の異常終了時に誤投稿する実装を排除できません。#688 のrendererはpublishable=falseの場合も正常終了し、reason_code=guard_fail_limit_exceededとbody=nullを返す設計です。つまり callsite 側で publishable / body / reason_code / exit code / stdout JSON の整合性を厳格に見る必要があります。([GitHub]1)最低限、以下のテストを AC に入れるべきです。
3. GitHub投稿経路の安全性が未定義
#655 は「public mutation route matrix」をSSOT化し、
gh issue comment/gh pr comment/gh apiの本文入力経路を分類することを求めています。#692 は投稿経路をgh issue commentにするのか、gh apiにするのか、bodyを--bodyで渡すのか、--body-fileで渡すのかを明記していません。([GitHub]2)GitHub CLI の公式ドキュメント上、
gh issue commentは--bodyと--body-fileを持ち、body指定なしでは対話プロンプトになります。callsite は非対話・テスト可能・shell injection耐性のため、--body-fileを使うべきです。([GitHub CLI]3)推奨:
禁止すべきもの:
理由は、本文が引数に露出しやすく、shell呼び出しと組み合わさると事故面が増えるためです。Python側では
subprocess.run([...], shell=False, capture_output=True, text=True, check=False)を使い、shell=Trueを避けるべきです。Python公式もargsはsequence推奨、capture_output/input/textの利用を説明しており、shell=TrueはSecurity Considerations参照対象です。([Python documentation]4)4. renderer の異常系契約が callsite 側に落ちていない
render_termination_report.pyは stdin JSON を読み、stdout に結果JSON、stderrに診断情報を出すCLIです。invalid input は exit 2、内部エラーは exit 3、通常処理はpublishable=true/falseを含むJSONで返します。([GitHub]5)#692 は「publishable=falseなら投稿しない」だけを要求していますが、callsite integrationとしては次の異常系が必須です。
schema != TERMINATION_REPORT_RENDER_RESULT_V1。schema_version != 1。publishable=trueなのにbodyが空。publishable=falseなのにbodyが入っている。Python の
jsonは不正JSONでJSONDecodeErrorを投げ、公式ドキュメントは untrusted JSON のCPU/メモリ消費にも注意を促しています。callsite は入力サイズ・stdoutサイズ・timeout を制限する設計にすべきです。([Python documentation]6)5. schema-governance のACが
rgだけで不十分#692 は
TERMINATION_REPORT_RENDER_RESULT_V1をdocs/dev/schema-governance.mdに登録する、としています。しかし現在の schema governance は、schema変更時に Consumer Inventory、互換性判断、検出コマンド出力を要求する設計です。単なるrg TERMINATION_REPORT_RENDER_RESULT_V1では不足します。([GitHub]1)PR #688 のレビューコメントでも、Schema Consumer Inventory 不足がブロッカーとして指摘され、その後の反復で解消された経緯があります。#692 は同じ欠陥を再発させないよう、callsite側の consumer を明示するべきです。([GitHub]7)
追加すべき記載:
また #193 も
docs/dev/schema-governance.mdを触る予定なので、#692 はマージ順・競合解消手順を明記した方が安全です。([GitHub]1)6. Step 5 の実際の接続点が曖昧
現行の
SKILL.mdの Step 5 は termination 条件についてreferences/termination-policy.mdを参照しているだけで、renderer呼び出しは明示されていません。#692 はSKILL.mdだけを主な変更対象にしていますが、termination-policy 側をSSOTとして維持するのか、Step 5に直接wrapper呼び出しを書くのかが曖昧です。([GitHub]8)ここは二択にすべきです。
A案:
SKILL.mdを薄いentrypointに保つB案: Step 5 に具体的callsiteを書く
ただし、
SKILL.md自身は「thin entrypointであり planner/reviewer/worker logic を再実装しない」と書かれているため、A案の方が設計思想には合います。([GitHub]8)7. 既存 termination marker との整合が未確認
termination-policy.mdは、terminationコメントにFOLLOW_UP_MATERIALIZATION_RESULTを含めること、承認済みterminationではLOOP_HANDOFF_RESULT_V1を出すことを定義しています。#692 は rendererのTERMINATION_REPORT_RENDER_RESULT_V1だけに注目しており、既存の termination comment 契約を壊さないことをACにしていません。([GitHub]9)追加すべきテスト:
推奨する wrapper 実装方針
新規scriptは
render_termination_report.pyを変更せず、薄い publisher として作るべきです。判定規則:
subprocess.runのcapture_output、input、text、check=Falseの使い方はPython公式の想定に沿っています。shell=Trueは不要で、ここでは禁止すべきです。([Python documentation]4)#692 のAC差し替え案
現在のACは
rg中心で、実装の安全性を保証しません。以下に差し替えるべきです。検証コマンド:
最終判断
#692 は このまま実装に投げるべきではありません。目的は正しいですが、現在のIssue契約では以下の事故が起きます。
publishable=falseでもGitHub投稿する。gh issue commentの対話モードや unsafe な body 渡しを使う。rgだけで済ませる。優先修正は、Allowed Pathsの厳格化、fake gh integration test、renderer出力のfail-closed検証、schema consumer inventoryの追加です。これを入れれば、#692 は #646 / #656 / #688 の流れに沿った安全な callsite integration Issue になります。
squne121 commentedon Jun 6, 2026
issue-refinement-loop 完了(iteration 2, approved)。
適用した変更サマリー
anchor comment(#issuecomment-4637525810)の REQUEST_CHANGES 7 ブロッカーを解消:
scripts/全体 →publish_termination_report.py個別ファイルに限定render_termination_report.py変更禁止を明示gh --body-file強制・shell=False・schema consumer inventory・termination marker 整合テスト$prefix、# AC<N>コメント、# preflight-scope: runtime_onlyマーカー追加applicable_acs/execution_environment/skip_conditions/fallback_policy/artifact_requirements完備--body-file強制・subprocess shell=False明記squne121 commentedon Jun 6, 2026
コントラクトスナップショット (2026-06-06T05:53:18Z)
issue-refinement-loopStep 5 がrender_termination_report.pyを呼び出す統合手順を持ち、publishable=true時のみ終了レポートが GitHub へ投稿され、publishable=false時はreason_codeが記録され、TERMINATION_REPORT_RENDER_RESULT_V1がschema-governance.mdに登録された状態publish_termination_report.py新規作成・fail-closed 検証・--body-file強制・shell=False・schema-governance 登録・統合テスト)rg "publish_termination_report"(AC1) / runtime_only×6 (AC2-6,AC8) /rg "TERMINATION_REPORT_RENDER_RESULT_V1" docs/dev/schema-governance.md(AC7) /uv run pytest .claude/skills/issue-refinement-loop/tests/ -q(AC9).claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/scripts/publish_termination_report.py.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.pydocs/dev/schema-governance.md.claude/skills/issue-refinement-loop/scripts/render_termination_report.py(変更禁止).claude/worktrees/issue-692-render-termination-report-issue-refinemeworktree-issue-692-render-termination-report-issue-refinemesqune121 commentedon Jun 6, 2026
実装完了。PR #698 を Draft 作成しました。
実装結果サマリー
.claude/skills/issue-refinement-loop/scripts/publish_termination_report.py.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py.claude/skills/issue-refinement-loop/SKILL.mddocs/dev/schema-governance.md検証コマンド(VC)実行結果
各 AC の検証が PASS しています(全 305 テスト通過)。
publish_termination_reportが 4件 hitsubprocess.runが 2件確認--body-fileが 3件確認PR: #698
fix(#692): apply pr-review fix_delta — gh timeout/env, stderr hash, r…
feat(#692): publish_termination_report.py で termination report の GitH…
squne121 commentedon Jun 6, 2026
post-merge-cleanup: 完了 (2026-06-06T06:40:00Z)