Skip to content

実装: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2158

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "2154"
goal_ref: "Anthropic subscription と ChatGPT Pro Codex subscription を独立 runtime として並列運用できる claude-gpt launcher を bootstrap し、現行ユーザーのまま worktree 上で runtime を実機確認する"
change_kind: feature

Parent Issue

#2154

Parent Goal Ref

  • Goal: Claude Code を共通 development harness とし、Anthropic subscription と ChatGPT Pro Codex subscription を独立 runtime として並列運用できる状態へ移行し、Codex CLI 実行系を段階的に廃止する。
  • Desired Destination: Native Claude(Anthropic subscription)と claude-gpt(ChatGPT Pro Codex subscription 経由 GPT-5.6 Sol/Terra/Luna)が、同一 repository・共通 .claude/agents/ .claude/skills/ を使いながら、config root・credential・working tree を分離した状態で並列稼働する。

Scope Reframe(2026-08-15, OWNER 判断)

本 Issue は個人趣味開発の Phase 1 実装であり、以下を OWNER の最新 authority として反映する(https://github.com/squne121/loop-protocol/pull/2162#issuecomment-5299336551):

  • raine/claude-code-proxy は通常の現行 Unix user・root 権限なしで利用できる(upstream 確認済み)。
  • dedicated Unix user・useradd・sudoers provisioning・root 権限での proxy 起動は Phase 1 の必須要件ではない。
  • Claude Code から起動される任意 subprocess(Bash tool 経由の python3/node 等)が、同一 Unix user が所有する credential を完全に秘匿できることは Phase 1 の non-goal であり、同一ユーザー内での local-user trust boundary を Phase 1 の accepted trust boundary とする。
  • permissions.deny の Read(//...) は、Claude Code 組み込み tool(Read 等)に対する best-effort な軽量防御として維持するが、「これにより arbitrary Bash subprocess から credential が安全になる」とは主張しない。
  • sandbox.enabled / CLAUDE_CODE_SUBPROCESS_ENV_SCRUB の OS-level sandbox hardening は Phase 1 の merge 条件から除外し、実装しない(ネストした sandbox 実行環境下で Bash tool を破壊することが Issue 実装: claude-gpt launcher の sandbox hardening 既定有効化可否を実機検証する #2173 の実機検証で判明したため)。
  • 一方で、credential を repository に保存しない・credential 内容をログや GitHub evidence に出さない・proxy を不必要に外部公開しない、という基本安全性は維持する。

Current Validated Scope

Remaining Parent Gaps

Outcome

repository-owned claude-gpt launcher(scripts/claude-gpt/ 配下)が追加され、現行ユーザーのまま CLAUDE_CONFIG_DIR / proxy 設定・認証・state ディレクトリの分離(canonical path 検証込み)・raine/claude-code-proxy 向け環境変数の allowlist 起動・GPT-5.6 モデルエイリアスマッピング・strict MCP 除外・PID 所有権付き loopback bind preflight・ChatGPT subscription 認証 preflight を実装したコミットが作成され、runtime smoke test(live 環境で worktree を cwd として claude-gpt launcher を起動し、実際に ChatGPT Pro backend の GPT モデルへ request を送り、Bash tool と Task/SubAgent を最低 1 回動作させ、応答・provider/model evidence・cleanup を確認する)を含む Draft PR が作成された状態。

Child 2(#2160)・Child 3(#2161)は起票済みであり、Parent #2154 の Child Issues / Remaining Parent Gaps / Phase Handoff Contract が実態(Phase 1 の PASS 状況)と整合している状態まで確認・必要なら同期されていること。Phase 2 / Phase 3 の repository 実装は行わない。

Runtime Verification Applicability

  • decision: immediate
  • reason: AC1〜AC7 は live 環境で claude-gpt launcher を worktree cwd から実際に起動し、ChatGPT subscription authentication・model/provider resolution・実際のプロンプト応答・Bash tool・Task/SubAgent を実機確認するため、静的検証(typecheck / lint / grep)だけでは検証が完結しない。
  • applicable_acs: AC1, AC2, AC3, AC4, AC5, AC6, AC7, AC10
  • execution_environment: raine/claude-code-proxy が起動可能かつ ChatGPT subscription 認証が利用可能な live 環境(開発者ローカルの現行ユーザー、または同等の worktree)
  • skip_conditions: raine/claude-code-proxy が利用不能、または ChatGPT subscription 認証が利用不能な場合。この場合 runtime smoke test は exit code 77 で SKIP を返す。
  • fallback_policy: SKIP(exit 77)を PASS へ昇格しない。SKIP はそのまま SKIP として記録し、Draft PR には SKIP 理由を明記する。fallback 実行や擬似成功判定は行わない。bounded retry / timeout は許容するが、LLM の非決定性を完全に排除するための複雑な validation framework は追加しない。
  • artifact_requirements: runtime smoke test の実行ログ(provider/model resolution・text response・Bash tool・Task/SubAgent 実行確認・cleanup 確認の出力)を Draft PR に証跡として添付する。証跡に credential・OAuth token・prompt 全文・tool 入出力全文を含めない。
applicable_acs: AC1, AC2, AC3, AC4, AC5, AC6, AC7, AC10
execution_environment: raine/claude-code-proxy が起動可能かつ ChatGPT subscription 認証が利用可能な live 環境(現行ユーザー)
skip_conditions: raine/claude-code-proxy または ChatGPT subscription 認証が利用不能な場合、exit code 77 で SKIP
fallback_policy: SKIP を PASS へ昇格しない。fallback 実行や擬似成功判定は行わない
artifact_requirements: runtime smoke test 実行ログ(credential・token・prompt/tool 全文は含めない)を Draft PR に添付

In Scope

  • scripts/claude-gpt/ 配下に repository-owned claude-gpt launcher スクリプトを追加する。実装は scripts/CLAUDE.md の不変条件(外部ライブラリ依存ゼロ・Shell は POSIX 準拠・破壊的処理は dry-run 実装・構造化 YAML/JSON 出力)に従う。launcher は root/sudo を要求せず、現行 Unix user のまま起動できる。
  • launcher が以下を設定することを実装する:
    • CLAUDE_CONFIG_DIR を Claude Code 専用の GPT ディレクトリ(例: $HOME/.claude-gpt/claude)に分離する(Native Claude 用 config との混同防止)。
    • raine/claude-code-proxy の設定・認証・state ディレクトリ(CCP_CONFIG_DIR / XDG_STATE_HOME 相当)を、CLAUDE_CONFIG_DIR とは独立した GPT 専用ディレクトリ(例: $HOME/.claude-gpt/proxy-config / $HOME/.claude-gpt/state)へ、現行ユーザーの HOME 配下で分離する。
    • 上記ディレクトリの canonical path(symlink 解決後)が repository root 配下または worktree 配下でないことを preflight で拒否する。
    • ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN を raine/claude-code-proxy の loopback listener 向けに設定する。
    • ANTHROPIC_MODEL と ANTHROPIC_DEFAULT_OPUS_MODEL / ANTHROPIC_DEFAULT_SONNET_MODEL / ANTHROPIC_DEFAULT_HAIKU_MODEL を、それぞれ gpt-5.6-terra[1m] / gpt-5.6-sol[1m] / gpt-5.6-terra[1m] / gpt-5.6-luna[1m] にマッピングし、ANTHROPIC_SMALL_FAST_MODEL を gpt-5.6-luna[1m] に明示設定する。[1m] suffixはupstream raine/claude-code-proxy の推奨設定(Claude Code側のlocal context判定を拡張するhint。proxyがupstream送信前にsuffixを除去する)であり、CLAUDE_CODE_AUTO_COMPACT_WINDOW を 272000(固定値)に設定することとセットで、Claude Codeが未知モデルとしてcontext上限を200kに誤認しauto-compactが早期破綻する事象(2026-08-15 OWNER実機確認)を防ぐ。
    • CLAUDE_CODE_SUBAGENT_MODEL を unset にする。
    • proxy を起動する子プロセスの環境変数を launcher が明示的に組み立てた allowlist のみへ限定する(親 shell から継承した CCP_* / HTTP_PROXY / HTTPS_PROXY / ALL_PROXY 系の値をそのまま proxy へ引き渡さない)。現行ユーザーのまま env -i 相当で起動する。
    • strict MCP mode(repository/user MCP を読み込まない)を有効化する設定を行う。
  • launcher 起動前 preflight として、launcher 自身が spawn した proxy プロセスの PID を保持し、その PID が所有する listen socket の bind アドレスが厳密に 127.0.0.1(または明示許可した loopback アドレス)であることを確認するチェックを実装する。
  • launcher 起動前 preflight として、ChatGPT subscription 認証状態を確認するチェックを実装する。
  • credential・OAuth token・proxy state を repository へ保存しないことを保証する実装にする(.gitignore 対象化含む)。credential 内容を runtime evidence・ログ・GitHub コメントへ出力しない。
  • permissions.deny の Read(//...) を、Claude Code 組み込み tool に対する best-effort の軽量防御として設定する(OS レベルの隔離を主張しない。実装・運用コストが増える dedicated user・OS sandbox 等は追加しない)。
  • launcher が supervisor pattern(exec を使わずバックグラウンド起動 + signal forwarding + wait + 全終了経路での cleanup)で proxy プロセスを管理し、launcher 終了時に proxy を確実に停止する。
  • runtime smoke test スクリプト(scripts/claude-gpt/ 配下)を追加し、raine/claude-code-proxy が利用可能な live 環境で、worktree を cwd として実際に launcher を起動し、ChatGPT subscription authentication・model/provider resolution・実プロンプト応答・Bash tool 実行・Task/SubAgent 実行・proxy cleanup を確認する。
  • raine/claude-code-proxy または ChatGPT subscription 認証が利用不能な環境では、runtime smoke test を exit code 77 で SKIP とし、SKIP を PASS に昇格しない。
  • Phase 1 runtime verification が PASS している状態を前提に、Child 2(実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160)・Child 3(実装: retire Codex CLI assets and documentation(Phase 3, Child 3 of #2154) #2161)・Parent 導入: Codex CLI 実行系を廃止し Claude Code dual-subscription runtime へ移行する #2154 の記載が実態と整合しているか確認し、必要なら Parent 導入: Codex CLI 実行系を廃止し Claude Code dual-subscription runtime へ移行する #2154 を最小限更新する。

Phase Handoff / GitHub Delivery Contract

Phase handoff は Phase 1 runtime verification の PASS を前提とする。exit 77 の SKIP、未検証、部分 PASS では #2154 を「Phase 1 gate 通過済み」と更新しない。

Child 2(#2160)・Child 3(#2161)は既に起票済みのため、本 Issue では新規起票を行わない。Phase 1 runtime verification が PASS したら、Parent #2154 の Child Issues / Remaining Parent Gaps / Phase Handoff Contract が実態(Phase 1 PASS)と整合しているかを確認し、乖離があれば最小限の更新を行う。

Out of Scope

  • Child 2(実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160)・Child 3(実装: retire Codex CLI assets and documentation(Phase 3, Child 3 of #2154) #2161)の repository 実装。
  • raine/claude-code-proxy 自体の実装・fork(upstream 管理下の依存として利用するのみ)。
  • herdr session 分離の一般的な仕組み自体の変更(既存の .claude/worktrees/issue-<number>-<slug>/ 規約はそのまま前提として使う)。
  • Codex CLI runtime の削除(本 Phase では fallback として残す)。
  • raine/claude-code-proxy / OpenAI ChatGPT subscription の利用規約上のリスク評価そのもの(credential 共有・rate limit 回避・resale/shared-service 該当性の最終判断)。これは repository owner の human decision gate として扱う。
  • proxy / Claude Code の exact version pin・binary hash 検証・rollback 手順の恒久運用ポリシー化。
  • dedicated Unix user・root/sudo/useradd/sudoers による OS-level credential isolation の実装・検証(Scope Reframe により Phase 1 の non-goal)。
  • sandbox.enabled / CLAUDE_CODE_SUBPROCESS_ENV_SCRUB による OS-level sandbox hardening の必須化(opt-in・必須いずれも実装しない。Issue 実装: claude-gpt launcher の sandbox hardening 既定有効化可否を実機検証する #2173 の実機検証でネスト環境下の Bash tool 破壊が判明したため)。
  • Claude Code から起動される任意 subprocess に対する credential exfiltration adversarial matrix の網羅的検証。

Acceptance Criteria

  • AC1: 通常の現行 Unix user のまま、root/sudo/useradd を一切使わずに claude-gpt launcher を起動できる。
  • AC2: worktree directory を cwd として claude-gpt launcher が正常に起動できる(CLAUDE_CONFIG_DIR / proxy 設定・認証・state ディレクトリの分離を含む)。
  • AC3: ChatGPT subscription authentication を利用して proxy への request が成功する(loopback bind preflight・認証 preflight を含む)。
  • AC4: 設定した GPT model alias(gpt-5.6-sol[1m]/terra[1m]/luna[1m])が利用可能で、実際の request で使用された provider/model(upstream送信時は[1m] suffix除去後の実model ID)を evidence として確認できる。実際のinteractiveセッションでSkillロード・SubAgent起動を伴う操作を行ってもContext limit reached/automatic compaction failed/unknown-model warningが発生しないことを含む。
  • AC5: launcher 経由で起動した Claude Code から通常のテキスト応答が返る。
  • AC6: launcher 経由で起動した Claude Code で Bash tool が最低 1 回正常に実行できる。
  • AC7: launcher 経由で起動した Claude Code で Task/SubAgent が最低 1 回正常に実行できる。
  • AC8: strict MCP mode により repository/user MCP の意図しない混入が発生しない設定になっている。
  • AC9: credential・OAuth token・proxy state が repository/worktree または runtime evidence(ログ・GitHub コメント)に保存・出力されない(.gitignore 等での除外を含む)。
  • AC10: launcher が起動した proxy が launcher 終了後に通常 cleanup される(PID/listen socket の残留なし)。
  • AC11: Child 2(実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160)・Child 3(実装: retire Codex CLI assets and documentation(Phase 3, Child 3 of #2154) #2161)・Parent 導入: Codex CLI 実行系を廃止し Claude Code dual-subscription runtime へ移行する #2154 の Phase handoff 記載が、本 Issue の Phase 1 runtime verification 結果と整合している。

Verification Commands

# AC1
# baseline-expect: fail
$ rg -n "CLAUDE_CONFIG_DIR" scripts/claude-gpt
# AC2
# baseline-expect: fail
$ test -f scripts/claude-gpt/launch.sh
# AC3
# baseline-expect: fail
$ rg -n "127.0.0.1" scripts/claude-gpt
# AC4
# baseline-expect: fail
$ rg -n "gpt-5.6-sol" scripts/claude-gpt
# AC5
# baseline-expect: fail
$ test -f scripts/claude-gpt/runtime_smoke_test.sh
# AC6
# baseline-expect: fail
$ rg -n -e bash_tool -e BASH_MARKER -e "bash tool" scripts/claude-gpt/runtime_smoke_test.sh
# AC7
# baseline-expect: fail
$ rg -n -e subagent -e SUBAGENT_MARKER -e SubAgent scripts/claude-gpt/runtime_smoke_test.sh
# AC8
# baseline-expect: fail
$ rg -n -e strict_mcp -e strict-mcp-config scripts/claude-gpt
# AC9
# baseline-expect: fail
$ rg -n "claude-gpt" .gitignore
# AC10
# baseline-expect: fail
$ rg -n -e cleanup -e trap scripts/claude-gpt/launch.sh
# AC11
# baseline-expect: pass
$ gh issue view 2154 --repo squne121/loop-protocol --json body,url

Allowed Paths

Repository file change の Allowed Paths:

  • scripts/claude-gpt/
  • .gitignore

GitHub control-plane write は repository file path 変更とは別枠として、以下のみ許可する:

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • dedicated Unix user・root/sudo/useradd/sudoers が実際に必要と判明した場合(本 Issue のスコープでは導入しない。判明した場合は実装自体が過剰でないか見直す)
  • GPT backend 利用に OpenAI API metered billing が必須と判明した場合
  • ChatGPT subscription auth では GPT-5.6 required models を利用できない場合
  • Claude Code custom SubAgent が proxy 経由で tool execution または continuation を保持できない場合
  • model alias routing または effort routing を実 runtime で検証できない場合
  • GPT profile から MCP を除外できない場合
  • proxy 利用に credential 本文を repository へ保存する必要が生じた場合
  • listener を loopback 外へ公開する必要が生じた場合
  • raine/claude-code-proxy / ChatGPT subscription の利用規約上、credential 共有・rate limit 回避・resale/shared-service に該当しうる運用が本 launcher に必須と判明した場合

Required Skills

なし

Required Design References

Delivery Rule

1 Issue = 1 PR で repository implementation を完結させる。dedicated worktree で作業し、Draft PR をデフォルトとする。PR #2162(既存 branch)を継続利用する。

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 14, 2026
  2. squne121 commented on Aug 14, 2026

    @squne121
    OwnerAuthor

    you asked

    message time: 2026-08-14 18:44:59

    #2158
    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


    chatgpt response

    Issue #2158から本文・コメント・関連Issue/PR・実装資産・履歴・テスト/CI契約を突き合わせ、外部一次仕様とも照合します。重大度順に、再現可能な破綻条件・見落とされやすい境界条件・必要な修正を敵対的に整理します。


    chatgpt response

    初期確認では、Allowed PathsとAC5が矛盾し、runtime verificationの適用宣言も欠落しています。さらにRV観点の縮退、共有settings由来の権限分離不足、OPENな関連Issueとの運用依存も追跡します。


    chatgpt response

    外部実装照合では、設定・資格情報・状態保存の三層分離不足に加え、役割別model aliasが一律subagent環境変数で上書きされる重大矛盾を確認しました。さらにbind露出検証とeffort/fallback契約も不足しています。


    chatgpt response

    敵対的レビュー結果

    判定

    REQUEST_CHANGES — 現状のIssue契約では実装着手不可です。

    採用している「Claude Codeを共通ハーネスとし、Anthropic系とChatGPT Pro/Codex系をプロセス・設定ごと分離する」という方向自体は妥当です。しかし、Issue #2158には次の問題があります。

    • ACとAllowed Pathsが自己矛盾している
    • OAuth資格情報が「Git管理外」であるだけで、Claude Codeから隔離されていない
    • loopback-only判定がfalse positiveを許す
    • proxyの所有権、同時起動、古いプロセスへの誤接続が未定義
    • MCP、モデルalias、effort、continuationの検証方法が証明になっていない
    • リポジトリのruntime-verification契約とscripts配下契約を満たしていない
    • 配布物のversion pin、実行バイナリ同定、rollback契約がない

    このまま実装すると、「canaryはPASSしたが、実際には資格情報が読める、外部公開されている、別バージョンのproxyにつながっている、effortが送られていない」という状態を許します。


    P0:実装前に修正必須

    P0-1. AC5とAllowed Pathsが同時に満たせない

    AC5は、OAuth情報・proxy state・資格情報をGit管理対象にしないことと、.gitignoreによる除外を要求しています。一方、Allowed Pathsは scripts/claude-gpt/だけに限定され、範囲外変更は停止条件です。したがって、.gitignoreを変更するとscope違反、変更しなければAC5不達になります。

    これは文言上の軽微な問題ではなく、実装者がどの選択をしてもIssueを完了できない契約矛盾です。

    修正は次のいずれかが必要です。

    1. Allowed Pathsへ.gitignoreを追加する
    2. .gitignore変更をACから外し、既存パターンで除外できる配置へ固定する
    3. .gitignoreとは別に、canonical path、symlink、git check-ignore、git ls-filesを検証する

    なお、現在の.gitignoreには.claude/settings.local.json等はありますが、~/.claude-gpt相当のrepo-local誤配置を明示的に拒否する契約はありません。


    P0-2. 「repo外に置く」はOAuth資格情報の隔離にならない

    claude-code-proxyのCodex認証情報にはaccess tokenとrefresh tokenが含まれます。Linux/WSL2ではmacOS Keychainではなくファイルストアが使われ、JSONファイルはmode 0600、ディレクトリは0700で保存されます。

    しかし、0600は別ユーザーからの保護であり、同じUnixユーザーで動くClaude CodeのBash toolからの保護ではありません。さらに、Claude Codeのsandboxは、明示的にdenyReadを設定しない限り、原則としてコンピューター上のファイルを読み取り可能です。公式ドキュメントも、home全体をdenyし、projectだけをallowする構成と、sandboxが利用不能な場合にhard failするfailIfUnavailableを説明しています。 (Claude)

    したがって、次の攻撃が成立します。

    悪意あるリポジトリ文書・Issue・依存コード
      → prompt injection
      → Bash tool
      → ~/.claude-gpt/proxy-config/.../auth.json を読む
      → refresh tokenを外部送信
    

    .gitignoreはこの攻撃に一切効きません。

    最低限、launcherはsession-scoped settingsとして次を強制すべきです。

    • sandbox有効
    • sandbox.failIfUnavailable: true
    • proxyのCCP_CONFIG_DIRとXDG_STATE_HOMEをdenyRead
    • より強くするならhome全体をdenyReadし、対象worktreeのみallowRead
    • 実効設定でproxy credential pathが再許可されていないことをpreflightで検査
    • Claude CodeのBashからdecoy credentialを読ませ、必ず拒否されるlive canary
    • 資格情報値、account ID、refresh tokenをartifactに出力しない

    より強い境界が必要なら、proxyをClaude Codeとは別のUnixユーザーまたは隔離serviceで動かすべきです。ただし、listener自体にclient authenticationがないため、別ユーザー化だけではlocal processによるquota消費までは防げません。


    P0-3. loopback確認がfalse positiveを許す

    Issueは「127.0.0.1へcurlできること」をloopback-onlyの検証にしています。しかし、0.0.0.0:PORTでlistenしていても、127.0.0.1:PORTへのcurlは成功します。

    さらに、proxyはCCP_BIND_ADDRESSや設定ファイルでbind addressを上書きできます。/healthz、/v1/models、/v1/messages等は同じlistenerにあり、client authentication middlewareはありません。

    上流自身も、incoming clientは未認証であり、非loopback公開は外部firewallまたは認証proxyを必要とすると明記しています。露出したlistenerはsubscription credentialとquota消費能力を露出するのと同等です。

    必要な検証はcurlではなく、次です。

    1. launcher自身がproxy processをspawnする
    2. PIDを保持する
    3. そのPIDが所有するlisten socketを検査する
    4. local addressが厳密に127.0.0.1または明示許可したloopback IPv6のみであることを確認する
    5. 0.0.0.0、::、WSL側Ethernet addressを拒否する
    6. 古いPID、別バイナリ、別ユーザーのprocessならattachしない
    7. 異常終了時もtrapで子processを回収する

    固定portを使う場合は、portへの接続成功だけで既存proxyを信用してはいけません。PID、実行ファイルpath、version、binary SHA-256、effective config digestを一致させる必要があります。


    P0-4. 分離対象がCLAUDE_CONFIG_DIRだけでは不足する

    CLAUDE_CONFIG_DIRはClaude Code側の設定、履歴、plugin等を分離するものです。proxyの設定とfile-backed authはCCP_CONFIG_DIR、ログ等のstateはXDG_STATE_HOMEで管理されます。CCP_CONFIG_DIRはstate directoryを移動しません。 (Claude)

    Issue #2158は主としてCLAUDE_CONFIG_DIR=~/.claude-gptだけを指定しているため、次が未定義です。

    • proxy認証ファイルの配置
    • proxy configの配置
    • state/log/traffic captureの配置
    • 複数profile間の共有可否
    • worktree内やrepo内への誤配置拒否
    • symlink経由でrepo内へ戻るケース
    • directory/file permissions
    • rollback時に削除または維持する範囲

    少なくとも次の3階層に分けるべきです。

    CLAUDE_CONFIG_DIR="$HOME/.claude-gpt/claude"
    CCP_CONFIG_DIR="$HOME/.claude-gpt/proxy-config"
    XDG_STATE_HOME="$HOME/.claude-gpt/state"

    preflightでは、文字列比較ではなくrealpath後のcanonical pathを検証し、以下を拒否する必要があります。

    • repository root配下
    • worktree配下
    • symlinkを解決するとrepositoryへ入るpath
    • group/world readableなcredential directory
    • 相対path
    • literalな未展開~

    P0-5. 環境変数の継承により、別endpoint・別modelへ静かに接続できる

    proxy設定は環境変数、config file、built-in defaultの順で解決され、serve --portはさらに強い優先順位を持ちます。また、次の変数でendpoint、model、effort、transport、traffic logging等を変更できます。

    • CCP_CODEX_BASE_URL
    • CCP_CODEX_MODEL
    • CCP_CODEX_EFFORT
    • CCP_CODEX_TRANSPORT
    • CCP_BIND_ADDRESS
    • PORT
    • CCP_TRAFFIC_LOG
    • CCP_LOG_VERBOSE
    • HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY

    現在のACでは、親shellからこれらが継承されても、launcherが期待するChatGPT Codex endpointやmodelを使った証明になりません。

    launcherは「必要変数を追加する」のではなく、明示的な環境allowlistからproxyを起動するべきです。企業proxy等を継承する必要がある場合も、予期しない値をそのまま許すのではなく、許容値を明示し、effective configurationをartifactへ記録する必要があります。


    P0-6. main model、alias、effort、continuationの契約が不足している

    Parent #2154は、mainをTerra、Opus aliasをSol、Sonnet aliasをTerra、Haiku aliasをLunaとしています。Issue #2158はmapping変数を列挙していますが、ANTHROPIC_MODELの最終値が明示されていません。

    最低限、起動時環境は次のように固定する必要があります。

    ANTHROPIC_MODEL=gpt-5.6-terra
    ANTHROPIC_DEFAULT_OPUS_MODEL=gpt-5.6-sol
    ANTHROPIC_DEFAULT_SONNET_MODEL=gpt-5.6-terra
    ANTHROPIC_DEFAULT_HAIKU_MODEL=gpt-5.6-luna
    
    CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1
    CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
    CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1
    CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1
    
    unset CLAUDE_CODE_SUBAGENT_MODEL

    特に次の点が欠落しています。

    effort

    Claude Codeはcustom model IDやgateway使用時、CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1を設定しなければeffortを常に送るとは限りません。 (Claude)

    非streaming fallback

    CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1がない場合、stream障害後のfallbackがtoolの二重実行を発生させる可能性があります。 (Claude)

    continuation

    claude-code-proxyのprevious_response_id continuationは既定で無効です。CCP_CODEX_PREVIOUS_RESPONSE_ID=1を明示しなければ、Issueが要求するcontinuation検証の前提自体が成立しません。また、このstateはprocess memory上にあり、proxy再起動で失われます。

    したがって、continuationのACは少なくとも次に分ける必要があります。

    • 同一proxy process・同一Claude session IDで継続する
    • subagentごとのstateが混線しない
    • fresh session IDでは継続しない
    • proxy restart後のstate喪失は「仕様上の期待値」か「失敗」か
    • Herdr tab復元時にどの状態まで復元するか

    P0-7. strict MCPではplugin、hook、project settingsを排除できない

    Claude Codeの--strict-mcp-configは、明示されたMCP configuration以外を読み込ませないためのオプションです。hook、plugin、skills、project settings、CLAUDE.md等を無効化するオプションではありません。customization全体を排除する境界には--bare等が別途存在します。 (Claude Platform Docs)

    実際、このrepositoryの.claude/settings.jsonには多数のhookとcontext-mode pluginが設定されています。

    したがって、「strict MCPで起動できた」という結果から、次は証明できません。

    • user-level pluginが無効
    • project pluginが無効
    • project hookが無効
    • project CLAUDE.mdの影響がない
    • user settingsが混入していない

    canaryを次の2層に分けるべきです。

    1. transport canary

      • clean temporary cwd
      • isolated Claude config
      • --bare
      • explicit MCP config
      • proxy、model route、tool translationだけを検証
    2. repository integration canary

      • 実際のworktree
      • repository agents/settings/hooksを意図的に読み込む
      • session-scoped plugin disable契約を検証
      • user MCPのsentinel serverが見えないことを確認
      • 必要なproject hookだけが動作することを確認

    この分離がないと、transport不良とrepository customization不良を区別できません。


    P0-8. runtime-verification policyに不適合

    repositoryのruntime verification policyは、Issueごとに## Runtime Verification Applicabilityを持ち、immediate/deferred/not_applicableを明示することを要求しています。immediateの場合、runtime対象AC/VC、exit 77によるSKIP、evidence artifact等が必要です。

    Issue #2158は明らかにimmediate対象ですが、必要なsectionとevidence schemaがありません。静的なrg検査は、次を証明できません。

    • 実際に正しいproxy binaryが起動した
    • listenerがloopback-only
    • OAuth認証が利用可能
    • model entitlementがある
    • alias routeが正しい
    • effortが送信された
    • tool callが一度だけ実行された
    • continuationが機能した
    • credentialsがsandboxから読めない

    Issue本文の「exit 77を使う」という記載だけでは、repository policyを満たしません。


    P1:高優先度の設計不備

    P1-1. proxy lifecycleとHerdr同時起動モデルが未決定

    Parentコメントでは、claude-code-proxy v0.1.34を導入し、Herdrの複数tabから同時利用したい意図が示されています。

    しかし、#2158は次を決めていません。

    • 1ユーザー1proxy singletonか
    • Herdr sessionごとに別proxyか
    • portは固定か動的か
    • auth refreshの競合をどう避けるか
    • stale processの判定
    • launcher終了時にproxyも終了するか
    • Herdr full restart時の再接続
    • version/configが異なるlauncher同士の競合

    推奨は、user-scoped singleton proxyです。lockfileまたはruntime manifestに次を保存し、launcherは完全一致した場合だけattachします。

    pid
    uid
    listen address
    port
    binary absolute path
    binary sha256
    proxy version
    effective-config digest
    started_at
    

    一致しなければ、既存listenerへ安易にattachせずfail closedにすべきです。


    P1-2. 配布物のversion pinと実行バイナリ同定がない

    調査時点のproxy latestはv0.1.34です。Claude Code側も2026年8月14日時点でv2.1.224が公開され、subagent frontmatterのeffort対応が追加されています。

    上流installerには以下の性質があります。

    • CLAUDE_CODE_PROXY_VERSIONでversion pin可能
    • 未指定時はmoving latest
    • release archiveとSHA-256を取得して検証
    • sha256sum/shasumがなければ検証を省略
    • 検証省略後も後続で「Checksum verified」と表示する

    release workflowはarchiveとSHA-256を公開していますが、確認したworkflowには独立したsignatureまたはattestation検証stepは示されていません。

    したがってIssueには次が必要です。

    • proxy exact version pin
    • Claude Code minimumまたはexact version
    • 実行バイナリのabsolute path
    • binary SHA-256
    • installer stdoutを信頼せず、自前でhash検証
    • checksum toolがなければSKIPではなくprecondition failure
    • PATH上の別binaryにすり替わっていないこと
    • 自動upgrade禁止
    • owner承認付きversion bump
    • last-known-good binaryへのrollback手順

    P1-3. auth statusだけではmodel利用可能性を証明できない

    proxyでOAuth認証が成立していても、Sol/Terra/Lunaがそのaccountで利用可能とは限りません。上流も、local model registrationはaccount entitlementを保証せず、unknown modelにfallbackしないとしています。

    preflightは少なくとも次を分離すべきです。

    • auth status: OAuth credentialが存在し、有効期限更新可能
    • models --json: 必須3 modelがcatalogに存在
    • minimal live request: 各routeが実際に受理される
    • configured model mismatch: FAIL
    • account entitlement未付与: SKIP:または明示的unsupported
    • 別modelへのfallback: FAIL

    モデル自身に「あなたはどのモデルか」と答えさせる方法は証明になりません。


    P1-4. evidence取得がprompt・tool内容を漏洩させ得る

    proxyのtraffic captureはrequest body、prompt、tool content等を保存する診断機能です。上流もtraffic captureがpromptとtool contentを意図的に保持すると説明しています。

    acceptance artifactでは以下を禁止すべきです。

    • CCP_TRAFFIC_LOG=1
    • verbose logging
    • auth header
    • access/refresh token
    • account ID
    • full prompt
    • tool input/output
    • repository file内容
    • environment全dump

    artifactはallowlist方式で、次だけを残すべきです。

    {
      "status": "pass|skip|fail",
      "reason_code": "...",
      "claude_version": "...",
      "proxy_version": "...",
      "proxy_binary_sha256": "...",
      "listener_pid": 123,
      "listener_address": "127.0.0.1",
      "listener_port": 18765,
      "required_models_present": true,
      "sandbox_credential_read_denied": true,
      "mcp_user_source_excluded": true,
      "tool_execution_count": 1,
      "continuation_same_session": true
    }

    P1-5. scripts/配下のrepository契約を満たしていない

    scripts/CLAUDE.mdは、次を要求しています。

    • ShellはPOSIX準拠
    • 外部依存を極力持たない
    • 破壊的処理にはdry-run
    • 構造化JSON/YAML出力
    • skill専用scriptとshared scriptの配置区別

    #2158のACには、POSIX shell、dry-run、structured outputがありません。また、既存package.jsonにはclaude-gpt関連の検証commandが存在せず、テストを置くだけではCIや標準verificationから呼ばれる保証がありません。

    少なくとも次が必要です。

    • --dry-run
    • --json
    • POSIX shell syntax test
    • fake proxy/fake claude fixtureによるcredential不要のhermetic test
    • port collision、stale PID、symlink、env poisoning、cleanup failureのnegative test
    • pnpmから呼べる明示的verification command、または既存Vitest discoveryに入ることの証明

    これを行うなら、Allowed Pathsへpackage.jsonまたは適切なtest pathを追加する必要があります。


    P1-6. 関連Issueの依存関係が現況とずれている

    関連作業の現在の状態は次です。

    • #2059は完了済み
    • PR #2150はmerge済み
    • #1943はOPEN
    • #2050はOPEN
    • #2153はOPEN

    #2153はbackend session resumeのnative canaryを扱っており、#2158のcontinuation canaryと直接重なります。「Allowed Pathsが重なるが依存なし」というコメントがありますが、ファイル競合がなくても、何をnative canaryと呼ぶか、どのsession lifecycleを正本とするかという運用契約上の依存は残っています。

    責務を次のように分けるべきです。


    P1-7. provider policy上の不確実性をIssueから除外している

    OpenAI公式資料ではCodexがChatGPT planに含まれることと利用上限が説明されていますが、主に公式Codex app、CLI、IDE、web等が案内されています。第三者proxyによる内部subscription endpoint利用が明示的に保証されているわけではありません。 (OpenAI Help Center)

    また、利用規約にはcredential共有、保護措置やrate limitの迂回、一定の自動的・プログラム的抽出等に関する制約があります。これは直ちに本構成が規約違反だという結論ではありませんが、上流proxy自身もprovider policyやaccount enforcementがprovider管理下であると明記しています。 (OpenAI)

    したがって、Issueには技術的PASSとは別に、次のhuman-owned decisionが必要です。

    provider_policy_risk:
      accepted_by: repository_owner
      credential_sharing: forbidden
      non_loopback_distribution: forbidden
      resale_or_shared_service: forbidden
      rate_limit_circumvention: forbidden
      account_enforcement_risk: accepted
      reviewed_at: YYYY-MM-DD

    修正後の推奨verification構成

    Lane A:credential不要のhermetic CI

    fake claude、fake proxy、fixture socketを使い、次を検証します。

    • 環境変数allowlist
    • canonical path/symlink拒否
    • dry-run
    • JSON schema
    • exit code
    • stale PID
    • port collision
    • signal cleanup
    • artifact redaction
    • 0.0.0.0/::拒否
    • tool二重実行検知
    • proxy version mismatch
    • binary hash mismatch

    Lane B:host preflight

    実環境で、外部へpromptを送る前に検証します。

    • Claude Code version
    • proxy versionとbinary SHA-256
    • auth status
    • required model catalog
    • config/auth/state directoryのcanonical pathとpermissions
    • 予期しないCCP_*/proxy envの不存在
    • owned PIDとlisten socket
    • loopback-only
    • traffic logging無効
    • sandboxからcredential decoyを読めない

    Lane C:bounded live transport canary

    subscription quotaを無制限に消費しないよう、request数、turn数、timeoutを固定します。

    • main→Terra
    • Opus alias→Sol
    • Sonnet alias→Terra
    • Haiku alias→Luna
    • low/high effort
    • read-only deterministic tool call
    • tool実行回数が厳密に1回
      -同一session continuation
    • fresh session非継続
    • stream障害時にnon-streaming replayしない

    Lane D:repository/Herdr integration canary

    • 実worktreeから起動
    • user MCP sentinelが見えない
    • 許可したproject hookだけが動く
    • session-scoped plugin policy
    • 2つのHerdr tabから同時利用
    • stale launcherとの競合拒否
    • full restart後のprofile復元
    • write sessionが別worktreeであること

    exit code契約

    Code 意味
    0 必須assertionがすべてPASS
    77 外部precondition不足。stdout先頭は必ずSKIP:。PASSとして集計禁止
    1 security、route、model、effort、MCP、tool、continuation、cleanupの不一致
    2 harness内部不良。任意だが、外部preconditionと区別するなら導入

    次は77ではなく1にすべきです。

    • authが存在するが壊れている
    • loopback以外でlisten
    • stale/unknown proxyへ接続
    • 必須modelがcatalogにあるのにroute失敗
    • aliasが別modelへfallback
    • credential readが成功
    • MCP exclusion不成立
    • toolが二重実行
    • cleanup失敗
    • evidenceにsecretまたはpromptが混入

    必要なAllowed Paths修正

    最低限、次へ変更する必要があります。

    scripts/claude-gpt/**
    .gitignore
    package.json                  # 専用verification commandを追加する場合
    tests/** または対象test path  # scripts配下で既存test discoveryに入らない場合
    

    GitHub Actionsへ専用laneを追加するなら、.github/workflows/**も明示的に追加します。逆にworkflowを変更しないなら、既存CIのどのcommandが新しいtestを実行するかをACで固定すべきです。


    最終結論

    #2158は、現状では「launcher実装Issue」ではなく、credential boundary、proxy ownership、runtime evidence、concurrency modelが未決定の設計Issueです。

    特にマージ前blockerは次の6点です。

    1. Allowed PathsとAC5の矛盾解消
    2. CCP_CONFIG_DIR/XDG_STATE_HOMEを含む完全なstate分離
    3. 同一UIDからOAuth tokenを守るsandbox hard gate
    4. PID所有権付きloopback listener検証
    5. model/effort/continuation/MCPを観測可能な形で検証
    6. exact version・binary hash・rollback契約

    これらをIssue本文へ反映するまでは、実装を開始しても「ACを満たした安全なPASS」を定義できません。


    you asked

    message time: 2026-08-14 19:11:32

    #2158
    実装内容に #2154 の GitHub Issueの更新と Child 2: migrate agent/runtime parity contracts(Phase 2) Child 3: retire Codex CLI assets and documentation(Phase 3)の記表を含めてほしいです。


    chatgpt response

    #2158の現行本文と#2154のPhase構成を確認し、実装スコープに「親Issue更新」と「Child 2 / Child 3の起票・記録」を明示的なAcceptance Criteriaとして追加します。既存の記述を壊さず、依存順序と完了条件も揃えます。

    #2158の現行契約では「Child 2/3は別途起票」「新規Issue起票が必要ならStop」となっており、希望内容と矛盾しています。Phase 2/3の実装自体はOut of Scopeのまま、Phase 1 PASS後にChild 2/3を起票し、#2154へ番号・依存関係・進捗を反映するところまでを#2158のdelivery scopeへ組み込みます。

    重複検索では、Child 2/3に相当する独立Issueはまだ存在せず、#2154だけが該当しました。したがって#2158には「Phase 1 runtime PASS後に2件を重複防止付きで起票し、その実番号を#2154へ反映する」を追加し、Phase 2/3の実装開始条件は従来どおり維持します。

    #2158を更新しました。

    追加した主要契約は以下です。

    • Phase 1 runtime verification が PASSした後にChild 2 / Child 3を起票
      • SKIP (77) や部分PASSでは起票しない
    • Child 2: migrate agent/runtime parity contracts(Phase 2)
      • Parent #2154
      • Phase 1 gateを明記
      • dual-provider portability contractへの移行を責務化
    • Child 3: retire Codex CLI assets and documentation(Phase 3)
      • Parent #2154
      • Child 2 mergeをimplementation gate化
      • producer/consumer inventory → zero-reference確認 → 段階撤去を必須化
    • 起票前に既存Issueを検索し、重複Issueを作らない
    • Child 2 / 3の実Issue番号確定後、#2154を更新
      • Child Issues
      • Remaining Parent Gaps
      • Phase Handoff Contract
      • Parent側Acceptance Criteria
    • Child 2 / 3は起票時点では未完了なので、parentのchild completion checkboxは未チェックのまま
    • Phase 2 / Phase 3のrepository実装は#2158では行わない
    • GitHub Issue操作をrepository Allowed Pathsとは別のcontrol-plane writeとして明示
    • 既存AC5との矛盾も解消するため、.gitignoreをAllowed Pathsへ追加
    • 「新規Issue起票なら停止」というStop Conditionを、Child 2 / 3は例外として許可する形へ修正

    つまり、#2158の完了フローは今後、

    launcher実装 → native canary PASS → Child 2起票 → Child 3起票 → #2154 rollup更新 → #2158 delivery完了

    となります。

    なお、現時点ではChild 2 / Child 3そのものはまだ起票しておらず、#2154もまだ変更していません。それらを「#2158のPhase 1 PASS後に実施する実装・handoff作業」として契約化した状態です。


    Powered by AI Exporter

  3. squne121 commented on Aug 14, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了報告

    対象コメント(#2158 コメント)に含まれる敵対的レビュー結果(REQUEST_CHANGES、P0 8件・P1 7件)を踏まえて Issue 本文を改訂しました。

    Step 2 最終判定

    VERDICT: approve(0 blocker)。REVIEWED_BODY_SHA256: sha256:c9adc30b7d939a1e00b86eea264011e75ce3d52a4678e582b3b21bf7c350ff17

    反映した主な変更

    決定論的ブロッカー(16件)の解消:

    • ## Runtime Verification Applicability セクションを新設(decision: immediate、applicable_acs / execution_environment / skip_conditions / fallback_policy / artifact_requirements の必須フィールドを含む)
    • AC8〜AC11 の VC マーカーを # AC<N> の bare 形式へ統一(コロン・説明文を除去)
    • 新規 Allowed Path(scripts/claude-gpt/)を対象とする VC に # baseline-expect: fail、既存 repository 状態で成功する VC(AC8〜AC11 の gh issue / git diff 系)に # baseline-expect: pass を付与
    • Stop Conditions を implementation issue template の定型6項目(原文のまま)+ Issue 固有の追加停止条件に再構成(旧本文はテンプレート定型文を独自に改変しており guard-issue-body.py の LP017 に抵触していたため修正)

    対象コメントの P0 指摘の反映(実装スコープ内で AC/In Scope を強化、新規 AC は追加せず既存 AC1〜AC11 の粒度を強化):

    • P0-1(AC5 と Allowed Paths の矛盾): 解消済みと確認(.gitignore が既に Allowed Paths に含まれている)
    • P0-2(credential 隔離不足): launcher が Claude Code 自身の読み取りから proxy credential/config/state を保護する設定を行うことを AC5 / In Scope に追加
    • P0-3(loopback 検証の false positive): PID 所有権付き listen socket 検証を AC4 / In Scope に追加(curl 疎通のみでの判定を明示的に禁止)
    • P0-4(CLAUDE_CONFIG_DIR だけでは不十分): CCP_CONFIG_DIR / XDG_STATE_HOME 相当の分離と canonical path 検証を AC1 / In Scope に追加
    • P0-5(環境変数継承によるルーティング逸脱): proxy 起動時の環境変数 allowlist 限定を AC2 / In Scope に追加
    • P0-6(model alias / effort / continuation 契約不足): ANTHROPIC_MODEL 系エイリアスの明示値を確定し AC2 に反映
    • P0-7(transport canary と repository integration canary の未分離): AC6 の粒度を強化
    • P0-8(Runtime Verification Applicability セクション欠落): 上記の通り新設

    P1 指摘の反映(Scope / Design References / Stop Conditions への反映、AC 追加なし):

    未反映・スコープ外と判断した指摘:

    • P1-1(proxy lifecycle / singleton モデル)、P1-2(exact version pin・binary hash 検証・rollback 運用)、P1-3(model entitlement 検証の分離)、P1-4(evidence artifact の allowlist 化)は、実装時の詳細設計判断に委ねるのが適切と判断し、AC 契約までは拡張しませんでした(P1-2 の pin/rollback 恒久運用は Out of Scope に明記)。実装時に必要であれば Draft PR 側で扱ってください。

    次のアクション(本 loop のスコープ外)

    issue-refinement-loop は issue-contract-review(別 skill)を実行しないため、impl-review-loop への正式な handoff(LOOP_HANDOFF_RESULT_V1.status: impl_ready)には、実装着手前に issue-contract-review の実行が別途必要です。

    LOOP_HANDOFF_RESULT_V1:
      status: blocked
      routing_action: blocked
      contract_review:
        status: blocked
        gate_result: missing_go
        latest_comment_url: null
        generated_at: null
        body_sha256: "sha256:c9adc30b7d939a1e00b86eea264011e75ce3d52a4678e582b3b21bf7c350ff17"
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "issue-refinement-loop はラベル操作を行っていない"
      auto_fixes:
        result: auto_fixed
        required: []
        skipped: []
      blockers:
        - kind: contract_review_not_yet_run
          description: "issue-refinement-loop は issue-contract-review を実行しない。impl-review-loop へ handoff する前に issue-contract-review を別途実行し、status: go を確認すること。"
      permissions:
        unavailable: []
      generated_at: "2026-08-14T10:33:47Z"
      checked_body_sha256: "sha256:c9adc30b7d939a1e00b86eea264011e75ce3d52a4678e582b3b21bf7c350ff17"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []
  4. squne121 commented on Aug 14, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了

  5. squne121 commented on Aug 14, 2026

    @squne121
    OwnerAuthor

    Issue #2174 evidence: --claude-bin 経由の claude-gpt launcher 実機検証(AC3/AC4)

    Issue #2174(worktree-agent-runtime-smoke へ --claude-bin launcher 選択入力を追加)の実装(PR #2176)にて、scripts/claude-gpt/launch.sh(本 PR #2158 ブランチの worktree、まだ main 未マージ)を --claude-bin に指定して structured lane(AC3)と isolated herdr interactive lane(AC4)を live 実機検証した結果を記録する。

    AC4(isolated herdr interactive lane): PASS

    isolated named herdr session 経由で claude-gpt launcher を実際に起動し、応答受信・session cleanup 確認まで成功した。

    - agent_name: rts-claude-543b945dd4c6
    - cleanup_attempted: True
    - cleanup_confirmed_removed: True
    - detected_agent: claude
    - errors: []
    - exit_code: 0
    - final_state: done
    - pane_id: w2:p1
    - prompt_stall_recovered: True
    - resolved_executable: <--claude-bin launcher shim>
    - runtime_version: 2.1.232 (Claude Code)
    - session_name: rts-43cd264701be44828852ca07521b
    - transport: herdr_isolated_session
    

    runtime_version: 2.1.232 (Claude Code) は claude-gpt proxy 経由で実際に Claude Code CLI が応答したことを示す。isolated session は stop/delete/herdr session list --json での消失確認まで完了している。人間の使用中 herdr session には一切相乗りしていない。

    初回試行は herdr agent prompt の bracketed-paste 由来の既知の stall(references/herdr.md に記載済みの agent_prompt_stalled)で失敗(exit_code: 1, errors: ['herdr agent prompt stalled and recovery send-keys produced no observed state change; prompt remains unsubmitted'])したが、これは claude-gpt launcher 固有の問題ではなく既知の一般的な flake であり、再試行で prompt_stall_recovered: True として成功した。

    AC3(structured lane): BLOCKED — アーキテクチャ不整合を発見

    - errors: ['structured lane exited non-zero: 2: {"schema":"CLAUDE_GPT_LAUNCH_RESULT_V1","status":"blocked","reason":"policy_weakening_flag_rejected","flag":"--settings"}\n']
    - exit_code: 1
    - process_exit_code: 2
    - resolved_executable: <--claude-bin launcher shim>
    - runtime_version: 2.1.232 (Claude Code)
    

    run_worktree_agent_runtime_smoke.py の run_structured_claude() は既存仕様(Issue #1886/#2046、hook lifecycle 観測用)として、すべての claude structured 起動に対して常に --settings <hook-observability-json> を固定 argv へ含める。

    一方 scripts/claude-gpt/launch.sh は自身の安全設計(本 PR #2162 OWNER fix-delta P1-1、CLAUDE_GPT_FORBIDDEN_EXTRA_FLAGS="--settings --mcp-config --strict-mcp-config --dangerously-skip-permissions --allow-dangerously-skip-permissions")として、--settings を含む policy-weakening flag を -- の前後を問わず常に拒否する(launch.sh 75-92 行目付近)。

    この 2 つはいずれも意図した通りに動作しており、両者を単純に組み合わせると構造的に非互換という発見である。回避策として:

    1. launch.sh へ直接(-- なしで)--claude-bin を渡す → launcher 自身の option parser が -p を unknown_launcher_option として拒否(exit 2)
    2. launch.sh -- <claude 引数...> の形で -- 区切りを挿入する shim 経由で渡す → forbidden-flags チェックに --settings が引っかかり policy_weakening_flag_rejected で拒否(exit 2)

    いずれの経路でも live 実行は失敗する。この不整合は launcher 側の起動前提(proxy / ChatGPT subscription 認証)が利用不能な場合の SKIP(Issue #2174 の skip_conditions)とは異なるカテゴリの失敗であり、Issue #2174 の Stop Conditions(「scripts/claude-gpt/launch.sh 自体の修正が必要と判明した場合」)に該当すると判断し、コード変更で無理に回避せず live 実行結果をそのまま記録した。

    OWNER 判断が必要な論点

    • launch.sh の CLAUDE_GPT_FORBIDDEN_EXTRA_FLAGS から --settings を除外する(hook lifecycle 観測目的の read-only 相当 settings のみ許可する等の緩和)か、
    • run_worktree_agent_runtime_smoke.py 側に --settings 注入を任意で抑制するオプトアウトを追加する(新規 runner 機能、別 Issue 化)か、
    • 現状のまま AC3 を「claude-gpt launcher では live 実行不可」として記録し、PR feat: claude-gpt launcher を bootstrap し native canary で runtime を検証する #2162 の pre-merge dependency 判定から AC3 を除外するか

    のいずれかを OWNER が決定する必要がある。詳細実装・全 evidence(両ケースの summary.md 全文・7 件の新規 pytest)は PR #2176 を参照。

    Ref: Issue #2174, PR #2176

  6. squne121 commented on Aug 14, 2026

    @squne121
    OwnerAuthor

    launch.sh stdin切断バグの修正(PR #2176 実機発見への対応)

    commit: 95d10ba(このブランチへ直接push、head更新済み)

    根本原因

    launch.sh の P0-4 supervisor構成("$CLAUDE_BIN" ... "$@" & に続けて wait)は、
    明示的な入力リダイレクトを持たない async command の stdin を shell が自動的に /dev/null
    へ差し替える POSIX 準拠の既定動作
    (job control 無効時。dash/bash 双方で再現確認済み)の
    影響を受けていた。

    再現条件を特定した結果:

    • stdin 経由で prompt を渡す呼び出し(-p のみ + prompt を stdin へ pipe)のみが影響を受ける。structured lane(run_worktree_agent_runtime_smoke.py の run_structured_claude())はまさにこの形(input_text=prompt を subprocess.PIPE 経由)で prompt を渡しており、これが Error: Input must be provided either through stdin or as a prompt argument when using --print の原因だった。
    • argv 経由で prompt を渡す呼び出し(runtime_smoke_test.sh の -p "$step_prompt")は影響を受けない(argv に prompt が含まれるため stdin は不要)。

    検討した対処法と不採用理由

    • set -m(job control 有効化): stdin 問題自体は解消するが [N]+ Done ... という job 完了通知が stderr に出力される(実害はないが不要なノイズ)
    • disown: stdin 問題は解消するが、wait "$CPID" がその後即座に rc=0 で返ってしまい、実際には子プロセスの終了を待たないことを検証で確認。これは P0-4 supervisor の exit code 取得と signal forwarding を静かに破壊する重大な副作用のため不採用。

    採用した修正

    launcher 自身の stdin を exec 9<&0 で fd 9 として明示的に複製し、claude 起動時に <&9 で結びつける。async command に明示的な入力リダイレクトを与えることで、shell 既定の /dev/null 差し替えを回避する。job control 有効化や disown を使わないため、既存の signal forwarding / exit code 取得 / cleanup(P0-4)には一切影響しない。

    検証結果

    1. 最小再現(echo hello | sh -c '...')で fd 9 複製ありなしの挙動差を dash・bash 両方で確認
    2. scripts/claude-gpt/runtime_smoke_test.sh 実機 PASS(claude_exit_code: 0, text_marker_ok/bash_tool_marker_ok/subagent_marker_ok すべて true, proxy_cleanup_ok_independent_reverify: true)
    3. PR 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加する (#2174) #2176(Issue 実装: worktree-agent-runtime-smoke に claude-gpt launcher 選択入力を追加し Lane A/B 実機検証する #2174)の run_worktree_agent_runtime_smoke.py structured lane を本修正版 launch.sh に対して narrow observability channel(CLAUDE_GPT_RUNTIME_SMOKE_HOOKS=subagent-start-stop)付きで実機実行し、AC3相当の実機確認を達成:
      • stdin経由prompt応答: exit_code: 0, terminal_event_observed: true, expected_markers_missing: []
      • Bash tool + Task tool経由SubAgent呼び出し: child_spawn_observed: true, child_agent_type_observed: general-purpose, child_completion_observed: true, child_terminal_status: completed
    4. P0-4 supervisor cleanup: proxy PID / listen socket の残留なしを確認(ps/ss で独立確認、CLEANUP_OK: true)
    5. bash -n / shellcheck -s sh(新規warning無し)、pnpm typecheck / pnpm lint / pnpm test(1872/1872 pass)/ pnpm build 全green

    Scope

    修正は scripts/claude-gpt/launch.sh のみ(Allowed Paths: scripts/claude-gpt/ 準拠)。

  7. squne121 commented on Aug 15, 2026

    @squne121
    OwnerAuthor

    Issue #2174 AC3/AC4/AC7 live runtime-verification evidence(fix_delta 後、head 8f7f60af)

    merge 済み main(scripts/claude-gpt/launch.sh 現行版)と PR #2176 fix_delta(--claude-adapter native|claude-gpt 分離後)を組み合わせた clean な worktree checkout から、scripts/agent-ops/run_worktree_agent_runtime_smoke.py を live 実行した結果。

    環境確認(Runtime Verification Applicability の execution_environment):

    {"schema":"CLAUDE_GPT_LAUNCH_RESULT_V1","status":"ok","mode":"check_only","bind_ok":true,"model_alias_ok":true,"chatgpt_auth":{"available":true,"detail":"authenticated"}}

    herdr status server も status: running を確認済み。SKIP 条件(proxy/認証/herdr 利用不能)には該当しないため、以下は SKIP ではなく genuine PASS。

    AC3: structured lane(非対話、--claude-bin scripts/claude-gpt/launch.sh --claude-adapter claude-gpt)→ PASS

    process_exit_code: 0
    terminal_event_observed: True
    native_event_count: 37
    claude_adapter: claude-gpt
    claude_gpt_launcher_receipt: None(launcher からの拒否 receipt なし = launcher 起動成功)
    child_spawn_observed: True
    child_agent_type_observed: general-purpose
    child_completion_observed: True
    child_terminal_status: completed
    spawn_events: [{'runtime': 'claude', 'tool': 'Agent'}]
    

    Bash tool 呼び出し(echo RUNTIME_SMOKE_STRUCTURED_OK)と general-purpose SubAgent の起動・完了が native event stream 上で確認できた。claude-gpt launcher(-- separator 挿入 + CLAUDE_GPT_RUNTIME_SMOKE_HOOKS=subagent-start-stop 環境変数チャンネル)経由の実対話・tool 呼び出し・SubAgent 呼び出しが genuine に成立している。

    AC4: isolated herdr interactive lane(Lane B、--claude-bin scripts/claude-gpt/launch.sh --claude-adapter claude-gpt)→ PASS

    exit_code: 0
    final_state: done
    expected_markers_missing: []
    turns_completed: 1
    detected_agent: claude
    cleanup_attempted: True
    cleanup_confirmed_removed: True
    transport: herdr_isolated_session
    session_name: rts-791c1a6423c84ab09fe631dde7bc(isolated named session、実行後 herdr session list からの消失を確認済み)
    

    --claude-bin を isolated session 専用の PATH shim(claude symlink)経由で herdr の --kind claude 解決に反映し、claude-gpt launcher 経由の起動・入力・応答が観測された。isolated session は実行後 stop → delete → session list --json での消失確認まで完了し、人間の使用中 herdr session には一切相乗りしていない。

    AC7: Herdr session snapshot 保全検証 → PASS

    runner 自身の evidence:

    herdr_workspace_snapshot_before_captured: True
    herdr_workspace_snapshot_after_captured: True
    herdr_workspace_snapshot_diffs: []
    herdr_workspace_snapshot_preserved: True
    

    control-plane 側の独立検証(runner の自己申告に依存せず、実行前後で自ら herdr session list --json / herdr api snapshot を直接取得し比較):

    • herdr session list --json: 実行前後で完全一致(差分なし)
    • herdr api snapshot: focused_workspace_id / focused_tab_id / focused_pane_id が実行前後で完全一致(w4 / w4:t3 / w4:p3 のまま不変)、既存 7 agent pane の workspace_id/tab_id/pane_id の集合も実行前後で完全一致。

    以上により、isolated interactive lane の実行が人間の使用中 Herdr session(workspace/agent/focus を含む)に一切影響を与えていないことを、runner 自身の evidence と control-plane の独立確認の両方で確認した。

    証跡に含まれないもの

    credential・OAuth token・prompt 全文・tool 入出力全文は本コメントに含めていない(summary.md は allowlist-only フィールドのみを出力する設計であり、この comment もそれをそのまま転記している)。


    関連: Issue #2174(https://github.com/squne121/loop-protocol/issues/2174)、PR #2176(https://github.com/squne121/loop-protocol/pull/2176)

    Co-Authored-By: Claude Sonnet 5 [email protected]

  8. squne121 commented on Aug 15, 2026

    @squne121
    OwnerAuthor

    Issue #2174 / PR #2176 live AC3/AC4/AC7 re-verification (post fix_delta iteration 2)

    tested_head: 6db0625f11299d88ad0a250b058d40a120fce19f
    executed: local live environment (raine/claude-code-proxy + ChatGPT subscription auth + herdr 0.8.0, all confirmed available via scripts/claude-gpt/launch.sh --check-only, exit 0)

    AC3 (structured lane): PASS

    Command: --runtime claude --mode structured --claude-bin scripts/claude-gpt/launch.sh --claude-adapter claude-gpt

    • exit_code: 0, errors: [], expected_markers_missing: []
    • resolved_executable: .../scripts/claude-gpt/launch.sh
    • Real tool-call and SubAgent-spawn evidence observed: child_spawn_observed: True, child_completion_observed: True, child_spawn_source: tool_use_result, child_completion_source: tool_use_result_status_completed

    AC4 (isolated herdr interactive lane, Lane B): BLOCKED (not PASS, not SKIP)

    Command: --runtime claude --mode interactive --claude-bin scripts/claude-gpt/launch.sh

    Causal-proof mechanism (Findings 1+2 of the OWNER's iteration-2 review) is confirmed to function correctly, after an additional live-only bug was found and fixed during this re-verification:

    • herdr workspace create --env PATH=<shim>:<original> DOES set the newly spawned pane shell's initial process PATH (confirmed via herdr pane run <pane> 'echo $PATH'), but the interactive login shell then re-sources its own .bashrc/.zshrc/.profile, which on this environment prepends ~/.local/bin (containing the real native claude binary) ahead of the shim -- silently defeating the override exactly as Finding 1 warned. Fixed by explicitly re-exporting PATH inside the already-running (post-rc) pane shell via herdr pane run <pane> "export PATH='<shim>':\"\$PATH\"" immediately before agent start (pushed as commit 6db0625 on this same PR).
    • With that fix applied, a direct manual reproduction (bypassing herdr's own fixed --kind claude flag injection) confirmed: the forwarder script IS invoked, the nonce/receipt is written and read back correctly, and the real launcher (scripts/claude-gpt/launch.sh) genuinely execs -- proving Findings 1+2 are structurally fixed at the PATH-resolution and shim-integrity layer.

    However, AC4 end-to-end still cannot PASS, for a reason outside this Issue's Allowed Paths:

    • herdr agent start --kind claude always injects a fixed --strict-mcp-config flag into the launched process's argv (a Herdr-side behavior, not runner-side).
    • scripts/claude-gpt/launch.sh explicitly rejects --strict-mcp-config as a policy-weakening flag it refuses to accept from a caller ({"status":"blocked","reason":"policy_weakening_flag_rejected","flag":"--strict-mcp-config"}), confirmed both with and without a -- separator inserted ahead of it.
    • Because launch.sh exits with a blocked status instead of becoming an interactively-ready claude process, herdr agent start itself fails before the isolated lane can ever reach a point where marker/turn/cleanup evidence is meaningful.

    This is a genuine structural incompatibility between Herdr's fixed --kind claude invocation contract and scripts/claude-gpt/launch.sh's own flag policy -- not fixable within Issue #2174's Allowed Paths (scripts/claude-gpt/launch.sh is Out of Scope, and "scripts/claude-gpt/launch.sh 自体の修正が必要と判明した場合" is one of this Issue's explicit Stop Conditions). Per the Issue's fallback_policy, no PASS is claimed here from this evidence. This is a discovered functional incompatibility (proxy/auth/herdr are all fully available) requiring an OWNER decision, not a SKIP-77 (missing-prerequisite) condition.

    Recommended follow-up (OWNER decision required, #2158/#2162 scope): either (a) scripts/claude-gpt/launch.sh should tolerate/pass through --strict-mcp-config when invoked as a drop-in claude replacement under Herdr (since Herdr, not an untrusted caller, is the one injecting it), or (b) a different Herdr invocation mode that does not auto-inject --strict-mcp-config needs to be identified for this interactive-launcher-substitution use case.

    AC7 (Herdr full snapshot preservation): mechanism validated PASS (independent of the AC4 launcher blocker)

    Since AC4's specific claude-gpt run never reaches a stable interactive state (see above), AC7 was independently validated using the SAME isolated-interactive-lane code path with the native (ambient) claude runtime (--runtime claude --mode interactive, no --claude-bin) to confirm the full-snapshot mechanism itself (Findings 3+4 of the OWNER's iteration-2 review) genuinely works end-to-end in this live environment:

    • exit_code: 0, errors: []
    • herdr_workspace_snapshot_before_captured: True, herdr_workspace_snapshot_after_captured: True
    • herdr_workspace_snapshot_diffs: [], herdr_workspace_snapshot_preserved: True
    • herdr session list --json before/after both confirmed clean (only default remained; isolated session correctly created and removed)

    This confirms capture_all_herdr_workspace_snapshots() (multi-session enumeration, Finding 4) and capture_herdr_workspace_snapshot() (full identity records including terminal_id/agent_session/panes/tabs/workspaces/layouts, Finding 3) function correctly against the real installed herdr 0.8.0 binary, not merely against fake-herdr test fixtures.

    Summary

    AC Result
    AC3 (structured) PASS
    AC4 (interactive) BLOCKED -- causal-proof mechanism fixed and confirmed working; end-to-end blocked by an out-of-scope Herdr/launch.sh flag-policy incompatibility requiring OWNER decision
    AC7 (full snapshot) Mechanism PASS (validated via native runtime; the combined AC4+AC7 claude-gpt run is blocked by the same AC4 issue above)

    No credentials, OAuth tokens, or full prompt/tool-output text are included above.

  9. squne121 commented on Aug 16, 2026

    @squne121
    OwnerAuthor

    Issue #2174 / PR #2176 AC4 実機再検証 evidence(CLAUDE_GPT_CLAUDE_BIN 自己再帰バグ修正後、2026-08-16)

    scripts/claude-gpt/launch.sh(Issue #2158 / PR #2162 由来)と PR #2176 の isolated herdr interactive lane を組み合わせた live 実機検証で、修正前は herdr agent start failed:(stdout/stderr 空)による genuine FAIL が再現していました。

    根本原因

    run_interactive_herdr_isolated() が herdr 自身の --kind claude 解決のため PATH 先頭に prepend する forwarder shim ディレクトリを、scripts/claude-gpt/lib.sh の claude_gpt_resolve_claude_bin()(CLAUDE_GPT_CLAUDE_BIN 未設定時に command -v claude へフォールバック)が自己参照的に発見してしまい、launch.sh が自分自身を再帰的に exec、その再帰呼び出し自身の引数パーサーが --strict-mcp-config を拒否して exit 2 で終了、herdr の agent readiness wait がタイムアウトしていました。比較 matrix(native claude / main の launch.sh / 候補修正版 launch.sh)で、特定の launch.sh 実装ではなく PATH シム統合自体の構造的欠陥であることを確認済みです。

    修正内容(PR #2176 の Allowed Paths 内、scripts/claude-gpt/ は無変更)

    claude_adapter == "claude-gpt" の場合のみ、シム prepend 前の元 PATH に対して shutil.which("claude") を実行し実ネイティブバイナリの絶対パスを解決、CLAUDE_GPT_CLAUDE_BIN として isolated session env(herdr workspace create --env と herdr pane run re-pin の両方)に設定するよう変更しました。

    修正後の live 実機再検証(genuine PASS)

    修正後コードで、default session には一切相乗りしない使い捨て isolated named herdr session を使い、scripts/claude-gpt/launch.sh を --claude-bin に指定して再検証:

    • exit_code: 0, final_state: done, detected_agent: claude, turns_completed: 1
    • expected_markers_missing: [](応答テキストにマーカーを実際に観測)
    • cleanup_attempted: True, cleanup_confirmed_removed: True(isolated session の stop/delete/消失確認済み)
    • herdr_workspace_snapshot_preserved: True, herdr_workspace_snapshot_diffs: []
    • 実行前後で herdr session list --json / herdr api snapshot を独立取得し、pre-existing default session が完全に不変であることを確認(diff 完全に空)

    修正前は同一条件で genuine FAIL、修正後は genuine PASS したことを確認しており、今回の fix_delta が実際にバグを解消したことを示します。

    詳細は PR #2176 本文「[追加修正] CLAUDE_GPT_CLAUDE_BIN 自己再帰バグの発見と修正」節を参照: #2176

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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions