Repository navigation
feat(agy): add capability gate for AGY headless capabilities - #1982
Conversation
`preflight_agy.py` becomes the single implementation SSOT for AGY capability detection. Adds a version parser (parse_agy_version_string), a fixed-argv parser-acceptance classifier for `--disable-slash-commands`, a runtime probe for leading-slash literal treatment, binary identity fingerprinting + drift detection, an in-process-only memoization cache, and a single finalizer that always persists a sanitized JSON artifact under `.claude/tmp/`. The capability matrix decomposes headless_permission_policy / hooks / disable_slash_commands into predicate-level supported / unsupported / unavailable / inconclusive / evidence_invalid results — evidence-source prioritized runtime_semantic_observation > parser_acceptance > changelog > help > version, so help/version alone never confirm `supported`. `pre_invocation_injected_tool_call` is pinned `unsupported` while upstream google-antigravity/antigravity-cli#728 is open. Predicates whose live enforcement verification is Issue #1979's responsibility are classified `inconclusive`, never fabricated as `supported`. Also fixes the existing early cli_incompatible exit on missing --help flags so it defers to the runtime smoke check (help absence is supporting evidence only, per PR #1976 design) — this was explicitly the bug #1941 asked to fix, and the pre-existing test asserting the old behavior is updated accordingly. `--require-capability` adds an additive 0/1/77 exit-code mode without touching the default invocation's existing ok-boolean exit 0/1. setup_check.py surfaces the additive `agy_capabilities` field without adding its own version/help parser or changing its existing single-boolean ok derivation. docs/dev/schema-governance.md records the additive `agy_capability_matrix/v1` extension to `agy_preflight_result/v1` (no v2 bump). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1982 closed). |
PR Review (iteration 0)Verdict: REQUEST_CHANGES 要約実装( 一方で、PR 本文に必須セクションが不足しているため REQUEST_CHANGES とします。 Blockers
Warnings
verdict: REQUEST_CHANGES
reviewed_head_sha: "d6ad9cfc2fa225efcd48c6aba4b7894b127a7bdf"
blockers:
- "PR body missing required section '## 受け入れ条件の達成状況' (per-AC [x]/[ ] + evidence for AC1-AC9)"
- "PR body missing required section '## Allowed Paths 遵守'"
- "PR body missing 'Schema Change Applicability' / 'Schema Consumer Inventory' section (schema_change: additive agy_capability_matrix/v1 field on agy_preflight_result/v1)"
- "PR body missing 'Safety Claim Matrix' section (safety-sensitive: .claude/skills/** diff introducing headless_permission_policy/hooks capability predicates and auth-signal classification)"
warnings:
- "Borderline Clean-Room Review (SKILL.md 4.7) applicability: control-plane should confirm dual-reviewer requirement"
- "allowed_paths_review_gate.py advisory warnings only: contract_source_kind/source_id_missing, expected_contract_fingerprint_missing" |
PR Review (iteration 1, re-review)Verdict: APPROVE 要約iteration 0 以降、実装本体の diff に変更はありません(base 独立再検証結果:
Blocker なし。 verdict: APPROVE
reviewed_head_sha: "d6ad9cfc2fa225efcd48c6aba4b7894b127a7bdf"
blockers: []
warnings: [] |
判定: REQUEST_CHANGESPR #1982 は draft・head P1-1. AC6の「同一バイナリ束縛」が実装されていない
PATH、shim、symlink、auto-updater が probe 間で変われば、Aを実行しながらBのhashを記録する、あるいはversionだけAでruntimeはBという状態が成立します。これは #1941 AC6の明示契約違反です。 さらに、PR #1976 では同じ欠陥に対し「開始時に一度だけresolveした絶対パスをversion captureとruntime invocationへ共有する」修正を既に採用しています。#1982はその設計を参照すると説明しながら、核心部分を再実装していません。 必要な修正: P1-2.
|
) OWNER REQUEST_CHANGES on PR #1982 found the previous automated APPROVE inadequate: binary-identity binding was not actually applied to executed probes, the leading_slash_is_literal runtime probe tested the wrong argv and misclassified combined evidence, the same probe leaked the real HOME/XDG_* environment and had no cost gate, sanitization missed version_evidence.raw/agy.version and the in-memory return value, parser- rejection classification was too broad, setup_check.py never actually requested the capability matrix on the real invocation path, and memoization could bypass binary-identity drift detection. - preflight_agy.py: resolve the agy binary exactly once via os.path.realpath(shutil.which()) and bind every version/help/smoke/ capability probe to that single path; rewrite the leading-slash-literal probe to use the exact production argv with an isolated HOME/XDG_* env and a cost-confirmation gate (skips by default, exit taxonomy unaffected); route every external-facing output (return value, --json, --output-file, artifact) through the same sanitizer, including version_evidence.raw and a normalized agy.version + redacted sample; narrow classify_parser_acceptance() to require the specific --disable-slash-commands flag name and prioritize auth evidence; bind the capability memoization cache key to both pre-run and pre-runtime-probe binary identity plus an expanded config digest (.agents/hooks.json + global hooks path); populate a full-shaped capability matrix with per-predicate reasons on controlled early exits; and anchor version parsing to an explicit `agy` context line when multiple version-shaped tokens are present. - setup_check.py: check_agy_preflight() now requests compute_capabilities=True so the real invocation path actually populates the capability matrix. - Adds unit/integration tests for every P1/P2 finding, including a real subprocess round-trip against a swappable fake binary proving binary-identity drift is caught. - docs/dev/schema-governance.md: documents the agy.version / version_evidence.raw sanitization semantics change. All 9 original Issue #1941 AC verification commands, the full gemini-cli-headless-delegation test suite (1278 tests), and the repo-wide pytest suite (7633 passed) are green. Co-Authored-By: Claude Sonnet 5 <[email protected]>
PR Review (iteration 2, OWNER fix_delta 後の再レビュー)Verdict: REQUEST_CHANGES 要約OWNER が投稿した REQUEST_CHANGES(P1 7件・P2 2件)を fix_delta として実装を修正し、この head で pr-reviewer が独立に fresh-eyes 再検証しました(worker/test-runner の自己申告は信用せず、独立 worktree で実ソース・実テストを直接確認)。 P1-1〜P1-7・P2-1・P2-2 の全9件について、ソースレベルで実修正を確認しました:
独立 worktree での fresh 実行: BlockerPR 本文が iteration 1 時点(head 必要な修正: PR 本文を iteration 2(head verdict: REQUEST_CHANGES
reviewed_head_sha: "329da0736840c660f2ee395df6d940f270ce80cc"
blockers:
- "PR body is stale: still describes iteration 1 and claims no implementation files changed, which is false at head 329da073 (2281 lines across 6 files implementing the OWNER's 9-item fix_delta). AC evidence citations reference the superseded head d6ad9cfc. Update PR body to describe iteration 2, summarize resolution of all 9 P1/P2 items, and re-cite VC evidence against head 329da073."
warnings:
- "Independent re-verification (fresh worktree, not trusting worker/test-runner self-report) confirms all 9 OWNER-flagged defects are genuinely fixed at the source level."
- "mergeable=MERGEABLE, merge_state_status=BLOCKED, isDraft=true は control-plane 向け情報のみで reviewer blocker ではない。" |
PR Review (iteration 3, PR本文更新のみの再レビュー)Verdict: APPROVE 要約このイテレーションでは PR 本文のみが更新され、コード変更はありません(head SHA は前回と同一)。独立検証:
Warning(blocker ではない)
Blocker なし。 verdict: APPROVE
reviewed_head_sha: "329da0736840c660f2ee395df6d940f270ce80cc"
blockers: []
warnings:
- "Non-required e2e job (tests/e2e/visual-overlay.spec.ts, unrelated battle-UI HUD overlay screenshot diff) failing at this head; PR diff is Python/docs-only and unrelated. Not in branch protection required_status_checks (all of which are green)."
- "isDraft=true, mergeStateStatus=UNSTABLE driven solely by the non-required e2e/ci-verdict-summary failure above — control-plane-facing state, not a reviewer blocker." |
Summary
Issue #1941 の実装。
preflight_agy.pyに AGY capability gate(version parser / help probe / 隔離 runtime probe / capability-specific 5値判定)を追加し、capability detection の唯一の実装 SSOT とする。本 PR は iteration 2(fix_delta 適用ラウンド)を経ている。 iteration 0/1 のレビュー時点(head
d6ad9cfc2fa225efcd48c6aba4b7894b127a7bdf)では PR本文不足のみを blocker としていたが、その後 OWNER が実装契約を直接突合し、REQUEST_CHANGES(P1 7件・P2 2件)を投稿した。これを fix_delta として実装を修正し、現在の head329da0736840c660f2ee395df6d940f270ce80ccは OWNER 指摘の全9件を解消済みであることを control-plane が worktree で独立に再検証した(本 iteration 3 は本文更新のみで、この head での実装ファイル変更はない)。OWNER fix_delta(iteration 2, 全9件解消)への対応
OWNER REQUEST_CHANGES が指摘した P1-1〜P1-7・P2-1・P2-2 のそれぞれについて、head
329da073のソースで確認した対応は以下の通り。preflight_agy.py:1814compute_binary_identity()と実行前解決でos.path.realpath(shutil.which(agy_bin))を起動時に一度だけ解決し、exec_binとして version / help / runtime smoke / capability probe の全_run_*呼び出しへ共有するよう変更。fake-binary で PATH を probe 間に切り替える integration test を追加。leading_slash_is_literalprobe が--disable-slash-commandsを使っていない): runtime semantic probe の argv に--disable-slash-commandsを追加し、expansion-error evidence を sentinel より優先する判定順に変更。preflight_agy.py:1022_isolated_probe_env()を新設し、HOME/XDG_CONFIG_HOME/XDG_CACHE_HOME/XDG_STATE_HOMEを temp root へ差し替えて runtime smoke へ渡す(preflight_agy.py:2269)。AGY_PREFLIGHT_CONFIRM_RUNTIME_PROBE_COST(preflight_agy.py:28のAGY_RUNTIME_PROBE_COST_CONFIRM_ENV_VAR)による明示的 cost-confirmation gate を追加し、未確認時は probe を実行せずunavailable/77 とする。_finalize()(preflight_agy.py:2420)が sanitize 済みの値を戻り値・--json・--output-file・artifact の全出力経路で共通化するよう再構成し、version_evidence.raw/agy.versionも redact 対象に含めた。classify_parser_acceptance()(preflight_agy.py:1873)を、auth/quota evidence を優先し、non-zero exit +--disable-slash-commandsの明示的 flag 名 + narrow な parser error 行形状の3条件を要求するよう変更。setup_check.pyが capability matrix を実際には生成・consume しない):setup_check.py:193check_agy_preflight()がmodule.run_preflight(compute_capabilities=True)を呼ぶよう修正し、check_agy_preflight全体を monkeypatch しない非 monkeypatch の統合テストを追加(test_setup_check_consumes_additive_capability_matrix_without_breaking_ok_boolean)。_capability_cache_key()(preflight_agy.py:2129)を pre-run と pre-runtime-probe 双方の binary identity を束縛するキーへ変更し、get_or_compute_capability_matrix()(preflight_agy.py:2152)が drift 時に無条件で cache bypass するよう修正。config digest に.agents/hooks.jsonを追加。_finalize_early_exit()(preflight_agy.py:1253)が early exit 時も per-predicate の reason code(probe_not_run等)付き capability matrix を生成するよう変更。parse_agy_version_string()(preflight_agy.py:1765)が複数の矛盾する version token を検出した場合にversion_evidence_invalid(preflight_agy.py:1787,1799,1806)を返すよう変更。変更内容
preflight_agy.py:parse_agy_version_string():agy 1.1.9形式・単体バージョン・prerelease/build metadata・stdout空+stderr出力・複数行warning・malformed/locale・exit0だがparse不能・矛盾する複数version token(P2-2追加分)の全fixtureを分類し、parse不能・矛盾はversion_evidence_invalidに分類(AC8)。compute_binary_identity():os.path.realpath(shutil.which(agy_bin))を起動時に一度だけ解決したexec_binに対してsha256/size/mtime_ns/platform/archを測定し、version/help/runtime smoke/capability probe の全経路がこの同一exec_binへ subprocess を渡す(P1-1修正、AC6)。probe 前後で drift があれば全 predicate がevidence_invalidに固定される。CAPABILITY_PREDICATES/build_capability_matrix():headless_permission_policy(3 predicate)/hooks(7 predicate)/disable_slash_commands(2 predicate)へ分解し、各 predicate をsupported/unsupported/unavailable/inconclusive/evidence_invalidの5値で fail-closed 判定(AC1, AC2)。classify_parser_acceptance(): auth/quota evidence を優先し、non-zero exit + 明示的 flag 名 + narrow parser error 行形状を要求(P1-5修正、AC2, AC5)。_isolated_probe_env()/AGY_PREFLIGHT_CONFIRM_RUNTIME_PROBE_COST: HOME/XDG隔離とcost-confirmation gate(P1-3修正)。pre_invocation_injected_tool_callは upstreamgoogle-antigravity/antigravity-cli#728が open の間unsupported(reason_code: upstream_known_runtime_rejection)に固定(AC1)。agy --helpflag 欠落時の早期cli_incompatible終了バグを修正し、実際の runtime smoke 結果を authority とするよう変更(PR fix(agent-ops): capability 判定を claude --help ではなく実 runtime 挙動で行う #1976 と同じ設計)。--require-capabilityCLI フラグを追加し、要求 capability 集合に対して0/1/77の exit code taxonomy を導出(AC4)。既存 default invocation のokboolean 由来 exit0/1は変更しない。_finalize()/_finalize_early_exit(): 全ての controlled exit 経路(early exit を含む、P2-1修正)で sanitize 済みの値を戻り値・--json・--output-file・artifact の全出力経路で共通化し、.claude/tmp/(テスト時はAGY_PREFLIGHT_ARTIFACT_DIRで override 可)へ出力。argv_shape.flagsとprompt.sha256/prompt.byte_lengthのみを保存し、version_evidence.raw/agy.versionも redact(P1-4修正、AC7)。_capability_cache_key()/get_or_compute_capability_matrix(): pre-run/pre-runtime-probe 双方の binary identity と.agents/hooks.jsonを含む config digest を key とした in-process-only memoization(persistent cache なし、drift 時は無条件 bypass、P1-7修正、AC9)。setup_check.py:check_agy_preflight()がmodule.run_preflight(compute_capabilities=True)を呼び、agy_preflight["capabilities"](additive)をagy_capabilitiesとして surface する(P1-6修正、AC3)。独自の version/help parser は実装しない。既存のagy_preflight["ok"]単一 boolean 消費経路は変更なし。test_agy_capability_gate.py(新規、1098行): Issue 実装: AGY capability gate(version/help/runtime probe)を fail-closed で追加する #1941 の全 Verification Commands、および OWNER fix_delta の adversarial fixture(fake-binary PATH切替、矛盾version token 等)に対応するテスト一式。test_preflight_agy.py: help flag 欠落時の早期終了バグ修正に伴い、既存のtest_missing_noninteractive_flagsを新しい(正しい)挙動に更新。test_setup_check.py:check_agy_preflight全体を monkeypatch しない非monkeypatch統合テストを含む、additive capability matrix 消費のテストを追加(AC3, P1-6)。docs/dev/schema-governance.md:agy_preflight_result/v1に対する additiveagy_capability_matrix/v1拡張を記載(v2 bump なし)。Out of Scope(Issue #1941 に準拠)
headless_permission_policy/ hooks 各 predicate の実 enforcement(live E2E)検証は Issue 実装: AGY permission boundaryのdeterministic live E2Eをupstream capabilityへ束縛する #1979 の責務。本 PR ではこれらをinconclusive(reason_code: runtime_semantic_observation_deferred_to_1979)として fail-closed に扱い、supportedを捏造しない。受け入れ条件の達成状況
Issue #1941 に列挙された Verification Commands を、iteration 3 の作業として control-plane が worktree(head
329da0736840c660f2ee395df6d940f270ce80cc)上で個別に再実行し、全 9 AC の PASS を独立に確認した(実装ファイルの変更はこの iteration では行っていない)。preflight_agy.pyが version /agy --help/ 隔離 runtime probe を source 別に記録し、headless_permission_policy/hooks/disable_slash_commandsの各 predicate を fail-closed 判定し、pre_invocation_injected_tool_callを upstream 実装: deploy-pages.yml の actionlint(SC1083) 失敗を HEAD^{commit} クォート化で解消する #728 open の間unsupported固定にすることを検証。supportedに誤判定されないことを検証。setup_check.py含む)がpreflight_agy.pyの結果のみを利用し、独自 parser を実装せず、既存okboolean 消費経路を破壊しないことを検証。check_agy_preflight()がcompute_capabilities=Trueを渡す非monkeypatch統合テストを含む(P1-6修正)。0/1を維持し、--require-capability指定時に0/1/77の exit code taxonomy を返すことを検証。--disable-slash-commands採用可否がdisable_slash_commandscapability のsupported判定(parser acceptance + runtime semantics)に束縛されることを検証。runtime semantic probe の argv に--disable-slash-commandsを含める(P1-2修正)。os.path.realpath(shutil.which(agy_bin))を全_run_*へ共有、P1-1修正)に束縛され、probe 前後の identity drift がevidence_invalidになることを検証。.claude/tmp/配下に生成され、prompt本文・raw credential path・absolute HOME・未redact stderrを含まないことを検証。戻り値・--json・--output-file・artifact の全出力経路で共通sanitizerを通す(P1-4修正)。agy 1.1.9形式・単体バージョン・prerelease/build metadata・stdout空+stderr出力・複数行warning・malformed/locale依存・exit0だがparse不能・矛盾する複数version token)を正しく分類し、parse不能・矛盾をversion_evidence_invalidにすることを検証(P2-2修正含む)。検証コマンド結果(head
329da0736840c660f2ee395df6d940f270ce80cc、iteration 3 で control-plane が独立 worktree で再実行)上記に加え、必須 CI 6 件(
actionlint/build/lint/python-test-core/test/typecheck)を含む全ジョブが green であることをこの head で確認済み(PR Body Japanese Checkのみ本 iteration が修正する本文不足を理由に別途対応)。Allowed Paths 遵守状況
Issue #1941 の Allowed Paths(10 パス)に対し、本 PR の変更ファイル 6 件はすべて包含される。
git diff --stat origin/main...HEAD(head329da073)で確認済み。.claude/skills/gemini-cli-headless-delegation/scripts/preflight_agy.py.claude/skills/gemini-cli-headless-delegation/scripts/setup_check.py.claude/skills/gemini-cli-headless-delegation/tests/test_agy_capability_gate.py.claude/skills/gemini-cli-headless-delegation/tests/test_preflight_agy.py.claude/skills/gemini-cli-headless-delegation/tests/test_setup_check.pydocs/dev/schema-governance.mdAllowed Paths のうち
run_gemini_headless.py/test_agy_provider.py/ 2件のreferences/*.mdは本 PR では変更していない(変更が不要だったため)。Allowed Paths 外への変更は 0 件。Schema Change Applicability
agy_preflight_result/v1にcapabilities/capability_schema/capability_probesの additive field を新設する。schema バージョンのv2bump は行わない。run_preflight()のデフォルト呼び出し(compute_capabilities省略)は既存のokboolean 由来 exit0/1を変更しない。新設の--require-capabilityCLI モードのみが要求 capability 集合に対する0/1/77の exit code taxonomy を持つ。Schema Consumer Inventory
Before(変更前)
After(変更後)
preflight_agy.py(producer)build_capability_matrix()/get_or_compute_capability_matrix()が唯一の実装 SSOT。既存okboolean の derivation ロジックは変更していないsetup_check.pycheck_agy_preflight()がcompute_capabilities=Trueを渡し(P1-6修正)、agy_preflight["capabilities"]をagy_capabilitiesとして additive に surface する。既存agy_preflight["ok"]単一 boolean 消費は不変(test_setup_check_consumes_additive_capability_matrix_without_breaking_ok_booleanで確認)run_gemini_headless.pygit diff --stat origin/main...HEADで確認済み)。capabilitiesfield を直接参照するコードはなく、既存の起動フローは不変Safety Claim Matrix
本 PR は
.claude/skills/gemini-cli-headless-delegation/**配下を変更し、headless_permission_policy/hookscapability predicate の命名と auth-signal classification(classify_parser_acceptance())を導入するため safety-sensitive として扱う。supportedに誤判定しないpre_invocation_injected_tool_callを upstream 未解決 issue の間unsupportedに固定する--disable-slash-commands込み)を検証する--json/--output-file/artifact)が同一 sanitizer を経由するheadless_permission_policy(persisted settings deny 強制等)の実 enforcement を live E2E で保証するpersisted_settings_loaded等は設定ロード確認のみ)--require-capabilityの exit code taxonomy(77 と pytest skip を成功や close の根拠にしない)Runtime Verification Applicability
Issue 本文の
decision: immediate(applicable_acs: [AC1, AC4, AC5, AC6])に対応し、test_agy_capability_gate.pyは unit level のテストで hermetic に検証している(実agybinary への live 依存はテスト内で_runを monkeypatch して置き換え、fail-closed 判定ロジック自体を検証)。実 binary に対する--require-capabilityの live 実行例は開発環境でagy 1.1.9を用いて手動確認済み。headless_permission_policy/ hooks predicate の実 enforcement(live side-effect)検証は Issue #1979 の責務であり、本 PR の PASS 条件には含めない。Checks
uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/ -q— 1278 passed(head329da073、iteration 3 で control-plane が独立 worktree で再実行)329da073)uv run ruff check対象 5 ファイル — All checks passedgh pr checks 1982— 必須 CI(actionlint/build/lint/python-test-core/test/typecheck等)が全て green(head329da073)git diff --stat origin/main...HEAD— 変更 6 ファイルはすべて Issue 実装: AGY capability gate(version/help/runtime probe)を fail-closed で追加する #1941 の Allowed Paths 内329da073のソースレベルで解消していることを control-plane が独立 worktree で再確認Notes
preflight_agy.py/setup_check.py/ テストを 6 ファイル・2281 行修正(headd6ad9cfc→329da073)。329da073の実態(OWNER 9項目の解消内容と再検証済み VC 結果)に合わせて更新した。実装ファイルの変更はこの iteration では行っていない(head は不変)。headless_permission_policy/ hooks predicate の live enforcement 検証は Issue 実装: AGY permission boundaryのdeterministic live E2Eをupstream capabilityへ束縛する #1979 の責務として明示的に切り離している。Related Issues(関連する Issue の一覧)
headless_permission_policy/ hooks predicate の実 enforcement の live 検証)pre_invocation_injected_tool_callがunsupportedに固定されている理由)最後に改めて明記する: 本 PR は Closes #1941 によりこの実装 Issue をクローズする。
Co-Authored-By: Claude Sonnet 5 [email protected]