Skip to content

実装: AGY isolated workspaceが既存認証済みセッションへ値露出なしで到達できるようにする #1726

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1265"
goal_ref: "AGY isolated workspaceが既存認証済みセッション(OS keyring/dbus)へ値露出なしで到達できるようにする"
change_kind: code

Parent Issue

#1265
(Antigravity CLI 移行の親 Issue)

Parent Goal Ref

Current Validated Scope

  • materialize_isolated_agy_workspace()(.claude/skills/gemini-cli-headless-delegation/scripts/agy_permission_policy.py)が返す環境変数 allowlist に、既存認証済みセッションへの到達に必要な非秘密環境変数(DBUS_SESSION_BUS_ADDRESS 等)を追加する
  • 上記変更後も HOME/XDG_CONFIG_HOME/XDG_CACHE_HOME/XDG_STATE_HOME の isolated tmp workspace への差し替え(実装: AGY profile別isolated permission policyとno-tools negative evidenceを導入する #1705 の secret-hygiene 設計)が維持されることを回帰テストで保証する
  • 認証情報の値そのもの(token 文字列・cookie・credential file 内容)が一切コピー・出力・ログ出力されないことを保証する redaction 回帰テストを追加する
  • hostile global settings fixture での tool deny 機構(実装: AGY profile別isolated permission policyとno-tools negative evidenceを導入する #1705 の AC 群)が今回の変更でも維持されることを確認する回帰テストを追加する
  • agy CLI の認証確認(system keyring / dbus secret service 経由)が isolated workspace 内で機能することを検証する統合テスト(hermetic / モック化)を追加する
  • .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md の該当箇所(dbus_session_bus_present 等の auth diagnostics metadata 記述箇所)を今回の allowlist 拡張と整合するよう更新する

Remaining Parent Gaps

  • fan-out orchestrator 経由の live AGY 実行が実際に既存認証済みセッションで成功することの動作確認は 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 側の最終 E2E run に委ねる(本 Issue は hermetic tests までがスコープ)
  • agy の認証確認ロジック自体(keyring backend 選択・auth_mode 判定等)の深掘りは本 Issue のスコープ外。必要なら別 Issue で扱う

Outcome

materialize_isolated_agy_workspace()(.claude/skills/gemini-cli-headless-delegation/scripts/agy_permission_policy.py)が、認証情報の値そのもの(トークン・cookie・credential file 内容)を一切コピー・出力・ログ出力しないまま、既存の OS keyring/dbus secret service 経由の認証済みセッションへ子プロセスが到達できる環境変数 allowlist に更新され、対応する redaction 回帰テスト・tool-deny 回帰テスト・isolated workspace 内 auth 到達性の統合テストが .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy.py に追加され、references/runtime-portability.md の記述が更新された状態で PR がマージ済みである。

In Scope

  1. materialize_isolated_agy_workspace() の環境変数 allowlist(現状 PATH/LANG/LC_ALL/TERM のみ)に DBUS_SESSION_BUS_ADDRESS を追加する(値は Unix ソケットパスであり credential 値ではない)
  2. 到達性のために必要な他の非秘密環境変数(例: XDG_RUNTIME_DIR。ソケットディレクトリパスであり秘密情報ではない)を検討し、追加する場合は各変数についてなぜ安全か(値の性質)をコード内コメントに明記する
  3. HOME/XDG_CONFIG_HOME/XDG_CACHE_HOME/XDG_STATE_HOME の isolated tmp workspace への差し替え自体は変更しない(実装: AGY profile別isolated permission policyとno-tools negative evidenceを導入する #1705 の secret-hygiene 設計の根幹を維持する)
  4. 認証情報の値(token 文字列、OAuth code、cookie 等)がテスト・ログ・public artifact へ一切出力されないことを保証する adversarial redaction 回帰テストを追加する
  5. hostile global settings fixture(hostile_global_settings_fixture())での tool deny 機構(no_tools/local_asset_research 全 deny、grounded_research allowlist 限定)が今回の allowlist 拡張後も維持されることを確認する回帰テストを追加する
  6. agy CLI の認証確認(system keyring / dbus secret service 経由)が isolated workspace 内で機能することを検証する統合テストを追加する(モック化して hermetic に保つ。live 認証確認自体は 調査: fan-out orchestrator の実AGY/Serena MCP/WebSearch並列実行E2E検証を行う #1494 側の runtime verification に委ねる)
  7. .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md の該当ドキュメント(permission policy 契約に関わる記述)を今回の allowlist 拡張と整合するよう更新する

Out of Scope

Acceptance Criteria

  • AC1: materialize_isolated_agy_workspace() が返す env に、実行環境の DBUS_SESSION_BUS_ADDRESS が設定されている場合、その値がそのまま伝播していることをテストで確認できる
  • AC2: materialize_isolated_agy_workspace() が返す env において、HOME/XDG_CONFIG_HOME/XDG_CACHE_HOME/XDG_STATE_HOME が引き続き isolated tmp workspace 配下のパスに差し替えられていることをテストで確認できる(実 $HOME の値が env に残っていない)
  • AC3: 環境変数 allowlist に含めた各追加変数(DBUS_SESSION_BUS_ADDRESS 等)について、なぜ credential 値ではないか(ソケットパス・ディレクトリパス等の性質)を説明するコメントが agy_permission_policy.py 内に存在する
  • AC4: DBUS_SESSION_BUS_ADDRESS に credential-like な文字列(sk-/ghp_/AIza 等)が偶然含まれるケースを模した adversarial ケースで、env にコピーされた値も record_denied_tool_attempt() / redaction ヘルパー経由の出力もテキストとして public artifact(テスト出力・比較対象文字列)へ credential-like パターンを残さないことを確認するテストが存在する
  • AC5: resolve_tool_permission() および build_workspace_permission_policy() の deny 挙動(no_tools/local_asset_research が全 deny、grounded_research が search_web/read_url_content のみ allow)が、今回の allowlist 拡張後も hostile_global_settings_fixture() を使った adversarial テストで維持されていることを確認するテストが存在する
  • AC6: find_credential_like_files() が今回の変更後も isolated workspace 配下に credential-like basename のファイルを一切検出しない(既存 AC12 相当の回帰)ことを確認するテストが存在する
  • AC7: isolated workspace 内で agy の認証確認(system keyring / dbus secret service 経由の到達性)が機能することを、モック化した dbus/keyring エンドポイントに対して検証する hermetic 統合テストが存在する
  • AC8: .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md に、materialize_isolated_agy_workspace() の環境変数 allowlist へ到達性変数が追加された旨の記述が存在する

Verification Commands

# AC1
$ uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_env_includes_dbus_session_bus_address
# AC2
$ uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_home_and_xdg_still_redirected
# AC3
$ rg -n "DBUS_SESSION_BUS_ADDRESS" .claude/skills/gemini-cli-headless-delegation/scripts/agy_permission_policy.py
# AC4
$ uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_env_allowlist_extension_never_leaks_credential_like_value
# AC5
$ uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_tool_deny_matrix_unaffected_by_env_allowlist_extension
# AC6
$ uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_credential_like_file_scan_unaffected_by_env_allowlist_extension
# AC7
$ uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_reaches_mocked_dbus_secret_service
# AC8
$ rg -n "DBUS_SESSION_BUS_ADDRESS" .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md

Allowed Paths

  • .claude/skills/gemini-cli-headless-delegation/scripts/agy_permission_policy.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy.py
  • .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py
  • .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • DBUS_SESSION_BUS_ADDRESS 以外に到達性のため必須と判明した環境変数が、値の性質上 credential-like と判断できない(安全性を明記できない)場合は追加せず停止し、人間判断を仰ぐ

Required Skills

  • Python(pytest / dataclasses / tempfile)
  • Unix プロセス環境変数・dbus/keyring の到達性に関する基礎知識

Required Design References

  • .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md
  • .claude/skills/gemini-cli-headless-delegation/SKILL.md
  • docs/dev/secret-policy.md

Scope Delta(該当時のみ記載)

N/A(現時点で Allowed Paths と実作業の乖離なし)

Runtime Verification Applicability

Delivery Rule(配信ルール)

Notes for Reviewer(レビュアー向け補足)

Activity

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

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-25T03:26:19Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1726
      body_sha256: "sha256:947c1f5f4bb9bc02f37b910a8257836fd759c41f1a525cbec7b9e6bc0df9f5d5"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:947c1f5f4bb9bc02f37b910a8257836fd759c41f1a525cbec7b9e6bc0df9f5d5","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_env_includes_dbus_session_bus_address","command_hash":"sha256:68fc8a675532f17a07deef023d8c1dcf6a8bdcea0996bd1b626816d026045258","execution_key_hash":"sha256:11d39dbd3a8ef1a0975475a04c522e351cbcd1d9bd7ab67d7dd9214b320f45c4","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_env_includes_dbus_session_bus_address"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":165,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":2,"raw_command":"uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_home_and_xdg_still_redirected","command_hash":"sha256:e7c2c7ac49ba203e7f9c7eefea4c5d56d8bb1010eade2abd22d5e52788f1af26","execution_key_hash":"sha256:dec2719693f676b4d4d943fecbf7d0a93fd8acaa176fd0a384a0a6a7014b0f05","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_home_and_xdg_still_redirected"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":166,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC3","line":2,"raw_command":"rg -n \"DBUS_SESSION_BUS_ADDRESS\" .claude/skills/gemini-cli-headless-delegation/scripts/agy_permission_policy.py","command_hash":"sha256:9fa7ca834d7f8111d37788bad2c6ad83b53bc18fe0169a4d6043a51f0eb8c59c","execution_key_hash":"sha256:8e06cf2a1b9346467b679948179852e427383fbc82f7d66d109f2c720380e4c8","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC4","line":2,"raw_command":"uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_env_allowlist_extension_never_leaks_credential_like_value","command_hash":"sha256:b8606a4d2c788bae9aa1b4f7c9c7761e8ca95dcc788551a85f9bc465e7c66ccd","execution_key_hash":"sha256:80e71f95610fbaf4dbc628dd360ec87ad47fc3de01eb75222a03985f39b14fa4","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_env_allowlist_extension_never_leaks_credential_like_value"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":168,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC5","line":2,"raw_command":"uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_tool_deny_matrix_unaffected_by_env_allowlist_extension","command_hash":"sha256:8f6cccb254482b900b48e90eef30cc4bf29e97feab2f94b63f206df594250316","execution_key_hash":"sha256:97118174d8a44ff6ac90d58b08c02999a8c32545ea25d4eccec88834fb40886e","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_tool_deny_matrix_unaffected_by_env_allowlist_extension"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":157,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC6","line":2,"raw_command":"uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_credential_like_file_scan_unaffected_by_env_allowlist_extension","command_hash":"sha256:624ec1096006c264fe28148e43db12169bb8ed8668ad043a9a65a6467dabec43","execution_key_hash":"sha256:5bb4a4a44c7d2f405643eb58459445838c9ebb4d2bcf2a59e9f1863460ea1155","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_credential_like_file_scan_unaffected_by_env_allowlist_extension"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":152,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC7","line":2,"raw_command":"uv run --with pytest python -m pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_reaches_mocked_dbus_secret_service","command_hash":"sha256:ea7024d9d237a988165a4d64c2cc692c8c56b16ad03cd06d91bd7fe4dc9d2093","execution_key_hash":"sha256:8ceab662af2a02b9f2580908b91127bd9507bce96590d89e98254a9c858d80a4","runner":"exec","exit_code":4,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 0 items","============================ no tests ran in 0.01s ============================="],"stdout_truncated":false,"stdout_original_line_count":9,"stderr_head":["ERROR: file or directory not found: .claude/skills/gemini-cli-headless-delegation/tests/test_agy_permission_policy_env_allowlist.py::test_isolated_workspace_reaches_mocked_dbus_secret_service"],"stderr_truncated":false,"stderr_original_line_count":3,"runner_env_delta":{},"duration_ms":148,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC8","line":2,"raw_command":"rg -n \"DBUS_SESSION_BUS_ADDRESS\" .claude/skills/gemini-cli-headless-delegation/references/runtime-portability.md","command_hash":"sha256:22014dcd65da586ff0e1bfb23d232356b439c2700b1baef2fe7260823e4ace12","execution_key_hash":"sha256:24a2fb0978e5b2b90054bcccbb120e4b353b0af7278487799693e1a345920f6d","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
      expected_contract_fingerprint: {"issue_number":1726,"contract_source_kind":"issue_comment","contract_source_id":"5076677828","contract_body_sha256":"sha256:947c1f5f4bb9bc02f37b910a8257836fd759c41f1a525cbec7b9e6bc0df9f5d5","allowed_paths_normalized_sha256":"d1de1c77f89669604094d50262fd2819041d5b4568ebccbbca37b1f280301f6b","base_ref":"main","base_sha_at_snapshot":"d9d88cf7f6d0f90ad0c275a1436a5fdd4e545b64"}
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/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions