Skip to content

実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886

Closed
1 of 1 issue completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1265"
goal_ref: "Claude Code と Codex CLI の codebase-investigator / web-researcher の全 required route を AGY provider へ固定し、Gemini 非依存で #1886 refinement を再開可能にする"
change_kind: workflow
blocked_by: []

satisfied_dependencies:
  - issue: "#1915"
    pr: "#1919"
    status: merged
  - issue: "#1920"
    pr: "#2000"
    status: merged

base_head_at_refinement:
  sha: "8f899d4a4a17f282fe75a03944448810a4c2cd04"
  refresh_required_at_implementation_start: true

conflicts_with:
  - issue: "#1909"
    overlapping_surfaces:
      - ".claude/agents/codebase-investigator.md"
      - ".claude/agents/web-researcher.md"
      - ".codex/agents/codebase-investigator.toml"
      - ".codex/agents/web-researcher.toml"

Parent Issue

#1265(CLOSED)

Parent Goal Ref

  • Goal: operator-disabled の Gemini CLI に依存せず、Claude Code と Codex CLI の調査 surface を AGY provider で検証可能にする。
  • Desired Destination: required 6 route が selected_provider: agy、provider_attempts: [agy]、gemini_attempt_count: 0 を同一 runtime evidence contract で示す。

Current Validated Scope

Remaining Parent Gaps

  • agent_provider_route_smoke/v1 envelope schema・producer・semantic validator・aggregate validator・live smoke runner・テストのいずれも未実装であり、本 Issue の Allowed Paths に追加する(下記参照)。
  • 実装: AGY permission/hook boundary の hermetic evidence を整備する #1814 は AGY permission / hook と version gate の owner であり、strong security claim の merge gate にはできるが、本 Issue 本文の refinement を停止する依存ではない。

GEMINI_RUNTIME_POLICY_V1

state: disabled_by_operator
reason: api_billing_or_quota_limit
scope_note: "この状態はリポジトリ固有の運用判断であり、Gemini CLI 全体の製品終了を意味しない(Enterprise / API キー経路は対象外)。"
prohibit:
  - gemini CLI invocation
  - Gemini OAuth smoke
  - Gemini setup_check
  - Gemini retry
  - Gemini fallback
  - Gemini availabilityを再開条件にすること

Outcome

Claude Code / Codex CLI の codebase-investigator(local_asset_research / github_research)および web-researcher(grounded_research)が、canonical builder を --provider agy --profile <profile> --prompt <non-empty> で呼び出し、modelなしの provider-aware validated request だけを実行する。Gemini は起動せず、direct fallback 成功も route PASS としない。各 route の実行結果は agent_provider_route_smoke/v1 envelope(新規定義)に記録し、custom agent の実 spawn を native event で独立観測する。

In Scope

  • .claude/agents/codebase-investigator.md と .claude/agents/web-researcher.md を、Gemini mandatory / direct fallback の記述から AGY-only canonical builder invocation へ更新する。web-researcher.md の許可 tools から WebSearch / WebFetch を、当該 route では除外または明示的に禁止する。
  • .codex/agents/codebase-investigator.toml と .codex/agents/web-researcher.toml の runtime follow-up route を、grounded_research_or_direct_web のような抽象 route から、profile と expected provider が検証できる AGY-only builder invocation へ更新する。
  • agent config bridge fixture(tests/fixtures/codex-agent-config/expected-runtime-contract.json)・scripts/check-codex-agents.mjs・scripts/check_codex_agent_config.py を、説明文ではなく builder invocation、profile、expected provider を検証するよう更新する(JS/Python 両 checker を同時に更新する)。
  • 新規 agent_provider_route_smoke/v1 envelope schema・producer・semantic validator・aggregate validator・live smoke runner・テストを実装する。github_research route では route_evidence.schema が agy_github_research_evidence/v1 であることを profile-specific constraint として検証する。
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py を拡張し、effective_agent_type の自己申告代入をやめ、parent_session_id / child_session_id(non-empty かつ異なる値)/ native_spawn_event_observed による独立 spawn 観測を追加する。
  • Claude Code と Codex CLI の custom agent を実際に spawn し、各 required route の agent_provider_route_smoke/v1 artifact を取得する。
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agent_contracts.py の「Antigravity 対応を仮定しない」という保守的記述を、provider=agy / 正しい profile / direct fallback 非成功を検証するアサーションへ置き換える。
  • Static contract 検証(builder invocation・provider・profile・model 不在・手書き provider JSON 不在)と Runtime 検証(6 route の live 実行・spawn 観測・fallback 非実行の実測)を、AC・Verification Commands の両方で明示的に分離する。

Out of Scope

Provider Policy

provider_policy:
  expected_provider: agy
  gemini_state: disabled_by_operator
  fallback_enabled: false
future_optional_fallback:
  enabled_only_by_explicit_operator_decision: true
  never_a_resume_requirement: true
  never_bypasses:
    - validation failure
    - permission failure
    - authentication failure
    - evidence validation failure
    - unsupported profile

provider=auto は current runtime で no_tools と proposal_only にしか eligible でないため、required 3 profile の代替に用いない。AGY adapter の prompt required / model forbidden は本 repository の builder / validator 契約であり、AGY CLI 一般仕様とは主張しない。

Resume Conditions

resume_conditions:
  - issue-reviewerがdeterministic checkerを実行できる
  - fresh raw ISSUE_REVIEW_RESULT_COMPACT_V1 stdoutを生成できる
  - raw stdout bytesがreview_compact.validateでvalidになる
  - required investigationがAGYまたはparent-owned read-only retrievalで完了する
  - Gemini CLIは一切起動されない

Required Routes

required_routes:
  - runtime: claude_code
    agent: codebase-investigator
    profile: local_asset_research
    selected_provider: agy
  - runtime: claude_code
    agent: codebase-investigator
    profile: github_research
    selected_provider: agy
  - runtime: claude_code
    agent: web-researcher
    profile: grounded_research
    selected_provider: agy
  - runtime: codex_cli
    agent: codebase-investigator
    profile: local_asset_research
    selected_provider: agy
  - runtime: codex_cli
    agent: codebase-investigator
    profile: github_research
    selected_provider: agy
  - runtime: codex_cli
    agent: web-researcher
    profile: grounded_research
    selected_provider: agy

Acceptance Criteria

Static Contract AC

  • AC1: 4つの agent surface が required profile ごとの canonical builder invocation、expected_provider: agy、Gemini operator-disabled policyを明示し、手書き provider 別 JSON を持たない。
  • AC2: local_asset_research と grounded_research は builder output を provider-aware validator で検証し、modelなし・non-empty prompt の AGY request として実行される契約になっている。
  • AC3: github_research route の contract が agy_github_research_evidence/v1 を route_evidence.schema として参照し、direct fallbackだけの成功を AGY route の成功と扱わない。
  • AC4: JS(scripts/check-codex-agents.mjs)と Python(scripts/check_codex_agent_config.py)の checker、fixture(tests/fixtures/codex-agent-config/expected-runtime-contract.json)、4 Agent surface が同じ route contract(provider/profile/builder invocation)を検証し、Gemini mandatory・direct fallback success の古い記述が残っていない。
  • AC5: agent_provider_route_smoke/v1 envelope schema・producer・semantic validator・aggregate validator が実装され、spawn.native_spawn_event_observed を含む spawn evidence フィールドを required として検証する。

Runtime AC

  • AC6: Runtime Verification Applicability が immediate で、6つの (runtime, agent, profile) の組み合わせを個別に live 実行し、selected_provider: agy、provider_attempts: [agy]、gemini_attempt_count: 0、request_validation: pass を示す agent_provider_route_smoke/v1 artifact を取得する。
  • AC7: 各 route で対象 custom agent の実 spawn を native event(parent_session_id / child_session_id が non-empty かつ異なる値、native_spawn_event_observed: true)で観測する。agent の自己申告(requested_agent_type == effective_agent_type の単純代入)は証拠にしない。
  • AC8: Gemini invocation count と direct fallback invocation count がともに実測 0 であることを、PATH 先頭の gemini invocation sentinel stub と native event stream 由来の direct web tool 検出の両方で確認する。exit 77 / SKIP は aggregate PASS に昇格しない。
  • AC9: AGY failure は failure class と evidence を報告して停止し、Geminiへ切り替えない。Gemini利用不能は human_judgment_required の理由にしない。
  • AC10: 実装: .codex/agents のモデル配分と permission profile を役割相応に再設計する #1915 / 実装: AGY が制約付き read-only gh を反復利用する github_research #1920 の merge 済み head(base_head_at_refinement.sha 以降)を readback したうえで、agent surface の line-level / semantic contract conflict を解消し、実装: SubAgent 発火前に bounded local context bundle を生成し Claude/Codex の両 loop で consume する #1909 の未マージ context bundle contract を削除・上書きしない。

Verification Commands

# AC1
# preflight-scope: pr_review_only
$ node scripts/check-codex-agents.mjs
# AC2
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agent_contracts.py -q
# AC3
# preflight-scope: pr_review_only
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_contract.py -q
# AC4
# preflight-scope: pr_review_only
$ uv run --locked python3 scripts/check_codex_agent_config.py
# AC5
# preflight-scope: pr_review_only
$ uv run --locked pytest scripts/agent-ops/tests/test_agent_provider_route_smoke.py -q
# AC6
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_agent_provider_route_smoke.py --all-routes
# AC7
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/validate_agent_provider_route_smoke.py --require-native-spawn-event
# AC8
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/validate_agent_provider_route_smoke.py --assert-zero-gemini-and-fallback-invocations
# AC9
# preflight-scope: runtime_only
$ rg -n "disabled_by_operator" .claude/agents/codebase-investigator.md
# AC10
# preflight-scope: runtime_only
$ rg -n "context_bundle" .claude/agents/codebase-investigator.md

Allowed Paths

  • .claude/agents/codebase-investigator.md
  • .claude/agents/web-researcher.md
  • .codex/agents/codebase-investigator.toml
  • .codex/agents/web-researcher.toml
  • scripts/check-codex-agents.mjs
  • scripts/check_codex_agent_config.py
  • tests/fixtures/codex-agent-config/expected-runtime-contract.json
  • tests/test_codex_agent_bridge_contract.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agent_contracts.py
  • schemas/agent_provider_route_smoke_v1.schema.json
  • scripts/agent-ops/run_agent_provider_route_smoke.py
  • scripts/agent-ops/validate_agent_provider_route_smoke.py
  • scripts/agent-ops/tests/test_agent_provider_route_smoke.py
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合。
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)。
  • 後続 Phase / 別スコープへの波及が判明した場合。
  • base_head_at_refinement.sha と実装開始時点の current main head が乖離し、readback / rebase なしに実装が進んだ場合。
  • 実装: SubAgent 発火前に bounded local context bundle を生成し Claude/Codex の両 loop で consume する #1909 の未マージ context_bundle_path 契約と、同一行 / 同一 semantic contract の競合が unresolved の場合。
  • agent_provider_route_smoke/v1 の route_evidence.schema が github_research route で agy_github_research_evidence/v1 以外になった場合。
  • AGY route が failure し、failure class / evidence を取得できない場合。
  • nested SubAgent delegation が必要になった場合。
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合。
  • 実装: AGY live E2E の temp-root cleanup を原因分類付き single retry にする #1997 型の transient cleanup race に対し、失敗理由を保存せず無言で再実行し PASS 扱いにしようとした場合(bounded single retry かつ initial_result 保持以外は禁止)。

Required Skills

  • Markdown
  • TOML
  • Python
  • pytest

Required Design References

  • .claude/skills/gemini-cli-headless-delegation/references/provider-mapping.md
  • .claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/runtime-verification-policy.md
  • schemas/agy_github_research_evidence_v1.schema.json

Runtime Verification Applicability

decision: immediate
applicable_acs: [AC6, AC7, AC8, AC9, AC10]
static_contract_acs: [AC1, AC2, AC3, AC4, AC5]
execution_environment: "AGY CLI、GitHub read-only認証、custom agent spawn が利用可能な current main runtime"
skip_conditions: "AGY または必要な child dependency が利用不能なら failed または blocked とし、Geminiへ切り替えない。exit 77 は aggregate PASS に昇格しない。"
fallback_policy: "direct fallback または別 provider の成功は PASS ではない。Gemini fallback は disabled_by_operator。"
artifact_requirements: "各 route ごとに .claude/artifacts/agent-provider-route/<run-id>/ の agent_provider_route_smoke/v1 artifact を保存する"
retry_policy: "infrastructure由来のtransient failure(#1997型)は bounded single retry のみ許容し、initial_result / initial_failure_class / retry_count / retry_result / final_route_verdict を保持する。理由を保存しない無言再実行は禁止。"
success_condition:
  selected_provider: agy
  provider_attempts: [agy]
  gemini_invocation_count: 0
  direct_fallback_invocation_count: 0
  request_validation: pass
  native_spawn_event_observed: true
  fallback_success_is_pass: false
artifact:
  schema: agent_provider_route_smoke/v1
  fields:
    - subject.runtime
    - subject.agent_name
    - subject.head_sha
    - subject.runtime_version
    - subject.agent_definition_sha256
    - subject.effective_runtime_config_sha256
    - spawn.parent_session_id
    - spawn.child_session_id
    - spawn.native_spawn_event_observed
    - request.profile
    - request.expected_provider
    - request.validation
    - provider_observation.selected_provider
    - provider_observation.provider_attempts
    - provider_observation.gemini_invocation_count
    - provider_observation.direct_fallback_invocation_count
    - route_evidence.schema
    - route_evidence.sha256
    - status
    - failure_class

Delivery Rule

1 Issue = 1 PR。#1915 / #1920 は merge 済みのため dependency ordering の対象外。#1909 との merge order は #1886 → #1909 を既定とし、実装直前に #1909 の状態を再確認する。merge、force-push、branch削除は通常の PR フローに従う。

Notes for Reviewer

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

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

    @squne121
    OwnerAuthor

    CodexCLIのサブージェントもスコープに加えて。

  3. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-08-01 15:07:05

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


    chatgpt response

    Issue #1886と指定コメントから関連Issue・PR・実装資産・議論の因果関係を再構成します。契約不整合、失敗時挙動、検証漏れ、重複実装を公式仕様と照合し、優先度付き改善案を示します。


    chatgpt response

    指定コメントはClaude限定の契約境界を崩し、Codex側の権限・委譲失敗・外部Web到達性まで再設計を要します。さらにPR #1823上、contract matrixのimplementedだけでは実呼出し経路の検証根拠になりません。


    chatgpt response

    さらに、同一資産を扱うOPEN #1909との競合と、Codex契約正本SCHEMA.mdの参照切れが判明しました。AGY最新JSON Schema対応と、誤引用#1808→#1806/PR #1823も反映します。


    chatgpt response

    敵対的レビュー結果

    判定: REQUEST_CHANGES。Issue本文を再設計するまで実装着手不可です。

    指定コメントの「CodexCLIのサブージェントもスコープに加えて」は、単なる補足ではなくスコープ変更の明示指示です。しかし現在のIssue本文は、変更対象をClaude Code側の2ファイルだけに限定し、Acceptance Criteriaも文字列検索だけ、Runtime Verificationもnot_applicableのままです。コメントと実装契約が一致していません。

    P0ブロッカー

    P0-1: 現在の実装案は、Claude Code側だけでもAGY validatorに拒否される

    Issueは、既存JSONテンプレートに単純に"provider": "agy"を追加する方針です。しかし、現在のcodebase-investigator.mdのlocal_asset_researchテンプレートは、objective、instructions、output_sectionsを持つGemini用のstructured requestで、AGYに必須のpromptを持っていません。

    一方、現行のAGY契約は明確なprompt-firstです。

    • provider=agyではpromptが必須
    • model指定は禁止
    • promptがなければagy_prompt_required
    • local_asset_researchの正しいAGY requestは、Gemini専用のobjective/instructions/output_sectionsを持たない

    これらは既存テストで固定されています。したがって、現テンプレートへproviderを1行追加するだけでは、AC1のrgはPASSしても実際のwrapper validationは失敗します。

    さらに、web-researcher.mdには、Issueが想定しているような具体的なdelegation request JSONテンプレート自体がありません。現在あるのは実行方針とfallback説明であり、providerという文字列を任意の説明文に追加するだけでも現行AC3を満たせます。つまりAC3は実行経路を検証していません。

    必須修正: Agent定義内でJSONを手書きせず、既存build_request.pyを唯一のrequest builderとして使用してください。

    local_asset_research:
      build_request.py --provider agy --profile local_asset_research --prompt ...
    
    grounded_research:
      build_request.py --provider agy --profile grounded_research --prompt ...
    
    github_research:
      build_request.py --provider gemini --profile github_research ...
    

    生成物を必ずrun_gemini_headless.py --validate-onlyへ通し、builderとruntime validatorのparityを検証する必要があります。


    P0-2: Codex側は「TOMLに説明を追記」するだけではprovider bindingにならない

    現在のCodex custom agentには、以下の問題があります。

    • codebase-investigator.tomlは「Gemini delegation skillを優先」としか定義していない
    • web-researcher.tomlもgrounded_research_or_direct_webという抽象的なfollow-up routeだけ
    • どちらにもprofile → providerの具体的なbindingやbuilder invocationがない
    • Codex runtime fixtureはmodel、reasoning effort、permission、follow-up routeを検証するだけで、provider選択を検証しない

    OpenAI公式仕様上、.codex/agents/*.tomlはspawnされるCodex sessionに適用されるconfiguration layerです。また、subagentは親sessionのsandbox/permission/runtime overrideを継承します。したがって、TOMLの静的文字列だけでは、実際にcustom agentがspawnされ、AGY builderを起動したことも、実効permissionで動作したことも証明できません。(OpenAI Developers) (OpenAI Developers)

    必須修正:

    1. .codex/agents/codebase-investigator.toml
    2. .codex/agents/web-researcher.toml

    の両方に、canonical skill経由の具体的なbuilder invocationとprofile別providerを記述する。

    加えて、

    • expected-runtime-contract.json
    • check_codex_agent_config.py
    • 必要ならcheck-codex-agents.mjs

    で、Agent本文に必要なprovider/profile invocationが存在することを検証する必要があります。

    ただし、静的検証だけで完了にはできません。実際のCodex custom agent dispatchを起動し、subagent resultまたはartifactでselected_providerを確認するlive smokeが必要です。


    P0-3: Runtime Verification Applicability: not_applicableは誤り

    本IssueはMarkdownの文言修正ではなく、外部CLIへ送る実際のprovider routeを変更するIssueです。現本文の「agent定義Markdownなので静的rgだけで十分」という判断は成立しません。

    profile_provider_contract_matrix.yamlが証明するのは、概ね次の能力関係です。

    local_asset_research × agy   = implemented
    grounded_research × agy      = implemented
    github_research × agy        = unsupported_by_design
    

    これは「特定Agentが実際にそのproviderを選択した」ことの証明ではありません。Capability matrixとcaller selectionは別の契約です。

    リポジトリ内でも、#1909はClaude CodeとCodex CLIのcustom agent dispatchを実際に起動し、fallback成功をPASSとせず、正規経路をartifactで確認するdecision: immediateのruntime検証を要求しています。本Issueも同じ水準が必要です。

    最低限、次の6ケースを実行してください。

    Runtime Agent Profile 期待provider
    Claude Code codebase-investigator local_asset_research agy
    Claude Code codebase-investigator github_research gemini
    Claude Code web-researcher grounded_research agy
    Codex CLI codebase-investigator local_asset_research agy
    Codex CLI codebase-investigator github_research gemini
    Codex CLI web-researcher grounded_research agy

    runtime artifactには少なくとも以下が必要です。

    AGENT_PROVIDER_ROUTE_SMOKE_V1:
      runtime: claude_code | codex_cli
      agent: codebase-investigator | web-researcher
      profile: local_asset_research | grounded_research | github_research
      selected_provider: agy | gemini
      provider_attempts: [agy | gemini]
      request_validation: pass | fail
      status: ok | failed | skipped
      failure_class: <string|null>

    selected_provider: agyなのにGeminiも試行している、直接fallbackだけ成功した、またはcustom agentをspawnせずwrapperを直接実行した場合はPASSにしてはいけません。


    P0-4: 既存テストが新方針と矛盾し、しかも一部はCI非gating

    現在のtest_agent_contracts.pyは、web-researcher.mdに「Antigravityは未対応または同等動作を仮定しない」という保守的記述が残っていることを要求しています。これはgrounded_researchをAGY主経路にする本Issueと正面から矛盾します。

    実際のweb-researcher.mdにも、AGY移行後のgrounded_researchは未確認であり、同等動作を仮定しないという古い互換性ノートが残っています。

    また、#1142には、このcontract test群の一部がpristine mainでも失敗し、CIのpython-test jobでgatingされていないという既知のdriftが記録されたままです。

    したがって、現在のAllowed Pathsでは不足しています。

    追加が必要な変更:

    .claude/skills/gemini-cli-headless-delegation/tests/test_agent_contracts.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_agent_provider_routes.py  # 新規推奨
    tests/fixtures/codex-agent-config/expected-runtime-contract.json
    scripts/check_codex_agent_config.py
    scripts/check-codex-agents.mjs
    .github/ci/python-test-plan.json  # 対象テストが既に含まれない場合のみ
    

    既存のbase failureと今回のregressionを混同しないよう、対象nodeを限定したbaseline verificationも必要です。


    P0-5: Scope Collision preflightが陳腐化している

    現在のIssueは競合先として#1736と#159しか記載していません。しかしCodex CLIをスコープへ追加すると、少なくとも次の並行Issueと直接競合します。

    #1909

    • Claude CodeとCodex CLIの両方を対象
    • codebase-investigator/web-researcherの4ファイルすべてをAllowed Pathsに含む
    • Agent入力契約とlive dispatch smokeを変更する

    #1915

    • .codex/agents/codebase-investigator.toml
    • .codex/agents/web-researcher.toml
    • Codex permission profile
    • runtime fixtureとvalidator

    を同時に変更します。特にCodex web-researcherのdirect web fallbackを実際に可能にするpermission修正を担当しています。

    さらに、AGYを「主経路」へ昇格する前提となる検証も未完了です。

    推奨する依存順は次です。

    構造面:
      #1909 → #1915 → #1886
    
    AGY readiness gate:
      #1885
      #1814
           ↓
      #1886 merge可
    

    #1736と#159については、従来どおり編集sectionが異なるならrebase対応でも構いません。しかし#1909と#1915はCodex追加後の本Issueと同一ファイル・同一semantic contractを変更するため、単なる「later merge側でrebase」では不十分です。


    P1改善事項

    P1-1: Codex web-researcherのdirect web fallbackは現状保証されない

    現在のCodex web-researcher.toml自身が、割り当てられたread-only permissionではGitHub以外の公式ドキュメントへ到達できないと明記しています。

    Codexの公式permission仕様でも、outbound networkは明示的なdomain allowlistで制御され、必要最小限のprofileを選ぶことが求められています。(OpenAI Developers)

    したがって#1915が完了するまでは、Codex web-researcherについて次のように扱うべきです。

    AGY grounded_research 成功:
      正常
    
    AGY失敗 + GitHub内の調査:
      direct_cliを試行可能
    
    AGY失敗 + GitHub外の公式仕様調査:
      failed / inconclusive
      direct_web成功を仮定しない
    

    本Issue内でpermission profileまで変更すると#1915と重複するため、#1915をdependencyにして本Issueではroute bindingだけを扱うのが妥当です。


    P1-2: 配布中AGY CLIとリポジトリのpreflight前提にversion driftがある

    公式Antigravity CLIの現行changelogでは、1.1.9が最新リリースとして掲載されています。また1.1.8からheadless print modeに--output-format text|json|stream-json、typed NDJSON、--json-schema、tool/subagent情報が導入されています。(GitHub) (GitHub)

    さらに1.1.4では、headless実行がpersisted settings.json policyを尊重する修正と、承認を表示できないheadless環境でtoolをsoft-denyする修正が入っています。1.1.2では、完全headless環境で認証待ちにぶら下がらずfail-fastする修正が入っています。(GitHub) (GitHub)

    一方、リポジトリのpreflight testはagy 1.0.0を正常系fixtureとして使い、--output-formatを「unexpected capabilityだが非block」として扱っています。grounded proofも現時点では独自stdout markerに依存しています。

    このversion/output契約の更新自体は#1886へ入れるべきではありません。#1814のversion gateとpermission E2Eを先に完了させ、structured output移行が#1814の範囲外なら別Issueへ限定して切り出すべきです。

    推奨する最小構成

    過剰なprovider ledger、fallback executor、永続state storeは不要です。既存資産を次の責務に固定するのが最小です。

    資産 責務
    build_request.py provider別request shapeの唯一のbuilder
    run_gemini_headless.py validationとprovider dispatch
    profile_provider_contract_matrix.yaml profile/providerの対応可否
    Claude/Codex Agent定義 profile別にbuilderへ渡すproviderを指定
    targeted pytest 4 Agent surfaceとbuilder/validatorのparity検証
    live smoke 実際のcustom agent spawnとselected providerの証明

    新しいrouting schemaを増やすより、Agent定義に実際に実行するbuilder commandを記述し、そのexact command fragmentsと生成requestをテストする方が小さく、実装との乖離も抑えられます。

    Issue契約の修正案

    Machine-Readable Contract

    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#1265"
    goal_ref: "Claude Code / Codex CLI の codebase-investigator / web-researcher で profile別provider bindingをAGY-first方針へ同期する"
    change_kind: workflow
    blocked_by:
      - "#1885"
      - "#1814"
      - "#1909"
      - "#1915"

    Outcome

    Claude CodeとCodex CLIの双方で、以下のprovider bindingが
    canonical build_request.py経由で実行される。
    
    - codebase-investigator/local_asset_research -> agy
    - codebase-investigator/github_research -> gemini
    - web-researcher/grounded_research -> agy
    
    各requestはprovider-aware validatorを通過し、実際のcustom
    SubAgent/custom Agent dispatch smokeでselected_providerが確認される。
    
    direct fallbackだけが成功した場合、別providerへ暗黙fallbackした場合、
    またはcustom agentをspawnせずwrapperを直接呼んだだけの場合は完了としない。
    

    Allowed Paths

    .claude/agents/codebase-investigator.md
    .claude/agents/web-researcher.md
    .codex/agents/codebase-investigator.toml
    .codex/agents/web-researcher.toml
    
    .claude/skills/gemini-cli-headless-delegation/tests/test_agent_contracts.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_agent_provider_routes.py
    
    tests/fixtures/codex-agent-config/expected-runtime-contract.json
    scripts/check_codex_agent_config.py
    scripts/check-codex-agents.mjs
    
    .github/ci/python-test-plan.json
      # targeted testが既存planに含まれない場合のみ
    

    Out of Scope

    - run_gemini_headless.pyのprovider dispatchロジック変更
    - provider=autoのeligible profile拡張
    - github_research × agy対応
    - AGY permission/version実装(#1814)
    - AGY subprocess安定化(#1885)
    - Codex web permission profile変更(#1915)
    - context bundle契約変更(#1909)
    - 新規fallback executor、ledger、永続state store
    

    Runtime Verification Applicability

    decision: immediate
    applicable_acs:
      - claude_local_asset_route
      - claude_grounded_route
      - claude_github_route
      - codex_local_asset_route
      - codex_grounded_route
      - codex_github_route
    execution_environment:
      - claude_code_custom_subagent_dispatch
      - codex_cli_custom_agent_dispatch
    skip_conditions:
      - required CLI or authentication unavailable
      - "#1909由来のexact custom-agent smoke launcherがcurrent mainに存在しない"
    fallback_success_is_pass: false
    artifact_requirements:
      - selected_provider
      - provider_attempts
      - request_validation
      - runtime
      - agent
      - profile

    修正版Acceptance Criteria

    AC 完了条件
    AC1 Claude codebase-investigator/local_asset_researchがbuilderへprovider=agyとpromptを渡す
    AC2 Claude codebase-investigator/github_researchがprovider=geminiを渡す
    AC3 Claude web-researcher/grounded_researchがprovider=agyとpromptを渡す
    AC4 Codex codebase-investigatorがAC1・AC2と同じbindingを持つ
    AC5 Codex web-researcherがAC3と同じbindingを持つ
    AC6 AGY requestがGemini専用fieldを持たず、provider-aware validationを通る
    AC7 Gemini github_research requestが既存structured contractを維持する
    AC8 全bindingがprofile/provider matrixの許可値と一致する
    AC9 Geminiへ必ず委譲、AGY grounded未確認等のstale記述が残らない
    AC10 Codex fixture/validatorがprofile別provider invocationを検証する
    AC11 ClaudeとCodexの実custom-agent dispatchで期待providerが選択される
    AC12 AGY失敗時のdirect fallbackや別provider fallbackをPASS扱いしない
    AC13 targeted testsがCIでgatingされ、既知base failureと分離されている

    Verification Commands案

    # provider別request shape / validator parity
    uv run --locked pytest \
      .claude/skills/gemini-cli-headless-delegation/tests/test_agent_provider_routes.py \
      .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provider_prompt_first_contract.py \
      .claude/skills/gemini-cli-headless-delegation/tests/test_agy_local_asset_research_contract.py \
      -q
    # Codex custom agent static contract
    uv run --locked python3 scripts/check_codex_agent_config.py
    # stale wording
    rg -n \
      -e '必ず.*Gemini' \
      -e 'grounded_research.*未対応' \
      -e 'grounded_research.*仮定しない' \
      .claude/agents/codebase-investigator.md \
      .claude/agents/web-researcher.md \
      .codex/agents/codebase-investigator.toml \
      .codex/agents/web-researcher.toml
    git diff --check

    Claude Code/Codex CLIのlive smoke commandは、架空のcodex exec --agent等をIssueへ書くべきではありません。#1909がcurrent mainへ提供する実際のcustom-agent dispatch launcherをreadbackし、そのexact invocationをAC11のVCへ固定してください。launcherが提供されていなければ、#1886のStop Conditionとして扱うべきです。

    最終結論

    指定コメントの方向性、すなわちClaude CodeだけでなくCodex CLIの同名custom agentもAGY主経路へ同期すること自体は妥当です。

    ただし、現在のIssueは以下の理由でそのまま実装できません。

    1. 提案されている一行追加はAGY prompt-first contractに違反する
    2. Codex側の実行binding・fixture・validator・live smokeが未定義
    3. Runtime Verificationを不要扱いしている
    4. 既存contract testと新方針が矛盾している
    5. 実装: SubAgent 発火前に bounded local context bundle を生成し Claude/Codex の両 loop で consume する #1909/#1915との衝突が未反映
    6. 実装: Antigravity CLI one-shot delegation の出力取得を安定化する #1885/#1814が未完了のままAGYを主経路へ昇格しようとしている

    したがって、Issue本文を上記契約へ改訂し、blocked_byとAllowed Pathsを更新した後にissue-refinement-loopを再実行するのが適切です。


    you asked

    message time: 2026-08-01 15:42:50

    Claude Code
    web-researcher
    grounded_research
    agy
    Codex CLI
    codebase-investigator
    github_research
    gemini

    とあるけどGeminiCLIはFallback先であり期待プロバイダは全てAntigravityCLIにして。


    chatgpt response

    理解しました。期待プロバイダは全経路でagy、geminiは失敗時の第二候補に統一します。これは#1886の単純なAgent定義修正ではなく、github_research対応とauto policy拡張を含む契約変更になります。

    了解しました。前回の表は誤りです。期待プロバイダは全経路でAntigravity CLI(agy)、Gemini CLI(gemini)はfallbackに限定します。

    修正後の期待経路

    Runtime Agent Profile 期待provider fallback
    Claude Code codebase-investigator local_asset_research agy gemini
    Claude Code codebase-investigator github_research agy gemini
    Claude Code web-researcher grounded_research agy gemini
    Codex CLI codebase-investigator local_asset_research agy gemini
    Codex CLI codebase-investigator github_research agy gemini
    Codex CLI web-researcher grounded_research agy gemini

    ただし、この方針にすると#1886の現在のスコープでは実現できません。現在は次の制約があります。

    • github_research × agyがmatrix上でunsupported_by_design
    • AGY_SUPPORTED_PROFILESにgithub_researchが含まれない
    • PROVIDER_AUTO_ELIGIBLE_PROFILESはno_toolsとproposal_onlyだけ
    • #1886はruntime providerロジック変更をOut of Scopeにしている
    • #1886本文はgithub_researchにprovider: geminiを明示する方針になっている

    推奨実装

    Agent側でprovider: "agy"を直接固定して個別fallbackを書くのではなく、全対象profileで次を使う構成が妥当です。

    {
      "provider": "auto",
      "tool_profile": "local_asset_research | grounded_research | github_research"
    }

    runtime側は既存方針を維持します。

    provider order:
      agy
      ↓ retryable failureのみ
      gemini
    

    AGYの以下の失敗はGeminiで迂回してはいけません。

    • request validation failure
    • permission policy failure
    • evidence validation failure
    • unsupported/unsafe request
    • authentication/authorization failure

    既存の人間判断でも、AGYを第一provider、Geminiを第二providerとし、安全性・validation・permission・evidence failureをfallbackで迂回しない方針が固定されています。

    github_research × agyの実装方式

    AGYへghやGitHub mutation capabilityを直接渡す必要はありません。local_asset_researchと同様に、wrapper-owned retrievalに寄せます。

    1. wrapperがgh_commandsを既存allowlistで検証
    2. wrapperがgh CLIをread-onlyで実行
    3. Issue/PR/commentの取得結果をbounded evidenceに変換
    4. evidenceをAGY promptへ注入
    5. AGYは分析のみ実行
    6. GitHubへの書込みは不許可
    

    現行matrix自身も、github_research × agyが非対応なのは上流Antigravity CLIの能力不足ではなく、リポジトリwrapperのAGY_SUPPORTED_PROFILESから除外している設計判断だと明記しています。したがって、wrapper側のread-only retrieval実装でimplementedへ変更できます。

    #1886の修正版Outcome

    Claude CodeおよびCodex CLIのcodebase-investigator/web-researcherが、
    local_asset_research/grounded_research/github_researchの全profileで
    provider=autoを指定し、Antigravity CLIを第一providerとして実行する。
    
    Antigravity CLIがretryableなquota/capacity系failureで失敗した場合のみ
    Gemini CLIを第二providerとして試行する。
    
    request validation、permission policy、authentication、evidence validation、
    unsupported profile等の失敗ではGemini fallbackを実行しない。
    
    github_researchはwrapper-owned read-only gh retrievalの結果をAGY promptへ
    注入する方式で対応し、AGYへGitHub mutation capabilityを与えない。
    

    必要なスコープ変更

    #1886のAllowed Pathsは、最低でも次へ拡張する必要があります。

    # Agent surfaces
    .claude/agents/codebase-investigator.md
    .claude/agents/web-researcher.md
    .codex/agents/codebase-investigator.toml
    .codex/agents/web-researcher.toml
    
    # Runtime / contract
    .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
    .claude/skills/gemini-cli-headless-delegation/config/profile_provider_contract_matrix.yaml
    .claude/skills/gemini-cli-headless-delegation/references/provider-mapping.md
    .claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
    
    # Tests
    .claude/skills/gemini-cli-headless-delegation/tests/test_agent_provider_routes.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_contract.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_provider_auto_priority.py
    .claude/skills/gemini-cli-headless-delegation/tests/test_validate_request_for_provider.py
    
    # Codex static contract
    tests/fixtures/codex-agent-config/expected-runtime-contract.json
    scripts/check_codex_agent_config.py
    scripts/check-codex-agents.mjs
    

    修正版Acceptance Criteria

    1. local_asset_research、grounded_research、github_researchがすべてprovider=autoを受理する。
    2. 3 profileすべてで最初のattemptがagyになる。
    3. AGY成功時はGemini attemptが存在しない。
    4. retryableなAGY quota/capacity failure時だけGeminiが第二attemptになる。
    5. validation/permission/auth/evidence failureではGeminiへfallbackしない。
    6. github_research × agyがwrapper-owned read-only gh retrievalを使用する。
    7. github_research × agyがGitHub mutation commandを拒否する。
    8. matrixのgithub_research.agy.valueがimplementedへ更新される。
    9. Claude CodeとCodex CLIの6経路すべてでAGYが選択される。
    10. fallback経由のみの成功はAGY経路のruntime smoke PASSとして扱わない。

    修正版Runtime Verification

    decision: immediate
    required_routes:
      - claude_code/codebase-investigator/local_asset_research
      - claude_code/codebase-investigator/github_research
      - claude_code/web-researcher/grounded_research
      - codex_cli/codebase-investigator/local_asset_research
      - codex_cli/codebase-investigator/github_research
      - codex_cli/web-researcher/grounded_research
    success_condition:
      selected_provider: agy
      first_provider_attempt: agy
      gemini_attempt_count: 0
    fallback_success_is_pass: false

    なお、#1886本文の「github_researchはprovider: geminiを明示する」「#1808で確定済み」という記述は削除が必要です。#1808は#1806の重複としてクローズされており、実際のmatrix判定は#1806/PR #1823で追加されています。


    Powered by AI Exporter

  4. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    • Cause: human_judgment_required
    • Issue: 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886
    • Iteration: 0
    • Anchor: 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 (comment)
    • Blockers:
      • checker_execution_policy_denied: issue-reviewer が決定論的 checker を実行できず、ISSUE_REVIEW_RESULT_COMPACT_V1 を生成できなかった。
      • review_compact.validate に渡すべき生の compact stdout artifact が存在しないため、validator-first 契約を満たせない。
      • GEMINI_DELEGATION_SETUP_AUTH_TIMEOUT: 必須の codebase-investigator 委譲で Gemini 認証 smoke が timeout し、repo 調査が fail-closed となった。
    • 調査済みの注意点:
      • AGY の prompt 必須・model 禁止は AGY CLI 一般の制約ではなく、LOOP_PROTOCOL の AGY provider request adapter の制約として扱う必要がある。
      • Codex custom agent の静的 TOML 検査は実 dispatch・実効 permission の証跡にはならない。
    • 再開条件:
      1. issue-reviewer が checker を実行して validator 対象の raw compact output を生成できること。
      2. Gemini OAuth / network timeout を解消し、required codebase investigation を wrapper 経由で完了できること。
      3. 上記を満たした current Issue body と同じ anchor で issue-refinement-loop を再実行すること。
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
  5. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    調査結果

    現行の human escalation は、そのまま再開条件として採用すべきではありません。

    ブロッカーは次の2件に分離する必要があります。

    1. issue-reviewer が checker 実行に必要な一時ファイル/artifactを書けない
    2. codebase-investigator が利用不能な Gemini CLI を必須経路としている

    特に「Gemini OAuth / network timeout を解消する」は再開条件から削除します。今回は Gemini CLI を operator-disabled とし、起動も認証確認も行わないのが正しい扱いです。

    1. checker_execution_policy_denied の最有力原因

    これは Issue #1886 の本文品質ではなく、Codex runtime permission の契約不整合である可能性が高いです。

    現在の issue-reviewer.toml は loop-protocol-readonly ですが、review-issue の正規手順は、Issue本文の一時ファイル、checker結果、readiness結果、merged結果、最終artifactを書き出す必要があります。一方、readonly profile はworkspaceも一時領域もread-onlyです。

    Codex permission profileでは、read はファイルの作成・変更を許可せず、write を特定のworkspace相対サブパスや:tmpdirだけに限定できます。また、subagentには親セッションのlive permission overrideが再適用されるため、TOMLの静的検査だけでは実効権限の証拠になりません。([OpenAI Developers]1)

    したがって、issue-reviewer 専用の最小権限profileを別Issue・別PRで追加するのが妥当です。

    # 概念例。実際のgrammarと既存fixtureを確認して確定する。
    [permissions.loop-protocol-issue-reviewer.filesystem]
    ":minimal" = "read"
    ":tmpdir" = "write"
    ":slash_tmp" = "write"
    
    [permissions.loop-protocol-issue-reviewer.filesystem.":workspace_roots"]
    "." = "read"
    ".claude/artifacts/issue-refinement-loop" = "write"

    loop-protocol-rtkのようなworkspace全体write profileを流用する必要はありません。

    2. Issue #1886 は現行本文のままでは要求を満たさない

    現在の本文はClaude Code側の2ファイルしか対象にせず、github_researchをGeminiのまま維持し、runtime verificationもnot_applicableとしています。Codex CLIを追加し、全profileでAGYを期待する現在の方針とは一致しません。

    現行runtimeには次の制約があります。

    • local_asset_research × agy: implemented
    • grounded_research × agy: implemented
    • github_research × agy: unsupported_by_design
    • provider=autoの順序はAGY→Gemini
    • ただしauto対象はno_toolsとproposal_onlyだけ

    したがって、Agent定義にprovider=autoと書くだけでは解決しません。

    推奨構成は以下です。

    • 現在の運用: 全対象経路を明示的なprovider=agyで実行
    • Gemini CLI: disabled_by_operator。起動・認証smoke・fallbackを行わない
    • 将来: 利用可能になった場合だけ、operator-controlledな第二候補として再有効化
    • github_research: wrapperがread-only gh retrievalを実行し、bounded evidenceをAGY promptへ渡す
    • AGY: GitHub mutation capabilityを持たず、取得済みevidenceの分析だけを行う

    AGY requestはrepo adapterのprompt-first契約に従い、手書きJSONではなくbuild_request.py --provider agy --prompt ...を使用します。modelは付けません。

    3. 関連Issue・PRの扱い

    AGY公式側も、headless subprocessのhang・空stdout、headless認証fail-fast、persisted permission policy、structured JSON outputを段階的に改善しています。実行時にはagy --versionを記録すべきですが、structured JSON移行自体を#1886へ混入させる必要はありません。([GitHub]2)

    Codex CLIへの作業プロンプト

    あなたは squne121/loop-protocol の root/main Codex CLI control-plane として作業してください。

    対象:

    最終目的

    Issue #1886 の refinement を、Gemini CLI に一切依存せず再開可能にする。

    期待providerは以下の全経路でAntigravity CLI (agy) とする。

    • Claude Code / codebase-investigator / local_asset_research
    • Claude Code / codebase-investigator / github_research
    • Claude Code / web-researcher / grounded_research
    • Codex CLI / codebase-investigator / local_asset_research
    • Codex CLI / codebase-investigator / github_research
    • Codex CLI / web-researcher / grounded_research

    Gemini CLIは将来的な第二候補になり得るが、現在はAPI料金上限に到達しているためoperator-disabledとする。

    絶対条件

    GEMINI_RUNTIME_POLICY_V1:
      state: disabled_by_operator
      reason: api_billing_or_quota_limit
      prohibit:
        - gemini CLI invocation
        - Gemini OAuth smoke
        - Gemini setup_check
        - Gemini retry
        - Gemini fallback
        - Gemini availabilityを再開条件にすること
    • geminiコマンドを実行しない。
    • Gemini認証復旧を待たない。
    • Gemini失敗を再現するためのsmokeも行わない。
    • Gemini利用不能をhuman_judgment_requiredの理由にしない。
    • 存在しないraw compact stdoutを再構築、再転記、捏造しない。
    • merge、force-push、branch削除を行わない。
    • GitHub mutationはrepo内のcanonical skill/controlled mutation laneを使う。
    • current main、Issue本文、指定anchorを毎phaseでfresh readする。

    事前調査

    次をfresh readしてください。

    Issue:
      #1886
      #1814
      #1885
      #1909
      #1915
    
    PR:
      #1910
      #1919
    
    Repo assets:
      .codex/agents/issue-reviewer.toml
      .codex/agents/codebase-investigator.toml
      .codex/agents/web-researcher.toml
      .codex/config.toml
    
      .claude/agents/codebase-investigator.md
      .claude/agents/web-researcher.md
    
      .claude/skills/review-issue/SKILL.md
      .claude/skills/issue-refinement-loop/SKILL.md
      .claude/skills/issue-refinement-loop/scripts/command_registry.py
      .claude/skills/issue-refinement-loop/scripts/validate_review_compact_output.py
      .claude/skills/issue-refinement-loop/scripts/compact_review_result.py
    
      .claude/skills/gemini-cli-headless-delegation/scripts/build_request.py
      .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py
      .claude/skills/gemini-cli-headless-delegation/config/profile_provider_contract_matrix.yaml
      .claude/skills/gemini-cli-headless-delegation/references/provider-mapping.md
      .claude/skills/gemini-cli-headless-delegation/references/usage-contract.md
    

    初期調査では、現在のcodebase-investigator custom agentを起動しないでください。現行定義がGemini委譲を必須としている可能性があるためです。

    代わりにroot threadのread-only調査、またはGemini delegationを行わない汎用explorer agentを使用してください。nested delegationは禁止します。


    Phase 1: checker_execution_policy_denied の根本修復

    1.1 再現と原因特定

    issue-reviewerを実際にspawnし、次のどの操作がpolicy denyされたか特定してください。

    • Issue本文の一時ファイル作成
    • review_result.json作成
    • readiness_result.json作成
    • merged_review_result.json作成
    • .claude/artifacts/issue-refinement-loop/<N>/へのartifact作成
    • checker subprocess実行
    • その他

    最低限、以下を記録してください。

    ISSUE_REVIEWER_PERMISSION_DIAGNOSIS_V1:
      agent: issue-reviewer
      effective_permission_profile: <string>
      parent_runtime_override: <string|null>
      denied_operation:
        argv: []
        path: <string|null>
        access: read | write | execute | network
      denial_source: permission_profile | approval_unavailable | command_policy | unknown
      reproduction_exit_code: <int>
      evidence_artifact: <repo-relative-or-tmp-path>

    TOML静的検査だけで原因確定してはいけません。実spawn時のeffective permissionと、実際に拒否されたpath/commandを証拠にしてください。

    1.2 独立Issue化

    原因がpermission mismatchなら、#1886に混入させず、dedupe確認後に専用Issueを作成してください。

    推奨タイトル:

    修正: Codex issue-reviewer に checker一時出力と refinement artifact の最小write権限を付与する
    

    専用permission profileの推奨境界:

    filesystem:
      repo_source: read_only
      system_tmp: write
      slash_tmp: write
      refinement_artifact_subtree:
        path: .claude/artifacts/issue-refinement-loop
        access: write
    
    network:
      github_read: allowed
      arbitrary_web: denied
    
    prohibited:
      - source code edit
      - Issue/PR/comment mutation
      - commit
      - push
      - merge
      - nested subagent

    .codex/config.tomlのpermission grammarで、workspace全体readの内側に特定subtree writeを定義できるか実装・テストで確認してください。

    loop-protocol-rtk等のworkspace全体write profileを安易に流用しないでください。

    profile grammar上、限定subtree writeが不可能な場合のみ、次の代替案を比較してください。

    1. invocation-private tmpdirにreview artifactを生成し、parentが検証後にmaterializeする
    2. dedicated controlled executorだけにartifact writeを許可する
    3. current artifact path契約を最小変更する

    新規ledger、永続state store、複雑なpublisherは追加しないでください。

    1.3 Draft PRと実runtime検証

    専用Issueから1 Issue = 1 Draft PRで実装してください。

    静的fixtureだけで完了にせず、次を実runtimeで証明してください。

    issue-reviewer custom agent spawn
      -> current Issue body取得
      -> deterministic checker実行
      -> readiness checker実行
      -> merged review artifact生成
      -> compact_review_result.pyがraw stdout生成
      -> raw stdout bytesを変更せずreview_compact.validateへ入力
      -> validation_status=valid
    

    必須条件:

    • raw child stdoutをparentが再転記しない
    • validator前にVERDICT / NEXT_ACTION / ARTIFACTを読まない
    • compact stdoutは現行byte budget以内
    • artifactにはsecretを含めない
    • parent live permission override適用時も結果を記録する
    • approvalを表示できないnon-interactive環境で失敗する場合、その条件を独立して報告する

    このPhaseの修復がcurrent mainへ未統合なら、#1886 refinementを成功扱いしないでください。Draft PRと明確なhandoffを残してください。


    Phase 2: Issue #1886 の契約再設計

    Issue #1886の現在本文を、指定anchor commentと現在のowner方針に合わせて改訂してください。

    2.1 再開条件の修正

    以下を削除してください。

    Gemini OAuth / network timeout を解消する
    Gemini authentication smoke を通す
    Gemini delegationをrequired codebase investigationとして成功させる
    

    代わりに以下を再開条件としてください。

    resume_conditions:
      - issue-reviewerがdeterministic checkerを実行できる
      - fresh raw ISSUE_REVIEW_RESULT_COMPACT_V1 stdoutを生成できる
      - raw stdout bytesがreview_compact.validateでvalidになる
      - required investigationがAGYまたはparent-owned read-only retrievalで完了する
      - Gemini CLIは一切起動されない

    2.2 provider方針

    現在の実行方針:

    provider_policy:
      expected_provider: agy
      gemini_state: disabled_by_operator
      fallback_enabled: false

    将来的なGemini fallbackを記述する場合は、次の条件を明記してください。

    future_optional_fallback:
      enabled_only_by_explicit_operator_decision: true
      never_a_resume_requirement: true
      never_bypasses:
        - validation failure
        - permission failure
        - authentication failure
        - evidence validation failure
        - unsupported profile

    現在のruntimeでprovider=auto対象profileが限定されていることを確認し、単にAgent定義へprovider=autoを書くだけの修正は禁止します。

    2.3 AGY request構築

    Agent定義内でprovider別JSONを手書きしないでください。

    canonical builderを使用してください。

    AGY経路は次の契約を満たすこと。

    build_request.py
      --provider agy
      --profile <profile>
      --prompt <non-empty prompt>
    
    • modelを指定しない
    • builder出力をprovider-aware validatorへ通す
    • request builderとruntime validatorのparityをテストする
    • AGY adapterのprompt required / model forbiddenを、AGY CLI一般仕様とは表現しない

    2.4 github_research × agy

    現在のmatrixでgithub_research × agyがunsupportedなら、単にmatrix値を書き換えないでください。

    最小実装は以下とします。

    caller / wrapper
      -> read-only gh argvをallowlist validation
      -> gh CLIでIssue / PR / commentを取得
      -> bounded・redacted・repo-relative evidence envelopeを生成
      -> evidenceをAGY promptへ注入
      -> AGYは分析のみ実行
    

    禁止事項:

    • AGYへGitHub mutation capabilityを渡す
    • AGYへ自由形式shellを渡す
    • gh issue edit/comment/close
    • gh pr merge/review
    • unsupportedを文字列変更だけでimplementedにする
    • direct fallbackだけの成功をAGY routeの成功と扱う

    この能力追加が#1886の1 PRとして過大またはAllowed Paths競合になる場合は、dedupe後に専用child Issueを作成し、#1886のblocked_byへ追加してください。

    推奨child title:

    実装: github_research の read-only GitHub evidence を Antigravity CLI promptへ渡す
    

    過剰なfallback executor、attempt ledger、永続state storeは追加しないでください。

    2.5 Claude / Codex surface

    対象:

    .claude/agents/codebase-investigator.md
    .claude/agents/web-researcher.md
    .codex/agents/codebase-investigator.toml
    .codex/agents/web-researcher.toml
    

    各surfaceについて、説明文だけでなく実際のbuilder invocation、profile、expected providerを検証してください。

    期待route:

    required_routes:
      - runtime: claude_code
        agent: codebase-investigator
        profile: local_asset_research
        selected_provider: agy
    
      - runtime: claude_code
        agent: codebase-investigator
        profile: github_research
        selected_provider: agy
    
      - runtime: claude_code
        agent: web-researcher
        profile: grounded_research
        selected_provider: agy
    
      - runtime: codex_cli
        agent: codebase-investigator
        profile: local_asset_research
        selected_provider: agy
    
      - runtime: codex_cli
        agent: codebase-investigator
        profile: github_research
        selected_provider: agy
    
      - runtime: codex_cli
        agent: web-researcher
        profile: grounded_research
        selected_provider: agy

    2.6 Runtime Verification

    Runtime Verification Applicabilityはimmediateに変更してください。

    成功条件:

    success_condition:
      selected_provider: agy
      first_provider_attempt: agy
      gemini_attempt_count: 0
      request_validation: pass
      custom_agent_was_actually_spawned: true
      fallback_success_is_pass: false

    最低artifact:

    AGENT_PROVIDER_ROUTE_SMOKE_V1:
      runtime: claude_code | codex_cli
      agent: codebase-investigator | web-researcher
      profile: local_asset_research | grounded_research | github_research
      selected_provider: agy
      provider_attempts: [agy]
      request_validation: pass | fail
      status: ok | failed | skipped
      failure_class: <string|null>
      agy_version: <string|null>

    TOML/Markdownの静的文字列検査だけで完了扱いにしないでください。

    2.7 関連Issue/PRの整理

    fresh stateを確認し、以下を処理してください。

    誤った#1808参照が残っている場合は、実際のmatrix導入Issue/PRへ修正してください。


    Phase 3: issue-refinement-loop 再実行

    Phase 1のpermission修復が実効環境に反映された後、次を行ってください。

    1. Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 current bodyをfresh fetch
    2. 同じanchor commentを使用
    3. refinement preflightをcanonical main rootから実行
    4. required investigationをAGY経路で実行
    5. Gemini CLIを起動しない
    6. issue-reviewerをfresh spawn
    7. fresh raw compact stdoutを生成
    8. raw bytesを変更せずreview_compact.validateへ渡す
    9. validator valid後だけrouting fieldを読む
    10. needs-fixなら通常のrewrite loopを継続
    11. approveなら通常のhandoffを生成

    既存の欠落raw stdoutを再利用・復元してはいけません。必ずfresh reviewer executionから生成してください。

    AGYが失敗した場合は、そのAGY failure classとevidenceを報告して停止してください。Geminiへ切り替えてはいけません。


    Verification

    最低限、以下を実行してください。exact commandはcurrent mainのregistry/skillをSSOTとしてreadbackし、架空のcommandは作らないでください。

    - Codex agent config validator
    - permission profile fixture tests
    - issue-reviewer actual spawn smoke
    - review-issue deterministic checker
    - compact producer
    - review_compact.validate with exact raw stdout
    - provider-aware request builder tests
    - AGY local_asset_research tests
    - AGY grounded_research tests
    - AGY github_research tests(実装する場合)
    - Claude custom SubAgent route smoke
    - Codex custom Agent route smoke
    - git diff --check
    - Allowed Paths validation
    

    agy --versionを記録してください。version更新やstructured JSON migrationが別Issueの責務なら、#1886へ混入させず観測値だけを残してください。


    最終報告形式

    ISSUE_1886_RECOVERY_RESULT_V1:
      status: completed | partially_completed | blocked
      gemini_invoked: false
      issue_reviewer_permission:
        diagnosis: <string>
        follow_up_issue: <number|null>
        draft_pr: <number|null>
        runtime_spawn_verified: true | false
      issue_1886:
        body_updated: true | false
        body_sha256: <string|null>
        expected_provider_all_routes: agy
        github_research_agy:
          status: implemented | child_issue_created | blocked
          issue: <number|null>
      overlap:
        issue_1909: <disposition>
        pr_1919: <disposition>
      refinement_loop:
        rerun: true | false
        anchor: issuecomment-5150262204
        iteration: <int|null>
        validator_status: valid | invalid | not_run
        final_status: approved | needs_fix | human_escalation | not_run
      blockers: []
      next_actions: []

    人間向けsummaryには、以下を明示してください。

    • Gemini CLIは意図的に実行していない
    • checker permission問題とprovider問題を別々に扱った
    • raw compact stdoutを再構築していない
    • 実AGY route smokeの成否
    • 作成・更新したIssue/Draft PR
    • merge待ち、rebase待ち、human decisionが必要な項目

    このプロンプトは、まずcontrol-planeの権限不整合を別PRで直し、その後に同じanchorで#1886を再実行する順序です。Issue本文の修正だけに限定する場合は、Phase 1を「専用Issue起票と診断まで」で停止させてください。

  6. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    判定

    別スコープの承認やsnapshot-null例外は、まだ不要です。
    停止判断は正しく、既存worktreeもそのまま再利用できます。

    原因は、#1838 のfresh review承認コメントが ISSUE_1838_REFINEMENT_RESULT であり、commit laneが要求するfingerprint付きの CONTRACT_REVIEW_RESULT_V1 status: go ではないことです。#1838本文自体は修正済みで、fresh reviewerの承認も記録されています。

    materialize_issue_scope_snapshot.py は、指定コメントをcanonical parserで再解析し、次をすべて満たす場合だけ受理します。

    • CONTRACT_REVIEW_RESULT_V1
    • status: go
    • trusted publisher
    • comment ID、Issue body SHA、Allowed Paths hash、base branch SHAに束縛されたfingerprint

    今回指定されたコメントはこの形式ではないため、contract_source_not_found は仕様どおりです。

    正規の復旧経路は、cleanなcanonical mainから ensure_contract_snapshot.py --mode auto --post を実行し、受理可能なコメントを生成してから、同じworktreeでcontrolled commitを再実行することです。このスクリプトは、provisional commentの投稿、実comment ID取得、fingerprint付与、同一コメントのPATCH、publisher/body readbackまで実装しています。

    以下をCodex CLIのmain sessionへ渡してください。

    Issue #1838 の実装済みworktreeから、正規のcontract sourceを生成してcommit・Draft PR・検証・独立レビューまで再開してください。

    対象:

    既存実装を破棄・再実装しないでください。まずcontract sourceを復旧し、その後に既存worktreeをpublishしてください。

    絶対禁止

    • raw git add
    • raw git commit
    • guardを回避するraw git操作
    • snapshot-null bypass
    • 手書きのCONTRACT_REVIEW_RESULT_V1
    • 既存refinement approval commentをcontract_snapshot_urlとして再利用すること
    • controlled_git_change_exec.py、materializer、parserの緩和
    • Issue #1838のAllowed Paths外のコード変更
    • 実装済み6ファイルの不要な再編集

    ISSUE_1838_REFINEMENT_RESULT はrefinement承認記録であり、controlled commit用のcontract sourceではありません。

    1. Sparkによるread-only復旧監査

    最初に gpt-5.3-codex-spark の spark-deep SubAgentを1件起動してください。

    task_name: publish_lane_recovery_audit
    agent_type: spark-deep
    fork_turns: none
    message: |
      Objective:
        Issue #1838の既存worktreeを変更せず、正規contract source生成から
        controlled commit、Draft PR作成までの復旧経路を監査する。
    
      Live references:
        - Issue #1838
        - .claude/worktrees/issue-1838-native-v2-dispatch
        - .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py
        - scripts/agent-guards/materialize_issue_scope_snapshot.py
        - scripts/agent-guards/controlled_git_change_exec.py
    
      Check:
        - current CLI --helpとrequest schema
        - contract sourceに必要なcomment markerとfingerprint
        - exact materializer output path
        - worktree branch、HEAD、changed paths
        - base SHA drift時の再materialization手順
    
      Constraints:
        - read-only
        - write、commit、push、Issue/PR mutation、review verdictは禁止
        -既存実装を変更しない
    
      Expected result:
        - SPARK_AGENT_RESULT_V1
        - exact commands/arguments
        - stop conditions
        - known race/drift risks

    Sparkの結果を参考証拠として使用し、mutationや最終判断はmain sessionが所有してください。

    2. 既存worktreeの保全確認

    次をfresh readしてください。

    • worktreeの絶対パス
    • branch名
    • current HEAD
    • staged / unstaged / untracked状態
    • changed paths
    • merge、rebase、cherry-pick、unmerged indexの有無

    変更ファイルが次の6件だけであることを確認してください。

    scripts/check_impl_review_loop_codex_dispatch.py
    tests/test_check_impl_review_loop_codex_dispatch.py
    .claude/skills/impl-review-loop/steps/step-1-implementation.md
    .claude/skills/impl-review-loop/steps/step-2-verification.md
    .claude/skills/impl-review-loop/steps/step-4-pr-review.md
    .claude/skills/post-merge-cleanup/SKILL.md
    

    別ファイルの変更、既存staged content、unmerged index、HEAD driftがあればcommitせず停止してください。

    ここでは再検証やファイル編集を行わず、状態だけ取得してください。

    3. canonical mainからcontract sourceを生成

    この手順は、変更済みworktreeではなく、cleanなcanonical main rootから実行してください。

    理由:

    • ensure_contract_snapshot.py はIssue contractのbaseline reviewを行う
    • 変更済みworktreeから実行すると、baseline-fail VCが実装済み状態でPASSし、誤ってunexpected_passになる可能性がある
    • contract fingerprintはlive Issue body、Allowed Paths、GitHub default branch tipに束縛される

    canonical main rootがcleanであることを確認した後、current --help を読んで引数を確認し、次の正規コマンドを実行してください。

    uv run --locked python3 \
      .claude/skills/impl-review-loop/scripts/ensure_contract_snapshot.py \
      --issue-number 1838 \
      --repo squne121/loop-protocol \
      --mode auto \
      --post

    stdoutのJSONだけをconsumeしてください。

    必須条件:

    schema: CONTRACT_SNAPSHOT_ENSURE_RESULT_V1
    status: ok
    contract_snapshot_url: <Issue #1838のissuecomment URL>
    post_status: posted | deduped_existing

    次の結果では停止してください。

    blocked_needs_refinement
    human_judgment
    stale_or_conflicting_snapshot
    controlled_publisher_binding_failed
    runtime_error
    dry_run_would_post
    

    status: ok以外を人間判断で上書きしてはいけません。

    4. 投稿されたcontract sourceをfresh readback

    返された contract_snapshot_url のコメントをGitHubから再取得し、canonical parserと同じ条件で確認してください。

    必須:

    • fenced YAML内に CONTRACT_REVIEW_RESULT_V1
    • status: go
    • generated_by: issue-contract-review
    • issue_url がIssue #1838と完全一致
    • body_sha256 がlive Issue本文と一致
    • expected_contract_fingerprint.issue_number == 1838
    • contract_source_kind == issue_comment
    • contract_source_id が実comment IDと一致
    • contract_body_sha256 がbody_sha256と一致
    • allowed_paths_normalized_sha256がcurrent Issueの6 Allowed Pathsと一致
    • base_refがGitHubのcurrent default branch
    • base_sha_at_snapshotがcurrent default branch tip
    • publisher identityがcanonical trusted publisher条件を満たす

    refinement approval commentや人間向けsummaryをcontract sourceに差し替えないでください。

    5. controlled commit requestを構築

    既存worktreeで、次を再取得してください。

    cwd: worktreeの絶対realpath
    branch_name: git branch --show-current
    expected_head: git rev-parse HEAD
    base_ref: GitHubのlive default branch名
    gh_bin: current gh executableの絶対パス
    contract_snapshot_url: Step 3のstatus: okから得たURL
    

    materialize requestは次のキーだけを持つexact JSONとしてください。

    {
      "issue_number": 1838,
      "repo": "squne121/loop-protocol",
      "contract_snapshot_url": "<fresh CONTRACT_REVIEW_RESULT_V1 comment URL>",
      "base_ref": "<live default branch>",
      "branch_name": "<exact current worktree branch>",
      "output": "artifacts/1838/issue-metadata/issue_scope_snapshot.materialize/issue_scope_snapshot.json",
      "gh_bin": "<absolute gh path>"
    }

    追加キー、欠落キー、null値を入れないでください。

    request fileとcommit-message fileは、repositoryのsanctioned temporary-file経路を使って生成してください。tracked pathへ追加せず、commit対象にも含めないでください。hookがcompound commandやheredocを拒否する場合は、既存のapproved helperまたは単一commandの安全なfile生成経路を使ってください。

    6. controlled commit

    controlled_git_change_exec.py --helpをfresh readし、current CLIに従って実行してください。

    概念的には次を渡します。

    --cwd <worktree absolute path>
    --materialize-request <request JSON path>
    --expected-head <pre-commit HEAD>
    --message "feat: migrate canonical dispatch instructions to native v2 shape"
    
    --path scripts/check_impl_review_loop_codex_dispatch.py
    --path tests/test_check_impl_review_loop_codex_dispatch.py
    --path .claude/skills/impl-review-loop/steps/step-1-implementation.md
    --path .claude/skills/impl-review-loop/steps/step-2-verification.md
    --path .claude/skills/impl-review-loop/steps/step-4-pr-review.md
    --path .claude/skills/post-merge-cleanup/SKILL.md
    

    成功条件:

    status: committed
    reason_code: committed
    commit_sha: <new SHA>
    requested_paths:
      - six exact Allowed Paths
    staged_paths:
      - same six paths

    拒否された場合はraw gitへフォールバックしないでください。

    再materializationが必要な拒否

    次は環境・source driftとして扱い、Issue本文を変更せずStep 3からやり直してください。

    contract_source_drift
    base_ref_fingerprint_mismatch
    base_sha_fingerprint_mismatch
    allowed_paths_fingerprint_mismatch
    stale_snapshot_body_drift
    stale_snapshot_comment_drift
    stale_snapshot_allowed_paths_drift
    

    古いコメントのfingerprintを手編集しないでください。ensure_contract_snapshot.py --mode auto --postでfresh sourceを生成してください。

    そのほかの拒否

    次は停止してください。

    branch_binding_mismatch
    worktree_binding_mismatch
    head_race_detected
    unmerged_index_conflict
    path_outside_allowed_paths
    protected_path_denied
    staged_requested_mismatch
    post_commit_audit_violation_rolled_back
    

    7. pushとDraft PR

    commit成功後、current repositoryが定義するsanctioned push laneを使ってください。raw pushやguard bypassは行わないでください。

    その後、canonical open-pr skillでDraft PRを作成してください。

    PR bodyには最低限次を含めてください。

    PR作成直前に、Issue #1838のbody、Allowed Paths、default branch、worktree HEADが変化していないことを再確認してください。

    8. PR作成後の検証・レビュー

    Draft PR作成後、初めて次を起動してください。

    test-runner

    • PR current head SHAにbinding
    • Issue #1838のliteral Verification Commandsを実行
    • 以前の12/12結果をそのまま再利用しない
    • current-head resultを返す
    • PRへの直接mutationは行わない

    pr-reviewer

    • test-runner完了後に起動
    • PR current head SHAにbinding
    • Issue本文、owner anchor、fresh contract source、実diff、current checksを読む
    • Allowed Paths外変更、false-green test、compatibility alias、completion protocol、runtime claim越境を敵対的に確認
    • proposed verdictを返す
    • GitHub投稿はcontrol-planeが行う

    head SHAが変わった場合はstale resultとして再実行してください。

    9. 最終報告

    成功時:

    ISSUE_1838_DELIVERY_RESULT:
      status: draft_pr_created
      issue: 1838
      worktree: .claude/worktrees/issue-1838-native-v2-dispatch
      contract_source:
        status: materialized
        url: <url>
        body_sha256: <sha256>
        base_sha: <sha>
      commit:
        status: committed
        sha: <sha>
        changed_paths: 6
      push: pass
      pr:
        number: <number>
        url: <url>
        draft: true
        head_sha: <sha>
      verification:
        status: pass
        pytest: 37
        gates: 12/12
      review:
        verdict: <APPROVE|REQUEST_CHANGES|HUMAN_REVIEW_REQUIRED>
        reviewed_head_sha: <sha>

    失敗時:

    ISSUE_1838_DELIVERY_RESULT:
      status: blocked
      phase: contract_materialization | controlled_commit | push | open_pr | verification | review
      reason_code: <exact reason>
      raw_git_bypass_used: false
      existing_worktree_preserved: true
      implementation_reverted: false
      next_action: <specific canonical action>

    予見に対する推奨アクション

    今回の復旧後、別Issueをdedupe確認の上で起票するのが妥当です。論点は次です。

    #1851 / PR #1854 ではcontract snapshot欠落を実装着手・PR publicationの停止条件から外した一方、controlled commit laneは現在もfingerprint付きcontract sourceを必須としており、処理の最後で初めて停止する。

    PR #1854は、snapshotを任意telemetryとして扱い、欠落しても実装・PR publicationを止めない方針を明示してマージされています。 一方、controlled executorは現在も--materialize-requestを必須とし、live materializerが失敗するとcommitを拒否します。

    follow-upの推奨Outcomeは、nullable bypassではなく、commit時にlive Issue・Allowed Paths・worktreeを直接束縛する最小materializationへ統合し、人間が事前にcontract commentを用意しなくても正規commit laneが完結することです。少なくとも、snapshotなしで実装開始 → controlled commit → Draft PR のE2E回帰テストが必要です。

  7. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    Gemini 非依存 refinement 復旧結果

    ISSUE_1886_RECOVERY_EXECUTION_RESULT_V1:
      status: partially_completed
      gemini_invoked: false
      issue_reviewer_permission:
        diagnosis: "実spawnで一時出力、artifact作成、deterministic checkerを実行し、permission denyは再現されなかった"
        follow_up_issue: null
        draft_pr: null
        runtime_spawn_verified: true
      issue_1886:
        body_sha256: "sha256:af6ba36cf481e74d884f0bb7adcfb5cdae8f8311e5f3fc0746b48869bddc23bf"
        expected_provider_all_routes: agy
        github_research_agy:
          status: child_issue_created
          issue: 1920
      refinement_loop:
        anchor: issuecomment-5150262204
        iteration: 2
        validator_status: valid
        final_status: approved
  8. squne121 commented on Aug 6, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。現状の Issue #1886 は実装着手不可です。

    AGY を主経路に固定し、Gemini を再開条件・フォールバック先から外す方向性自体は妥当です。Googleも個人向け Gemini CLI から Antigravity CLI への移行を告知し、対象の個人向けアクセスを2026年6月18日に終了しました。ただし Enterprise や API キー経路には例外があるため、disabled_by_operator は製品全体の状態ではなく、このリポジトリ固有の運用判断として扱うべきです。(Google Developers Blog)

    問題は、2026年8月1日に確定した Issue 本文が、その後の依存実装と current main に追随しておらず、さらに要求している runtime evidence を Allowed Paths 内では生成できないことです。Issue は open のままで、本文の最終更新も2026年8月1日です。

    現在の前提差分

    Issue本文の前提 | 2026年8月6日時点の実態 -- | -- #1915 / PR #1919 は OPEN Draft | マージ済み github_research × agy は未実装 | #1920 / PR #2000 で実装・マージ済み #1915 / #1920 が OPEN の間はマージ禁止 | 両方とも dependency satisfied AGENT_PROVIDER_ROUTE_SMOKE_V1 を出力する | schema・producer・validator が存在しない #1909 の契約を維持する | #1909 は同じ4 Agentファイルを所有したまま open

    PR #2000 のマージコミット 8f899d4a4a17f282fe75a03944448810a4c2cd04 が現在の main であり、AGY による bounded read-only github_research、専用 broker、live positive run、negative probes、digest binding まで入っています。
    一方、#1909 は .claude/.codex の同じ4つの Agent surface と実 dispatch を対象にしたまま open です。


    P0ブロッカー

    P0-1: dependency contract が stale で、本文の実装順序が現在は成立しない

    現在の Issue は blocked_by: ["#1915", "#1920"] を保持し、本文にも「#1920完了前に github_research × agy success を主張しない」「#1915 / #1920 が OPEN の間はマージしない」とあります。これは起票時点では正しかったものの、現在は事実と一致しません。

    また、親 #1265 自体も既に closed です。

    単なる文言の陳腐化ではありません。実装者が本文に従うと、以下を誤ります。

    必須修正

    Machine-Readable Contract は少なくとも次の構造へ更新すべきです。

    blocked_by: []
    

    satisfied_dependencies:

    • issue: "#1915"
      pr: "#1919"
      status: merged
    • issue: "#1920"
      pr: "#2000"
      status: merged

    base_head_at_refinement:
    sha: "8f899d4a4a17f282fe75a03944448810a4c2cd04"
    refresh_required_at_implementation_start: true

    conflicts_with:

    • issue: "#1909"
      overlapping_surfaces:
      • ".claude/agents/codebase-investigator.md"
      • ".claude/agents/web-researcher.md"
      • ".codex/agents/codebase-investigator.toml"
      • ".codex/agents/web-researcher.toml"

    P0-2: 必須 artifact が未定義で、Allowed Paths 内では AC4 を実装できない

    Issue は各 route について AGENT_PROVIDER_ROUTE_SMOKE_V1 を保存し、以下を証明するよう要求しています。

    • selected_provider: agy

    • provider_attempts: [agy]

    • gemini_attempt_count: 0

    • custom_agent_was_actually_spawned: true

    しかし、リポジトリ検索では次のいずれも0件です。

    • AGENT_PROVIDER_ROUTE_SMOKE_V1

    • agent-provider-route

    • custom_agent_was_actually_spawned

    さらに、#1920 が追加した正式な agy_github_research_evidence/v1 schema は、AGENT_PROVIDER_ROUTE_SMOKE_V1 を明示的に「無関係かつ未定義」と説明しています。

    Issue の Allowed Paths には、次が含まれていません。

    • artifact schema

    • producer

    • semantic validator

    • aggregate validator

    • live smoke runner

    • producer/validator のテスト

    したがって、現行スコープのままでは実装者は次の二択になります。

    1. AC4を満たせない。

    2. Allowed Paths 外を変更して Stop Condition に入る。

    必須修正

    新しい artifact は profile 固有 evidence を再実装せず、正規化された外側の envelope にしてください。

    schema: agent_provider_route_smoke/v1
    
    
    
    

    subject:
    repository: squne121/loop-protocol
    head_sha: <sha>
    runtime: claude_code | codex_cli
    runtime_version: <version>
    agent_name: codebase-investigator | web-researcher
    agent_definition_sha256: <digest>
    effective_runtime_config_sha256: <digest>

    spawn:
    mode: custom_subagent
    parent_session_id: <id>
    child_session_id: <id>
    observed_agent_name: <name>
    evidence_source: native_event | session_log

    request:
    profile: local_asset_research | github_research | grounded_research
    expected_provider: agy
    request_sha256: <digest>
    validation: pass

    provider_observation:
    selected_provider: agy
    provider_attempts: [agy]
    gemini_invocation_count: 0
    direct_fallback_invocation_count: 0

    route_evidence:
    schema: <profile-specific-schema>
    relative_path: <path>
    sha256: <digest>
    status: pass

    status: pass | fail | skip
    failure_class: <string|null>

    github_research については、route_evidence.schema が必ず agy_github_research_evidence/v1 でなければならない、という profile-specific constraint が必要です。#1920 の schema は AGY/GH binary digest、permission policy、hook、isolated settings、iteration evidence まで保持しており、その証拠を平坦な generic JSON にコピーし直すべきではありません。


    P0-3: Runtime Verification が静的テストへすり替わっている

    Issue は AC1〜AC6をすべて runtime-verification: true としながら、Verification Commands は次の種類だけです。

    • Nodeによる設定検査

    • pytestによるMarkdown/fixture検査

    • rg による文字列検索

    特に AC4 の「custom agent actual spawn」は、tests/test_codex_agent_bridge_contract.py に割り当てられています。しかし、このテストは fixture repo を作成して静的 validator を subprocess 実行するテストであり、Codex custom agent を実 spawn しません。

    test_agent_contracts.py も、自身を static contract validation と定義しています。

    リポジトリの Runtime Verification Policy は、immediate を「プロセス起動・通信・I/Oで初めて確認できる検証」と定義し、環境不足時は exit 77、fallback 成功は FAIL とするよう要求しています。静的 test は代替になりません。

    必須修正

    ACを分離してください。

    Static contract AC

    • 4 Agent surface に exact builder invocation が存在する。

    • provider=agy、正しい profile、non-empty prompt、model 不在を検査する。

    • 手書き provider JSON がない。

    • JS/Python checker と fixture が一致する。

    • Gemini mandatory/direct fallback success の古い記述がない。

    Runtime AC

    • 6 route を個別に live 実行する。

    • 対象 custom agent の実 spawn を native event で確認する。

    • request validation、provider selection、profile-specific evidence を確認する。

    • Gemini/direct fallback が一度も実行されていないことを確認する。

    • exit 77 は aggregate PASS に昇格させない。

    既存コマンドに付けられた preflight-scope: runtime_only も誤りです。静的検査は static_contract、live runner は runtime_only と分離すべきです。


    P0-4: 「custom agent actual spawn」と「agent名の自己申告」を混同している

    既存の run_worktree_agent_runtime_smoke.py は runtime smoke の基盤として有用ですが、対象 persona の実効 identity を独立観測できません。コード自身が、runtime event から現在の persona 名は得られず、effective_agent_type を呼び出し側の requested_agent_type と同値にしていると明記しています。

    したがって、次のような artifact は証拠になりません。

    requested_agent_type: web-researcher
    effective_agent_type: web-researcher

    どちらも caller が入力した同じ値だからです。

    Claude Code では、自然言語で agent 名を述べるだけでは Claude が委譲するか判断します。特定 subagent の明示的な @ 指定は、その agent を1タスクについて確実に実行します。一方、claude --agent <name> は main session をその agent persona として起動するもので、child subagent が spawn された証拠とは別です。(Claude)

    Codex の custom agent も、子スレッドの生成と inspection を実際に観測する必要があります。子 agent は親 turn の sandbox/approval override を継承するため、TOML上の agent名やpermissionだけでは実効状態を証明できません。(OpenAI Developers)

    必須修正

    Issue は次のどちらを要求するのか明確化する必要があります。

    1. main session が指定 Agent persona で起動したこと

    2. 親 session から指定 custom subagent が child として spawn されたこと

    現行本文は明確に「actual spawn」を要求しているため、後者を採るべきです。

    PASS条件には次を追加してください。

    spawn:
    requested_agent_name: web-researcher
    observed_agent_name: web-researcher
    parent_session_id: <non-empty>
    child_session_id: <non-empty-and-different>
    native_spawn_event_observed: true

    agent の最終回答に「私は web-researcher です」と書かせる方式は不採用です。


    P0-5: static TOML/Markdown が実効 permission と runtime config を証明しない

    Codex custom agent の default permission は、親 session の live override によって変わり得ます。OpenAI公式仕様でも、subagent は現在の sandbox policy と親 turn の runtime override を継承するとされています。(OpenAI Developers)

    また、permission profiles と旧 sandbox_mode は単純に合成されるものではありません。profile名だけを artifact に残しても、実効 permission boundary の証明にはなりません。(OpenAI Developers)

    Antigravity CLI 側も、1.1.4〜1.1.6で headless -p の persisted settings 適用、permission/sandbox error reporting などが変更されています。単なる agy_version 文字列だけでは不十分です。(GitHub)

    必須修正

    artifact に少なくとも次を束縛してください。

    • Codex/Claude runtime version

    • parent runtime config digest

    • effective permission profile

    • sandbox/approval override

    • Agent definition digest

    • AGY executable digest

    • AGY version

    • isolated settings digest

    • permission policy digest

    • enforcement hook digest

    • builder/validator digest

    • tested repository head SHA

    これは過剰な新規 ledger ではありません。1回の smoke artifact に、検証対象を特定する最小 provenance を残すだけです。#1920 の実装が既に同じ方式を採用しています。


    P0-6: gemini_attempt_count: 0 と direct fallback禁止を実証する経路がない

    current main の Claude web-researcher.md は、Geminiを先に使い、その後 direct web/direct CLI fallback を使う構造をまだ保持しています。また WebSearch/WebFetch surface も残っています。

    Codex web-researcher.toml も grounded_research_or_direct_web という抽象 route を保持し、model-hosted web__run はローカル permission profile の network proxy とは別経路である旨を自身で記載しています。

    したがって、設定文に次を書くだけでは何も証明できません。

    fallback_enabled: false
    gemini_attempt_count: 0

    必須修正

    少なくとも二層で検証してください。

    構造的制約

    • Claude web-researcher から direct WebSearch/WebFetch を除外するか、当該 route では禁止する。

    • Codex agent instruction から grounded_research_or_direct_web を廃止し、exact AGY builder route にする。

    • Gemini fallback の文言・branch を削除する。

    runtime trap

    • PATH 先頭に invocation sentinel 用の gemini stub を置く。

    • stub が一度でも起動されたら即 FAIL。

    • Claude/Codex native event stream から direct web tool invocation を検出し、1件でもあれば FAIL。

    • provider_attempts 等は Agent回答から読まず、wrapper/process event から導出する。


    P0-7: #1909との競合は「実装直前に再確認」では不十分

    #1909 は次を同じ4 Agent surface に追加する予定です。

    • context_bundle_path

    • bundle ID/digest echo

    • Claude/Codex actual dispatch

    • live smoke

    • cleanup evidence

    #1886 は「#1909 の contract を削除・上書きしない」としていますが、#1909 はまだ open です。未マージの将来契約を「維持する」ことは決定論的ではありません。

    推奨する順序

    #1886 → #1909

    理由は、provider route を先に canonical 化し、その最終 request invocation に #1909 が context_bundle_path を接続する方が責務境界が明確だからです。

    反対に、context bundle が #1886 の live smoke に必須なら、次のように明示的に逆順へしてください。

    blocked_by: ["#1909"]
    merge_order: "#1909 -> #1886"

    現在の「blockerではないが未マージ契約を保持する」という中間状態は不採用です。


    P1の品質問題

    P1-1: 現行 contract test が新方針と正面衝突する

    test_agent_contracts.py は、web-researcher.md に「Antigravity対応を仮定しない」または「未対応」という保守的記述が残ることを要求しています。

    一方、current profile matrix は grounded_research × agy と github_research × agy を implemented としています。

    これは expected drift ではなく、明確な契約矛盾です。#1886 で assertion を削除するだけでなく、次へ置き換えるべきです。

    • AGY route が canonical builder を使用する。

    • provider=agy

    • profileが grounded_research

    • direct fallbackを成功扱いしない。

    • profile-specific evidence validatorを通る。


    P1-2: Codex fixture を二つの validator が読むのに、片方しかスコープにない

    expected-runtime-contract.json は現在も次を正本としています。

    • codebase-investigator: gemini-cli-headless-delegation

    • web-researcher: grounded_research_or_direct_web

    この fixture は scripts/check-codex-agents.mjs だけでなく、scripts/check_codex_agent_config.py からも読まれます。

    しかし #1886 の Allowed Paths には Python checker がありません。route-specific fieldを追加するなら、次もスコープに含める必要があります。

    scripts/check_codex_agent_config.py
    その route validation test

    JSだけを更新し、Python側は古い抽出規則のままにする構造は避けるべきです。


    P1-3: unrelated comment が review context を汚染している

    #1886 のコメント列には、#1838 の contract snapshot/controlled commit lane に関する別件回答が混入しています。

    人間には誤投稿と判断できますが、全コメントを単純連結する automated reviewer では、#1886 の authoritative decision と誤認する可能性があります。

    Issue 本文または最新の authoritative comment に、次を記録すべきです。

    superseded_or_unrelated_comments:

    • comment_id: 5150535366
      disposition: unrelated_to_issue_1886
      authority: none

    P1-4: AGY live E2E の既知 cleanup race を、無言の再実行で隠せる

    #1997 には、permission-boundary live E2E で temporary_processes_removed が稀に false となる transient race が記録されています。観測値は PR #1994 の検証で概ね5回に1回です。

    #1886 の live gate が同じ基盤を通る場合、次の運用は禁止すべきです。

    失敗 → 理由を保存せず再実行 → 2回目が通ったのでPASS

    許容するなら、一度だけの bounded retry とし、最初の結果を保持してください。

    initial_result: fail
    initial_failure_class: infrastructure_cleanup_race
    retry_count: 1
    retry_result: pass
    final_route_verdict: blocked_pending_flake_classification

    provider route が正しかったことと、cleanup evidence が正常だったことを別軸にする必要があります。


    推奨する最終Acceptance Criteria

    Static AC

    1. 4 Agent surface が profile別の exact canonical builder invocation を持つ。

    2. provider=agy、non-empty prompt、model不在が機械検証される。

    3. Gemini mandatory/retry/fallbackおよびdirect fallback successの記述がない。

    4. JS/Python validator、fixture、Agent定義が同じ route contract を検証する。

    5. 手書きの provider別 request JSON が存在しない。

    Runtime AC

    1. 6つの (runtime, agent, profile) の組み合わせを個別に実行する。

    2. native eventから指定 custom agent の child spawnを観測する。

    3. 全 artifact が同じ repository head SHAへ束縛される。

    4. request validationが pass。

    5. provider attemptsが厳密に [agy]。

    6. Gemini invocation、direct fallback invocationがともに0。

    7. profile-specific child evidenceが validかつdigest一致。

    8. exit 77/SKIPが1件でもあればaggregateはPASSしない。

    9. 同じchild artifactの複数routeへの使い回しを拒否する。

    10. artifactがsecret scan、byte cap、relative-path制約を満たす。

    Aggregate validator は、次を満たす場合だけ exit 0 とすべきです。

    required_route_count: 6
    unique_route_count: 6
    pass_count: 6
    skip_count: 0
    fail_count: 0
    distinct_child_evidence_count: 6
    same_head_sha: true
    all_spawn_events_observed: true
    all_provider_attempts_exactly_agy: true
    total_gemini_invocations: 0
    total_direct_fallback_invocations: 0

    修正版Allowed Paths

    少なくとも以下を追加する必要があります。

    schemas/agent_provider_route_smoke_v1.schema.json
    scripts/agent-ops/run_agent_provider_route_smoke.py
    scripts/agent-ops/validate_agent_provider_route_smoke.py
    scripts/agent-ops/tests/test_agent_provider_route_smoke.py
    scripts/check_codex_agent_config.py
    scripts/agent-ops/run_worktree_agent_runtime_smoke.py

    既存 runner を拡張する場合でも、自己申告した agent type をPASS根拠にせず、runtime固有の明示 spawn bindingとnative event観測を追加する必要があります。


    最終merge gate

    次の全条件を満たすまで、Draft PR作成後も merge 不可です。

    1. Issue本文が current dependency stateへ更新されている。

    2. #1909とのmerge orderが明示されている。

    3. generic envelope schema、producer、validatorが実装されている。

    4. 6 routeすべてが同一headでlive PASSしている。

    5. actual child agent identityがnative eventで確認されている。

    6. github_research が agy_github_research_evidence/v1 を参照している。

    7. Gemini/direct fallback invocationが実測0。

    8. effective permission・runtime config・AGY binary/settings/hookがdigest-boundされている。

    9. SKIP/fallback/無言のretryをPASSへ昇格していない。

    10. #1997型flakinessとprovider route failureが別々に分類されている。

    現行Issueの最大の欠陥は、AGYへの切替方針ではありません。証拠契約を要求しながら、その証拠を真正に生成・検証する実装面をスコープから除外している点です。

    # 判定

    REQUEST_CHANGES。現状の Issue #1886 は実装着手不可です。

    AGY を主経路に固定し、Gemini を再開条件・フォールバック先から外す方向性自体は妥当です。Googleも個人向け Gemini CLI から Antigravity CLI への移行を告知し、対象の個人向けアクセスを2026年6月18日に終了しました。ただし Enterprise や API キー経路には例外があるため、disabled_by_operator は製品全体の状態ではなく、このリポジトリ固有の運用判断として扱うべきです。([Google Developers Blog]1)

    問題は、2026年8月1日に確定した Issue 本文が、その後の依存実装と current main に追随しておらず、さらに要求している runtime evidence を Allowed Paths 内では生成できないことです。Issue は open のままで、本文の最終更新も2026年8月1日です。

    現在の前提差分

    Issue本文の前提 2026年8月6日時点の実態
    #1915 / PR #1919 は OPEN Draft マージ済み
    github_research × agy は未実装 #1920 / PR #2000 で実装・マージ済み
    #1915 / #1920 が OPEN の間はマージ禁止 両方とも dependency satisfied
    AGENT_PROVIDER_ROUTE_SMOKE_V1 を出力する schema・producer・validator が存在しない
    #1909 の契約を維持する #1909 は同じ4 Agentファイルを所有したまま open

    PR #2000 のマージコミット 8f899d4a4a17f282fe75a03944448810a4c2cd04 が現在の main であり、AGY による bounded read-only github_research、専用 broker、live positive run、negative probes、digest binding まで入っています。
    一方、#1909 は .claude/.codex の同じ4つの Agent surface と実 dispatch を対象にしたまま open です。


    P0ブロッカー

    P0-1: dependency contract が stale で、本文の実装順序が現在は成立しない

    現在の Issue は blocked_by: ["#1915", "#1920"] を保持し、本文にも「#1920完了前に github_research × agy success を主張しない」「#1915 / #1920 が OPEN の間はマージしない」とあります。これは起票時点では正しかったものの、現在は事実と一致しません。

    また、親 #1265 自体も既に closed です。

    単なる文言の陳腐化ではありません。実装者が本文に従うと、以下を誤ります。

    必須修正

    Machine-Readable Contract は少なくとも次の構造へ更新すべきです。

    blocked_by: []
    
    satisfied_dependencies:
      - issue: "#1915"
        pr: "#1919"
        status: merged
      - issue: "#1920"
        pr: "#2000"
        status: merged
    
    base_head_at_refinement:
      sha: "8f899d4a4a17f282fe75a03944448810a4c2cd04"
      refresh_required_at_implementation_start: true
    
    conflicts_with:
      - issue: "#1909"
        overlapping_surfaces:
          - ".claude/agents/codebase-investigator.md"
          - ".claude/agents/web-researcher.md"
          - ".codex/agents/codebase-investigator.toml"
          - ".codex/agents/web-researcher.toml"

    P0-2: 必須 artifact が未定義で、Allowed Paths 内では AC4 を実装できない

    Issue は各 route について AGENT_PROVIDER_ROUTE_SMOKE_V1 を保存し、以下を証明するよう要求しています。

    • selected_provider: agy
    • provider_attempts: [agy]
    • gemini_attempt_count: 0
    • custom_agent_was_actually_spawned: true

    しかし、リポジトリ検索では次のいずれも0件です。

    • AGENT_PROVIDER_ROUTE_SMOKE_V1
    • agent-provider-route
    • custom_agent_was_actually_spawned

    さらに、#1920 が追加した正式な agy_github_research_evidence/v1 schema は、AGENT_PROVIDER_ROUTE_SMOKE_V1 を明示的に「無関係かつ未定義」と説明しています。

    Issue の Allowed Paths には、次が含まれていません。

    • artifact schema
    • producer
    • semantic validator
    • aggregate validator
    • live smoke runner
    • producer/validator のテスト

    したがって、現行スコープのままでは実装者は次の二択になります。

    1. AC4を満たせない。
    2. Allowed Paths 外を変更して Stop Condition に入る。

    必須修正

    新しい artifact は profile 固有 evidence を再実装せず、正規化された外側の envelope にしてください。

    schema: agent_provider_route_smoke/v1
    
    subject:
      repository: squne121/loop-protocol
      head_sha: <sha>
      runtime: claude_code | codex_cli
      runtime_version: <version>
      agent_name: codebase-investigator | web-researcher
      agent_definition_sha256: <digest>
      effective_runtime_config_sha256: <digest>
    
    spawn:
      mode: custom_subagent
      parent_session_id: <id>
      child_session_id: <id>
      observed_agent_name: <name>
      evidence_source: native_event | session_log
    
    request:
      profile: local_asset_research | github_research | grounded_research
      expected_provider: agy
      request_sha256: <digest>
      validation: pass
    
    provider_observation:
      selected_provider: agy
      provider_attempts: [agy]
      gemini_invocation_count: 0
      direct_fallback_invocation_count: 0
    
    route_evidence:
      schema: <profile-specific-schema>
      relative_path: <path>
      sha256: <digest>
      status: pass
    
    status: pass | fail | skip
    failure_class: <string|null>

    github_research については、route_evidence.schema が必ず agy_github_research_evidence/v1 でなければならない、という profile-specific constraint が必要です。#1920 の schema は AGY/GH binary digest、permission policy、hook、isolated settings、iteration evidence まで保持しており、その証拠を平坦な generic JSON にコピーし直すべきではありません。


    P0-3: Runtime Verification が静的テストへすり替わっている

    Issue は AC1〜AC6をすべて runtime-verification: true としながら、Verification Commands は次の種類だけです。

    • Nodeによる設定検査
    • pytestによるMarkdown/fixture検査
    • rg による文字列検索

    特に AC4 の「custom agent actual spawn」は、tests/test_codex_agent_bridge_contract.py に割り当てられています。しかし、このテストは fixture repo を作成して静的 validator を subprocess 実行するテストであり、Codex custom agent を実 spawn しません。

    test_agent_contracts.py も、自身を static contract validation と定義しています。

    リポジトリの Runtime Verification Policy は、immediate を「プロセス起動・通信・I/Oで初めて確認できる検証」と定義し、環境不足時は exit 77、fallback 成功は FAIL とするよう要求しています。静的 test は代替になりません。

    必須修正

    ACを分離してください。

    Static contract AC

    • 4 Agent surface に exact builder invocation が存在する。
    • provider=agy、正しい profile、non-empty prompt、model 不在を検査する。
    • 手書き provider JSON がない。
    • JS/Python checker と fixture が一致する。
    • Gemini mandatory/direct fallback success の古い記述がない。

    Runtime AC

    • 6 route を個別に live 実行する。
    • 対象 custom agent の実 spawn を native event で確認する。
    • request validation、provider selection、profile-specific evidence を確認する。
    • Gemini/direct fallback が一度も実行されていないことを確認する。
    • exit 77 は aggregate PASS に昇格させない。

    既存コマンドに付けられた preflight-scope: runtime_only も誤りです。静的検査は static_contract、live runner は runtime_only と分離すべきです。


    P0-4: 「custom agent actual spawn」と「agent名の自己申告」を混同している

    既存の run_worktree_agent_runtime_smoke.py は runtime smoke の基盤として有用ですが、対象 persona の実効 identity を独立観測できません。コード自身が、runtime event から現在の persona 名は得られず、effective_agent_type を呼び出し側の requested_agent_type と同値にしていると明記しています。

    したがって、次のような artifact は証拠になりません。

    requested_agent_type: web-researcher
    effective_agent_type: web-researcher

    どちらも caller が入力した同じ値だからです。

    Claude Code では、自然言語で agent 名を述べるだけでは Claude が委譲するか判断します。特定 subagent の明示的な @ 指定は、その agent を1タスクについて確実に実行します。一方、claude --agent <name> は main session をその agent persona として起動するもので、child subagent が spawn された証拠とは別です。(Claude)

    Codex の custom agent も、子スレッドの生成と inspection を実際に観測する必要があります。子 agent は親 turn の sandbox/approval override を継承するため、TOML上の agent名やpermissionだけでは実効状態を証明できません。([OpenAI Developers]3)

    必須修正

    Issue は次のどちらを要求するのか明確化する必要があります。

    1. main session が指定 Agent persona で起動したこと
    2. 親 session から指定 custom subagent が child として spawn されたこと

    現行本文は明確に「actual spawn」を要求しているため、後者を採るべきです。

    PASS条件には次を追加してください。

    spawn:
      requested_agent_name: web-researcher
      observed_agent_name: web-researcher
      parent_session_id: <non-empty>
      child_session_id: <non-empty-and-different>
      native_spawn_event_observed: true

    agent の最終回答に「私は web-researcher です」と書かせる方式は不採用です。


    P0-5: static TOML/Markdown が実効 permission と runtime config を証明しない

    Codex custom agent の default permission は、親 session の live override によって変わり得ます。OpenAI公式仕様でも、subagent は現在の sandbox policy と親 turn の runtime override を継承するとされています。([OpenAI Developers]3)

    また、permission profiles と旧 sandbox_mode は単純に合成されるものではありません。profile名だけを artifact に残しても、実効 permission boundary の証明にはなりません。([OpenAI Developers]4)

    Antigravity CLI 側も、1.1.4〜1.1.6で headless -p の persisted settings 適用、permission/sandbox error reporting などが変更されています。単なる agy_version 文字列だけでは不十分です。([GitHub]5)

    必須修正

    artifact に少なくとも次を束縛してください。

    • Codex/Claude runtime version
    • parent runtime config digest
    • effective permission profile
    • sandbox/approval override
    • Agent definition digest
    • AGY executable digest
    • AGY version
    • isolated settings digest
    • permission policy digest
    • enforcement hook digest
    • builder/validator digest
    • tested repository head SHA

    これは過剰な新規 ledger ではありません。1回の smoke artifact に、検証対象を特定する最小 provenance を残すだけです。#1920 の実装が既に同じ方式を採用しています。


    P0-6: gemini_attempt_count: 0 と direct fallback禁止を実証する経路がない

    current main の Claude web-researcher.md は、Geminiを先に使い、その後 direct web/direct CLI fallback を使う構造をまだ保持しています。また WebSearch/WebFetch surface も残っています。

    Codex web-researcher.toml も grounded_research_or_direct_web という抽象 route を保持し、model-hosted web__run はローカル permission profile の network proxy とは別経路である旨を自身で記載しています。

    したがって、設定文に次を書くだけでは何も証明できません。

    fallback_enabled: false
    gemini_attempt_count: 0

    必須修正

    少なくとも二層で検証してください。

    構造的制約

    • Claude web-researcher から direct WebSearch/WebFetch を除外するか、当該 route では禁止する。
    • Codex agent instruction から grounded_research_or_direct_web を廃止し、exact AGY builder route にする。
    • Gemini fallback の文言・branch を削除する。

    runtime trap

    • PATH 先頭に invocation sentinel 用の gemini stub を置く。
    • stub が一度でも起動されたら即 FAIL。
    • Claude/Codex native event stream から direct web tool invocation を検出し、1件でもあれば FAIL。
    • provider_attempts 等は Agent回答から読まず、wrapper/process event から導出する。

    P0-7: #1909との競合は「実装直前に再確認」では不十分

    #1909 は次を同じ4 Agent surface に追加する予定です。

    • context_bundle_path
    • bundle ID/digest echo
    • Claude/Codex actual dispatch
    • live smoke
    • cleanup evidence

    #1886 は「#1909 の contract を削除・上書きしない」としていますが、#1909 はまだ open です。未マージの将来契約を「維持する」ことは決定論的ではありません。

    推奨する順序

    #1886 → #1909
    

    理由は、provider route を先に canonical 化し、その最終 request invocation に #1909 が context_bundle_path を接続する方が責務境界が明確だからです。

    反対に、context bundle が #1886 の live smoke に必須なら、次のように明示的に逆順へしてください。

    blocked_by: ["#1909"]
    merge_order: "#1909 -> #1886"

    現在の「blockerではないが未マージ契約を保持する」という中間状態は不採用です。


    P1の品質問題

    P1-1: 現行 contract test が新方針と正面衝突する

    test_agent_contracts.py は、web-researcher.md に「Antigravity対応を仮定しない」または「未対応」という保守的記述が残ることを要求しています。

    一方、current profile matrix は grounded_research × agy と github_research × agy を implemented としています。

    これは expected drift ではなく、明確な契約矛盾です。#1886 で assertion を削除するだけでなく、次へ置き換えるべきです。

    • AGY route が canonical builder を使用する。
    • provider=agy
    • profileが grounded_research
    • direct fallbackを成功扱いしない。
    • profile-specific evidence validatorを通る。

    P1-2: Codex fixture を二つの validator が読むのに、片方しかスコープにない

    expected-runtime-contract.json は現在も次を正本としています。

    • codebase-investigator: gemini-cli-headless-delegation
    • web-researcher: grounded_research_or_direct_web

    この fixture は scripts/check-codex-agents.mjs だけでなく、scripts/check_codex_agent_config.py からも読まれます。

    しかし #1886 の Allowed Paths には Python checker がありません。route-specific fieldを追加するなら、次もスコープに含める必要があります。

    scripts/check_codex_agent_config.py
    その route validation test
    

    JSだけを更新し、Python側は古い抽出規則のままにする構造は避けるべきです。


    P1-3: unrelated comment が review context を汚染している

    #1886 のコメント列には、#1838 の contract snapshot/controlled commit lane に関する別件回答が混入しています。

    人間には誤投稿と判断できますが、全コメントを単純連結する automated reviewer では、#1886 の authoritative decision と誤認する可能性があります。

    Issue 本文または最新の authoritative comment に、次を記録すべきです。

    superseded_or_unrelated_comments:
      - comment_id: 5150535366
        disposition: unrelated_to_issue_1886
        authority: none

    P1-4: AGY live E2E の既知 cleanup race を、無言の再実行で隠せる

    #1997 には、permission-boundary live E2E で temporary_processes_removed が稀に false となる transient race が記録されています。観測値は PR #1994 の検証で概ね5回に1回です。

    #1886 の live gate が同じ基盤を通る場合、次の運用は禁止すべきです。

    失敗 → 理由を保存せず再実行 → 2回目が通ったのでPASS
    

    許容するなら、一度だけの bounded retry とし、最初の結果を保持してください。

    initial_result: fail
    initial_failure_class: infrastructure_cleanup_race
    retry_count: 1
    retry_result: pass
    final_route_verdict: blocked_pending_flake_classification

    provider route が正しかったことと、cleanup evidence が正常だったことを別軸にする必要があります。


    推奨する最終Acceptance Criteria

    Static AC

    1. 4 Agent surface が profile別の exact canonical builder invocation を持つ。
    2. provider=agy、non-empty prompt、model不在が機械検証される。
    3. Gemini mandatory/retry/fallbackおよびdirect fallback successの記述がない。
    4. JS/Python validator、fixture、Agent定義が同じ route contract を検証する。
    5. 手書きの provider別 request JSON が存在しない。

    Runtime AC

    1. 6つの (runtime, agent, profile) の組み合わせを個別に実行する。
    2. native eventから指定 custom agent の child spawnを観測する。
    3. 全 artifact が同じ repository head SHAへ束縛される。
    4. request validationが pass。
    5. provider attemptsが厳密に [agy]。
    6. Gemini invocation、direct fallback invocationがともに0。
    7. profile-specific child evidenceが validかつdigest一致。
    8. exit 77/SKIPが1件でもあればaggregateはPASSしない。
    9. 同じchild artifactの複数routeへの使い回しを拒否する。
    10. artifactがsecret scan、byte cap、relative-path制約を満たす。

    Aggregate validator は、次を満たす場合だけ exit 0 とすべきです。

    required_route_count: 6
    unique_route_count: 6
    pass_count: 6
    skip_count: 0
    fail_count: 0
    distinct_child_evidence_count: 6
    same_head_sha: true
    all_spawn_events_observed: true
    all_provider_attempts_exactly_agy: true
    total_gemini_invocations: 0
    total_direct_fallback_invocations: 0

    修正版Allowed Paths

    少なくとも以下を追加する必要があります。

    schemas/agent_provider_route_smoke_v1.schema.json
    scripts/agent-ops/run_agent_provider_route_smoke.py
    scripts/agent-ops/validate_agent_provider_route_smoke.py
    scripts/agent-ops/tests/test_agent_provider_route_smoke.py
    scripts/check_codex_agent_config.py
    scripts/agent-ops/run_worktree_agent_runtime_smoke.py
    

    既存 runner を拡張する場合でも、自己申告した agent type をPASS根拠にせず、runtime固有の明示 spawn bindingとnative event観測を追加する必要があります。


    最終merge gate

    次の全条件を満たすまで、Draft PR作成後も merge 不可です。

    1. Issue本文が current dependency stateへ更新されている。
    2. #1909とのmerge orderが明示されている。
    3. generic envelope schema、producer、validatorが実装されている。
    4. 6 routeすべてが同一headでlive PASSしている。
    5. actual child agent identityがnative eventで確認されている。
    6. github_research が agy_github_research_evidence/v1 を参照している。
    7. Gemini/direct fallback invocationが実測0。
    8. effective permission・runtime config・AGY binary/settings/hookがdigest-boundされている。
    9. SKIP/fallback/無言のretryをPASSへ昇格していない。
    10. #1997型flakinessとprovider route failureが別々に分類されている。

    現行Issueの最大の欠陥は、AGYへの切替方針ではありません。証拠契約を要求しながら、その証拠を真正に生成・検証する実装面をスコープから除外している点です。

  9. squne121 commented on Aug 6, 2026

    @squne121
    OwnerAuthor

    Refinement Loop 終了報告

    実施内容

    anchor comment の P0-1〜P0-7 / P1-1〜P1-4 指摘を検証し(codebase-investigator による repo claim 検証、web-researcher による外部 claim fact-check、および control-plane 独自の git grep / gh issue view / gh pr view 再検証)、Issue 本文を以下の方針で書き換えた。

    検証

    • Static readiness check(contract_readiness_check.py --mode preflight-static): status: go
    • issue-reviewer 再レビュー(rewrite 後): VERDICT: approve、blockers_count: 0、body_sha256 一致確認済み

    Final Gate

    Final Gate: not applicable(本 loop のスコープ外) — issue-contract-review(Final Gate)は本 refinement loop では未実行。次段階として issue-contract-review の実行を推奨する。

    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: blocked
        gate_result: missing_go
        latest_comment_url: ""
        generated_at: "2026-08-06T10:30:00Z"
        body_sha256: "sha256:4df25e1ca4a27a0385c6d2531aea9da0bb0a4adec4e4ea4fbdeea62b6a7d3a9e"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers:
        - kind: contract_review_not_run
          description: "issue-contract-review(Final Gate)が本 Issue に対して未実行のため、fresh go が存在しない。実装着手前に issue-contract-review を実行すること。"
      permissions:
        unavailable: []
      generated_at: "2026-08-06T10:30:00Z"
      checked_body_sha256: "sha256:4df25e1ca4a27a0385c6d2531aea9da0bb0a4adec4e4ea4fbdeea62b6a7d3a9e"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  10. squne121 commented on Aug 6, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了(AC1-5 static contract 検証済み、AC6-10 runtime は部分検証)

    • PR: 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005
    • Worktree: .claude/worktrees/issue-1886-codebase-investigator-web-researcher-del
    • Branch: worktree-issue-1886-codebase-investigator-web-researcher-del
    • Static Contract (AC1-5): 全 Verification Commands PASS(詳細は PR 本文 Checks 参照)
    • Runtime (AC6-10): producer/validator(run_agent_provider_route_smoke.py / validate_agent_provider_route_smoke.py)と native spawn session 観測を実装・hermetic テスト済み。6 route 全件の live 実行完遂には至っていない(具体的な制約は PR 本文 Notes 参照)。捏造した PASS は無し。
    • 後続: PR レビュー(pr-review-judge)→ runtime AC6-10 の残作業判断 → マージ → post-merge-cleanup
  11. squne121 commented on Aug 8, 2026

    @squne121
    OwnerAuthor

    OWNER Decision: human-escalation resolution(AC6 waiver rejected)

    対象: Issue #1886 / PR #2005(reviewed head 256d0aedb4f0a287d91a798e991d77d4249ae91d、現在 PR head 0e15fe89dbc9e23183f8209052c7c4160092d52a、main への追従 merge のみで Allowed Paths 内ファイルに差分なし)
    human-escalation comment: #2005 (comment)
    OWNER adversarial review: #2005 (comment)

    決定

    OWNER decision: AC6 waiver rejected. PR #2005 の code diff は現時点で追加の code blocker が実証されていないが、Issue #1886 の acceptance は AC6 exact six-route live verification 未達のため未完了。runtime prerequisite/reliability gap は #2012 / #2015 / #2013 で追跡する。#1886 / #2005 はそれらを解決または実行環境を満たして AC6 を current head で再実証するまで Open/Draft を維持する。

    Follow-up Issues(runtime prerequisite / reliability gap の分離追跡)

    gap follow-up Issue 概要
    codex_cli / codebase-investigator / github_research の GH_TOKEN provisioning #2012 AGY github_research route の GH_TOKEN provisioning gap を解消する(#1920 の token-owning broker / env isolation 境界は維持)
    codex_cli / codebase-investigator / local_asset_research の Serena MCP timeout #2015 local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する
    claude_code required 3 route の非決定的な spawn_not_observed / validation_failed #2013 Claude Code custom SubAgent の spawn observability 非決定性を診断する

    確認事項

    再開条件

    follow-up Issue(#2012 / #2015 / #2013)の解決、または実行環境の整備により、PR #2005 の current head に対して Issue #1886 の live body に定義された required 6 route 全件が genuine live status: pass(selected_provider == agy, provider_attempts == [agy], gemini_attempt_count == 0, direct_fallback_invocation_count == 0, request_validation == pass, native custom-agent spawn evidence valid, github_research は #1920 の canonical route evidence で semantic validation)に到達することを live に確認できた場合のみ、AC6 再実証 → fresh pr-review(APPROVE, blockers=[], reviewed_head_sha=current head, live mergeability approvable)を経て draft_pr_ready 相当の終了を検討する。実マージは人間の最終判断に委ねる。

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