Repository navigation
fix(gemini-delegation): AGY headless prompt の leading slash-command を fail-closed 拒否する (#1928) - #1931
Merged
Merged
Conversation
… fail-closed 拒否する #1918 の policy decision(headless wrapper では leading slash-command を fail-closed で拒否する)を実装する。prompt の先頭トークン(BOM・空白除去後)が ASCII `/` で始まる場合、_run_agy() が subprocess を起動する前に AgyInvocationPolicyError を送出し、既存の agy_invocation_policy_denied failure_class(Issue #1807)へ合流させる。新規 failure_class・schema変更なし。 Closes #1928
Contributor
Preview URLPreview removed (PR #1931 closed). |
Owner
Author
独立レビュー結果(pr-review-judge、head 8be857960 時点)独立 SubAgent によるレビューを実施した。 Verdict(当時): REQUEST_CHANGES
Blocker(対応済み)PR 本文の Safety Claim Matrix 1行目の → commit Warnings(対応済み)
いずれも commit |
…gy-leading-slash-policy
squne121
marked this pull request as ready for review
August 1, 2026 11:03
This was referenced Aug 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.pyの_run_agy()に、prompt の先頭トークン(BOM・空白除去後)が ASCII/で始まる場合に fail-closed 拒否する純粋関数チェックを追加する。Issue #1918 で確定した slash-command policy decision(https://github.com/squne121/loop-protocol/issues/1918#issuecomment-5150974825)を実装する唯一の implementation Issue。Policy Decision Implemented(実装した policy 決定内容)
-p/-p-p-p--disable-slash-commandsによる literal 保持AgyInvocationPolicyErrorを送出し、既存のagy_invocation_policy_deniedfailure_class(Issue #1807)へそのまま合流させる。新規 failure_class・delegation_result/v1schema 変更は行わない。受け入れ条件の達成状況
_agy_prompt_has_leading_slash_command()/_run_agy()が reject-class の全パターン(単一 leading slash・leading whitespace+slash・BOM+slash・stacked leading slash・unknown command・workspace/global skill 形式・bare/・newline を含む leading slash)でAgyInvocationPolicyErrorを送出することをテストで検証/が現れる allow-class(mid-prompt mention・URL・絶対パス・fenced code block・通常の日本語 prompt・既存--model引数付き canonical argv)が拒否されないことをテストで検証subprocess.run()が一度も呼ばれないこと、stderr/warnings/failure_reasonに prompt 全文や secret sentinel が含まれないことをテストで検証test_agy_invocation_argv_allowlist.py(19 tests)、test_agy_real_subprocess.py、test_agy_provider.py、test_preflight_agy.py、skill 全体(1184 tests)が回帰なく passrun_gemini_headless.py/test_agy_invocation_argv_allowlist.pyが Ruff lint を通過failure-class-taxonomy.mdが無変更(git diff --exit-code origin/mainで確認、新規 failure_class を追加していないため)検証コマンド結果
以下の検証コマンドをすべて実行し、結果を記録した。
uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_invocation_argv_allowlist.py -q→ 19 passeduv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_real_subprocess.py .claude/skills/gemini-cli-headless-delegation/tests/test_agy_provider.py .claude/skills/gemini-cli-headless-delegation/tests/test_preflight_agy.py -q→ 106 passeduv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests -q→ 1184 passeduv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -q→ 21 passeduv run --locked ruff check .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py .claude/skills/gemini-cli-headless-delegation/tests/test_agy_invocation_argv_allowlist.py→ All checks passed(違反なし)git diff --exit-code origin/main -- .claude/skills/gemini-cli-headless-delegation/references/failure-class-taxonomy.md→ exit 0(無変更を確認)git diff --check→ exit 0(問題なし)pnpm typecheck→ pass(tsc --noEmitエラーなし)pnpm lint→ESLint: No issues found(問題なし)pnpm test→ 105 test files / 1794 tests が成功pnpm build→ 成功Allowed Paths 遵守
Issue #1928 の Allowed Paths(2 ファイルのみ)と完全一致:
.claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py.claude/skills/gemini-cli-headless-delegation/tests/test_agy_invocation_argv_allowlist.pygit diff --stat origin/mainで上記 2 ファイル以外の変更がないことを確認済み。Runtime Verification Evidence(実行時検証の証跡)
subprocess.runを mock/monkeypatch する hermetic pytest のみ。実agyバイナリは起動していない。model-backedagy -pの live call は実行していない(無課金確認ができないため)。Issue 調査: Gemini/AGY delegation slash-command literal・expansion policy と実装 routing を確定する #1918 の policy decision comment に記録済みのagy --version(1.1.9) /agy --help(--disable-slash-commands実在確認)/agy changelogの direct evidence は本 PR の実装判断の根拠として使用したが、本 PR 自体はその CLI を呼び出さない。Schema Change Applicability
agy_invocation_policy_deniedfailure_class(Issue 実装: AGY permission-bypass flag 拒否のfail-closed実装と再実行可能テストを追加する #1807)をそのまま再利用。delegation_result/v1のキー・型・producer-consumer 境界は変更していない。新規 failure_class・新規 result フィールドは追加していない。Schema Consumer Inventory
N/A(schema 変更なし)。
failure-class-taxonomy.mdが無変更であることを AC6 の VC で確認済み。Compatibility Decision(互換性判断)
agy_invocation_policy_denied消費者はそのまま動作する)--disable-slash-commandsを用いた literal 保持は 実装: AGY permission/hook boundary の hermetic evidence を整備する #1814(AGY version gate)完了後に別途検討するSafety Claim Matrix
agy --help/changelogevidence に基づく推定に留まる。実バイナリの実際のパース挙動そのものを検証・保証しない)--disable-slash-commandsを用いた literal 保持Checks
uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_invocation_argv_allowlist.py -q— 19 passed(AC1〜AC3 の新規テストを含む)uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests -q— 1184 passed(AC4 回帰)uv run --locked ruff check .claude/skills/gemini-cli-headless-delegation/scripts/run_gemini_headless.py .claude/skills/gemini-cli-headless-delegation/tests/test_agy_invocation_argv_allowlist.py— All checks passed(AC5)git diff --exit-code origin/main -- .claude/skills/gemini-cli-headless-delegation/references/failure-class-taxonomy.md— exit 0(AC6、無変更)pnpm typecheck/pnpm lint/pnpm test/pnpm build— 全て pass(CLAUDE.md 必須検証)Notes
git diff --stat origin/mainで確認済み。/で始まるか」という単一の構造的判定のみ。個別 slash command 名の allowlist/denylist は意図的に追加していない(調査: Gemini/AGY delegation slash-command literal・expansion policy と実装 routing を確定する #1918 policy decision の理由セクション参照)。--disable-slash-commandsはagy --help(v1.1.9)で実在確認済みだが、実装: AGY permission/hook boundary の hermetic evidence を整備する #1814 の version gate 完了までは本 PR で採用しない。Related Issues(関連する Issue の一覧)
本 PR に関連する Issue を以下に列挙する。
最後に改めて明記する: 本 PR は Closes #1928 によりこの実装 Issue をクローズする。