Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1265"
goal_ref: "Gemini CLI → Antigravity CLI (agy) provider migration: 機能同等性評価と改善計画"
change_kind: codeParent Issue
Parent Goal Ref
- Goal: AGY provider を Gemini delegation platform と安全境界を保ちながら機能同等に近づける。
- Desired Destination: AGY fan-out 実行時の WebSearch 成功判定を model-attested stdout 自己申告ではなく runtime provenance(PreToolUse hook / transcript)で証明可能にする。
Current Validated Scope
.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.pyの AGY WebSearch/grounding 成功判定ロジック(_run_agy()周辺の marker/JSON stdout parser、grounding_backend/web_tool_call_count算出部)。- 同 skill 配下の新規 provenance 検証モジュールと、それを検証する pytest(新規テストファイル)。
- 同 skill 配下の provider contract 文書(
.claude/skills/gemini-cli-headless-delegation/references/)への、新schema・schema governance の追記。
Remaining Parent Gaps
- fan-out process lifecycle telemetry(PID/PGID/monotonic timestamp による process overlap 検証、調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 レビューの Blocker 2 相当)は別 Issue とする。
- AGY profile 別 permission policy(
no_tools/local_asset_research/grounded_researchの runtime tool deny 強制、Blocker 4 相当)は別 Issue とする。 - task-linked Serena evidence(objective-derived selector と request/evidence/prompt/result hash binding、Blocker 3 相当)は別 Issue とする。
-
e2e-evidence-manifest.json/e2e-verdict.jsonを含む E2E validator 全体(Blocker 5 相当)は別 Issue とする。 - prompt truncation / fabrication 検査(Major 1 相当、sentinel + persistent transcript 照合による truncation 検出)は本 Issue の In Scope に含めない。詳細は
## Notes for Reviewer(レビュアー向け補足)を参照。 - 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 の Blocker 2/3/4/5 と Major 1/2/3 の残りは、本 Issue のhermetic tests 完了後に 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 側で改めて実装 Issue 分割を検討する。
Outcome
AGY fan-out 実行時の WebSearch 成功判定の正本が、AGY stdout 自己申告(モデルが出力する tool_calls JSON や AGY_WEBSEARCH: 等の marker line)から、runtime PreToolUse hook / transcript provenance(toolCall.name、stepIdx、conversationId、transcriptPath 由来のイベント)へ移行し、stdout 自己申告だけでは成功判定できないこと・hook event 欠落時や conversation/run 不一致時に FAIL することが hermetic pytest で機械検証されている状態。
In Scope
- installed AGY version と公式 hook documentation(
antigravity.google/docs/hooks)を readback し、現行 hook event schema とPreToolUseが提供する web 系 tool 名(少なくともsearch_web,read_url_content)を確認・記録する。 search_web/read_url_content以外の unknown tool 名・未確認 alias(旧実装が誤認識していたweb_search/websearch/browser_navigate/browser/url_read/read_url/fetch_url/fetchを含む)は許可済み canonical name として扱わず、fail-closed(unknown_tool_provenance相当の明示 FAIL)にする。- AGY stdout 中の
tool_calls/ URL / marker JSON(AGY_GROUNDED_RESEARCH:/AGY_WEBSEARCH:/grounded_research:/grounding:等の既存 marker)は補助情報(stdout_self_report相当の non-authoritative フィールド)に降格し、grounding_backend/web_tool_call_countの算出に単独では使用しない。 - stdout の
tool_calls/marker JSON だけが存在し hook event が存在しない場合に成功判定できないことを検証する pytest を追加する。 - AGY 実行ごとの isolated temporary workspace(
_run_agy()が生成する一時 cwd)へ、workspace-scoped.agents/hooks.json(または現行 AGY hook 設定ファイル名に合わせたファイル)を動的生成する仕組みを追加する。ユーザーの global Antigravity settings/hooks ファイルは変更しない。 - hook event スキーマ
agy_tool_provenance_v1を新設する。少なくとも次のフィールドを持つ:schema,version,event,toolCall.name,toolCall.args_sha256(raw args ではなく canonicalized args の sha256),stepIdx,conversationId,transcript_path_ref(transcriptPathの public-safe identifier またはhash。raw absolute path は含めない),transcript_sha256,parent_run_id,subtask_id,attempt_id,provider,tool_profile,monotonic_ns,utc。 - raw credential、raw transcript 全文、
HOME絶対パス、repo 絶対パスをagy_tool_provenance_v1イベントおよびそれを含む public artifact へ出力しない redaction ロジックを追加する。 - hook event と fan-out child result が同一 conversation/run に属することを検証するロジック(
conversation_id/parent_run_id/attempt_id/transcript_sha256の一致検証)を追加する。wrongconversationId/ wrongparent_run_id/ wrongattempt_id/ transcript hash mismatch のそれぞれで FAIL となることを pytest で検証する。 - モデルが偽の
tool_callsJSON を stdout へ出力しても、対応するagy_tool_provenance_v1hook event が存在しなければ WebSearch 成功と判定されないことを検証する adversarial pytest を追加する。 - hook 生成失敗(workspace への書込失敗)・hook event の JSON parse 失敗は、既存 marker 判定へフォールバックせず fail-closed(FAIL または明示的な not_tested 相当の non-success 状態)にする。
- hermetic unit/integration tests(fixture 済み hook event、モック AGY 実行)を CI で実行可能な状態にする。live AGY 実行を伴う test は本 Issue に含めず、fixture 結果を「live 成功」と呼ばない旨をテストの docstring / 契約文書に明記する。
- 新設する
agy_tool_provenance_v1schema について、schema governance 手順(consumer inventory、compatibility decision、closed-schema tests)を Acceptance Criteria に含める。
Out of Scope
- fan-out process lifecycle telemetry(PID/PGID/monotonic timestamp による process overlap 検証、Blocker 2 相当)。
- AGY profile 別 permission policy(
no_tools/local_asset_research/grounded_researchの runtime tool deny 強制、Blocker 4 相当)。 - task-linked Serena evidence(objective-derived selector、request/evidence/prompt/result hash binding、Blocker 3 相当)。
e2e-evidence-manifest.json/e2e-verdict.jsonを含む E2E validator 全体(Blocker 5 相当)。- prompt truncation / fabrication 検査(Major 1 相当。sentinel + persistent transcript 照合による truncation 検出)。
- live AGY 実行そのもの(本 Issue は hermetic unit/integration tests までとし、live 検証は 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 側の最終 E2E run で実施する)。
- Serena MCP・fan-out orchestrator の concurrency gate・prompt truncation・profile permission の実装変更。
Acceptance Criteria
- AC1:
.claude/skills/gemini-cli-headless-delegation/references/配下の文書に、readback 済みの installed AGY version と公式PreToolUsehook schema(toolCall.name/toolCall.args/stepIdx/conversationId/transcriptPath)、および canonical web tool 名(search_web,read_url_content)が記録されている。 - AC2:
search_web/read_url_content以外の tool 名(旧実装が認識していたweb_search/websearch/browser_navigate/browser/url_read/read_url/fetch_url/fetchを含む)を持つ hook event を与えた場合に、provenance 判定ロジックが FAIL(成功扱いにしない)ことを pytest で検証できる。 - AC3: stdout に
tool_calls/marker JSON(AGY_WEBSEARCH:等)だけが存在し、対応するagy_tool_provenance_v1hook event が存在しないケースで、WebSearch 成功と判定されない(grounding_backendがagy_native_websearchにならない)ことを pytest で検証できる。 - AC4:
agy_tool_provenance_v1schema のバリデータがschema/version/event/toolCall.name/toolCall.args_sha256/stepIdx/conversationId/transcript_path_ref/transcript_sha256/parent_run_id/subtask_id/attempt_id/provider/tool_profile/monotonic_ns/utcの必須フィールド欠落を fail-closed で拒否することを pytest で検証できる。 - AC5: AGY 実行ごとの isolated temporary workspace に workspace-scoped hook 設定ファイルが動的生成され、既存の global Antigravity settings/hooks ファイル(fixture でシミュレートした global config)が変更されないことを pytest で検証できる。
- AC6:
agy_tool_provenance_v1イベントを含む生成物に raw credential・raw transcript 全文・HOME絶対パス・repo 絶対パスが含まれないことを redaction テストで検証できる。 - AC7: hook event と fan-out child result の
conversation_id不一致、parent_run_id不一致、attempt_id不一致、transcript_sha256不一致のそれぞれについて、個別の pytest ケースで FAIL になることを検証できる。 - AC8: モデルが偽の
tool_callsJSON(citation 付き)を stdout に出力しても、対応する hook event が存在しない場合に成功判定されない adversarial pytest ケースが存在する。 - AC9: hook 生成失敗(書込不可ディレクトリ等)・hook event JSON parse 失敗のそれぞれについて、既存 marker ベース判定へフォールバックせず fail-closed になることを pytest で検証できる。
- AC10: 新規テストが全て hermetic(fixture 済み hook event・モック AGY 実行のみ)であり、live AGY バイナリ起動を必要としないことをテストファイルの構成(
subprocessの呼び出し先が fixture/mock であること)で確認できる。 - AC11:
agy_tool_provenance_v1の schema governance セクション(consumer inventory、compatibility decision、closed-schema tests への参照)が provider contract 文書に追加されている。 - AC12: 既存の
test_run_gemini_headless.py/test_agy_provider.pyの既存テストが破壊されていない(regression なし)。
Verification Commands
新規テストファイルは未作成のため、実装前 baseline では pytest 実行は collection error(exit4)を返す想定。実装後に各 AC を検証する。
# AC1
$ rg -n "agy_tool_provenance_v1" .claude/skills/gemini-cli-headless-delegation/references/
$ uv run --locked python3 .claude/skills/gemini-cli-headless-delegation/scripts/setup_check.py --version
# AC2
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_unknown_tool_name_fails_closed -v
# AC3
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_stdout_self_report_alone_is_not_success -v
# AC4
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_schema_governance.py -k test_required_field_missing_is_rejected -v
# AC5
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_workspace_scoped_hook_does_not_mutate_global_settings -v
# AC6
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_redaction_removes_credential_transcript_home_repo_path -v
# AC7
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_conversation_run_mismatch_fails -v
# AC8
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_fabricated_tool_calls_json_without_hook_event_fails -v
# AC9
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -k test_hook_generation_or_parse_failure_fails_closed -v
# AC10
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py -v
# AC11
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_schema_governance.py -k test_schema_governance_section_present -v
# AC12
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_run_gemini_headless.py -v
$ uv run --locked python3 -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provider.py -vAllowed Paths
.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py.claude/skills/gemini-cli-headless-delegation/scripts/agy_tool_provenance.py(新規: provenance schema バリデータ・hook 動的生成・conversation/run 一致検証ロジック).claude/skills/gemini-cli-headless-delegation/tests/test_agy_tool_provenance.py(新規).claude/skills/gemini-cli-headless-delegation/tests/test_agy_provenance_schema_governance.py(新規).claude/skills/gemini-cli-headless-delegation/tests/fixtures/(新規 fixture: hook event JSON、モック transcript).claude/skills/gemini-cli-headless-delegation/references/usage-contract.md.claude/skills/gemini-cli-headless-delegation/references/provider-mapping.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- installed AGY version が公式 hook documentation の前提(
PreToolUseがtoolCall.name/stepIdx/conversationId/transcriptPathを提供する)と一致しないことが AC1 の readback で判明した場合
Required Skills
- Python 実装力(pytest によるテスト設計、hashlib によるハッシュ検証、json schema validation の実装経験)
- Antigravity CLI の hook/transcript 仕様理解(
.claude/skills/gemini-cli-headless-delegation/references/runtime-portability.mdを参照) - Gemini/AGY delegation provider contract の理解(
.claude/skills/gemini-cli-headless-delegation/references/usage-contract.mdを参照)
Required Design References
.claude/skills/gemini-cli-headless-delegation/references/usage-contract.md.claude/skills/gemini-cli-headless-delegation/references/provider-mapping.md.claude/skills/gemini-cli-headless-delegation/references/runtime-portability.mddocs/dev/agent-skill-boundaries.md
Scope Delta(任意)
N/A
Runtime Verification Applicability
- decision: deferred
- reason: 本 Issue は hermetic unit/integration tests(fixture 済み hook event、モック AGY 実行)までを Outcome とする。実 AGY バイナリを起動する live 検証は環境依存(AGY installed version, 認証, WebSearch availability)であり、単独 Issue での意味のある動作検証設計が困難。
- deferred_destination:
- destination_type: issue
- destination_ref: "調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494"
- deferred_verification_condition: 本 Issue の hermetic tests が全て green になり、
agy_tool_provenance_v1を用いた workspace-scoped hook 生成・provenance 検証ロジックが merge された後、調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 の最終 live E2E run で実 AGY プロセスに対してsearch_web/read_url_contentの実 hook event が採取され、fixture ではなく実行環境由来のconversation_id/transcript_sha256一致が確認できた時点で成立する。
Delivery Rule(配信ルール)
1 Issue = 1 PR を適用する。本 Issue は WebSearch provenance の正本化(Blocker 1 相当)のみを扱い、Blocker 2/3/4/5・Major 1/2/3 は別 PR・別 Issue とする。
この Issue のクローズ条件: Closes #<issue_number_placeholder>
Scope Collision 確認
#1638(調査: fan-out orchestrator...の実装子 Issue、local_asset_researchの Serena targeted-evidence 契約)と Allowed Paths・Outcome ともに重複しない。実装: AGY local_asset_research の targeted source evidence を fail-close で返す #1638 は Serena wrapper-side retrieval の evidence envelope(path/selector/line range/sha256)を扱い、本 Issue は AGY 自身のPreToolUsehook provenance(WebSearch tool call の実行証明)を扱う。両者は.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.pyを共通で触るが、変更対象関数・行範囲が異なる(_run_agy()の WebSearch marker parser 部 vs.local_asset_researchの evidence envelope 生成部)ため、並行実装時はマージ順序の確認が必要(同一 Allowed Paths への複数 Issue 集約ガイドライン参照)。delegation_audit_v1schema を扱う既存実装(test_delegation_audit_schema.py等)との衝突は確認できなかった(gh issue list --search "delegation_audit_v1" --state openは 導入: Gemini CLI → Antigravity CLI (agy) provider migration: 機能同等性評価と改善計画 #1265 のみヒットし、本 Issue と scope が異なる)。本 Issue が新設するagy_tool_provenance_v1は既存delegation_audit_v1とは別 schema であり、両者の関係(agy_tool_provenance_v1イベントをdelegation_audit_v1にどう取り込むか)は AC11 の schema governance セクションで明示する。gh issue list --search "agy_tool_provenance"/"WebSearch provenance"/"PreToolUse hook AGY"はいずれも本 Issue と同一スコープの既存 OPEN Issue を返さなかった(2026-07-25 時点で確認済み)。#1705(AGY profile 別 isolated permission policy と no-tools negative evidence、Blocker 4 相当)・#1706(fan-out local_asset_research の Serena evidence への task-linked hash chain、Blocker 3 相当)は、調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 レビューが提案した 4 分割のうち本 Issue とは別枠(それぞれ profile 別 tool deny と Serena evidence hash chain)として既に起票済みであり、本 Issue(Blocker 1: WebSearch provenance)と Allowed Paths・Outcome の重複はない。3 Issue とも.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.pyを共通で編集しうるため、実装着手前に他 2 Issue の進捗(merge 状態、PR の diff)を read-back し、必要なら Scope Delta で衝突を再確認する。
Notes for Reviewer(レビュアー向け補足)
- 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 のレビューコメント(調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 (comment) )は Blocker 1(WebSearch 証跡の自己申告問題)と Major 1(prompt truncation/fabrication 検査)の両方の解消を求めているが、本 Issue は起票依頼の In Scope 指定に従い Blocker 1 のみを扱う。Major 1 は独立した Outcome(prompt 全文の sentinel + persistent transcript 照合によるtruncation検出)であり、
1 Issue = 1 PR原則と AC 独立性基準に基づき本 Issue には含めない。Major 1 の実装が別途必要かどうかは、本 Issue マージ後に 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 側で改めて判断・起票する。 - Blocker 2(process lifecycle telemetry)/ Blocker 3(task-linked Serena evidence)/ Blocker 4(profile 別 permission policy)/ Blocker 5(E2E validator)は、レビューコメント末尾の「起票すべき implementation Issues」一覧が示す 4 分割のうち、本 Issue が「AGY hook/transcript provenance adapter」に対応する。残り 3 件(child process lifecycle telemetry、AGY profile別 permission isolation、task-linked Serena retrieval)は本 Issue の Remaining Parent Gaps に列挙した通り別 Issue とする。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
実装: AGY/Serena/WebSearch fan-out E2E artifact validatorとenvironment m…
実装: agy headless print modeでgrounded_researchのsearch_web/read_url_con…