Skip to content

導入: Claude-GPT → issue-refinement-loop → impl-review-loop の実行契約を end-to-end で整合させる #2271

Closed
5 of 5 issues completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: parent
goal_ref: "Claude-GPT上でIssue契約修復、fresh review、条件付き実装を一続きに実行した際、delegation transport・runtime capability・skill handoffの不整合で途中停止しない状態にする"
change_kind: workflow
parent_mode: delivery-rollup
closure_mode: child-complete

Summary

Issue #2230 上で、Claude-GPT が該当プロンプトを完走できなかった理由を検証させたところ、以下の三層でワークフロー契約が分離していることが判明した。

  1. Claude-GPT の Spark delegation transport が現行 Claude Code の Agent tool schema と不整合
  2. Claude-GPT 起動前 preflight と、skill が要求する実行 capability が不整合
  3. issue-refinement-loop の handoff 条件と impl-review-loop の intake 条件が相互矛盾

この Parent issue は、上記 3 層を解消する child issue 群(Child A/B/C)と、それらを統合検証する Child D を束ねる delivery-rollup tracking である。

2026-08-21 の anchor review(https://github.com/squne121/loop-protocol/issues/2271#issuecomment-5368571793)が REQUEST_CHANGES を判定し、Child B の mutation broker 前提の矛盾(P0-1)、Parent closure が統合 E2E を要求しない点(P0-2)、Child 間依存順序が advisory prose に留まる点(P0-3)を指摘した。本 Issue はこの anchor review を反映して改訂されている。

Goal

Claude-GPT 上の root/main thread が、次の工程を安全かつ再開可能に実行できる状態にする。

  1. workflow capability preflight
  2. optional Spark delegation
  3. Issue 契約修復と mutation readback
  4. parent rollup と readback
  5. current live body に対する fresh contract review
  6. implementation entry 判定
  7. impl-review-loop による実装・検証・PR review
  8. merge 直前で停止

Desired Destination

  • Child A/B/C の実装完了後、単一の統合 clean HEAD(Child D)上で Claude-GPT が Issue 実装: visual-impact-policy-trusted の decision/evidence artifact に run_attempt identity を結合する #2230 相当の作業プロンプトを再実行し、typed terminal result(draft_pr_ready / blocked / human_judgment_required / implementation_not_authorized)のいずれかへ到達すること
  • 未分類の Agent schema error、raw gh 認証失敗、遅延した uv_not_found を発生させないこと
  • child issue 完了ごとに本 Parent の ## Child Issues チェックボックスを更新すること

Current Validated Scope

Decisions Fixed

  • 2026-08-21: 実装: visual-impact-policy-trusted の decision/evidence artifact に run_attempt identity を結合する #2230 comment 分析に基づき、不整合を 3 層(Spark delegation transport / capability preflight / loop handoff 契約)に分解し、それぞれ独立した child issue で解決する方針を確定した
  • 2026-08-21: 本 Parent は delivery-rollup として運用し、closure は child issue 全完了時点とする
  • 2026-08-21: anchor review REQUEST_CHANGES を反映し、Mutation Transport Decision の固定、Dependency Graph の normative 化、Parent Closure Rule への integration gate 追加、Child D の追加を確定した

Quality Decision Record

  • Status: N/A
  • Decision Date: 未記録
  • Does this prove the parent goal complete?: N/A
  • Reason: delivery-rollup parent のため quality-gate 判定は行わない
  • Evidence: N/A
  • Next Action: Child A/B/C/D 全完了後に closure 判定を行う

Mutation Transport Decision

Issue #2223 の現行 Owner Decision(https://github.com/squne121/loop-protocol/issues/2223)を canonical route として採用する。

  • canonical route: capability-scoped mutation actor(対象 operation の GitHub mutation capability を明示的に割り当てられた Agent/SubAgent)が使用する operation-scoped native GitHub client / connector / gh の直接使用(承認済み native route)
  • generic production mutation broker の存在は前提にしない
  • mutation authority は agent hierarchy(root/main thread / nested / leaf という深さ)では判定しない。各 Agent/SubAgent に明示的に割り当てられた capability/role contract(frontmatter の tools/disallowedTools/permissionMode 等)で判定する。mutation capability を明示的に持つ Agent/SubAgent(issue-editor/issue-creator 等)は責務範囲内で mutation してよく、条件を満たす nested delegation も許可する
  • read capability と write(mutation)capability を別々に判定する。read route の存在だけで mutation-ready と判定しない
  • mutation 手順: pre-readback → 単一の明示的 mutation → post-readback → 不一致なら追加 mutation せず停止
  • 決定: GitHub mutation を minimal harness に縮退し server-side protection と live readback を正本にする #2223 を再度 supersede して production broker を復活させない
  • 新しい enforcing hook は追加しない

Child B(#2273)はこの決定に整合するよう reframe 済みである(2026-08-22 追記: #2273 は当初 2026-08-21 時点の reframe で「root-owned mutation route」という hierarchy-based な残存表現を含んでいたが、同日付 OWNER 敵対的レビュー(#2273 (comment) )を受けて「capability-scoped mutation actor + operation-scoped native GitHub route」へ置換済み。本 Parent の Mutation Transport Decision も同レビューを反映し同日付で更新した)。

2026-08-22 追記(同日 Child B への追加 OWNER 敵対的レビュー #2273 (comment) を反映): PR #2303 により launch.sh からの GitHub 認証は native gh CLI 経由(Claude Code 本体と同一の認証情報共有)が実際の transport となったことが確定した。この事実を受け、Child B の AC10 および AC7-9 は write permission の可否をあらかじめ blocked と決め打ちせず unverified として判定し、正しさは mutation 前後の live readback(#2223 のモデルに準拠)で担保する方針に更新されている。本 Mutation Transport Decision もこの更新と整合する。

scripts/claude-gpt/launch.sh は 2026-08-21 時点では Claude/AGY 子プロセスに対して HOME/GH_CONFIG_DIR の隔離・GH_TOKEN/GITHUB_TOKEN の unset・MCP 空 config(mcpServers: {})を適用していた。上記 anchor review は、この隔離が続く限り Claude-GPT 実行環境からの GitHub write positive lane が preflight 上つねに unavailable になり得ることを指摘した(P0-2)。

2026-08-22 追記(Child B #2273 への新規 OWNER 敵対的レビュー #2273 (comment) を受けた事実更新): PR #2303(merged, commit c3cbe6c)が launch.sh を変更し、GitHub 認証関連の env var(GH_CONFIG_DIR/GH_TOKEN/GH_HOST/GH_REPO)は Claude-GPT 子プロセスへ native Claude Code と同様に共有されるようになった(native GitHub auth)。隔離されたまま残るのは SSH/GPG/credential-helper 関連の secret のみである。したがって上記の「GitHub write positive lane が preflight 上つねに unavailable になり得る」という懸念は #2303 により解消済みの事実であり、本 Parent はこれを stale な指摘として supersede する。

この隔離アーキテクチャ自体の解消方針(隔離継続 vs Claude Code との機能同等性優先への変更)は、#2303 によって GitHub 認証部分は機能同等性優先へ既に変更済みという確定事実になったため、この点についてはもはや open な Owner Decision ではない。ただし、隔離アーキテクチャ全体(SSH/GPG/credential-helper を含む)の設計判断自体は、引き続き本 Parent および Child B(#2273)のスコープ外として扱う。Child B は現状の(更新後の)availability を正直に報告するに留め、存在しない broker や代行 route を前提にした fallback を実装しない。

Parent Closure Rule

delivery-rollup: 以下をすべて満たした場合に限り本 Parent を close する(Child A/B/C の close だけでは close しない)。

parent_closure_requirements:
  - child_a_pr_merged            # Child A (#2274)
  - child_b_pr_merged            # Child B (#2273)
  - child_c_pr_merged            # Child C (#2272)
  - child_d_completed            # 統合 E2E gate(下記 Child Issues 参照)
  - mutation_transport_decision_is_current   # 上記 Mutation Transport Decision と現在の #2223 Owner Decision が整合
  - integration_head_is_clean
  - issue_2230_equivalent_prompt_executed
  - typed_terminal_result_observed
  - no_unclassified_agent_schema_error
  - no_late_uv_not_found
  - no_unclassified_github_mutation_failure
  - sut_sha_claude_code_version_proxy_version_recorded

quality-gate / routing-map / decision-log: N/A(本 Parent の parent_mode ではない)。Quality Decision Record は close 判定の必須材料にしないが、Child D 完了時点の証跡(SUT SHA・terminal result・reason_code)を close コメントに記録する。

Child Issues

Dependency Graph

Child A #2274
      |
      v
Child B #2273

Child C #2272 は原則並行可能(shared docs は最終側が rebase)

Child A + Child B + Child C すべて merged
      |
      v
Child D(Integration Gate, #2278)

Remaining Parent Gaps

Phase Handoff Contract

child issue(A/B/C/D)起票時に以下の構造を引き継ぐ:

  • Desired Destination
  • Current Validated Scope
  • Remaining Parent Gaps
  • Current Objective
  • Bounded Current Context
  • Normative References
  • Allowed Paths
  • Required Skills
  • Validation Commands
  • Stop Conditions
  • Open Questions
  • Next Action
  • Artifact Refs
  • Handoff Prompt Draft
  • Linked PR(implementation のみ)

Outcome

Claude-GPT 上の root/main thread が、次の工程を安全かつ再開可能に実行できる状態にする。

  1. workflow capability preflight
  2. optional Spark delegation
  3. Issue 契約修復と mutation readback
  4. parent rollup と readback
  5. current live body に対する fresh contract review
  6. implementation entry 判定
  7. impl-review-loop による実装・検証・PR review
  8. merge 直前で停止

Child A/B/C の merge 後、Child D が単一の統合 clean HEAD から元の Issue #2230 作業プロンプト相当を再実行した際、以下のいずれかの typed terminal result へ到達する。

  • draft_pr_ready
  • blocked
  • human_judgment_required
  • implementation_not_authorized

途中で未分類の Agent schema error、raw gh 認証失敗、遅延した uv_not_found を発生させない。

Acceptance Criteria

  • AC1: Spark preferred route が利用可能なら実 Spark SubAgent が完了する
  • AC2: Spark preferred route が利用不能かつ fallback allowed なら、理由付き fallback 結果を返す
  • AC3: trusted uv や GitHub controlled route が不足する場合、SubAgent 起動・Issue mutation 前に停止する
  • AC4: Issue 修復後の fresh review が go の場合だけ impl-review-loop へ進む
  • AC5: stale comment/snapshot 単独では実装を authorize しない
  • AC6: raw gh、raw git push、ambient HOME credential を fallback route にしない
  • AC7: 各 mutation phase 後に live readback を行い、中断時に決定論的な再開点を返す
  • AC8: PR merge は行わず、人間の merge 判断直前で停止する
  • AC9: 新しい永続 ledger、digest-bound authorization、独自 graph control-plane を追加しない
  • AC10: Mutation Transport Decision が 決定: GitHub mutation を minimal harness に縮退し server-side protection と live readback を正本にする #2223 の現行 Owner Decision と矛盾しない
  • AC11: Child D が Child A/B/C 統合後の単一 clean HEAD 上で typed terminal result への到達を証跡(SUT SHA・Claude Code version・proxy version)付きで確認する
  • AC12: Child A/B の実装順序が normative dependency(base SHA 条件)として Child 本文に明記されている

Required Design References

Related

Notes

なし

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    tracking
    state/in-progress
    on Aug 21, 2026
  2. squne121 commented on Aug 21, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。Issue #2271 の問題診断は妥当ですが、現行の Parent/Child 契約では実装開始を許可できません。

    確認時点の対象は main@59c323af です。三層への分解自体は、#2230 の作業ログ、現行 impl-review-loop 資産、Spark delegation の回帰状況と整合しています。問題は、Child B が現在の Owner Decision と矛盾していること、Parent が最終 E2E 未実施のまま閉じられること、Child 間の実装順序と統合責務が定義されていないことです。


    P0-1 — Child B が、#2223 で明示的に不採用となった production broker に依存している

    Child B #2273 は、次を前提にしています。

    しかし、現在の #2223 は implementation Issue ではなく Owner Decision record へ変更されており、以下を明示しています。

    • generic GitHub mutation production broker は実装しない
    • 新規 enforcing hook は追加しない
    • root/main thread が mutation を所有する
    • 通常の Issue/PR mutation は GitHub client、connector、または gh を直接使用する
    • correctness は mutation 前後の live readback で担保する
    • controlled executor は CAS や複数 object transaction が本当に必要な narrow operation に限定する

    したがって、#2273 が probe しようとしている canonical production broker は、現在の設計上は存在せず、今後も作らない方針です。

    必要な修正は Child B の reframe です。 以下のいずれかを Owner Decision として明示的に選ぶ必要があります。

    1. root-owned connector route

      • Claude-GPT root thread が利用可能な GitHub connectorを使用
      • mutation 前取得 → 単一 mutation → post-readback
      • raw gh credential を Claude 子プロセスへ戻さない
    2. host-mediated mutation boundary

      • Claude-GPT は typed mutation proposal を返して停止
      • host/root controller が mutation と readback を実行
      • readback 結果を渡して同じ phase から再開
    3. 決定: GitHub mutation を minimal harness に縮退し server-side protection と live readback を正本にする #2223 を再度 supersede

    現方針との整合性からは、1または2が妥当です。Child B の「non-mutating probe」は、read route の存在確認と write capability を別 field に分離すべきです。read-only probe が通っただけで mutation-ready と判定してはいけません。


    P0-2 — Parent の closure rule が、Parent 自身の Goal 完了を証明しない

    Parent は次を Remaining Parent Gap として明記しています。

    Child A/B/C 完了後、clean worktree から #2230 相当の作業プロンプトを再実行し、typed terminal result への到達を確認する。

    一方、Parent Closure Rule は、

    Child A/B/C がすべて closed になれば Parent を close する。

    となっており、Quality Decision Record も必須ではありません。つまり、最終統合 E2E が未実施でも、三つの Child が閉じれば Parent を閉じられます。

    さらに、各 Child は最終統合 E2E を自分の scope から除外しています。

    修正案

    Parent を次のいずれかへ変更してください。

    • Child D を追加する

      • 統合: merged Child A/B/C の単一 clean HEAD で issue-to-impl E2E を検証する
    • または Parent closure に明示的な integration gate を追加する

    推奨 closure は次です。

    parent_closure_requirements:
      - child_a_pr_merged
      - child_b_pr_merged
      - child_c_pr_merged
      - mutation_transport_decision_is_current
      - integration_head_is_clean
      - issue_2230_equivalent_prompt_executed
      - typed_terminal_result_observed
      - no_unclassified_agent_schema_error
      - no_late_uv_not_found
      - no_unclassified_github_mutation_failure

    ここで typed_terminal_result は draft_pr_ready である必要はありません。正しい preflight による blocked や、正しい判断による human_judgment_required でも、未分類例外ではなく契約どおり到達したことを証明できれば Parent Goal の対象になります。


    P0-3 — Child A/B の依存順序が advisory に留まり、統合差分を保証しない

    Child A と Child B は、少なくとも以下を重複して編集します。

    • scripts/claude-gpt/launch.sh
    • scripts/claude-gpt/lib.sh
    • scripts/claude-gpt/tests/test_delegation_directive.py
    • docs/dev/workflow.md

    コメントでは「並行 PR は避け、片方をマージ後にもう片方を rebase」とされていますが、明示的な dependency は設定しない方針です。

    これは不十分です。rebase は textual conflict を解消するだけで、以下を保証しません。

    • Child B の Spark capability 判定が Child A の最終 route semantics を参照する
    • Child B の test fixture が Child A の最終 Agent schema behavior と一致する
    • Child A の live smoke が Child B の preflight 追加後も通る
    • launcher の option parsing、hook JSON、環境変数の組み立てが統合後も一貫する

    必須 dependency graph

    Owner mutation-route decision / #2223同期
                      |
                      v
                 Child A #2274
                      |
                      v
                 Child B #2273
    
    Child C #2272 は原則並行可能
    ただし docs/dev/workflow.md の競合は最終側が rebase
    
    A + B + C merged
            |
            v
    Integration Gate / Child D
    

    Child B の Depends on Child A は advisory prose ではなく、着手前条件と base SHA 条件にしてください。


    P0-4 — Child A の「custom agent definition へ一本化」だけでは model pin にならない

    Child A は updatedInput.model の外部 model ID 注入を撤去し、session-local custom agent definition の model に一本化する方針です。この方向は、実 runtime schema が per-invocation full ID を拒否した事実への修正として妥当です。

    ただし、Claude Code の現行 model resolution 順序は次です。

    1. CLAUDE_CODE_SUBAGENT_MODEL
    2. per-invocation model
    3. agent definition の model
    4. parent model

    さらに、model allowlist により指定 model が使用できない場合、継承 model への置換が起こり得ます。SubAgent は現行版では background が既定であり、環境変数でも background behavior が変わります。(Claude)

    Child A は CLAUDE_CODE_SUBAGENT_MODEL を Out of Scope にしていますが、設定変更を Out of Scope にすることと、その変数が未設定または無害であることを検証しないことは別です。

    最低限、次の negative control が必要です。

    • CLAUDE_CODE_SUBAGENT_MODEL 未設定
    • exact Spark と一致
      -異なる model が指定されている
    • inherit 相当の値
    • availableModels が Spark を許可しない
    • CLAUDE_CODE_FORK_SUBAGENT=1
    • run_in_background: true が tool input に明示される
    • launcher が CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 を scoped に使う場合の readback

    launcher が env -i により ambient 値を除去しているなら、それを 実装上の暗黙前提ではなく、テストされた invariant にしてください。

    また、upstream proxy の current registry に gpt-5.3-codex-spark が存在することは確認できますが、catalog 登録は account entitlement、Claude Code schema compatibility、実際の SubAgent route 成功を保証しません。

    PR #2263 では、先行 live run 後の fix delta で updatedInput.model pin が加わり、最終差分の live E2E が静的 test に置き換わったことが今回の回帰原因です。したがって Child A の「最終 commit に対する live smoke 必須化」は正しいですが、SUT SHA と evidence SHA の完全一致を機械判定する必要があります。


    P1-1 — 現行 runtime smoke の --agents 経路が launcher policy と自己矛盾している

    現行 lib.sh は caller-supplied --agents を policy-weakening flag として拒否対象に含めています。

    一方、現行 runtime_smoke_test.sh の SubAgent canary は、次の形で launcher の後段引数に --agents "$CANARY_AGENTS_JSON" を渡します。

    launch.sh -- ... --agents <canary-json>
    

    静的な code path 読解では、この invocation は launcher の forbidden flag 判定に到達します。

    本レビューでは実機 smoke を再実行していないため、runtime 結果自体は断定しません。ただし Child A は runtime_smoke_test.sh --spark-delegation を canonical VC にする以上、次を明示的に修復すべきです。

    • caller-owned --agents は引き続き拒否
    • smoke 用 canary は launcher-owned test fixture として内部合成する
    • session-local Spark definition と canary definition の JSON merge を launcher内部で行う
    • duplicate agent name、invalid JSON、caller override を fail-closed にする
    • smoke 自身が実際に Agent invocation まで到達したことを確認する

    「既存 ordinary SubAgent smoke が回帰しない」だけでは、既に壊れている baseline を固定する可能性があります。AC10 は positive control が実 Agent 起動を観測したことまで要求してください。


    P1-2 — Child A の preferred fallback live test が再現可能になっていない

    Child A は次を同時に要求しています。

    • preferred + fallback: allowed の live failure/fallback 確認
    • entitlement 不足の PASS 昇格禁止
    • proxy catalog/entitlement の偽装禁止
      -意図的 quota exhaustion は行わない

    このままでは、実 Spark が正常な環境で preferred fallback failure を決定論的に発生させる方法がありません。

    検証を次の二つに分離すべきです。

    1. Live positive

      • real Spark route
      • requested/resolved/proxy observed model の因果相関
      • foreground completion
      • final SUT SHA
    2. Hermetic negative

      • capability boundary へ fault injection
      • unavailable、schema rejected、quota-like typed error
      • preferred のみ fallback eligible
      • required は terminal stop
      • silent generic fallback がない

    実 provider 障害を待つテストは再現可能な Verification Command ではありません。


    P1-3 — Child C の direct handoff transport が未定義

    Child C の問題認識は正しいです。現行資産では、

    • impl-review-loop の advisory policy は stale/missing snapshot を停止理由にしない
    • steps/preparation.md の後段には stale review hard stop がある
    • LOOP_HANDOFF_RESULT_V1 の実 consumer が impl-review-loop に存在しない

    という不整合があります。

    一方、現在の LOOP_HANDOFF_RESULT_V1 は Issue comment に publish される durable audit artifact です。Child C は「過去 comment は authorization にしない」「same-invocation direct handoff を consumeする」としていますが、direct transport の型、寿命、受け渡し方法が未定義です。

    次の契約を明記してください。

    implementation_entry_decision:
      persistence: ephemeral
      authority: current_root_invocation_only
    
      binding:
        repository:
        issue_number:
        contract_body_sha256:
        allowed_paths_normalized_sha256:
        base_ref:
        base_sha:
    
      review:
        source_kind:
        source_id:
        verdict:
        reviewed_at:
    
      routing:
        status: proceed | rerun_review | stop
        reason_code:
        resume_from:
    
      invocation:
        root_invocation_id:
        produced_by_phase:

    既存 issue-contract-review parser はすでに contract_body_sha256、allowed_paths_normalized_sha256、base_ref、base_sha_at_snapshot 等を要求しています。新しい独立 freshness tuple を作らず、既存 fingerprint parser を再利用すべきです。

    重要なのは次の分離です。

    • direct handoff: 現在 invocation 内だけの routing input
    • GitHub comment: audit telemetry
    • process/session をまたいだ再開: comment から直接 authorize せず、live Issue を再取得して fresh review へ戻す

    これは durable authorization packet を新設せず、#1860 の minimal harness と両立します。#1860 は live Issue/PR、実 diff、実 test、current-head CI、独立 review を authority とし、新規 ledger/digest control-plane を禁止しています。


    P1-4 — Child C の「pytest で runtime verification 完了」は証明範囲が不足している

    Child C は runtime verification を immediate としつつ、理由を「pytest による契約テストで即時検証可能」としています。

    しかし対象は単純な parser ではなく、次の process-level workflow です。

    • issue-refinement-loop が Issue を修復
    • mutation 後 live readback
    • current body に対する contract review
    • body/base drift 判定
    • impl-review-loop への直接 handoff
    • Step 1 着手直前の再検証
    • partial failure 後の resume

    最低限、fake GitHub transport を用いた integration test が必要です。

    • prior review missing → fresh review
    • stale review → fresh review
    • review go → Step 1
    • request_changes / blocked → stop
    • review直後の Issue body mutation → handoff invalidation
    • base SHA drift → reroute
    • Issue mutation 成功、readback 失敗
    • readback 成功、次 phase 開始前に中断
    • audit comment だけ存在 → authorize しない
    • current direct handoff → consume
      -再開時は deterministic resume_from

    Parent の最終 clean-worktree E2E は、この Child の unit/integration testとは別に必要です。


    P1-5 — Child B の capability schema と既存 preflight 出力契約が不整合

    既存 preflight.sh は stdout に CLAUDE_GPT_PREFLIGHT_RESULT_V1 の JSON を返し、proxy、認証、canonical path、read restriction を構造化しています。

    Child B は Outcome で CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1 を掲げる一方、Runtime Verification では「構造化 YAML」と記述しています。

    以下へ固定すべきです。

    • format: JSON

    • stdout: exactly one JSON object

    • stderr: human-readable diagnostics

    • exit code:

      • 0: ready または degraded
      • nonzero: blocked / malformed / internal error を区別
    • capabilityごとに:

      • required
      • applicable
      • status
      • evidence_source
      • reason_code
      • remediation

    例:

    {
      "schema": "CLAUDE_GPT_WORKFLOW_CAPABILITIES_V1",
      "status": "blocked",
      "capabilities": {
        "trusted_uv": {
          "required": true,
          "status": "blocked",
          "reason_code": "trusted_uv_missing"
        },
        "spark": {
          "required": false,
          "status": "fallback_only"
        },
        "github_read": {
          "required": true,
          "status": "available"
        },
        "github_mutation": {
          "required": true,
          "status": "unproven",
          "reason_code": "canonical_mutation_transport_not_selected"
        }
      }
    }

    available、verified_read_only、mutation_unproven を混同しないことが重要です。


    P1-6 — uv remediation が、拒否対象の公式デフォルト install へ戻る可能性がある

    リポジトリは uv == 0.11.29 を project pin としています。

    一方、Astral の standalone installer は user executable directory を既定の配置先とし、Unix 環境では ~/.local/bin/uv が一般的な配置先です。Child B はこの位置を明示的に拒否します。([Astral Docs]2)

    したがって AC9 の remediation を単に「uv をインストールする」とすると、次回 preflight でも trusted_uv_missing になります。

    remediation は少なくとも次を含む必要があります。

    • exact version 0.11.29
    • trusted install root
    • owner / group / mode
    • symlink resolution後の canonical path
      -実 binary の uv --version
    • project pinとの一致
    • install後の canonical resolver readback

    自動 sudo は不要ですが、operator が実行する具体的な trusted installation pathは必要です。


    P1-7 — Parent の terminal result は列挙だけで、状態機械になっていない

    Parent は次の四つを terminal result としています。

    • draft_pr_ready
    • blocked
    • human_judgment_required
    • implementation_not_authorized

    しかし、各 Child がどの phase、reason、retry semantics でこれらへ写像するか定義されていません。

    root-owned output-only envelopeを定義すべきです。これは永続 ledger や authorization packetではありません。

    WORKFLOW_TERMINAL_RESULT_V1:
      status: draft_pr_ready | blocked | human_judgment_required | implementation_not_authorized
      phase:
      reason_code:
      retryable:
      resume_from:
    
      binding:
        repository:
        issue_number:
        issue_body_sha256:
        base_sha:
        integration_git_sha:
    
      evidence_refs: []

    状態は相互排他的・網羅的である必要があります。

    • optional Spark 不可 + fallback allowed → blocked ではなく degraded continuation
    • trusted uv 不足 → mutation 前 blocked
    • fresh review request_changes → implementation_not_authorized
    • semantic判断が必要 → human_judgment_required
    • current-head CI/review/mergeabilityまで完了 → draft_pr_ready
    • unknown exception → typed blocked に丸めず internal_contract_error として区別

    P1-8 — mutation readback と deterministic resume の最小規則が不足している

    Parent AC7 は「各 mutation phase 後に live readbackを行い、中断時に決定論的な再開点を返す」としていますが、Child B/C 間で mutation ownership と resume semantics が分かれています。

    #2223 の Owner Decision に沿い、root-owned mutation は次へ限定してください。

    1. live pre-read
    2. expected target/state を確認
    3. exactly one mutation
    4. live post-read
    5. postcondition 一致なら phase complete
    6. 不一致・取得不能なら追加 mutation せず停止
    7. resume_from と現在の live state を返す
    

    body hash は authorization authority ではなく、同時変更検出と fresh review のための correctness bindingとしてのみ使用します。


    P2 — 本文に既に stale / contradictory な記述がある

    修正対象は次です。

    1. Parent の Remaining Parent Gaps に「Child A/B/C の起票」が残っていますが、三件とも既に存在します。
    2. Child C は「impl-review-loop redesign や merge automation は parent の別 Child」としていますが、Parent の Child 一覧に該当 Child はありません。また Parent 自体は merge直前停止を目的としており、merge automation は対象外です。
    3. Child B は現在の 決定: GitHub mutation を minimal harness に縮退し server-side protection と live readback を正本にする #2223 を「production broker implementation」として参照していますが、決定: GitHub mutation を minimal harness に縮退し server-side protection と live readback を正本にする #2223 は逆の Owner Decisionです。
    4. Child B の output format が JSON/YAML で揺れています。
    5. Parent の Quality Decision Record は Decision Date: 未記録 のままです。

    推奨する Issue #2271 の最小改訂

    Parent Closure Rule

    ## Parent Closure Rule
    
    本 Parent は Child A/B/C の close だけでは close しない。
    
    以下をすべて満たした場合に限り close する。
    
    1. Child A/B/C の各 implementation PR が merged
    2. #2223 と整合する canonical GitHub mutation transport が明記されている
    3. merged 後の単一 integration HEAD を clean worktree で checkout
    4. #2230 相当の作業プロンプトを再実行
    5. 定義済み typed terminal result のいずれかへ到達
    6. Agent schema error、late uv_not_found、未分類 GitHub mutation failure がない
    7. SUT SHA、Claude Code version、proxy version、terminal result、resume_from を記録

    Child Issues

    - [ ] Child A (#2274): Spark model resolution / foreground / final-diff live smoke
    - [ ] Child B (#2273): current #2223 Owner Decision に従う workflow capability preflight
    - [ ] Child C (#2272): ephemeral fresh implementation-entry handoff
    - [ ] Child D: A/B/C merged HEAD の clean-worktree end-to-end integration verification

    Dependency Order

    1. #2223 と #2273 の mutation transport 整合を Owner が確定
    2. Child A を実装・merge
    3. Child B を Child A merged SHA 上で実装・merge
    4. Child C は独立実装可能。ただし shared docs は current main へ rebase
    5. Child D で最終統合 E2E

    追加 Acceptance Criteria

    - [ ] AC10: Child B が current #2223 Owner Decision と矛盾する production broker を要求しない
    - [ ] AC11: Spark model resolution の env/per-invocation/definition/allowlist precedenceをnegative testする
    - [ ] AC12: foreground completionを background-related env 含めて検証する
    - [ ] AC13: direct handoffはcurrent invocation内だけで有効で、過去comment単独ではauthorizeしない
    - [ ] AC14: merged A/B/C の単一 clean HEAD で最終E2Eを実行する
    - [ ] AC15:全終了経路が typed terminal result と deterministic resume_from を返す

    最終評価

    • 三層への問題分解: 妥当
    • Child A の基本方向: 妥当。ただし model precedence、background override、smoke harness を補強必須
    • Child B: 現在の 決定: GitHub mutation を minimal harness に縮退し server-side protection と live readback を正本にする #2223 と正面衝突しており、reframe 前の実装は禁止
    • Child C の基本方向: 妥当。ただし direct handoff transport と process-level verification が未定義
    • Parent closure: 不合格。最終 E2E を mandatory integration gate に変更必須
    • 現時点の routing: implementation_not_authorized
    • 修正後の推奨 routing: Owner mutation-route decision → Child A → Child B、Child C並行 → Child D integration gate
  3. squne121 commented on Aug 21, 2026

    @squne121
    OwnerAuthor

    はい。現行の issue-refinement-loop は、通常は「指定した1 Issue」を mutation 対象にする設計と考えるのが正しいです。入力も単一の issue_number で、Step 4 は issue-editor に「現在の Issue」の rewrite を委譲します。scope rollup にも amend_current_issue はありますが、既存 sibling を一括修正する amend_related_issue のような action はありません。Step 4.5 は child/follow-up の作成・再利用を扱いますが、既存 sibling Issue 本文の自動追随更新とは別です。

    また、issue-refinement-loop の iteration 承認は既に default_required: false です。つまり「needs-fix → 次 iteration」は人間承認なしで継続するのが標準ですが、これは Claude Code 自体の permission mode や --dangerously-skip-permissions を変更する意味ではありません。

    今回については、明示的な multi-Issue refinement として #2271 + #2272/#2273/#2274 を同期修正し、Child D も materialize するのを推奨します。レビューの最終 routing 自体が「Owner mutation-route decision → Child A → Child B、Child C は並行可能 → Child D integration gate」を推奨しています。

    特に #2273 は現在も「#2223 mutation broker」を前提にしており、現行 #2223 の「generic production broker は作らない・root/main が mutation を所有・通常 mutation は client/connector/gh + pre/post live readback」という Owner Decision と正面衝突しています。ここはレビューの選択肢1 root-owned connector route を採るのが最小変更です。

    #2274 の追加指摘も有効です。Claude Code の現行公式仕様では subagent model resolution は CLAUDE_CODE_SUBAGENT_MODEL → per-invocation → agent definition → parent の順で、availableModels の影響も受けます。また v2.1.198 以降は subagent が background 既定です。したがって review が要求している env/allowlist/background の negative control を Issue に反映する価値があります。([code.claude.com]1)

    今後についても、「関連Issueも修正」「sub issueも修正」などと明示された場合は、対象Issueだけでなく指定された関連Issue群も更新対象として扱います。明示がない通常の issue-refinement-loop 依頼では single-target mutation のまま扱います。

    以下をそのまま Claude Code に渡せます。

    Claude Code 作業プロンプト — Issue #2271 multi-Issue refinement

    対象リポジトリ: squne121/loop-protocol

    対象 Parent Issue:

    trusted human-context anchor:

    既存 sub issues:

    目的

    上記 anchor comment の REQUEST_CHANGES を対象に issue-refinement-loop を実行し、Parent #2271 だけでなく、レビュー指摘の影響を直接受ける既存 sub issue #2272/#2273/#2274 も同期して refinement する。

    必要なら integration verification 用の Child D を dedupe 後に新規 materialize し、Parent #2271 の child / dependency / closure contract と整合させる。

    この作業は Issue contract の refinement が目的であり、Child A/B/C のコード実装や impl-review-loop の実行までは行わない。

    承認済みスコープ

    このプロンプト自体を operator-selected trusted human-context directive として扱う。

    以下は人間による事前承認済みであり、途中で改めて承認を求めないこと。

    上記の multi-Issue scope expansion 自体を human_judgment_required の理由にしない。

    ただし、この承認範囲を超える新しい semantic scope、destructive operation、権限昇格、外部 credential の要求、無関係な Issue の変更などが新たに必要になった場合は、既存 hard-stop policy を無効化せず typed blocker として停止する。

    人間承認不要の loop policy

    issue-refinement-loop は max_iterations: 3 を使用する。

    needs-fix から次 iteration へ進む際の repository loop approval は不要とし、自動継続する。

    ただし、これは Claude Code の permission model を変更する指示ではない。

    以下は禁止する。

    • --dangerously-skip-permissions
    • bypassPermissions
    • permissions.defaultMode の緩和
    • permission hook の無効化
    • repository safety boundary の迂回

    GitHub mutation ownership

    #2223 の現在の Owner Decision を authority とする。

    採用する mutation route は root-owned GitHub mutation route とする。

    原則:

    1. root/main thread が mutation を所有する。
    2. mutation 前に live state を取得する。
    3. 一度に単一の明示的 mutation を行う。
    4. mutation 後に同一 object を再取得し postcondition を確認する。
    5. 不一致なら追加 mutation を行わず停止する。
    6. generic GitHub mutation production broker を前提にしない。
    7. 新しい enforcing hook を追加しない。
    8. nested/leaf SubAgent に GitHub write authority を渡さない。

    SubAgent は調査・レビュー・candidate body/proposal の生成に使用し、実 GitHub mutation は root/main thread が行うこと。

    legacy skill procedure と #2223 Owner Decision が衝突する場合は、#2223 の root-owned mutation ownership を優先し、skill 自体のコード変更には今回踏み込まない。

    必須 SubAgent

    少なくとも以下を使用する。

    codebase-investigator

    以下を調査させる。

    web-researcher

    anchor comment の external/runtime claim を current upstream documentation で再検証させる。

    最低限:

    • Claude Code custom subagent model resolution precedence
    • CLAUDE_CODE_SUBAGENT_MODEL
    • per-invocation model
    • custom agent definition model
    • availableModels
    • background subagent behavior
    • CLAUDE_CODE_FORK_SUBAGENT
    • CLAUDE_CODE_DISABLE_BACKGROUND_TASKS
    • --agents session-local agent definition behavior

    一次情報・公式 documentation を優先する。

    issue-reviewer

    各 mutation 後の current live body を独立にレビューさせる。

    SubAgent を起動したら、必ず全 SubAgent の完了を待ってから root/main thread が判断すること。

    background のまま結果未取得で「完了」と扱わない。

    Step 1 — live state と anchor の fact-check

    最初に live state を取得する。

    レビュー時点の main@59c323af を現在の authority と仮定しない。

    current main、live Issue body/comments、関連 Issue/PR、repository assets を再取得して anchor comment の各 blocker を fact-check する。

    anchor を stale snapshot として盲目的に適用せず、

    • still valid
    • already resolved
    • superseded
    • partially valid

    を分類する。

    ただし anchor comment は trusted human-context feedback なので、事実確認後も成立している REQUEST_CHANGES は rewrite input として扱う。

    Step 2 — Parent #2271 refinement

    #2271 に issue-refinement-loop を適用する。

    anchor:
    https://github.com/squne121/loop-protocol/issues/2271#issuecomment-5368571793

    Parent では最低限以下を修正する。

    Mutation transport decision

    #2223 と整合する以下の判断を固定する。

    • canonical route: root-owned GitHub client / connector / approved native route
    • pre-readback → single mutation → post-readback
    • generic production mutation broker は存在を要求しない
    • read capability と write capability を別々に判定する
    • read route が存在するだけで mutation-ready と判定しない

    #2223 を再 supersede して production broker を復活させない。

    Dependency graph

    実装順序を normative にする。

    Child A #2274
          |
          v
    Child B #2273
    
    Child C #2272 は原則並行可能
    
    #2272 + #2273 + #2274 completed
          |
          v
    Child D / Integration Gate
    

    「必要なら rebase」の advisory prose だけで済ませない。

    可能なら GitHub native dependency も同期する。

    Parent Closure Rule

    Child A/B/C が close しただけでは Parent を close できないようにする。

    少なくとも以下を closure requirements に含める。

    Step 3 — Child B #2273 を全面 reframe

    #2273 は anchor review の P0-1 を受けるため、単なる部分追記ではなく contract の意味を修正する。

    現在の以下の前提を除去する。

    新しい Outcome は概ね以下とする。

    workflow-profile issue-to-impl が

    • trusted uv
    • Spark route capability
    • GitHub read capability
    • GitHub write capability

    を別々に評価し、

    GitHub mutation が必要な phase では root-owned mutation route が利用可能かを事前判定する。

    read-only route の存在だけでは write capability を PASS にしない。

    raw credential を leaf SubAgent へ渡さない。

    GitHub mutation correctness は root/main による pre/post live readback で担保する。

    また #2273 は #2274 の final route semantics を前提として実装されるため、

    を着手前条件として明文化する。

    Step 4 — Child A #2274 を補強

    基本方針である

    updatedInput.model への external full model ID injection を撤去し、session-local custom agent definition を使う

    という方向は維持する。

    ただし model pin の成立条件を追加する。

    最低限以下を AC / VC に反映する。

    • CLAUDE_CODE_SUBAGENT_MODEL unset
    • expected Spark と同一値
    • conflicting model
    • inherit
    • availableModels が Spark を許可しないケース
    • inherited/substituted model になった場合の検出
    • background execution
    • CLAUDE_CODE_FORK_SUBAGENT=1
    • CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1
    • foreground requirement の readback

    ambient environment が launcher により除去されるなら、それを「暗黙前提」ではなく tested invariant にする。

    smoke harness

    caller-supplied --agents が launcher policy 上 forbidden なら、runtime smoke から caller-owned --agents を渡す設計にしない。

    canary/custom agent fixture は launcher-owned/session-owned test fixture として内部合成する契約にする。

    以下を検証対象に含める。

    • duplicate agent name
    • malformed JSON
    • caller override
    • actual Agent invocation 到達
    • requested model
    • resolved model
    • proxy observed model

    live / negative verification 分離

    provider failure を待つ nondeterministic VC にしない。

    • Live positive: real Spark route + final SUT SHA
    • Hermetic negative: capability boundary fault injection

    へ分割する。

    negative case では少なくとも

    • unavailable
    • schema rejected
    • quota-like typed error
    • preferred fallback eligible
    • required terminal stop
    • silent generic fallback 禁止

    を決定論的に検証する。

    live evidence の SUT SHA と最終 Issue/PR が要求する implementation SHA が一致することを machine-checkable にする。

    Step 5 — Child C #2272 を補強

    same-invocation direct handoff の transport を曖昧な prose のままにしない。

    新しい durable ledger / authorization packet / digest control-plane は作らない。

    authority は current root invocation 内だけで有効な ephemeral implementation-entry decision とする。

    少なくとも以下を contract として定義する。

    implementation_entry_decision:
      persistence: ephemeral
      authority: current_root_invocation_only
    
      binding:
        repository:
        issue_number:
        contract_body_sha256:
        allowed_paths_normalized_sha256:
        base_ref:
        base_sha:
    
      review:
        source_kind:
        source_id:
        verdict:
        reviewed_at:
    
      routing:
        status: proceed | rerun_review | stop
        reason_code:
        resume_from:
    
      invocation:
        root_invocation_id:
        produced_by_phase:

    既存 GitHub comment 上の LOOP_HANDOFF_RESULT_V1 は audit/history として扱い、過去 comment 単独を implementation authorization にしない。

    impl-review-loop が same-invocation direct result を実際に consume する process-level regression test を要求する。

    body drift / base SHA drift が起きた場合は decision を invalidation し、fresh review/preflight へ戻ること。

    Step 6 — Child D を materialize

    まず dedupe search を行う。

    同一目的の open Issue が存在しなければ、Parent #2271 の新しい child として以下の Issue を作成する。

    推奨タイトル:

    統合: merged Child A/B/C の単一 clean HEAD で issue-to-impl E2E を検証する

    目的:

    Child A/B/C が統合された単一 clean HEAD 上で #2230 相当 workflow を実行し、Parent #2271 の Goal が実際に成立したことを確認する。

    Child D は原則として verification/integration gate とし、無関係な production code を追加しない。

    E2E で新しい実装 defect が見つかった場合は、Child D に無制限に code scope を吸収せず follow-up Issue として materialize する。

    Child D は #2272/#2273/#2274 の completion を prerequisite とする。

    Parent #2271 の ## Child Issues、closure rule、native sub-issue relationship を同期する。

    Step 7 — multi-Issue fresh review

    mutation 後、必ず live readback する。

    対象:

    各 Issue について current body を入力に fresh review を行う。

    implementation Issue は current body に対して contract readiness / issue review を再実行し、stale snapshot を approval に使わない。

    needs-fix の場合は iteration budget 内で自動 rewrite → fresh review を継続する。

    途中 iteration ごとの人間承認は求めない。

    Parent #2271 は delivery-rollup parent なので、implementation handoff marker を生成する対象として扱わない。

    Mutation consistency

    複数 Issue を一括で「成功したこと」にしない。

    Issue ごとに以下を行う。

    1. pre-readback
    2. candidate body / relationship delta 確定
    3. mutation
    4. post-readback
    5. expected body / relationship と一致確認
    6. 次 Issue へ進む

    partial failure が発生した場合は、成功済み mutation を推測で巻き戻さず、live state を再取得して deterministic resume point を返す。

    完了条件

    以下をすべて満たしたら終了する。

    最終報告

    最後に簡潔に以下を報告する。

    Issue refinement 完了後は impl-review-loop を自動開始しない。
    今回の作業は refined Issue set が implementation-ready な状態になったところで停止する。

    この形なら、今回の「sub issue も直す」が単なる参考指示ではなく、明示的に許可された mutation scope になります。また、Child B を先に直すのではなく、設計上は #2274 → #2273、#2272 は並行、最後に Child D が最も整合的です。

  4. squne121 commented on Aug 24, 2026

    @squne121
    OwnerAuthor

    全 child issue (#2272, #2273, #2274, #2278, #2311) が CLOSED になったため、delivery-rollup parent として本 Issue を close します(post-merge-cleanup、PR #2325 マージ起点、closure_mode: child-complete)。

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

    state/in-progresstracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions