Skip to content

実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943

Open

Description

@squne121

Parent Issue

#1833

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1833"
goal_ref: "Codex CLI Multi-Agent V2 移行における bounded nested delegation harness の確立(#1833)"
change_kind: mixed

Parent Goal Ref

Current Validated Scope

  • implementation-worker の Claude/Codex agent contract、implementation skill、parity checker、既存 parity/bridge test と runtime fixture を final V1 に揃える。
  • 変更対象は本 Issue の exact Allowed Paths のみとし、runtime canary と親 rollup 同期は後続 Issue に分離する。

Remaining Parent Gaps

Outcome

Claude Code と Codex CLI の implementation-worker が、normal implementation path において必要な evidence domain に応じ、codebase-investigator と web-researcher を合計 0〜2 体(各型最大 1、同時実行最大 1)まで順次選択でき、選択した全調査結果を検証してから実装へ進む。

In Scope

  • .codex/agents/implementation-worker.toml と .claude/agents/implementation-worker.md に final V1 policy を同じ意味で記述する。
  • .claude/skills/implement-issue/SKILL.md に、snapshot validation 後かつ最初の tracked content mutation 前に実行する Investigation Gate を定義する。
  • policy producer/consumer の Claude/Codex parity、fixture、bridge contract、hook/config checker を実際に必要な最小変更で同期する。
  • test-runner を investigation 件数に数えない一方、active investigation と重複させない制約を consumer behavior に反映する。

Out of Scope

Investigation Gate

  1. live Issue binding、contract snapshot、canonical worktree/branch、tested base/head SHA を検証する。
  2. 必要な evidence domain がなければ 0 体を選択し、暗黙の investigation は起動しない。
  3. codebase domain と web domain が必要な場合だけ、それぞれ最大 1 体を選び、必ず順次実行する(同時 active investigation は最大 1)。
  4. 各 selected result が terminal、schema-valid、current issue snapshot relevant であり、相互に矛盾しないことを確認するまで implementation_go=false とする。
  5. この gate を通過後にのみ最初の Allowed Paths 内 tracked content mutation を開始する。test-runner は investigation 件数に含めないが、active investigation との重複は不可とする。

Final V1 Policy

  • allowed agent types: codebase-investigator、web-researcher
  • selected investigation agents: 0〜2
  • max instances per agent type: 1
  • max concurrent investigation agents: 1
  • both domains selected: sequential execution
  • selection basis: required evidence domain
  • implementation start: selected 全結果の terminal / schema-valid / snapshot relevance / conflict check 成功後
  • concurrency 2: 本 Issue の範囲外。native runtime canary により別 Issue でのみ検討する。

Acceptance Criteria

  • AC1: 0、1、2 agent selection を machine-readable policy で表現し、各型の重複選択を拒否する。
  • AC2: 同時 active investigation が 2 以上となる request を拒否し、both-selected は順次順序を記録する。
  • AC3: selected result の missing / unknown field / malformed schema / non-terminal / stale snapshot / irrelevant / conflicting conclusion を implementation start 前に拒否する。
  • AC4: codebase-investigator と web-researcher 以外の investigation agent、write-capable investigation、暗黙起動を拒否する。
  • AC5: test-runner は investigation 数に含めず、active investigation 中の重複実行を拒否する。
  • AC6: Claude/Codex parity、fixture、checker、agent inventory と launch/permission consumer が final V1 の同一意味を検証する。
  • AC7: implementation skill consumer が Investigation Gate の位置と implementation_go 条件を保持する。
  • AC8: fixed base/head SHA に束縛した Allowed Paths gate が symbolic main ではなく snapshot の full SHA を使用する。
  • AC9: static/schema/contract verification は本 Issue で実施し、native runtime canary の deferred dependency を 実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 に記録する。
  • AC10: negative tests が same-type duplicate、concurrency >1、順序違反、stale result、missing/unknown/malformed field を扱う。

Runtime Verification Applicability

Verification Commands

# AC1
# baseline-expect: fail
$ rg -n "max concurrent investigation agents: 1" .codex/agents/implementation-worker.toml

# AC2
# baseline-expect: fail
$ rg -n "順次" .claude/agents/implementation-worker.md

# AC3
# baseline-expect: fail
$ rg -n "schema-valid" .claude/skills/implement-issue/SKILL.md

# AC4
# baseline-expect: fail
$ rg -n "write-capable investigation" .claude/agents/implementation-worker.md

# AC5
# baseline-expect: fail
$ rg -n "active investigation" .claude/agents/implementation-worker.md

# AC6
# baseline-expect: pass
$ uv run pytest tests/test_agent_parity.py

# AC7
# baseline-expect: fail
$ rg -n "Investigation Gate" .claude/skills/implement-issue/SKILL.md

# AC8
# baseline-expect: fail
$ rg -n "fixed base/head SHA" .claude/skills/implement-issue/SKILL.md

# AC9
# baseline-expect: pass
$ test -f docs/dev/runtime-verification-policy.md

# AC10
# baseline-expect: pass
$ uv run pytest tests/test_codex_agent_bridge_contract.py

Implementation/PR review の Allowed Paths gate は、contract snapshot に保存された full base SHA と reviewed full head SHA を baseline_vc_preflight.py --mode current-head および canonical allowed_paths_review_gate.py に渡して再計算する。symbolic main を base evidence に用いない。

Allowed Paths

  • .codex/agents/implementation-worker.toml
  • .claude/agents/implementation-worker.md
  • .claude/skills/implement-issue/SKILL.md
  • scripts/check_claude_codex_agent_parity.py
  • tests/test_agent_parity.py
  • tests/test_codex_agent_bridge_contract.py
  • tests/fixtures/codex-agent-config/expected-runtime-contract.json
  • scripts/check-codex-agents.mjs

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合。
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)。
  • 後続 Phase / 別スコープへの波及が判明した場合。
  • nested SubAgent delegation が必要になった場合。
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合。
  • secret/credential exposure、external paid service、destructive operation、または permission boundary 拡張が必要な場合。
  • trusted OWNER directives が実質的に矛盾し、機械的優先順位で解消できない場合。
  • GitHub controlled mutation authorization が拒否され、許可済み代替経路がない場合。

Required Skills

  • issue-contract-review
  • implement-issue
  • pr-review-judge

Required Design References

  • .codex/agents/implementation-worker.toml
  • .claude/agents/implementation-worker.md
  • .claude/skills/implement-issue/SKILL.md
  • scripts/check_claude_codex_agent_parity.py
  • tests/fixtures/codex-agent-config/expected-runtime-contract.json
  • docs/dev/runtime-verification-policy.md
  • docs/dev/schema-governance.md

Scope Delta

Notes for Reviewer

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 1, 2026
  2. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    「codebase-investigator または web-researcher のどちらか一体へ」と書かれているが両方必要なら同時に2体調査させられてもよいのでは?

  3. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    総合判定

    REQUEST_CHANGES。

    指定コメントの問題提起は正しいです。codebase-investigator と web-researcher は担当する evidence domain が異なるため、両方が必要な Issue では二体を選択し、独立調査なら並行実行できる設計が合理的です。親 #1833 が固定しているのは「bounded read-only delegation」であり、「必ず一体だけ」という制約ではありません。#1943 の 最大1件・両方禁止 は、親契約から導かれない過剰制約です。

    ただし、単純に max=1 を max=2 に変更して終わりでは不十分です。0〜2体の bounded fan-out、同一 role の重複禁止、全選択 child の completion barrier、部分失敗時の fail-closed、test-runner との非重複、dual-runtime canaryまで契約化する必要があります。

    Blocking concerns

    P0-1: Runtime Verification Applicability 欠落により、現行 worker は実装開始できない

    #1943 の本文には ## Runtime Verification Applicability がありません。

    一方、現行 implement-issue は同セクションがない場合、「推測で進めず status: blocked を返す」と明記しています。したがって現在の Issue は、単一委譲か二体委譲か以前に fail-closed します。

    #1943 には次を追加すべきです。

    ## Runtime Verification Applicability
    
    decision: deferred
    reason: >
      本IssueはClaude/Codexの静的なworker contractとparity validatorを実装する。
      live spawn/join、parallel execution、effective role、non-mutationの実測は#1842が所有する。
    applicable_acs: []
    follow_up_issue: "#1842"
    fallback_policy: >
      fixtureやprose assertionをruntime PASSの代替にしない。

    P0-2: 「最大一体」は根拠がなく、実際の責務分割にも反する

    codebase-investigator は repository・Git・コード依存の調査、web-researcher は外部仕様・最新ドキュメント・公開APIの検証を担当しています。両者は代替関係ではなく直交関係です。

    #1842 自身も両 agent の non-mutation リスクを別 AC に分離しています。それにもかかわらず #1943 が「一方だけ」に固定するのは不整合です。

    Claude Code の現行公式仕様も、独立した調査では複数 subagent の並行実行を一般的なパターンとして明示しています。nested subagent も現行版では標準でサポートされています。(Claude)

    妥当な上限は次です。

    • 選択数は 0〜2
    • codebase-investigator は最大一体
    • web-researcher は最大一体
    • 同じ role の二重起動は禁止
    • 両 evidence domain が必要な場合のみ二体
    • 独立調査なら並行実行を許可
    • 常時二体起動はしない

    P0-3: #1842 が dual-child 動作を一切検証しない

    現在の #1842 は各 runtime について、次の三 session を別々に実行する設計です。

    1. no investigation
    2. codebase-investigator のみ
    3. web-researcher のみ

    二体を同時に選択する session はありません。したがって #1943 だけを二体対応にすると、最も故障しやすい経路が未検証になります。

    #1842 に各 runtime 一件ずつ、次の session を追加する必要があります。

    - id: dual-investigation
      children:
        - codebase-investigator
        - web-researcher
      requirements:
        - both_spawned_before_first_tracked_write
        - spawn_intervals_overlap
        - requested_role_matches_effective_role
        - both_terminal_results_consumed
        - worker_continues_after_both_results
        - no_repository_or_github_mutation
        - no_third_child

    静的 config が二体分の slot を持つことは runtime 成功の証明ではありません。PR #1879 も live nested capability を #1842 に明示的に defer しています。

    P1-1: Codex の thread 上限をちょうど使い切り、test-runner と競合する

    current main は max_concurrent_threads_per_session = 4 です。

    Codex Multi-Agent V2 の実装は、この値を root を含む同時 active agent 数としてモデルに提示しています。したがって、

    root
    + implementation-worker
    + codebase-investigator
    + web-researcher
    = 4
    

    で上限を完全に使い切ります。([GitHub]2)

    #1943 の AC9 は test-runner を「調査一件枠には数えない」としていますが、論理上の調査枠に数えないことと、runtime concurrency slot を消費しないことは別です。

    必須制約は次です。

    test_runner:
      counts_toward_investigation_limit: false
      may_overlap_active_investigation_children: false

    二体調査中に test-runner や別 child を起動すれば五 thread となり、current config では成立しません。

    P1-2: Claude の child type allowlist は実効的に強制できない

    Claude Code では、main-thread agent に対する Agent(worker, researcher) は allowlist として機能します。しかし nested subagent 定義内では括弧内 type list が無視され、単なる unrestricted Agent tool になります。([Claude]1)

    したがって .claude/agents/implementation-worker.md に Agent を追加すると、behavioral contract 上は二 role 限定でも、runtime tool surface 上は他の agent type も起動可能です。#1943 が security boundary と主張しない方針自体は正しいですが、AC5 の「厳密に二者」という表現は enforcement と declaration を区別すべきです。

    次の二層に直すべきです。

    • 静的 checker: declared allowed set が二者であることを検証
    • runtime negative canary: disallowed role の要求に worker が従わなかったことを観測

    後者も security proof ではなく observed behavior に限定します。

    P1-3: before first write は現行実装手順と矛盾する

    implement-issue は tracked file の編集前に worktree・branch を作成します。この bootstrap は filesystem と Git metadata を変更するため、文字どおりの「初回 write 前」は成立しません。

    正確な境界は次です。

    canonical linked worktree、branch、tested HEAD、live Issue contract を確定した後、最初の Allowed Paths 内 tracked-content mutation より前に調査を完了する。

    また、現在の worker は implement-issue Skill を procedure SSOT として使用する契約ですが、#1943 の Allowed Paths には同 Skill が含まれていません。agent prompt に能力だけ追加しても、いつ選択・起動するかが canonical procedure に存在しません。

    .claude/skills/implement-issue/SKILL.md を Allowed Paths に加え、worktree binding 後・TDD 前に小さな Investigation Gate を設けるべきです。

    P1-4: grep と自由記述では parity を証明できない

    #1943 の VC は主として特定の日本語文字列を rg するだけです。

    現行 parity checker も Codex の delegation prose を advisory hint として扱い、strict failure authority にはしていません。テストでもその挙動を明示的に固定しています。

    日本語文章の存在確認ではなく、closed-key の正規化契約が必要です。

    READONLY_DELEGATION_POLICY_V1:
      mode: optional_bounded_readonly_fanout
      allowed_agent_types:
        - codebase-investigator
        - web-researcher
      max_selected_agents: 2
      max_instances_per_agent_type: 1
      parallel_allowed: true
      parallel_required: false
      completion_barrier: all_selected_terminal_success
      partial_failure_policy: block_before_tracked_write
      conflicting_results_policy: block_before_tracked_write
      require_same_issue_contract: true
      require_same_worktree_and_head: true
      test_runner_counts_toward_investigation_limit: false
      test_runner_may_overlap_investigation: false

    少なくとも unknown key、型不正、三体目、同一 role 重複、write-capable child、片方未完了、部分失敗、test-runner overlap の negative test が必要です。

    P1-5: Claude Code の環境変数に関する Notes が事実誤認

    #1943 は CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION を「存在しない変数」と記載しています。

    現行公式仕様では、以下の三つが別々に存在します。

    • CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH
    • CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION
    • CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS

    現在の既定値は、対応バージョンではそれぞれ depth 3、session total 200、concurrent 20 です。([Claude]1)

    Notes は、バージョン条件付きで修正する必要があります。#1842 の evidence に実インストール版と effective override を記録する方針が妥当です。

    P1-6: 二体選択時の部分失敗と結果衝突が未定義

    これは本文から導かれる未定義 failure mode です。

    両方を「必要」と判断して起動したにもかかわらず、一方が failed または inconclusive のとき、もう一方だけで実装を続けてはいけません。また、repository evidence と外部仕様 evidence が矛盾した場合も、worker が都合のよい方を選んではいけません。

    when_two_selected:
      success: both_ok
      one_failed: blocked
      one_inconclusive: blocked
      role_mismatch: blocked
      result_conflict_affecting_ac_or_design: blocked

    Non-blocking concerns

    P2-1: 「read-only」の定義を filesystem write 不在にしてはいけない

    Claude の codebase-investigator は /tmp に request/result を書きます。また親 worker の permissionMode: acceptEdits は、公式仕様上 child の dontAsk より優先されます。 ([Claude]1)

    したがって read-only の意味は次に限定すべきです。

    tracked repository content、Git refs/index、GitHub Issue/PR/comment/state を変更しない。

    tmp artifact の生成まで禁止すると現行 agent が動作しません。

    P2-2: #1886 の AGY route と二体並行実行の相互作用

    #1886 は両 researcher の required route を AGY に統一する予定です。二体並行起動では同一 provider の認証、rate limit、外部実行 capacity を同時消費します。

    これは blanket な並行禁止理由にはなりませんが、#1842 の dual canary では provider failure と native spawn failure を別の failure class に分ける必要があります。

    P2-3: .codex/config.toml の capacity コメントが stale

    config コメントはいまだ implementation-designer を expected peak に含めていますが、同 role は not planned です。

    #1943 の scope 外でも構いませんが、thread budget を説明する文書として誤解を招くため、別の小さな修正対象です。

    必須検証

    #1943 の static tests では、構造化 policy の正規化、Claude/Codex の同値性、unknown key rejection、同一 role 重複、三体目、write-capable child、部分失敗、test-runner overlap を検証します。

    #1842 の runtime tests では、各 runtime について次の四 session が最低限必要です。

    1. no-investigation
    2. codebase-investigator only
    3. web-researcher only
    4. codebase-investigator + web-researcher
    

    四番目では、二つの spawn request の時間的重複、requested/effective role、同一 Issue・worktree・HEAD binding、両 terminal result の消費、worker の post-join continuation、tracked-content/Git/GitHub non-mutation を一次 evidence から検証します。逐次二回起動を「並行成功」と扱ってはいけません。

    推奨修正

    #1943 の方針は、次のように変更するのが妥当です。

    implementation-worker は調査不要なら child を起動しない。repository evidence のみ必要なら codebase-investigator、外部・最新仕様 evidence のみ必要なら web-researcher を一体起動する。両 evidence domain が必要なら各一体、合計最大二体を選択でき、独立調査である場合は並行起動を許可する。全選択 child の terminal success と結果消費が完了するまで Allowed Paths 内の tracked-content mutation を開始しない。一体でも失敗・未確定・role mismatch の場合、または結果が implementation-critical な点で矛盾する場合は実装を開始せず block する。調査中は test-runner その他の child を重複起動しない。

    つまり、指定コメントへの回答は **「賛成。ただし常時二体ではなく、必要な evidence domain に応じた 0〜2体の bounded fan-out とし、dual-child canary・all-result barrier・thread budget を同時に追加する」**です。

    未確認事項

    • Codex CLI の current installed versionで、nested worker が二 child を実際に重複時間帯で起動できるか。
    • Claude Code の実行環境に depth/session/concurrent の override が設定されているか。
    • 実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 の runner が二 child の spawn interval と result consumption を個別に抽出できるか。
    • AGY provider が同一 session からの二並行 request を安定処理できるか。

    これらは static prose で解決せず、#1842 の runtime evidence で反証可能に判定すべき事項です。

  4. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(human_judgment_required)

    anchor comment: #1943 (comment)

    check_issue_contract.py + contract_readiness_check.py --mode execute を決定論的に実行した結果、compact_review_result.py の正規 envelope(validator で validation_status: valid を確認済み)が NEXT_ACTION: human_judgment_required を返したため、本 iteration では Issue 本文の自動書き換えを行わず、ここで停止します。

    1. 決定論チェックで検出されたブロッカー(body_sha256: e17b47fa482197c81061098c792d77d00b5eba75bf8bd9cec4f396d31a6246b3)

    • C9: ## Runtime Verification Applicability セクションが本文にない(OWNER anchor comment の P0-1 指摘と一致)。
    • RDR001: ## Required Design References が実質空(既存の Allowed Paths と同じ bare path の再掲のみで、design doc への参照になっていない)。
    • AC9 / AC10 / AC14: 対応する VC コマンドが baseline で「予期せず PASS」しており、# baseline-expect: pass 注記が必要。
    • AC12: VC コマンド uv run --locked python3 scripts/check_claude_codex_agent_parity.py --strict が VC preflight allowlist(uv run pytest 系のみ許可)に含まれない。
    • AC13(regression gate、human_judgment 分類): VC コマンド uv run --locked pytest tests/test_agent_parity.py tests/test_codex_agent_bridge_contract.py が 本 Issue と無関係に main 上で既に 6 件失敗していることを実行確認済み。
      FAILED tests/test_agent_parity.py::TestNestedDelegation::test_delegation_mismatch_produces_drift
      FAILED tests/test_agent_parity.py::TestNestedDelegation::test_codex_delegation_from_max_depth
      FAILED tests/test_agent_parity.py::TestNestedDelegation::test_delegation_report_in_output
      FAILED tests/test_agent_parity.py::TestStatusOutput::test_delegation_drift_status_warn
      FAILED tests/test_agent_parity.py::TestFixtureFiles::test_drift_delegation_mismatch_fixture
      FAILED tests/test_agent_parity.py::TestB3DriftIsFail::test_delegation_drift_produces_fail
      
      いずれも NESTED_DELEGATION_001 drift 検出が STATUS: ok を返し warn/fail を返さないという既存不具合であり、実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 の変更内容とは無関係です。Issue 本文の書き換えでは解消できない環境状態であるため、本ループは contract_readiness_human_judgment として fail-closed しました。

    2. anchor comment(OWNER REQUEST_CHANGES)が要求する未反映のスコープ変更

    上記の contract formality blocker とは別に、OWNER の REQUEST_CHANGES 自体がまだ本文へ全く反映されていません。主な要求:

    これらは Issue の意味・スコープに関わる実質的な変更であり、check_issue_contract.py の decision surface(C1〜C13)が検出する contract formality の問題とは別に、人間による方針確認が必要と判断しました。

    3. 推奨される次のアクション(人間判断待ち)

    1. main の NESTED_DELEGATION_001 drift 検出の既存不具合(6 test failures)を独立 Issue として扱うか、実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 の AC13 側で明示的にスコープ外として扱うかを決定する。
    2. OWNER の anchor comment が提示した 0〜2体 bounded fan-out 契約(P0-2, P1-4 のスキーマ)をそのまま採用するか、実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 の Outcome/In Scope/AC/VC 全体構成をどこまで書き換えるかを承認する。
    3. 実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 への dual-investigation session 追加(P0-3)を 実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 の Notes に依存関係として明記するか、実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 側の別途 refinement に委ねるかを決定する。

    上記の人間判断が得られた後、本 refinement loop を再実行して Issue 本文の書き換えへ進めます。

  5. squne121 commented on Aug 2, 2026

    @squne121
    OwnerAuthor

    追記: AC13 regression gate 失敗の根本原因を特定し follow-up を起票

    前回の終了報告で触れた AC13 の regression gate 失敗(tests/test_agent_parity.py 6件 FAIL)について、原因コミットを特定しました。

    この不具合を追跡する follow-up Issue を起票しました: #1948

    #1943 は #1948(テスト追従修正)の完了を待つ hard blocker 関係にあります。#1948 がマージされ AC13 の regression gate が green になった後、本 refinement loop を再実行してください。

  6. self-assigned this
    on Aug 9, 2026
  7. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    総合判定

    REQUEST_CHANGES。現状の Issue 契約では実装着手不可です。

    主因は、最新の OWNER REQUEST_CHANGES が本文へ materialize されていないこと、Runtime Verification Applicability が欠落していること、親 #1833・本 Issue #1943・後続 #1842 の dependency/cardinality 契約が一致していないことです。現行 implement-issue は Runtime Verification セクション欠落時に推測で進まず、明示的に blocked で停止するため、現在の本文は consumer-ready contract ではありません。

    一方、過去の blocker だった parity テストの既存赤は、Issue #1948 と merged PR #1959 により解消済みです。したがって現在は「#1948 待ち」ではなく、最新 main を基準に #1943 自体を再 refinement する段階です。


    Blocking findings

    P0-1: 親子 dependency graph が破綻している

    #1943 は parent_issue: #1833 を宣言し、自身を #1842 の hard predecessor としています。しかし親 #1833 の Child Issues と Dependency Order には #1943 が存在せず、依然として #1841 → #1842 が正規 chain です。さらに親本文は canary 対象を codebase-investigator のみに固定したままですが、#1842 は後から web-researcher も対象へ追加しています。

    現在は次の三つが同時に成立しています。

    これは一つの delegation contract ではありません。少なくとも親 #1833 の Child Issues、Dependency Order、Current Validated Scope、AC2 と、#1842 の dependency/session matrix を #1943 の最終設計へ同期する必要があります。


    P0-2: 「何体を選ぶか」と「何体を同時実行するか」が混同されている

    既存レビューは max=1 から直ちに「0~2体、必要なら並行」へ変更するよう求めていますが、これは selection cardinality と concurrency cardinality の混同です。

    親 #1833 が要求しているのは bounded delegation であり、最大一体も最大二体も直接は導きません。Claude Code 公式ドキュメントも、独立した調査の並行実行を有用なパターンとして示しているだけで、並行実行を correctness requirement にはしていません。 (Claude)

    Codex Multi-Agent V2 は現在、既定の同時 active agent 数を4とし、その数には root 自身も含まれます。リポジトリの PR #1879 も同じ4スロット契約を導入しています。したがって二調査 agent を並行起動すると、root + implementation-worker + codebase-investigator + web-researcher = 4 となり、test-runner や障害切り分け用 child の余地がなくなります。([GitHub]2)

    推奨する V1 は次です。

    • 選択可能数: 0~2体
    • 同一 agent type: 最大一体
    • 同時実行数: 最大一体
    • 両 evidence domain が必要なら同一 worker 内で順次実行
    • 全選択結果の validation 完了後にだけ実装へ進む
    • 並行二体は、別 follow-up で runtime canary を通した後に解禁

    これなら両 evidence domain を欠落させず、Codex の4スロットを飽和させず、並行 partial-failure/join barrier/結果競合の複雑性も初期導入から分離できます。現在の max_selected_agents=1 を維持する場合は、「両 domain が必要なら実装前に block する」という明示的な制約が必要です。


    P0-3: READONLY_DELEGATION_POLICY は実質的な新規 schema だが、consumer inventory がない

    #1943 は単なる説明文追加ではなく、Claude/Codex の policy を正規化し、parity checker と JSON fixture で比較することを要求しています。producer と consumer の境界を越えて parse/validate/compare されるため、リポジトリの schema governance 上は machine-readable contract です。

    特に tests/fixtures/codex-agent-config/expected-runtime-contract.json は、既に implementation-worker を含む runtime contract fixture であり、scripts/check_codex_agent_config.py など複数 consumer から読み取られています。agent inventory や launch-ledger 系 consumer も同じ fixture を参照しています。

    しかし現在の Allowed Paths には、少なくとも以下がありません。

    • docs/dev/schema-governance.md
    • scripts/check_codex_agent_config.py
    • fixture を読む inventory/ledger consumer とそのテスト
    • 必要になり得る CI selection SSOT

    全 consumer の変更が必須とは限りません。additive field を安全に無視できる consumer もあります。しかし、安全に無視できることを inventory と regression test で示していないのが問題です。PR #1879 から tests/test_agent_parity.py が consumer inventory 漏れしたことが、Issue #1948 発生の直接原因でした。同じ事故を同じ parity surface で繰り返す設計になっています。

    また親 #1833 は graph policy、専用 checker、別名 schema 群を Out of Scope にしています。新 policy は次のように明示的に分類すべきです。

    READONLY_DELEGATION_POLICY_V1 は implementation-worker 二実装間の agent-local capability contract であり、delegation graph、ledger、authorization、security enforcement ではない。

    この分類を親本文にも反映しない限り、子 Issue が親の Out of Scope に接触します。


    P0-4: agent 定義に能力を追加しても、正規手順に起動地点が存在しない

    Claude/Codex の両 implementation-worker は implement-issue Skill を procedure SSOT としています。Claude worker は通常実装 V1 と PR repair V2 の二 dispatch mode を持ち、Codex worker は IMPLEMENT_RESULT_V1 の通常実装だけを公開しています。

    一方、現行 implement-issue の手順は次の順序です。

    1. live Issue contract 再取得
    2. worktree/branch 作成
    3. Runtime Verification Applicability 確認
    4. TDD/実装

    この間に Investigation Gate は存在しません。#1943 の Allowed Paths に Skill 自体も含まれていません。

    そのため現行案は、「Agent tool は持つが、canonical procedure のどこで、何を根拠に、どの agent を選択するかが未定義」という半実装になります。

    必要なのは .claude/skills/implement-issue/SKILL.md に次の gate を追加することです。

    live Issue、canonical worktree、branch、tested HEAD を bind した後、最初の Allowed Paths 内 tracked-content mutation より前に、必要な evidence domain を判定し、選択した read-only investigator の terminal result を schema validation する。

    加えて policy の適用 mode は normal_implementation_v1 に限定すべきです。Claude 側の update_pr_body_hygiene、update_branch、apply_pr_review_fix_delta にまで暗黙適用すると、Codex に存在しない PR repair surface を parity 対象へ巻き込みます。


    P0-5: 現行 parity checker に implementation-worker をそのまま追加すると false PASS が起こり得る

    現行 checker の output-schema 抽出は限定的な正規表現です。

    • Claude: 特定の「出力契約」見出し、emit ... via、特定形式の fenced YAML
    • Codex: emit ... via または _COMPACT_V* 記述

    Claude worker は IMPLEMENT_RESULT_V1 と IMPLEMENTATION_WORKER_RESULT_V2 の二 mode を持ちますが、Codex worker は V1-only です。それにもかかわらず現在の文面では、両ファイルの schema 抽出結果がともに None となり、None == None で既知の非対称を見逃す可能性があります。

    したがって implementation-worker を whole-agent parity 対象へ直接追加してはいけません。次のどちらかが必要です。

    1. 推奨: readonly_delegation_policy という dimension-specific comparator を追加し、その dimension だけ strict 比較する。
    2. worker の mode matrix、input schema、output schema、適用 policy を正式にモデル化し、V1/V2 非対称も含めて whole-agent parity を再設計する。

    PR #1959 も、従来の prose heuristic は advisory-only だが、#1943 の将来の正規化 policy まで advisory にするものではない、と意図的に範囲を限定しています。新 policy は既存 delegation_intent_hint に混ぜず、別の strict contract として扱うべきです。


    P0-6: Verification Commands が prose の存在しか検証していない

    AC5~AC11 は「両ファイルに契約が存在する」ことを要求していますが、対応 VC の大半は .claude/agents/implementation-worker.md だけを rg しています。Codex 側との同値性、キー集合、型、cardinality、failure policy は検証されません。AC14 も移動する origin/main を比較対象としており、空 diff なら無条件に PASS します。

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

    • unknown/missing key
    • enum、boolean、integer の型不正
    • agent type 集合の欠落・余分な role
    • 同一 role の重複
    • max_selected_agents または max_concurrent_investigation_agents 超過
    • write-capable role の選択
    • expected result schema の不一致
    • child の failed/inconclusive/insufficient-context
    • selected child の一部未完了
    • test-runner との overlap
    • Claude/Codex policy の一キーだけが異なるケース
    • policy が Claude V2 repair mode に誤適用されるケース

    また changed-path gate は、PR 作成時に固定した base_sha...head_sha に対して Allowed Paths の集合包含を検証すべきです。origin/main の現在値を使う検証では race を閉じられません。


    P0-7: runtime を #1842 に defer しても、現在の #1842 は実行可能な canary contract になっていない

    #1842 は Runtime Verification を immediate としていますが、VC は実質的に codex --version、claude --version、git status、git diff です。これらは次を検証しません。

    • child の spawn/start
    • requested role と effective role
    • child terminal status
    • expected output schema
    • worker による result consumption
    • join 後の parent continuation
    • write-capable tool call より前に join したこと
    • child-origin tool activity
    • GitHub remote mutation の不存在

    さらに #1842 の Stop Conditions には、Issue 自体が実施しなければならない nested delegation を「必要になったら停止する」という template residue が残っています。session matrix も no-investigation/codebase-only/web-only の三つだけで、同一 worker が両 result を順次消費する経路を検証しません。

    推奨 V1 に合わせ、各 runtime に次を追加すべきです。

    - session: sequential-both
      selected_agents:
        - codebase-investigator
        - web-researcher
      max_concurrent_investigation_agents: 1
      required_observations:
        - first_child_started_and_terminal
        - first_result_schema_validated
        - second_child_started_after_first_terminal
        - second_result_schema_validated
        - both_results_consumed
        - parent_post_join_continuation
        - no_tracked_mutation_before_barrier
        - no_test_runner_overlap

    証跡は native session JSONL または一次 runtime event を parser で抽出し、version、tested SHA、requested/effective role、start/terminal event、result digest、parent continuation marker、前後の repo/index/ref 状態を記録する必要があります。取得不能なら exit 77/environment blocker であり、fixture や agent の自己申告で代替してはいけません。

    「最初の tracked write より前」を実証するには、実リポジトリを汚さない disposable fixture repository/isolated worktree で、join 後に制御された mutation を行う canary が必要です。最後まで一度も write-capable action を発生させない session では、順序制約を証明できません。


    外部仕様との不整合

    Claude Code の上限に関する既存レビューの P1-5 は誤り

    現在の公式ドキュメントで subagent 利用を制御する上限は次の二系統です。

    • 深さ: CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH
    • 同時実行数: CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS

    現行既定は深さ3層、同時実行20体で、session 全体の総 spawn 数には上限がないと明記されています。既存レビューが記載した CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION と session-total 200 は現行仕様に存在しません。したがって、この点は現在の #1943 本文の Notes の方が正しく、REQUEST_CHANGES コメントをそのまま正本化してはいけません。([Claude]1)

    ただし既定深さは過去バージョンで変化しているため、#1842 は claude --version と effective depth/concurrency override を必ず記録すべきです。(Claude)

    Claude の agent-type 制約は宣言であり enforcement ではない

    Agent(codebase-investigator, web-researcher) の括弧内 type list は、agent が main thread として claude --agent で動く場合にだけ allowlist になります。nested subagent 定義内では type list が無視され、Agent tool 自体が許可されるだけです。したがって AC5 の「厳密に二者」は declared_allowed_agent_types に改称すべきです。([Claude]1)

    また Claude worker は permissionMode: acceptEdits です。公式仕様では親の acceptEdits が child frontmatter の permission mode より優先されるため、child の dontAsk や read-only prose を書込み防止の security boundary として扱えません。 ([Claude]1)


    read-only と result consumption の定義が不足している

    codebase-investigator は AGY request/result を /tmp に書き出します。したがって read-only を「filesystem write が一切ない」と定義すると、現行 agent contract と矛盾します。

    妥当な境界は次です。

    invocation-private な一時ファイルは許可する。一方で tracked repository content、Git index、Git refs、GitHub Issue/PR/comment/review/label/state を変更しない。

    web-researcher は filesystem read-only profile を持ちますが、自身の契約でも GitHub API の GET/POST を分離する remote-readonly security boundary ではないと認めています。そのため runtime evidence から主張できるのは「観測した invocation で mutation event がなかった」までです。

    さらに child output は同型ではありません。

    • codebase-investigator: CODEBASE_INVESTIGATION_RESULT_V1
    • web-researcher: WEB_RESEARCH_RESULT_V1

    両者は AGY-only route を使いますが、入力不足、provider failure、grounding failure、inconclusive などの failure semantics が異なります。worker は単に「terminal result を消費する」のではなく、agent type ごとの expected schema、terminal success、evidence completeness を検証し、非成功または設計判断に影響する結果競合があれば tracked mutation 前に停止する必要があります。

    また二つの evidence domain は論理的には異なりますが、どちらも AGY provider route に依存しています。二体失敗時には、native child spawn failure と AGY auth/capability/grounding/transport failure を別 failure class として記録すべきです。


    推奨する V1 契約

    READONLY_DELEGATION_POLICY_V1:
      schema_version: 1
      scope: agent_local_capability_contract
      graph_policy: false
    
      applies_to_modes:
        - normal_implementation_v1
    
      selection:
        declared_allowed_agent_types:
          - codebase-investigator
          - web-researcher
        max_selected_agents: 2
        max_instances_per_agent_type: 1
        selection_basis: required_evidence_domain
    
      scheduling:
        max_concurrent_investigation_agents: 1
        execution: sequential
        test_runner_counts_toward_selection_limit: false
        test_runner_may_overlap_active_investigation: false
    
      invocation_gate:
        starts_after:
          - live_issue_contract_bound
          - canonical_worktree_bound
          - branch_bound
          - tested_head_bound
        completes_before:
          - first_allowed_path_tracked_content_mutation
    
      expected_results:
        codebase-investigator:
          schema: CODEBASE_INVESTIGATION_RESULT_V1
        web-researcher:
          schema: WEB_RESEARCH_RESULT_V1
        require_terminal_success: true
        require_evidence_complete: true
        require_all_selected_results: true
    
      failure_policy:
        failed: block_before_tracked_mutation
        inconclusive: block_before_tracked_mutation
        insufficient_context: block_before_tracked_mutation
        role_mismatch: block_before_tracked_mutation
        schema_mismatch: block_before_tracked_mutation
        result_conflict_affecting_contract_or_design: human_escalation
    
      mutation_boundary:
        invocation_private_temp_files: allowed
        tracked_repository_content: prohibited
        git_index: prohibited
        git_refs: prohibited
        github_state: prohibited
    
      child_authority:
        reinterpret_live_issue_contract: prohibited
        expand_allowed_paths: prohibited
        change_acceptance_criteria: prohibited
    
      enforcement_claim: behavioral_only

    並行二体を後続で導入する場合は、max_concurrent_investigation_agents: 2 だけを安易に変えるのではなく、#1842 に parallel dual-session、全 child completion barrier、partial-failure、result conflict、test-runner non-overlap、Codex slot exhaustion の runtime test を追加する必要があります。


    追加すべき Runtime Verification セクション

    ## Runtime Verification Applicability
    
    decision: deferred
    owner_issue: "#1842"
    reason: >
      本Issueはimplementation-workerの静的なagent-local policy、
      parser、parity comparator、negative testを実装する。
      native spawn/join、effective role、result consumption、
      parent continuation、non-mutationの実測は#1842が所有する。
    
    required_runtime_sessions:
      - no-investigation
      - codebase-only
      - web-only
      - sequential-both
    
    required_evidence:
      - cli_version
      - tested_head_sha
      - effective_depth_and_concurrency_limits
      - requested_and_effective_agent_type
      - child_start_and_terminal_events
      - expected_result_schema_and_status
      - parent_post_join_continuation
      - first_write_capable_event_order
      - repository_index_refs_before_after
      - github_mutation_event_inventory
    
    fallback_policy: >
      prose、fixture、TOML、自己申告をruntime PASSへ昇格しない。
    
    unavailable_policy: environment_blocker

    Approve 条件

    1. 導入: Codex CLI Multi-Agent V2 へ移行し、明示的な委譲グラフとbounded nested delegation harnessを導入する #1833・実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943・実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 の child topology、dependency chain、対象 agent、cardinality を同時に同期する。
    2. Runtime Verification Applicability: deferred を 実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 に追加し、実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 を実行可能な canary contract に修正する。
    3. selection 数と concurrency 数を別キーにし、V1 は「最大二体選択・同時一体」にするか、最大一体を維持する明示的な fail-closed 理由を記載する。
    4. policy を agent-local schema として versioning、closed-key validation、consumer inventory、compatibility decision の対象にする。
    5. implement-issue に Investigation Gate を追加し、Claude の V2 PR repair mode を policy 対象外に固定する。
    6. whole-agent parity ではなく、delegation-policy dimension の strict comparator と negative testsを実装する。
    7. 実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842 の runtime evidence を native event/session log parser による machine-verifiable な証跡へ置き換える。
    8. 既存 REQUEST_CHANGES コメントの CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION/session-total 200 の誤情報は採用しない。
  8. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    Blockers

    1. 現行本文に ## Runtime Verification Applicability がなく、決定論的レビューが C9 blocker を返した。
    2. 指定 OWNER コメントは、導入: Codex CLI Multi-Agent V2 へ移行し、明示的な委譲グラフとbounded nested delegation harnessを導入する #1833・調査: Codex network_proxy enforcement の実効性を実測する #1942 ではなく 実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842・実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 をまたぐ dependency/cardinality 同期、0〜2 の選択数、順次実行上限、追加 consumer/test surface を要求する。これは現行 実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 の In Scope / Allowed Paths を実質的に拡張する。
    3. preflight の normalized scope-delta authority は no_anchor_scope_reframe_v1_payload を返した。自由記述の REQUEST_CHANGES を、cross-issue mutation と Allowed Paths 拡張の確定指示として推測できない。
    4. 追加で、Required Design References の existing design-doc 記載、VC の baseline annotation、allowlist 外の uv run python3 VC 正規化が必要と判定された。

    次に必要な OWNER 決定

    #1943 に ANCHOR_SCOPE_REFRAME_V1 を投稿し、最終 V1(選択数・同時実行数・順次/並行方針)、正確な Allowed Paths の差分、#1833 / #1842 の同期を本 Issue の mutation に含めるか別 Issue に分けるか、再実行対象を明示してください。受領後、fresh preflight から controlled rewrite・readback・再レビューを再開します。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
  9. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    訂正: issue-refinement-loop termination report

    直前の終了報告の Blocker 2 にある #1833・#1942 は誤記です。正しくは #1833・#1842・#1943 の dependency/cardinality 同期です。

    それ以外の termination route、human_judgment_required、および ANCHOR_SCOPE_REFRAME_V1 を要する判断は変更ありません。

  10. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    結論

    今回、人間に ANCHOR_SCOPE_REFRAME_V1 を手書きさせる必要はありません。

    #5229806061 には、少なくとも実装契約の主要な判断がすでに記載されています。

    • 選択数は 0〜2

    • codebase-investigator と web-researcher はそれぞれ最大1体

    • investigation agent の同時実行数は1

    • 両方必要な場合は順次実行

    • 選択した全調査結果を検証してから実装へ進む

    • 並行2体は、別の runtime canary を通した後に検討する

    したがって不足しているのは人間の判断ではなく、自然言語の OWNER 指示を、正確な Allowed Paths を含む型付き authority に変換する機械処理です。現行 #1943 本文は依然として「最大1体・どちらか一方」を前提としており、OWNER コメントと不整合です。

    また、途中報告の「authority が router に接続されていない」という表現は断定が強すぎました。追加調査では、最終 router には scope-signal-guard-decision-v2 を受け取り、contract_update_required へ進む分岐が存在します。今回の記録だけでは、次のどこで途切れたかを特定できません。

    1. authority sidecar が生成されなかった

    2. 生成されたが最終 router に渡されなかった

    3. cross-issue mutation または exact Allowed Paths 不足により classifier 自体が escalation を返した

    終了報告に sidecar の action、reason、入力ハッシュ、router への受渡し結果が出ていないためです。この観測可能性不足そのものが workflow defectです。

    あるべき authority workflow

    現行設計にも、自由記述の OWNER directive を SCOPE_DELTA_AUTHORITY_EVIDENCE_V1 に正規化する互換経路と、対話中の人間指示を provenance 付きで materialize する経路があります。ANCHOR_SCOPE_REFRAME_V1 は厳格な schema を持ちますが、人間がその内部形式を覚えて直接作ることを通常経路にすべきではありません。

    正常な設計は次です。

    人間:
      目的、選択、制約、許容する変更範囲を自然言語で提示
           ↓
    機械:
      source / author / comment ID / body hash を固定
           ↓
    機械:
      repo consumer inventory から exact Allowed Paths delta を算出
           ↓
    機械:
      schema-valid ANCHOR_SCOPE_REFRAME_V1 を生成
      + direct_interactive_human_instruction の provenance を付与
           ↓
    機械:
      人間の指示と生成 payload の semantic equivalence を検証
           ↓
    機械:
      fresh preflight → controlled rewrite → readback → final review
    

    つまり、責任分界は次であるべきです。

    • 人間の責任: 意図、目的、リスク許容度、実質的な選択

    • 機械の責任: schema、正確な path、hash、provenance、再実行手順

    • 人間へ戻す条件: 互いに矛盾する選択、破壊的変更、秘密情報、権限拡張など、意味論上の未決事項だけ

    「schema がないから人間判断」という現在の終了理由は、この責任分界が逆転しています。

    #1943 に対する推奨アクション

    #1943 は、次の契約で controlled rewrite を再実行するのが妥当です。

    項目 | 採用値 -- | -- 許可する調査 agent | codebase-investigator, web-researcher 選択数 | 0〜2 同型 agent 数 | 最大1 investigation 同時実行数 | 最大1 両方必要な場合 | 順次実行 選択基準 | 必要な evidence domain 実装開始条件 | 選択した全結果が terminal・valid・関連性確認済み test-runner | investigation 数には含めないが、active investigation とは重複させない 並行2体 | #1943 には含めず、別 runtime canary 後に検討

    現行 validator は、approve/needs-fix の9フィールド envelope を字句・順序・サイズ面で検証します。しかし ARTIFACT: のパスを open、stat、schema validation、hash verification していません。したがって、B が正しく、C が存在しなくても validator 単体は通過し得ます。一方、B が空なら validator-first は成立せず、verdict を消費してはいけません。

    確定していること

    別セッションの一文から確定できるのは、canonical compact stdout が親 orchestrator に渡らなかったことだけです。

    確定できないこと

    次は現存する証拠だけでは確定できません。

    • reviewer が semantic review を完了していたか

    • compactor が起動されたか

    • artifact 書込みだけが失敗したか

    • hook がコマンドを遮断したか

    • timeout、signal、process crash のどれだったか

    • stdout が生成されたが親側の capture で失われたか

    現行 compactor は、schema 不正や artifact 書込み失敗などの処理可能な失敗時にも、5行の canonical producer-failure envelope を stdout に出す設計です。したがって完全な空出力であったなら、通常の compactor 内エラーよりも、次の可能性が強くなります。

    1. compactor が呼び出される前に reviewer が終了した

    2. hook または permission boundary が command を拒否した

    3. timeout・signal・強制終了が発生した

    4. 親 orchestrator が child stdout を捕捉しなかった

    5. reviewer が compactor stdout 以外の応答を返し、wrapper が破棄した

    これは推論であり、exit code、stderr、signal、timeout、stdout length、実行 command がないため一つには絞れません。

    過去の別事例では、未知の compact field を追加したことで validator が拒否したケースと、PreToolUse/local-main guard がレビュー関連 command を遮断したケースが存在します。ただし、これらは今回の直接原因を証明するものではなく、必要な failure taxonomy が不足していることを示す類例です。

    成果物は必須か

    反証的に分けると、次の結論になります。

    compact stdout envelope は必須です。

    validator-first の目的は、reviewer の自由文を直接信頼せず、制限された wire format のみを routing に使うことです。これを省くと、prompt injection、未知 field、field-order drift、oversized output、未検証 verdict を直接消費することになります。

    完全な artifact JSON は、routing のためだけなら必須ではありません。

    VERDICT、BLOCKERS、NEXT_ACTION、body SHA が compact envelope に収まれば、最小 routing は可能です。artifact をなくせば filesystem、permission、path traversal、stale file に由来する故障面を減らせます。

    しかし audit/replay のためには完全な artifact を残す価値があります。

    2,048 byte の envelope だけでは、finding ごとの evidence、詳細な remediation、レビュー再現性、障害分析に不足します。したがって推奨は「artifact を廃止」ではなく、次です。

    • approve/needs-fix verdict では完全 artifact を必須にする

    • validator 後に親 orchestrator が artifact を検証する

    • regular file、expected root 内、symlink escape なしを確認する

    • JSON schema、reviewed body SHA、artifact SHA-256 を確認する

    • envelope に ARTIFACT_SHA256 と ATTEMPT_ID を追加する

    • producer failure では、reviewer 自身の artifact に依存せず、親 wrapper が attempt ledger を必ず生成する

    なお、producer の自己記述と field constant は8フィールドのままですが、実際の成功 envelope と validator は REVIEWED_BODY_SHA256 を含む9フィールドです。これが今回の空出力原因とは断定できませんが、契約ドリフトとして修正対象です。


    Claude Code / Codex CLI に渡す実行プロンプト

    この応答環境からリポジトリ内の Codex multi-agent runtime を直接 spawn する手段はないため、ここで Spark を実行したとは主張しません。以下では spark-deep を優先的に直接起動することを必須化しています。現行設定では spark-deep は gpt-5.3-codex-spark / high ですが、GitHub mutation、loop orchestration、最終 verdict、nested delegation は禁止されているため、調査・反証・inventory に限定します。

    あなたは squne121/loop-protocol の root control-plane として動作する。
    

    TARGET

    OBJECTIVE
    Issue #1943 の issue-refinement-loop を fresh live state から再実行し、
    人間への中間承認要求なしで、以下を完了する。

    1. OWNER directive の authority 正規化
    2. exact minimal Allowed Paths の確定
    3. #1943 本文の controlled rewrite
    4. GitHub readback と body SHA 検証
    5. canonical final reviewer と validator-first 判定
    6. valid needs-fix の自動修正ループ
    7. approve または真の環境・安全停止条件まで実行
    8. #1833 / #1842 同期を対象 Issue から分離し、必要な follow-up Issue を重複確認後に作成・関連付け

    このプロンプト自体を direct_interactive_human_instruction として扱う。
    ユーザーに ANCHOR_SCOPE_REFRAME_V1 の YAML、Allowed Paths、schema field を
    手作業で作らせてはならない。

    NO INTERMEDIATE APPROVAL
    次の操作は追加承認なしで実行する。

    • Issue/comment/PR/関連 Issue の read
    • repository の read-only inventory
    • gpt-5.3-codex-spark subagent の read-only 起動
    • #1943 本文の controlled update
    • provenance 付き authority comment の投稿
    • termination/result comment の投稿
    • 重複のない follow-up Issue の作成と相互リンク
    • readback、hash 検証、review retry

    STOP CONDITIONS
    次の場合だけ停止する。

    • secret、credential、token、個人情報の取得・露出が必要
    • 新たな権限付与または permission boundary の拡張が必要
    • 外部課金が発生する
    • 不可逆な destructive operation が必要
    • GitHub write authorization が実際に拒否され、許可された代替経路もない
    • 二つ以上の信頼済み OWNER 指示が実質的に矛盾し、機械的優先順位で解決できない
    • 対象 repository または Issue identity が一致しない

    以下は停止条件ではない。

    • 人間が ANCHOR_SCOPE_REFRAME_V1 を投稿していない
    • exact Allowed Paths が最初から列挙されていない
    • Runtime Verification セクションがない
    • baseline annotation がない
    • VC command が非正規形
    • reviewer の空 stdout、malformed envelope、producer failure
    • artifact write failure
    • valid needs-fix
    • cross-issue 同期が必要だが、follow-up Issue に分離できる
    • deterministic repair が可能

    LIVE-STATE LOCK
    最初に GitHub live state を取得し、以下を記録する。

    • #1943 title/body/state/updatedAt/body SHA-256
    • comment #5229806061 author/association/body hash/createdAt
    • termination comment #5229820867
    • correction comment #5229822323
    • #1833 と #1842 の live body/state/dependencies
    • #1943 に関連する open/closed PR と follow-up Issue
    • repository main SHA
    • current checkout/worktree status

    #5229822323 の訂正を適用し、同期対象の番号は
    #1833 / #1842 / #1943 とする。#1942 をこの同期対象に含めない。

    SUBAGENT POLICY
    gpt-5.3-codex-spark を優先的に使う。

    canonical agent:

    • agent_type: spark-deep
    • configured model: gpt-5.3-codex-spark
    • reasoning: high
    • invocation: root から直接
    • execution: sequential
    • nested delegation: 禁止
    • GitHub mutation: 禁止
    • final verdict: 禁止

    最低3回、独立した Spark read-only audit を実行する。

    SPARK-1: authority / routing audit

    • ANCHOR_SCOPE_REFRAME_V1 schema
    • scope-signal-guard
    • trusted freeform directive compatibility
    • SCOPE_DELTA_AUTHORITY_EVIDENCE_V1
    • contract_update_required route
    • preflight → sidecar → decide_next_loop_action の binding
    • 今回の termination telemetry で欠けている情報
      を調査し、SPARK_AGENT_RESULT_V1 で返す。

    SPARK-2: consumer and exact-path inventory

    • #1943 の final V1 を実装する全 producer/consumer/checker/schema/fixture/test/doc を列挙
    • 各ファイルを read-only / modification-required に分類
    • modification-required のものだけを exact Allowed Paths delta 候補にする
    • wildcard、directory placeholder、推測 path を禁止
    • current issue body の Allowed Paths と差分を返す
    • .claude/skills/implement-issue/SKILL.md と対応テストを必ず調査対象にする
    • expected-runtime-contract、parity checker、agent inventory、launch ledger、
      permission/config checker の downstream consumer を確認する

    SPARK-3: reviewer transport / artifact audit

    • issue-reviewer invocation path
    • compact_review_result.py
    • validate_review_compact_output.py
    • stdout capture
    • hook/permission/timeout boundary
    • artifact write and readback
    • 8-field/9-field contract drift
    • empty stdout 時の現在の route
      を反証的に調べる。
      Spark は final reviewer の代替になってはならない。

    AUTHORITY MATERIALIZATION
    #5229806061 を semantic OWNER authority とする。

    次の最終 V1 は既決事項として扱う。

    • allowed_agent_types:
      • codebase-investigator
      • web-researcher
    • selected investigation agents: 0..2
    • max instances per agent type: 1
    • max concurrent investigation agents: 1
    • execution when both domains are needed: sequential
    • selection basis: required evidence domain
    • implementation may start only after every selected result is:
      • terminal
      • schema-valid
      • relevant to the current issue snapshot
      • checked for conflicting conclusions
    • test-runner is not counted as an investigation agent
    • test-runner must not overlap an active investigation agent unless a separately
      approved contract explicitly permits it
    • parallel investigation concurrency 2 is not part of #1943 V1
    • parallelism 2 requires a separate native runtime canary

    まず freeform trusted-directive compatibility route を実行する。
    それが exact-path authority として contract_update_required を返す場合は、その route を使用する。

    exact Allowed Paths 不足だけが理由で route が成立しない場合は、
    SPARK-2 と root inventory から exact minimal delta を生成する。

    その後、repository の canonical schema と reference を読み、
    schema-valid な ANCHOR_SCOPE_REFRAME_V1 を機械生成する。
    このプロンプト中の概念例から schema shape を推測してはならない。
    必ず repository 内 schema を SSOT とする。

    生成 payload には少なくとも次の semantic content を入れる。

    • target repo: squne121/loop-protocol
    • target issue: 1943
    • decision: approve_scope_delta
    • exact allowed-path deltas
    • final V1 rationale
    • required reruns:
      • contract_review
      • refinement_preflight
      • allowed_paths_gate

    canonical reference に従い、
    OWNER_DIRECTIVE_MATERIALIZED_FROM_INTERACTIVE_PROMPT_V1 provenance を付与する。

    provenance には次を保持する。

    • source_kind: direct_interactive_human_instruction
    • semantic source comment ID: 5229806061
    • correction comment ID: 5229822323
    • source body hash
    • generated payload hash
    • exact-path inventory hash
    • materializer version

    placeholder、TODO、glob、未確定 path を含む authority comment を投稿してはならない。
    投稿後に GitHub readback し、payload/schema/hash を再検証する。

    CROSS-ISSUE POLICY
    一つの controlled mutation で #1833、#1842、#1943 の本文を同時編集しない。

    この実行では #1943 だけを rewrite target とする。

    重複検索後、必要なら以下の follow-up Issue を作成する。

    A. #1833 parent rollup sync

    • #1943 final V1 の 0..2 selection
    • sequential max concurrency 1
    • dependency/rollup/cardinality
    • child Issue linkage
      を parent contract に同期する。

    B. #1842 runtime canary sync

    • no-investigation
    • codebase-only
    • web-only
    • both selected and sequential
      の native runtime matrix を定義する。
      simulation、mocked spawn、self-reported success だけで PASS にしない。

    C. parallel concurrency 2 canary
    既存 Issue がなければ独立 Issue にする。
    #1943 V1 の完了条件には含めない。

    各 follow-up Issue を #1943 にリンクする。
    #1943 の Closes/Depends-on semantics を壊さない。

    ISSUE #1943 REWRITE REQUIREMENTS
    現行本文を保存した上で、controlled issue editor を使用して rewrite する。

    本文に最低限、次を含める。

    1. Outcome
    • normal implementation path における bounded read-only investigation parity
    • repair/recovery path は、明示的な適用契約がない限り対象外
    1. Final V1 policy
    • 0..2 selection
    • max one per type
    • max concurrency 1
    • sequential execution
    • all-results-valid-before-write gate
    1. Investigation Gate
      Issue binding と snapshot validation 後、最初の tracked write より前に置く。
      未選択 agent を暗黙に起動してはならない。
      選択された全 agent の validated result が揃うまで implementation_go=false とする。

    2. Machine-readable contract

    • producer
    • consumer
    • exact schema fields
    • unknown-field rejection
    • missing-field rejection
    • integer/boolean/list semantics
    • fail-closed behavior
    • runtime projection
    1. Required Design References
      既存 repository design docs、skills、agent contracts、checker contracts を
      実在確認した上で参照する。
      存在しない文書を捏造しない。

    2. Runtime Verification Applicability
      repository の canonical section format を使用する。

    runtime behavior 自体は applicable とするが、
    #1943 では static/schema/contract verification を行い、
    native launch/join canary は #1842 follow-up に委譲することを明示する。

    deferred verification には以下を記載する。

    • responsible follow-up Issue
    • required runtime matrix
    • evidence artifact
    • fixed base/head SHA
    • success/failure criteria
    • simulated evidence を不可とする条件
    1. Allowed Paths
      SPARK-2 と root inventory が modification-required と判定した exact path のみ。
      reader であるだけのファイルを無条件に追加しない。
      変更が必要なのに allowlist 外となる consumer を残さない。

    2. Acceptance Criteria
      少なくとも以下を含める。

    • 0, 1, 2 agent selection
    • same-type duplicate rejection
    • concurrency >1 rejection
    • sequential ordering
    • result validation before implementation
    • missing/unknown/malformed policy field rejection
    • Claude/Codex parity
    • fixture/schema/checker consistency
    • implementation skill consumer behavior
    • stale snapshot rejection
    • negative tests
    • follow-up runtime dependency
    1. Verification Commands
      各 command を repository の command registry / allowlist と照合する。
      uv run python3 等を推測で使用しない。
      registry が要求する --locked、working directory、対象 path を反映する。
      baseline で失敗する VC には repository canonical syntax の
      baseline-expect annotation を付ける。
      base/head path gate は symbolic main ではなく fixed SHA で評価できる形にする。

    PREFLIGHT AND CONTROLLED REWRITE
    authority materialization 後、必ず fresh に以下を再実行する。

    • contract review
    • refinement preflight
    • allowed paths gate
    • stale snapshot gate
    • command registry validation
    • deterministic reviewer

    古い preflight、古い body SHA、古い review artifact を再利用しない。

    rewrite 前後で以下を記録する。

    • old body SHA
    • authority payload SHA
    • rewrite plan SHA
    • exact changed sections
    • new body SHA
    • GitHub readback SHA
    • updatedAt
    • target issue number

    readback が一致しなければ mutation success として扱わない。

    FINAL REVIEWER POLICY
    最終 verdict を出せるのは canonical issue-reviewer だけとする。
    Spark の結論を verdict に代用しない。

    reviewer child の raw stdout bytes を、解釈前に保存する。
    最低限、各 attempt について次を記録する。

    • attempt_id
    • reviewer agent/config
    • issue body SHA
    • start/end monotonic timestamp
    • exit code
    • terminating signal
    • timeout flag
    • stdout byte length
    • stdout SHA-256
    • stderr byte length
    • stderr SHA-256
    • invoked command
    • hook/permission denial classification
    • produced artifact path
    • artifact existence/schema/SHA result

    VALIDATOR-FIRST
    raw stdout bytes を byte-exact で validator に渡す。
    validator 成功前に VERDICT、NEXT_ACTION、ARTIFACT を読まない。

    valid approve:

    • artifact integrity gate を通した後に完了

    valid needs-fix:

    • configured max iteration まで自動 rewrite/review
    • 人間承認を求めない

    empty stdout:

    • reviewer_transport_empty_stdout

    malformed envelope:

    • reviewer_transport_malformed_envelope

    canonical producer failure:

    • reviewer_producer_failure

    artifact missing/write failure:

    • reviewer_artifact_write_failure

    artifact schema/hash/body-SHA mismatch:

    • reviewer_artifact_integrity_failure

    これらを human_judgment_required に分類しない。

    REVIEWER RECOVERY
    transport/producer/artifact failure 時は次を実行する。

    Attempt 1 failure:

    1. verdict を消費しない
    2. parent-owned REVIEWER_ATTEMPT_LEDGER_V1 を生成
    3. same canonical reviewer を clean foreground context で1回再実行

    Attempt 2 failure:

    1. verdict を消費しない
    2. SPARK-3 の read-only transport audit を実行
    3. fresh canonical issue-reviewer instance で1回再実行

    Attempt 3 failure:

    • environment_failure として controlled termination
    • human_judgment_required と記録しない
    • exit/stdout/stderr/hook/timeout/artifact ledger をコメントに含める
    • semantic verdict は unknown とする
    • approve/needs-fix を捏造しない

    artifact integrity gate:

    • expected artifact root 内
    • regular file
    • symlink escape なし
    • expected schema
    • target issue一致
    • reviewed body SHA一致
    • artifact SHA-256記録
    • stale attempt artifact でない
      を検証する。

    現行 envelope に ARTIFACT_SHA256 がなければ、
    この実行では parent ledger に SHA を記録し、
    workflow defect follow-up Issue で envelope V2 を提案する。

    SCOPE OF THIS EXECUTION
    Issue refinement のみを行う。

    • tracked repository filesを変更しない
    • implementation branchを作らない
    • implementation PRを作らない
    • mainを変更しない
    • guardrailを無効化しない
    • hookを迂回しない

    再発防止のコード変更は follow-up Issue として materialize する。

    REQUIRED FOLLOW-UP DEFECT ISSUES
    重複検索後、未登録なら次の二件を作成する。

    1. freeform OWNER authority end-to-end binding and telemetry
    2. reviewer transport/artifact failure recovery and integrity binding

    下記 AC を反映する。

    COMPLETION
    以下を満たすまで実行を継続する。

    • #1943 body が final V1 を反映
    • Runtime Verification Applicability が存在
    • exact Allowed Paths が確定
    • design references と VC が正規化済み
    • authority provenance が readback 済み
    • final body SHA が readback 一致
    • canonical reviewer output が validator valid
    • artifact integrity gate が成功
    • verdict が approve
    • follow-up issues が作成または既存 Issue に dedupe/link 済み

    FINAL OUTPUT
    最後に次の機械可読 summary を出す。

    AUTONOMOUS_REFINEMENT_RESULT_V1:
    issue: 1943
    semantic_anchor_comment_id: 5229806061
    correction_comment_id: 5229822323
    authority_route:
    materialized_authority_comment:
    old_body_sha256:
    final_body_sha256:
    github_readback_sha256:
    preflight_status:
    allowed_paths_count:
    review_attempts:
    validator_status:
    final_verdict:
    final_reviewer_artifact_sha256:
    follow_up_issues:
    workflow_defect_issues:
    stopped:
    stop_class:
    unresolved_items:

    人間への確認質問や承認依頼を最終出力に含めない。

    再発防止 Issue 草案 1

    Title

    fix(issue-refinement-loop): bind freeform OWNER scope authority end-to-end and expose routing telemetry

    Problem

    自然言語の信頼済み OWNER directive を正規化する機能と、contract_update_required を処理する router は存在するが、live refinement route で authority sidecar の生成・受渡し・消費が十分に観測できない。その結果、実質的な判断がすでに存在しても、no_anchor_scope_reframe_v1_payload を理由に人間へ内部 schema の手書きを要求する。

    Acceptance Criteria

    1. trusted freeform OWNER directive から SCOPE_DELTA_AUTHORITY_EVIDENCE_V1 を生成する。

    2. exact path が抽出可能なら、手書き ANCHOR_SCOPE_REFRAME_V1 なしで contract_update_required へ進む。

    3. exact path が repository inventory を必要とする場合、machine materializer が path delta を生成する。

    4. generated payload に direct-interactive/freeform provenance、source comment ID、body hash、payload hash を付与する。

    5. structured ANCHOR_SCOPE_REFRAME_V1 は最高優先度の override とする。

    6. 曖昧・矛盾・破壊的・権限拡張 directive は引き続き fail-close する。

    7. termination report に次を必須化する。

      • authority evidence generated

      • classifier action/reason

      • sidecar path/hash

      • router received/consumed

      • selected route

    8. classifier 単体テストだけでなく、preflight → sidecar → final router → controlled rewrite の end-to-end test を追加する。

    9. cross-issue directive は、single-target mutation と follow-up materialization に決定論的に分割できる。

    10. 人間へ要求するのは semantic ambiguity の解決だけとし、schema/path/hash の生成を要求しない。

    再発防止 Issue 草案 2

    Title

    fix(issue-refinement-loop): recover reviewer transport failures and cryptographically bind compact verdicts to artifacts

    Problem

    現在の validator-first は compact stdout の妥当性を検証するが、空出力・process failure・stdout capture failure・artifact failure の原因分類と自動復旧が不足している。また、ARTIFACT: path は envelope に必須である一方、validator は file existence、schema、reviewed body SHA、content hash を検証しない。

    Acceptance Criteria

    1. 各 reviewer attempt について exit code、signal、timeout、stdout/stderr length/hash、command、hook denial を保存する。

    2. failure class を最低限次に分離する。

      • reviewer_transport_empty_stdout

      • reviewer_transport_malformed_envelope

      • reviewer_producer_failure

      • reviewer_artifact_write_failure

      • reviewer_artifact_integrity_failure

    3. transport/producer/artifact failure は semantic human_judgment_required に分類しない。

    4. same-instance clean retry と fresh-instance retry を bounded に実行する。
      5.全 retry 失敗後は environment_failure とし、semantic verdict を未確定のまま保持する。

    5. compact envelope V2 に ATTEMPT_ID と ARTIFACT_SHA256 を追加する。

    6. 親 orchestrator が artifact の実在、regular-file、root confinement、schema、issue number、body SHA、artifact SHA を検証する。

    7. producer が起動しない場合でも、親 wrapper が attempt ledger と canonical failure record を必ず生成する。

    8. compactor の docstring、field constant、producer、validator、tests を単一の9-field/V2 SSOTに統一する。

    9. 次の fault-injection tests を追加する。

      • empty stdout

      • process kill

      • timeout

      • hook rejection

      • permission denied

      • malformed/extra/missing field

      • output over wire limit

      • artifact missing

      • symlink escape

      • schema mismatch

      • body SHA mismatch

      • artifact hash mismatch

      • first-attempt failure followed by retry success

    この二件を分離すれば、人間判断に残るのは本来の semantic ambiguity だけになり、authority の形式変換と reviewer transport 障害は control-plane が自律処理できます。

  11. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    以下の authority は、#5229806061 の semantic OWNER directive、#5229822323 の対象番号訂正、およびこのセッションで受領した direct interactive human instruction を、現行 repository schema と current-main consumer inventory に従って機械 materialize したものです。人間が schema/path/hash を手書きしたものではありません。

    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 1943
    decision: approve_scope_delta
    allowed_path_deltas:
      - .claude/skills/implement-issue/SKILL.md
    rationale: "OWNER directive #5229806061 と direct interactive human instruction に従い、normal implementation V1 の Investigation Gate を実行 consumer に追加する。exact paths は current main の consumer inventory から導出し、#1833/#1842 同期は separate follow-up に分離する。"
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate

    authority は implementation go を与えません。controlled rewrite 後に、fresh contract review、refinement preflight、Allowed Paths gate、final reviewer を実行します。

  12. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    Autonomous refinement result (environment failure)

    tracked repository files、implementation branch、implementation PR、main は変更していません。

  13. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    Refinement final review result

    issue: 1943
    github_body_sha256: efb6a7115099da2e0eb0af26a2dc64f032ab613037fa5e15be5f240693f20741
    reviewed_body_sha256_normalized: 3b7dba5a2718de680c9d975bea56a46bff8873e1403939adc6ccfbdb605b0ff6
    preflight_status: pass
    compact_validation_status: valid
    final_semantic_verdict: approve
    review_artifact: .claude/artifacts/issue-refinement-loop/1943/compact_review_result_20260809T092752Z.json
    review_artifact_sha256: 1fa4b936dfd6cc2e7e87813f55a7f5159487153562d375c275f1394f5165e40c
    implementation_go: false
    implementation_gate_status: blocked
    blocker_class: environment_failure
    blocker: web-researcher grounded_research capability_unavailable

    final reviewer は current live snapshot に対して approve を返し、compact envelope は validator-first で valid でした。reviewer の body SHA は本文末尾改行を正規化した値であり、GitHub API body SHA と同一 content を表します。

    ただし planner が要求した web-researcher は、machine-verifiable grounded-research trace を取得できず capability_unavailable で terminal failure になりました。#1943 の Investigation Gate に従い、selected evidence が検証可能になるまで tracked content mutation、implementation branch、PR は開始しません。

    既存 follow-up: #2053(authority telemetry)、#2054(reviewer transport/artifact)。今回の failure は web-research capability であり、両 Issue の重複対象にはしません。

  14. squne121 commented on Aug 9, 2026

    @squne121
    OwnerAuthor

    調査結果から、#1943 をそのまま再実行するのは推奨しません。現在の environment_failure は記録として妥当ですが、実態は一時障害より grounded_research capability probe の設計上の不整合である可能性が高いです。

    Google Antigravity CLI は公式 changelog 上、v1.1.8 で agy -p --output-format stream-json を正式実装しており、init → step_update* → result の NDJSON と tool payload を提供します。したがって、PR #2043 で実測された v1.1.11 系環境に対し「structured output capability 自体が存在しない」と考える根拠は弱いです。 ([Google Antigravity]1)

    一方、loop-protocol の現在の capability 判定は、help だけでは supported にせず、実 agy -p ... --output-format stream-json semantic probe が成功した場合だけ supported へ昇格します。その probe は temporary/empty HOME と縮小環境変数で起動されています。しかも同じ preflight_agy.py は、AGY の認証情報を $HOME/.gemini/antigravity-cli/antigravity-oauth-token から検出する実装を持っています。つまり、能力を実証するための probe が、自分で認証経路を隔離してしまっている構造が強く疑われます。

    これは上流仕様とも整合します。Antigravity CLI 公式は system keyring を認証に利用し、未認証時は Google Sign-In へフォールバックします。また headless 実行では D-Bus/keyring や OAuth の扱いが明示的に修正されており、完全な headless 状態で認証がなければ fail-fast する仕様です。 ([GitHub]2)

    さらに 第二の blocker もあります。現在の web-researcher.md は critical claim の evidence が 0 件なら grounding_failure とする一方、provider source → claim の対応付けは false grounding 防止のため #2042 完了まで意図的に実施しない契約です。 #2042 はまさに stable source_id による deterministic claim-source relation を実装する open Issue です。 したがって capability だけ直して #1943 を再実行しても、critical claim を要求する調査なら次に grounding_failure へ進む可能性があります。

    また #1943 の Allowed Paths には preflight_agy.py や grounded-research runner が含まれていません。新規 Issue が必要になった場合も明示的な Stop Condition です。よって #1943 の scope を拡張して直すのではなく、grounded-research capability defect を独立 Issue で直す → #2042 → #1943 再開の直列順が妥当です。現在の #1943 final result は approve だが implementation_go: false と正しく記録されています。

    推奨順序は、① capability failure の exact reason_code を read-only で採取、② empty-HOME/auth isolation が原因なら専用 Issue を起票して修正、③ #2042 を完了、④ 同じ #1943 body SHA に対して web-researcher だけを fresh rerun、⑤ terminal/schema/snapshot/evidence/conflict gate がすべて通った場合だけ implementation_go=true にする、です。Direct WebSearch/WebFetch や Gemini への fallback で通すのは、現行 web-researcher 契約を破るため避けるべきです。

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

    #1943 implementation blocker diagnosis / recovery

    対象:

    • repository: squne121/loop-protocol

    • Issue: #1943

    • refinement result comment: #5230822070

    • expected live body SHA-256:
      efb6a7115099da2e0eb0af26a2dc64f032ab613037fa5e15be5f240693f20741

    • expected review artifact SHA-256:
      1fa4b936dfd6cc2e7e87813f55a7f5159487153562d375c275f1394f5165e40c

    • current state:

      • preflight: pass
      • contract validation: go
      • final semantic verdict: approve
      • compact validator: valid
      • implementation_go: false
      • blocker: web-researcher grounded_research capability_unavailable
      • stop class: environment_failure

    Goal

    #1943 の実装を開始するのではなく、web-researcher の
    grounded_research capability_unavailable の root cause を
    一次 evidence で確定し、必要なら専用 follow-up Issue を作成して
    blocker を解消可能な状態へ持っていく。

    #1943 の tracked content、implementation branch、PR は、
    Investigation Gate が成立するまで作成・変更しないこと。

    Important upstream fact to verify

    Google Antigravity CLI の公式 changelog / repository を必ず再確認すること。

    現行公式仕様では v1.1.8 以降の print mode が

    --output-format text|json|stream-json

    を提供し、stream-json は少なくとも

    init -> step_update* -> terminal result

    という NDJSON event stream と tool payload を提供する。

    公式一次情報以外のブログ等は補助情報に限定する。

    したがって、インストール済み AGY が対象機能を持つバージョンである場合、
    単純な「upstream capability missing」と決めつけないこと。

    Phase 1 — fresh binding / evidence collection

    最初に GitHub と current checkout を fresh read し、以下を確認する。

    この段階では tracked file を一切変更しない。

    Phase 2 — exact capability failure classification

    capability_unavailable という粗い結果だけで停止せず、
    producer が持つ最も具体的な以下の evidence を回収する。

    • capability status
    • reason_code
    • evidence_source
    • binary realpath
    • binary SHA-256
    • version
    • help probe exit code
    • help probe stdout/stderr classification
    • semantic probe attempted: yes/no
    • semantic probe exit code
    • semantic probe timeout
    • auth failure classification
    • quota/rate-limit classification
    • parser verdict
    • structured stream terminal-result presence

    secret、OAuth token 本文、authorization code、
    raw credential、HOME absolute path の不要な出力は禁止する。

    最低限、read-only で次を確認する。

    agy --version
    agy --help
    uv run python3 \
      .claude/skills/gemini-cli-headless-delegation/scripts/setup_check.py \
      --provider agy --json

    preflight_agy.py の capability API / CLI についてはコードから canonical
    invocation を確認して実行する。古い推測コマンドを使わない。

    agy --help は stdout だけでなく stderr も evidence として確認する。

    Phase 3 — test the auth-isolation hypothesis

    特に次の仮説を敵対的に検証すること。

    structured-output Stage-2 semantic probe が _isolated_probe_env()
    によって HOME/XDG を temporary empty root に差し替える一方、
    AGY の実認証は user HOME 内 credential または system keyring/session
    に依存するため、probe 自身が authentication capability を除去し、
    supported に到達できない状態を作っているのではないか。

    確認事項:

    • _run_structured_output_semantic_probe() が使用する env
    • _isolated_probe_env() が保持/除外する env
    • AGY auth detection が想定する credential channel
    • D-Bus/session/keyring の扱い
    • OAuth token/cache の扱い
    • semantic probe が isolated HOME に必要な認証だけを安全に投影しているか
    • customization isolation と authentication isolation が誤って同一視されていないか

    credential の中身は読まない・表示しない。
    token の stdout 出力、hash 化、Git への保存も禁止する。

    AGY_PREFLIGHT_CONFIRM_RUNTIME_PROBE_COST=1 は
    model-backed probe の明示的 cost confirmation である。
    root cause が未確定のまま retry storm を起こさないこと。
    同じ deterministic failure を繰り返さない。

    必要な live probe は最大1回の bounded probe とし、
    既存の operator authorization で cost-bearing probe が明示的に許可されて
    いない場合は、勝手に env var を立てず、
    必要な exact command と理由を最終報告に含める。

    Phase 4 — classification

    結果を以下のいずれかに明確に分類する。

    A. real environment failure

    例:

    • current auth session unavailable
    • quota/rate limit
    • binary missing
    • provider outage
    • actual account capability unavailable

    この場合:

    • repository change は行わない
    • exact recovery action を示す
    • recovery 後に web-researcher だけを fresh rerun する手順を示す
    • stale result を再利用しない

    B. loop-protocol capability-probe defect

    例:

    • probe が認証経路を自分で隔離している
    • supported state が production environment から実質 unreachable
    • auth failure を capability missing として潰している
    • setup/preflight/runner 間で capability semantics が不一致

    この場合、#1943 を変更して直してはならない。

    #1943 Allowed Paths 外のため、dedupe search 後、
    専用 implementation Issue を作成する。

    Issue の provisional goal:

    AGY structured-output semantic probe の customization isolation と authentication availability を分離し、credential を露出せずに same-binary runtime capability を判定できるようにする

    最低限の AC:

    • same-binary binding を維持
    • help-only evidence では supported にしない
    • bounded runtime semantic probe を維持
    • customization/hooks/plugins は isolated
    • authentication channel は明示的な最小 projection とする
    • raw credential/token は log/artifact に出さない
    • real credential を mutation しない
    • temp auth material は restrictive permissions + guaranteed cleanup
    • auth unavailable と capability unsupported を別 taxonomy にする
    • quota / permission / malformed stream / identity drift を区別する
    • valid init -> step_update* -> result 観測時のみ supported
    • retry storm 禁止
    • fixture tests + bounded live verification を要求
    • existing fail-closed behaviorを弱めない
    • WebSearch/WebFetch direct fallback、Gemini fallback を追加しない

    実装まで許可される場合でも、
    その新 Issue の refinement / contract review / Allowed Paths を確定してから
    別 worktree/branch で行うこと。

    #1943 scope へ sneak-in してはならない。

    Phase 5 — inspect the second blocker: #2042

    capability defect と独立して、current web-researcher.md の
    Grounding Quality Gate と claim-source materialization を照合する。

    特に、

    という条件が同時に成立する場合、
    critical claim を要求する WEB_RESEARCH_RESULT_V1 が
    構造的に PASS 不能になっていないか検証する。

    PASS 不能なら #2042 を #1943 再開前の serial dependency とする。

    #2042 は既存 Issue なので重複 Issue を作らない。
    #2038 / PR #2043 が dependency を満たしているか fresh に確認する。

    capability repair と #2042 が同じファイルを変更する場合は
    parallel implementation せず serial に処理する。

    推奨順:

    1. grounded_research capability/auth isolation defect
    2. 実装: WEB_RESEARCH_RESULT の claim-source 関連付けを stable source_id で deterministic 化する (#2038 follow-up) #2042 deterministic claim-source materialization
    3. 実装: Claude Code / Codex CLI の implementation-worker に bounded read-only delegation parity を追加する #1943 web-researcher fresh rerun
    4. Investigation Gate 再評価

    Phase 6 — #1943 resume gate

    上記 blocker が解消するまで implementation_go=false を維持する。

    解消後も #5230822070 の古い web-research result を成功扱いしない。

    #1943 の current live body SHA に束縛して web-researcher を fresh に起動し、

    • selected agent == web-researcher
    • terminal
    • schema-valid
    • correct verification_route
    • current Issue snapshot relevant
    • critical claim coverage valid
    • machine-verifiable sources present
    • no conflicting conclusion
    • no stale evidence

    を満たすことを確認する。

    全条件が成立した場合だけ implementation_go=true とし、
    そこで初めて #1943 の canonical implementation worktree/branch と
    Allowed Paths 内 tracked content mutation を開始する。

    Prohibited shortcuts

    以下は禁止。

    Final output

    最後に compact に以下を返す。

    ISSUE_1943_GROUNDED_RESEARCH_RECOVERY_V1:
      issue_body_sha256:
      current_implementation_go: false
      agy:
        version:
        binary_sha256:
      capability:
        status:
        reason_code:
        evidence_source:
        semantic_probe_attempted:
      diagnosis:
        class: environment_failure | workflow_defect | dependency_blocked | unknown
        root_cause:
        confidence:
      auth_isolation_hypothesis:
        verdict: confirmed | rejected | inconclusive
        evidence:
      claim_source_gate:
        issue_2042_required_before_retry: true | false
        reason:
      follow_up:
        existing_issue:
        new_issue_created:
        new_issue_number:
      mutations:
        issue_1943_tracked_files_changed: false
        issue_1943_branch_created: false
        issue_1943_pr_created: false
      next_action:

    判定根拠には、repository evidence と公式 upstream evidence を分離して記載する。
    不明なものを supported / pass / approve に昇格させない。

    ポイントは、「AGYをもう一度叩く」ではなく、まず supported を証明する probe 自身が認証を消していないか証明することです。その修正後も #2042 を通さないと、#1943 の critical web evidence gate が次の地点で再び停止する可能性があります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions