Skip to content

実装: Codex に Claude 相当の project-local permissions と rtk 実行ルールを追加する #343

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "Codex が LOOP_PROTOCOL で `.claude/settings.json` の単純移植ではなく、rtk 前提の stricter project-local guardrail を repo から読めるようにする"
change_kind: workflow

Parent Issue

none

Parent Goal Ref

  • Goal: Codex が .claude/settings.json の意図を踏まえつつ、rtk に集約した stricter repo-local permission / execution policy を読めるようにする
  • Desired Destination: .codex/config.toml / .codex/rules/default.rules / repo ルート AGENTS.md / 関連 SSOT に Codex 用の運用境界と trusted-project 前提が反映されている

Current Validated Scope

  • .codex/config.toml に GitHub 最小 network allowlist を持つ project-local permission profile を追加する
  • .codex/config.toml に npm registry を含む bootstrap profile を分離追加する
  • .codex/rules/default.rules に documented rtk subcommand allow と direct pnpm / mutating git / direct gh forbid を追加する
  • repo ルート AGENTS.md に Codex の作業入口、CLAUDE.md 読み順、保護領域を追加する
  • docs/dev/directory-structure.md と docs/dev/github-ops.md に Codex surface、trusted project 前提、sandbox_mode 競合を追記する

Remaining Parent Gaps

なし

Outcome

.codex/config.toml、.codex/rules/default.rules、repo ルート AGENTS.md、関連 SSOT が追加・更新され、Codex が rtk 前提の stricter project-local guardrail と GitHub 最小 network profile を repo から読める状態。

In Scope

  • Codex の project-local config / rules / AGENTS surface を追加・更新する
  • assets/ と LICENSES/ を read-only / 非編集領域として Codex 側にも反映する
  • Codex の実行入口を rtk に寄せつつ、allow 対象を documented subcommand に絞る
  • GitHub 操作に必要な network allowlist を default profile に含め、npm registry は bootstrap profile に分離する
  • trusted project 前提、sandbox_mode 競合、CLAUDE.md 読み順を docs に明記する

Out of Scope

  • ~/.codex/config.toml など user-global 設定の変更
  • Codex のインストール方法そのものの変更
  • .claude/settings.json / .claude/settings.local.json の変更
  • assets/ / LICENSES/ の中身の編集

Acceptance Criteria

  • .codex/config.toml に approval_policy = "on-request"、default_permissions、workspace write、assets / LICENSES read-only、GitHub 最小 network allowlist を持つ loop-protocol-rtk profile が追加されている
  • .codex/config.toml に npm registry allow を分離した loop-protocol-bootstrap profile が追加されている
  • .codex/rules/default.rules に documented rtk subcommand allow と direct pnpm / direct gh / mutating git forbid が定義されている
  • repo ルート AGENTS.md に CLAUDE.md 読み順、rtk 経由実行、assets/ / LICENSES/ 非編集、read-only git inspection の方針が記載されている
  • docs/dev/directory-structure.md と docs/dev/github-ops.md から Codex の project-local config / rules surface、trusted project 前提、sandbox_mode 競合方針を発見できる
  • codex sandbox linux --permissions-profile loop-protocol-rtk -C . -- rtk gh issue list --repo squne121/loop-protocol --limit 1 --json number,title と codex sandbox linux --permissions-profile loop-protocol-rtk -C . -- rtk gh api repos/squne121/loop-protocol が成功し、GitHub network allowlist の実効性を確認できる

Verification Commands

# AC1
test -f .codex/config.toml && rg -n '^approval_policy = "on-request"$' .codex/config.toml && rg -n '^default_permissions = "loop-protocol-rtk"$' .codex/config.toml && rg -n '^\[permissions\.loop-protocol-rtk\.network\]$' .codex/config.toml && rg -n '^"api.github.com" = "allow"$' .codex/config.toml

# AC2
rg -n '^\[permissions\.loop-protocol-bootstrap\.network\.domains\]$' .codex/config.toml && rg -n '^"registry.npmjs.org" = "allow"$' .codex/config.toml && rg -n '^"\*\.npmjs.org" = "allow"$' .codex/config.toml

# AC3
test -f .codex/rules/default.rules && rg -n 'pattern = \["rtk", "--help"\]' .codex/rules/default.rules && rg -n 'pattern = \["rtk", \["git", "gh", "pnpm"\]\]' .codex/rules/default.rules && rg -n 'pattern = \["gh"\]' .codex/rules/default.rules && rg -n 'pattern = \["git", \["push", "commit", "checkout", "switch", "worktree", "stash", "merge", "rebase", "cherry-pick", "reset", "restore", "add", "rm", "mv", "clean", "apply", "am", "pull", "fetch", "remote", "tag", "config", "submodule"\]\]' .codex/rules/default.rules

# AC4
test -f AGENTS.md && rg -n '^- After this file, read `CLAUDE.md` and follow its read order\.' AGENTS.md && rg -n '^- Run project work through `rtk`\.$' AGENTS.md && rg -n '^- Treat this as a stricter Codex profile than `\.claude/settings\.json`, not a byte-for-byte translation\.$' AGENTS.md

# AC5
rg -n '^- `AGENTS.md`: Codex project-local の実行方針。$' docs/dev/directory-structure.md && rg -n '^- `\.codex/`: Codex project-local config / rules surface。$' docs/dev/directory-structure.md && rg -n '^### 有効化前提$' docs/dev/github-ops.md && rg -n '`sandbox_mode` が有効な場合' docs/dev/github-ops.md

# AC6
codex sandbox linux --permissions-profile loop-protocol-rtk -C . -- rtk gh issue list --repo squne121/loop-protocol --limit 1 --json number,title
codex sandbox linux --permissions-profile loop-protocol-rtk -C . -- rtk gh api repos/squne121/loop-protocol

Allowed Paths

  • .codex/config.toml
  • .codex/rules/default.rules
  • AGENTS.md
  • docs/dev/directory-structure.md
  • docs/dev/github-ops.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Scope Delta(任意)

N/A

Runtime Verification Applicability

decision: not_applicable
reason: product runtime の動作検証ではなく、Codex project-local permission / rules / docs surface の検証を行う
applicable_acs: []

Delivery Rule

  • 1 Issue = 1 PR
  • Worktree: .claude/worktrees/issue-343-codex-project-local-permissions
  • Branch: worktree-issue-343-codex-project-local-permissions
  • Draft PR を既定とし、人間が最終マージ判断を行う

Activity

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

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-24T03:00:00Z)

    • Outcome: .codex/config.toml、.codex/rules/default.rules、repo ルート AGENTS.md、関連 SSOT が追加され、Codex が Claude 相当の project-local guardrail と rtk 前提を repo から読める状態。
    • Acceptance Criteria:
      1. .codex/config.toml に project-local permission profile を追加する
      2. .codex/rules/default.rules に rtk allow / direct pnpm・mutating git・direct gh forbid を追加する
      3. repo ルート AGENTS.md に Codex の作業入口と保護領域を追加する
      4. docs/dev/directory-structure.md と docs/dev/github-ops.md から新規 surface を発見できる
    • Verification Commands: AC1-AC4 の各コマンドは baseline で exit 1(期待どおり fail)を確認済み
    • Allowed Paths:
      • .codex/config.toml
      • .codex/rules/default.rules
      • AGENTS.md
      • docs/dev/directory-structure.md
      • docs/dev/github-ops.md
    • Worktree: .claude/worktrees/issue-343-codex-project-local-permissions
    • Branch: worktree-issue-343-codex-project-local-permissions
    • VC preflight: baseline fail = 4, 想定外 pass = 0, 実行不可 = 0

    CONTRACT_REVIEW_RESULT_V1:
    status: go
    generated_at: 2026-05-24T03:00:00Z
    generated_by: main-thread-manual
    issue_url: #343
    checks:
    template_compliance: pass
    state_label: ok
    allowed_paths_present: pass
    vc_present: pass
    stop_conditions_complete: pass
    vc_preflight:
    passed: true
    vc_failed_as_expected: 4
    vc_passed_unexpectedly: 0
    vc_unrunnable: 0
    ac_verifiability: pass
    worktree_branch_collision: clear
    next_action: implement_issue
    blocked_reasons: []
    warnings:
    - triage-required ラベルは残っているが、依存 blocker はなく main thread で即時実装に進む

  3. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: iteration 1 完了 (2026-05-24T03:00:00Z)

    • 結果サマリ: APPROVE 相当の実装完了。draft PR を作成済み
    • PR: feat(codex): add project-local permissions and rtk rules #345
    • Branch: worktree-issue-343-codex-project-local-permissions
    • Head: 8cf36f4
    • 検証:
      • issue VC 4 件 PASS
      • codex execpolicy check で rtk --help / git status が allow、pnpm test / gh issue view 1 が forbidden
      • pnpm typecheck PASS
      • pnpm lint PASS
      • pnpm test PASS
      • pnpm build PASS
    • 次イテレーション: No(人間レビュー待ち)

    LOOP_STATE:
    issue_number: 343
    contract_snapshot_url: #343 (comment)
    iteration: 0
    max_iterations: 1
    worktree: .claude/worktrees/issue-343-codex-project-local-permissions
    branch: worktree-issue-343-codex-project-local-permissions
    last_step: judgment
    last_loop_verdict: APPROVE
    blockers_history: []
    external_research_skip_basis: "OpenAI 公式 Codex docs を参照して config/rules/AGENTS を実装"
    termination_reason: approved

  4. added a commit that references this issue on May 24, 2026
  5. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop: iteration 1 完了 (2026-05-24T04:08:46Z)

    PR #345 に REQUEST_CHANGES の対応を commit しました。

    対応内容の要約

    ポイント 対応
    (A) TOML structure bug TOML は Codex 0.133.0 で有効。structure は正しい
    (B) rtk trust boundary AGENTS.md に明文化:git/gh/pnpm subcommand enforcement + shell passthrough constraint
    (C) rtk curl/env 制御 allow から prompt に変更(secret/exfiltration risk)
    (D) Instruction/rules surface 確認 docs/dev/github-ops.md に 3 段階確認手順を追加
    (E) sandbox_mode 競合 競合 risk と対策を docs に明記
    Major 3 Issue contract 更新は orchestrator 側で処理(本 worker では不要)

    VC / AC 状況

    • VC: pnpm typecheck / lint / test / build / pytest 全パス
    • AC1-AC5: 全て PASS(ファイル存在・content 確認・TOML 有効・rules/docs 追加)
    • AC6: 環境制約で未達成

      • これは Codex sandbox 実行環境の binary 欠損(ローカル環境問題)
      • PR の rules / docs 修正は正しいが、network 実効検証は別環境必要

    次のステップ

    AC6(network 実効確認)について以下の選択肢を提案:

    1. 別環境で再実行: Codex sandbox binary が intact な環境で を実行
    2. AC6 を deferred 扱いに: merge 後の環境確認に委譲、contract で明記
    3. 環境整備 Issue を別途起票: WSL2 Codex sandbox binary 欠損の修復を追跡

    PR 本文と comment に詳細なログを貼っています。

  6. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    PR #345 を impl-review-loop iter1 で REQUEST_CHANGES 対応 (commit 97dd72e) 後、Ready for review に変更しました。AC6 (codex sandbox 経由の GitHub network 実効確認) は Codex 0.133.0 の sandbox bug で達成不可だったため human_escalation で loop を終了します。詳細は #345 (comment) 参照。

  7. added a commit that references this issue on May 24, 2026
  8. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    impl-review-loop iter2 完了 (2026-05-24T14:00:00Z)

    reviewer の REQUEST_CHANGES 5-item fix list に対応完了。

    対応内容

    Verification Status

    Repository health checks ✓

    • pnpm typecheck ✓
    • pnpm lint ✓
    • pnpm test ✓ (20 passed, 100 tests)
    • pnpm build ✓
    • uv run pytest ✓ (21 passed)

    Policy checks ✓

    • rtk pnpm test → allow ✓
    • pnpm test → forbidden ✓
    • git status → allow ✓
    • git diff → allow ✓
    • rtk curl → prompt ✓
    • rtk env → prompt ✓
    • gh issue view → forbidden ✓

    AC Status

    Changed Files (Allowed Paths only)

    Follow-up Issue

    Next Steps

    1. Reviewer の条件付き merge 可 判定を受ける
    2. AC6 deferred を人間が承認する前提でマージ可能
    3. Issue 調査: Codex 0.133.0 sandbox の self-binary bind 不全を追跡し AC6 を再検証する #350 で upstream Codex sandbox bug 追跡・修正後 AC6 を再検証
  9. squne121 commented on May 24, 2026

    @squne121
    OwnerAuthor

    PR #345 が merge され AC1-AC5 達成。AC6 (codex sandbox 経由の GitHub network 実効確認) は Codex 0.133.0 の sandbox self-binary bind bug により本環境では達成不可と判定し、human 承認のもと deferred として follow-up Issue #350 で追跡する。

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