Repository navigation
Closed
1 / 11 of 1 issue completed
Copy link
Labels
phase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "human_escalation 停止時の termination report 入力正規化を安全化し、Cause と blocker 情報が false-positive なく comment に表示されるようにする"
change_kind: mixedRuntime Verification Applicability
decision: not_applicable
reason: "スクリプト単体テスト(uv run pytest)で完結する。runtime UI / simulation 動作確認は不要"Parent Issue
none(単独改善)
Parent Goal Ref
- Goal: issue-refinement-loop の human_escalation 終了時に停止理由と blocker 情報が GitHub comment で安全に可視化される
- Desired Destination: termination report 入力が正規化され、
Cause: noneや legacy alias 取りこぼしを起こさず、false-positive な cause 推定も行わない
Current Validated Scope
- 実装: issue-refinement-loop の checker approve が max_rewrite_attempts を超えて human_escalation される問題を修正する #814 refinement loop(2026-06-13)で
human_escalation停止時に GitHub comment がCause: noneになり blocker 情報が失われた render_termination_report.pyはhuman_escalationでtermination_cause = data.get("termination_cause")をそのまま_cause_label()に渡し、Noneのとき"none"を返すrender_termination_report.pyはblockers_summaryしか読まず、blocker_summarylegacy alias、alias conflict、alias 側の型検証を持たないpublish_termination_report.pyは renderer への thin pass-through で、termination report input の正規化責務を持っていないtermination-policy.mdはtermination_cause: nullを approved / superseded 等で有効値として定義しており、human_escalationは max iterations 専用ではないSKILL.mdStep 5 の publisher 呼び出し例は approved の最小 JSON のみで、human_escalation時のtermination_cause/blockers_summary入力例がない- 既存テストは green だが、missing cause、
blocker_summaryalias、alias conflict、explicit cause preserve の新仕様は未固定
Remaining Parent Gaps
なし(単独改善)
Outcome
termination_reason: human_escalation かつ termination_cause omitted/null の termination report 入力が Cause: none を出さず安全な fallback cause に正規化され、blocker_summary legacy alias も conflict-aware に canonical blockers_summary へ正規化される状態で、renderer / publisher / skill docs の回帰テストが PASS している状態。
In Scope
render_termination_report.pyに termination report input の正規化を追加し、human_escalationかつtermination_causeomitted/null の場合はhuman_judgment_requiredを fallback cause として扱い、caller が明示した valid cause は上書きしないrender_termination_report.pyでblocker_summarylegacy alias を canonicalblockers_summaryへ正規化し、alias conflict と alias 側の型不正を fail-closed で reject するpublish_termination_report.pyが renderer と異なる意味論を持たないことを維持しつつ、publisher 経路でも canonical input が renderer に渡ることを regression で固定する.claude/skills/issue-refinement-loop/references/termination-policy.mdと.claude/skills/issue-refinement-loop/SKILL.mdの Step 5 / termination report input 例を、human_escalation時のtermination_cause/blockers_summary/ legacy alias policy に合わせて更新する- renderer test / publisher test に missing cause、legacy alias、alias conflict、explicit cause preserve の回帰ケースを追加する
Out of Scope
approved/superseded_by_decisionのtermination_cause: nullを invalid 化する変更human_escalationのすべてをmax_iterations_exceededに推定する汎用 fallback の導入TERMINATION_REPORT_INPUT_V1の canonical key 名そのものを変更すること- issue-refinement-loop 本体の routing semantics や
VALID_TERMINATION_CAUSESへの新規 cause 追加
Acceptance Criteria
- AC1:
termination_reason: human_escalationかつtermination_causeomitted/null の termination report 入力を renderer / publisher 経路で処理したとき、生成される comment body がCause: noneを含まず、fallback cause としてhuman judgment requiredを表示する - AC2: caller が
termination_cause: max_iterations_exceededなどの valid cause を明示した場合、その値は renderer / publisher 経路で保持され、fallback に上書きされない - AC3:
blocker_summary: list[str]のみが渡された場合、canonicalblockers_summaryと同等に blocker section へ表示される - AC4:
blocker_summaryとblockers_summaryが両方あり値が異なる場合、または alias 側がlist[str]でない場合、termination report 入力は validation error / fail-closed になる - AC5:
.claude/skills/issue-refinement-loop/references/termination-policy.mdと.claude/skills/issue-refinement-loop/SKILL.mdに、human_escalation時のtermination_cause/blockers_summary入力例と legacy alias policy が追記される - AC6:
uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -vが PASS する - AC7:
uv run pytest .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py -vが PASS する
Verification Commands
# AC1
$ rg -n "test_human_escalation_missing_cause_defaults_to_human_judgment_required" .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py
# AC2
$ rg -n "test_publish_preserves_explicit_termination_cause" .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py
# AC3
$ rg -n "test_legacy_blocker_summary_alias_renders_blockers" .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py
# AC4
$ rg -n "test_blocker_summary_alias_conflict_is_rejected|test_blocker_summary_alias_type_is_rejected" .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py
# AC5
$ rg -n "legacy alias blocker_summary is normalized to canonical blockers_summary|human_escalation example includes termination_cause and blockers_summary" .claude/skills/issue-refinement-loop/references/termination-policy.md .claude/skills/issue-refinement-loop/SKILL.md
# AC6
# preflight-scope: pr_review_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_render_termination_report.py -v
# AC7
# preflight-scope: pr_review_only
$ uv run pytest .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py -vAllowed Paths
.claude/skills/issue-refinement-loop/scripts/render_termination_report.py.claude/skills/issue-refinement-loop/scripts/publish_termination_report.py.claude/skills/issue-refinement-loop/references/termination-policy.md.claude/skills/issue-refinement-loop/SKILL.md.claude/skills/issue-refinement-loop/tests/test_render_termination_report.py.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR。worktree 作成・Draft PR を既定とする。
Sub-issues
Collapse Sub-issuesSub-issues
Loading 1 sub-issues
Metadata
Metadata
Assignees
Labels
phase/implementationImplementation phase
Activity
squne121 commentedon Jun 12, 2026
Verdict: REQUEST_CHANGES
#829 の不具合設定は実在します。Issue コメントは 0 件ですが、Issue 本文は #814 の refinement loop で
human_escalation停止コメントがCause: noneになり、blocker 情報も失われた事象を修正対象にしています。AC も「省略されたtermination_causeを意味ある Cause にする」「旧キーblocker_summaryを受ける」ことを要求しています。現行コードでも根拠は確認できます。
render_termination_report.pyはtermination_cause = data.get("termination_cause")、blockers_summary = data.get("blockers_summary") or []だけを見ており、human_escalationでは_cause_label(termination_cause)をそのままCause:に出します。さらに_cause_label(None)は"none"を返します。blocker セクションもblockers_summaryが空なら出ません。ただし、#829 はこのまま実装に渡すには危険です。最大の問題は、
human_escalationかつ cause 欠落を常にmax_iterations_exceededと推定する設計です。human_escalationは max iterations 以外にも、human review 必要、contract review のhuman_judgment、hard stop、scope change、外部調査未解決、unsafe mutation など複数の停止経路を表します。termination policy でもhuman_escalationは max iterations 専用ではありません。Blockers
#829 の AC1 は、
termination_cause省略時にCause: Max iterations exceededを出すことを要求しています。しかし #814 由来の実バグが max-attempts 系だったとしても、renderer が全human_escalation欠落 cause を max iterations と決め打ちすると、将来の scope change / human judgment / unsafe mutation でも虚偽の Cause を出します。これは observability の改善ではなく、callsite bug の隠蔽です。修正方針はどちらかに固定すべきです。
route.reason_code == max_attempts_exceededのときだけtermination_cause: max_iterations_exceededにマップする。human_judgment_requiredなどの広い値にし、max_iterations_exceededにはしない。Noneを無効化してはいけない#829 本文は
VALID_TERMINATION_CAUSESにNoneが含まれることを問題視していますが、現行 policy はtermination_cause: nullを approved / superseded 等の「原因なし」として定義しています。既存テストも missing/null cause を valid として扱っています。したがってNoneを global に invalid 化すると既存契約を壊します。修正は「human_escalationのときだけ cause 欠落を扱う」べきです。#829 は「SKILL.md Step 5 のサンプル」を修正対象にしていますが、Allowed Paths には
.claude/skills/issue-refinement-loop/SKILL.mdがありません。しかも PR #698 は実際に SKILL.md Step 5 に publisher 呼び出し例を追加しており、その例は approved の最小 JSON だけで、human_escalation/termination_cause/blockers_summaryの例を含みません。Allowed Paths は次のどちらかに修正が必要です。
.claude/skills/issue-refinement-loop/SKILL.mdを追加する。termination-policy.mdのTERMINATION_REPORT_INPUT_V1例だけを更新する。blocker_summaryalias の衝突ルールが未定義旧キー
blocker_summaryを受けること自体は互換性維持として妥当です。しかし、両方のキーが来た場合のルールがありません。これを曖昧にすると、caller のバグを静かに上書きします。最低限、次を AC 化してください。
現行
_validate_inputはblockers_summaryだけを検証しており、blocker_summaryは見ていません。#829 は「renderer または呼び出し元で補完」「publisher で aliasing または input 変換」と書いており、責務が分散しています。現在の
publish()はinput_dataをそのまま renderer subprocess に渡すだけです。ここに中途半端な正規化を入れると、directrender()呼び出しと publisher 経由で挙動が分岐します。推奨は、
render_termination_report.py側に_normalize_input(raw)を置き、render()と CLI validation の前で必ず通すことです。publisher 側でやるなら、renderer 側にも同じ正規化を置き、publisher は単なる互換 shim に留めるべきです。既存 render test の helper は
blockers_summaryしか受けず、publish test の helper はtermination_reason/termination_cause/issue_numberしか扱いません。つまり #829 の実バグである「publisher に渡した JSON が renderer にどう流れるか」を直接捕まえるテストが薄いです。追加すべき regression はこれです。
Web 調査に基づく実装上の注意
現在の publisher の
gh issue comment --body-file -は維持でよいです。GitHub CLI 公式 manual はgh issue commentに--body-file <file>があり、-で stdin から読むと明記しています。(GitHub CLI)subprocess.runについても、現行のcapture_output=True,input=...,text=True,check=False,timeout=...,shell=Falseは妥当です。Python 公式 docs ではcapture_outputが stdout/stderr を捕捉し、inputが stdin に渡され、check=Trueの場合は non-zero exit でCalledProcessErrorを投げるため、fail-closed publisher ではcheck=Falseを維持すべきです。([Python documentation]2)alias を schema 境界に入れる場合は、canonical schema に未知キーを混ぜないことも重要です。JSON Schema では
additionalProperties: falseは定義外プロパティを許可しない指定なので、blocker_summaryは validation 前にblockers_summaryへ正規化し、canonical object からは削除するのが安全です。([JSON Schema]3)修正版 AC 案
実装指針
正規化はテンプレート描画の途中ではなく、入力境界で一度だけ行うべきです。
#814 専用に
max_attempts_exceeded -> max_iterations_exceededを出したいなら、renderer に推測させず、orchestrator / route wrapper 側が明示的にtermination_cause: "max_iterations_exceeded"を渡すべきです。#814 のレビューコメントでも、router の reason_code を human escalation 終了コメントに添付する経路が重要視されています。最終判断
#829 は必要です。ただし現状の AC1 は「観測不能だった原因を可視化する」よりも「欠落した原因を max iterations と決め打ちする」内容になっており、将来の別種
human_escalationを誤表示します。実装前に、少なくとも cause fallback の意味論、alias 衝突時の fail-closed、正規化レイヤー、SKILL.md Allowed Paths の矛盾を直してください。これを直さずに実装すると、
Cause: noneは消えますが、次は false cause が termination comment に残る設計になります。squne121 commentedon Jun 12, 2026
更新内容
human_escalationの missing cause でCause: noneを出さない契約に更新human_judgment_requiredへ寄せ、max_iterations_exceededは caller 明示 / route-specific mapping に限定blocker_summarylegacy alias の canonical 化と conflict fail-closed を追加termination-policy.mdとSKILL.mdStep 5 を合わせ、Allowed Paths に.claude/skills/issue-refinement-loop/SKILL.mdを追加Guards
check_vc_scope.py: PASSguard-issue-body.py: PASScontract_readiness_check.py: gosqune121 commentedon Jun 12, 2026
Issue 本文を owner comment に合わせて更新し、live readback で
check_issue_contract.py: approveとcontract_readiness_check.py: status: goを確認しました。今回の更新では、
human_escalationの cause 欠落を一律max_iterations_exceededと決め打ちしないようにし、blocker_summarylegacy alias の conflict-aware な正規化、SKILL.md/termination-policy.mdの入力例整合、対応する regression test の future marker を issue contract に反映しています。squne121 commentedon Jun 12, 2026
CodexCLI作業ログ
squne121 commentedon Jun 12, 2026
Issue #829 について deterministic preflight を実行し、implementation intake 用の canonical contract snapshot を記録します。
blocker/dependency なし、product spec preflight は
not_applicable/pass、VC preflight はpassでした。squne121 commentedon Jun 12, 2026
Issue #829 の contract snapshot を確認しました。
product spec は not_applicable で、VC は AC1-AC5 baseline fail / AC6-AC7 pr_review_only skipped です。