Skip to content

実装: Gemini delegation preload-only contract #1736

Closed as not planned
2 of 2 issues completed
Closed as not planned

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1736"
goal_ref: "preload-only knowledge contract for Gemini delegation"
change_kind: workflow
blocked_by: ["#1745"]

Parent Issue

#1736

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

Outcome

gemini-cli-headless-delegation-contract の knowledge-only Skill と2 Agentの preload mapping が追加され、#1745 の strict validator/fresh-session smoke が execution Skill や fallback 実装を含めずに PASS する状態を、対象ファイルと単一コマンドの証跡で完了とする。

In Scope

Out of Scope

  • wrapper taxonomy、run_gemini_headless.py の実装変更、fallback launcher/executor
  • provider policy、schema catalog、settings、hook、permission変更

Acceptance Criteria

Verification Commands

# AC1
# baseline-expect: fail
$ test -f .claude/skills/gemini-cli-headless-delegation-contract/SKILL.md
# AC2
# baseline-expect: fail
$ rg -n "gemini-cli-headless-delegation-contract" .claude/agents/codebase-investigator.md .claude/agents/web-researcher.md
# AC3
# baseline-expect: fail
$ test -f .claude/skills/gemini-cli-headless-delegation-contract/SKILL.md

Allowed Paths

  • .claude/skills/gemini-cli-headless-delegation-contract/SKILL.md
  • .claude/agents/codebase-investigator.md
  • .claude/agents/web-researcher.md
  • docs/dev/agent-skill-boundaries.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 実装: Skill references/ の read permission と Agent/Skill 契約 strict validator を追加する #1745 が未完了、または smoke runner の exact invocation が未提供の場合

Required Skills

  • YAML / JSON Schema

Required Design References

  • docs/dev/agent-skill-boundaries.md
  • #1745 の strict validator/fresh-session smoke contract

Scope Delta(該当時のみ記載)

N/A

Runtime Verification Applicability

本 Issue の変更対象はワークフロー文書・スクリプトのみです。ゲームの実行時動作には影響しません。

decision: not_applicable
reason: "Workflow documentation and script changes only. No runtime game behavior changed."

Delivery Rule

1 Issue = 1 PR。#1745 merge 後に worktree 上で実装し、Draft PR を既定とする。

Notes for Reviewer

OWNER comment #5081111879 の推奨分割 A。#1745 への blocked dependency は GitHub native dependency として登録する。

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Jul 25, 2026
  2. squne121 commented on Jul 25, 2026

    @squne121
    OwnerAuthor

    判定

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

    設計の方向性自体は妥当です。特に「quota/capacity の場合だけ直接 fallback を許可し、auth・permission・schema・integrity failure を隠蔽しない」という目的は正しいです。しかし、現在の Issue は次の三点を同時に成立させられていません。

    1. fallback 判定に必要な完全な失敗履歴が、現在の wrapper 出力に存在しない
    2. caller が作成できる result.json を fallback 許可証として扱っている
    3. 対象 Agent が使う profile は、既存 provider_auto_policy_v1 の対象外である

    確認時点で #1736 のコメントは0件、Closes/Fixes/Resolves #1736 を持つ直接PRも確認できませんでした。関連実装としては、quota/capacity 限定の provider fallback を導入した PR #1331 が既にマージ済みです。

    P0-1. --delegation-result は容易に偽造できる

    Issue は、概ね次のインターフェースを想定しています。

    direct_codebase_fallback.py
      --delegation-result <result.json>
      --request <request.json>
    

    しかし、codebase-investigator 自身が Bash で /tmp に request JSON を作成し、wrapper の result JSON を読み取る構造です。つまり、同じ Agent が quota-only に見える偽の result.json を作成して executor に渡せます。JSON Schema を厳格にしても、検証できるのは内容の形式であって、wrapper が本当に生成したかという来歴ではありません。

    さらに両対象 Agent は Bash を持っています。現在の .claude/settings.json には gh api *、gh issue edit/create/close/comment、git push、git commit まで許可されています。したがって「決定論的 executor のみが fallback を実行する」という文章上の制約は、現状の permission contract では成立しません。

    必須修正

    --delegation-result を廃止してください。fallback executor 自身が wrapper を呼び、同一プロセス内で結果を評価してから fallback を実行する必要があります。

    controlled_research_fallback_exec.py --request <request.json>
      1. request を検証
      2. wrapper を内部起動
      3. wrapper の戻り値をメモリ上で判定
      4. eligibility=true の場合だけ固定 profile を実行
      5. 統合 result と audit evidence を出力
    

    request_sha256、result_sha256、run_id は監査には有効ですが、caller が書けるファイルを認可証にする設計の代替にはなりません。秘密鍵を同一 Agent から参照可能にした HMAC も実質的な防御にはなりません。

    P0-2. Issue が要求する完全な attempts[] は存在しない

    Issue は「terminal code だけでなく、attempts[] のすべての原因を検証する」と要求しています。

    ところが現在の wrapper が provider fallback 時に保持するのは、providerごとの次の情報です。

    • その provider の最終 failure_class
    • model_chain
    • model_downgrades
    • モデル別の試行回数
    • provider fallback 可否

    個々の subprocess 試行ごとの failure_class は保持していません。したがって、caller-side gate は「すべての leaf failure が quota/capacity だった」ことを独立に検証できません。

    さらに、既存契約には既に schema drift があります。failure-class-taxonomy.md は attempts_by_model を object list とし、各項目に final_failure_class を持たせています。一方、実装は {model_id: attempt_count} の mapping を出力しています。

    これは単なる表記差ではありません。#1736 の executor がどちらを正として実装するかで、fallback 許可判定が変わります。

    必須修正

    推奨は、wrapper を唯一の fallback eligibility 判定者にすることです。

    schema: delegation_fallback_decision/v1
    policy_version: quota_only_v1
    eligible: false
    run_id: "<uuid>"
    request_sha256: "<sha256>"
    tool_profile: local_asset_research
    terminal_failure_class: provider_fallback_exhausted
    attempt_history_complete: true
    leaf_attempt_count: 4
    eligible_failure_classes:
      - quota_or_rate_limited
      - model_capacity_exhausted
    eligible_quota_dimensions:
      - rpm
      - tpm
      - rpd
      - model_capacity
    denial_reasons:
      - mixed_failure_classes
    fallback_profile: null

    この decision は監査用に出力して構いませんが、認可判断は wrapper と executor を束ねた制御プロセス内で行うべきです。

    完全履歴を外部に出す場合は、少なくとも次を追加します。

    attempt_history:
      - ordinal: 1
        provider: gemini
        model: gemini-3-flash-preview
        phase: model_retry
        failure_class: quota_or_rate_limited
        quota_dimension: rpm
        classification_confidence: high
        retryable: true

    この変更は delegation_result/v1 の producer である wrapper と、その consumer 群の契約変更です。新しい contract Skill だけに別定義を置くことはできません。schema catalog は現在、wrapperを producer、web-researcher、codebase-investigator、impl-review-loop を consumer として明示しています。

    P0-3. 対象 profile では provider fallback が動かない

    対象 Agent の利用 profile は次の通りです。

    • codebase-investigator

      • local_asset_research
      • github_research
    • web-researcher

      • grounded_research

    一方、現在の provider_auto_policy_v1 が許可する profile は no_tools と proposal_only だけです。さらに AGY は github_research をサポートしていません。

    したがって、#1736 の「wrapper 内の retry、model chain、provider fallback が完了した後」という前提は、対象三 profile では成立しません。

    • provider=auto + local_asset_research → 現行policyでは profile unsupported
    • provider=auto + grounded_research → 現行policyでは profile unsupported
    • provider=auto + github_research → 現行policyでは profile unsupported、かつAGY非対応

    必須修正

    profile別に経路を明文化してください。

    fallback_routes:
      local_asset_research:
        provider_route: gemini -> agy
        direct_fallback: repo_read_v1
    
      grounded_research:
        provider_route: gemini -> agy
        direct_fallback: web_research_v1
    
      github_research:
        provider_route: gemini_only
        direct_fallback: github_get_v1

    ただし、local_asset_research と grounded_research を provider_auto_policy_v1 に追加するなら、PR #1331で意図的に限定した安全境界を拡張する変更です。wrapper、model_routing.yaml、failure taxonomy、provider mapping、tests の変更が必要であり、「wrapper execution logic は変更しない」「独立着手可能」という記述は削除すべきです。

    P0-4. 「read-only executor」の唯一性を permission が保証していない

    Issue の AC9 は、executor 内に read-only という文字列があることを rg で確認するだけです。これは実行時制約ではありません。

    Claude Code の permission は deny → ask → allow の順で評価され、prompt や Agent 本文の「禁止」は permission enforcement を変更しません。dontAsk は未許可操作を拒否しますが、allowlist に一致する Bash は実行されます。(Claude)

    現在の設定では、対象 Agent の Bash から以下が承認不要で実行可能です。

    gh issue edit
    gh issue create
    gh issue close
    gh issue comment
    gh api *
    git push
    git commit
    

    この状態で「fallback は read-only executor 経由でのみ行われる」とは主張できません。

    必須修正

    リポジトリ既存の controlled executor パターンに合わせるべきです。

    • Agent が直接 direct_codebase_fallback.py を呼ばない
    • scripts/agent-guards/...exec.py --command-id research.repo_read.v1 のような固定 launcher を経由
    • settings には exact command pattern だけを許可
    • PreToolUse hook で対象 Agent の他の Bash を拒否
    • executor は arbitrary argv を受け取らず、固定 operation ID のみ受理
    • shell=False
    • fixed cwd、minimal env
    • repo境界、symlink、device file、/proc、/sys、.. を拒否
    • ファイル数、行数、byte数、実行時間、出力量を上限化

    github_get_v1 は gh api --method GET の固定 endpoint template のみとし、caller提供の任意 argv は受け取らない設計が必要です。

    P0-5. preload可能なSkillは、それ自体では capability boundary にならない

    既存 execution Skill は disable-model-invocation: true です。これは自動起動を防ぎますが、同時に SubAgent への preload も禁止します。

    Claude Code の公式仕様では、SubAgent の skills: に指定されたSkill本文は起動時に全量注入されます。一方、disable-model-invocation: true のSkillは preloadできません。また user-invocable: false は / メニューから隠すだけで、モデルによるSkill利用を禁止しません。(Claude)

    したがって新規 contract Skill は、次の形に限定すべきです。

    ---
    name: gemini-cli-headless-delegation-contract
    description: Delegation request/result schema IDs、failure taxonomy、routing invariantsだけを提供する背景知識。
    user-invocable: false
    ---

    本文には以下を置かない方が安全です。

    • wrapper実行コマンド
    • fallback executor実行手順
    • allowed-tools
    • provider呼び出しを開始する命令
    • mutationや認証変更手順

    実際の execution Skill は引き続き disable-model-invocation: true を維持します。

    また、preload mapping と permission を検証する strict validator/fresh-session smoke は #1745 の責務です。類似 preload Issue #1744 は既に blocked_by: ["#1745"] としています。#1736だけを独立着手可能にする合理的理由はありません。

    #1736 にも blocked_by: ["#1745"] を追加すべきです。

    P0-6. 既存Agentの挙動を破壊的に変更するのにmigrationがない

    現在の web-researcher は次の失敗で direct fallback を許可しています。

    • auth_error
    • capability_unavailable
    • grounding_failure

    一方、query_error では fallbackしません。

    WEB_RESEARCH_RESULT_V1 の failure_class union に quota/capacity は存在しません。

    対して codebase-investigator は wrapper failure の全てで fail-close し、Bashを使った直接調査も禁止しています。

    #1736 は、両者に対して正反対の既存挙動を同時に変更します。これは「contract Skillをpreloadするだけ」の変更ではありません。

    必須修正

    少なくとも次を明記してください。

    • WEB_RESEARCH_RESULT_V1 を additive extension にするか、V2へ上げるか
    • quota_or_capacity_exhausted
    • fallback_attempted
    • fallback_profile
    • fallback_denied_reason
    • delegation_run_id
    • fallback_policy_version
    • consumerである issue-refinement-loop のbefore/after
    • 旧 auth_error direct fallbackを廃止するmigration test
    • codebaseの旧 all-fail-closeからquota-onlyへのmigration test

    P1-1. direct_codebase_fallback.py だけでは web-researcher を統制できない

    #1736 は両Agentを対象にしながら、実行物として明示しているのは direct_codebase_fallback.py だけです。

    しかし web-researcher には既に WebSearch、WebFetch、gh api --method GET の三経路があります。codebase executor の存在確認では、web fallback が quota-onlyであることも、read-onlyであることも、唯一経路であることも証明できません。

    次のいずれかに分けるべきです。

    • repo_read_v1
    • github_get_v1
    • web_research_v1

    Web検索結果そのものは時刻や検索indexによって変化するため「決定論的」とは言えません。決定論的にできるのは、認可判定、query組み立て、取得制限、provenance記録、出力schemaです。

    P1-2. CLIバージョン差を無視している

    Gemini CLIの公式headless契約では、JSON出力に response、stats、任意の error があり、exit code 1 は一般的なAPI failureです。したがって quota判定をexit codeだけで行うことはできず、構造化 error を優先する必要があります。(Gemini CLI)

    Antigravity CLIは直近の複数リリースでheadless挙動が変更されています。

    • 1.1.1: server failure時の成功終了・空出力を修正
    • 1.1.3: headless permission promptをsoft-denyへ修正
    • 1.1.4: headlessでpersisted permissions/sandbox等を尊重するよう修正
    • 1.1.6: print modeの実エラー報告を修正

    ([GitHub]4)

    従って fallback gate には次が必要です。

    • provider_cli_name
    • provider_cli_version
    • tested minimum/maximum version
    • unknown version時のfail-close
    • golden fixtureを取得したversion
    • classification_confidence: high の場合だけfallback許可

    また、Gemini APIの429にはRPM、TPM、RPDだけでなくspend-based limitもあります。単に HTTP 429 を quota-only許可とせず、quota_dimension の許可集合を固定してください。([Google AI for Developers]5)

    例:

    eligible_quota_dimensions:
      - rpm
      - tpm
      - rpd
      - model_capacity
    
    denied_quota_dimensions:
      - spend
      - unknown

    spend を許可する方針もあり得ますが、その場合は明示的なpolicy decisionとテストが必要です。

    P1-3. Acceptance Criteria が文字列検査に偏りすぎている

    現在のACは次のような確認です。

    • executorファイルが存在する

    • read-only という文字列がある

    • attempts という文字列がある

    • auth expired という文字列がある

    • -k negative に一致するテストを実行する

    既存テストには、この方式が既に誤検知を起こしている具体例があります。

    test_disallowed_tools_includes_webfetch_websearch は「disallowedTools に含まれる」ことを検証する名前ですが、実際には frontmatter 全体に WebFetch/WebSearch という文字列があるかしか見ていません。現行 Agent では両方とも tools、つまり許可側にありますが、このテストは通過します。

    これは #1736 の rg ベースACが安全性を証明しないことの実例です。

    推奨するIssue分割

    現状のIssue自身が「Allowed Paths外の変更が必要」「新規Issueへのスコープ分割が必要」な場合を停止条件としています。今回、wrapper、settings、schema catalog、consumer migrationが必要なので、その停止条件に該当します。

    A. preload-only contract

    対象:

    • contract Skill
    • Agent frontmatter
    • strict validator
    • fresh-session preload smoke

    条件:

    • blocked_by: #1745
    • execution Skillは引き続き disable-model-invocation: true
    • contract Skillはknowledge-only
    • fallback実装を含めない

    B. wrapper-owned fallback eligibility

    対象:

    • run_gemini_headless.py
    • failure taxonomy
    • provider policy
    • delegation_result/v1
    • schema catalog
    • producer/consumer tests

    条件:

    • 完全なattempt history、またはwrapper内部decision
    • quota dimensionの許可集合
    • high-confidence classificationのみ許可
    • mixed/missing/unknownはfail-close
    • CLI version記録

    C. controlled direct fallback executors

    対象:

    • controlled launcher
    • repo/GitHub/web profile別executor
    • settings/PreToolUse hook
    • runtime smoke
    • audit evidence

    条件:

    • caller提供の result.json を認可入力にしない
    • direct executorの単独起動を拒否
    • read-only capabilityをpermissionとコードの両方で固定
    • global attempt/wall-clock/byte budget
    • fallback一回限り
    • post-processingやmutation禁止

    置換すべき主要AC

    1. #1745がマージ済みで、strict validatorとfresh-session runnerを再利用している
    2. contract Skillのfrontmatterがstrict YAMLとして妥当で、Agentのskills: mappingが完全一致する
    3. execution Skillのdisable-model-invocation: true が維持される
    4. contract Skillにはprovider実行手順、allowed-tools、副作用命令が存在しない
    5. controlled launcherがwrapperを自身で呼び、caller提供のdelegation resultを受け取らない
    6. wrapperまたは同一制御プロセスが全leaf attemptからeligibilityを判定する
    7. 全leaf failureが許可class、許可dimension、classification_confidence=high の場合だけfallbackする
    8. auth、permission、trusted workspace、CLI missing、schema、output integrity、Serena provenance、unknown、mixed causeは全てfallbackしない
    9. 対象profileごとのprovider routeとdirect fallback profileが固定されている
    10. executor以外のBash/Web/gh経路がpermissionまたはhookで拒否される
    11. repo境界、symlink、path traversal、device file、出力量、実行時間のnegative testがある
    12. schema catalogと全consumer inventoryが更新される
    13. Gemini/AGYの対応versionとunknown-version fail-close testがある
    14. fresh sessionで通常成功、quota fallback、auth拒否、偽造result拒否、malformed result拒否、symlink拒否、mutation拒否を実証する
    15. smoke evidenceにcommit SHA、CLI version、policy version、run ID、request/result hashを保存し、credential/絶対HOME pathは保存しない

    最終結論

    #1736 はこのまま実装すると、quota-only fallbackを追加するはずが、Agentが偽のquota resultを作って直接調査を解禁できる構造になります。

    特に修正必須なのは次の四点です。

    1. --delegation-result を廃止し、wrapper呼び出しとfallback判定を一体化する
    2. wrapperが完全なattempt historyまたはfallback decisionを所有する
    3. 対象profileと既存 provider_auto_policy_v1 の不整合を解消する
    4. permission/hookによってcontrolled executorを唯一経路にする

    推奨措置は、#1736を一旦着手停止し、preload契約・wrapper判定・controlled executorの三Issueへ分割することです。

  3. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "review_compact_validation_invalid"
    
    "unknown_field:REVIEWER_BLOCKER_CLAIM"
    
    "reviewer output reported status=failed with no deterministic blockers"
    
  4. changed the title [-]実装: Gemini delegation を preload 可能な contract と quota-only fallback に分離する[/-] [+]実装: Gemini delegation preload-only contract[/+] on Jul 26, 2026
  5. squne121 commented on Jul 26, 2026

    @squne121
    OwnerAuthor
    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: blocked
        gate_result: blocked
        latest_comment_url: ""
        generated_at: "2026-07-26T00:27:00Z"
        body_sha256: "sha256:b2e4ac0e97ed7b1ce7c38cb6fb7100e43c7c5076992ad2bb5d969ac776d9965c"
      metadata:
        title_prefix_ready: true
        phase_label_ready: true
      auto_fixes:
        result: blocked
        required: []
        skipped: []
      blockers:
        - kind: dependency_open
          description: "#1745 が OPEN のため、実装開始および contract snapshot の go は保留。"
      permissions:
        unavailable: []
      generated_at: "2026-07-26T00:27:00Z"
      checked_body_sha256: "sha256:b2e4ac0e97ed7b1ce7c38cb6fb7100e43c7c5076992ad2bb5d969ac776d9965c"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  6. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    判定

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

    単独Issueとして修正を続けるより、not planned / superseded で閉じ、有用な要件だけを #1886 へ統合するのが妥当です。

    現在の契約は issue_kind: implementation である一方、parent_issue: "#1736"、本文の Parent Issue も #1736 となっており、自己参照しています。また、#1745 を blocking dependency としながら、「別 child Issue」に残課題を送る構造になっています。implementation Issue・parent・child の三役が混在しており、依存関係と完了条件を機械的に解釈できません。

    評価できる点

    実行用 Skill と background knowledge を分離する発想自体は技術的に成立します。既存の実行用 gemini-cli-headless-delegation Skill は disable-model-invocation: true を持っており、Claude Code公式仕様では、このフラグを持つ Skill は SubAgentへ preload できません。また、user-invocable: false を使った background knowledge Skill も公式に想定されています。 (Claude)

    問題は preload という機能ではなく、このリポジトリで新しい provider固有・概念専用Skillを増やす設計、依存先、検証方法が現行方針と一致していないことです。

    P0ブロッカー

    P0-1. 現行の設計SSOTと正面衝突している

    docs/dev/agent-skill-boundaries.md は現在、次の設計を正本としています。

    • SubAgentは役割。

    • Skillは作業手順。

    • 共有される説明・概念だけを独立Skillにする構成はアンチパターン。

    • 共通知識は references/ または同ドキュメントへ集約する。

    これに対して #1736 の中心成果物は、実行手順を一切持たない gemini-cli-headless-delegation-contract という knowledge-only Skillです。つまり、Required Design Referenceとして指定した文書と、実装方針が一致していません。

    Claude Code製品としては background knowledge Skillが正式サポートされています。したがって、実装不能なのではありません。採用するなら、Issue本文で次のどちらかを明示的に決める必要があります。

    1. agent-skill-boundaries.md に「SubAgent preload専用 background knowledge Skill」を例外として追加する。

    2. 新Skillを作らず、provider-neutralな最小契約をAgent本文と既存referenceへ配置する。

    現状はどちらも行っていません。

    さらに、Claude Codeの skills: は progressive disclosure ではなく、Skill全文をSubAgent起動時に注入する eager preload です。#1736 は既存Agent本文から重複説明を削ることも、preload後の合計byte/token量を減らすこともACにしていません。そのため、現在の契約どおりに実装すると、コンテキスト削減ではなく単純なコンテキスト追加になる可能性が高いです。(Claude)

    必須修正: preloadを残すなら、各Agentについて次をACにしてください。

    candidate_agent_body_bytes
    + preloaded_skill_bytes
    <= baseline_agent_body_bytes
    

    この条件を満たせないなら、目的は「context diet」ではなく「契約の重複防止」に改称すべきです。

    P0-2. #1745 依存は、現在利用不能であるうえ、技術的にも不要

    #1745 は次の共有基盤を提供する契約でした。

    • binding_manifest.yaml

    • validate_claude_agent_skill_contract.py

    • fresh_session_permission_smoke.py

    • result_schema_v1.json

    • .claude/** blanket read denyの撤去

    • pr-reviewer/pr-review-judge bindingの検証

    Issue自体は completed でクローズされています。

    しかし、レビュー時点のcurrent mainでは、#1736が依存する上記4成果物を解決できませんでした。加えて、.claude/settings.json には現在も Read(**/.claude/**) denyが残っています。つまり、Issueのclosed状態だけではcurrent-main成果物の存在を証明できません。

    より重要なのは、#1736 の単一 SKILL.md preloadにはreference read permissionが不要なことです。公式仕様では、preloadされたSkill全文は起動時に直接コンテキストへ注入されます。AgentがReadツールで .claude/skills/** を読む経路ではありません。(Claude)

    したがって、#1745が必要になるのは、起動後にAgentが references/ をReadする設計を採用した場合です。#1736はそれをOut of Scopeにしています。

    また、#1745のcanonical smokeは pr-reviewer/pr-review-judge pairを対象としており、codebase-investigator/web-researcher を対象とするにはmanifest・test・runnerの変更が必要です。それらは #1736 のAllowed Paths外なので、自身のStop Conditionsにも抵触します。

    必須修正: blocked_by: ["#1745"] を削除してください。存在しない共有ハーネスを復活させるべきでもありません。

    P0-3. Acceptance Criteriaを何も証明していない

    現在のVerification Commandsは次の状態です。

    • AC1: 新Skillファイルが存在するか test -f

    • AC2: Agent 2ファイルにSkill名の文字列があるか rg

    • AC3: AC1と同じ test -f

    空のファイルでもAC1とAC3は通ります。Agent本文のコメントにSkill名を書くだけでAC2も通ります。frontmatterのYAMLが壊れている、skills: が文字列でなく誤った型、Skill名がdirectory名と不一致、disable-model-invocation: true を誤って指定、実行命令や allowed-tools を含む、といった障害を一切検出できません。

    Claude Codeは、preload対象Skillが欠落または無効でもセッション全体を必ず失敗させるのではなく、そのSkillをskipしてdebug logへwarningを記録します。このため、文字列検査だけでは silent degradation を見逃します。(Claude)

    大規模な新validatorは不要です。既存の test_agent_contracts.py を拡張し、最低限次を検証すべきです。既存テスト資産はすでに同じAgent/Skill契約を扱っています。

    検証 | 必須条件 -- | -- Agent frontmatter | yaml.safe_load でstrict parse、skills はlist mapping | 2 Agentとも完全一致したSkill名を1回だけ保持 Skill identity | directory名とfrontmatter name が一致 background knowledge | user-invocable: false preload可能性 | disable-model-invocation が不存在またはfalse 無副作用 | allowed-tools、disallowed-tools、context、agent、hooksが不存在 negative fixtures | malformed YAML、Skill欠落、wrong name、disabled Skillを拒否 context budget | Agent本文+preload全文がbaseline以下 behavior invariants | 既存terminal state/output schema markerが不変

    新しい gemini-cli-headless-delegation-contract Skill、#1745型manifest、fresh-session evidence schemaは追加しません。

    実装順序

    1. #1909を維持するか先に確定する。

    2. 維持する場合は 実装: SubAgent 発火前に bounded local context bundle を生成し Claude/Codex の両 loop で consume する #1909 を先にマージする。

    3. #1886本文をowner commentに同期する。

    4. Claude/Codexの両Agentを対象化する。

    5. 全profileのprimaryをAGY、Geminiをfallbackにする。

    6. Agent契約をprovider-neutralなthin bindingへ整理する。

    7. #1736を not planned / superseded by #1886 で閉じる。

    preloadを残す場合の最小構成

    preload自体を採用するなら、少なくとも次の形まで縮小してください。

    ---
    name: headless-delegation-contract
    description: Provider-neutral delegation identifiers and invariants for research subagents.
    user-invocable: false
    ---
    

    禁止事項:

    - allowed-tools を持たない
    - disable-model-invocation を持たない
    - context / agent / hooks を持たない
    - CLI argv を記載しない
    - provider routing table を複製しない
    - fallback policyを所有しない
    - schema bodyを複製しない
    - references/ のruntime Readに依存しない
    

    検証は既存test suiteへの十数ケースの追加と、1回のloader smokeで十分です。#1745への依存は削除します。

    推奨クローズコメント

    ## Closing as `not planned` / superseded
    

    本Issueが持っていた有用な要件のうち、research SubAgentをthin binding化し、
    delegation契約のdriftを決定論的に検査する要件は #1886 へ統合する。

    新しい Gemini 固有の knowledge-only Skill は追加しない。

    理由:

    • current architecture SSOTでは、Skillは作業手順を所有し、
      共有概念だけの独立Skillは既定の構成ではない
    • preloadはSkill全文を起動時に注入するため、
      現契約ではcontext削減を証明できない
    • #1745の共有validator/smoke成果物をcurrent mainから利用できず、
      単一SKILL.md preloadにはreference read permissionも不要
    • 現AC/VCはfrontmatter・preload成功・negative caseを検証していない
    • provider方針はAGY primary / Gemini fallbackへ移行しており、
      Gemini固有の新しい契約名は陳腐化する
    • #1886と#1909が同じAgent startup contractを変更するため、
      別PRとして並行実装するとsemantic split-brainを招く

    Superseded by: #1886

    #1909を維持する場合は、同Issueの入力契約確定後のmainを
    #1886のbaselineとして使用する。

    最終判断は、#1736単独のrewriteではなく、not planned クローズです。 preload機構を追加しても現在の問題であるAGY primary routing、Codex parity、request validation、実SubAgent dispatchのいずれも解決しません。これらを所有する #1886 に集中させる方が、現行リポジトリのminimal harness方針と一致します。

    # 判定

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

    単独Issueとして修正を続けるより、not planned / superseded で閉じ、有用な要件だけを #1886 へ統合するのが妥当です。

    現在の契約は issue_kind: implementation である一方、parent_issue: "#1736"、本文の Parent Issue も #1736 となっており、自己参照しています。また、#1745 を blocking dependency としながら、「別 child Issue」に残課題を送る構造になっています。implementation Issue・parent・child の三役が混在しており、依存関係と完了条件を機械的に解釈できません。

    評価できる点

    実行用 Skill と background knowledge を分離する発想自体は技術的に成立します。既存の実行用 gemini-cli-headless-delegation Skill は disable-model-invocation: true を持っており、Claude Code公式仕様では、このフラグを持つ Skill は SubAgentへ preload できません。また、user-invocable: false を使った background knowledge Skill も公式に想定されています。 ([Claude]1)

    問題は preload という機能ではなく、このリポジトリで新しい provider固有・概念専用Skillを増やす設計、依存先、検証方法が現行方針と一致していないことです。

    P0ブロッカー

    P0-1. 現行の設計SSOTと正面衝突している

    docs/dev/agent-skill-boundaries.md は現在、次の設計を正本としています。

    • SubAgentは役割。
    • Skillは作業手順。
    • 共有される説明・概念だけを独立Skillにする構成はアンチパターン。
    • 共通知識は references/ または同ドキュメントへ集約する。

    これに対して #1736 の中心成果物は、実行手順を一切持たない gemini-cli-headless-delegation-contract という knowledge-only Skillです。つまり、Required Design Referenceとして指定した文書と、実装方針が一致していません。

    Claude Code製品としては background knowledge Skillが正式サポートされています。したがって、実装不能なのではありません。採用するなら、Issue本文で次のどちらかを明示的に決める必要があります。

    1. agent-skill-boundaries.md に「SubAgent preload専用 background knowledge Skill」を例外として追加する。
    2. 新Skillを作らず、provider-neutralな最小契約をAgent本文と既存referenceへ配置する。

    現状はどちらも行っていません。

    さらに、Claude Codeの skills: は progressive disclosure ではなく、Skill全文をSubAgent起動時に注入する eager preload です。#1736 は既存Agent本文から重複説明を削ることも、preload後の合計byte/token量を減らすこともACにしていません。そのため、現在の契約どおりに実装すると、コンテキスト削減ではなく単純なコンテキスト追加になる可能性が高いです。([Claude]1)

    必須修正: preloadを残すなら、各Agentについて次をACにしてください。

    candidate_agent_body_bytes
    + preloaded_skill_bytes
    <= baseline_agent_body_bytes
    

    この条件を満たせないなら、目的は「context diet」ではなく「契約の重複防止」に改称すべきです。

    P0-2. #1745 依存は、現在利用不能であるうえ、技術的にも不要

    #1745 は次の共有基盤を提供する契約でした。

    • binding_manifest.yaml
    • validate_claude_agent_skill_contract.py
    • fresh_session_permission_smoke.py
    • result_schema_v1.json
    • .claude/** blanket read denyの撤去
    • pr-reviewer/pr-review-judge bindingの検証

    Issue自体は completed でクローズされています。

    しかし、レビュー時点のcurrent mainでは、#1736が依存する上記4成果物を解決できませんでした。加えて、.claude/settings.json には現在も Read(**/.claude/**) denyが残っています。つまり、Issueのclosed状態だけではcurrent-main成果物の存在を証明できません。

    より重要なのは、#1736 の単一 SKILL.md preloadにはreference read permissionが不要なことです。公式仕様では、preloadされたSkill全文は起動時に直接コンテキストへ注入されます。AgentがReadツールで .claude/skills/** を読む経路ではありません。([Claude]1)

    したがって、#1745が必要になるのは、起動後にAgentが references/ をReadする設計を採用した場合です。#1736はそれをOut of Scopeにしています。

    また、#1745のcanonical smokeは pr-reviewer/pr-review-judge pairを対象としており、codebase-investigator/web-researcher を対象とするにはmanifest・test・runnerの変更が必要です。それらは #1736 のAllowed Paths外なので、自身のStop Conditionsにも抵触します。

    必須修正: blocked_by: ["#1745"] を削除してください。存在しない共有ハーネスを復活させるべきでもありません。

    P0-3. Acceptance Criteriaを何も証明していない

    現在のVerification Commandsは次の状態です。

    • AC1: 新Skillファイルが存在するか test -f
    • AC2: Agent 2ファイルにSkill名の文字列があるか rg
    • AC3: AC1と同じ test -f

    空のファイルでもAC1とAC3は通ります。Agent本文のコメントにSkill名を書くだけでAC2も通ります。frontmatterのYAMLが壊れている、skills: が文字列でなく誤った型、Skill名がdirectory名と不一致、disable-model-invocation: true を誤って指定、実行命令や allowed-tools を含む、といった障害を一切検出できません。

    Claude Codeは、preload対象Skillが欠落または無効でもセッション全体を必ず失敗させるのではなく、そのSkillをskipしてdebug logへwarningを記録します。このため、文字列検査だけでは silent degradation を見逃します。([Claude]1)

    大規模な新validatorは不要です。既存の test_agent_contracts.py を拡張し、最低限次を検証すべきです。既存テスト資産はすでに同じAgent/Skill契約を扱っています。

    検証 必須条件
    Agent frontmatter yaml.safe_load でstrict parse、skills はlist
    mapping 2 Agentとも完全一致したSkill名を1回だけ保持
    Skill identity directory名とfrontmatter name が一致
    background knowledge user-invocable: false
    preload可能性 disable-model-invocation が不存在またはfalse
    無副作用 allowed-tools、disallowed-tools、context、agent、hooksが不存在
    negative fixtures malformed YAML、Skill欠落、wrong name、disabled Skillを拒否
    context budget Agent本文+preload全文がbaseline以下
    behavior invariants 既存terminal state/output schema markerが不変

    AC3はAC1の重複ではなく、このtest suiteの実行に置換すべきです。

    P0-4. Runtime Verificationの判定が自己矛盾している

    OutcomeとAC3は「#1745 の strict validator/fresh-session smoke がPASSすること」を完了条件としています。一方、Runtime Verification Applicabilityは not_applicable であり、理由も「ゲームの実行時動作には影響しない」という無関係なテンプレート残骸です。

    preloadはSubAgentの起動時system contextを実際に変更します。公式仕様でも、skills: に列挙したSkill全文がstartup時に注入されると明記されています。したがって、少なくともloader-level runtime verificationはapplicableです。([Claude]1)

    ただし、#1745型の証跡基盤は過剰です。必要なのは一つの最小smokeです。

    1. `claude --agents` で一時Agentを定義
    2. `skills: [対象Skill]` を付与
    3. Skill内の一意なsentinelをAgentに返させる
    4. debug logに missing/disabled Skill warningがないことを確認
    5. transcript、hash manifest、baseline/candidate evidence bundleは作らない
    

    --agents はファイルベースSubAgentと同じ skills frontmatterを受理する公式経路です。([Claude]1)

    P0-5. Gemini固有の契約名が、現在のprovider戦略と陳腐化している

    Googleは2026年6月18日に、Google AI Pro/Ultraおよび無償個人利用者向けGemini CLIのリクエスト提供を停止し、Antigravity CLIへ移行しました。Antigravity CLIはSkill、Hooks、Subagents等を引き継ぐ後継として位置付けられています。([Google Developers Blog]2)

    リポジトリ側でも #1265 がGemini CLIからAntigravity CLIへの移行を扱っています。

    さらに、関連する #1886 のowner指示では、

    • Claude CodeだけでなくCodex CLIのSubAgentも対象にする。
    • 全profileの期待providerはAntigravity CLI。
    • Gemini CLIはfallbackに限定する。

    という方針が示されています。一方、現在の #1886 本文はまだClaude側2ファイルだけを対象とし、github_research をGemini固定としています。本文とowner commentが未同期です。

    この状態で #1736 が gemini-cli-headless-delegation-contract という名前とrole/profile mappingを新たな正本として固定すると、provider authorityがさらに分散します。

    CLI固有のwire contractもpreload知識へ複製すべきではありません。Gemini CLIのheadless interfaceだけでも、--prompt、JSON/stream-json output、exit code 0・1・42・53という実装契約があります。これらは既存wrapper/execution Skillで所有し、Agent preloadには入れないのが妥当です。([Gemini CLI]3)

    必須修正: preloadを残す場合でも、名前はprovider-neutralにしてください。

    name: headless-delegation-contract

    内容は次だけに限定します。

    • profile ID
    • operation ID
    • canonical builder/validatorの参照先
    • output contract ID
    • provider選択をAgent本文で再定義しないという禁止事項

    provider順序、CLI argv、fallback条件、failure taxonomy、schema bodyは既存execution Skill/configの正本に残します。

    P0-6. #1886・#1909との競合判定が甘い

    #1886は同じ codebase-investigator.md/web-researcher.md のprovider request契約を変更します。#1909は同じClaude Agentに加えCodex Agentも変更し、context_bundle_path、bundle_id、context_source をstartup input contractへ追加します。

    「編集sectionが異なるためnon-conflict」という判断は不十分です。Agent frontmatter、Agent本文、preloaded Skill、context bundleは最終的に一つのSubAgent startup contextになります。ファイル上の行が異なっても、context budget、instruction precedence、terminal contractの意味的競合が発生します。Claude Code公式仕様でも、Agent本文はsystem promptになり、preloaded Skill全文が追加注入されます。(Claude)

    #1909を維持するなら、先にその入力契約を確定・マージし、その後のmainをbaselineとして #1886 を実装すべきです。単なる「later merge側でrebase」ではなく、native dependencyまたは明示した直列順序が必要です。

    P1・P2指摘

    配布境界が未定義

    .claude/agents/ はcurrent project scopeです。複数プロジェクトへの配布は ~/.claude/agents/ またはpluginの agents/ が別経路になります。plugin Agentにはfrontmatter fieldの制約もあります。([Claude]1)

    したがって #1736 の成果物は、現状ではこのリポジトリ限定のproject-local contractです。cross-repository配布、plugin packaging、versioning、install smokeを完了したと主張してはいけません。

    文書契約の品質不足

    以下はすべて修正対象です。

    • parent_issue: "#1736" の自己循環。
    • Required Skills: YAML / JSON Schema としながらJSON Schema成果物がない。
    • docs/dev/agent-skill-boundaries.md がAllowed Pathsにあるのに対応ACがない。
    • Runtime理由に「ゲーム」が残る。
    • AC3とAC1が同一。
    • exact smoke invocationを記録するとしながら、Issue内にそのcommandがない。
    • Stop Conditionsが、本Issueの実装に必要なmanifest/test変更を自ら禁止している。

    推奨する収束案

    第一推奨: #1736を閉じ、#1886へ統合する

    #1774では、fallback eligibility・完全attempt ledger・専用認可基盤が個人開発規模に対して過剰と判断され、not planned で閉じられました。その後は #1885 のAGY one-shot real subprocess検証という小さい実装へ置換されています。

    #1736も同じ方針で縮小するべきです。

    #1886に統合する要件

    Surface 所有内容
    Claude/Codex Agent role、profile ID、canonical builder呼出し、output contract ID、禁止事項
    既存execution Skill/config provider matrix、argv、validation、fallback、failure taxonomy
    既存Agent contract tests strict frontmatter、builder/runtime validator parity、terminal marker不変
    #1886 runtime smoke Claude/Codexの実dispatchでAGY primary、Gemini fallbackを確認
    #1885 tests AGY subprocessのstdout/stderr/timeout/non-zero round-trip

    新しい gemini-cli-headless-delegation-contract Skill、#1745型manifest、fresh-session evidence schemaは追加しません。

    実装順序

    1. #1909を維持するか先に確定する。
    2. 維持する場合は 実装: SubAgent 発火前に bounded local context bundle を生成し Claude/Codex の両 loop で consume する #1909 を先にマージする。
    3. #1886本文をowner commentに同期する。
    4. Claude/Codexの両Agentを対象化する。
    5. 全profileのprimaryをAGY、Geminiをfallbackにする。
    6. Agent契約をprovider-neutralなthin bindingへ整理する。
    7. #1736を not planned / superseded by #1886 で閉じる。

    preloadを残す場合の最小構成

    preload自体を採用するなら、少なくとも次の形まで縮小してください。

    ---
    name: headless-delegation-contract
    description: Provider-neutral delegation identifiers and invariants for research subagents.
    user-invocable: false
    ---

    禁止事項:

    - allowed-tools を持たない
    - disable-model-invocation を持たない
    - context / agent / hooks を持たない
    - CLI argv を記載しない
    - provider routing table を複製しない
    - fallback policyを所有しない
    - schema bodyを複製しない
    - references/ のruntime Readに依存しない
    

    検証は既存test suiteへの十数ケースの追加と、1回のloader smokeで十分です。#1745への依存は削除します。

    推奨クローズコメント

    ## Closing as `not planned` / superseded
    
    本Issueが持っていた有用な要件のうち、research SubAgentをthin binding化し、
    delegation契約のdriftを決定論的に検査する要件は #1886 へ統合する。
    
    新しい Gemini 固有の knowledge-only Skill は追加しない。
    
    理由:
    
    - current architecture SSOTでは、Skillは作業手順を所有し、
      共有概念だけの独立Skillは既定の構成ではない
    - preloadはSkill全文を起動時に注入するため、
      現契約ではcontext削減を証明できない
    - #1745の共有validator/smoke成果物をcurrent mainから利用できず、
      単一SKILL.md preloadにはreference read permissionも不要
    - 現AC/VCはfrontmatter・preload成功・negative caseを検証していない
    - provider方針はAGY primary / Gemini fallbackへ移行しており、
      Gemini固有の新しい契約名は陳腐化する
    - #1886と#1909が同じAgent startup contractを変更するため、
      別PRとして並行実装するとsemantic split-brainを招く
    
    Superseded by: #1886
    
    #1909を維持する場合は、同Issueの入力契約確定後のmainを
    #1886のbaselineとして使用する。

    最終判断は、#1736単独のrewriteではなく、not planned クローズです。 preload機構を追加しても現在の問題であるAGY primary routing、Codex parity、request validation、実SubAgent dispatchのいずれも解決しません。これらを所有する #1886 に集中させる方が、現行リポジトリのminimal harness方針と一致します。

  7. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 変更記録

  8. squne121 commented on Aug 1, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: superseded_by_decision

    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations: []
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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions