Skip to content

実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する #1842

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1833"
goal_ref: "implementation-worker から codebase-investigator / web-researcher への任意 read-only nested delegation を、Claude Code / Codex CLI 双方の native runtime canary として確認する"
change_kind: mixed

Parent Issue

#1833

Parent Goal Ref

  • Goal: root/main ownership を維持した native Multi-Agent V2 minimal harness。
  • Desired Destination: 任意の read-only nested canary(既存 codebase-investigator および web-researcher)を、Codex CLI と Claude Code の双方の実 runtime で確認する。

Current Validated Scope

  • 実装: .codex/agents/*.toml へ delegation metadata を追加し implementation-designer を新規追加する #1839 は既存 codebase-investigator との責務重複が解消できず not planned となったため、designer は導入しない。既存 .codex/agents/codebase-investigator.toml の behavioral contract を参照する。
  • OWNER コメント(issuecomment-5151858294)により、委譲先の対象を codebase-investigator だけでなく web-researcher も含める形に拡張する。両エージェントは non-mutation の性質が異なる:codebase-investigator は local filesystem/Git 限定の read-only、web-researcher は outbound network 到達を持つが GitHub mutation は禁止という別種の read-only である。この違いは AC3/AC4 で個別に検証する。
  • .claude/agents/codebase-investigator.md と .claude/agents/web-researcher.md はいずれも Agent tool を持たず、grandchild(孫)起動は現状不可能。
  • .claude/agents/implementation-worker.md の現行 tools は [Read, Grep, Glob, Bash, Edit, Write, MultiEdit] であり Agent は含まれていない。.codex/agents/implementation-worker.toml の stop condition には nested delegation 必須化を検知したら停止する旨の文言が既にある。
  • graph policy、packet、ledger、digest、validatorの current-main 実装はない。

Remaining Parent Gaps

  • nested delegation が Codex CLI/Claude Code のいずれか一方でも利用不能なら、そのランタイムについて環境blockerとして記録し、追加 graph subsystem は作らない。

Outcome

Codex CLI と Claude Code の native runtime が実際に nested delegation をサポートするかどうかを、それぞれ独立に確認する。サポートする runtime では、worker が既存 codebase-investigator および web-researcher へ任意の read-only design task を一件ずつ委譲し、各エージェント完了後に worker が処理を継続できることを live readback で確認する。未対応な runtime/エージェント組み合わせがあれば false PASS にせず environment blocker とする。

In Scope

  • implementation-worker -> codebase-investigator および implementation-worker -> web-researcher の任意 read-only delegation。
  • Codex CLI と Claude Code、それぞれの native runtime での検証(runtime session matrix: 各ランタイムにつき no-investigation baseline / codebase-investigator / web-researcher の3 session を独立に smoke する)。
  • 各委譲先エージェント完了後に worker が処理を継続すること。
  • codebase-investigator がファイル編集、Git操作、PR/GitHub mutation、child起動を行わなかったことの実 readback(local filesystem/Git 限定 read-only の観点)。
  • web-researcher が repo file 編集、Git操作、PR/GitHub mutation、child起動を行わなかったことの実 readback(outbound network 到達はあり得るが GitHub mutation は行わない、という別種の read-only の観点)。
  • writer が常に worker 一体だけであること(Codex CLI/Claude Code いずれの runtime でも)。
  • codebase-investigator あり/なし、web-researcher あり/なし、双方の runtime smoke。
  • agent instruction は security proof ではないという制約の明記。
  • Claude Code の nested subagent 挙動(Agent tool による子起動、既定の nesting 深さがバージョン依存であること、nested subagent 内では型 allowlist が無視されること、parent が acceptEdits のとき child の permissionMode より優先されること)を事実として踏まえた runtime smoke 設計。既定 nesting 深さの具体的な数値は断定せず、実行時のインストール済み Claude Code バージョンで確認する。

Out of Scope

  • graph policy の canary/active 状態、self-attested binding、graph validator evidence、digest/packet/ledger。
  • .codex/hooks.json および .claude/settings.json の変更、write-capable nested delegation、security enforcement の主張。
  • 新しい agent role(implementation-designer 等)の追加。
  • Claude Code / Codex CLI 双方の implementation-worker に bounded read-only delegation parity を追加する実装そのもの(OWNER が採用を明言した別スコープであり、新規 prerequisite Issue として別途起票する。本 Issue は runtime canary の確認のみを扱う)。
  • implementation-worker を scripts/check_claude_codex_agent_parity.py の PARITY_AGENTS に追加すること(別スコープ)。
  • 親 導入: Codex CLI Multi-Agent V2 へ移行し、明示的な委譲グラフとbounded nested delegation harnessを導入する #1833 本文の編集。

Acceptance Criteria

  • AC1: Codex CLI runtime で、no-investigation baseline / codebase-investigator / web-researcher の3 session smoke を実行し、各委譲 session 後に worker が join 後に継続することを確認する。
  • AC2: Claude Code runtime で、no-investigation baseline / codebase-investigator / web-researcher の3 session smoke を実行し、各委譲 session 後に worker が join 後に継続することを確認する。
  • AC3: codebase-investigator の non-mutation(ファイル編集・Git操作・PR/GitHub mutation・child起動なし)を実 readback で確認する(local filesystem/Git 限定 read-only の観点)。
  • AC4: web-researcher の non-mutation(repo file 編集・Git操作・PR/GitHub mutation・child起動なし。outbound network 到達はあり得るが GitHub mutation は行わない)を実 readback で確認する。
  • AC5: writer は Codex CLI/Claude Code いずれの runtime でも worker 一体だけである。
  • AC6: read-only agent instruction を security boundary と主張しない。
  • AC7: Codex CLI または Claude Code のいずれかが nested delegation を支援しない場合は、そのランタイムについて environment blocker として記録する。
  • AC8: .codex/hooks.json および .claude/settings.json は変更しない。

Verification Commands

# AC1
# preflight-scope: runtime_only
$ codex --version
# AC2
# preflight-scope: runtime_only
$ claude --version
# AC3
# baseline-expect: pass
$ git status --short
# AC4
# baseline-expect: pass
$ git diff --check
# AC5
# baseline-expect: pass
$ git rev-parse HEAD
# AC6
# baseline-expect: pass
$ rg -n "security boundary" -- .codex/agents/codebase-investigator.toml
# AC7
# preflight-scope: runtime_only
$ codex --version
# AC8
# baseline-expect: pass
$ git diff --name-only origin/main -- .codex/hooks.json .claude/settings.json

実行可能な nested runtime smoke command と live readback は実行環境(Codex CLI/Claude Code それぞれのインストール済みバージョン)に合わせて記録する。fixture/source-text assertion は AC1--AC5 の代替にしない。

Allowed Paths

  • (なし。read-only runtime verification につき repo file、branch、worktree、hookを変更しない。証跡は GitHub comment に記録する)

Dependencies

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • ただし新規 prerequisite Issue(Dependencies 参照)自体は既に言及済みの別ステップでの起票であり、この Stop Condition の対象ではない
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • Codex CLI/Claude Code いずれかの runtime が nested delegation を実際に提供しない、または codebase-investigator/web-researcher の non-mutation を readbackできない場合は、そのランタイム/エージェント組み合わせについて environment blocker として停止する。
  • writer が複数になる、Allowed Paths 外の変更、または .codex/hooks.json/.claude/settings.json 変更が必要な場合。
  • runtime output から codebase-investigator/web-researcher の start/join を観測できない場合。
  • codebase-investigator/web-researcher の tool activity と worktree non-mutation を readbackできない場合。
  • worker が codebase-investigator/web-researcher join後に継続しない場合。
  • current tested head が origin/main と一致しない場合。
  • branch、commit、PR、code変更が必要になった場合。

Required Skills

  • なし

Required Design References

  • docs/dev/runtime-verification-policy.md
  • .codex/agents/implementation-worker.toml
  • .codex/agents/codebase-investigator.toml
  • .claude/agents/implementation-worker.md
  • .claude/agents/codebase-investigator.md
  • .claude/agents/web-researcher.md

Runtime Verification Applicability

decision: immediate
owner: root/main
tested_head: origin/main
applicable_acs: [AC1, AC2, AC3, AC4, AC5, AC6, AC7]
execution_environment: "current origin/main worktree, installed Codex CLI, and installed Claude Code"
skip_conditions: "nested spawn/joinまたはcodebase-investigator/web-researcher trace readbackが利用不能"
fallback_policy: "environment_blocker。PASSへ代替しない"
artifact_requirements: "GitHub commentにCLI version(Codex/Claude 双方)、tested head、codebase-investigator/web-researcher trace、前後git statusを記録"
evidence:
  - "codex --version / claude --version"
  - "worker/codebase-investigator/web-researcherの session output とjoin結果(Codex/Claude 双方)"
  - "git status --short の前後readback"
  - "codebase-investigator/web-researcherのedit/Git/PR/child start非実行を示すruntime trace"
unavailable_policy: "environment_blocker。instruction、fixture、自己申告だけでPASSにしない"

Scope Delta(任意)

  • 変更理由(1): #1839(implementation-designer 新規追加)が OWNER コメント により not planned となったため、本 Issue の委譲先を新規 implementation-designer から既存 .codex/agents/codebase-investigator.toml へ変更した。
  • 変更理由(2): OWNER コメント(issuecomment-5151858294)により、委譲先の対象を codebase-investigator だけでなく web-researcher も含める形に拡張した。両エージェントは non-mutation の性質が異なるため、AC/VC を分けて検証する。
  • 変更理由(3): review-issue の needs-fix フィードバック(8 blockers)に対応し、decision: immediate の AC に <!-- runtime-verification: true --> タグを付与、codex/claude CLI を伴う VC に # preflight-scope: runtime_only を付与、baseline で pass する VC に # baseline-expect: pass を付与、AC6(旧AC5)の rg broad-path 判定を Allowed Paths セクションの記法修正(説明文を丸ごと括弧内に収め、パス由来の誤爆を防ぐ)と -- 明示指定で解消した。
  • 変更内容: Outcome / In Scope / Out of Scope / Acceptance Criteria / Verification Commands / Dependencies / Stop Conditions / Required Design References / Runtime Verification Applicability の該当箇所を更新した。AC を7件から8件に拡張し(codebase-investigator 用と web-researcher 用の non-mutation AC を分離)、タイトルを Codex 限定から Codex CLI/Claude Code 両ランタイム対象を正確に表す形に変更した。
  • 変更していない箇所: Allowed Paths(なし)、hard predecessor(実装: native Multi-Agent V2 の bounded runtime smoke と negative test を追加する #1841)、AC8(旧AC7、hooks.json 不変更)の semantics、親 導入: Codex CLI Multi-Agent V2 へ移行し、明示的な委譲グラフとbounded nested delegation harnessを導入する #1833 本文。

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 28, 2026
  2. changed the title [-]実装: read-only nested canary implementation-worker -> implementation-designer を有効化する[/-] [+]実装: native Multi-Agent V2 の read-only nested canary を実行する[/+] on Aug 1, 2026
  3. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop follow-up(#1839 close 反映・reframe)

    #1839(implementation-designer 新規追加)が OWNER コメント により not planned として close された。同コメントの推奨に従い、本 Issue の委譲先を新規 implementation-designer から既存 .codex/agents/codebase-investigator.toml へ reframe した。

    • implementation-worker -> implementation-designer を implementation-worker -> codebase-investigator に置換(Outcome / In Scope / AC1〜AC3 / Dependencies / Stop Conditions / Required Design References / Runtime Verification Applicability)。
    • AC5 の Verification Command は .codex/agents/codebase-investigator.toml 内の既存の security boundary ではない 宣言(# baseline-expect: pass、実行確認済み: rg -n "security boundary" .codex/agents/codebase-investigator.toml → exit 0)を参照するよう更新した。
    • Hard predecessor(#1841)、Allowed Paths(なし)、AC4/AC6/AC7 の semantics は変更していない。

    親 #1833 も同時に更新済み(別コメント参照)。

  4. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    implementation-worker -> codebase-investigator だけでなく "web-researcher" への作業移譲も対象に含めて。

  5. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-08-01 23:30:38

    #1842
    #1842 (comment)
    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


    chatgpt response

    Issue #1842 と指定コメントを起点に、本文・全コメント・関連 Issue/PR・該当コード・CI/運用契約を横断して確認します。そのうえで、外部仕様や実装事例と照合し、成立しない前提・過剰設計・不足している受け入れ条件を優先度付きで整理します。

    指定コメントの要求自体は妥当ですが、単純に対象ロールを一つ追加するだけでは、web-researcher 固有の外部通信・副作用・資格情報境界を取り逃がす可能性があります。親契約と実際の agent 設定を確認し、同一 canary に含めるべきか、別の観測契約が必要かを切り分けます。

    現行設定では web-researcher は codebase-investigator と同じ「read-only」ではありません。ファイル書込みは禁止でも、広い outbound network と GitHub API 到達性を持つため、non-mutation の観測方法を共通化すると remote mutation と資格情報利用の検証が欠落します。導入元 Issue/PR と runner の観測可能範囲を確認します。

    判定

    REQUEST_CHANGES。

    指定コメントの「web-researcher も対象に含める」は妥当です。ただし、現行本文へ agent 名と AC を一つ追加するだけでは不十分です。現在の #1842 は、codebase-investigator だけを対象にしている点とは別に、worker 契約・実行証跡・permission 境界・provider dependency が相互に矛盾しており、そのままでは信頼できる PASS を出せません。

    P0-1: implementation-worker 自身が nested delegation を禁止している

    #1842 は implementation-worker -> codebase-investigator の nested delegation 成功を完了条件にしています。一方、current main の implementation-worker.toml は、nested delegation 必須化を検知したら停止する と明記しています。さらに #1842 の Allowed Paths は「なし」です。

    したがって現契約では、worker が正しく自身の指示に従うと canary が失敗し、canary を成功させると worker 契約違反になります。

    必要な修正は次のどちらかです。

    1. 前提 Issue/PR で worker 契約を「指定された既存 read-only agent への任意・最大1件の委譲は許可」に変更する。
    2. root から直接 agent を起動する smoke に縮退する。

    ただし後者は、worker -> child の nested delegation を証明しないため、#1842 の目的とは別物です。第一案が必要です。

    P0-2: web-researcher は codebase-investigator と同じ read-only risk class ではない

    codebase-investigator は filesystem read-only と限定的な GitHub network profileですが、web-researcher は loop-protocol-web-research を使い、filesystem read-onlyのまま outbound network を広く許可しています。agent 本文自身も、この profile は GitHub API の GET/POST を分離する remote-readonly security boundary ではないと認めています。

    さらに、現在 open・draft の PR #1937 の実測では、network.mode = "full" の下で allowlist 外の example.com に、ローカル subprocess の curl と組み込み web 閲覧の双方から到達しています。つまり、worktree fingerprint が不変でも、外部通信や remote mutation の不存在は証明できません。

    そのため、両 agent を一つの AC3「non-mutation」でまとめてはいけません。

    • codebase-investigator: local filesystem/Git/child-spawn の observed absence
    • web-researcher: 上記に加え、外部アクセス経路、利用可能な認証情報、GitHub mutation tool event の observed absence

    を別々に判定する必要があります。なお、これはあくまで観測された副作用の不存在であり、権限強制の証明ではありません。

    P0-3: 現在の Verification Commands は AC を検証していない

    AC1、AC2、AC6 の codex --version は、次のどれも検証しません。

    • child の spawn/start
    • requested role と effective role の一致
    • worker が wait 結果を消費したこと
    • worker が join 後に処理を再開したこと
    • child が child を起動しなかったこと
    • child の tool activity
    • remote mutation の不存在

    また、decision: immediate なのに各 runtime AC に <!-- runtime-verification: true --> がありません。repository の runtime verification SSOT では、これは blocker 扱いです。

    既存の run_worktree_agent_runtime_smoke.py も、そのままでは不十分です。この runner が確認するのは、プロセス終了、native JSON event 数、terminal event、ローカル worktree fingerprint 等です。summary.md には raw native event や session log が保存されず、任意文字列の marker 検索以上の semantic verification は行いません。runner 自身も semantic verdict の owner ではないと宣言しています。

    #1842 では、少なくとも次の event を実 session JSONL から抽出する具体的なコマンドまたは parser が必要です。

    • spawn_agent request payload
    • requested agent type
    • effective agent/model/permission metadata
    • child terminal completed
    • wait_agent result consumption
    • worker の post-join continuation marker
    • child-origin tool call inventory
    • nested child spawn count
    • raw evidence の SHA-256

    これを作れないなら environment_blocker であり、child の自己申告 markerだけで PASS にしてはいけません。

    P0-4: provider route の検証と native nesting の検証が混ざる

    current main の codebase-investigator は既定経路として gemini-cli-headless-delegation を参照しています。一方、open の #1886 は codebase-investigator と web-researcher の required route を AGY-only に変更し、actual spawn と provider evidence を別途検証する契約です。

    この状態で実際の調査タスクを #1842 に渡すと、失敗原因を区別できません。

    • native nested delegation が壊れている
    • AGY/Gemini wrapper が失敗した
    • provider auth がない
    • outbound network が使えない
    • child output schema が不正
    • agent contract が stale

    したがって #1842 は、次の二層に分離すべきです。

    #1842が所有するもの

    • agent の spawn/start/join
    • effective role の確認
    • worker の post-join continuation
    • observed non-mutation
    • thread lifecycle

    #1886/#1924 が所有するもの

    • AGY provider selection
    • grounded research の実行
    • network/domain behavior
    • WEB_RESEARCH_RESULT_V1
    • provider attempt/fallback evidence

    #1842 の canary task は、外部 provider を必要としない bounded orchestration probe に限定するのが妥当です。

    P1: parent #1833 も同期更新が必要

    親 #1833 は現在、任意の nested canary を implementation-worker -> codebase-investigator のみに固定し、Child Issues、Dependency Order、Definition of Done も同じ前提です。#1842 本文だけを直すと親子契約が再び不一致になります。

    少なくとも以下を同期してください。

    名称も read-only nested canary ではなく、既存 read-only agents canary と複数形にする方が正確です。

    P1: child TOML の read-only 宣言を effective permission の証拠にできない

    OpenAI公式仕様では、subagent は現在の sandbox policy を継承し、親 turn の live runtime override が child spawn 時に再適用されます。これは custom agent file に別の default があっても適用されます。公式ガイダンスも、prompt に作業分割、wait 条件、返却形式を明示するよう要求しています。(OpenAI Developers)

    したがって evidence には、TOML の設定値ではなく、実 runtime から取得した次の値が必要です。

    • requested role
    • effective role
    • effective sandbox/permission mode
    • parent runtime override
    • effective model
    • approval mode

    default_permissions = "loop-protocol-readonly" の grep だけでは AC を満たしません。

    推奨する最小構成

    過剰な harness を追加する必要はありません。次の3セッションで足ります。

    1. baseline
      worker を起動するが child を起動しない。既存 worker flow が完了することを確認。

    2. codebase-investigator canary
      worker が1件だけ起動し、terminal result を消費して処理を再開する。

    3. web-researcher canary
      別の fresh session で同じ lifecycle を検証する。外部 provider/web access は行わない。

    同一セッションで両方を並列起動すると、thread limit、network、provider、agent lifecycle の失敗が混ざるため、主検証には不向きです。

    推奨AC

    • AC1: baseline session が child なしで完了する。
    • AC2: worker→codebase-investigator の spawn、effective role、wait、completed、post-join continuationを確認する。
    • AC3: worker→web-researcher について同じ項目を確認する。
    • AC4: 各 child の nested child spawn count が0である。
    • AC5: local file/Git/branch/HEAD/index/untracked fingerprint に evidence directory 外の差分がない。
    • AC6: child-origin Git/GitHub mutation event が観測されない。security enforcement の証明とは表現しない。
    • AC7: exact tested SHA、Codex version、binary SHA-256、OS/arch、auth mode、parent override、effective permissionを記録する。
    • AC8: capability/auth/schema/effective-role readback不可は exit 77、lifecycle不一致は exit 1とする。
    • AC9: .codex/hooks.json、branch、commit、PRを変更しない。

    また、現行 AC4 の「writer は worker 一体だけ」は不正確です。Allowed Paths がなく runtime-only verification なら、実際の writer/mutation count は0です。「write-capable role は worker 1体」「観測された mutation は0」を分けて記載してください。

    指定コメントへの直接回答

    web-researcher は対象に含めるべきです。

    ただし、codebase-investigator と同じ AC に名前だけ追加するのではなく、

    まで本文へ反映する必要があります。現状のまま実行へ進めると、成功しても「実際に何を証明したのか」が確定しません。


    you asked

    message time: 2026-08-01 23:41:18

    「前提 Issue/PR で worker 契約を「指定された既存 read-only agent への任意・最大1件の委譲は許可」に変更する。」採用する。ClaudeCodeでも同等のことが可能で、両者の仕様の違いを埋めながら同等の使い方可能かWEB調査した上で作業内容として追加して。


    chatgpt response

    前提 Issue を、Codex 側だけの例外追加ではなく「両 runtime で既存 read-only agent への bounded delegation を同等運用できる状態」に拡張して再設計します。公式仕様と現行リポジトリ資産を照合し、共通契約・runtime別差分・検証マトリクスまで具体化します。

    公式仕様上、Claude Code は現行版で nested subagent をサポートしています。既定は main 配下3層までで、親 agent の tools に Agent を含めると子を起動できます。ただし Codex と違い、agent種別 allowlist の挙動、depth制御、permission継承、観測イベントが異なるため、単純な設定コピーではなく共通 semantic contract と runtime別 adapter が必要です。

    採用判断

    新規の前提 Issue/PR を作り、Claude Code と Codex CLI の両方の implementation-worker に、既存 read-only agent への任意・最大1件の調査委譲を追加する方針が妥当です。

    Claude Codeでも同等の運用は可能です。現行公式仕様では、subagent は Agent toolを持つ場合、main conversation 配下の既定3層まで nested subagent を起動できます。深度は CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH で制限できます。(Claude)

    ただし、ランタイム間の機構は完全には同一ではありません。次の差分を明示的に吸収する必要があります。

    観点 Codex CLI Claude Code 採用する共通設計
    agent定義 .codex/agents/*.toml .claude/agents/*.md 同じ semantic contract を両方に記述
    nested起動 native subagent thread Agent tool workerが直接一件起動し、完了を待つ
    対象agent制限 spawn時のagent typeを観測可能 nested subagent内では Agent(a,b) の括弧内allowlistが無視される behavioral contract+runtime traceで対象を検証
    深度制限 runtime capabilityとtraceで確認 環境変数で明示的に2層へ制限可能 canaryでは main→worker→researcher の2層固定
    permission parentのlive overrideがchildへ再適用される acceptEdits等のparent modeがchild設定より優先する場合がある read-onlyをsecurity boundaryと主張せず、実副作用の不存在を検証
    lifecycle spawn/wait/completed Agent/SubagentStart/SubagentStop 共通の正規化済み証跡に変換

    Codexも、child起動時にparent turnのsandbox・approval overrideを再適用します。Claude CodeもparentがacceptEditsの場合はchild側のpermissionModeで弱められません。したがって両runtimeとも、agent-local設定だけでread-onlyを証明する設計にはできません。(OpenAI Developers) (Claude)

    また、現在のClaude implementation-worker はAgent toolを持っておらず、制約文ではtest-runnerへの最小限の委譲しか許可していません。一方、Codex workerはnested delegation 必須化を停止条件にしています。両方とも変更が必要です。


    追加する前提 Issue/PR

    推奨タイトル

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

    Outcome

    Claude CodeとCodex CLIの両implementation-workerが、承認済みIssueの意味・スコープを変更せず、初回write前に必要な調査を次のどちらか一体へ任意で一件だけ委譲できる状態にします。

    • リポジトリ内部のコード、依存、影響範囲: codebase-investigator
    • 外部仕様、公式ドキュメント、公開API: web-researcher

    workerはchildのterminal resultを待って消費した後、同じIssue実装を継続します。

    既存のtest-runnerへの検証委譲は調査委譲とは別枠として維持します。つまり以下の順序です。

    root/main
    └── implementation-worker
        ├── optional investigation: codebase-investigator OR web-researcher
        │   └── 最大1件、初回write前、完了待ち
        └── verification: test-runner
            └── 既存契約を維持
    

    実装内容

    1. Codex worker

    .codex/agents/implementation-worker.tomlへ次を追加します。

    READONLY_DELEGATION_POLICY
    - 調査委譲は任意であり、実装開始の必須儀式にしない。
    - 一回のimplementation runにつき最大1件。
    - 委譲先はcodebase-investigatorまたはweb-researcherのどちらか一体。
    - 両方を起動しない。並列起動しない。
    - 原則として最初のファイル変更前に実行する。
    - child resultを待って消費してから実装を継続する。
    - childはIssueのOutcome、AC、Allowed Pathsを変更・再解釈しない。
    - child resultはevidence/adviceであり、live Issue contractが正本。
    - write-capable childへのnested delegationは禁止。
    

    現在の次の停止条件は置き換えます。

    nested delegation 必須化を検知したら停止
    

    変更後は、次のようにします。

    許可された一件の任意read-only調査以外のnested delegation、
    または調査委譲を全Issueで必須化する要求を検知したら停止
    

    2. Claude worker

    .claude/agents/implementation-worker.mdのtoolsへAgentを追加し、Codex側と同じREADONLY_DELEGATION_POLICYを追加します。

    tools:
      - Read
      - Grep
      - Glob
      - Bash
      - Edit
      - Write
      - MultiEdit
      - Agent

    Agent(codebase-investigator, web-researcher)とは記述しません。Claude Code公式仕様では、agentがsubagentとして動く場合、Agent(...)の括弧内の型allowlistは無視され、単にAgent toolが利用可能になります。型allowlistが機能するのは、そのagentをclaude --agentでmain threadとして動かす場合です。(Claude)

    したがってClaude側の対象制限は次の二層で扱います。

    1. workerのbehavioral contractで対象を限定する。
    2. runtime canaryで実際に起動されたagent名を検証する。

    他agentを列挙してdenyする設定や専用enforcement hookは追加しません。agent inventory追加のたびにdeny一覧を更新する仕組みは、今回の個人開発規模には過剰です。

    3. Claudeのdepth固定

    repository-wideの.claude/settings.jsonは変更しません。#1842のfresh canary sessionだけで次を指定します。

    CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=2
    CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION=2
    CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1

    これにより、canaryでは次だけが成立します。

    main → implementation-worker → researcher
    

    MAX_SUBAGENTS_PER_SESSION=2は、mainから起動するworkerとworkerから起動するresearcherの合計です。productionの通常実装セッションへこの上限を固定すると後続のtest-runnerを妨げるため、canary限定とします。Claude Codeではnested depth・session total・concurrent数が別々に管理されています。(Claude)

    4. 共通選択ルール

    delegation_selection:
      codebase-investigator:
        use_for:
          - repository files
          - symbols and call graph
          - consumers and fixtures
          - impact scope
      web-researcher:
        use_for:
          - external specifications
          - official documentation
          - public API or CLI behavior
          - version-specific defaults
      none:
        use_when:
          - existing Issue contract and local evidence are sufficient

    同一runで両方必要になった場合は、workerが勝手に二件起動するのではなく、よりcriticalな一件だけを選びます。二件とも不可欠ならscope不足としてroot/mainへ返します。

    5. parity checker更新

    現在のcheck_claude_codex_agent_parity.pyはimplementation-workerをstrict parity対象に含めておらず、nested delegationを主に「禁止されているか」で分類しています。テストにも旧Codex max_depth前提が残っています。

    次の値を正規化して比較するよう更新します。

    delegation_mode: optional_single_readonly_investigation
    allowed_investigation_targets:
      - codebase-investigator
      - web-researcher
    max_investigation_delegations: 1
    delegation_stage: before_first_write
    result_consumption: wait_then_continue
    verification_delegation: test-runner
    security_claim: behavioral_contract_only

    これは新しいruntime protocolや公開schemaではなく、既存agent定義の静的parity fixtureです。

    前提IssueのAcceptance Criteria

    1. Codex/Claude両workerが、調査委譲を任意・最大1件としている。
    2. 委譲先の集合が厳密にcodebase-investigatorとweb-researcherである。
    3. 一回のrunで両者を起動しない。
    4. 調査委譲は初回write前に完了し、workerがterminal resultを消費してから継続する。
    5. Claude workerのtoolsにAgentが存在する。
    6. Claude subagent内のAgent(...)を型allowlistとして主張しない。
    7. 既存test-runner委譲を調査委譲の一件に数えず、既存verification flowを維持する。
    8. child resultがlive Issue contractを変更・再設計しない。
    9. read-only instructionやpermission profileをsecurity boundaryと主張しない。
    10. 新規agent、graph policy、ledger、packet、digest、専用enforcement hookを追加しない。
    11. parity checkerと関連テストがpassする。
    12. .codex/hooks.jsonと.claude/settings.jsonを変更しない。

    Allowed Paths

    .codex/agents/implementation-worker.toml
    .claude/agents/implementation-worker.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
    

    codebase-investigatorとweb-researcherの4 agentファイルは、現在の#1886と競合するため、この前提Issueでは変更しません。現在のClaude両researcherはそもそもAgent toolを持たないため、Claude側でのgrandchild起動は通常のtools surface上できません。

    Verification Commands

    node scripts/check-codex-agents.mjs
    
    uv run --locked python3 \
      scripts/check_claude_codex_agent_parity.py --strict
    
    uv run --locked pytest \
      tests/test_agent_parity.py \
      tests/test_codex_agent_bridge_contract.py -q
    
    git diff --name-only origin/main -- \
      .codex/hooks.json \
      .claude/settings.json \
      .codex/agents/codebase-investigator.toml \
      .codex/agents/web-researcher.toml \
      .claude/agents/codebase-investigator.md \
      .claude/agents/web-researcher.md

    #1842へ追加する作業

    #1842はCodex限定の本文から、次のタイトルへ変更します。

    実装: Claude Code / Codex CLI の bounded read-only nested delegation canaryを実行する

    Hard predecessors

    #1841
    └── 新規 prerequisite Issue
        └── #1842
    

    正確には、#1842は次の両方が完了するまで開始しません。

    #1886はresearch providerの実動作を所有するため参照しますが、#1842のhard predecessorにはしません。

    runtime session matrix

    各sessionはfreshに分離します。

    sessions:
      codex:
        - no-investigation
        - codebase-investigator
        - web-researcher
      claude:
        - no-investigation
        - codebase-investigator
        - web-researcher

    調査agentのactual provider routeまで同時に試すと、nested lifecycle失敗とAGY/network/auth失敗を区別できません。そのため#1842のchild taskは、入力不足に対する既存のdeterministic terminal resultを利用します。

    • codebase-investigator: INSUFFICIENT_CONTEXT
    • web-researcher: status: insufficient_context

    これにより、次だけを独立して確認します。

    1. workerが正しいagent typeを起動した。
    2. childがterminal resultを返した。
    3. workerがresultを待って消費した。
    4. workerがpost-join continuation markerを返した。
    5. childがfile/Git/GitHub mutationを行わなかった。
    6. childがgrandchildを起動しなかった。

    有用な実調査が成功したとは主張しません。 AGY/providerを含むpositive routeは#1886の責務です。

    #1842の追加AC

    • CodexとClaudeの両runtimeで同じ3種類のsessionが成立する。
    • 実際に起動されたagent名が要求されたagent名と一致する。
    • worker一体につきinvestigation childが0または1である。
    • codebase-investigatorとweb-researcherを同じsessionで起動しない。
    • workerがchild terminal resultを消費した後に継続する。
    • Claudeはdepth 2、session spawned-agent total 2、foreground固定で実行する。
    • parent permission overrideを含むeffective runtime metadataを記録する。
    • instruction、TOML、Markdown、自己申告markerだけではPASSにしない。
    • provider実調査成功やpermission enforcementを本Issueの成果として主張しない。

    runnerの最小変更

    既存runnerはClaude/Codexのstructured laneとworktree fingerprintを既に扱っているため、新しいgraph harnessは作りません。

    #1842では既存runnerへ、native eventから次のallowlisted telemetryだけを抽出する小さい拡張を加えます。

    agent_lifecycle:
      requested_agent_types: []
      observed_agent_types: []
      parent_child_edges: []
      terminal_agent_types: []
      nested_child_count: 0
      worker_continued_after_child: true

    raw prompt、raw output、reasoning、tool結果本文は永続化しません。既存summary.mdの方針を維持します。


    親 #1833 の同期修正

    #1833には次を反映します。

    • #1842の対象をcodebase-investigatorだけでなくweb-researcherにも拡張。
    • Codexをprimary runtime、Claude Codeをsemantic-parity runtimeとして記載。
    • runtime機構の完全一致ではなく、以下の結果同等性を要求。
      • 任意
      • 最大一件
      • read-only investigation
      • terminal result待機
      • worker継続
      • 単一writer
    • 新規前提Issueを#1842のhard predecessorとして追加。
    • #1886のprovider検証と#1842のnested lifecycle検証を混同しない。

    この構成なら、Claude CodeとCodex CLIの機能差を無視せず、利用者から見た運用は同等にできます。同時に、専用graph subsystem、ledger、enforcement hook、恒久的な複雑harnessは追加しません。


    Powered by AI Exporter

  6. changed the title [-]実装: native Multi-Agent V2 の read-only nested canary を実行する[/-] [+]実装: Claude Code / Codex CLI の bounded read-only nested delegation canary を実行する[/+] on Aug 1, 2026
  7. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了報告(自律実行、人間承認なし)

    結果: approve(iteration 2 で contract ready)

    経緯

    • anchor comment: issuecomment-5151075912(実装: .codex/agents/*.toml へ delegation metadata を追加し implementation-designer を新規追加する #1839 close を受けた委譲先 reframe)
    • OWNER の追加コメント(issuecomment-5151858294、issuecomment-5151949764)を反映し、委譲先へ web-researcher を追加、Codex CLI/Claude Code 双方の runtime を対象化した。
    • ChatGPT 由来の技術的主張は web 公式ドキュメントで fact-check した。Agent tool による nested subagent サポート・型 allowlist が nested 内で無視される点は公式ドキュメントで裏付け済み。一方で CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION という環境変数は存在しない(正しくは CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS、意味も異なる)ため、本文へは転記しなかった。
    • iteration 1 の review-issue で 8 blockers(C11 runtime-verification tag欠如、VC preflight allowlist違反×3、baseline-expect注釈欠落×3、rg broad-path誤検知)を検出、issue-author による rewrite で全て解消。
    • iteration 2 の review-issue で VERDICT: approve(0 blockers)。validate_review_compact_output.py で raw stdout を検証し validation_status: valid を確認。

    Follow-up materialization

    OWNER が採用を明言した「Claude Code / Codex CLI 双方の implementation-worker に bounded read-only delegation parity を追加する」方針を、新規 prerequisite Issue として起票した(dedupe search: 既存重複なし)。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues:
        - request_dedupe_key: "follow-up:squne121/loop-protocol:issuecomment-5151949764:worker-delegation-parity"
          status: created
          issue:
            number: 1943
            url: "https://github.com/squne121/loop-protocol/issues/1943"
          reason: null
      note_only_observations: []

    #1842 の Dependencies を、この確定した #1943 への参照に更新済み(body_sha256: sha256:ca4e8d3ddb873a586bc7f86ec9fbcf56836ea38427549854e9e776adc5a40810)。

    対象外として扱った事項

    STATUS: approved
    NEXT_ACTION: 実装フェーズ(#1943 → #1842 の順で implementation issue として着手可能)

  8. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor
    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: null
        gate_result: missing_go
        latest_comment_url: null
        generated_at: null
        body_sha256: "sha256:ca4e8d3ddb873a586bc7f86ec9fbcf56836ea38427549854e9e776adc5a40810"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers:
        - kind: contract_review_not_run
          description: "issue-refinement-loop は review-issue の VERDICT: approve まで完了したが、issue-contract-review(実装着手直前の決定論的 preflight)は本ループの範囲外のため未実行。impl_ready への昇格には issue-contract-review を別途実行し fresh_go を得る必要がある。"
      permissions:
        unavailable: []
      generated_at: "2026-08-01T15:40:00Z"

    補足: review-issue(内容品質レビュー)は iteration 2 で VERDICT: approve / 0 blockers に到達済み(本文 body_sha256 = 上記 contract_review.body_sha256 と同一)。上記 status: blocked は content quality の再開ではなく、実装ハンドオフゲート(issue-contract-review 未実行)を指す。次アクションは issue-contract-review の実行、または前提 #1943 の先行着手。

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

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions