Skip to content

test(gemini-delegation): AGY 実 subprocess failure を検証する - #1910

Merged
squne121 merged 6 commits into
mainfrom
worktree-issue-1885-agy-real-subprocess
Aug 1, 2026
Merged

squne121 merged 6 commits into
mainfrom
worktree-issue-1885-agy-real-subprocess

Conversation

@squne121

@squne121 squne121 commented Aug 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • 実行可能な AGY_BIN フェイクを用い、成功 stdout sentinel が real subprocess → _run_agy() → _normalize_agy_result() → run_delegation() → response_text に届くことを検証します。
  • empty stdout は CI/non-CI の両方を、timeout と non-zero は実 subprocess で検証します。
  • 全フェイクは argc と argv を厳密に検査し、trailing argv を拒否します。production code は変更しません。

Checks

  • 検証済み: uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py -q — 5 passed(Issue 実装: Antigravity CLI one-shot delegation の出力取得を安定化する #1885 の AC1〜AC5 VC)
  • 検証済み: uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provider.py -q — 61 passed
  • 検証済み: uv run --locked pytest .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_timeout_classification.py -q — 5 passed
  • 検証済み: uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests -q -n auto — 1178 passed
  • 検証済み: uv run --locked ruff check .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py

Schema Change Applicability

  • decision: not_schema_change
  • 判定補足: production code と delegation_result/v1 のキー、型、producer-consumer 境界は変更しません。
  • reason: 既存 AGY 実行経路を hermetic real subprocess test で回帰検証する変更のみです。

Schema Consumer Inventory

変更対象 schema: N/A(schema 変更なし)

before/after 差分: N/A(schema 変更なし)

Consumer 列挙(rg コマンド例と結果): N/A(schema 変更なし)

Consumer 更新状況: N/A(schema 変更なし)

Compatibility Decision(互換性判断)

  • change_type: N/A(schema の変更はありません)
  • compatibility: N/A(互換性に影響しません)
  • migration_required: N/A(移行は不要です)
  • migration_or_followup: 実 AGY invocation の argv allowlist/permission-hook E2E は #1814、structured JSON output migration は #277、slash-command literal/expansion policy は #1918。
  • reason: 本 PR は既存 wrapper の実 subprocess 境界テストのみで、実配布物の argv/permission E2E、JSON 移行、slash-command 方針は所有しません。

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
hermetic fake の成功 stdout が caller の response_text へ届く yes structured JSON output migration AC1 と test file 5 passed #277
empty stdout の CI/non-CI 分類、timeout、non-zero の stdout/stderr/exit code/argv 境界 yes 実 AGY invocation の argv allowlist/permission-hook E2E AC2〜AC4 と skill suite 1178 passed #1814
structured JSON output migration no 本 PR の対象外 fake executable の wrapper boundary test のみ #277
slash-command literal/expansion policy no 本 PR の対象外 fake executable の wrapper boundary test のみ #1918

受け入れ条件の達成状況

  • AC1: 成功 fake の stdout sentinel が実 OS subprocess から _run_agy()、_normalize_agy_result()、run_delegation() を経て response_text と inline_response_text surface に届くことを確認しました。
  • AC2: exit 0 + empty stdout の fake を実行し、non-CI の agy_empty_stdout と CI の agy_output_missing を確認しました。
  • AC3: exec sleep 30 の fake が実 subprocess timeout となり agy_timeout に分類されることを確認しました。
  • AC4: 全 fake が argc=2 と exact argv を検査し、non-zero fake の agy_exit_nonzero、exit code 23、stderr sentinel を確認しました。
  • AC5: Issue VC、新規 file、既存 provider、timeout-classification 回帰、skill 全体、Ruff を実行しました。

検証コマンド結果

  • Issue VC: test_agy_real_subprocess.py は 5 passed。AC1〜AC5 の指定 node を同一ファイル実行で検証しました。
  • 回帰: provider 61 passed、timeout-classification 5 passed、skill suite 1178 passed、Ruff pass。

Allowed Paths 遵守

  • 変更ファイル: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py
  • 変更ファイル: .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight_timeout_classification.py
  • 上記2パスはいずれも Issue 実装: Antigravity CLI one-shot delegation の出力取得を安定化する #1885 の current Allowed Paths に含まれます。run_gemini_headless.py と既存 mock-based test は変更していません。

Notes

@github-actions

github-actions Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1910 closed).

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST_CHANGES

Findings

  • blocker / current-head CI: required-CI evaluator CI_WAIT_RESULT_V1 returned failed for 7917bb65f0412146ef8bf9a7998bd91a2ed918d3; python-test-core, python-test, and ci-verdict-summary are FAILURE. The CI summary binds the failures to this head.
  • blocker / PR evidence contract: the PR body does not contain the required ## 受け入れ条件の達成状況, ## 検証コマンド結果, or ## Allowed Paths 遵守 sections with per-AC evidence. Summary / Checks do not satisfy the required body shape.
  • pass / scope: the deterministic live-issue Allowed Paths gate is ok: one added file, .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py; source git_diff_name_status_find_renames_z; no rename/copy or violation.
  • pass / independent VC: supplied independent evidence is bound to this head and the live Issue 実装: Antigravity CLI one-shot delegation の出力取得を安定化する #1885 body SHA; AC1--AC4 all PASS with literal command matches and no skipped verification.

Blockers

  • "current-head required CI failed: python-test-core, python-test, ci-verdict-summary"
  • "PR evidence contract missing required AC coverage, verification-results, and Allowed Paths sections"

Non-blockers

verdict: REQUEST_CHANGES
reviewed_head_sha: "7917bb65f0412146ef8bf9a7998bd91a2ed918d3"
blockers:
  - "current-head required CI failed: python-test-core, python-test, ci-verdict-summary"
  - "PR evidence contract missing required AC coverage, verification-results, and Allowed Paths sections"
warnings:
  - "stale_snapshot: advisory only; live Issue #1885 body was evaluated"
  - "local single-test spot check passed; required CI failure remains authoritative"

@squne121
squne121 marked this pull request as ready for review August 1, 2026 05:40
@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE

Evidence

verdict: APPROVE
reviewed_head_sha: "c594503e96f27ac4821120516c61587d8293bf6c"
blockers: []
warnings:
  - "expected_contract_fingerprint_missing は advisory。live Issue #1885 本文で再評価済み"

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

判定

REQUEST_CHANGES です。対象は current head c594503e96f27ac4821120516c61587d8293bf6c。

current head は CI 成功・MERGEABLE/CLEAN で、既存レビューも live Issue の AC1〜AC4を基準に APPROVE しています。ただし、その live Issue の受け入れ条件自体が、元の目的と過去の敵対的レビューを取りこぼしています。この PR を「失敗境界の部分的な回帰テスト」として扱うなら妥当ですが、現状の Closes #1885 は認められません。


Findings

P0 / Blocker — 成功 stdout の実 subprocess round-trip が依然として存在しない

test_agy_real_subprocess.py に追加されたのは次の三件だけです。

  • exit 0+空 stdout
  • timeout
  • non-zero+空 stdout

成功した fake AGY が stdout sentinel を出し、それが実 OS subprocess、_run_agy()、_normalize_agy_result()、run_delegation() を通って最終 response_text に届くテストはありません。

これは単なる追加要望ではありません。Issue #1885 の Outcome 自体が、既存 mock テストでは「成功 stdout が呼び出し元まで届くことを証明しない」と明記しています。しかし、その直後の AC1〜AC4 は失敗経路だけで構成されています。Issue 内部で Outcome と Acceptance Criteria が矛盾しています。

過去の敵対的レビューでも、必要な経路は明確に次のように定義されていました。

fake executable
  → 実 subprocess 起動
  → stdout sentinel
  → CompletedProcess
  → _normalize_agy_result()
  → run_delegation()
  → response_text

既存の成功テストは _run_agy() を CompletedProcess でモックしており、process boundary を通りません。

より直接的には、現在の三件では次の mutation を検出できません。

- capture_output=True
+ capture_output=False

この変更が入っても、論理上は以下のままです。

  • empty stdout test: stdout が取れないため、期待どおり empty 分類
  • timeout test: timeout 自体は発生
  • non-zero test: return code により generic non-zero 分類
  • 既存 success test: _run_agy() をモックしているため、この変更を通らない

つまり、この PR は説明文で「stdout / stderr を取得する実 subprocess 経路」を主張していますが、stdout capture を壊しても新規三件が通り得ます。本体は現在 capture_output=True, text=True, shell=False で起動していますが、その最重要不変条件を新規テストが固定できていません。

必須修正: 成功 stdout の real subprocess test を追加してください。

最低限の assertion は次です。

assert result["ok"] is True
assert result["provider"] == "agy"
assert result["exit_code"] == 0
assert result["response_text"] == "LOOP_AGY_REAL_SUBPROCESS_OK"
assert result["failure_class"] is None
assert result["result_surface"]["primary_artifact_type"] == "inline_response_text"

P1 / Major — non-zero テストが argv 不正を見逃す偽陽性になっている

non-zero fake は、argv が期待と異なる場合には exit 91、正常に引数を受け取った場合には exit 23 します。

test "$1" = "-p" &&
test "$2" = "Return exactly: LOOP_AGY_REAL_SUBPROCESS" ||
exit 91

exit 23

しかしテストは failure_class == "agy_exit_nonzero" しか確認せず、exit_code == 23 を確認していません。したがって、wrapper が誤った argv を渡して fake が 91 で終了しても、同じ generic agy_exit_nonzero になりテストが成功します。

また、Issue Outcome は stdout、stderr、exit code の取得を目的に掲げていますが、三件とも stderr sentinel を出さず、result["stderr"] を一度も検査していません。result["exit_code"] も一度も検査していません。

必須修正:

test "$#" -eq 2 || exit 90
test "$1" = "-p" || exit 91
test "$2" = "Return exactly: LOOP_AGY_REAL_SUBPROCESS" || exit 92
printf '%s\n' 'LOOP_AGY_REAL_SUBPROCESS_STDERR' >&2
exit 23
assert result["failure_class"] == "agy_exit_nonzero"
assert result["exit_code"] == 23
assert result["stderr"] == "LOOP_AGY_REAL_SUBPROCESS_STDERR"

これにより、少なくとも次を区別できます。

  • fake が期待どおり実行されて 23 を返した
  • argv が壊れて fake 自身の検証で 90〜92 を返した
  • stderr capture が壊れた

P1 / Major — Closes #1885 のままでは親 Issue を誤って進捗させる

Issue #1885 の machine-readable contract は、現在も parent_issue: "#1736" です。

しかし #1736 は「Gemini delegation preload-only contract」であり、次を明示的に Out of Scope としています。

  • wrapper taxonomy
  • run_gemini_headless.py の変更
  • fallback launcher / executor
  • provider policy

#1885 の AGY subprocess boundary test は、この preload-only Issue の子としては整合しません。

AGY provider migration、テスト密度、認証・非対話実行などを管理している親は #1265 です。以前の敵対的レビューでも parent_issue: "#1265" への修正が明示的に要求されています。

PR は Closes #1885 と明記しています。したがって、このままマージすると、不完全な #1885 を閉じるだけでなく、無関係な #1736 の roll-up に誤った完了情報を混入させます。

マージ前修正:

parent_issue: "#1265"

少なくとも、#1736 を維持する明示的な owner override と、その理由がない限り変更が必要です。


P2 / Minor — CI 固有の agy_output_missing 分岐は real subprocess 化されていない

empty stdout test は意図的に CI を削除しています。

monkeypatch.delenv("CI", raising=False)

そのため、real subprocess で検証されるのは agy_empty_stdout だけです。CI 環境で使われる agy_output_missing は、依然として _run_agy() をモックした既存テストだけに依存しています。

PR #1345 で mock ベースの CI/non-CI 両分岐は既に追加されていますが、今回の Issue が目的とする「mock を越えた OS process boundary coverage」は CI 分岐に届いていません。

次のように parameterize するのが最小です。

@pytest.mark.parametrize(
    ("ci_value", "expected_failure_class"),
    [
        (None, "agy_empty_stdout"),
        ("1", "agy_output_missing"),
    ],
)
def test_agy_real_subprocess_empty_stdout_classified(
    tmp_path,
    monkeypatch,
    ci_value,
    expected_failure_class,
):
    if ci_value is None:
        monkeypatch.delenv("CI", raising=False)
    else:
        monkeypatch.setenv("CI", ci_value)

    ...
    assert result["exit_code"] == 0
    assert result["failure_class"] == expected_failure_class

P2 / Scope claim — fake AGY testと実 AGY 1.1.9 の動作保証を混同してはならない

公式 Antigravity CLI では、1.1.1 の時点で次の二件が修正されています。

  • server-side failure が exit 0+空 stdout になる問題
  • shell script/subprocess 内の agy -p が stdin を読み続けて hang する問題

したがって、この PR の empty/timeout test は、現行 distribution bug の再現テストではなく、wrapper 側の defense-in-depth として位置づけるべきです。([GitHub]1)

その後、1.1.8 では --output-format text|json|stream-json と --json-schema が追加され、1.1.9 では print mode で slash command/skill expansion が導入されました。literal prompt が必要な場合は --disable-slash-commands が必要です。1.1.9 の headless one-shot は MCP startup 完了を待つ仕様でもあります。([GitHub]2)

一方、現行 wrapper の argv allowlist は基本的に次だけです。

agy -p <prompt>
agy -p <prompt> --model <approved-model>

--output-format や --disable-slash-commands の追加は現在の allowlist では拒否されるため、#1910 に混ぜるべきではありません。

この version gate・実 AGY live E2E は #1814 が明示的に所有しています。

したがって PR 本文の次の記載は不正確です。

migration_or_followup: N/A(後続作業は不要)

少なくとも以下を Not controlled / Follow-up に記載すべきです。

- real Antigravity CLI distribution behavior
- AGY semver/version gate: #1814
- structured JSON output migration: #1814 または別 Issue
- slash-command literal/expansion policy: 別 Issue

P3 / Documentation — PR 本文が current diff と自己矛盾している

PR 本文には「追加テストの対象外ファイルに変更はありません」とありますが、current diff は次の二ファイルです。

  1. test_agy_real_subprocess.py
  2. test_baseline_vc_preflight_timeout_classification.py

したがって前者の記述は current head と一致しません。

ただし、二つ目の変更内容自体は妥当です。#1893 の regression fixture が「将来存在する test node」を missing-file fixture に使っていたため、今回の test 追加と衝突しました。新しい未作成 node ID へ置き換える変更は、timeout 文字列を含む高速な pytest missing-file failure という元の回帰目的を維持しています。

修正すべきなのはコードではなく、PR 本文の説明です。


評価できる点

三件の失敗テストは、対象を「wrapper failure boundary」に限定すれば実装方法は概ね適切です。

  • _run_agy() と subprocess.run() を mock していない
  • AGY_BIN で temporary executable を差し込んでいる
  • timeout fake は exec sleep 30 のため、余分な shell child を残しにくい
  • shell=False の実 argv 経路を通っている
  • generic non-zero が empty stdout より優先されることを確認している
  • WSL2 Ubuntu を主要サポート環境とするリポジトリ方針には #!/bin/sh ベースの fixture が合っている

Python の仕様上も、capture_output=True は stdout/stderr を PIPE にし、subprocess.run() の timeout は child を kill・wait した後に TimeoutExpired を再送出します。現在の timeout test の構造は、この Python boundary を確認する用途としては正しいです。([Python documentation]3)


推奨する最小修正セット

  1. test_agy_real_subprocess_success_stdout_round_trip を追加し、stdout sentinel が最終 response_text へ届くことを確認する。
  2. non-zero fake に stderr sentinel を出させ、exit_code == 23 と stderr の完全一致を assert する。
  3. fake 全件で "$#" を確認し、余分な trailing argv を拒否する。
  4. empty stdout test を CI/non-CI の二分岐に parameterize する。
  5. Issue 実装: Antigravity CLI one-shot delegation の出力取得を安定化する #1885 の親を 導入: Gemini CLI → Antigravity CLI (agy) provider migration: 機能同等性評価と改善計画 #1265 へ再束縛する。
  6. PR 本文の Closes #1885、後続作業は不要、変更ファイル説明、Safety Claim Matrix を実態に合わせて更新する。
  7. version gate、JSON output、slash-command policy、実 AGY live E2E は 実装: AGY permission/hook boundary の hermetic evidence を整備する #1814 側へ残し、test(gemini-delegation): AGY 実 subprocess failure を検証する #1910 では実装しない。

この修正後であれば、production code を変更せず、テストファイル中心の小さい PR のまま #1885 の「実 OS subprocess boundary coverage」を直接証明できます。

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

独立検証証跡(TEST_VERDICT_MACHINE/v2 / current-head)

AC 判定

AC status 根拠
AC1 PASS success sentinel の real subprocess round-trip
AC2 PASS CI/non-CI empty stdout 分類
AC3 PASS timeout 分類
AC4 PASS exact argv/argc、exit 23、stderr sentinel
AC5 PASS 上記コマンド全件 PASS

Producer / artifact binding

TEST_VERDICT_MACHINE/v2 の protected producer receipt は利用できませんでした。current head 42ca6c763689ee4faf5fe3b152f6a2dbb14f554e に紐づく Actions artifacts(run 30687728252)を確認しましたが、TEST_VERDICT_MACHINE/v2 execution record / producer receipt artifact が存在せず、canonical materializer の live readback を成立させる入力がありません(generic self-report は生成していません)。上記はローカル独立 VC の結果であり、protected producer の代替ではありません。

TEST_VERDICT_MACHINE:
  schema: TEST_VERDICT_MACHINE/v2
  producer: unavailable
  reviewed_head_sha: "42ca6c763689ee4faf5fe3b152f6a2dbb14f554e"
  linked_issue_body_sha256: "sha256:963632cce2fe5b55a7ca18a710234de5eaa977d8ad7242f1da86d67ffcaf1779"
  command: "uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py -q"
  exit_code: 0
  status: pass
  per_ac:
    AC1: pass
    AC2: pass
    AC3: pass
    AC4: pass
    AC5: pass
  artifact_binding: unavailable
  artifact_unavailable_reason: "No TEST_VERDICT_MACHINE/v2 execution-record/producer-receipt artifact for current head; canonical protected producer live readback cannot be performed."

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

authoritative independent Issue VC(current-head bound)

  • evidence_schema: INDEPENDENT_ISSUE_VC_V1
  • issue: #1885
  • pr: #1910
  • head_sha: 42ca6c763689ee4faf5fe3b152f6a2dbb14f554e
  • linked_issue_body_sha256: sha256:963632cce2fe5b55a7ca18a710234de5eaa977d8ad7242f1da86d67ffcaf1779
  • literal_command: uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py -q
  • literal_command_sha256: sha256:7f08dfeace35405ecb0c4462cd2852ae0df151a40fd62abd479d376f9e0884f9
  • exit_code: 0
  • result: 5 passed in 1.11s
  • verification_skipped_count: 0
  • fallback_detected: false

Per-AC

AC status command exit_code skipped fallback
AC1 PASS exact command above 0 0 false
AC2 PASS exact command above 0 0 false
AC3 PASS exact command above 0 0 false
AC4 PASS exact command above 0 0 false
AC5 PASS exact command above 0 0 false

CI_CHECK_RUN_SCOPED corroboration

Current-head required checks are completed successfully and bound to the same head_sha:

  • python-test-core, check_run_id 91336754614
  • python-test, check_run_id 91337071601
  • ci-verdict-summary, check_run_id 91337083319
independent_issue_vc:
  schema: INDEPENDENT_ISSUE_VC_V1
  issue: 1885
  pr: 1910
  head_sha: "42ca6c763689ee4faf5fe3b152f6a2dbb14f554e"
  linked_issue_body_sha256: "sha256:963632cce2fe5b55a7ca18a710234de5eaa977d8ad7242f1da86d67ffcaf1779"
  literal_command: "uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py -q"
  literal_command_sha256: "sha256:7f08dfeace35405ecb0c4462cd2852ae0df151a40fd62abd479d376f9e0884f9"
  exit_code: 0
  result: "5 passed in 1.11s"
  verification_skipped_count: 0
  fallback_detected: false
  per_ac: {AC1: PASS, AC2: PASS, AC3: PASS, AC4: PASS, AC5: PASS}
current_head_required_ci:
  schema: CI_CHECK_RUN_SCOPED
  expected_head_sha: "42ca6c763689ee4faf5fe3b152f6a2dbb14f554e"
  checks:
    - {name: python-test-core, check_run_id: 91336754614, conclusion: success, head_sha_match: true}
    - {name: python-test, check_run_id: 91337071601, conclusion: success, head_sha_match: true}
    - {name: ci-verdict-summary, check_run_id: 91337083319, conclusion: success, head_sha_match: true}

@squne121

squne121 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

impl-review-loop 最終判定

OWNER 指摘(P0–P3)に対する修正を current head で再確認しました。

verdict: APPROVE
reviewed_head_sha: "42ca6c763689ee4faf5fe3b152f6a2dbb14f554e"
blockers: []
warnings:
  - "expected_contract_fingerprint_missing は advisory。live Issue、current-head CI、独立 VC 証跡で再評価済み"

@squne121
squne121 merged commit 487f80f into main Aug 1, 2026
29 checks passed
@squne121
squne121 deleted the worktree-issue-1885-agy-real-subprocess branch August 1, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: Antigravity CLI one-shot delegation の出力取得を安定化する

1 participant