Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "Issue #889 / PR #952 が意図した通り、repair_issue_contract の deterministic かつ auto-safe な repair は human_escalation を発火させず、machine-actionable な needs_fix / repair_action signal として downstream へ伝播する(実際の Issue 本文 auto-mutation は follow-up Issue で扱う)"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: なし(単独改善のため N/A)
- Desired Destination: なし(単独改善のため N/A)
Current Validated Scope
repair_issue_contract.pyの producer 契約に versionedrepair_actionblock(disposition の closed enum、repairs[]全要素からの集約規則)を追加するrun_refinement_preflight.pyの repair_diagnostics blocker 生成ロジックを disposition に応じてneeds_fix(auto-safe)/blocked(unsafe・unknown・混在)/environment_failure(subprocess・artifact 異常)に分岐させるrefinement_preflight_result_v1.schema.jsonへstatus: needs_fixとrepair_actionの canonical projection を additive に追加するrepair_issue_contract_result_v1.schema.json(新規)へrepair_actiondisposition schema を追加する- Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 の safe baseline-expect repair が false human_escalation する経路を fixture 化し、修正後の needs_fix ルーティングを end-to-end 検証する
- 対応するテスト(新規
.claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.pyおよび既存.claude/skills/issue-refinement-loop/scripts/tests/test_repair_issue_contract.py/.claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py)の追加・更新
Remaining Parent Gaps
なし
Runtime Verification Applicability
- decision: not_applicable
- reason: マージ済み実装は
run_refinement_preflight.pyの_run_repair_subprocess()がsubprocess.run()で repair subprocess を実際に起動し、repair_issue_contract.pyのsecure_atomic_write_candidate()がos.open/fsync/os.replaceによる実ファイル I/O で candidate body を書き込む。これらの subprocess 起動・実ファイル I/O パスは PR 実装: repair_diagnostics blocker が deterministic な safe repair でも human_escalation する問題を修正する #2037 が追加したtest_repair_diagnostics_routing.py/test_repair_issue_contract.py(symlink-safety テストを含む、実 subprocess・実ファイルシステム挙動を伴う pytest)によって unit/integration test の枠内で exercise・検証済みであり、GUI/ゲームランタイムでの実行や専用の runtime AC/VC/証跡パイプラインを要するimmediate区分の動作検証は本 Issue の変更範囲に含まれない。
Outcome
repair_issue_contract.py が producer 契約として versioned repair_action(disposition の closed enum: auto_apply_safe / human_review_required / informational / invalid_payload と、repairs[] 全要素からの集約規則。legacy record の missing confidence・複数 kind 混在も定義する)を返し、run_refinement_preflight.py がその repair_action.disposition を consume して、
auto_apply_safeの場合は generic blocker を追加せずSTATUS: needs_fix/NEXT_ACTION: apply_deterministic_repairとし、diagnostics・candidate body artifact・original/repaired SHA を含む canonicalrepair_actionを result schema・compact stdout の両方へ機械可読に投影するhuman_review_required/informational/ unknown kind / safe・unsafe 混在 / overlapping repair / unsupported producer version の場合は既存通りblockersへ追加しSTATUS: blocked/NEXT_ACTION: human_judgment_requiredにする- repair subprocess の non-zero return code・timeout・invalid JSON・schema mismatch・input SHA 不一致・
changed: trueなのに mutating repair が 0 件・artifact write/readback failure はすべてSTATUS: environment_failure/NEXT_ACTION: fix_environmentにする
状態へ修正され、対応する新規 integration test と既存回帰テストが追加・PASS している状態。
実際の Issue 本文への auto-mutation(controlled issue-editor transaction・stale hash guard・GitHub readback・fresh preflight 再実行)は本 Issue の Outcome に含めない(Out of Scope 参照。理由は Background・Notes for Reviewer を参照)。
In Scope
repair_issue_contract.pyの producer payload にrepair_action(schema_version/disposition/original_body_sha256/repaired_body_sha256/diagnostics_artifact/candidate_body_artifact/repair_kinds/reason_codes)を追加し、repairs[]全要素(legacy record の missing confidence を含む)から単一 disposition を決定する集約規則を実装するrun_refinement_preflight.pyの repair_diagnostics blocker 生成ロジックをrepair_action.dispositionを consume するよう変更し、needs_fix/blocked/environment_failureの3ルートに分岐させる_invoke_repair()の subprocess 呼び出しを fail-open から fail-closed に修正する(returncode検査、timeout・invalid JSON・schema mismatch・input SHA 不一致・errorフィールド・changed: trueかつ mutating repair 0 件のケースをすべてenvironment_failureとして扱う)- artifact 書き込みを既存
_atomic_write_json()と readback validation で行い、例外の無条件 silent pass(except Exception: pass)を廃止する refinement_preflight_result_v1.schema.jsonへstatus: needs_fixの enum 値とrepair_actionprojection を additive に追加するrepair_issue_contract_result_v1.schema.json(新規)へrepair_actiondisposition の closed enum を追加するrun_refinement_preflight.pyの compact stdout(STATUS/NEXT_ACTION/ARTIFACT)へrepair_actionを機械可読に投影する(generic blocker の JSON 文字列内には埋め込まない)issue-refinement-loop/SKILL.mdの Step 0f canonical stdout フィールド説明へSTATUS: needs_fix/NEXT_ACTION: apply_deterministic_repairを追記する。orchestrator は現時点では auto-apply consumer を持たないため、apply_deterministic_repair受信時は human 判断待ちの informational route として扱うことを明記する(decide_next_loop_action.py等のロジック自体は変更しない)- Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 の再現ケースを fixture 化した end-to-end regression test を追加する
- 上記に対応するユニットテスト・integration テストの追加・更新
Out of Scope
- 実際の Issue 本文への auto-mutation(controlled
issue-editortransaction・stale hash guard・GitHub readback・fresh preflight 再実行)。別途 follow-up Issue(本 Issue の refinement 完了後に起票)で扱う。PR feat: Codex issue creator と editor を分離 #2027 のissue-editorcutover 完了後に着手する。 run_refinement_preflight.py内の repair_diagnostics 以外の blocker 種別(他の BLOCKER 群)の変更decide_next_loop_action.py/ rewrite loop router のロジック変更(SKILL.md へのapply_deterministic_repairの informational route 記述のみ許可し、router 実装自体は変更しない)baseline_vc_preflight.pyの変更- Issue 実装: run_refinement_preflight.py の結果に decisions フィールドを出力しSKILL.mdとのSSOT乖離を解消する #1556(
decisionsフィールド出力)・実装: issue-refinement-loop の preflight result から LOOP_STATE を生成する route wrapper を追加し CLI/schema 迷走を防ぐ #1006(LOOP_STATEroute wrapper)が扱う設計自体の変更
Acceptance Criteria
- AC1:
repair_issue_contract.pyの結果が versionedrepair_actionblock(dispositionの closed enum、集約規則)を含み、legacy record(confidence 欠落)を含むrepairs[]全要素から単一 disposition を決定している - AC2: 既知の auto-safe repair(
disposition: auto_apply_safe)が1件以上ある場合、run_refinement_preflight.pyが generic blocker を追加せずSTATUS: needs_fix/NEXT_ACTION: apply_deterministic_repairを返し、canonicalrepair_action(diagnostics・candidate body artifact・original/repaired SHA)を出力することをユニットテストで検証している - AC3: unknown kind・missing safety classification・非auto-safe repair・safe/unsafe 混在・overlapping repair・unsupported producer version のいずれかでは
STATUS: blocked/NEXT_ACTION: human_judgment_requiredになることをユニットテストで検証している - AC4: repair subprocess の non-zero・timeout・invalid JSON・
errorフィールドあり・schema mismatch・input SHA 不一致・changed: trueかつ mutating repair 0 件・artifact write/readback failure のいずれかではSTATUS: environment_failure/NEXT_ACTION: fix_environmentになることをユニットテストで検証している - AC5:
changed: falseでは既存の planner exit mapping が変更されないことをユニットテストで検証している - AC6: repair diagnostics と candidate body artifact が result schema・artifact map・compact stdout のすべてから機械的に参照でき、generic blocker の JSON 文字列内に埋め込まれていないことを検証している
- AC7: Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 で発生した「safe baseline-expect repair → generic blocker → blocked → human_judgment_required」経路を fixture 化し、修正後は
needs_fix/apply_deterministic_repairになることを end-to-end で検証している - AC8: 既存回帰テスト(
test_repair_issue_contract.py/test_refinement_preflight.py)が regression なく PASS している
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_repair_action_disposition_aggregated_from_repairs -q# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_known_safe_repair_routes_actionable_needs_fix -q# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_unknown_or_mixed_repair_requires_human_judgment -q# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_repair_process_and_artifact_failures_are_environment_failures -q# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_no_change_repair_result_keeps_existing_planner_mapping -q# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_repair_action_projected_in_result_schema_and_compact_stdout -q# AC7
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py::test_issue_2013_safe_repair_does_not_silent_pass_or_human_escalate -q# AC8
$ uv run --locked pytest .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py .claude/skills/issue-refinement-loop/scripts/tests/test_repair_issue_contract.py .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py -qAllowed Paths
- .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
- .claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py
- .claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json
- .claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json
- .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py
- .claude/skills/issue-refinement-loop/scripts/tests/test_repair_issue_contract.py
- .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py
- .claude/skills/issue-refinement-loop/SKILL.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。ただし本 Issue の In Scope が定める additive な
repair_actionフィールド追加・status: needs_fixenum 追加自体は対象外とし、それを超える非後方互換な破壊的変更(既存 consumer が読める範囲を超える変更)が必要になった場合に限る - 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合。具体的には、実際の Issue 本文 auto-mutation(controlled mutation transaction)の実装が必要と判明した場合(Out of Scope。follow-up Issue へ切り出す)、および Draft PR fix: trusted OWNER directive を contract update へ正規化 #2026(
run_refinement_preflight.pyを同時変更中)との rebase/stack 方針が実装時点で解決できないコンフリクトを起こした場合を含む - nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Required Design References
- docs/dev/agent-skill-boundaries.md
- docs/dev/runtime-verification-policy.md
Scope Delta(該当時のみ記載)
N/A
Background
本注記(Runtime Verification Applicability の
decision訂正、Issue #2013 との関係の明確化)は PR #2037 マージ後、issue-refinement-loop による post-hoc ドキュメント訂正として追加された。
.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py および run_refinement_preflight.py からの repair 呼び出し wiring は、以下の3段階の履歴で導入・拡張された。
- 原因となった wiring の導入: Issue 実装: baseline-expect VC annotation と deterministic repair pass で issue-refinement-loop 反復失敗を防ぐ #889(CLOSED)/ PR feat(#889): baseline-expect VC annotation と repair pass で baseline false-positive を防ぐ #893(MERGED)が
repair_issue_contract.py・_invoke_repair()・run_refinement_preflight.pyからの repair 呼び出し・changed: trueを generic blocker へ変換する wiring を導入した。 - 後続 producer 拡張: Issue 実装: baseline_vc_preflight.py に --strict フラグを追加し annotation 欠落 VC を強制 needs_fix にする #899 / PR impl(#899): Add --strict flag to baseline_vc_preflight.py for annotation enforcement #952(MERGED, 2026-06-17)は 実装: 自機移動と Projectile 射撃システム #1 の後続変更として、strict baseline validation・inline baseline annotation repair・missing baseline annotation repair・一部 repair record への
safety/confidenceフィールドを追加した。PR impl(#899): Add --strict flag to baseline_vc_preflight.py for annotation enforcement #952 のレビューは「needs_fix であり human_escalation ではない」ことを満たしたと判定したが、変更ファイル一覧にrun_refinement_preflight.pyは含まれておらず、producer 単体の挙動が wrapper 統合まで検証されたわけではなかった。 - 実運用での再現: Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013(2026-08-08)自体は本 Issue とは無関係な調査 Issue(Claude Code custom SubAgent の spawn observability 非決定性の診断)だが、issue-refinement-loop を Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 を対象に実行していた最中に、producer の safe repair が generic blocker に再変換され
STATUS: blocked/NEXT_ACTION: human_judgment_requiredになる経路が副次的に再現された(Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 の本文もこの repair_diagnostics の修正自体は本 Issue 実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016 で追跡済みと明記している)。
Issue #2016 は当初、_repair_result の top-level confidence フィールドを参照する条件分岐追加として起票されたが、OWNER によるアドバーサリアルレビュー(#2016 コメント、レビュー基準 SHA 01b863302053be046a167f756ea08789ca8eea44、判定 REQUEST_CHANGES)により、以下の構造的欠陥が指摘された。
- 現行
repair_issue_contract.pyのrun_repair()は top-levelconfidenceを返さず、confidenceは一部のrepairs[]要素のみが持つフィールドである(記述通りの実装は常にNoneになり成立しない) - blocker を追加しないだけでは
needs_fixではなくpass / proceedへ誤分類される(result schema にneeds_fixstatus が存在しないため) _invoke_repair()は subprocess の non-zero return code を検査せず、artifact 書き込みも例外を無条件に握りつぶす fail-open 設計であり、repair subsystem 自体の故障が silent pass になり得る- 「通常の rewrite loop で自動解消」を実現する mutation 実行経路(issue-editor handoff・stale hash guard・controlled mutation・readback)が定義されていない
- 修正に必要な schema 変更(
additionalProperties: falseへの追加)が、当初の Allowed Paths / Stop Conditions では禁止されており、Issue が自己矛盾していた
本 Issue の本文は上記レビューの「推奨する修正設計」「修正版 Acceptance Criteria 案」「Verification Commands 修正版」「必要な Allowed Paths」に基づいて全面的に書き直されている。ただし同コメントが示した2つの選択肢((a) Outcome を machine-actionable な needs_fix handoff までに縮小し実 mutation は別 Issue にする / (b) auto-resolve を維持し issue-editor handoff・controlled mutation まで In Scope に含める)のうち、1 Issue = 1 PR 原則と PR #2027(issue-editor cutover、Draft)への依存を避けるため、(a) を採用している。
なお Draft PR #2026 は同じ run_refinement_preflight.py を変更中であり、実装着手時は rebase またはスタック方針を確認すること(Stop Conditions 参照)。
参照: Issue #889, PR #893, Issue #899, PR #952, Issue #2013, PR #2026(Draft), PR #2027(Draft)
Notes for Reviewer
- disposition の closed enum(
auto_apply_safe/human_review_required/informational/invalid_payload)と集約規則の詳細(all()の空 iterable 罠を避ける実装、missing confidence の扱い等)は、実装時に OWNER レビューコメントの「推奨する修正設計」節を正本として参照する。 repair_issue_contract_result_v1.schema.jsonは現時点で未作成のため、本 Issue の実装で新規作成する(Allowed Paths に含む)。- Scope Collision (C1) advisory: overlap preflight が
.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py/tests/test_refinement_preflight.pyを Allowed Paths に含む既存 OPEN issue(修正: issue-refinement-loop で trusted OWNER directive を重複承認なしに contract update へ正規化する #1951, 実装: 両review loopの人間向けGitHub作業履歴をphase-awareに整理し推奨理由を記録する #1908, 実装: run_refinement_preflight.py の結果に decisions フィールドを出力しSKILL.mdとのSSOT乖離を解消する #1556, 実装: fix(issue-refinement-loop): no-human-approval autonomy mode を loop state routing に明示する #1007, 実装: issue-refinement-loop の preflight result から LOOP_STATE を生成する route wrapper を追加し CLI/schema 迷走を防ぐ #1006, feat(agent-ops): issue-contract-fixer SubAgent を追加し、LLM rewrite 前に deterministic contract repair を完了させる #998, feat(issue-refinement-loop): LOOP_ITERATION_CAPSULE_V1 を導入し、raw body / raw log の main context 流入を禁止する #997, 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995, 実装: issue-refinement-loop の rewrite routing が既存 blocker contract を consume して non-body-author-fixable blocker を早期停止できるようにする #944, test: scope_signal_guard termination の publisher-level 回帰テストを追加する #926)および Draft PR fix: trusted OWNER directive を contract update へ正規化 #2026 / feat: Codex issue creator と editor を分離 #2027 を検出した。いずれも本 Issue が扱う repair_action disposition ベースの routing とは異なる関心事(decisions フィールド出力、autonomy mode、rewrite routing、issue-editor cutover 等)であり exact dedupe ではないが、run_refinement_preflight.pyへの並行変更が集中しているため、実装着手時は PR fix: trusted OWNER directive を contract update へ正規化 #2026 のマージ状況を必ず確認しコンフリクトを避けること。
Activity
squne121 commentedon Aug 8, 2026
判定
REQUEST_CHANGES — 現在の Issue 契約のまま実装へ進めるべきではありません。
問題自体は実在します。現在の
run_refinement_preflight.pyは、repair がchanged: trueを返すとrepair_diagnosticsを generic blocker に追加し、最終的にSTATUS: blocked/NEXT_ACTION: human_judgment_requiredへ変換します。Issue #2013 でもこの経路が実際に再現されています。一方、Issue #2016 が要求している「top-level の
repair_result.confidenceを見て high なら blocker にしない」という修正は、現行 producer 契約に存在しないフィールドを前提としており、さらに blocker を消すだけではneeds_fixではなくpass / proceedに誤分類される設計です。レビュー基準は 2026年8月8日時点の
main、SHA01b863302053be046a167f756ea08789ca8eea44です。敵対的レビュー
P0-1: Issue が要求する top-level
confidenceは producer に存在しないIssue #2016 の AC1 と In Scope は、
_repair_resultのconfidenceフィールドを直接参照することを要求しています。しかし、現行
repair_issue_contract.pyのrun_repair()が返す top-level payload は次だけです。schemadry_runchangedoriginal_body_sha256repaired_body_sha256repairstop-level の
confidenceやkindはありません。confidence: highがあるのは一部のrepairs[]要素だけです。具体的には、後から追加された以下の repair record にはあります。move_inline_baseline_expect_to_preceding_lineinsert_baseline_expect_fail対して、以下の既存 kind は
confidenceを持ちません。runtime_only_commandescaped_code_fencenon_target_fenceしたがって、例えば次の実装は成立しません。
常に
Noneになるためです。また
repairs[]の全要素を走査する実装に変えても、legacy record の missing confidence、informational record、複数 kind 混在時の集約規則が定義されていません。修正要求: producer 契約を変更対象に含めるか、consumer 側に versioned な closed allowlist と集約規則を定義してください。現在の Allowed Paths では producer を変更できないため、この時点で Issue 自身の Stop Condition に到達します。
P0-2: blocker を追加しないだけでは
needs_fixにならず、silentpassになる現行 preflight result の
statusenum は次の4種類だけです。needs_fixは存在しません。さらに schema はadditionalProperties: falseです。現在の
_apply_exit_code_mapping()は、概ね次のように動きます。blocker なし
→ pass
その後の
next_actionは次の固定マッピングです。つまり Issue #2016 の記述通りに high-confidence repair を
blockersへ追加しないだけでは、となります。
これは
needs_fixではなく、未修復の Issue 本文をそのまま次工程へ流す false pass です。さらに
repair_diagnostics.jsonのパスは現在 generic blocker の JSON 文字列にしか格納されていません。blocker を消すと、canonical result や compact stdout から repair artifact を発見する経路も消えます。canonicalartifactsmap に許可されているのは raw snapshot、planner input、preflight result の3種類だけです。修正要求: 「blocker を追加しない」ではなく、schema-backed な repair route を新設する必要があります。
P0-3: repair subprocess と artifact 書き込みが fail-open
現行
_invoke_repair()はsubprocess.run()のreturncodeを確認しません。check=Trueを指定していないproc.returncodeを評価しないsubprocess が non-zero でも stdout が JSON ならそのまま正常 payload として返す
JSON decode error、timeout、その他例外は
changed: falseを含む error payload に変換するPython の公式仕様上、
subprocess.run()のcheckは既定でFalseです。non-zero を失敗として扱うには、check=True、returncodeの検査、またはcheck_returncode()が必要です。現在の wrapper は
_repair_result.get("changed") is Trueの場合しか反応しないため、次の失敗が repair なしの正常状態として通過し得ます。repair subprocess の non-zero
error JSON
stdout 不在
invalid JSON
timeout
producer schema drift
input body hash 不一致
加えて artifact 書き込みは直接
write_text()を行い、例外を無条件に握りつぶします。artifact 書き込みが失敗した場合は
repair_artifact_pathがNoneのため、changed: trueであっても blocker が追加されません。これは今回の修正対象より深刻です。安全な repair を human escalation へ送る false positive と同時に、repair subsystem 自体の故障を pass にする false negative が存在します。
修正要求: 以下はすべて
environment_failure / fix_environmentにしてください。non-zero return code
timeout
invalid JSON
schema mismatch
errorフィールドありinput SHA 不一致
changed: trueなのに mutating repair が0件artifact write/readback failure
candidate body hash 不整合
artifact は既存の
_atomic_write_json()と readback validation を再利用すべきです。P0-4: 「通常の rewrite loop で自動解消」の実行経路が存在しない
Issue #2016 の Outcome は、safe repair を
needs_fixとして body-author-fix rewrite loop へ流し、自動解消可能にすることを要求しています。しかし現在の producer は、修復後本文そのものを返しません。返すのは hashes と局所的な repair records だけです。
また wrapper は dry-run repair を呼び出すだけで、
repaired body を planner に渡さない
candidate body artifact を保存しない
mutation command を結果に出さない
issue editor への handoff を生成しない
GitHub readback を検証しない
という状態です。PR #893 の導入説明も、「repair は dry-run であり、planner は元の Issue 本文を受け取る」という構造です。
したがって
needs_fixシグナルを追加しても、誰が、何を入力として、どの controlled executor で本文を更新するかが未定義です。現在、既存 Issue 更新担当を
issue-editorに切り替える PR #2027 が Draft で進行中です。#2016 の auto-apply lane は、この topology と整合させる必要があります。修正要求: 次のどちらかを選ぶ必要があります。
実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016 の Outcome を「machine-actionable な
needs_fixhandoff を出す」までに縮小し、実 mutation は別 Issue にする。auto-resolve を維持するなら、issue-editor handoff、stale hash guard、controlled mutation、readback、fresh preflight まで 実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016 の In Scope に含める。
現在の契約は「自動解消」を主張しながら、その実装箇所をすべて Out of Scope にしています。
P1-1: 原因導入 PR と後続拡張 PR を混同している
Issue #2016 の Background は「Issue #889 / PR #952 が
repair_issue_contract.py等を導入した」と読める記述ですが、履歴は次の通りです。原因となった wiring の導入
PR #893 が Issue #889 を閉じ、以下を導入しました。
repair_issue_contract.py_invoke_repair()run_refinement_preflight.pyからの repair 呼び出しchanged: trueを generic blocker へ変換する wiring後続 producer 拡張
PR #952 は Issue #899 を閉じた後続変更です。
strict baseline validation
inline baseline annotation repair
missing baseline annotation repair
一部 repair record への
safety/confidence正しい因果関係は次です。
PR #952 のレビューは「needs_fix not human_escalation」を満たしたと判定しましたが、変更ファイル一覧に
run_refinement_preflight.pyは含まれていません。producer 単体の挙動を wrapper integration まで検証したと誤認した integration false-green です。修正要求: Background と regression fixture をこの3段階の履歴に修正してください。
P1-2: Acceptance Criteria と Verification Commands が false-green/hard-block を含む
AC1 は実装前から通る
AC1 のコマンドは次です。
しかし現行 wrapper には、planner decision 用の
_has_unknown_confidence()が既にあります。repair routing を一切変更しなくてもrgは成功します。したがって AC1 は false-green です。
AC2・AC3 は禁止されている pytest baseline 形
Issue は既存ファイルに対して未実装テスト名を
-kで選択しています。リポジトリの現行 body-authoring policy は、既存テストファイルへの未作成
-kを禁止しています。canonical baseline-fail は、Allowed Paths 内の まだ存在しない新規テストファイル + exact node-id です。pytest 公式仕様でも
-kは収集済みテストを名前式で選択する機能であり、テストの存在証明ではありません。テストが収集されなければ exit code 5 です。_apply_exit_code_mapping()単体では今回の AC を検証できない今回必要なのは次の一連の挙動です。
_apply_exit_code_mapping()に空の blockers を渡してblockedでないことだけを確認しても、repair signal が消失してpassになった false-greenを検出できません。修正要求: 新規 integration test file を作り、
run_preflight()から artifact と compact output まで検証してください。P1-3: 正しい修正に必要な schema 変更を Allowed Paths と Stop Conditions が禁止している
現在の result schema は
additionalProperties: falseです。未宣言のrepair_action、repair_diagnostics、needs_fixなどを追加すれば schema validation に失敗します。JSON Schema の公式仕様でも、
additionalProperties: falseはpropertiesまたはpatternPropertiesに宣言されていないプロパティを拒否します。一方、Issue #2016 の Allowed Paths は wrapper と既存 test file の2つだけで、schema 変更は Stop Condition です。
したがって正しい実装には schema 変更が必要なのに、契約上は schema 変更が判明した時点で停止しなければなりません。
これは単なる不足ではなく、Issue が自分自身を実装不能にしている構造的矛盾です。
P1-4:
confidenceを authorization として使う設計が弱いconfidence: highは診断メタデータであり、「自動 mutation を許可してよい」という authorization と同義ではありません。少なくとも以下を閉じた契約として定義する必要があります。
auto-apply を許可する repair kind の closed enum
informational kind
human-review-required kind
unknown kind の扱い
missing confidence の扱い
safe と unsafe が混在した場合
changed: true, repairs: []changed: falseなのに mutating record がある場合duplicate/overlapping repair
producer schema version 不一致
candidate hash 不一致
特に次のような判定は危険です。
Python の
all()は iterable が空でもTrueを返すため、repairs=[]を safe と誤判定し得ます。推奨:
confidenceとは別に、producer または versioned classifier が次のような明示的 disposition を出すべきです。未知 kind が自己申告で
confidence: highを返しても auto-apply してはいけません。P1-5: 現在進行中の変更との sequencing が未定義
PR #2026 は Draft・open で、同じ
run_refinement_preflight.pyを変更しています。単なる rebase 競合だけでなく、preflight provenance と routing semantics を変更するため、#2016 はその上へ stack するか、マージ後に再設計する必要があります。また、隣接する open Issue として以下があります。
実装: run_refinement_preflight.py の結果に decisions フィールドを出力しSKILL.mdとのSSOT乖離を解消する #1556: preflight result への
decisions出力実装: issue-refinement-loop の preflight result から LOOP_STATE を生成する route wrapper を追加し CLI/schema 迷走を防ぐ #1006: preflight result から actionable
LOOP_STATEを作る route wrapperこれらは duplicate ではありませんが、result schema と downstream consumer の所有境界が重なります。#2016 だけが独自の非構造化 repair route を追加すると、再び SSOT が分裂します。
さらに PR #2026 と #2027 の Safety Claim Matrix では、repair routing と直接関係しない claim の follow-up に
#2016が記載されています。#2016 を generic な「後で安全性を直す Issue」として参照しており、related graph を汚染しています。推奨する修正設計
1.
confidenceではなく versioned repair disposition を正本にする推奨 payload は以下です。
repair_actionは canonical result と compact stdout の両方に投影し、artifact path は generic blocker 文字列の内部に埋め込まないでください。JSON Schema の
if/thenを使えば、disposition: auto_apply_safeの場合に candidate body、両 SHA、repair kinds を必須化できます。公式仕様上、ifの評価結果でthenまたはelseの subschema を適用できます。2. wrapper-level
needs_fixroute を明示する推奨する判定表は次です。
最も明確なのは、result schema に
status: needs_fixを追加することです。互換性のため一時的に
warnを再利用する案もありますが、現行warnはproceed_with_notesなので、consumer 更新なしでは未修復本文を次工程へ送ります。単にwarnに畳み込む修正は推奨しません。3. auto-apply は optimistic concurrency 付き transaction にする
自動更新を Outcome に残す場合、処理は次の順序でなければなりません。
live Issue body を再取得する。
original_body_sha256が dry-run 時点と一致することを検証する。current body に対して repair を再実行する。
full candidate body を生成する。
controlled
issue-editortransaction で更新する。GitHub readback body hash を検証する。
fresh preflight を再実行する。
changed: falseになったことを確認してから semantic refinement へ戻る。line number ベースで局所 patch を当てるべきではありません。producer の line number は section-relative なものを含み、同時編集にも弱いためです。
修正版 Acceptance Criteria 案
AC1: producer 契約
repair_issue_contractの結果が versioned schema で検証され、repair ごとに closed enum の disposition または classifier が確定する。AC2: safe deterministic route
既知の auto-safe repair が1件以上ある場合、
generic blocker を追加しない
status: needs_fixnext_action: apply_deterministic_repaircanonical
repair_actiondiagnostics と candidate body artifact
original/repaired SHA
が出力される。
AC3: unsafe/unknown route
以下のいずれかでは
blocked / human_judgment_requiredになる。unknown kind
missing safety classification
non-auto-safe repair
safe/unsafe mixed
overlapping repair
unsupported producer version
AC4: environment failure route
以下のいずれかでは
environment_failure / fix_environmentになる。subprocess non-zero
timeout
invalid JSON
payload
errorschema mismatch
input SHA mismatch
changed: trueかつ mutating repair 0件artifact write/readback failure
AC5: no-change regression
changed: falseでは、現在の planner exit mapping が変更されない。AC6: canonical artifact projection
repair diagnostics と candidate body が result schema、artifact map、compact stdout のすべてから機械的に参照できる。
AC7: Issue #2013 integration fixture
Issue #2013 で発生した
を fixture 化し、修正後は
needs_fix / apply_deterministic_repairになることを end-to-end で検証する。実際の dead-end は Issue #2013 のコメントでも記録されています。AC8: controlled mutation
auto-apply を本 Issue に含める場合、stale hash 拒否、controlled issue-editor、readback、fresh preflight をテストする。
AC9: integration regression
producer 単体だけでなく、wrapper、schema、compact output、downstream decision consumer の回帰テストを通す。
Verification Commands 修正版
新しい test file を Allowed Paths に追加し、baseline では存在しない exact node-id を使用します。
必要な Allowed Paths
最低でも次を含める必要があります。
status: needs_fixまたはnext_action: apply_deterministic_repairを downstream が consume するなら、さらに次が必要です。auto-mutation まで含める場合は、#2027 の
issue-editortopology に対応する controlled transaction とテストも scope に追加する必要があります。実装順序
Issue 実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016 の Background、Outcome、AC、Allowed Paths、Stop Conditions を修正する。
同一ファイルを変更している Draft PR fix: trusted OWNER directive を contract update へ正規化 #2026 のマージまたは stack 方針を確定する。
auto-apply を含める場合は PR feat: Codex issue creator と editor を分離 #2027 の issue-editor cutover と整合させる。
producer schema、wrapper route、result schema、consumer を同じ contract snapshot に束縛する。
Issue 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 型の integration fixture を先に追加してから実装修正する。
PR impl(#899): Add --strict flag to baseline_vc_preflight.py for annotation enforcement #952 で不足していた producer-to-wrapper integration を merge blocker にする。
最終結論
Issue #2016 は close や duplicate 判定ではなく、契約を書き直して維持すべきです。
ただし現状のまま実装すると、主に次のどちらかになります。
confidenceが取得できず、従来通り human escalation する。blocker だけを消し、未修復 Issue を
pass / proceedへ流す。後者は現在の問題より危険です。修正の本体は confidence 条件分岐ではなく、repair producer → wrapper → result schema → next-action consumer → controlled mutation の end-to-end routing contract です。
squne121 commentedon Aug 8, 2026
issue-refinement-loop 終了報告
経緯
VERDICT: needs-fix(4 blockers: Runtime Verification Applicability セクション欠落 / AC1 VC unexpected pass / AC2・AC3 が未作成テストへの-k参照)confidencetop-level 参照を廃し、versionedrepair_action(disposition closed enum・集約規則)ベースの設計へ変更。Outcome を「machine-actionable なneeds_fixhandoff を出す」までに縮小し、実際の Issue 本文 auto-mutation は別 follow-up Issue に切り出した(OWNER レビューが提示した2択のうち (a) を採用)。AC1〜AC8・Verification Commands・Allowed Paths・Stop Conditions・Background の3段階履歴(実装: baseline-expect VC annotation と deterministic repair pass で issue-refinement-loop 反復失敗を防ぐ #889/PR#893 → 実装: baseline_vc_preflight.py に --strict フラグを追加し annotation 欠落 VC を強制 needs_fix にする #899/PR#952 → 調査: Claude Code custom SubAgent の spawn observability 非決定性を診断する #2013 再現)・Runtime Verification Applicability セクションを追加。VERDICT: approve(C1〜C11 全 pass、blockers 0)Final Gate
issue-contract-reviewは本 loop 内では未実行(CONTRACT_REVIEW_RESULT_V1の go snapshot が Issue 上に存在しない)。contract_review.gate_result: missing_goのためLOOP_HANDOFF_RESULT_V1.statusはblockedとする。実装着手前にissue-contract-reviewを別途実行すること。squne121 commentedon Aug 8, 2026
implement-issue: 実装完了 (2026-08-08T09:27:00Z)
.claude/worktrees/issue-2016-repair-disposition-routingworktree-issue-2016-repair-disposition-routingfix: OWNER adversarial review iteration-3 P0/P1 対応(PR #2037)
fix: Issue #2013 fixture を Allowed Paths 内へインライン化する(PR #2037 review b…
squne121 commentedon Aug 8, 2026
issue-refinement-loop: 完了 (2026-08-08)
VERDICT: approve(1 iteration)
PR #2037 マージ後の post-hoc ドキュメント訂正として、以下 2点の事実誤りを修正しました。
reasonを、マージ済み実装が実際にsubprocess.run()(_run_repair_subprocess())と実ファイル I/O(secure_atomic_write_candidate()のos.open/fsync/os.replace)を伴う事実に基づく記述へ訂正(decisionは AC タグ付与を伴うapplicable/immediateへの変更を避けるためnot_applicableを維持し、pytest による検証カバレッジで担保している旨を明記)AC/VC/Allowed Paths/Outcome/Scope/Machine-Readable Contract は無変更。Issue は CLOSED のまま。
sha256:a5c48e731c443a9ff7b23cd7acc192a762a2ad052d33e45e4e879342c7d06951sha256:916f282f11e7f7080b1fdbe584ef8b13c10e8c044d9fd07c8ab3009ad350f5b5STATUS: approve
NEXT_ACTION: none(追加対応不要)