Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "template-required section gapsを一回で完全列挙し、安全に一意導出できる項目だけをevidence-bound repair_actionとして生成する"
change_kind: code
depends_on:
- issue: 2016
pr: 2037
state: merged
- issue: 2039
role: opaque_controlled_consumer_interface
producer_policy_owner: .claude/skills/issue-refinement-loop/scripts/repair_issue_contract.pyParent Issue
none
Parent Goal Ref
- Goal: standalone の issue-refinement-loop producer として、resolved implementation template の required field 欠落を安全かつ決定的に分類し、evidence-bound proposal を生成する。
- Desired Destination: N/A — delivery parent を持たない単独改善。実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160 は delivery parent ではなく、この不足を露呈させた source incident / background reference である。
Current Validated Scope
.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.pyを structural-repair の detector、classifier、proposal producer の policy owner として拡張する。- resolved template から field id、label、required、value、field order、template path、template digest/blob identity を取得し、issue_kind ごとの authoring SSOT から required contract key を解決する。
- CommonMark の H2 heading と fenced-code block を parse して、required section / contract key の欠落、duplicate、empty、placeholder-only、曖昧な cardinality と insertion anchor を判定する。
- versioned structural-repair provenance と policy-version の additive schema migration を、指定した issue-refinement-loop schema と producer tests の範囲で行う。
- 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 が proposal を opaque に読めることだけを interface compatibility test で確認する。実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 の production path は GitHub mutation を実行しない。
Remaining Parent Gaps
なし。#2039 は別責務として GitHub mutation、stale consumer orchestration、authoritative readback、unknown outcome、post-dispatch retry 禁止、fresh validation、controlled transaction E2E を所有する。これらの実装・実証は #995 の完了条件ではない。
Outcome
resolved implementation template の required field と issue_kind 別 authoring SSOT の required contract key を、field id、label、required、value、field order、template path、digest/blob identity とともに読み取る。heading set membership だけで required field の存在を判定してはならない。
一回の producer run は、すべての不足 section / contract key を template field order、次いで field id の deterministic order で列挙し、一つの versioned handoff bundle に束ねる。bundle 内の各 item は issue/body identity、target field、cardinality、template、provenance、derivation、candidate digest と insertion decision を持つ。item ごとの自由な複数 dispatch は行わない。
自動提案の derivation mode は次の closed enum だけである。
template_value_exact: resolved template のattributes.valueが non-empty の実値であり、placeholder ではなく、field id が auto-safe allowlist にあり、template path と immutable blob/digest に束縛される場合だけ、その value を byte-exact に挿入する。template description、placeholder、validations.required単独から prose を生成しない。source_span_exact: parent、canonical owner anchor、又は design reference のうち単一 authoritative source に exact source span があり、source URL/ref、line/span、text digest を記録し、内容を byte-exact に挿入できる場合だけ用いる。複数 source が異なる内容を示す場合、又は authority が競合する場合は用いない。derived_scalar_exact: validated parent number、template field order に基づく単一 label 等、構文的に一意な scalar だけを生成する。prose、要約、解釈は生成しない。
各 proposal は field id、rendered label、required、template field order、template path、template digest/blob identity、source span/digest、derivation mode、insertion anchor、repo、issue number、original body SHA-256、original updatedAt、issue/body identity、candidate content digest を記録する。expected / observed cardinality と empty / placeholder-only / duplicate の観測も記録する。
semantic free-form prose、placeholder-only value、multiple-source conflict、authority conflict、scope/product/policy judgment、duplicate heading、empty section、ambiguous cardinality、ambiguous insertion anchor、又は Outcome / Scope / Acceptance Criteria / Verification Commands / Allowed Paths 等に exact source がない場合は、必ず human_review_required とする。安全な item と unsafe item が混在しても、全不足項目とその reason を一つの human-review handoff に束ね、silent omission も semantic completion も行わない。
#995 は template-derived structural repair の detector / classifier / proposal producer のみを所有する。#2039 は consumer-side GitHub mutation、stale handling、authoritative readback、unknown outcome、post-dispatch retry policy、fresh validation、controlled transaction E2E を所有する。#995 の統合は opaque schema/interface compatibility までであり、production GitHub mutation 又は readback を AC、scope、RVA の成功主張に含めない。
#950 の historical body、body SHA、updatedAt、template blob 等の immutable evidence を真正に復元できない限り、回帰 fixture は synthetic_issue_950_shape と明記する。その fixture は #950 の実 intermediate state の再現を主張しない。
Runtime Verification Applicability
decision: not_applicable
applicable_acs: []
reason: >
本 Issue は mutation-free な Python structural classifier / proposal producer、
deterministic text transformation、JSON Schema validation のみを扱う。
GitHub mutation と authoritative GitHub readback、unknown outcome、fresh validation、
controlled transaction E2E は #2039 の scope である。simulation readback は
authoritative GitHub readback ではなく、本 Issue の runtime PASS として扱わない。In Scope
- template field の id / label / required / value / order / path / immutable digest/blob identity の抽出
- issue_kind 別 authoring SSOT による required contract key 解決
- required section / contract key の全件 batch detection と deterministic ordering
- heading set membership 単独を使わない duplicate / empty / placeholder-only / cardinality / fence-aware insertion-anchor 判定
- closed derivation mode による evidence-bounded structural repair classification と一つの proposal / human-review handoff bundle の生成
- structural-repair provenance schema と policy-version の明示承認済み additive migration、および schema validation
- 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 の opaque input schema/interface compatibility test
synthetic_issue_950_shapeと明記した fixture
Out of Scope
- GitHub Issue mutation、authoritative GitHub readback、controlled transaction dispatch
- stale consumer orchestration、unknown outcome 解決、post-dispatch retry、fresh preflight / review / readiness
- semantic free-form prose の生成、LLM による補完、parent / scope / product / policy / authority の自動判断
- 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 の consumer classification / policy の変更、又は consumer E2E を 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 の成功として主張すること
- 新規 global ledger、publisher、security boundary、Issue / comment 作成、native relationship mutation、raw GitHub mutation
Acceptance Criteria
- AC1: resolved template の required item が field id、label、required、value、field order、template path、immutable digest/blob identity とともに取得され、issue_kind ごとの authoring SSOT から required contract key が解決される。
- AC2: 一回の producer run がすべての不足 required section / contract key を template field order、次いで field id の deterministic order で列挙し、一つの handoff bundle に束ねる。heading set membership 単独は存在判定に使わない。
- AC3: exact source のない semantic field、
validations.required単独、template placeholder-only value、又は prose の要約・解釈が必要な field はhuman_review_requiredとなり、auto-safe prose を生成しない。 - AC4:
template_value_exact、source_span_exact、derived_scalar_exactの closed enum と各 mode の authority、provenance digest、byte-exact insertion 条件を満たす item だけがauto_apply_safeとなる。 - AC5: duplicate heading、empty / placeholder-only section、multiple-source conflict、authority conflict、ambiguous cardinality、template order conflict、又は ambiguous insertion anchor は
human_review_requiredとなり、全不足 item を同一 handoff に残す。 - AC6: repair proposal の template / source / target / insertion / issue-body provenance と additive policy-version migration が
repair_issue_contract_result_v1およびrefinement_preflight_result_v1schema validation を通過する。 - AC7: 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 の production producer path は GitHub mutation、authoritative readback、controlled transaction dispatch を呼び出さず、これらを成功条件に含めない。
- AC8: 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 compatibility test は versioned opaque repair action / handoff の schema-interface readability だけを検証し、consumer classification、transaction、GitHub mutation、authoritative readback、fresh validation の成功を主張しない。
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_required_fields_include_id_value_order_and_template_digest -q
# AC2
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_all_missing_required_fields_are_reported_in_one_batch -q
# AC3
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_semantic_field_without_exact_source_requires_human_review -q
# AC4
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_exact_template_value_can_be_auto_apply_safe -q
# AC5
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_duplicate_heading_or_conflicting_sources_are_ambiguous -q
# AC6
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_structural_repair_provenance_validates_against_schema -q
# AC7
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_producer_path_does_not_invoke_github_mutation -q
# AC8
# baseline-expect: fail
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py::test_2039_opaque_action_compatibility_does_not_claim_transaction -q
# Aggregate producer regression
$ uv run --locked pytest -p no:cacheprovider .claude/skills/issue-refinement-loop/tests/test_template_section_repair.py .claude/skills/issue-refinement-loop/tests/test_repair_diagnostics_routing.py .claude/skills/issue-refinement-loop/tests/test_plan_refinement_loop.py .claude/skills/issue-refinement-loop/tests/test_refinement_preflight.py -q
# Repository gates
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pyAllowed Paths
.claude/skills/issue-refinement-loop/scripts/plan_refinement_loop.py.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.json.claude/skills/issue-refinement-loop/tests/test_template_section_repair.py.claude/skills/issue-refinement-loop/tests/**.claude/skills/issue-contract-review/scripts/contract_readiness_check.py.claude/skills/issue-contract-review/scripts/run_contract_review_once.py.claude/skills/issue-contract-review/scripts/tests/**.claude/skills/issue-refinement-loop/SKILL.md
#2039 の generic consumer implementation は Allowed Paths 外であり、本 Issue はその production mutation / readback contract を変更しない。
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合。ただし、本 Issue で明示承認した structural-repair provenance schema と policy-version の additive migration は停止条件から除外する。
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。ただし、前項で明示した additive migration は除く。
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)。
- 後続 Phase / 別スコープへの波及が判明した場合。
- nested SubAgent delegation が必要になった場合。
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合。
- additive ではない incompatible / breaking schema migration、既存 consumer の互換性を壊す変更、又は 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 の consumer classification / policy 変更が必要になった場合。
- closed derivation enum 外の mode、semantic prose の生成、又は evidence に基づかない field content が必要になった場合。
- source / authority conflict、duplicate / empty / placeholder-only section、ambiguous cardinality / insertion anchor、又は exact source のない Outcome / Scope / AC / VC / Allowed Paths 等を auto-safe に扱う必要が生じた場合。
- GitHub mutation、authoritative readback、stale consumer orchestration、unknown outcome、post-dispatch retry、fresh validation、controlled transaction E2E を 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 の実装又は成功条件に含める必要が生じた場合。これらは 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 へ routing する。
- Issue comment、native relationship mutation、raw GitHub mutation、global ledger / publisher / security boundary が必要になった場合。
Required Skills
- Python と deterministic text transformation
- JSON Schema Draft 2020-12 と backward-compatible additive schema evolution
- CommonMark heading / fenced-code parsing と byte-exact source provenance
- SHA-256 digest、immutable blob identity、deterministic ordering の設計
Required Design References
.github/ISSUE_TEMPLATE/implementation.yml— issue_kind 別 authoring SSOT と template field metadata.claude/skills/create-issue/references/body-authoring.md— implementation issue の required contract key SSOT.claude/skills/issue-refinement-loop/scripts/repair_issue_contract.py— structural-repair producer policy owner.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.jsondocs/dev/agent-skill-boundaries.md— 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 controlled consumer boundary- 実装: repair_diagnostics blocker が confidence: high の deterministic repair でも human_escalation を発火させる問題を修正する #2016 / PR 実装: repair_diagnostics blocker が deterministic な safe repair でも human_escalation する問題を修正する #2037 — deterministic repair producer precedent
- 実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 — controlled consumer / transaction / readback ownership
- 実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160 — source incident/background reference only; not a delivery parent
Activity
fix(agents): issue-author に readiness_forwarding_payload の消費契約を復元する
squne121 commentedon Aug 16, 2026
判定
REQUEST_CHANGES — 現状の #995 は実装着手不可です。
解決対象そのものは実在します。#2016 / PR #2037 は deterministic repair の producer までを実装し、実際の Issue mutation は後続 consumer に明示的に切り出しました。#995 が「不足セクションを一度に分類し、不要な human escalation を減らす」方向へ進むこと自体は妥当です。
しかし現在の契約には、AC を正しく実装すると Allowed Paths/Stop Conditions に違反し、Allowed Paths/Stop Conditionsを守ると AC を達成できないという内部矛盾があります。さらに、未実装かつ設計基準が古い #2039 の責務を #995 の AC に取り込み、producer と consumer の所有境界が崩れています。#995 自体には補足コメントがなく、2026年8月15日の本文だけが現行の authority です。
P0 — 実装をブロックする問題
P0-1. AC2 は schema migration なしでは実装不能だが、schema は Allowed Paths 外
AC2 は、すべての structural proposal に対して以下を記録するよう要求しています。
一方、現行
repair_issue_contract_result_v1.schema.jsonはadditionalProperties: falseで、repairs[]とrepair_actionのキー集合を閉じています。現在の repair record にはkind、行範囲、reason、original/repaired、safety/confidence 程度しかなく、template ID、template digest、source span、derivation mode、insertion anchor などを格納できません。refinement_preflight_result_v1.schema.jsonも strict schema であり、repair_actionは現行repair_action/v1/deterministic-issue-repair/v1の固定 projection です。AC2 が求める provenance を新規フィールドとして追加すると schema validation に失敗します。ところが #995 の Allowed Paths に schema ファイルは含まれず、Stop Conditions は固定キー集合・schema・型定義の変更が必要になった場合に停止するよう要求しています。
したがって現状は、次のどちらかにしかなりません。
必須修正
Allowed Paths に最低限、次を追加してください。
Stop Conditions は次のように限定する必要があります。
また、repair kind の追加だけでは不足します。現在
auto_apply_safeになり得る mutating kind は二種類に閉じられており、未知の kind はhuman_review_requiredへ落ちます。template-section repair を自動適用対象にするなら、repair policy の更新と compatibility decision が必要です。P0-2. #995 は producer-only を名乗りながら、未実装 consumer の完了条件まで所有している
#995 の本文は、generic consumer implementation は #2039 に残し、#995 の Allowed Paths には含めないと明記しています。その一方で AC5・AC6 は、次の consumer 動作まで #995 の完了条件にしています。
これらは既に #2039 の主責務です。#2039 は exactly-one arbiter、stale 時の producer 再実行、unknown outcome、readback、fresh validation、secure artifact read まで詳細に所有しています。
しかも #2039 は現在も OPEN で、設計基準は
reviewed_main_sha: 11ed12ec…です。現在の main はacb422b5…まで進んでいます。つまり、#2039 は実装済み dependency ではなく、current main に対する再検証が必要な未完了 consumer です。この状態では #995 の PR 単体で AC5/AC6 を達成できません。consumer の mock を使って PASS させても、「#2039 の実 consumer が動く」ことの証明にはなりません。
推奨する責務分割
#995 から現在の AC5 を削除し、AC6 は「producer output の schema/interface test」に縮小してください。full-loop verification は #2039 へ deferred にすべきです。
P0-3.
validations.requiredは意味内容を一意に導出する規則ではないGitHub Issue Forms の
validations.requiredは、その入力欄を空のまま submit できないようにするフォーム検証です。valueは pre-filled content、idはフォーム要素の識別子です。required であること自体は、既存 Issue 本文へ何を補うべきかを定義しません。 ([GitHub Docs]1)現行 planner が template から取得しているのは、実質的に次だけです。
その後、body の H2 heading set と exact match して、見出しがないかを判定しています。template の
id、value、description、placeholder、field order、template blob digest は保持していません。実際の implementation template では、次のような意味判断を伴う自由記述欄が required です。
これらは、見出しが不足しているという事実だけから自動生成できません。template の placeholder や説明文を本文として挿入するのも誤りです。
一意導出の許可条件を closed enum にすべき
推奨する derivation mode は次の三種類だけです。
template_value_exactattributes.valueがあるsource_span_exactderived_scalar_exact次は常に
human_review_requiredとすべきです。AI に内容を考えさせることを「structural repair」と呼んではいけません。自動化すべきなのは、不足項目を一度に全件列挙し、一回の issue-editor handoff に束ねることです。
P0-4. #995 自身の Machine-Readable Contract が implementation template 契約を満たしていない
#995 の contract block には
goal_refがありません。implementation/research の required contract key は、authoring SSOT 上では以下です。ところが現在の planner の
REQUIRED_CONTRACT_KEYSはcontract_schema_versionとissue_kindの二つだけです。つまり、template/authoring SSOT 上は不完全な #995 自身が、planner では通過し得ます。これは #995 が直そうとしている問題と同型です。さらに
parent_issue: "2160"は意味的に不適切です。#2160 は Claude native/claude-gpt の runtime portability contract を扱う Phase 2 implementation Issue であり、issue-refinement-loop の structural repair tooling の親ではありません。#2160 が不具合を露呈させた対象だったとしても、それは source incident であって parent-child delivery relation ではありません。修正案
#2160 は
Backgroundの incident reference に移してください。また、required contract key はグローバルな二項目リストではなく、
issue_kindごとの SSOT から解決する必要があります。P1 — マージ前に解消すべき問題
P1-1. Runtime Verification Applicability が実際の検証内容と一致していない
#995 は
decision: immediateとし、AC5/AC6 について GitHub readback artifact を要求しています。一方、execution environment は isolated fixture と controlled transaction simulation に限定され、production Issue の編集を禁止しています。simulation の readback は、GitHub の authoritative readback ではありません。ここで AC5 を PASS にすると、mock transaction の成功を実 remote transaction の成功へ昇格させることになります。
producer-only に縮小する場合は、次が適切です。
full loop を残すなら
deferredにしてください。authoring SSOT も、
deferredでは destination と verification condition の両方を要求しています。P1-2. Verification Commands が AC の判定器になっていない
現在は AC1〜AC7 を一つの aggregate pytest command にまとめています。
問題は次の通りです。
専用ファイルを新設し、AC ごとに node ID を固定してください。
その後に aggregate regression と repository gate を置く構造が適切です。
P1-3. #950 の「初回 rewrite 失敗」を再現する immutable evidence がない
現在の #950 は必要な section を備えた状態で CLOSED/COMPLETED です。現行本文だけを見ても、「最初に AC/VC/Allowed Paths だけを追加した」という中間状態は復元できません。
#950 のレビューコメントには、初期契約が薄く、追加 section が必要だったという記録があります。ただし、それは review prose であり、planner input/body SHA/template SHA/planner output を束縛した regression fixture ではありません。
#995 の Background を正式な回帰根拠にするなら、fixture に最低限次を保存すべきです。
historical body を取得できない場合は、fixture を
synthetic_issue_950_shapeと明記し、「#950 の実 intermediate state を証明する」という主張を削除してください。P1-4. heading の存在判定だけでは duplicate・順序・挿入位置を安全に扱えない
現在の canonical section extractor は fence-aware で、通常の H2 heading を処理します。しかし結果を heading title を key とする辞書へ格納するため、同名 heading が複数ある場合は前の section が上書きされます。missing detector も最終的には heading の set membership だけを見ています。
したがって次を区別できません。
## Outcomeが二つある## Allowed Pathsの前後 anchor が曖昧auto-safe proposal には最低限、次が必要です。
同名 heading が複数存在する場合、section order が template と矛盾する場合、predecessor/successor が一意でない場合は
human_review_requiredにしてください。P1-5. stale guard を「原子的 CAS」と表現してはいけない
GitHub の documented Issue update endpoint は PATCH ですが、documented request parameters には expected body hash や expected
updated_atによる atomic precondition はありません。したがって repository 側の hash/timestamp guard は、remote server 上の atomic CAS ではなく、アプリケーション側の read-check-write です。 ([GitHub Docs]2)現行
edit_issue_txn.pyが expected previous body SHA と updated time を受け取り、not_attempted/no_change/applied/unknownを区別しようとしている方向は正しいです。ただし pre-read と PATCH の間には残余 race が存在します。そのため consumer 契約は次に限定されます。
unknownのまま停止HTTP semantics 上も、非冪等な request は、元の request が適用されなかったと確証できる場合などを除き、自動再送すべきではありません。 ([IETF Datatracker]3)
この設計は #2039 に残し、#995 の producer AC から外してください。
P2 — 契約品質上の修正
P2-1. タイトルが current issue-editor architecture と一致していない
タイトルにはまだ
issue-authorが残っていますが、#1734 / PR #1974 で issue-author は deprecated stub となり、既存 Issue の修正は issue-editor/edit-issueに移行済みです。推奨タイトルは次です。
P2-2. Required Skills に workflow skill を列挙している
#995 は Required Skills に次を挙げています。
しかし implementation template は、Required Skills にはドメイン知識のみを記載し、workflow skill は列挙しないよう明記しています。
例えば次のようにするべきです。
workflow skill は Required Design References または実行手順側で参照します。
P2-3. minimal-harness 方針に対して provenance を過剰設計しない
#1860 は、新しい graph policy、packet schema、ledger、digest authority、専用 publisher を増やさず、live state、実 diff、実テスト、current-head CI、独立 review を authority にする方針です。
したがって #995 で必要なのは、新しい global ledger ではありません。既存
repair_actionに、proposal を再検証するための最小 provenance を追加するだけで十分です。推奨最小形は次です。
この情報は authorization authority ではなく、consumer が stale/cross-Issue/template drift を拒否するための検証入力です。
推奨する #995 の再定義
Outcome
In Scope
Out of Scope
改訂 AC
実施順序
goal_refを追加し、parent_issueをnoneに修正する。現状の #995 をそのまま実装すると、schema 外 provenance、consumer mock による偽の E2E PASS、semantic section の過剰自動生成、または Stop Conditions による即時停止のいずれかになります。まず producer-only へ責務を縮小し、schema migration と一意導出規則を契約に明記する必要があります。
squne121 commentedon Aug 16, 2026
推奨は、同じ refinement task をサブエージェントへ再委譲しないことです。親 Claude Code セッション自身を
/home/squne/projects/LOOP_PROTOCOLの canonicalmaincontrol-plane とし、サブエージェントは調査・外部調査・レビューだけに使う構成へ変えるべきです。現行mainはacb422b5f24b93c4ee6aea5518ad57b072f384e0で、anchor がレビューした main と一致しています。#995 はまだ OPEN で、本文も REQUEST_CHANGES の修正を反映していません。 anchor の最終的な実施順序は明確で、#995 を producer-only に縮小し、
goal_ref/parent_issue: none、schema migration、closed derivation mode、duplicate/cardinality、template digest、専用 baseline-fail VC を契約へ入れた後に実装へ進むべきとされています。また
validations.required: trueはフォーム入力の必須性を表すもので、それ自体が欠落本文の意味内容を定義するものではありません。GitHub の公式仕様でもid、attributes.value、validationsは別の概念として定義されています。したがって anchor の「自由作文を auto-safe repair にしない」という制約は妥当です。([GitHub Docs]1)Claude Code 側についても、subagent は独立コンテキストで動き、subagent 自身は別 subagent を spawn できません。foreground subagent は親を完了までブロックするので、今回の「サブエージェントを使い、完了を待つ」要件にはこの形が適しています。([Claude]2)
目的
GitHub Issue #995 の issue-refinement-loop を、次の OWNER direct-human anchor を authority として最後まで再実行してください。
Anchor:
https://github.com/squne121/loop-protocol/issues/995#issuecomment-5305011082前回は refinement loop 全体を isolation worktree の subagent に委譲したため、iteration 0 で以下の blocker により fail-closed しました。
issue-refinement-loopの privileged preflight / contract-update は parent-owned canonical-main control-plane 専用preflight.run.with_human_contextを開始できなかった今回はこの実行主体の誤りを修正してください。
最重要: control-plane の所有者
この top-level Claude Code session 自身が parent control-plane を所有してください。
開始時に canonical repository root:
/home/squne/projects/LOOP_PROTOCOLを確認し、そこで以下を検証してください。
squne121/loop-protocolmainorigin/mainと local main の関係を確認するcanonical root で branch checkout / branch switch / implementation 用変更を行わないでください。
canonical root が
mainでない、dirty である、または安全な parent control-plane として使えない場合は、状態を破壊的に修復せず fail-closed してください。issue-refinement-loop 全体を subagent に委譲してはいけません。
特に以下は top-level parent session が実行してください。
preflight.run.with_human_contextcontract_update.run.with_human_contextsubagent / isolation worktree から canonical privileged executor を直接実行させないでください。
SubAgent 利用
必要な specialist subagent を積極的に使用してください。ただし control-plane authority は親 session に保持してください。
少なくとも適切なものを選んで以下を分担してください。
codebase / contract investigator
.claude/skills/issue-refinement-loop/**.claude/skills/edit-issue/**を調査する。
web-researcher
を確認する。
issue reviewer / adversarial reviewer
を独立にレビューする。
独立に実行可能な read-only 調査は並列化してよいです。
起動した全 subagent の完了を必ず待ってください。
途中結果だけで親 control-plane の mutation 判断へ進まないでください。
subagent がさらに subagent を必要とする構造にはしないでください。nested delegation が必要な作業は親 session が別 specialist として直接 spawn してください。
外部ネットワーク利用の許可
この作業に必要な外部ネットワークアクセスを明示的に許可します。
必要に応じて以下を使用してください。
ghcurl等による公式一次資料の取得必要な外部ネットワーク調査が存在すること自体を human escalation の理由にしないでください。
ただし、この許可は以下を意味しません。
--dangerously-skip-permissions等への勝手な変更通常の既存 permission / controlled executor / repository policy の範囲で実行してください。
refinement の authority
OWNER direct-human anchor:
https://github.com/squne121/loop-protocol/issues/995#issuecomment-5305011082を canonical human context として扱ってください。
Issue 本文より新しい OWNER feedback なので、refinement の修正要求として完全に取り込んでください。
まず canonical parent control-plane から repository の command registry / skill 契約に従い、
preflight.run.with_human_contextを使用してください。
手書きで privileged command を再構成せず、current main の registry / skill を SSOT としてください。
trusted contract patch plan が生成された場合は、親 session が current skill の prescribed controlled lane に従って処理してください。
contract_update.run.with_human_contextが使用可能な経路ならそれを使用してください。
NEXT_ACTION: issue_editor_required等により full rewrite が必要な場合は、同一 command の blind retry をせず、currentissue-refinement-loop/edit-issueが指定する controlled issue-editor transaction route へ親 session から handoff してください。#995 に反映すべき OWNER 要求
anchor を authority としつつ repository の current state と再照合してください。少なくとも以下を解消する必要があります。
1. producer-only への責務縮小
#995 は template-derived structural repair の detector / classifier / proposal producer を所有する。
#2039 が所有するものを #995 の完了条件として奪わない。
#2039 側の責務:
#995 が保持する integration boundary は、将来 #2039 が producer output を opaque に consume できることを証明する schema/interface compatibility test までとする。
#995 自身では production GitHub Issue mutation を acceptance condition にしない。
2. Machine-Readable Contract
少なくとも current authority を検証した上で次を是正する。
goal_refを追加parent_issue: "2160"が delivery parent として不正ならparent_issue: "none"へ変更3. schema migration
structural repair provenance を格納するために必要な schema を Allowed Paths に含める。
anchor が要求する最低候補:
.claude/skills/issue-refinement-loop/schemas/repair_issue_contract_result_v1.schema.json.claude/skills/issue-refinement-loop/schemas/refinement_preflight_result_v1.schema.jsoncurrent main を確認し、実際に必要な schema / policy owner を inventory した上で最小集合に確定する。
Issue で明示承認する additive structural-repair provenance schema / policy migration は Stop Condition の対象外とし、それを超える incompatible migration のみ stop とする。
4. closed derivation policy
validations.requiredだけから semantic prose を生成してはならない。auto-applicable derivation を closed set に制限する。anchor の候補:
template_value_exactsource_span_exactderived_scalar_exactそれぞれの authority / provenance / digest / insertion 条件を contract に固定する。
次は
human_review_requiredとする。ただし不足項目を一件ずつ human escalation せず、一回の producer run で全不足項目を deterministic order で列挙し、一つの handoff に束ねることを目標とする。
5. template provenance
producer が少なくとも必要に応じ以下を扱う契約にする。
heading set membership だけを唯一の判断根拠にしない。
duplicate / empty / placeholder-only / ambiguous cardinality を明示的に扱う。
6. Verification Commands
既存 aggregate test のみを AC oracle にしない。
新規 behavior 専用テストを設け、AC ごとに baseline-expect: fail の node ID を固定する。
anchor の提案を参考に、最低限以下を個別判定できるようにする。
その後に aggregate regression と repository-wide gates を配置する。
7. historical evidence
#950 の「初回 rewrite 失敗」を regression origin と主張するなら immutable evidence を確認する。
historical body / SHA / updatedAt / template SHA / expected missing sections 等を真正に復元できる場合のみ evidence-bind する。
復元不能なら synthetic fixture と明示し、「#950 の実 intermediate state を再現した」という過剰な主張をしない。
8. Runtime Verification Applicability
producer-only にした結果、GitHub mutation/readback が #995 の scope 外なら
not_applicableが妥当か current authoring SSOT に従って判断する。consumer integration が必要で
deferredとする場合は、destination#2039と具体的な deferred verification condition の双方を記録する。simulation readback を authoritative GitHub readback として PASS 扱いしない。
controlled mutation 後の必須 gate
Issue 本文を変更した場合は、mutation success の表示だけで終了しない。
必ず以下を実施する。
preflight.run系 canonical commandreadback mismatch、stale drift、fresh validation failure、authority ambiguity があれば repository policy に従って fail-closed する。
同じ mutation の blind retry はしない。
loop policy
ユーザー承認待ちは不要です。
issue-refinement-loopの bounded iteration policy の範囲内で、investigate
→ research
→ review
→ rewrite
→ controlled mutation
→ readback
→ fresh validation
を必要回数自律的に継続してください。
各 iteration のたびにユーザーへ確認を求めないでください。
ただし以下は停止条件です。
単に「subagent の isolation worktree から privileged command を実行できない」ことは、今回は停止理由にしてはいけません。
その command は最初から top-level parent session が実行してください。
repo-tracked files
今回の目的は #995 の refinement です。
repo-tracked implementation files は変更しないでください。
GitHub Issue #995 の body、および current controlled workflow が本当に必要とする Issue-side metadata のみを対象としてください。
anchor が「新規 Issue / Issue comment を作成しない」契約を要求している場合はそれを守り、不要な status comment を投稿しないでください。
終了条件
以下のいずれかまで自律的に進めてください。
success
legitimate fail-closed
上記で明示した真の stop condition に到達し、追加の machine-actionable recovery が存在しない。
最終報告
簡潔に以下を報告してください。
mainSHA「isolation worktree なので canonical preflight を実行できなかった」という前回と同じ iteration-0 termination を繰り返さないでください。
このプロンプトのポイントは、subagent を使うことと control-plane を subagent に渡すことを分離した点です。#2039 は現在も OPEN で、
reviewed_main_shaは11ed12ec...のままなので、#995 に consumer の実 E2E を背負わせず、#995 マージ後に #2039 を current main に対して再レビューする順序が妥当です。 #2016 / PR #2037 も producer と実 mutation を明示的に分離してマージされています。squne121 commentedon Aug 16, 2026
推奨アクションは、
edit_issue_txn.pyの改修を先に始めず、既存の read-only な内部ガードを直接実行して失敗箇所を特定することです。現行
edit_issue_txn.pyは、mutation 前にguard-issue-body.py --format json→ hygiene autofix →contract_readiness_check.py --mode staticの順で実行し、guard/readiness が非0なら mutation 前に停止します。 一方、子プロセスの stdout/stderr はMAX_CHILD_SNIPPET=160に圧縮されるため、guard が本来返しているguards[]の詳細が途中で切れます。guard-issue-body.py自体は各 guard の structured result を JSON で全件出力し、どれか1件でも失敗すれば exit 2 にしています。つまり、今回の exact blocker は新しい診断機能を実装しなくても、同じ candidate に guard を直接当てれば取得できる可能性が高いです。また、#995 の現行 Allowed Paths には
edit_issue_txn.py/guard-issue-body.pyが含まれておらず、現在の Stop Conditions も scope 外変更や新規 Issue を停止条件にしています。 #1916 はedit_issue_txn.pyを Allowed Paths に含みますが、対象は relationship pagination であり、body/title mutation logic は明示的に Out of Scope です。したがって、#1916 を便乗して直すべきではありません。順序は ① candidateを復元 → ② guard/hygiene/readinessをread-only再現 → ③ candidate側の問題なら修正して controlled transaction を1回だけ実施 → ④ helper自体の欠陥と実証された場合だけ別control-plane scopeへ分離 が適切です。GitHub は unsafe method の conditional request を原則サポートしないとしており、Issue update は PATCH なので、「If-Match を追加してCAS化」のような未文書化前提には寄せない方がよいです。([GitHub Docs]1) また RFC 9110 も、非冪等リクエストは適用されなかったと判定できる等の条件なしに自動 retry すべきではないとしています。([RFCエディタ]2)
以下をそのまま Claude Code に渡すのがよいです。
Issue #995 の issue-refinement-loop が
legitimate fail-closedで終了した件を復旧してください。今回の目的は、同じ Issue mutation を再試行することではありません。まず
guard_or_readiness_failed_before_mutationの exact root cause を mutation なしで特定し、その結果に応じて最小の正しい recovery を実施してください。人間承認待ちは不要です。ただし、scope / authority / mutation safety の fail-closed 条件は維持してください。
既知の状況
前回実行では以下でした。
repo:
squne121/loop-protocolcanonical parent control-plane:
/home/squne/projects/LOOP_PROTOCOL前回 starting / ending main:
acb422b5f24b93c4ee6aea5518ad57b072f384e0repo-tracked mutation: なし
Issue 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 body mutation: なし
Issue 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 authoritative body SHA:
sha256:374fdf1dfec502a81cc39c5e896be2dcd5f55d477b68b561618daa9c47c03498updatedAt:
2026-08-16T01:03:25Zcandidate static readiness:
gocontrolled transaction:
failed_no_mutationmutation_started=falseguard_or_readiness_failed_before_mutationall_passed:falsePATCH/comment/relationship mutation は未試行
blind retry は未実施
candidate body は OWNER anchor の P0/P1 disposition を反映済みだったが publish されていない
ただし、上記 SHA / body hash / updatedAt を現在も正しいとは仮定しないこと。開始時に authoritative readback で再確認すること。
最重要方針
edit_issue_txn.pyを先に修正しない。現行実装を確認すると、body変更時の transaction helper は概ね次の順で処理する。
guard-issue-body.py <candidate> --format jsoncontract_readiness_check.py --body-file <candidate> --mode staticしたがって、まず transaction helper が実際に使った candidate と同じ内容に対して、この validation sequence を直接 read-only で再現し、full structured output を取得すること。
helper の bounded error text だけを根拠に推測しない。
0. Canonical context を確立する
最初に以下を確認すること。
/home/squne/projects/LOOP_PROTOCOLが canonical main root であることgit status --porcelainが clean であることgit fetch --prune origin後のorigin/mainlocal
mainとorigin/mainの SHAIssue 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 の current title/body/body SHA/updatedAt
current Issue comments / OWNER anchor / 前回 termination evidence
CLAUDE.mdおよび関連する repository instructions以下の skill / contract:
issue-refinement-loopedit-issueissue-contract-reviewdocs/dev/agent-skill-boundaries.mdcanonical root では branch checkout / branch switch を行わないこと。
code mutation が後で正当に必要になった場合も、canonical main root を作業 branch に切り替えず dedicated worktree を使うこと。
前回 SHA と現在の
origin/mainが異なる場合は、現在の main を authoritative とし、差分が今回の failure に影響するか確認すること。1. SubAgent を使用する
親 session が orchestration と最終判断を所有すること。
少なくとも以下の specialist SubAgent を起動すること。SubAgent 自身には nested delegation をさせないこと。
Agent A — transaction/codebase investigator
調査対象:
.claude/skills/edit-issue/scripts/edit_issue_txn.py.claude/skills/edit-issue/scripts/guard-issue-body.pycontract_readiness_check.pyISSUE_EDIT_TXN_INPUT_V1ISSUE_EDIT_TXN_RESULT_V1確認事項:
Agent B — candidate/reproduction investigator
前回 issue-editor が作った candidate body を特定する。
優先順位:
禁止:
gh issue editcandidate の SHA-256 を必ず記録する。
Agent C — adversarial reviewer
今回の recovery plan に対して敵対的レビューする。
最低限チェックすること:
all_passed:falseを単に無視していないかAgent D — external primary-source researcher
必要な技術判断について一次資料だけを調査する。
優先:
確認対象:
ブログ等の二次資料を authoritative source にしない。
SubAgent completion rule
起動した全 SubAgent の完了を必ず待つこと。
親 session は、active / running の SubAgent が1つでも残っている状態で final decision、Issue mutation、終了報告をしてはいけない。
SubAgent が 403 WebSocket upgrade、permission guard 等で失敗した場合:
2. 必要な外部ネットワークアクセスを明示的に許可する
この作業に必要な外部ネットワークアクセスを許可します。
許可するもの:
git fetch/ remote ref readgh auth statusgh issue viewgh apicurl等による一次資料の read-only 取得この許可は 外部ネットワーク通信の許可 であり、GitHub mutation の blanket authorization ではない。
以下は引き続き禁止:
gh issue editGitHub write は、後述の controlled Issue transaction が全 gate を通過した場合の Issue #995 body の1 transactionだけを候補とする。
3. exact candidate を使って read-only reproduction する
edit_issue_txn.py自体はまだ起動しない。candidate を lossless に確定したら、その candidate の copy に対して transaction helper と同じ sequence を再現する。
3-A. Guard
helper と同じ引数で実行する。
重要:
--orig-file等を勝手に追加しない--check-ready-tupleも helper が指定していないなら追加しないall_passedguards[]passed:falseの全 guard nameを抽出する
bounded wrapper text ではなく full JSON を根拠にすること。
3-B. Hygiene
candidate 原本を上書きせず scratch copy を作る。
helper が使用する hygiene autofix を同じ引数で実行する。
以下を保存:
helper が success として扱う exit-code contract もコードから確認すること。
3-C. Static readiness
post-hygiene candidate に対して helper と同じ command を実行する。
structured output、exit code、errors を全文保存する。
前回「candidate static readiness = go」と報告された検証が、
のどちらだったかも明確にすること。
3-D. 結果分類
以下のどれかに分類する。
Case A — guard が fail
exact failed guard を特定する。
その failure が正当な contract/policy violation なら、guardを弱めず candidate を修正する。
例:
候補修正後に 3-A〜3-C を最初からやり直す。
Case B — guard pass / readiness fail
readiness の exact failure を特定する。
正当な contract violation なら candidate を修正する。
readiness implementation defect なら #995 の candidate を歪めて回避せず、ownership を調査する。
Case C — guard / hygiene / readiness が全部 pass
前回の transaction failure と矛盾する。
この場合は、
を突き合わせ、同じ input で transaction validation phase のみが異なる理由を調査する。
この時点でも GitHub mutation はまだ行わない。
4.
edit_issue_txn.pyの diagnostic defect を別問題として評価する現行 helper が child の structured output を短い text snippet に圧縮し、failed guard identity を lossless に伝播できていないなら、それは control-plane observability defect として記録する。
ただし、
「診断しにくい」ことと「今回 #995 が失敗した直接原因」を混同しない。
今回の failure は既存 guard を直接実行して先に特定する。
helper改善が必要なら、まず既存 open Issue を検索し、次を変更する explicit authority があるか確認する。
.claude/skills/edit-issue/scripts/edit_issue_txn.py.claude/skills/edit-issue/tests/**ISSUE_EDIT_TXN_RESULT_V1注意:
edit_issue_txn.pyを扱うが native relationship pagination が scope であり、body/title transaction diagnostics を流用してはならないedit_issue_txn.py改修 authority とはみなさないexplicitly matching existing Issue がなければ、#995 の名義で code を変更しない。
その場合は新しい control-plane improvement Issue の ready-to-file draft を作り、repo mutation 前で停止する。
新規 Issue 作成自体は #995 の current Stop Conditions と衝突し得るため、この session から勝手に create しない。
diagnostic improvement の望ましい方向
専用の
--diagnosemode を増やすことを最初から決め打ちしないこと。まず最小案を比較する:
既存 child JSON を parse して
failed_gatefailed_checks[]child_returncodeを
ISSUE_EDIT_TXN_RESULT_V1に lossless に近い形で投影するfull diagnostic artifact を mutation-free に保存し、その digest/ref だけ result に持たせる
本当に orchestration-level reproduction が必要な場合だけ explicit validation-only mode を設ける
要件:
5. candidate側の問題だけなら #995 を復旧する
3-A〜3-C の direct validation がすべて PASS し、SubAgent の敵対的レビューでも blocker がなく、今回の failure が candidate側で修復できたと実証された場合のみ、#995 の controlled update に進む。
mutation 前に必ず:
を確認する。
その後、production
edit_issue_txn.py経由で 最大1回だけ controlled transaction を実行する。gh issue edit禁止もし再び
failed_no_mutationになったら、2回目の mutation invocation を行わず、exact input/candidate に対する read-only diagnostic を実施して終了する。6. mutation 成功後
成功した場合は authoritative readback を行い、
の一致を確認する。
続いて fresh:
を実行する。
Issue #995 の contract が最終 gate を通るまで implementation handoff を authorized と扱わない。
7. GitHub PATCH / retry 設計上の禁止事項
GitHub API に未文書化の atomic CAS capability があると仮定しない。
特に:
If-Matchを issue PATCH の CAS として勝手に採用しないfailed_no_mutationに縮退しないGitHub公式ドキュメントと HTTP RFC の一次資料で確認すること。
8. 終了条件
最終報告には最低限以下を含める。
Environment
Candidate provenance
Exact failure
all_passedRoot-cause classification
次の1つを明示:
candidate_contract_defectguard_policy_expected_rejectionreadiness_expected_rejectiontransaction_diagnostic_loss_onlytransaction_helper_behavioral_defectenvironment_or_transport_failureinconclusiveMutation
SubAgents
全 agent について:
Follow-up
helper defect が残る場合:
または
を示す。
全 SubAgent の完了を待ってから終了すること。
このプロンプトのポイントは、前回提案の「diagnostic path をまず実装する」から一段手前に戻し、既に存在する full guard JSON を使って原因を無変更で観測することです。そこで helper 固有の不整合まで再現できた場合にだけ、diagnostic transport の改善を別スコープに切り出すのが最小リスクです。
squne121 commentedon Aug 16, 2026
Contract Review Result
squne121 commentedon Aug 16, 2026
issue-refinement-loop 終了報告(復旧完了)
状況
前回セッションは Step 4 Rewrite の
edit_issue_txn.pycontrolled transaction がfailed_no_mutation/guard_or_readiness_failed_before_mutation/all_passed:falseとして mutation 前に fail-closed 停止しました(GitHub mutation は未実施のまま)。
今回セッションは blind retry を行わず、以下を read-only / controlled 経路で確認しました。
sha256:374fdf1d..., updatedAt2026-08-16T01:03:25Z)から更新されており、現在の body はsha256:4a0029032779e27e15949065d991248d8cc7821ded00488f736149de87ac1392(updatedAt
2026-08-16T04:56:46Z)でした。本セッションはこの body を mutation していません。run_root_review_pipeline.py produce(issue-refinement-loop Step 2、root-owned single producer):VERDICT: approve/STATUS: ok/BLOCKERS: 0/NEXT_ACTION: proceed(
reviewed_body_sha256は上記 body と一致)。classify-child-stdoutによる独立整合性検証もclassification: ok。contract_readiness_check.py --mode static:status: go(同一 body SHA)。run_contract_review_once.py --mode static:status: go。ensure_contract_snapshot.py --mode auto --post: Contract Snapshot を投稿し、fresh go を確立。Root-cause classification
transaction_diagnostic_loss_onlyではなく、現在の body に対してはguard / readiness いずれも fail していません(
Case C相当だが、現在の body 自体が前回 candidate から既に修正されているため、前回の
failed_no_mutationと矛盾しません — 前回fail-closed した candidate と、現在 authoritative な body は異なる内容です)。前回の fail-closed
は「未修正 candidate に対する正当な guard/readiness 拒否」であり、その後 body が修正されて
現在は解消済みと判断します。
Mutation
(
https://github.com/squne121/loop-protocol/issues/995#issuecomment-5306249527)判定
[-]fix(issue-refinement-loop): fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する[/-][+]実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する[/+]squne121 commentedon Aug 16, 2026
implement-issue: 実装完了 (2026-08-16)
.claude/worktrees/issue-995-fail-closed-rewrite-constraints-issue-auworktree-issue-995-fail-closed-rewrite-constraints-issue-au8aa0e839fcd281b85c88e774d9e330f3d9194287pnpm typecheck/lint/test(1872)/buildPASS + gemini model routing(24) PASSrepair_issue_contract.py/repair_issue_contract_result_v1.schema.json/refinement_preflight_result_v1.schema.json/tests/test_template_section_repair.pyのみで Allowed Paths 内fix_delta: structural_repair_action の fail-closed routing/provenance/…
fix_delta: structural_repair_action の production preflight 接続と templa…
fix: E501 対応のため長い assert 行を中間変数で分割する (#995)
fix_delta: run_refinement_preflight.py の wiring 済み実態に scope-disclosur…
feat: repair_issue_contract に template-derived structural repair prod…