Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2005(Issue #1886)の impl-review-loop iteration 3 で AC6 live verification が github_research_skip/gh_token_unavailable で fail した gap を、#1920/#2000 の security boundary を強化した形で解消する(OWNER REQUEST_CHANGES 反映後の再定義、#2012 anchor comment 5225022347 / HUMAN_DECISION_V1 anchor comment 5225265837)"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 の
codex_cli / codebase-investigator / github_researchroute の live AC6 検証が、GH_TOKEN未設定により毎回 skip せず実行できる状態にする - Desired Destination:
run_agy_github_research_broker.pyが実際の独立 subprocess として credential resolution(storedghcredential の bootstrap を含む)と downstreamgh実行を所有し、E2E/orchestrator process・AGY process のいずれも GitHub token を取得・保持しない状態
Current Validated Scope
.claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_broker.pyexecute_operation(...)という in-process 関数と、main()/_cli_argv()によるvalidate/executeサブコマンドを持つ CLI エントリポイントの両方を既に持つ(if __name__ == "__main__"あり)。- CLI
executeサブコマンドは--gh-token-env(既定GH_TOKEN)で指定した環境変数から自分自身の process で token を読む設計であり、真の subprocess isolation に使える土台が既に存在する。 - しかし現状この CLI エントリポイントは
run_agy_github_research_e2e.pyから使われていない。
.claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_e2e.pyimport run_agy_github_research_broker as brokerで broker module を同一 Python process に import し、_preflight(*, gh_token_env: str)でos.environ.get(gh_token_env)により E2E process 自身がGH_TOKENを取得する。- 取得した token を
broker.execute_operation(..., gh_token=gh_token, ...)へ 同一プロセス内の Python 関数呼び出しとして 渡している(= broker は独立 process ではない)。 - AGY child process へは
_scrubbed_probe_env()/_isolated_agy_env()により token を渡さない防御は既に機能している(この防御自体は維持する)。
.claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_broker.pyはexecute_operation()内でghchild process を起動する際、その環境(_minimal_broker_env())にGH_TOKENを設定する。- 上記の結果、「
run_agy_github_research_broker.pyのみが GH_TOKEN を保持する唯一の process である」という docstring 上の不変条件は、現行実装(E2E process が token を取得・保持する)と矛盾する。この矛盾は OWNER REQUEST_CHANGES(issuecomment-5225022347)P0-1 で指摘され、codebase-investigator による独立コード調査(issuecomment-5225079720 の human_judgment_required 終了報告に記録)でも同一ファイル・行レベルで確認済み。 .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_e2e.py/test_agy_github_research_contract.pyは、AGY env からの token 排除・redaction・isolatedGH_CONFIG_DIR・streaming cap・timeout・deadline 等、Issue 実装: AGY が制約付き read-only gh を反復利用する github_research #1920/実装: AGY が制約付き read-only gh を反復利用する github_research #2000 の security invariant を broker 呼び出しレベル(in-process fixture 経由)で広範にテストしている。ただし E2E→broker が同一 process か別 process かを区別するテストは存在しない。
Remaining Parent Gaps
- Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 の Allowed Paths はこの gap を理由に拡張しない(OWNER human-escalation resolution)
- Serena MCP / Claude Code custom-agent runtime に関する残 gap は本 Issue の対象外(別途 follow-up が必要な場合は分離する、Issue 実装: local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する #2015 が Serena MCP timeout を別 reliability gap として扱っている)
Outcome
以下の security property がすべて成立する状態になり、Issue #1886 の github_research route の live 実行が status: pass に到達したことを記録した検証ログ(token 値を含まない)が残っている。
- E2E/orchestrator process(
run_agy_github_research_e2e.py)は GitHub token を取得・保持しない。 - AGY process は GitHub token を取得・保持しない(既存 実装: AGY が制約付き read-only gh を反復利用する github_research #1920/実装: AGY が制約付き read-only gh を反復利用する github_research #2000 の invariant を維持)。
run_agy_github_research_broker.pyは実際の subprocess として起動され、その subprocess boundary の内部だけで credential resolution(storedghcredential の bootstrap を含む)と repository-boundgh実行を行う。- parent(E2E)↔ broker subprocess の IPC は token-free の closed operation protocol(operation id + validated params のみを送り、redacted/bounded な public-safe result のみを受け取る)に限定される。
- broker 内の credential bootstrap(stored credential 取得)が失敗した場合は fail-closed/SKIP を返し、token 値を表示・ログ・diagnostic 出力しない。
- downstream research 用
ghchild process 実行では、既存 実装: AGY が制約付き read-only gh を反復利用する github_research #1920/実装: AGY が制約付き read-only gh を反復利用する github_research #2000 の allowlist・repository/host binding・shell=False・private/isolatedGH_CONFIG_DIR・timeout・byte cap・redaction-before-truncate の invariant をすべて維持する。 - shell で事前に
export GH_TOKEN=...していなくても、gh auth login済みで authenticated な stored credential が利用可能な実行環境では、github_research route の live 実行が genuinestatus: passに到達する。credential が利用不能な環境ではSKIPを返し、SKIPをPASSとして扱わない。
Background
Issue #1886(PR #2005)の impl-review-loop iteration 3 で、codex_cli / codebase-investigator / github_research route を live 実行したところ、以下の failure_class で fail した:
failure_class: github_research_skip
skip_reason: gh_token_unavailable
run_agy_github_research_e2e.py の _preflight(*, gh_token_env: str) は次の通り GH_TOKEN 環境変数を明示的に要求する:
gh_token = os.environ.get(gh_token_env)
if not gh_token:
return False, "gh_token_unavailable", Noneこの実行環境(sandbox/worktree agent 実行環境)では gh auth status はログイン済みだったが、そのログイントークンが GH_TOKEN 環境変数として反映されておらず未設定だった。
OWNER は #1886 の impl-review-loop human escalation で、この gap を「PR #2005 の既知コード欠陥」ではなく「AC6 の acceptance を完了するための runtime prerequisite / reliability gap」として分離し、GH_TOKEN 関連の gap を narrowly-scoped な別 Issue として起票するよう決定した。
OWNER REQUEST_CHANGES と再定義の経緯
本 Issue の初版(GH_TOKEN の動的取得手段の追加、または operator provisioning 手順のドキュメント化のいずれかを選ぶ二択)に対し、OWNER は anchor comment(#2012 (comment) )で REQUEST_CHANGES を判定した。主要な指摘(P0-1〜P0-3)は以下の通りで、いずれも codebase-investigator による独立コード調査で正確と確認された:
- P0-1: 「
run_agy_github_research_broker.pyが唯一の GH_TOKEN 保持プロセス」という初版 Outcome/AC4 の不変条件は、現行実装(E2E process が自らGH_TOKENを取得し、同一プロセス内で broker 関数を呼ぶ)と矛盾する。 - P0-2: 初版の解決案の一つだった「
run_agy_github_research_e2e.pyにgh auth tokenを追加する」は、gh auth tokenが token 値そのものを stdout へ出力する以上、credential exposure surface を E2E process にまで拡大してしまい採用できない。 - P0-3: 初版の AC2 / AC4 の Verification Commands(
grepベース)は、現行実装のままでも PASS してしまう false-green だった。
OWNER はこれを受けて、issue-refinement-loop の human_judgment_required 終了報告(#2012 (comment) )に対する明示的な決定として HUMAN_DECISION_V1(#2012 (comment) )を発行し、本 Issue を「broker を実際の独立 subprocess にして credential acquisition も broker 側へ移す」設計へ再定義した。GitHub CLI 公式仕様(gh auth token の出力仕様、GH_TOKEN/GITHUB_TOKEN の precedence、GH_CONFIG_DIR、gh auth login の credential store)については、AGY grounded_research route が agy_web_grounding_no_citations(citation_count: 0)で2回とも fail-closed したため、OWNER が一次資料を人間判断で確認し、HUMAN_DECISION_V1 の external_spec_resolution として記録している(--hostname は GitHub CLI の必須オプションではなく、本 route の deterministic host-binding要件として採用する、という精度修正を含む)。
In Scope
run_agy_github_research_e2e.pyを、run_agy_github_research_broker.pyを Python module として import して in-process 関数呼び出しする現行方式から、broker を 実際の OS subprocess(run_agy_github_research_broker.pyが既に持つexecuteCLI サブコマンドを使う、または同等の subprocess 起動)として起動する方式へ変更する。run_agy_github_research_broker.pyのexecuteCLI パス(または新設する専用 bootstrap パス)に、storedghcredential を broker subprocess 内部だけで取得する credential bootstrap ロジックを追加する:GH_TOKEN/GITHUB_TOKEN環境変数が broker subprocess の起動時 env に明示的に provisioning されていれば、それを優先して使用する。- 環境変数が無ければ、broker subprocess 内部で
gh auth token --hostname github.com相当の呼び出しにより stored credential を取得し、その結果を broker subprocess のメモリ内だけ で保持する(stdout に出力しない・呼び出し元へ返さない)。 - credential bootstrap に失敗した場合(
gh auth tokenの非ゼロ終了・空 token・malformed 出力・timeout 等)は、broker が構造化された fail/SKIP 応答を返し、token を診断出力しない。
- parent(E2E)と broker subprocess 間の IPC を、operation id + validated params のみを送り、redacted/bounded な public-safe result のみを受け取る closed operation protocol に限定する(token を argv・env(parent→broker 方向)・stdin・stdout・stderr のいずれにも含めない)。
- 既存の research 用
ghchild process 呼び出し(_minimal_broker_env()/_isolated_gh_config_dir()/ redaction-before-truncate 等)における isolation invariant を、credential bootstrap 追加後も維持する。 - 上記変更に対応する hermetic pytest の追加。新規テストは既存
test_agy_github_research_e2e.py/test_agy_github_research_contract.pyへ関数追加するのではなく、新規ファイルtest_agy_github_research_broker_process_boundary.py(AC1/AC2: E2E→broker の subprocess 起動境界、parent の token 非受領)とtest_agy_github_research_credential_bootstrap.py(AC3〜AC7: hostname pin、bootstrap failure 分類、GH_CONFIG_DIRisolation 維持、token 非出現、pass/skip 判定)に分離して追加する。 - Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 の
github_researchroute が、解決策適用後に live でstatus: passに到達することの検証と、検証ログ(token 値を含まない)の記録(docs/dev/agy-github-research-gh-token-provisioning.mdへ、設計決定の記録と合わせて残す)。
Out of Scope
- AGY child process への
GH_TOKEN/GITHUB_TOKEN直接注入(Issue 実装: AGY が制約付き read-only gh を反復利用する github_research #1920 の security invariant により禁止。維持する) GH_TOKENの値そのものを表示・ログ・artifact・Issue/PR comment・tracked file に記載すること- E2E/orchestrator process が
gh auth tokenを実行して stdout の token を受け取り、それを broker 関数へ Python 文字列として渡す設計(P0-1/P0-2 を再導入するため採用禁止) .env/ settings.local /ghcredential store 等を agent が探索して token を回収する変更- secret guard や
GH_CONFIG_DIRisolation の緩和 - Issue 実装: AGY が制約付き read-only gh を反復利用する github_research #1920 / PR 実装: AGY が制約付き read-only gh を反復利用する github_research #2000 の broker operation allowlist・repository binding・streaming cap・timeout・deadline 設計自体の変更(尊重・維持する)
- Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 の Allowed Paths 拡張(実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 側では対応しない)
agy_web_grounding_no_citations(AGY grounded_research の structured citation 欠落)という grounding tooling gap の修正(本 Issue の refinement では調査・dedupe のみを行い、実装は別 Issue の対象とする)- Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 / PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 の未解決点のうち本 gap(GH_TOKEN provisioning / credential boundary)以外のもの(例: Serena MCP timeout、Issue 実装: local_asset_research route の live Serena MCP 応答待ちタイムアウトの信頼性を改善する #2015 で扱う)
Acceptance Criteria
- AC1:
run_agy_github_research_e2e.pyが broker を実際の OS subprocess として起動していることを検証する hermetic test が存在し pass する(subprocess.Popen/subprocess.run等の実プロセス起動 API 呼び出しをモックして argv に broker script path とexecuteサブコマンドが含まれることを確認し、broker.execute_operationへの同一プロセス内直接呼び出しが行われていないことも確認する) - AC2: parent(E2E)process が token を一度も受け取らない・保持しない・IPC で forward しないことを検証する hermetic test が存在し pass する(fake credential source と fake
ghexecutable を用い、parent process の環境・引数・標準入出力のいずれにも raw token が出現しないことを確認する) - AC3: broker subprocess による credential bootstrap が
github.comを明示的に--hostnameで pin していることを検証するテストが存在し pass する - AC4: credential bootstrap が失敗するケース(stored credential 利用不能・
gh auth token非ゼロ終了・空 token・malformed 出力)が PASS へ昇格せず、構造化された fail/SKIP になることを検証するテストが存在し pass する - AC5: credential bootstrap 実行後も、research 用
ghchild process 実行が private/isolated(fresh・empty)なGH_CONFIG_DIRの下で行われ、ambient なghalias/extension/config に依存しないことを検証するテストが存在し pass する - AC6: token 値が stdout・stderr・broker→parent の IPC result・route artifact・audit/result JSON・checked-in docs・test fixture のいずれにも出現しないことを、token-shaped sentinel を用いた hermetic test と、
.claude/scripts/secret_exposure_scanner.pyのscan_file()を pytest から直接呼び出す static scan の両方で検証し、いずれも finding 0 になる - AC7: (a) credential-available / credential-unavailable の両ケースをモックした hermetic test により、
github_researchroute が前者でstatus: pass、後者でstatus: skipに到達しskipがpassへ昇格しないことを検証する。(b) 上記 (a) に加え、shell でGH_TOKEN/GITHUB_TOKENを明示的に unset した状態かつ authenticated な storedghcredential が利用可能な実行環境で実施した genuine live 実行の結果(token 値を含まない)をdocs/dev/agy-github-research-gh-token-provisioning.mdに記録する - AC8: 既存の Issue 実装: AGY が制約付き read-only gh を反復利用する github_research #1920 / PR 実装: AGY が制約付き read-only gh を反復利用する github_research #2000 由来の negative probe(AGY env からの token 排除、redaction-before-truncate、isolated
GH_CONFIG_DIR、streaming cap、timeout、deadline 等)を含め、test_agy_github_research_e2e.py/test_agy_github_research_contract.pyの既存テストがすべて変更後も pass する
Verification Commands
# AC1
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_broker_process_boundary.py::test_ac1_broker_is_invoked_as_real_subprocess -v# AC2
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_broker_process_boundary.py::test_ac2_parent_process_never_receives_or_forwards_raw_token -v# AC3
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.py::test_ac3_credential_bootstrap_pins_explicit_hostname -v# AC4
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.py::test_ac4_credential_bootstrap_failure_is_skip_not_pass -v# AC5
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.py::test_ac5_isolated_gh_config_dir_still_fresh_after_credential_bootstrap -v# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.py::test_ac6_bootstrap_token_never_appears_in_ipc_argv_stdout_stderr_or_artifact .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.py::test_ac6_secret_scanner_reports_zero_findings_on_changed_scripts -v# AC7
# baseline-expect: fail
$ test -f docs/dev/agy-github-research-gh-token-provisioning.md
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.py::test_ac7_live_credential_resolution_pass_vs_skip_distinction -v# AC8
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_e2e.py .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_contract.py -vAllowed Paths
.claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_e2e.py.claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_broker.py.claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_e2e.py.claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_contract.py.claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_broker_process_boundary.py.claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_credential_bootstrap.pydocs/dev/agy-github-research-gh-token-provisioning.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
GH_TOKENの値そのものを出力・記録する必要が生じた場合は直ちに停止し、値を伏せて報告する- true process boundary の実装が Allowed Paths 内の変更だけで完結できないと判明した場合(例: broker 実行に既存 5 ファイル以外の新規 helper module が本質的に必要になる場合)は、実装を進めず本 Issue へ差し戻す
Required Skills
- Python subprocess / 環境変数 semantics(parent-child process boundary、env inheritance の制御)
- GitHub CLI 認証(
gh auth token/gh auth login/ credential store /GH_CONFIG_DIR) - secret-boundary hermetic testing(token-shaped sentinel、redaction 検証)
Required Design References
.claude/skills/gemini-cli-headless-delegation/SKILL.md.claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_broker.py(既存executeCLI サブコマンド、_minimal_broker_env()、_isolated_gh_config_dir()、_redact()/_bounded_redacted()).claude/skills/gemini-cli-headless-delegation/scripts/run_agy_github_research_e2e.py(_preflight()、_scrubbed_probe_env()、_isolated_agy_env())
Runtime Verification Applicability
本 Issue の変更対象はワークフロー文書・スクリプトのみです。ゲームの実行時動作には影響しません。
decision: not_applicable
reason: "Workflow documentation and script changes only. No runtime game behavior changed."
Activity
squne121 commentedon Aug 8, 2026
判定
REQUEST_CHANGES。現状の Issue #2012 は、そのまま実装に入るべきではありません。最大の問題は、単なる
GH_TOKENprovisioning の不足ではなく、Issue #1920 / PR #2000 が主張する credential boundary と、現在の実装・#2012 の解決案が一致していないことです。さらに Acceptance Criteria と Verification Commands に複数の false-green があり、実装が安全性を退行させても Issue を完了できてしまいます。#2012 自体には現時点でコメントはありません。P0-1: 「broker が唯一の GH_TOKEN 保持プロセス」という不変条件が、現行実装ですでに成立していない
#2012 は Outcome/AC4 で、
を維持するとしています。ところが current main の
run_agy_github_research_e2e.pyはGH_TOKENをos.environから E2E Python process 自身で取得し、import run_agy_github_research_broker as brokerした同一プロセス内のbroker.execute_operation(..., gh_token=gh_token)に Python 文字列として渡しています。broker は独立 process ではありません。さらに broker は実際の
ghchild process を起動するとき、その環境にGH_TOKENを入れます。したがって literal に「唯一の process」とするならghprocess も例外になります。これは用語上だけの問題ではありません。PR #2000 では、かつて
agy --versionが親環境を継承して GH_TOKEN を意図せず受け取る実バグが発見され、scrubbed env に修正されています。credential の process-locality は実際に重要な security boundary です。したがって #2012 の二択のうち、
は「#1920 の security boundary を一切変更しない」と両立しません。
GitHub CLI 公式仕様でも
gh auth tokenは、保存済み credential を安全な opaque handle として返す API ではなく、token 値そのものを標準出力へ出すコマンドです。E2E がこれを capture すれば、E2E process memory に credential が materialize します。 ([GitHub CLI]1)Issue の実装前に、次のどちらかを明示的に選ぶ必要があります。
私は 2 を推奨します。
P0-2:
gh auth tokenを E2E に追加する案は credential exposure surface を拡大するgh auth statusが成功しているのにGH_TOKENが無いこと自体は GitHub CLI の異常ではありません。GitHub CLI は、
GH_TOKEN/GITHUB_TOKENによる環境変数認証gh auth loginで credential store に保存する認証を別経路として扱います。環境変数 credential は保存済み credential より優先されます。
GH_CONFIG_DIRも別の設定面です。 ([GitHub CLI]2)したがって #2012 の root cause は、
ではなく、
という contract mismatch と定義すべきです。
さらに
gh auth tokenは account/host の credential を取り出すので、最低でも--hostname github.comを固定すべきです。multi-account 環境で「現在 active な account」を暗黙に採用する設計も、再現性のある runtime evidence としては弱いです。 ([GitHub CLI]1)P0-3: Verification Commands が AC を証明しておらず、false-green が大量にある
ここは実装より先に直すべきです。現在の VC では安全性が壊れても PASS できます。
特に問題なのは以下です。
AC2
grep -n -e "gh auth token" -e GH_TOKEN run_agy_github_research_e2e.py現行ファイルは既に
GH_TOKENを扱うため、何も実装しなくても PASS します。AC4
grep -n "GH_TOKEN" run_agy_github_research_e2e.pyこれは「broker 以外が保持しない」を検証するどころか、E2E に
GH_TOKENが存在することを確認するだけです。AC6
AC は、
を要求していますが VC は、
test -f docs/dev/agy-github-research-gh-token-provisioning.mdだけです。
完全に無関係です。 空の documentation file を作るだけで AC6 が green になります。
AC3
も不十分です。リポジトリ自身の secret-related test は既に
github_pat_とghr_まで認識しています。さらに既存
secret_exposure_scanner.pyはgh[pousr]_...とgithub_pat_...を provider-aware rule として持ち、raw value を結果へ出さない設計になっています。新しい脆い prefix grep を定義するより、こちらを再利用する方が整合的です。P0-4: 「operator provisioning docs だけ」も、現状の AC では解決を証明できない
GitHub CLI 公式も headless/automation では
GH_TOKENの利用を案内しているため、operator provisioning 自体は技術的には妥当な選択肢です。 (GitHub CLI)ただし本件の場合は、
という propagation を証明する必要があります。
現在の Issue は「export する手順を書く」だけでも AC2 を満たせます。これでは、
のどれも検証できません。
しかも PR #2000 は、ambient
GH_TOKENが AGY probe に漏れた実績を既に持ちます。高い階層の agent environment に token を常設する設計は、攻撃面・事故面とも broker-local acquisition より広いです。推奨する設計
credential acquisition を real broker process に所有させるのが最も契約がきれいです。
ここで security invariant は、実装可能な形に修正します。
これなら PR #2000 の目的だった「AGY が token にアクセスできない」を維持しつつ、現行の「broker という module が唯一の process」という虚偽も除去できます。PR #2000 の operation table、repository binding、fresh
GH_CONFIG_DIR、streaming limits、redaction-before-truncate はそのまま維持できます。重要なのは、stored credential の解決と、実 research command の isolated
GH_CONFIG_DIRを別フェーズにすることです。gh auth loginの credential は secure credential store を使える一方、research command 側は PR #2000 の通り空のGH_CONFIG_DIRを使うべきです。 ([GitHub CLI]3)Acceptance Criteria はこう修正するべきです
少なくとも以下の水準にしてください。
Issue #1920 は credential unavailable を exit 77/SKIP にし、SKIP を PASS と扱わないことを既に重要な閉鎖条件としていました。この意味論は #2012 でも維持すべきです。
Verification Commands も置き換えるべきです
例えば最低限こうです。
# hermetic contract / credential-resolution tests uv run --locked pytest \ .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_e2e.py \ .claude/skills/gemini-cli-headless-delegation/tests/test_agy_github_research_contract.py \ -qE2E CLI は現在
--promptと--gh-token-envを受け、exit 77 を SKIP として返す実装なので、live VC は documentation の存在確認ではなくこの実経路を直接叩くべきです。secret check は既存 scanner を再利用できます。
PR コメント面も必要なら scanner が
--github-pr OWNER/REPO#Nをサポートしています。その他の P1 修正
change_kind: codeなのに AC2 は「docs-only でも完了可」になっているのも contract drift です。二択を残すなら machine-readable contract と一致させる必要があります。ただし今回のような security boundary では、実装担当者に「code か docs か好きな方」を選ばせず、refinement 時点で architecture decision を固定する方が安全です。また #1886 の runtime reliability gap は token だけではありません。別 Issue #2015 は Serena MCP timeout を独立した reliability gap として扱っています。#2012 の close を「Issue #1886 AC6 全体の解決」と解釈せず、
github_researchcredential prerequisite のみに限定してください。Required Skills: なしも適切ではありません。少なくとも Python subprocess/env semantics、GitHub CLI authentication、secret-boundary testing を扱う Issue です。skill-routing 用フィールドで実用上の意味があるなら、ここも実装内容と一致させるべきです。総括
Issue の切り出し方自体は妥当です。PR #2005 の runtime failure を #1886 の Allowed Paths に押し込まず、credential reliability を別 Issue にした判断は合理的です。PR #2005 のレビュー履歴でも runtime/environment failure が実際に繰り返し観測されています。
ただし #2012 の現在の契約は security invariant が自己矛盾しており、VC も主要 AC を証明していません。 特に
run_agy_github_research_e2e.pyにgh auth tokenを直接追加する実装は避けるべきです。最終推奨は
REQUEST_CHANGES/ 実装着手停止で、修正優先順位は、① credential trust boundary を正確に再定義 → ② broker-owned credential acquisition に一本化 → ③ false-green VC 全廃 → ④ env-unset genuine live E2E を close gate 化 → ⑤既存 secret scanner を再利用
です。これまでに #2000 で発生した secret inheritance regression と同型の事故を、#2012 で再導入する可能性をかなり下げられます。
squne121 commentedon Aug 8, 2026
issue-refinement-loop 終了報告(human_judgment_required)
対象 anchor comment: #2012 (comment)
実施内容
repair_issue_contract.pyが AC6 VC のbaseline-expect注釈欠落を検出。機械的修正(# baseline-expect: fail追加)を適用済み(issue-editor 経由、body sha25671880232...)。以降 preflight はSTATUS: pass/NEXT_ACTION: proceed。run_agy_github_research_e2e.py/run_agy_github_research_broker.py/ 既存テスト)に対して独立検証。主張は概ね正確と確認:os.environ.get()でGH_TOKENを自ら取得し、同一プロセス内でbroker.execute_operation(..., gh_token=...)を Python 文字列として呼んでいる(broker は独立 subprocess ではない)ghchild process 起動時にその環境へGH_TOKENを設定するgh auth tokenの出力仕様、GH_TOKEN/GITHUB_TOKENの precedence、GH_CONFIG_DIR、gh auth loginの credential store)を AGY grounded_research route で fact-check。2 回ともfailure_class: agy_web_grounding_no_citations(citation_count: 0)で fail-closed となり、WEB_RESEARCH_RESULT_V1はstatus: failedのまま。response_text 自体には claim ごとの verdict(4件 supported、1件 partially_supported=「--hostnameは必須ではなく optional」という overstatement 指摘)が含まれるが、citation が構造化されず quality gate を通過できないため、正式なstatus: okとしては扱えない。停止理由
references/web-research-routing.mdの routing rule により、status: failedかつcritical_external_claimsが存在する場合は human escalation が必須(orchestrator はこの routing-critical field を prose で再判定しない)。2 回の再試行でも同一の grounding quality gate 失敗(systemic、citation 未返却)となったため、Step 2 (review) 以降には進めていない。人間判断が必要な点
gemini-cli-headless-delegation側の tooling gap の可能性がある(本 loop の scope 外)。gh auth tokenの--hostnameは必須ではなく optional」という OWNER 主張への軽微な overstatement 指摘があるが、citation なしでは正式な事実確認として扱えない。次のアクション候補(人間判断待ち)
squne121 commentedon Aug 8, 2026
推奨は 「(c) をこの時点で人間判断として解決し、その判断を根拠に (a) へ進む」 です。(b) を #2012 の前提条件にはしません。
現行の停止自体はルールどおりです。
web-research-routing.mdはstatus: failedかつ critical external claims が残る場合に human escalation を要求しており、orchestrator に prose での再判定を禁止しています。したがって今回の停止は適切でした。ただし、人間判断後まで #2012 を止める必要はありません。リポジトリ実装を見ると、E2E runner は自分で
GH_TOKENを環境から取得し、broker モジュールを同一 Python process に import してgh_token=...を渡しています。一方 broker の説明は「broker だけが token を見る」としており、現在の process boundary と説明が一致していません。 これは #1920 / PR #2000 が意図していた token-owning broker 境界とも整合していません。また、GitHub CLI の外部仕様は公式ドキュメントから独立に確認できます。
gh auth tokenは認証 token を出力し、--hostname未指定時には default host が選ばれます。したがって 「--hostnameは CLI の必須引数」ではありません。一方、#2012 で--hostname github.comを明示固定するのは host/account の暗黙選択を避ける security/reproducibility 上の設計判断として妥当です。GH_TOKEN/GITHUB_TOKENは stored credential より優先され、gh auth loginは可能なら system credential store を使い、GH_CONFIG_DIRは gh の設定ディレクトリを制御します。 ([GitHub CLI]1)推奨判断
#2012 は rewrite を再開する。 ただし、単に現在の In Scope にある「
run_agy_github_research_e2e.pyからgh auth tokenを実行する」案を採用するのは避けるべきです。それでは E2E process 自身が token を Python string として保持し、まさに今回判明した P0-1 を温存します。目標境界は次の形が適切です。
ghexecution の唯一の token-owning process。gh auth token --hostname github.comを実行して credential を bootstrap。ghchild は、既存設計どおり private/emptyGH_CONFIG_DIRと runtime-onlyGH_TOKENを使う。特に credential bootstrap と research-command isolation を分ける必要があります。最初から空の
GH_CONFIG_DIRでgh auth tokenを実行すると、file-backed credential を参照できない構成があり得るためです。GH_CONFIG_DIRを固定する目的は既存 gh 設定を research command に持ち込まないことであり、stored credential を読み出す bootstrap 自体とは役割を分離した方が契約が明瞭です。GitHub CLI は credential store を利用し、GH_CONFIG_DIRは設定ディレクトリを制御するため、この境界をテストで固定するのが適切です。 (GitHub CLI)grounding の
citation_count: 0は 別 concern です。既存の #247 はまさに citation/evidence quality gate と retry/fallback 責務を扱っていましたが、すでに completed で close されています。 したがって今回と同じ現象が current main で再現するなら、#247 を再利用するのではなく、まず現在の実装との差分を dedupe したうえで「AGY response に citation が存在するのに structured citation として surface されない」という狭い runtime bug として別 Issue 化するのがよいです。ただし #2012 の blocker にはしません。以下をそのまま Claude Code / Codex CLI に渡すのを推奨します。
Issue #2012 の
issue-refinement-loopを、人間判断による escalation 解決を入力として再開してください。対象:
実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012 (comment)
実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012 (comment)
HUMAN_DECISION_V1
この HUMAN_DECISION_V1 は前回の
human_judgment_requiredに対する明示的な OWNER 判断として扱ってください。
同じ external claims を AGY web-researcher で再度解決しようとして
同一
agy_web_grounding_no_citationsloop を繰り返さないでください。canonical workflow が GitHub 上の anchor comment を要求する場合は、
この HUMAN_DECISION_V1 の意味を変更せず OWNER decision comment として
#2012 に materialize し、その canonical comment URL を新しい
anchor_comment_urlとして使用してください。generated handoff/comment を human provenance と偽装してはいけません。
1. Fresh readback / preflight
最初に current main と Issue #2012 の live state を再取得してください。
必須確認:
Issue 実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012 本文
OWNER anchor comment 5225022347
termination comment 5225079720
Issue 実装: AGY が制約付き read-only gh を反復利用する github_research #1920
PR 実装: AGY が制約付き read-only gh を反復利用する github_research #2000
Issue 実装: codebase-investigator / web-researcher の delegation request で AGY provider をメインルートにする #1886 / PR 実装: codebase-investigator/web-researcher を AGY-only provider route へ固定する #2005 の 実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012 起票根拠
current:
run_agy_github_research_e2e.pyrun_agy_github_research_broker.pytest_agy_github_research_e2e.pytest_agy_github_research_contract.pyissue-refinement-loopの current canonical contractsmain HEAD、Issue body hash、anchor body hash を新たに固定し、
stale な前回 artifact を authoritative input として再利用しないでください。
canonical
preflight.run.with_anchor/ trusted contract-update route が存在する場合は current repository contract に従って実行してください。
2. Issue #2012 を rewrite
Issue 本文を、少なくとも次の方向へ修正してください。
Current Validated Scope / Background
current implementation の事実を正確に記載すること。
run_agy_github_research_e2e.py自身が現在GH_TOKENを読む。current implementation に独立 broker process boundary はない。
execute_operation(..., gh_token=...)に token string を渡す。ghchild env にGH_TOKENを設定する。「broker が唯一の GH_TOKEN 保持 process」という表現は実装と不一致。
Outcome
Outcome は単なる「gh_token_unavailable を消す」ではなく、
次の security property が成立する状態に変更してください。
repository-bound
ghinvocation を所有する。token を表示して diagnostic しない。
ghinvocation では既存 実装: AGY が制約付き read-only gh を反復利用する github_research #1920/実装: AGY が制約付き read-only gh を反復利用する github_research #2000 のallowlist / repository binding / isolated GH_CONFIG_DIR /
timeout / byte cap / redaction invariants を維持する。
export GH_TOKEN=...しなくても、authenticated
ghcredential が利用可能な環境では live route が成立する。In Scope
true process boundary の実装に必要な最小変更を Issue contract に反映してください。
候補設計は:
gh auth token --hostname github.com相当でcredential を bootstrap する。
ghchild にのみ runtime env として token を渡す。既存
run_agy_github_research_broker.pyを executable 化するか、必要最小限の新規 entrypoint が必要かは current code を確認して決定してください。
重要:
「E2E process が
gh auth tokenを実行して stdout token を受け取り、その token を broker function に渡す」設計は P0-1 を解消しないため採用禁止です。
Credential bootstrap と GH_CONFIG_DIR
stored credential の bootstrap と research execution isolation を区別してください。
authenticated gh credential を broker 内部で取得するための段階。
取得済み runtime token を使い、
private/empty
GH_CONFIG_DIRと固定 repository/host binding の下でallowlisted
ghcommand を実行する段階。bootstrap credential を読むための context まで無条件に empty
GH_CONFIG_DIRへ切り替えて認証情報を自ら不可視化する設計にしないでください。ただし host global gh config/credential を research command の
behavioral configuration として継承してはいけません。
Out of Scope
最低限以下を明示してください。
.envや credential file の agent による探索・直接 parse3. Acceptance Criteria を behavioral contract に直す
現在の grep 中心 AC/VC をそのまま残さないでください。
最低限、次を acceptance として表現してください。
AC: true broker process boundary
テストが actual subprocess boundary を検証し、
broker module import + same-process function call を成功扱いしない。
AC: parent does not receive token
fake credential source / fake gh executable を使った hermetic test で、
ことを検証する。
token の値を assertion failure message に出力しないこと。
AC: explicit host binding
credential bootstrap は
github.comを明示的に pin する。--hostnameを「GitHub CLI の必須仕様」と説明せず、本 route の deterministic host-binding requirement として定義する。
AC: bootstrap failure
stored credential unavailable /
gh auth tokennonzero /empty token / malformed result の各ケースは PASS ではなく
structured fail/SKIP になる。
AC: GH_CONFIG_DIR isolation
credential bootstrap 完了後の research
ghcommand はprivate isolated
GH_CONFIG_DIRで実行され、ambient aliases/extensions/config に依存しない。
AC: token non-emission
token-shaped sentinel を用い、
に raw token が出ないことを検証する。
AC: live verification
shell で GH_TOKEN を明示 export していない状態かつ
ghauthenticated credential が利用可能な環境でrepository-bound github_research route を live 実行し、
genuine
status: passを確認する。credential unavailable の環境では SKIP を PASS と扱わない。
4. Verification Commands を修正
grep theatre / false-green VC を behavioral pytest へ置換してください。
新規テストを要求する VC は baseline で確実に fail し、
repository の VC policy に従って
# baseline-expect: failを付けてください。
既存テストファイルへ存在しない node id を指定して
pytest exit 5 を出すような noncanonical baseline を作らず、
repo の current pytest VC policy に従ってください。
少なくとも以下をテスト対象に含めること:
5. Allowed Paths を現実の設計に合わせる
true broker subprocess 化に新規 entrypoint/test が必要なら、
refinement の段階で Allowed Paths を必要最小限に更新してください。
ただし、実装都合だけで broad directory wildcard を追加しないでください。
Issue refinement と implementation を混ぜないこと。
このフェーズでは Issue contract を正しくすることが目的です。
6. Review loop
rewrite 後は fresh
issue-reviewerを実行し、OWNER P0-1〜P0-3 が本当に Issue contract へ反映されたかを
独立に adversarial review してください。
特に reviewer は以下を blocker としてください。
gh auth tokenstdout token が parent IPC を通る--hostnameを CLI mandatory と誤記しているreview verdict が needs-fix なら bounded loop policy に従って rewrite を続け、
approve まで進めてください。
7. Grounding tooling gap の扱い
#2012 の refinement を grounding fix 待ちにしないでください。
#2012 が review-approved になった後、current main を基準に:
agy_web_grounding_no_citationsWEB_RESEARCH_RESULT_V1.claims[].evidence[]への citation materializationについて既存 OPEN/CLOSED Issue を dedupe してください。
既存 issue の current contract で今回の再現をカバーしていない場合のみ、
narrow follow-up Issue を提案または起票してください。
候補 concern:
AGY grounded_research の response に citation が存在する場合でも structured citation/evidence surface が空になり web-researcher quality gate が systemic fail-closed する gapこれは #2012 の dependency にしないこと。
8. 停止条件
通常の refinement iteration に人間承認を要求しないでください。
ただし以下だけは停止してください。
deterministic に解決不能
architecture scope expansion が不可避
最終報告には最低限以下を含めてください。
このプロンプトで重要なのは、**「web research を無視して進めろ」ではなく、「human escalation で止まった外部 claim を一次資料確認済みの人間判断として解決し、canonical loop を fresh state から再開しろ」**としている点です。これなら現在の fail-closed routing を壊さず、同じ citation failure を再試行し続ける迷走も避けられます。前回の停止コメントでも、コード側 P0 は独立確認済みで、残った停止理由は grounding quality gate でした。
結論としては
c → a、grounding gap は非 blocking follow-up が最適です。 #2012 ではむしろ「動的 token 取得をどこで行うか」を厳密化し、same-process broker から actual broker subprocess への境界修正を Issue contract に要求するのが次の一手です。squne121 commentedon Aug 8, 2026
OWNER Decision(human_judgment_required 解決)
前回の human_judgment_required 終了報告(https://github.com/squne121/loop-protocol/issues/2012#issuecomment-5225079720)に対する、OWNER の明示的な判断です。issue-refinement-loop はこの内容を anchor comment として consume し、refinement を再開します。
この HUMAN_DECISION_V1 は、issue-refinement-loop の次回実行における
anchor_comment_urlとして本コメントの URL を使用することを想定しています。squne121 commentedon Aug 8, 2026
issue-refinement-loop 終了報告(approved)
HUMAN_DECISION_V1(#2012 (comment) )を入力として refinement を再開し、rewrite → adversarial review を1 iteration 実施した結果、
issue-reviewerの VERDICT がapprove、issue-contract-review(Final Gate)のCONTRACT_REVIEW_RESULT_V1.statusがgoに到達したためapprovedで終了する。実施内容
run_refinement_preflight.py --anchor-comment-url <上記>で preflightSTATUS: passを確認。external_spec_resolutionをそのまま採用した。required_security_directionに基づいて全面 rewrite(Current Validated Scope / Outcome / Background / In Scope / Out of Scope / Acceptance Criteria / Verification Commands / Allowed Paths を更新)。issue-reviewerによる adversarial review(1回目):VERDICT: needs-fix、9 blocker(すべて Verification Commands の構文・preflight allowlist 適合性の問題。設計・security boundary 面の adversarial review 10項目はすべて PASS)。test_agy_github_research_broker_process_boundary.py/test_agy_github_research_credential_bootstrap.pyへの分離、secret scanner の pytest 化、live 実行 VC を doc-based evidence 記録へ変更、Allowed Paths に新規テストファイル2件を追加)。issue-reviewerによる adversarial review(2回目):VERDICT: approve、blocker 0。run_contract_review_once.py --mode executeでCONTRACT_REVIEW_RESULT_V1.status: go(readiness_status: go,vc_preflight_status: pass)を確認。agy_web_grounding_no_citations)の dedupe を実施。既存 OPEN Issue に一致するものがなかったため、narrow follow-up Issue 調査: web-researcher の citation_count 0 fail-closed root cause を特定する #2034(調査: web-researcher の citation_count 0 fail-closed root cause を特定する #2034 、issue_kind: research)を起票。実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012 の dependency にはしていない。P0-1 / P0-2 / P0-3 の反映先
## Current Validated Scopeに same-process import の事実を明記。## Outcome1〜4 で E2E/AGY いずれも token を保持しない・broker が実 subprocess として credential resolution を所有する、と明文化。gh auth tokenの E2E 実行禁止):## Out of Scopeに「E2E/orchestrator process がgh auth tokenを実行して stdout の token を受け取る設計」を明示的に禁止事項として記載。## Verification Commandsを grep から behavioral pytest(新規2ファイル)+secret_exposure_scanner.scan_file()へ全面置換。rewritten AC/VC 一覧
AC1(broker subprocess boundary)/ AC2(parent が token を受け取らない)/ AC3(
--hostname明示 pin)/ AC4(bootstrap failure は SKIP)/ AC5(GH_CONFIG_DIRisolation 維持)/ AC6(token 非出現、hermetic test + secret scanner)/ AC7(pass/skip 判定の hermetic test + doc evidence)/ AC8(既存 #1920/#2000 regression 全 pass)。対応する VC はすべてuv run --locked pytest <新規または既存テストファイル>::<test名>形式(未実装分は# baseline-expect: fail)。false-green VC 除去の証跡
baseline_vc_preflight.py実行結果ですべてdecision: go(新規テスト参照は exit_code 4 /expected_baseline_fail、既存 regression テストは exit_code 0 /regression_gate)。grep ベースの false-green VC は本文に残っていない。final issue-reviewer verdict
VERDICT: approve(2回目)、BLOCKERS: 0、REVIEWED_BODY_SHA256: sha256:3a0830fc40781518f00eb3d1e61dd6ac831c10fa4598d246d21df768a02fd746(現在の live body と一致することを独立確認済み)。unresolved risks
agy_web_grounding_no_citations(AGY grounded_research が response に evidence を含みながら structured citation を返さない gap)は Issue 実装: AGY github_research route の GH_TOKEN provisioning gap を解消する #2012 内では未解決のまま。人間が一次資料で外部仕様を確認しexternal_spec_resolutionとして記録することで非 blocking 化した。follow-up Issue 調査: web-researcher の citation_count 0 fail-closed root cause を特定する #2034 で別途調査する。GH_CONFIG_DIRの関係は AC5 で isolation 維持を要求しているが、bootstrap 自体の実行 context(isolatedGH_CONFIG_DIRの外か内か)の詳細実装判断は implementation phase に委ねられている(Issue 本文は境界条件のみを規定)。実装移行状態
implementation_ready。impl-review-loopへ handoff可能。squne121 commentedon Aug 8, 2026
implement-issue: 実装完了 (2026-08-08T09:02:20Z)
.claude/worktrees/issue-2012-gh-token-broker-subprocessworktree-issue-2012-gh-token-broker-subprocess014d50b9test_agy_github_research_broker_process_boundary.py4件 /test_agy_github_research_credential_bootstrap.py8件 / 既存test_agy_github_research_e2e.py+test_agy_github_research_contract.py113件、ruff findings 0)docs/dev/agy-github-research-gh-token-provisioning.md)squne121 commentedon Aug 8, 2026
impl-review-loop: 完了 (2026-08-08T18:35:00Z)
Live mergeability に関する重要な注記
gh pr viewの live 状態はmergeable: MERGEABLE/merge_state_status: UNSTABLEです。required CI(build/lint/python-test/test/typecheck/validate-generated-artifact)は全て pass、
Allowed Paths gate も
status: ok、実 Git conflict はありません。UNSTABLE の原因は non-required の
component-vrt-reportjob の fail のみで、このジョブは本 PR の diff(Allowed Paths 7ファイルのみ)と無関係(VRT/component 関連ファイルは変更していない)
であることを
gh pr diff --name-onlyで確認済みです。branch protection の required_status_checks にも含まれていません。この状態は本 Issue のスコープ内では修正できません(該当ジョブの Allowed Paths 外)。
component-vrt-reportの要否を別途判断)→ マージ → post-merge-cleanupsqune121 commentedon Aug 8, 2026
impl-review-loop: 完了 (2026-08-08T21:42:00Z)
対応した追加指摘(PR #2036 コメント https://github.com/squne121/loop-protocol/pull/2036#issuecomment-5225975575)
env=Noneによる ambient GH_TOKEN 漏洩)→_scrubbed_broker_subprocess_env()で明示的な最小 env を渡すよう修正denyに縮退し PASS へ昇格し得る欠陥 →BrokerDeniedを type 分離し、policy_denied以外は必ずroute_failure_classを立ててstatus: failにするよう修正ghprocess の孤児化 → 単一 deadline +Popen(start_new_session=True)+ process-group cleanup へ修正GH_TOKEN/GITHUB_TOKEN/stored credential の precedence・provenance 不整合 → 明示的なGH_TOKEN > GITHUB_TOKEN > stored_credentialprecedence +credential_source(internal-only、schema 非拡張)を追加status == "pass"assert・timeout branch test・7ファイル全カバーへ修正修正は独立検証済み(AC1-AC8 全 pass、136テスト pass、ruff clean、Allowed Paths 完全一致、コード読解で env scrub / route_failure_class 算出 / credential precedence の実装を直接追跡確認)。
実装: AGY github_research の broker を真の subprocess 境界にし GH_TOKEN provisi…