Repository navigation
Closed
2 / 22 of 2 issues completedLabels
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: research
parent_issue: "none"
goal_ref: "Codex 固有の CODEX_ALLOWED_PATHS 入力を repository guard の正規契約から廃止し、Claude/Codex 共通で説明可能な安全な publish 境界へ移行する implementation Issue を起票可能にする"
change_kind: research-onlyParent Issue
none
Outcome
CODEX_ALLOWED_PATHS を使わない publish/staging 境界の採用案、削除対象インベントリ、既存 Issue #1542 との移行順序、および後続 implementation Issue(2件)が検証可能な contract として本 Issue に記録され、実装Issueを起票できる状態。
In Scope
CODEX_ALLOWED_PATHS/CODEX_ALLOWED_PATHS_MODEの参照箇所、producer、consumer、保護している性質を読み取りで棚卸しする。- repository-local な環境変数を廃止する候補を比較し、Claude/Codex で共通に説明できる明示 pathspec・Issue contract・controlled publish executor のいずれに責務を置くかを決定する。
- 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 の workspace/strict 意味論整合との依存・置換・分割の関係を live readback で記録する。
- 削除後も broad staging、保護 path、範囲外変更、remote publish の fail-closed 性質を維持する後続 implementation Issue を起票する。
- OWNER anchor comment(issuecomment-5010747083)で追加提案された、producer/consumer/authority 表・三案比較・threat model・edge case(rename/deletion/type change/submodule/rollback)・実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542/実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 処遇・remote publish scope・protected path policy 正本・rollback authority 保証を棚卸しする。
Out of Scope
- この Issue 内での guard、hook、Codex 設定、Claude 設定、テスト、ドキュメントの変更。
- 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 の実装または close。
- Claude Code または Codex の製品設定・認証・branch protection の変更。
git add -A、git add .、wildcard pathspec、保護 path、無検証 remote publish の許可。
Acceptance Criteria
- AC1:
CODEX_ALLOWED_PATHSとCODEX_ALLOWED_PATHS_MODEの全 repository-local consumer、現在の入力元、担保する安全性を本 Issue に列挙している。 - AC2: 環境変数を削除する少なくとも2案を、安全性、Claude/Codex parity、変更面、ロールバック、実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 との競合で比較している。
- AC3: 採用案が、通常の worktree で明示 pathspec による staging/commit を可能にし、broad pathspec・保護 path・範囲外変更は fail-closed に保つことを明記している。
- AC4: 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 との live dependency/置換関係と、同一ファイル競合を避ける直列化方針を記録している。
- AC5: 採用案を実装する
実装:Issue が 2件((a) staging/commit 実装、(b) Codex edit env removal)起票され、それぞれ exact Allowed Paths、AC、Verification Commands、rollback を含み、本 Issue からリンクされている。 - AC6:
edit/stage/commit/pushの操作ごとに producer、consumer、authority、Claude/Codex 差分を表形式で本 Issue に記録している。 - AC7: (a) raw pathspec hook、(b) contract artifact + controlled executor、(c) native permission profile + review gate の三案を比較し、採用案の根拠を記録している。
- AC8: 採用案の threat model を明記し、repository-local guardrail を security boundary として主張しないことを明示している。
- AC9: rename(旧path・新pathの双方)、deletion、type change、submodule change、特殊文字を含むパス、stale snapshot、HEAD race の扱いを確定している。
- AC10: 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 と 実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 について、それぞれ supersede / close / retain のいずれを採用するかを決定し記録している。
- AC11: remote publish lane を今回変更するか否かを明示している(変更しない場合は明示的に Out of Scope として記録する)。
- AC12: protected path policy(
assets/**、LICENSES/**、.env*、secrets/**等)の単一正本をどこに置くかを決定している。 - AC13: rollback 時に旧 env(
CODEX_ALLOWED_PATHS等)と新契約が同時に authority として扱われないことを保証する設計を記録している。
Verification Commands
# AC1
$ rg -n CODEX_ALLOWED_PATHS scripts/check-codex-agents.mjs scripts/agent-guards/git_mutation_command_policy.py scripts/agent-guards/tests/test_git_mutation_command_policy.py .claude/hooks/tests/test_issue1241_hook_repair_hint.py docs/dev/agent-runtime-ops.md
# AC2
$ gh issue view 1542 --repo squne121/loop-protocol --json number,state,title,body,url
# AC3
$ rg -n git_add_requires_explicit_pathspec scripts/agent-guards/git_mutation_command_policy.py
# AC4
$ gh issue view 1542 --repo squne121/loop-protocol --json state,comments,url
# AC5
$ gh issue list --repo squne121/loop-protocol --state open --search "Codex edit env removal" --json number,title,url
# AC6
$ rg -n CODEX_ALLOWED_PATHS_MODE scripts/check-codex-agents.mjs docs/dev/agent-runtime-ops.md
# AC7
$ rg -n "permission profile" docs/dev/agent-runtime-ops.md
# AC8
$ rg -n "threat model" docs/dev/agent-runtime-ops.md
# AC9
$ rg -n rename scripts/agent-guards/git_mutation_command_policy.py
# AC10
$ gh issue view 963 --repo squne121/loop-protocol --json number,state,title,url
# AC11
$ rg -n "remote publish" docs/dev/agent-runtime-ops.md
# AC12
$ rg -n "protected path" docs/dev/agent-runtime-ops.md
# AC13
$ rg -n CODEX_LEGACY_ALLOW_WRITES scripts/check-codex-agents.mjsAllowed Paths
- 読み取り専用。リポジトリ変更なし(既定)
Stop Conditions
- Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
- Allowed Paths 外への書き込みを試みた場合は即停止
- 権限不足(permission denied)により操作が完了できない場合は即停止
- 成果物の書き込みに失敗した場合(I/O エラー等)は即停止
- broad staging、保護 path、範囲外変更、または remote publish の既存 fail-closed 性質を維持できない案しか残らない場合は即停止
- 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 と同一の implementation scope を分離不能な形で要求する場合は即停止し、実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 を canonical destination として記録する
Handoff Contract
Current Objective: repository-local なCODEX_ALLOWED_PATHS入力を廃止する安全な後続 implementation contract(2件の実装 Issue: staging/commit 実装 と Codex edit env removal)を確定する。Bounded Current Context: 実装: command_registry.py の scope_rollup.run argv テンプレートに --invocation-id/--requested-at を反映する #1579 の専用 worktree でrtk git addがallowed_paths_missing_for_git_mutationにより停止し、実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 は未設定 workspace mode と Git mutation policy の不一致を扱っている。実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 は git add -A / Allowed Paths 外 commit 混入防止の staging guard を扱っている。Open Questions: 環境変数を完全削除する際に、strict mode の Issue contract をどの controlled executor が検証・注入するか。producer/consumer/authority 表、三案比較、threat model、edge case、実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542/実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 処遇、remote publish scope、protected path policy 正本、rollback authority 保証は未確定。Next Action: 採用案を exact Allowed Paths と検証行列へ落とした implementation Issue を 2件(staging/commit 実装、Codex edit env removal)起票する。Artifact Refs: 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542、実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963、実装: command_registry.py の scope_rollup.run argv テンプレートに --invocation-id/--requested-at を反映する #1579、実装: worktree bootstrap を direct Python/no-project-mutation launcher に統一する #1588、停止時のallowed_paths_missing_for_git_mutationevidence、anchor comment(issuecomment-5010747083)。
Notes for Reviewer
- 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 は現在の未設定 workspace mode を整合させる implementation Issue であり、本 Issue は environment-variable 入力そのものの廃止と後続移行を対象にする research-only scope である。
- 新規 implementation Issue は 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 の merge/close 状態を readback して、同一 policy function を並行変更しないよう依存関係を固定する。
- 本更新は OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/1592#issuecomment-5010747083)の追加提案(AC6-14相当)を反映したものである。issue-refinement-loop は当初
scope_delta_authority_evidenceのboundary_flags: requires_issue_splitにより human_escalation としたが、人間(リポジトリオーナー)が「三案比較・threat model等の research scope は本 Issue に含め、後続実装は staging/commit 実装 と Codex edit env removal の2件に分割起票する」方針を明示的に決定したため、その方針を AC5・AC6-AC13・Handoff Contract に反映した。
Scope Collision Preflight
- 既存 OPEN Issue 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 を確認した。実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 は
git_mutation_command_policy.py等の実装変更を対象にし、本 Issue は読み取り専用の移行判断と後続 implementation Issue の契約作成だけを対象にするため、同一 PR にはしない。 - 既存 OPEN Issue 実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 を確認した。実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 は staging guard の
git add -A/ Allowed Paths 外 commit 混入防止を対象にしており、本 Issue の AC10 でその処遇(supersede/close/retain)を決定する。
Sub-issues
Collapse Sub-issuesSub-issues
Loading 2 sub-issues
Activity
squne121 commentedon Jul 18, 2026
判定
REQUEST_CHANGES — 現状の #1592 は調査Issueとして未完了で、後続実装Issueを起票できる粒度に達していません。
方向性自体は妥当です。
CODEX_ALLOWED_PATHSを Claude/Codex 共通の正規契約として扱うのは不自然であり、廃止すべきです。ただし、現在のIssueは 編集・staging・commit・remote publishという別々の境界を「publish境界」として混同しています。現時点ではコメントがなく、
parent_issue: #1592の後続Issueも確認できません。敵対的レビュー結果
P0-1: 「publish境界」という問題設定が実装実態と一致していない
CODEX_ALLOWED_PATHSが現在関与しているのは主に次の二箇所です。Codex の
apply_patch/Edit/Writeに対する編集範囲制限Claude/Codex共有の
rtk git add/rtk git commit判定一方、
git pushの認可はLOOP_PUBLISH_EXPECTED_REMOTE_HEAD、LOOP_PUBLISH_ALLOWED_PATHS_GATE_STATUS、head bindingなど、独立したLOOP_PUBLISH_*証跡群を使っています。Claude の Write/Edit は
CODEX_ALLOWED_PATHSを使わず、active issue worktree の realpath containmentで制限されています。共有されているのは Bash 経由の Git mutation policyだけです。さらにremote pushでは、Codex adapterが共有policyへ委譲し、初回branch作成はpolicy内部で実際のprobe・push・readbackを完了した後、元のshell commandを再実行させない設計です。
修正要求
Issue名とOutcomeを、少なくとも以下に狭めるべきです。
remote publish laneは原則Out of Scopeとし、「将来同じ契約スナップショットを参照できる」程度に留めるべきです。
P0-2: 「明示 pathspec なら安全」というAC3の前提が誤っている
Gitのpathspecは単なるファイル名ではなく、パターンです。ディレクトリ名は配下全体を対象にでき、
*、?、先頭:によるpathspec magicも存在します。Git公式文書でも、pathspecがtreeのsubsetを指定するパターンであること、directory prefixやmagic syntaxを持つことが明記されています。(Git)したがって、次は「明示的に見える」だけで安全ではありません。
実行側は少なくとも次のいずれかを強制する必要があります。
または、
--literal-pathspecsはglobとpathspec magicを無効化します。--pathspec-file-nulはNUL区切りとし、改行や引用符を含む文字もliteralとして扱います。(Git)現在のpolicyは広いpathspecやdirectoryを事前に拒否していますが、判定後に元のshell commandを別途実行させる構造です。commitもcached diffを検査した後で実際のcommitが実行されるため、判定と使用の間でindexが変更されるTOCTOUが残ります。
修正要求
AC3を次の契約へ変更すべきです。
モデルが生成したraw
git add/git commitは認可しないexact argvのcontrolled executorだけを認可する
executor自身がstage・検査・commitまで所有する
pathspecはliteralとして扱う
HEAD、branch、Issue、worktree、契約fingerprintを同一実行にbindする
staged状態を再取得し、認可した集合との一致を確認する
これは既存のinitial branch create laneが採用した「policy内でtransactionを実行し、元commandを再実行させない」構造と整合します。
P0-3: AC1のインベントリ検証コマンドが不完全
Issue記載の検索対象は以下です。
これでは
docs/dev/agent-runtime-ops.mdが検索対象外です。実際に参照はdocsにも存在します。また、廃止対象には実質的に以下も含まれます。
CODEX_ALLOWED_PATHS_MODECODEX_LEGACY_ALLOW_WRITES.guard_shadow_log.jsonlstrict/workspace/shadowのself-test
runtime opsの設定例
Codex Write/Edit/ApplyPatch hook wiring
CODEX_LEGACY_ALLOW_WRITESはコードとdocsの双方に残っています。さらに、docsには「CI / automationではIssue contractから
CODEX_ALLOWED_PATHSを設定する」と書かれていますが、リポジトリ内にはそのproducerが確認できません。現状は実装されたproducerというより、手動または外部launcherへの期待値です。修正要求
最低限、検証コマンドを次へ置き換えるべきです。
インベントリ表には以下を必須列として持たせるべきです。
列 | 内容 -- | -- boundary | edit / stage / commit / push producer | 誰が値・契約を生成するか consumer | どのhook/policyが読むか authority | 認可の正本か、単なるhintか Claude/Codex | どちらが利用するか removal destination | 削除・置換先 rollback | 旧状態への戻し方「repo内にproducerなし」も正式な調査結果として記録する必要があります。
P0-4: threat modelが定義されていない
現在の
.codex/config.toml自身が、project-local設定を「fail-closed local guardrailであり、security boundaryではない」と明記しています。また、過去に検討されたexternal trust rootは、個人開発のthreat modelには過剰としてnot plannedとなり、未配線コードも削除されています。現行publish laneはcandidate repository内のpolicyを使う設計です。
Codexのproject-local rulesも、project
.codex/layerがtrustedな場合にのみ読み込まれます。つまり、project-local guardを敵対的なcandidate codeから独立した信頼境界として説明することはできません。(OpenAI Developers)修正要求
「安全」の意味を次に限定してください。
この記述なしに「安全なpublish境界」をAcceptance Criteriaへ置くのは過大claimです。
P1-1: 既存のrename-aware Allowed Paths gateを再利用する要求がない
現在のcommit判定は概ね次を使っています。
--name-onlyはpost-image側のファイル名しか返さず、rename元のpath provenanceやchange typeを失います。一方、既存の
allowed_paths_review_gate.pyは既に以下を実装しています。git diff --name-status -M -zrenameのcurrent pathとprevious pathの双方を監査
malformed statusや不完全provenanceを
indeterminateIssue contract fingerprint
normalized Allowed Paths matcher
worker self-reportを正本として使用しない
Git公式でも、
--name-statusはpathと変更種別を返し、-zは特殊文字をquoteせずNUL区切りにする仕様です。(Git)修正要求
後続実装Issueに以下を入れるべきです。
allowed_paths_review_gate.pyからmatcher・normalizer・changed-file recordを共有moduleへ抽出staging/commit/reviewで同じgrammarを使用
renameは旧path・新pathの両方が許可範囲内であること
deletion、type change、submodule changeを明示的に分類
name-onlyを認可oracleとして使用しないP1-2: 関連Issueの優先順位が不適切
#1592 は #1579 と #1588 をincident evidenceとして挙げていますが、直接衝突するのは #1542 と #963 です。
#1542 は、まさに
CODEX_ALLOWED_PATHSのworkspace/strict semanticsをGit mutation laneへ反映する実装Issueです。#963 はClaude専用の新規staging hookを追加し、
git add/git commitをAllowed Pathsと照合するIssueです。これは「Claude/Codex共通境界」という#1592の目的と正面衝突します。修正要求
「#1542との移行順序を記録する」だけでは不十分です。以下を明示すべきです。
実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 と 実装: staging guard で git add -A と Allowed Paths 外 commit 混入を防ぐ #963 の実装を一旦freeze
#1592で採用契約を確定
新しいstaging/commit実装Issueが 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 を
supersedes#963は重複部分をclose、またはworktree hook wiringだけに縮小
実装: command_registry.py の scope_rollup.run argv テンプレートに --invocation-id/--requested-at を反映する #1579/#1588はdependencyではなくincident evidenceとして分類
#1542を先に実装して直後に環境変数を削除する順序は、一時的な互換コードとテストを増やすだけです。
P1-3: 一つのimplementation Issueでは広すぎる
CODEX_ALLOWED_PATHSの完全廃止には少なくとも二つの独立変更があります。A. 共通staging/commit契約
Issue scope snapshot
matcher
controlled executor
raw add/commit deny
Claude/Codex hook wiring
実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542/#963の整理
B. Codex編集hookからの環境変数廃止
CODEX_ALLOWED_PATHS_MODEstrict/workspace/shadow
CODEX_LEGACY_ALLOW_WRITESshadow log
check-codex-agents.mjsruntime ops docs
self-tests
native permission profileとの役割分担
現在のCodex profileはworkspace全体を書込み可能としながら、
assetsとLICENSESをread-onlyにしています。Codexのpermission profileは広いworkspace writeの内側に狭いdeny/read ruleを配置でき、denyが優先されます。したがって、編集時のfilesystem境界はnative permission profileへ寄せ、Issue単位のscopeはstaging/commit/reviewで担保する方が責務が明確です。(OpenAI Developers)
修正要求
AC5の「implementation Issueを1件起票する」は、上記A/Bの二件へ変更すべきです。remote publishの証跡形式変更まで含めるなら、さらに三件目です。
P1-4: protected pathの正本が分散している
現在確認できる保護定義は分散しています。
Codex permission profile:
assets/LICENSESをread-onlycheck-codex-agents.mjs:assets/LICENSES/.env*/secrets/**worktree scope guard: worktree containment
Git mutation policy: Allowed Pathsとの一致
protected_path_violationの実装検索ではcheck-codex-agents.mjsしか確認できませんでした。環境変数を削除する際に、保護pathが「native sandboxでは守られるがClaude stagingでは守られない」といったsplit-brainを起こす可能性があります。
修正要求
共通契約に以下を持たせるべきです。
IssueのAllowed Pathsに記載されてもprotected policyが常に優先される契約にしてください。
推奨する採用設計
1. 環境変数ではなく、検証可能な契約スナップショットを使う
例:
ファイルはprivate/local artifactとし、Issue bodyの更新、branch drift、base drift、worktree mismatchでstale扱いにします。
2. controlled stage/commit executorを作る
概念的には以下です。
executorは同一process内で次を行います。
repository、worktree、branch、HEAD、Issue binding検証
literal pathspecでexact filesのみstage
git diff --cached --name-status -M -zでindexを再取得rename旧新path、deletion、type change、protected pathを検査
staged集合がrequested集合と一致することを確認
commit
commit diffを再読して監査結果と一致することを確認
より強い原子性が必要なら、private
GIT_INDEX_FILE上でtreeを作成し、commit-treeでcommit objectを生成した後、git update-ref <ref> <new> <expected-old>のcompare-and-swapでbranchを更新する設計が適します。update-refはcurrent refがexpected old OIDと一致する場合だけ更新できます。(Git)3. raw Git mutationはagent laneでdenyする
raw
git addraw
git commitrtk git addrtk git commitはcontrolled executorの外ではdenyします。人間の通常操作まで制限するかは別policyとして明示します。
4. remote publish laneは当面変更しない
既存のpush laneはhead・remote head・Allowed Paths gate・branchをbindしており、初回branch作成もcontrolled transaction化されています。
初回実装では既存publish laneを保持し、新しいscope snapshotのfingerprintだけを証跡として受け取れるようにするのが安全です。
#1592に追加すべきAcceptance Criteria
最低限、以下が必要です。
AC6: edit / stage / commit / pushごとにproducer、consumer、authority、Claude/Codex差分を表で記録する。
AC7: raw pathspec hook、contract artifact + controlled executor、native permission profile + review gateの三案を比較する。
AC8: threat modelを明記し、repository-local guardrailをsecurity boundaryと主張しない。
AC9: rename旧新path、deletion、type change、submodule、特殊文字、stale snapshot、HEAD raceの扱いを確定する。
AC10: #1542と#963について
supersede / close / retainのいずれかを決定する。AC11: remote publish laneを今回変更するか、明示的にOut of Scopeにする。
AC12: protected path policyの単一正本を決定する。
AC13: rollback時に旧envと新契約が同時にauthorityにならないことを保証する。
AC14: 後続実装を「staging/commit」と「Codex edit env removal」に分割する。
最終評価
#1592の核心である「Codex固有envを正規契約から外す」は正しいです。しかし、現状のまま進めると以下のどれかになります。
envをJSONファイルへ移しただけの名前変更
editとstageとpushの三重実装
pathspec magicによる範囲拡大
index raceによるscope外commit
Claude/Codex間のprotected path split-brain
#1542と#963を実装した直後に削除する二重作業
採用案は Issue契約スナップショット + 共通matcher + controlled stage/commit executor とし、Codex編集hookの環境変数廃止は別Issueへ分割するのが妥当です。
## 判定REQUEST_CHANGES — 現状の #1592 は調査Issueとして未完了で、後続実装Issueを起票できる粒度に達していません。
方向性自体は妥当です。
CODEX_ALLOWED_PATHSを Claude/Codex 共通の正規契約として扱うのは不自然であり、廃止すべきです。ただし、現在のIssueは 編集・staging・commit・remote publishという別々の境界を「publish境界」として混同しています。現時点ではコメントがなく、
parent_issue: #1592の後続Issueも確認できません。敵対的レビュー結果
P0-1: 「publish境界」という問題設定が実装実態と一致していない
CODEX_ALLOWED_PATHSが現在関与しているのは主に次の二箇所です。apply_patch/Edit/Writeに対する編集範囲制限rtk git add/rtk git commit判定一方、
git pushの認可はLOOP_PUBLISH_EXPECTED_REMOTE_HEAD、LOOP_PUBLISH_ALLOWED_PATHS_GATE_STATUS、head bindingなど、独立したLOOP_PUBLISH_*証跡群を使っています。Claude の Write/Edit は
CODEX_ALLOWED_PATHSを使わず、active issue worktree の realpath containmentで制限されています。共有されているのは Bash 経由の Git mutation policyだけです。さらにremote pushでは、Codex adapterが共有policyへ委譲し、初回branch作成はpolicy内部で実際のprobe・push・readbackを完了した後、元のshell commandを再実行させない設計です。
修正要求
Issue名とOutcomeを、少なくとも以下に狭めるべきです。
remote publish laneは原則Out of Scopeとし、「将来同じ契約スナップショットを参照できる」程度に留めるべきです。
P0-2: 「明示 pathspec なら安全」というAC3の前提が誤っている
Gitのpathspecは単なるファイル名ではなく、パターンです。ディレクトリ名は配下全体を対象にでき、
*、?、先頭:によるpathspec magicも存在します。Git公式文書でも、pathspecがtreeのsubsetを指定するパターンであること、directory prefixやmagic syntaxを持つことが明記されています。(Git)したがって、次は「明示的に見える」だけで安全ではありません。
実行側は少なくとも次のいずれかを強制する必要があります。
または、
--literal-pathspecsはglobとpathspec magicを無効化します。--pathspec-file-nulはNUL区切りとし、改行や引用符を含む文字もliteralとして扱います。([Git]2)現在のpolicyは広いpathspecやdirectoryを事前に拒否していますが、判定後に元のshell commandを別途実行させる構造です。commitもcached diffを検査した後で実際のcommitが実行されるため、判定と使用の間でindexが変更されるTOCTOUが残ります。
修正要求
AC3を次の契約へ変更すべきです。
git add/git commitは認可しないこれは既存のinitial branch create laneが採用した「policy内でtransactionを実行し、元commandを再実行させない」構造と整合します。
P0-3: AC1のインベントリ検証コマンドが不完全
Issue記載の検索対象は以下です。
これでは
docs/dev/agent-runtime-ops.mdが検索対象外です。実際に参照はdocsにも存在します。また、廃止対象には実質的に以下も含まれます。
CODEX_ALLOWED_PATHS_MODECODEX_LEGACY_ALLOW_WRITES.guard_shadow_log.jsonlCODEX_LEGACY_ALLOW_WRITESはコードとdocsの双方に残っています。さらに、docsには「CI / automationではIssue contractから
CODEX_ALLOWED_PATHSを設定する」と書かれていますが、リポジトリ内にはそのproducerが確認できません。現状は実装されたproducerというより、手動または外部launcherへの期待値です。修正要求
最低限、検証コマンドを次へ置き換えるべきです。
git grep -n -E \ 'CODEX_ALLOWED_PATHS|CODEX_ALLOWED_PATHS_MODE|CODEX_LEGACY_ALLOW_WRITES|guard_shadow_log'インベントリ表には以下を必須列として持たせるべきです。
「repo内にproducerなし」も正式な調査結果として記録する必要があります。
P0-4: threat modelが定義されていない
現在の
.codex/config.toml自身が、project-local設定を「fail-closed local guardrailであり、security boundaryではない」と明記しています。また、過去に検討されたexternal trust rootは、個人開発のthreat modelには過剰としてnot plannedとなり、未配線コードも削除されています。現行publish laneはcandidate repository内のpolicyを使う設計です。
Codexのproject-local rulesも、project
.codex/layerがtrustedな場合にのみ読み込まれます。つまり、project-local guardを敵対的なcandidate codeから独立した信頼境界として説明することはできません。([OpenAI Developers]3)修正要求
「安全」の意味を次に限定してください。
この記述なしに「安全なpublish境界」をAcceptance Criteriaへ置くのは過大claimです。
P1-1: 既存のrename-aware Allowed Paths gateを再利用する要求がない
現在のcommit判定は概ね次を使っています。
--name-onlyはpost-image側のファイル名しか返さず、rename元のpath provenanceやchange typeを失います。一方、既存の
allowed_paths_review_gate.pyは既に以下を実装しています。git diff --name-status -M -zrenameのcurrent pathとprevious pathの双方を監査
malformed statusや不完全provenanceを
indeterminateIssue contract fingerprint
normalized Allowed Paths matcher
worker self-reportを正本として使用しない
Git公式でも、
--name-statusはpathと変更種別を返し、-zは特殊文字をquoteせずNUL区切りにする仕様です。(Git)修正要求
後続実装Issueに以下を入れるべきです。
allowed_paths_review_gate.pyからmatcher・normalizer・changed-file recordを共有moduleへ抽出name-onlyを認可oracleとして使用しないP1-2: 関連Issueの優先順位が不適切
#1592 は #1579 と #1588 をincident evidenceとして挙げていますが、直接衝突するのは #1542 と #963 です。
#1542 は、まさに
CODEX_ALLOWED_PATHSのworkspace/strict semanticsをGit mutation laneへ反映する実装Issueです。#963 はClaude専用の新規staging hookを追加し、
git add/git commitをAllowed Pathsと照合するIssueです。これは「Claude/Codex共通境界」という#1592の目的と正面衝突します。修正要求
「#1542との移行順序を記録する」だけでは不十分です。以下を明示すべきです。
supersedes#1542を先に実装して直後に環境変数を削除する順序は、一時的な互換コードとテストを増やすだけです。
P1-3: 一つのimplementation Issueでは広すぎる
CODEX_ALLOWED_PATHSの完全廃止には少なくとも二つの独立変更があります。A. 共通staging/commit契約
B. Codex編集hookからの環境変数廃止
CODEX_ALLOWED_PATHS_MODECODEX_LEGACY_ALLOW_WRITEScheck-codex-agents.mjs現在のCodex profileはworkspace全体を書込み可能としながら、
assetsとLICENSESをread-onlyにしています。Codexのpermission profileは広いworkspace writeの内側に狭いdeny/read ruleを配置でき、denyが優先されます。したがって、編集時のfilesystem境界はnative permission profileへ寄せ、Issue単位のscopeはstaging/commit/reviewで担保する方が責務が明確です。([OpenAI Developers]5)
修正要求
AC5の「implementation Issueを1件起票する」は、上記A/Bの二件へ変更すべきです。remote publishの証跡形式変更まで含めるなら、さらに三件目です。
P1-4: protected pathの正本が分散している
現在確認できる保護定義は分散しています。
Codex permission profile:
assets/LICENSESをread-onlycheck-codex-agents.mjs:assets/LICENSES/.env*/secrets/**worktree scope guard: worktree containment
Git mutation policy: Allowed Pathsとの一致
protected_path_violationの実装検索ではcheck-codex-agents.mjsしか確認できませんでした。環境変数を削除する際に、保護pathが「native sandboxでは守られるがClaude stagingでは守られない」といったsplit-brainを起こす可能性があります。
修正要求
共通契約に以下を持たせるべきです。
IssueのAllowed Pathsに記載されてもprotected policyが常に優先される契約にしてください。
推奨する採用設計
1. 環境変数ではなく、検証可能な契約スナップショットを使う
例:
ファイルはprivate/local artifactとし、Issue bodyの更新、branch drift、base drift、worktree mismatchでstale扱いにします。
2. controlled stage/commit executorを作る
概念的には以下です。
executorは同一process内で次を行います。
git diff --cached --name-status -M -zでindexを再取得より強い原子性が必要なら、private
GIT_INDEX_FILE上でtreeを作成し、commit-treeでcommit objectを生成した後、git update-ref <ref> <new> <expected-old>のcompare-and-swapでbranchを更新する設計が適します。update-refはcurrent refがexpected old OIDと一致する場合だけ更新できます。([Git]6)3. raw Git mutationはagent laneでdenyする
git addgit commitrtk git addrtk git commitはcontrolled executorの外ではdenyします。人間の通常操作まで制限するかは別policyとして明示します。
4. remote publish laneは当面変更しない
既存のpush laneはhead・remote head・Allowed Paths gate・branchをbindしており、初回branch作成もcontrolled transaction化されています。
初回実装では既存publish laneを保持し、新しいscope snapshotのfingerprintだけを証跡として受け取れるようにするのが安全です。
#1592に追加すべきAcceptance Criteria
最低限、以下が必要です。
supersede / close / retainのいずれかを決定する。最終評価
#1592の核心である「Codex固有envを正規契約から外す」は正しいです。しかし、現状のまま進めると以下のどれかになります。
採用案は Issue契約スナップショット + 共通matcher + controlled stage/commit executor とし、Codex編集hookの環境変数廃止は別Issueへ分割するのが妥当です。
squne121 commentedon Jul 18, 2026
issue-refinement-loop 終了報告(human_escalation)
termination_reason:
human_escalationtermination_cause:
human_judgment_requirediteration: 1
実施済み事項
CODEX_ALLOWED_PATHS/CODEX_ALLOWED_PATHS_MODEの主な consumer を確認済み(scripts/check-codex-agents.mjs(strict/workspace/shadow の主 enforcement)、scripts/agent-guards/git_mutation_command_policy.py:1031)。git add -A/git add .相当はgit_add_requires_explicit_pathspecreason_code で拒否される実装であることを確認。Issue 実装: workspace モードと Git staging guard の Allowed Paths 契約を整合させる #1542 は OPEN・workspace/staging guard 整合が主題であることを確認。重複する OPEN Issue なし。rtkが VC preflight allowlist 外、rg検索パスが broad 判定)を修正済み。contract_readiness_check.py --mode staticでstatus: goを独立に再現確認済み。他セクション(Outcome/Scope/AC本文/Allowed Paths 等)は無変更。human 判断が必要な理由(scope_delta_authority_evidence、boundary_flags: requires_issue_split)
対象 anchor comment(OWNER投稿、https://github.com/squne121/loop-protocol/issues/1592#issuecomment-5010747083)は、現在の AC1-AC5(read-only research scope)に対して、以下の広範な追加提案(AC6-AC14 相当)を含んでいます:
この anchor comment は本 skill の
scope_delta_authority_evidence_v1判定上boundary_flags: requires_issue_split = true(confidence: explicit、author_association: OWNER)に該当します。references/scope-signal-guard.mdの route 決定優先順位では、trusted anchor(OWNER)由来であってもboundary_flagsのいずれかが true の場合はhuman_escalationに倒す設計(AC18、優先順位: destructive > permission > external_service > allowed_paths > issue_split)であり、AI が自動的に AC6-AC14 を Issue 本文へ追記する、または新規 Issue へ分割する判断を代行することはできません。人間に決めていただきたいこと
判断後、再度 issue-refinement-loop を実行すれば、確定したスコープで本文を更新します。
squne121 commentedon Jul 18, 2026
RESEARCH_RESULT_V1
1. Live baseline
issuecomment-5010747083、REQUEST_CHANGES、author_association: owner)の指摘(P0-1〜P0-4、P1-1〜P1-4)と、後続の issue-refinement-loophuman_escalation報告を経て、AC6–AC13 が本文に反映済みであることを確認した(body 内 Notes for Reviewer に記載のとおり)。c0048fab6e5544c5b599cd0feb8f85571a9bd4b8。直近の CI run(Check Japanese Content 他)はsuccess。gh pr list --search "1592 in:body"0件)。scripts/check-codex-agents.mjs、git_mutation_command_policy.py、allowed_paths_review_gate.py、.codex/config.toml、.codex/hooks.json、.claude/settings.json、docs/dev/agent-runtime-ops.md)を変更する open PR: なし。現在の open PR は 実装: Codex Stop/SubagentStop session manifest の canonical output root を repo 外へ移行する #1586(session manifest root 移行)、fix: pr_review_only VC の current-head 判定を修正する #1544(Issue 実装: pr_review_only VC の current-head adjudication を修正する #1540、pr_review_only VC current-head 判定。#1592の対象ファイルとは無関係、プロンプト前提と実態の乖離を確認)、feat: Codex scope-rollup capture を復旧 (#1527) #1534(scope-rollup capture)、feat(cleanup): 同一実行内の branch-only fallback を追加 #1528(post-merge-cleanup branch-only fallback)の4件のみで、いずれも本調査対象ファイルと衝突しない。parent_issue: "#1592"またはタイトルにCodex edit env removal/staging/commit 境界を含む既存子 Issue: なし(重複起票なし、検索確認済み)。2. Producer / Consumer / Authority inventory
scripts/check-codex-agents.mjs(denyForWriteTool, apply_patch/Edit/Write hook, L1189-1349)CODEX_ALLOWED_PATHS_MODE(workspace/strict/shadow/unknown),CODEX_ALLOWED_PATHS(改行区切り).claude/hooks/worktree_scope_guard.py)isProtectedPath()固定実装:assets/,LICENSES/,.env*,secrets/**(L1234-1244)。全モード共通 denyworkspaceに自動復帰git add)CODEX_ALLOWED_PATHSscripts/agent-guards/git_mutation_command_policy.pyclassify_rtk_git_mutation()(L1428-1497,_load_allowed_paths()L1030)CODEX_ALLOWED_PATHS未設定なら常にallowed_paths_missing_for_git_mutationで拒否、これが #1542 の対象不整合そのもの)_normalize_allowed_patternはglob*/**は許可しwildcard以外は禁止だが directory prefix 自体は許可されるためassetsを明示allowすると通る)classify_rtk_git_mutation()L1498-1529、_staged_repo_paths()L1111(git diff --cached --name-only -zのみ、rename provenance なし)LOOP_PUBLISH_*群(LOOP_PUBLISH_EXPECTED_REMOTE_HEAD/_CURRENT_REMOTE_HEAD/_DECLARED_PUBLISH_HEAD/_VERIFIED_HEAD/_ALLOWED_PATHS_GATE_STATUS/_REMOTE_READBACK_SOURCE。CODEX_ALLOWED_PATHSとは独立)git_mutation_command_policy.pyの push lane(L1531-1620超、_load_publish_guard_context()L983-1027)、codex-hook-adapter.mjs(publish lane approval bridge, #1408)"repo内にproducerなし"の正式記録:
docs/dev/agent-runtime-ops.md:274「CI/自動化: strict モード(CODEX_ALLOWED_PATHSを Issue contract から設定する)」との記述があるが、git grep/rgで Issue contract からCODEX_ALLOWED_PATHSを注入する実装済み producer(script/hook/CI job)はリポジトリ内に存在しない。手動 export または外部 launcher への期待値のみ。3. 三案比較
(a) raw pathspec hook: 現行方式。
git_mutation_command_policy.pyはcommand文字列を静的解析して判定するが、判定後に元の shell command(rtk git add/rtk git commit)を別途実行させる構造のため、判定〜実行間で index が変更されうる TOCTOU が残る。また pathspec magic(:(top)、:(exclude)、*/**)を--literal-pathspecs相当で無効化していない(_contains_broad_pathspecはワイルドカード文字列を拒否するが、git --literal-pathspecsのような実行時強制はない)。Claude/Codex間でmode概念が非対称(Codexのみmode enum、rtk classifierはCODEX_ALLOWED_PATHS有無の二値)。rollbackは容易(env unset)だが、fail-closedすぎて通常編集を止める副作用がある(#1542の実際の障害)。(b) contract snapshot + controlled executor: Issue contractから検証済みscope snapshotを生成し、executorがstage/検査/commitを単一transactionとして所有。raw add/commitはagent laneでdeny。HEAD/branch/worktree/Issue/fingerprintをbindでき、literal path・NUL区切り・staged-set一致・rename provenance(既存
allowed_paths_review_gate.pyの--name-status -M -zパーサを共有可能)を実現できる。実装面積はexecutor新設+matcher共有化で中程度。rollbackはsnapshot schema versionで管理可能。#1542/#963とは、rtk classifierの置き換え先として競合するため、着手前に#1542/#963のfreeze/supersedeが必要。(c) native permission profile + review gate:
.codex/config.tomlは既にworkspace全体write可、assets/LICENSESのみread-onlyのdeny-overrideを実装済み(.env*/secrets/**は含まれない = P1-4のsplit-brain実例)。編集時のfilesystem境界をnative profileへ寄せる設計。ただしnative configはIssue単位のAllowed Paths(動的・Issueごとに変わる)を直接表現できないため、review gate(既存rename-aware matcher)との併用が必須。protected pathのSSOTをnative configに一本化するには、Node/Python/TOML間でのvalidated mirrorが必要。採用根拠: stage/commitは(b)、editは(c)、protected pathは言語非依存の単一policyファイルをSSOTとしvalidated mirrorで一致保証、という組み合わせが、実装実態(Claude editはCODEX_ALLOWED_PATHS不使用、push laneは独立)と整合する。
4. 採用設計
allowed_paths_review_gate.pyから共有moduleへ抽出し、staging/commit/reviewで同一grammarを使う。.codex/config.tomlのnative permission profile + worktree realpath containment(Claude)を維持・強化。LOOP_PUBLISH_*laneを当面維持(Out of Scope)。将来、snapshot fingerprintをpublish evidenceに含める拡張余地は残す。assets/**,LICENSES/**,.env,.env.*,**/.env,**/.env.*,secrets/**を含む言語非依存の単一policy(PROTECTED_PATHS_POLICY_V1)をSSOTとし、.codex/config.toml・.claude/settings.json・Node/Pythonのconsumerはvalidated mirrorとして扱う(現状3箇所で定義が分散していることを確認:check-codex-agents.mjsのisProtectedPath、.codex/config.tomlのworkspace_roots deny(assets/LICENSESのみ)、.claude/settings.jsonのRead/Edit deny rules(.env系))。IssueのAllowed Pathsに書かれていてもprotected policyが優先。git add/git commit/rtk git add/rtk git commitはcontrolled executor外でdeny。5. Threat model
本設計は cooperative agent workflow における誤操作・Issue scope逸脱・無関係変更のstaging・broad staging・protected path混入・stale contract/stale headの利用を防止するrepository-local guardrailである。悪意ある同一ユーザープロセス、candidate branchによるpolicy自体の書き換え、repository-local configを信頼しない実行、OS-levelアデバーサリ、credential theft、hook bypass権限を持つ利用者には耐えるsecurity boundaryとして主張しない(
.codex/config.toml:6の既存の明示的限定と整合)。6. Edge case matrix
git diff --name-status -M -zで旧path・新pathの双方をAllowed Paths判定(既存allowed_paths_review_gate.pyのChangedFileRecordを再利用)-C検出時は元pathも判定対象-z(NUL区切り)で quote なしのraw bytesとして扱う。leading dashは--区切り後のpathspecとして扱う--literal-pathspecs相当を強制、または--pathspec-from-file+--pathspec-file-nulでliteral化GIT_INDEX_FILE+git update-ref <ref> <new> <expected-old>のcompare-and-swap、過剰な場合は通常indexでの再取得+一致確認に留め、残存raceをdocsに明記git diff --cached --name-only(rename-unaware)は認可oracleとして使用しない。7. #1542 / #963 の処遇
git_mutation_command_policy.pyのmode整合が対象): 新しい staging/commit実装Issue(Child A)へ supersede。理由: #1542が解決しようとしている「workspaceモードで通常editが許可されているのにstagingがallowed_paths_missing_for_git_mutationで止まる」不整合は、根本的にはCODEX_ALLOWED_PATHS依存のrtk classifierをcontrolled executorへ置き換えることで解消され、mode enum自体の整合作業は不要になる。#1542はChild Aマージ後、new issue URLと理由をコメントしnot_plannedとしてclose。git add -A/Allowed Paths外commit混入防止): 重複部分(staging guardのcore判定)はChild Aへsupersede。Claude固有のhook配線が必要な部分のみ残す可能性があるが、現状の記載は「Claude/Codex共通境界」というChild Aの目的と正面衝突するため、Child Aマージ後に再評価しclose or scope reduction。allowed_paths_missing_for_git_mutationのincident referenceとして調査: CODEX_ALLOWED_PATHS を廃止する共通 publish 境界を設計する #1592 Handoff Contractに残す)、#1588はOPEN(worktree bootstrap launcher統合、別トピック)。8. Remote publish scope
LOOP_PUBLISH_*群によるexisting branch update/initial branch create transactionは変更しない。remote-head readback・head bindingは既存のまま維持する。将来、同じIssue scope snapshot fingerprintをpublish evidenceに含める拡張余地は残すが、Child A/Bには含めない(Out of Scope)。9. Protected path policy SSOT
最低限
assets/**,LICENSES/**,.env,.env.*,**/.env,**/.env.*,secrets/**を含むPROTECTED_PATHS_POLICY_V1を言語非依存の単一ファイル(新設)として正本にする。現状分散している3箇所(.codex/config.tomlのworkspace_roots deny=assets/LICENSESのみ、scripts/check-codex-agents.mjsのisProtectedPath=assets/LICENSES/.env系/secrets、.claude/settings.jsonのRead/Edit denyルール=.env系のみ)はいずれもSSOTを直接参照できないため、validated mirror(起動時または CI での一致検証)として扱う。IssueのAllowed Pathsに保護pathが書かれていてもprotected policyが優先する契約とする。10. Rollback authority
旧env(
CODEX_ALLOWED_PATHS系)と新契約(Issue scope snapshot + controlled executor)は同時にauthorityにならない設計とする。schema/authority versionフィールドでold_only→migration_validation→new_only→ (必要なら)rollback_to_oldの状態遷移を明示し、各状態でauthorityは常に一つ。old envとnew snapshotのunion判定、一方deny/他方allowのfallback、unknown versionのfail-open、rollback時の二重authority、stale snapshotの黙認は禁止する。11. 子Issue URL
実装: Issue scope snapshot と controlled executor で共通 staging/commit 境界を構築する(起票後にURLを追記)実装: Codex 編集ガードから CODEX_ALLOWED_PATHS 系 env を廃止する(起票後にURLを追記、Child A merge後着手)12. AC1–AC13 evidence matrix
rg -n CODEX_ALLOWED_PATHS ./rg -n CODEX_LEGACY_ALLOW_WRITES ./rg -n guard_shadow_log .の実行結果(本コメント section 2)13. 実行した Verification Commands と結果
14. 未解決事項
なし。producer未実装箇所(strict mode Issue contract injector)は「repo内にproducerなし」として正式に記録済み(section 2)。
squne121 commentedon Jul 18, 2026
test
squne121 commentedon Jul 18, 2026
CLOSURE_EVIDENCE_V1
先の RESEARCH_RESULT_V1(#issuecomment-5010971038)の section 11(子Issue URL)を以下で確定する。
子 Issue(起票完了)
parent_issue: "#1592"、sub-issue登録済み・parent_verified: true)parent_issue: "#1592"、sub-issue登録済み・parent_verified: true、blocked-by #1611登録済み・dependency_verified: true)両Issueとも
validate_issue_body.pyPASS、post-create ready tuple validationall_passed: true、Allowed Paths・AC・Verification Commands・rollback設計を含む。AC1–AC13 充足状況
RESEARCH_RESULT_V1(#issuecomment-5010971038)section 12 の evidence matrix により全AC充足。AC5(2件の実装Issue起票・本Issueからのリンク)は本コメントで確定。
#1542 / #963 の処遇(記録)
not_plannedとしてclose予定。Close
上記により、本Issueの調査scope(producer/consumer/authority表・三案比較・採用設計・threat model・edge case・#1542/#963処遇・remote publish scope・protected path policy SSOT・rollback authority・子Issue起票)は完了した。
completedとしてクローズする。(注: 本コメント投稿前に暫定コメント「test」を伴うclose操作を誤って実行した。本コメントが正式なclosure evidenceであり、先の暫定コメントは無視すること。)