Skip to content

実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995

Closed

Description

@squne121

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.py

Parent 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

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

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_v1 schema 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.py

Allowed 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

Activity

  1. added
    enhancement
    on Jun 18, 2026
  2. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    判定

    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 に対して以下を記録するよう要求しています。

    • Issue snapshot
    • resolved template
    • required label/key
    • parent Issue
    • canonical anchor
    • design-reference evidence
    • content の一意導出根拠

    一方、現行 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・型定義の変更が必要になった場合に停止するよう要求しています。

    したがって現状は、次のどちらかにしかなりません。

    1. provenance を schema 外の自由記述や artifact に埋め込み、AC2 を形だけ満たす
    2. schema を正しく更新し、Allowed Paths/Stop Conditions に違反する

    必須修正

    Allowed Paths に最低限、次を追加してください。

    .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
    

    Stop Conditions は次のように限定する必要があります。

    本 Issue で明示的に承認した structural repair provenance の
    additive schema migration と policy-version 更新は停止条件から除外する。
    それを超える破壊的変更が必要な場合のみ停止する。
    

    また、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 の完了条件にしています。

    • controlled transaction による GitHub mutation
    • authoritative GitHub readback
    • fresh preflight/review/readiness
    • post-dispatch retry 禁止
    • readback mismatch
    • fresh-validation failure
    • bounded no-progress stop

    これらは既に #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 から取得しているのは、実質的に次だけです。

    attributes.label
    validations.required == true

    その後、body の H2 heading set と exact match して、見出しがないかを判定しています。template の id、value、description、placeholder、field order、template blob digest は保持していません。

    実際の implementation template では、次のような意味判断を伴う自由記述欄が required です。

    • Parent Goal Ref
    • Current Validated Scope
    • Remaining Parent Gaps
    • Outcome
    • In Scope
    • Out of Scope
    • Acceptance Criteria
    • Verification Commands
    • Allowed Paths
    • Stop Conditions
    • Required Skills

    これらは、見出しが不足しているという事実だけから自動生成できません。template の placeholder や説明文を本文として挿入するのも誤りです。

    一意導出の許可条件を closed enum にすべき

    推奨する derivation mode は次の三種類だけです。

    derivation_mode:
      - template_value_exact
      - source_span_exact
      - derived_scalar_exact

    template_value_exact

    • template に実値の attributes.value がある
    • placeholder ではない
    • field ID が auto-safe allowlist に含まれる
    • template path と blob SHA が proposal に束縛される
    • 内容を byte-exact に挿入する

    source_span_exact

    • parent、anchor、design reference のいずれか一つに exact source span がある
    • source URL/ref、行範囲、text digest を記録する
    • 複数 source が異なる内容を示す場合は自動修復しない

    derived_scalar_exact

    • validated parent number など、構文的に一意な単一値だけを生成する
    • prose を生成しない

    次は常に human_review_required とすべきです。

    • Outcome/Scope/AC/VC/Allowed Paths の自由作文
    • parent と anchor の内容が競合
    • authority source が複数
    • placeholder しかない
    • design reference から要約・解釈が必要
    • field の挿入位置が曖昧

    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 上では以下です。

    contract_schema_version
    issue_kind
    parent_issue
    goal_ref
    change_kind
    

    ところが現在の 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 ではありません。

    修正案

    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

    #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 に縮小する場合は、次が適切です。

    decision: not_applicable
    reason: >
      本 Issue は mutation-free な structural classifier / proposal producer の
      Python実装とschema validationのみを扱う。GitHub mutation/readbackは #2039 の責務。

    full loop を残すなら deferred にしてください。

    decision: deferred
    deferred_destination:
      - destination_type: issue
        destination_ref: "#2039"
    deferred_verification_condition: >
      #2039 が current main に対して実装・マージされ、repair_action.apply の
      production command contract が利用可能になった時点で実施する。

    authoring SSOT も、deferred では destination と verification condition の両方を要求しています。


    P1-2. Verification Commands が AC の判定器になっていない

    現在は AC1〜AC7 を一つの aggregate pytest command にまとめています。

    pytest \
      test_repair_diagnostics_routing.py \
      test_plan_refinement_loop.py \
      test_refinement_preflight.py

    問題は次の通りです。

    • 新規 behavior に対応する test node ID がない
    • 実装前 baseline でも既存 suite が PASS し得る
    • どの test がどの AC を証明するか不明
    • template ID/digest/source derivation/duplicates を検証していない
    • consumer mock が AC5 の実 GitHub behavior を証明したように見える
    • Gemini model routing test は repository policy gate であり、本機能の acceptance oracle ではない

    専用ファイルを新設し、AC ごとに node ID を固定してください。

    # 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

    その後に 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 に最低限次を保存すべきです。

    source_issue: 950
    source_body_sha256: ...
    source_updated_at: ...
    template_path: .github/ISSUE_TEMPLATE/implementation.yml
    template_blob_sha256: ...
    planner_input_sha256: ...
    expected_missing_fields:
      - parent-goal-ref
      - current-validated-scope
      - remaining-parent-gaps
      - outcome
      - required-skills
    expected_reason_code: missing_required_section

    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 が二つある
    • template 順と異なる位置に section がある
    • ## Allowed Paths の前後 anchor が曖昧
    • heading はあるが本文が空
    • heading はあるが placeholder だけ
    • insertion target の前後で code fence が壊れている

    auto-safe proposal には最低限、次が必要です。

    field_id: outcome
    rendered_label: Outcome
    expected_cardinality: 1
    observed_cardinality: 0
    predecessor_field_id: remaining-parent-gaps
    successor_field_id: runtime-verification-applicability
    heading_level: 2
    content_sha256: sha256:...

    同名 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 契約は次に限定されます。

    1. dispatch 直前に fresh read
    2. drift があれば古い candidate を rebase せず producer を再実行
    3. PATCH は最大一回
    4. 応答不明なら GET readback
    5. candidate digest/old digest/third digest を分類
    6. third digest または readback failure では unknown のまま停止
    7. blind retry 禁止

    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 に移行済みです。

    推奨タイトルは次です。

    fix(issue-refinement-loop): template-required section gapsを一括分類し、evidence-bound structural repair_actionを生成する
    

    P2-2. Required Skills に workflow skill を列挙している

    #995 は Required Skills に次を挙げています。

    issue-refinement-loop
    edit-issue
    issue-contract-review
    

    しかし implementation template は、Required Skills にはドメイン知識のみを記載し、workflow skill は列挙しないよう明記しています。

    例えば次のようにするべきです。

    ## Required Skills
    
    - Python / deterministic text transformation
    - JSON Schema Draft 2020-12
    - CommonMark heading / fenced-code parsing

    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 を追加するだけで十分です。

    推奨最小形は次です。

    structural_repair:
      field_id: outcome
      rendered_label: Outcome
    
      target:
        repo: squne121/loop-protocol
        issue_number: 1234
        original_body_sha256: sha256:...
        original_updated_at: ...
    
      template:
        path: .github/ISSUE_TEMPLATE/implementation.yml
        blob_sha256: sha256:...
    
      derivation:
        mode: source_span_exact
        source_refs:
          - ref: ...
            text_sha256: sha256:...
    
      insertion:
        predecessor_field_id: remaining-parent-gaps
        successor_field_id: runtime-verification-applicability
        content_sha256: sha256:...

    この情報は authorization authority ではなく、consumer が stale/cross-Issue/template drift を拒否するための検証入力です。


    推奨する #995 の再定義

    Outcome

    ## Outcome
    
    resolved implementation template の required field を field ID・label・順序・
    template digest とともに読み取り、Issue body に不足する section/contract key を
    一回の実行で完全列挙する。
    
    不足内容が template の exact value、単一 authoritative source span、または
    構文的な scalar として一意に導出できる場合だけ、versioned structural
    repair_action を生成する。
    
    自由作文、複数 source の競合、duplicate heading、曖昧な挿入位置、
    authority/scope/product/policy 判断が必要な場合は、全不足項目を一つの
    human-review handoff に束ねる。
    
    本 Issue は GitHub mutation を行わない。controlled transaction、readback、
    unknown outcome、fresh validation は #2039 が所有する。

    In Scope

    - template field の id / label / required / value / order / template digest の取得
    - required section と required contract key の一括不足判定
    - duplicate/empty/placeholder-only section の判定
    - closed derivation mode に基づく structural repair classification
    - evidence-bound repair_action schema/policy migration
    - 全不足項目を一回の proposal または human handoff に束ねる
    - #2039 が opaque に consume できる compatibility test

    Out of Scope

    - GitHub Issue mutation
    - authoritative GitHub readback
    - post-dispatch retry/unknown outcome 解決
    - fresh preflight/review/readiness の実行
    - semantic prose の LLM 自動生成
    - parent/scope/product/policy/authority の自動判断
    - 新しい global ledger/publisher/security boundary

    改訂 AC

    - [ ] AC1: resolved template の required item が field ID、label、value、順序、
          template digest とともに取得される。
    - [ ] AC2: 一回の producer 実行で、すべての不足 section/contract key が
          deterministic order で列挙される。
    - [ ] AC3: auto_apply_safe は template_value_exact、source_span_exact、
          derived_scalar_exact のいずれかに限定される。
    - [ ] AC4: semantic free-form field、複数 source conflict、duplicate heading、
          ambiguous insertion anchor は human_review_required になる。
    - [ ] AC5: proposal は repo、Issue番号、body SHA、updatedAt、template digest、
          source digest、candidate digest に束縛される。
    - [ ] AC6: structural repair provenance を追加した schema/policy migration が
          schema validation と consumer inventory を通過する。
    - [ ] AC7: #995 の production code path は GitHub mutation を実行しない。
    - [ ] AC8: #2039 compatibility test は opaque action の読取り可能性だけを検証し、
          transaction/readback の成功を主張しない。

    実施順序

    1. 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 本文を上記 producer-only 契約へ修正する。
    2. goal_ref を追加し、parent_issue を none に修正する。
    3. schema files と専用 test file を Allowed Paths に追加する。
    4. derivation mode、duplicate/cardinality、template digest の仕様を固定する。
    5. dedicated baseline-fail VCs を追加する。
    6. 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 を実装・マージする。
    7. その後、実装: repair_action candidate を controlled Issue transaction へ自動適用する main control-plane consumer を追加する #2039 を current main に対して再レビューし、新しい repair policy/schema version を consumer 側へ統合する。

    現状の #995 をそのまま実装すると、schema 外 provenance、consumer mock による偽の E2E PASS、semantic section の過剰自動生成、または Stop Conditions による即時停止のいずれかになります。まず producer-only へ責務を縮小し、schema migration と一意導出規則を契約に明記する必要があります。

  3. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    推奨は、同じ refinement task をサブエージェントへ再委譲しないことです。親 Claude Code セッション自身を /home/squne/projects/LOOP_PROTOCOL の canonical main control-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 専用
    • subagent / isolation worktree からは直接実行不可
    • そのため preflight.run.with_human_context を開始できなかった
    • GitHub mutation は 0 件

    今回はこの実行主体の誤りを修正してください。

    最重要: control-plane の所有者

    この top-level Claude Code session 自身が parent control-plane を所有してください。

    開始時に canonical repository root:

    /home/squne/projects/LOOP_PROTOCOL

    を確認し、そこで以下を検証してください。

    canonical root で branch checkout / branch switch / implementation 用変更を行わないでください。

    canonical root が main でない、dirty である、または安全な parent control-plane として使えない場合は、状態を破壊的に修復せず fail-closed してください。

    issue-refinement-loop 全体を subagent に委譲してはいけません。

    特に以下は top-level parent session が実行してください。

    • canonical context の確認
    • preflight.run.with_human_context
    • planner result の routing
    • trusted contract update の dispatch
    • contract_update.run.with_human_context
    • controlled Issue mutation の authority を伴う handoff
    • final GitHub readback
    • fresh preflight
    • fresh review/readiness の統合
    • loop iteration / termination の最終判断

    subagent / isolation worktree から canonical privileged executor を直接実行させないでください。

    SubAgent 利用

    必要な specialist subagent を積極的に使用してください。ただし control-plane authority は親 session に保持してください。

    少なくとも適切なものを選んで以下を分担してください。

    1. codebase / contract investigator

    2. web-researcher

      • GitHub Issue Forms の公式仕様
      • 使用している関連技術・schema・security semantics
      • 必要ならその他の一次資料
        を確認する。
    3. issue reviewer / adversarial reviewer

      • anchor の P0/P1 が candidate body に完全反映されたか
      • producer / consumer boundary
      • schema migration
      • derivation safety
      • verification oracle
      • Stop Conditions
        を独立にレビューする。

    独立に実行可能な read-only 調査は並列化してよいです。

    起動した全 subagent の完了を必ず待ってください。
    途中結果だけで親 control-plane の mutation 判断へ進まないでください。

    subagent がさらに subagent を必要とする構造にはしないでください。nested delegation が必要な作業は親 session が別 specialist として直接 spawn してください。

    外部ネットワーク利用の許可

    この作業に必要な外部ネットワークアクセスを明示的に許可します。

    必要に応じて以下を使用してください。

    • GitHub API / gh
    • GitHub Issue / PR / comment / commit / repository file の取得
    • WebSearch / WebFetch
    • curl 等による公式一次資料の取得
    • package / tool / upstream implementation の確認
    • その他、契約を正確に refinement するために合理的に必要な read-only network research
    • repository policy が認める controlled GitHub Issue mutation

    必要な外部ネットワーク調査が存在すること自体を human escalation の理由にしないでください。

    ただし、この許可は以下を意味しません。

    • Claude Code の permission model の弱体化
    • --dangerously-skip-permissions 等への勝手な変更
    • credential の生成・変更・露出
    • OS / security policy の変更
    • sudo / privilege escalation
    • unrelated external service mutation
    • destructive operation

    通常の既存 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 をせず、current issue-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 側の責務:

    • GitHub Issue mutation
    • stale handling の consumer orchestration
    • authoritative readback
    • unknown outcome
    • post-dispatch retry policy
    • fresh validation
    • controlled transaction E2E

    #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 を検証した上で次を是正する。

    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.json

    current 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_exact
    • source_span_exact
    • derived_scalar_exact

    それぞれの authority / provenance / digest / insertion 条件を contract に固定する。

    次は human_review_required とする。

    • semantic free-form prose generation
    • placeholder-only source
    • multiple source conflict
    • authority conflict
    • scope / product / policy judgment
    • duplicate heading
    • ambiguous insertion anchor
    • exact source を持たない Outcome / Scope / AC / VC / Allowed Paths 等

    ただし不足項目を一件ずつ human escalation せず、一回の producer run で全不足項目を deterministic order で列挙し、一つの handoff に束ねることを目標とする。

    5. template provenance

    producer が少なくとも必要に応じ以下を扱う契約にする。

    • field id
    • label
    • required
    • value
    • field order
    • template path
    • template digest / blob identity
    • source span / source digest
    • derivation mode
    • insertion anchor
    • Issue/body identity

    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 の表示だけで終了しない。

    必ず以下を実施する。

    1. authoritative GitHub readback
    2. title/body identity / hash / updatedAt の確認
    3. fresh preflight.run 系 canonical command
    4. fresh issue review
    5. fresh contract readiness
    6. anchor の P0/P1 全項目が解消されたことの確認

    readback 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 のたびにユーザーへ確認を求めないでください。

    ただし以下は停止条件です。

    • destructive operation が必要
    • credential / secret の露出・変更が必要
    • privilege escalation が必要
    • authority が本当に曖昧で current OWNER anchor から一意に決められない
    • repository の fail-closed policy が明示的に停止を要求する
    • bounded no-progress に達した
    • canonical root が安全な parent control-plane として利用不能

    単に「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 が存在しない。

    最終報告

    簡潔に以下を報告してください。

    「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 を明示的に分離してマージされています。

  4. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    推奨アクションは、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 条件は維持してください。

    既知の状況

    前回実行では以下でした。

    ただし、上記 SHA / body hash / updatedAt を現在も正しいとは仮定しないこと。開始時に authoritative readback で再確認すること。

    最重要方針

    edit_issue_txn.py を先に修正しない。

    現行実装を確認すると、body変更時の transaction helper は概ね次の順で処理する。

    1. candidate body 読み込み
    2. guard-issue-body.py <candidate> --format json
    3. hygiene autofix
    4. contract_readiness_check.py --body-file <candidate> --mode static
    5. ここまで成功した場合のみ controlled mutation

    したがって、まず transaction helper が実際に使った candidate と同じ内容に対して、この validation sequence を直接 read-only で再現し、full structured output を取得すること。

    helper の bounded error text だけを根拠に推測しない。

    0. Canonical context を確立する

    最初に以下を確認すること。

    canonical 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.py
    • hygiene autofix
    • contract_readiness_check.py
    • ISSUE_EDIT_TXN_INPUT_V1
    • ISSUE_EDIT_TXN_RESULT_V1
    • transaction tests

    確認事項:

    • actual pre-mutation command sequence
    • child stdout/stderr の bounded diagnostic 処理
    • full structured guard result がどこで失われるか
    • mutation を一切行わず同じ判定を再現できる既存 entrypoint
    • helper defect を直す場合の真正な ownership / Allowed Paths

    Agent B — candidate/reproduction investigator

    前回 issue-editor が作った candidate body を特定する。

    優先順位:

    1. 前回 session の保存済み candidate
    2. transaction input / temporary artifact / logs から lossless に復元
    3. 存在しない場合のみ、同じ OWNER anchor / human context から producer-only で再生成

    禁止:

    • Issue mutation
    • comment publish
    • relationship mutation
    • raw gh issue edit
    • stale candidate の textual rebase

    candidate の SHA-256 を必ず記録する。

    Agent C — adversarial reviewer

    今回の recovery plan に対して敵対的レビューする。

    最低限チェックすること:

    Agent D — external primary-source researcher

    必要な技術判断について一次資料だけを調査する。

    優先:

    • GitHub REST API official docs
    • GitHub API best practices
    • RFC Editor
    • repository自身の design docs

    確認対象:

    • Issue update PATCH の documented concurrency / conditional request semantics
    • unsafe PATCH の conditional request support
    • non-idempotent request retry semantics

    ブログ等の二次資料を authoritative source にしない。

    SubAgent completion rule

    起動した全 SubAgent の完了を必ず待つこと。

    親 session は、active / running の SubAgent が1つでも残っている状態で final decision、Issue mutation、終了報告をしてはいけない。

    SubAgent が 403 WebSocket upgrade、permission guard 等で失敗した場合:

    1. exact transport/error を記録する
    2. failed result が返るまで待つ
    3. 親 session が同じ read-only 調査を直接補完する
    4. SubAgent transport failure を substantive finding と扱わない
    5. 無制限 retry しない

    2. 必要な外部ネットワークアクセスを明示的に許可する

    この作業に必要な外部ネットワークアクセスを許可します。

    許可するもの:

    • git fetch / remote ref read
    • gh auth status
    • gh issue view
    • read-only gh api
    • GitHub REST / GraphQL readback
    • GitHub公式ドキュメントへの HTTPS access
    • RFC Editor
    • WebFetch / WebSearch / curl 等による一次資料の read-only 取得
    • SubAgent が上記 read-only network research を行うこと

    この許可は 外部ネットワーク通信の許可 であり、GitHub mutation の blanket authorization ではない。

    以下は引き続き禁止:

    • raw gh issue edit
    • raw PATCH による Issue 更新
    • 不要な comment / label / relationship mutation
    • branch protection / ruleset mutation
    • secret/token の出力・アップロード
    • auth credential の変更
    • sudo / privilege escalation
    • security setting の緩和

    GitHub 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 と同じ引数で実行する。

    python3 .claude/skills/edit-issue/scripts/guard-issue-body.py \
      <candidate-body-file> \
      --format json

    重要:

    • helper が使っていない --orig-file 等を勝手に追加しない
    • --check-ready-tuple も helper が指定していないなら追加しない
    • stdout JSON を全文保存
    • exit code を保存
    • all_passed
    • guards[]
    • passed:false の全 guard name
    • 各 failed guard の structured fields
      を抽出する

    bounded wrapper text ではなく full JSON を根拠にすること。

    3-B. Hygiene

    candidate 原本を上書きせず scratch copy を作る。

    helper が使用する hygiene autofix を同じ引数で実行する。

    以下を保存:

    • hygiene exit code
    • pre-hygiene SHA
    • post-hygiene SHA
    • semantic/non-semantic delta
    • stdout/stderr

    helper が success として扱う exit-code contract もコードから確認すること。

    3-C. Static readiness

    post-hygiene candidate に対して helper と同じ command を実行する。

    python3 .claude/skills/issue-contract-review/scripts/contract_readiness_check.py \
      --body-file <post-hygiene-candidate> \
      --mode static

    structured output、exit code、errors を全文保存する。

    前回「candidate static readiness = go」と報告された検証が、

    • pre-hygiene candidate
    • post-hygiene candidate

    のどちらだったかも明確にすること。

    3-D. 結果分類

    以下のどれかに分類する。

    Case A — guard が fail

    exact failed guard を特定する。

    その failure が正当な contract/policy violation なら、guardを弱めず candidate を修正する。

    例:

    • template guard
    • issue body validation
    • AC/VC alignment
    • outcome quality
    • compound command restriction
    • schema / Allowed Paths / contract invariant

    候補修正後に 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 と矛盾する。

    この場合は、

    • exact candidate SHA
    • transaction input
    • readiness forwarding payload
    • environment
    • invoked script revision
    • hygiene result
    • current main revision

    を突き合わせ、同じ 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

    注意:

    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 の望ましい方向

    専用の --diagnose mode を増やすことを最初から決め打ちしないこと。

    まず最小案を比較する:

    1. 既存 child JSON を parse して

      • failed_gate
      • failed_checks[]
      • child_returncode
      • bounded structured details
        を ISSUE_EDIT_TXN_RESULT_V1 に lossless に近い形で投影する
    2. full diagnostic artifact を mutation-free に保存し、その digest/ref だけ result に持たせる

    3. 本当に orchestration-level reproduction が必要な場合だけ explicit validation-only mode を設ける

    要件:

    • guard/readiness semantics を弱めない
    • pass/fail 判定を変えない
    • mutation を追加しない
    • candidate body 全文を stdout に漏らさない
    • secret を diagnostics に含めない
    • bounded stdout contract を壊さない
    • guard failure / readiness failure / hygiene runtime error を区別できる
    • late-position の failed guard が 160-byte truncation で消えないことを regression test する

    5. candidate側の問題だけなら #995 を復旧する

    3-A〜3-C の direct validation がすべて PASS し、SubAgent の敵対的レビューでも blocker がなく、今回の failure が candidate側で修復できたと実証された場合のみ、#995 の controlled update に進む。

    mutation 前に必ず:

    1. authoritative GitHub readback
    2. current title/body/body SHA/updatedAt
    3. fresh preflight with current human context
    4. fresh root-owned review
    5. direct guard full JSON: all pass
    6. post-hygiene static readiness: go
    7. candidate SHA と transaction input の provenance binding
    8. stale precondition がないこと

    を確認する。

    その後、production edit_issue_txn.py 経由で 最大1回だけ controlled transaction を実行する。

    • raw gh issue edit 禁止
    • direct REST PATCH 禁止
    • blind retry 禁止
    • mutation ambiguity を success に変換禁止
    • failed_no_mutation でも同じ input の自動再試行禁止

    もし再び failed_no_mutation になったら、2回目の mutation invocation を行わず、exact input/candidate に対する read-only diagnostic を実施して終了する。

    6. mutation 成功後

    成功した場合は authoritative readback を行い、

    • title
    • body SHA
    • updatedAt
    • expected candidate SHA

    の一致を確認する。

    続いて fresh:

    • preflight
    • root review
    • static readiness

    を実行する。

    Issue #995 の contract が最終 gate を通るまで implementation handoff を authorized と扱わない。

    7. GitHub PATCH / retry 設計上の禁止事項

    GitHub API に未文書化の atomic CAS capability があると仮定しない。

    特に:

    • If-Match を issue PATCH の CAS として勝手に採用しない
    • PATCH の自動 retry を追加しない
    • network error を「未適用だった」と推測しない
    • unknown mutation outcome を failed_no_mutation に縮退しない

    GitHub公式ドキュメントと HTTP RFC の一次資料で確認すること。

    8. 終了条件

    最終報告には最低限以下を含める。

    Environment

    • starting main SHA
    • ending main SHA
    • origin/main
    • git status
    • repo-tracked mutation 有無

    Candidate provenance

    • candidate の取得元
    • pre-hygiene SHA
    • post-hygiene SHA
    • 前回 candidate と同一か

    Exact failure

    • guard exit
    • all_passed
    • failed guard names
    • failed guard structured detail
    • hygiene exit/result
    • readiness exit/status/errors

    Root-cause classification

    次の1つを明示:

    • candidate_contract_defect
    • guard_policy_expected_rejection
    • readiness_expected_rejection
    • transaction_diagnostic_loss_only
    • transaction_helper_behavioral_defect
    • environment_or_transport_failure
    • inconclusive

    Mutation

    • attempted / not attempted
    • transaction count
    • before/after SHA
    • updatedAt
    • receipt
    • authoritative readback

    SubAgents

    全 agent について:

    • role
    • result
    • evidence
    • failed/unavailable の場合 exact reason

    Follow-up

    helper defect が残る場合:

    • existing owner Issue
      または
    • ready-to-file dedicated control-plane Issue draft

    を示す。

    全 SubAgent の完了を待ってから終了すること。

    このプロンプトのポイントは、前回提案の「diagnostic path をまず実装する」から一段手前に戻し、既に存在する full guard JSON を使って原因を無変更で観測することです。そこで helper 固有の不整合まで再現できた場合にだけ、diagnostic transport の改善を別スコープに切り出すのが最小リスクです。

  5. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-08-16T07:06:53Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/995
      body_sha256: "sha256:4a0029032779e27e15949065d991248d8cc7821ded00488f736149de87ac1392"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:4a0029032779e27e15949065d991248d8cc7821ded00488f736149de87ac1392","source_provenance":{"source_type":"body_file","body_file":"/tmp/contract_review_once_body_v09holn8.md"}}
        vc_preflight:
          decision: pass
          classifications: '[{"ac":"AC1","line":3,"raw_command":"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","command_hash":"sha256:fc0cd683ba523080bf2d53acc9d47e3cdd101c9c18c33c8b1a9c897a8336cebd","execution_key_hash":"sha256:80991a396cdf45f140d34d16e7525d09bc2a07fad6dcdcdec5e89f4a1bdd5acd","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":164,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":2,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC2","line":7,"raw_command":"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","command_hash":"sha256:d17ec4c14ba058ea73e8b30d276dd57fb5cf460bdd589d1472f26586f01907bb","execution_key_hash":"sha256:e4f57ea695bab95764040126be49d89e81ef2348242279c16feeff3e54ec8b12","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":166,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":6,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":11,"raw_command":"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","command_hash":"sha256:a26c73cbcf57093d18942e329def0d9da74d2dca5ff0fce520580d0b95d8eba0","execution_key_hash":"sha256:79d2d6252e9c80305209cce25ffe1ab30ddc164f0c4014a1301d82e515a3e45c","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":189,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":10,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC4","line":15,"raw_command":"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","command_hash":"sha256:23aacb058d5805bb181685e3cacf54a1b03e5dadaa7fcda4a9a28202cfd3c5c3","execution_key_hash":"sha256:fd39f122022045675df82bf4cdf341a7048f5a26941464ec917a2e3543e5b831","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":200,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":14,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC5","line":19,"raw_command":"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","command_hash":"sha256:1107d30829f5a3a4fdd8db0df31fe86e7598f63833864bf76593b55f86373a1c","execution_key_hash":"sha256:7ad31ac3320d39f7e579c7cbab28826514e7d5a23d851da95070d352dd962e44","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":191,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":18,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC6","line":23,"raw_command":"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","command_hash":"sha256:32b64cb3f1890d214f566158522f17f2f2bec250760df7d55f136affe21d45ca","execution_key_hash":"sha256:f26039fed22875243f99057cb0b8fa71003a3f02e42b9c79242054689ad07a2b","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":204,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":22,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC7","line":27,"raw_command":"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","command_hash":"sha256:00d981343c5316c031697f86b9fee890b80684a661ea9e9272d1547036872b26","execution_key_hash":"sha256:d6ff4d50e1296cb50c78452b266d5ee9bbb5100210ee50f757e7c3271ec19c64","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":195,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":26,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC8","line":31,"raw_command":"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","command_hash":"sha256:461eddfc35ca5acdc98608c24156cdf5bae53cc62b64e7464b95251d133ed5f3","execution_key_hash":"sha256:cb1ecea539710cab1bb781eff5a881a0290f5002dc699c87eb7af324929c2d88","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":184,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":30,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC8","line":34,"raw_command":"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","command_hash":"sha256:1af3c4b5855d1adbed43df1cfbed832f137eb12af48f418e56d6da78f3aa8b84","execution_key_hash":"sha256:7d4a6ce1ffe5172a9122fa06cc44dcaa1dbcbaa245b74ad341edd135d3a7923c","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_truncated":false,"stdout_original_line_count":3,"stderr_truncated":false,"stderr_original_line_count":3,"duration_ms":175,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC8","line":37,"raw_command":"pnpm typecheck","command_hash":"sha256:1b65adab2d69e0f148ddd11c15c7dcd73ca087b66cc02dac2672f9493093cc6d","execution_key_hash":"sha256:2256ec6387c103f51a1c82dae38ac94435427b1940fb40e3de6b394a1637c49b","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_truncated":false,"stdout_original_line_count":1,"stderr_truncated":false,"stderr_original_line_count":2,"duration_ms":1091,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"pnpm_gate_evidence_required":true},{"ac":"AC8","line":38,"raw_command":"pnpm lint","command_hash":"sha256:ede823a2d5f2814db6ddd8a2969504d513bf5a4428b806aa4d1a0499fb38462f","execution_key_hash":"sha256:3225a0f00d44814e3069288fb105dbc93dd62b66bb532c2706d4451e0ac352d9","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_truncated":false,"stdout_original_line_count":1,"stderr_truncated":false,"stderr_original_line_count":2,"duration_ms":9938,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"pnpm_gate_evidence_required":true},{"ac":"AC8","line":39,"raw_command":"pnpm test","command_hash":"sha256:ae7aca4de98e885127fe392c0b60056f3472ed0f0be972870a06df422b3f140a","execution_key_hash":"sha256:60611f60c416bc8fb93beb8001f0f6af1ec9d0b599f95bed1e5cc0900f63e459","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_truncated":false,"stdout_original_line_count":10,"stderr_truncated":false,"stderr_original_line_count":2,"duration_ms":21793,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"pnpm_gate_evidence_required":true},{"ac":"AC8","line":40,"raw_command":"pnpm build","command_hash":"sha256:702e948d947e109310cb2bf19c157b5bb8142b88c87e02ae87a7594c9b797893","execution_key_hash":"sha256:1a5575c6becc32f59ceee5ba1a8842a79bba4abf8263e64d56073ab0b2aaaab1","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_truncated":false,"stdout_original_line_count":11,"stderr_truncated":false,"stderr_original_line_count":2,"duration_ms":1458,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null,"pnpm_gate_evidence_required":true},{"ac":"AC8","line":41,"raw_command":"uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py","command_hash":"sha256:de797c88d2c6031f471b794d3a4102b7bf9cba8140df510371044083e52bb13e","execution_key_hash":"sha256:5d1f7a5fc60c431f596f4dfbe7b60203599507d1761b33023aaeba5506f888f0","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_truncated":false,"stdout_original_line_count":12,"stderr_truncated":false,"stderr_original_line_count":1,"duration_ms":13872,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]'
          classifications_transport: {"schema":"vc_preflight_classifications_transport/v1","classification_count":14,"original_payload_sha256":"sha256:ad05a4b921d33b5ccf1731f9640388ad22b92e8988d7201e90833620b1cfef33","compact":true,"truncated":true}
        declared_path_overlap: '{"schema":"declared_path_overlap/v1","advisory":true,"blocking":false,"decision":"advisory_only","disjoint":true,"overlapping_prs":[],"inventory":{"schema":"OPEN_PR_INVENTORY_V1","repo":"squne121/loop-protocol","state":"open","base_ref":"main","base_sha":"a046fb37d70027b63fc6f1776f97213b3a0f767f","draft_policy":"include_drafts","prs":[{"number":2202,"title":"実装: repair_action.apply の controlled Issue transaction consumer を追加する","base_ref_name":"main","head_ref_name":"worktree-issue-2039-repair-action-apply-consumer","head_ref_oid":"829238daa7efd0fdb0b284a9607a2c582f53fb33","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2202","changed_files_count_graphql":19},{"number":2205,"title":"fix: claude-gpt launcher の isolated proxy 起動で CCP_CODEX_TRANSPORT を http に repository-owned で固定する","base_ref_name":"main","head_ref_name":"worktree-issue-2204-codex-transport-http","head_ref_oid":"3862fa28f5c346d8d83a2ed0c953b14d014d07ea","is_draft":true,"is_cross_repository":false,"head_repository_owner":"squne121","head_repository_name":"loop-protocol","url":"https://github.com/squne121/loop-protocol/pull/2205","changed_files_count_graphql":4}],"fetched_count":2,"totalCount":2,"has_next_page":false,"complete":true,"saturated":false,"limit":200,"page_count":1,"inventory_digest":"sha256:13c9f1487a1c3e8998be7045cf2e3c9bc18bbd96bf35bbfe315740b1ef524731","errors":[]},"inventory_digest_extended":"sha256:63727a3b183d125ba3438530fd43b141dc836c3cea3a45a7bebafaeaf7672081","errors":[],"note":"changed-file 名の単純な重なりのみを証明する advisory check。3-way merge・hunk 競合・rename/delete 競合は評価しない(実 Git merge 競合の判定は Issue #1792 の PAIRWISE_MERGE_OBSERVATION_V1 producer の責務)。単独では blocking にしない。disjoint は tri-state(true/false/null)— 観測が不完全な場合は null。"}'
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: '{"issue_number":995,"contract_source_kind":"issue_comment","contract_source_id":"5306249527","contract_body_sha256":"sha256:4a0029032779e27e15949065d991248d8cc7821ded00488f736149de87ac1392","allowed_paths_normalized_sha256":"f0fc3057aba5af196267324d0badcb5cc41b0a21e9bd0850a7814cbee56a7aaf","base_ref":"main","base_sha_at_snapshot":"a046fb37d70027b63fc6f1776f97213b3a0f767f"}'
  6. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(復旧完了)

    状況

    前回セッションは Step 4 Rewrite の edit_issue_txn.py controlled transaction が
    failed_no_mutation / guard_or_readiness_failed_before_mutation / all_passed:false
    として mutation 前に fail-closed 停止しました(GitHub mutation は未実施のまま)。

    今回セッションは blind retry を行わず、以下を read-only / controlled 経路で確認しました。

    1. authoritative readback: 現在の Issue 実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する #995 body は前回記録(sha256:374fdf1d..., updatedAt
      2026-08-16T01:03:25Z)から更新されており、現在の body は
      sha256:4a0029032779e27e15949065d991248d8cc7821ded00488f736149de87ac1392
      (updatedAt 2026-08-16T04:56:46Z)でした。本セッションはこの body を mutation していません。
    2. 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。
    3. contract_readiness_check.py --mode static: status: go(同一 body SHA)。
    4. run_contract_review_once.py --mode static: status: go。
    5. 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

    判定

    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: https://github.com/squne121/loop-protocol/issues/995#issuecomment-5306249527
        generated_at: "2026-08-16T07:06:55Z"
        body_sha256: "sha256:4a0029032779e27e15949065d991248d8cc7821ded00488f736149de87ac1392"
      blockers: []
  7. changed the title [-]fix(issue-refinement-loop): fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する[/-] [+]実装: fail_closed rewrite constraints を issue-author へ強制転送し、template-derived required sections を初回修復する[/+] on Aug 16, 2026
  8. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-16)

    • PR: feat: repair_issue_contract に template-derived structural repair producer を追加する #2206
    • Worktree: .claude/worktrees/issue-995-fail-closed-rewrite-constraints-issue-au
    • Branch: worktree-issue-995-fail-closed-rewrite-constraints-issue-au
    • head SHA: 8aa0e839fcd281b85c88e774d9e330f3d9194287
    • Verification: AC1-AC8 各 VC 個別 PASS + 集約回帰(163 tests) PASS + pnpm typecheck/lint/test(1872)/build PASS + gemini model routing(24) PASS
    • Allowed Paths 遵守: 変更ファイルは repair_issue_contract.py / repair_issue_contract_result_v1.schema.json / refinement_preflight_result_v1.schema.json / tests/test_template_section_repair.py のみで Allowed Paths 内
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions