Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1137"
goal_ref: "codex execpolicy required gate を fail-open から fail-closed へ修正し、execpolicy の coarse routing 契約と cleanup-route contract evidence を CI で再現可能に検証する"
change_kind: workflowSource
- origin: PR feat(#1137): cleanup_exec 認可境界 + one-shot V3 + 実 hook 統合 (OWNER review 反映) #1143(実装: guard arbitration preflight と cleanup contract delivery を機械化する (agent-ops) #1137, merged 2026-06-23T11:28:54Z)OWNER review Blocker 10 の follow-up
- dedupe_key: "follow-up:squne121/loop-protocol:pr/1143:blocker10-codex-execpolicy-enablement"
- 参照コメント: PR feat(#1137): cleanup_exec 認可境界 + one-shot V3 + 実 hook 統合 (OWNER review 反映) #1143 #issuecomment-4778597564(escalation), OWNER 回答(codex 版指定), Issue 実装: codex execpolicy gate を fail-open から fail-closed へ修正し、execpolicy と hook の責務境界を明確化する (#1137 Blocker10 follow-up) #1150 OWNER comment 実装: codex execpolicy gate を fail-open から fail-closed へ修正し、execpolicy と hook の責務境界を明確化する (#1137 Blocker10 follow-up) #1150 (comment)
- 現在の修正入力: PR feat(#1150): fail-close codex execpolicy CI gate #1158 OWNER comment feat(#1150): fail-close codex execpolicy CI gate #1158 (comment)
Parent Issue
Parent Goal Ref
- Goal: codex execpolicy と cleanup-route guard の CI 契約を fail-open なしで維持する
- Desired Destination: required gate で codex execpolicy decision と cleanup-route contract evidence を継続検証できる
Current Validated Scope
.github/workflows/ci.ymlの required lane を Node 22 + stable pinned@openai/[email protected]で fail-closed に修正するscripts/ci/**に strict JSON parser / matrix / artifact writer を分離し、install/probe/case failure を追跡可能にするscripts/ci/tests/**とtests/codex/**で parser / matrix / contract の回帰 test を追加する.github/ci/python-test-plan.jsonで python-test / node-backed-hook-tests の lane coverage SSOT にtests/codex/**の帰属を反映する.claude/hooks/**やscripts/check-codex-agents.mjsなど runtime hook 実体の変更は本 Issue の対象外とし、必要なら Stop Condition に従って別 scope へ送る
Remaining Parent Gaps
-
.codex/rules/default.rules自体の policy 変更は本 Issue では扱わない - runtime hook aggregate parity(
.codex/hooks.jsonの全 handler 再生)を required lane で検証する場合は別 scope で扱う
背景
PR #1143 で codex execpolicy CI の no-op(|| true + codex 不在時 skip)を撤廃し、JSON decision matrix を assert する実装を入れた。しかし現行 .github/workflows/ci.yml は @openai/[email protected] を install し、codex 不在なら EXECPOLICY_SKIPPED、execpolicy 非対応なら EXECPOLICY_UNSUPPORTED を出力して exit 0 するため、required gate が fail-open のまま残っている。
一方で、PR #1158 OWNER comment により、現時点の matrix が runtime hook aggregate decision そのものを再現しているとは言えないこと、malformed cleanup case と failure artifact が偽陽性を含むことが判明した。したがって本 Issue は、runtime hook 実体を変更せずに required CI lane 上の execpolicy / cleanup-route contract evidence を fail-closed に是正する scope として扱う。
Outcome
required CI lane が stable に pin した codex build 上で codex execpolicy check を実行し、top-level decision / matchedRules / return code / provenance を strict に検証する。artifact は install / probe / 各 case の expected / actual / raw JSON / reason code / return code を fail-closed に保持し、少なくとも local cleanup-route contract evidence が tombstone 由来の偽陽性に依存していないことを追跡できる状態。
In Scope
- stable required lane の codex install を fail-closed にし、install 失敗・version 不一致・probe 失敗を CI failure に変更する
- execpolicy を exact command 判定器として扱わず、coarse routing layer としての責務を Issue contract に明記する
- malformed cleanup case を fresh contract 前提で独立実行し、decision だけでなく reason code まで回帰防止する
git branch -df/-fd/--delete --force/ long option unique prefix 等の no-match / force variant を matrix と test に追加する- JSON parser を
decision/matchedRulestop-level contract の厳密検証へ置き換える - inline YAML 中の matrix ロジックを
scripts/ci/**のテスト可能なプログラムへ分離し、artifact 出力を追加する - failure artifact を逐次保存し、install failure / probe failure / case mismatch でも途中証跡を失わない構造にする
- native executable realpath / selected package / sha256 など npm 配布物の provenance を artifact に含める
Out of Scope
.codex/rules/default.rulesの rule 内容変更.claude/hooks/**/scripts/check-codex-agents.mjs/.codex/hooks.jsonの runtime hook 実体変更- cleanup route 以外の hook policy 拡張
- prerelease canary を required lane の代替証跡として扱う設計
- Codex 0.142.0 の aggregate hook executor(全 handler 並行実行)の完全再実装
Acceptance Criteria
- AC1: required lane の codex install は stable build を exact pin し、install 失敗・binary/version 検証失敗・
codex execpolicy check --helpprobe 失敗をすべて CI failure にする - AC2: required lane は
EXECPOLICY_SKIPPED/EXECPOLICY_UNSUPPORTEDを成功終了経路として残さず、prerelease canary を使う場合も non-required 観測 lane に限定する - AC3: execpolicy の役割を coarse routing layer として明記し、exact cleanup argv / contract / one-shot authorization は fixture-based cleanup-route contract evidence で表現する。runtime hook aggregate decision を検証したかのような表現は残さない
- AC4: execpolicy matrix は read-only / exact cleanup + valid contract / malformed cleanup / force・余剰argv・複数target・missing target /
branch -D/branch -df/branch -fd/branch --delete --force/ long option unique prefix /worktree add/worktree pruneを回帰防止し、malformed cleanup は fresh valid contract を前提に reason code まで assert する - AC5: JSON parser は subprocess return code、stdout JSON、top-level
decision、matchedRules型を厳密検証し、recursive token scan と alias 正規化を廃止する。schema drift / parse error / no-match 契約逸脱は CI failure にする - AC6: version / package route / selected platform package / native executable realpath / native executable sha256 / argv / expected / actual / raw JSON / reason code / return code を JSON artifact として逐次保存し、required run に skip marker が残っていないことを追跡できる
- AC7: matrix 実装は
scripts/ci/**に分離され、対応するtests/codex/**またはscripts/ci/tests/**の fixture / unit test で parser と lane contract を再現検証できる
Verification Commands
# AC1
$ rg -n "codex execpolicy check --help" .github/workflows/ci.yml
# AC2
# baseline-expect: fail
$ test -f scripts/ci/codex_execpolicy_matrix.py
# AC3
# baseline-expect: fail
$ rg -n "coarse routing layer" .github/workflows/ci.yml scripts/ci
# AC4
# baseline-expect: fail
$ rg -n "branch -df" .github/workflows/ci.yml scripts/ci tests/codex scripts/ci/tests
# AC5
# baseline-expect: fail
$ rg -n "matchedRules" .github/workflows/ci.yml scripts/ci
# AC6
# baseline-expect: fail
$ rg -n "raw_json" .github/workflows/ci.yml scripts/ci
# AC7
# baseline-expect: fail
$ test -f tests/codex/test_execpolicy_matrix.pyAllowed Paths
- .github/workflows/ci.yml
- .github/ci/python-test-plan.json
- scripts/ci/
- scripts/ci/tests/
- tests/codex/
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
.claude/hooks/**/scripts/check-codex-agents.mjs/.codex/hooks.jsonの修正が merge blocker として必要になった場合- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- stable codex build で required lane を fail-closed にできず、non-required canary 分離だけでは Owner comment の blocker を解消できないと判明した場合
Required Skills
- GitHub Actions
- Python 3
- pytest
Runtime Verification Applicability
- decision: deferred
- reason: required outcome の最終成立は GitHub Actions 上の required lane 実行と artifact readback を前提とし、Issue body 単独では runtime verification が完結しない
- deferred_destination:
- destination_type: issue
- destination_ref: "実装: codex execpolicy gate を fail-open から fail-closed へ修正し、execpolicy と hook の責務境界を明確化する (#1137 Blocker10 follow-up) #1150"
- deferred_verification_condition:
.github/workflows/ci.yml上の required lane が stable codex build で execpolicy matrix と cleanup-route contract evidence を実行し、artifact に provenance / expected / actual / raw JSON / reason code / return code が保存されていること
Activity
squne121 commentedon Jun 25, 2026
判定
REQUEST_CHANGES。
方向性は妥当ですが、現状のIssue contractでは、
execpolicyを一度も実行しないままCIをgreenにでき、さらにprefix policyを「exact command」と誤認する余地があります。Blocker 1: required gateでのloud-skipを禁止する
#1150は「gateを完全有効化する」としながら、最終fallbackとして
EXECPOLICY_UNSUPPORTEDを出力して成功終了する設計を残しています。現行CIも、インストール失敗、CLI不在、非対応buildのすべてをexit 0で処理します。これはsilentではないだけで、enforcementとしてはfail-openです。手元検証では、公式npm経路の
@openai/[email protected]で以下が成立しました。上流の
rust-v0.142.0にもhiddenなexecpolicysubcommandが組み込まれ、同tagのREADMEがcodex execpolicy checkとJSON response schemaを文書化しています。release tag、commit3a76f3a、公開日時もIssue記載と一致します。 (GitHub)したがってrequired laneでは次を必須にすべきです。
install失敗、version不一致、probe失敗はCI failure
EXECPOLICY_SKIPPEDまたはEXECPOLICY_UNSUPPORTEDを出して成功する経路を削除prerelease canaryは別のnon-required laneに限定
AC4は「green」だけでなく、matrixが全件実行され、skip markerが存在しない証跡を要求
Blocker 2:
exact removeという仕様表現が実装と一致しない上流execpolicyは、現時点ではprefix-rule subsetです。ルールはcommand全体の完全一致ではなく、先頭token列へのprefix matchです。
現在のrulesも次のprefixを
promptにしています。そのため、現行rulesを0.142.0で評価すると次のようになります。
これは直ちに認可迂回になるとは限りません。Codexの
PreToolUseには共有worktree_scope_guard.pyが配線されているため、runtime hookが余剰argv、force、hash不一致等を拒否できます。問題は、IssueとPR #1143がexecpolicy側を「exact」と表現し、CI matrixも正常形しか検証していない点です。PR #1143自身も「exact remove /
-dをprompt、forceをforbidden」と説明していますが、実際のexactnessはexecpolicy単体ではなくhookとの合成によって成立しています。(GitHub)仕様を次のように修正すべきです。
matrixもレイヤ別ではなく、以下の合成不変条件を検証してください。
.codex/rules/default.rulesをOut of Scopeに維持するなら、Issue本文から「execpolicyによるexact判定」を削除する必要があります。Blocker 3: 現行JSON parserはschema変更をfailさせない
公式0.142.0のresponse contractは、トップレベルの
decisionとmatchedRulesです。no-matchの場合はdecision自体が省略されます。一方、現行CIはJSON全体を再帰走査して、どこかに
allow、prompt、forbiddenという文字列があれば成功扱いします。さらにdeny → forbidden、ask → prompt等の非公式aliasも受理します。これは互換性を広げる実装であり、AC2の「schema変更でfail」と逆です。subprocessのreturn codeも確認せず、stdoutが空ならstderr上のJSONも受理します。必須修正は以下です。
再帰探索とalias正規化は削除し、no-matchも独立ケースとして検証すべきです。
High: 配布経路を一つに固定する
OpenAIの公式READMEはnpm、Homebrew、GitHub release binaryを配布経路として案内しています。npm package builderも、umbrella packageからOS/architecture別native packageを選択する構成です。
このCIはUbuntu固定なので、primaryは次の一経路で十分です。
name: Install pinned Codex CLI
run: |
CODEX_PREFIX="$RUNNER_TEMP/codex-cli"
npm install
--prefix "$CODEX_PREFIX"
--package-lock=false
--no-audit
--no-fund
"@openai/[email protected]"
CODEX="$CODEX_PREFIX/node_modules/.bin/codex"
test "$("$CODEX" --version)" = "codex-cli 0.142.0"
"$CODEX" execpolicy check --help >/dev/null
現行
python-testjobはPython環境だけを明示セットアップし、npmをrunner imageの暗黙状態に依存しています。リポジトリの標準Node setupはNode 22です。rust-v0.143.0-alpha.2は明示的なprereleaseです。stable installの代替として自動選択せず、互換性観測用のnon-required canaryに限定すべきです。(GitHub)推奨するAcceptance Criteria
actions/setup-nodeでNode 22を固定し、temporary prefixへ@openai/[email protected]をexact pinでinstallする。install失敗はCI failure。実行対象binaryのrealpathと
codex-cli 0.142.0をassertする。codex execpolicy check --helpがexit 0であることをassertする。required laneではprobe失敗をskipしない。subprocessのexit code、stdout JSON、トップレベル
decision、matchedRules型を厳密に検証する。aliasとrecursive token scanは禁止。allow/prompt/forbiddenの正常系に加え、no-match、missing argv、extra argv、複数target、force flag位置違い、combined flagを検証する。
cleanup exactnessはexecpolicy単体ではなく、execpolicy decisionと実PreToolUse hook decisionの組でassertする。
matrixロジックをinline YAMLから
script/ci配下のテスト可能なプログラムへ分離し、parser fixture testを追加する。version、package route、各argv、expected、actual、raw JSON、return codeをJSON artifactとして
if: always()で保存する。required run内に
EXECPOLICY_SKIPPEDまたはEXECPOLICY_UNSUPPORTEDがあれば失敗する。alpha canaryはstable required gateと別stepまたは別jobにし、stableの代替証跡として扱わない。
結論として、#1150はバージョン更新Issueではなく、fail-open gateをfail-closedへ変更し、execpolicyとruntime hookの責務境界を正確に定義するIssueへ改訂する必要があります。
## 判定REQUEST_CHANGES。
方向性は妥当ですが、現状のIssue contractでは、
execpolicyを一度も実行しないままCIをgreenにでき、さらにprefix policyを「exact command」と誤認する余地があります。Blocker 1: required gateでのloud-skipを禁止する
#1150は「gateを完全有効化する」としながら、最終fallbackとして
EXECPOLICY_UNSUPPORTEDを出力して成功終了する設計を残しています。現行CIも、インストール失敗、CLI不在、非対応buildのすべてをexit 0で処理します。これはsilentではないだけで、enforcementとしてはfail-openです。手元検証では、公式npm経路の
@openai/[email protected]で以下が成立しました。上流の
rust-v0.142.0にもhiddenなexecpolicysubcommandが組み込まれ、同tagのREADMEがcodex execpolicy checkとJSON response schemaを文書化しています。release tag、commit3a76f3a、公開日時もIssue記載と一致します。 ([GitHub]1)したがってrequired laneでは次を必須にすべきです。
EXECPOLICY_SKIPPEDまたはEXECPOLICY_UNSUPPORTEDを出して成功する経路を削除Blocker 2:
exact removeという仕様表現が実装と一致しない上流execpolicyは、現時点ではprefix-rule subsetです。ルールはcommand全体の完全一致ではなく、先頭token列へのprefix matchです。
現在のrulesも次のprefixを
promptにしています。そのため、現行rulesを0.142.0で評価すると次のようになります。
これは直ちに認可迂回になるとは限りません。Codexの
PreToolUseには共有worktree_scope_guard.pyが配線されているため、runtime hookが余剰argv、force、hash不一致等を拒否できます。問題は、IssueとPR #1143がexecpolicy側を「exact」と表現し、CI matrixも正常形しか検証していない点です。PR #1143自身も「exact remove /
-dをprompt、forceをforbidden」と説明していますが、実際のexactnessはexecpolicy単体ではなくhookとの合成によって成立しています。([GitHub]2)仕様を次のように修正すべきです。
matrixもレイヤ別ではなく、以下の合成不変条件を検証してください。
branch -D、worktree add/prune.codex/rules/default.rulesをOut of Scopeに維持するなら、Issue本文から「execpolicyによるexact判定」を削除する必要があります。Blocker 3: 現行JSON parserはschema変更をfailさせない
公式0.142.0のresponse contractは、トップレベルの
decisionとmatchedRulesです。no-matchの場合はdecision自体が省略されます。一方、現行CIはJSON全体を再帰走査して、どこかに
allow、prompt、forbiddenという文字列があれば成功扱いします。さらにdeny → forbidden、ask → prompt等の非公式aliasも受理します。これは互換性を広げる実装であり、AC2の「schema変更でfail」と逆です。subprocessのreturn codeも確認せず、stdoutが空ならstderr上のJSONも受理します。必須修正は以下です。
再帰探索とalias正規化は削除し、no-matchも独立ケースとして検証すべきです。
High: 配布経路を一つに固定する
OpenAIの公式READMEはnpm、Homebrew、GitHub release binaryを配布経路として案内しています。npm package builderも、umbrella packageからOS/architecture別native packageを選択する構成です。
このCIはUbuntu固定なので、primaryは次の一経路で十分です。
現行
python-testjobはPython環境だけを明示セットアップし、npmをrunner imageの暗黙状態に依存しています。リポジトリの標準Node setupはNode 22です。rust-v0.143.0-alpha.2は明示的なprereleaseです。stable installの代替として自動選択せず、互換性観測用のnon-required canaryに限定すべきです。([GitHub]3)推奨するAcceptance Criteria
actions/setup-nodeでNode 22を固定し、temporary prefixへ@openai/[email protected]をexact pinでinstallする。install失敗はCI failure。codex-cli 0.142.0をassertする。codex execpolicy check --helpがexit 0であることをassertする。required laneではprobe失敗をskipしない。decision、matchedRules型を厳密に検証する。aliasとrecursive token scanは禁止。script/ci配下のテスト可能なプログラムへ分離し、parser fixture testを追加する。if: always()で保存する。EXECPOLICY_SKIPPEDまたはEXECPOLICY_UNSUPPORTEDがあれば失敗する。結論として、#1150はバージョン更新Issueではなく、fail-open gateをfail-closedへ変更し、execpolicyとruntime hookの責務境界を正確に定義するIssueへ改訂する必要があります。
[-]実装: codex execpolicy gate を codex 0.142.0 + execpolicy check --help capability probe で有効化する (#1137 Blocker10 follow-up)[/-][+]実装: codex execpolicy gate を fail-open から fail-closed へ修正し、execpolicy と hook の責務境界を明確化する (#1137 Blocker10 follow-up)[/+]squne121 commentedon Jun 25, 2026
Contract Review Result
fix(#1150): align python-test coverage with execpolicy contract tests
fix(#1150): harden execpolicy matrix evidence
fix(#1150): detect npm alias codex package
fix(#1150): align guard-pair case keys
fix(#1150): narrow branch force execpolicy checks
feat(#1150): fail-close codex execpolicy CI gate (#1158)
squne121 commentedon Jun 25, 2026
PR #1158 がマージされ、#1150 の対応が完了しました。post-merge cleanup により手動で close しています。