Skip to content

実装: Codex CLI で impl-review-loop の明示 SubAgent spawn 監査を repo-side deterministic guardrail として導入する #764

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "Codex CLI 実行時の impl-review-loop / post-merge-cleanup が root thread 直接実行ではなく、明示 spawn された custom agent と event-derived launch ledger によって repo-side deterministic guardrail として監査可能になる"
change_kind: workflow

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: Codex CLI 実行時に impl-review-loop / post-merge-cleanup の SubAgent dispatch を self-report 非依存の deterministic guardrail として監査可能にする
  • Desired Destination: 既存 .codex/agents/*.toml 定義、.codex/hooks.json、launch ledger validator、impl-review-loop handoff docs、fixture tests が揃い、root-thread data-plane 実行と evidence 不足を fail-closed で検出できる状態

Current Validated Scope

  • 既存 .codex/agents/implementation-worker.toml / test-runner.toml / pr-reviewer.toml / post-merge-cleanup-worker.toml を「新規追加」前提ではなく required model / reasoning / permission / runtime limitation を持つ監査対象として更新する
  • .codex/config.toml に [agents] max_depth = 1 を反映し、project-local config を Codex profile routing の証拠として扱わない方針を明記する
  • .codex/hooks.json と scripts/check-codex-agents.mjs を含む既存 hook wiring を監査対象にし、trust state / skipped / disabled / unsupported tool path / Codex binary unavailable を fail-closed に分類する
  • .claude/skills/impl-review-loop/ の Step 1 / 2 / 4 と post-merge handoff の Codex 実行時注意書きを更新し、root thread が data-plane を直接実行しない契約を明文化する
  • docs/dev/agent-skill-boundaries.md と必要最小限の workflow docs に、repo-side deterministic guardrail と feat(#579 follow-up): AC7 real spawn verification with OpenAI API key environment #601 への deferred boundary を追記する
  • scripts/check_codex_agent_config.py / scripts/check_claude_codex_agent_parity.py / scripts/check_impl_review_loop_codex_dispatch.py / scripts/check_subagent_launch_ledger.py を追加または更新する
  • tests/fixtures/subagent-ledger/ と必要な config fixture を追加し、PR test: hooks tests の CI 取りこぼしを防ぐ (#682) #763 相当ログの replay audit を fail fixture として固定する

Remaining Parent Gaps

Outcome

既存 .codex/agents/*.toml、.codex/hooks.json、scripts/check-codex-agents.mjs、Codex dispatch / launch-ledger validator scripts、fixture tests、impl-review-loop / docs の handoff 更新を含むコミットが追加され、Codex CLI での impl-review-loop / post-merge-cleanup が明示 spawn された custom agent と event-derived SUBAGENT_LAUNCH_LEDGER_V1 によって監査され、root thread による file edit / test run / git commit / git push / review judgment の直接実行、および trusted evidence 不足が validator で fail になる状態。

In Scope

  • 既存 Codex custom agent 定義の required field / model / reasoning / permission / runtime limitation の更新と .claude/agents/*.md との role parity 検証
  • [agents] max_depth = 1 の固定と nested recursion 禁止
  • impl-review-loop / post-merge-cleanup の Codex handoff 文言追加
  • SUBAGENT_LAUNCH_LEDGER_V1 の strict schema、canonical evidence source、validator 実装
  • worker self-report を advisory に落とし、spawn evidence は hook / event / trusted generated artifact に限定するルールの導入
  • root-thread data-plane 実行検出、wrong runtime config 検出、missing-launch 検出、hook trust failure 検出の negative fixtures 追加
  • PR test: hooks tests の CI 取りこぼしを防ぐ (#682) #763 相当ログを replay fixture 化し、現状 fail を再現する監査テスト追加

Out of Scope

Acceptance Criteria

  • AC1: .codex/agents/implementation-worker.toml / test-runner.toml / pr-reviewer.toml / post-merge-cleanup-worker.toml が存在し、Codex custom agent 必須 field と repo が要求する runtime limitation field を満たす
  • AC2: scripts/check_codex_agent_config.py が既存 agent TOML と scripts/check-codex-agents.mjs の expected runtime contract を照合し、actual model / reasoning effort / default_permissions / runtime_dependency_status の不一致を fail にする
  • AC3: .codex/config.toml で [agents] max_depth = 1 が固定され、project-local config を profile routing の証拠に使わないことが docs / validator で明記される
  • AC4: impl-review-loop の Step 1 / 2 / 4 と post-merge handoff docs に、Codex 実行時は root thread が data-plane を直接実行せず該当 custom agent を明示 spawn することが書かれている
  • AC5: SUBAGENT_LAUNCH_LEDGER_V1 validator が strict schema を持ち、valid fixture を通し、generated_by: worker のみ・missing launch・wrong runtime config・root-thread git push・root-thread test execution・root-thread file edit / review judgment を含む invalid fixture を fail にする
  • AC6: hook trust state が untrusted / skipped / disabled、unsupported tool path 観測、Codex binary unavailable の fixture に対して launch-ledger or dispatch validator が fail-closed になる
  • AC7: PR test: hooks tests の CI 取りこぼしを防ぐ (#682) #763 replay fixture に対して subagent_launch_evidence_missing と root_thread_data_plane_execution_observed を返す fail audit が固定される
  • AC8: Runtime Verification Applicability が decision: deferred として feat(#579 follow-up): AC7 real spawn verification with OpenAI API key environment #601 を明示し、この Issue の成功条件が live spawn 実証ではなく repo-side deterministic guardrail の実装であることが本文に記載される

Verification Commands

# AC1
# preflight-scope: runtime_only
$ python3 scripts/check_codex_agent_config.py --assert-required-fields

# AC2
# preflight-scope: runtime_only
$ python3 scripts/check_codex_agent_config.py --assert-runtime-contract

# AC3
# preflight-scope: runtime_only
$ python3 scripts/check_impl_review_loop_codex_dispatch.py --assert-max-depth --assert-no-project-profile-routing

# AC4
# preflight-scope: runtime_only
$ python3 scripts/check_impl_review_loop_codex_dispatch.py --assert-explicit-spawn-notes

# AC5
# preflight-scope: runtime_only
$ python3 scripts/check_subagent_launch_ledger.py tests/fixtures/subagent-ledger/valid.json

# AC6
# preflight-scope: runtime_only
$ python3 scripts/check_subagent_launch_ledger.py tests/fixtures/subagent-ledger/hook-untrusted.json

# AC7
# preflight-scope: runtime_only
$ python3 scripts/check_subagent_launch_ledger.py tests/fixtures/subagent-ledger/pr763-replay.json

# AC8
# preflight-scope: runtime_only
$ python3 .claude/skills/review-issue/scripts/check_issue_contract.py --file tmp/issue-764-body.md --json

Allowed Paths

  • .codex/config.toml
  • .codex/hooks.json
  • .codex/agents/implementation-worker.toml
  • .codex/agents/test-runner.toml
  • .codex/agents/pr-reviewer.toml
  • .codex/agents/post-merge-cleanup-worker.toml
  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/impl-review-loop/steps/step-1-implementation.md
  • .claude/skills/impl-review-loop/steps/step-2-verification.md
  • .claude/skills/impl-review-loop/steps/step-4-pr-review.md
  • .claude/skills/post-merge-cleanup/SKILL.md
  • docs/dev/agent-skill-boundaries.md
  • docs/dev/workflow.md
  • scripts/check-codex-agents.mjs
  • scripts/check_codex_agent_config.py
  • scripts/check_claude_codex_agent_parity.py
  • scripts/check_impl_review_loop_codex_dispatch.py
  • scripts/check_subagent_launch_ledger.py
  • tests/fixtures/subagent-ledger/
  • tests/fixtures/codex-agent-config/

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • .codex/rules/default.rules の新規追加や変更が必要と判明した場合
  • launch ledger の canonical evidence source を repo-side deterministic input に固定できない場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Scope Delta(任意)

owner comment #4649560282 を受けて、profile routing 仮定を縮退し、self-report 非依存の launch evidence / hook trust fail-closed / #601 deferred boundary を明示する方向へ reframe した。

Runtime Verification Applicability

decision: deferred
deferred_destination: "issue #601"
destination_type: issue
destination_ref: "#601"
deferred_verification_condition: "OpenAI API key を直接利用できる環境で custom agent の real spawn と child-agent event evidence を取得できたときに live runtime verification を行う。本 Issue では live spawn 実証ではなく、evidence が無い場合に fail-closed する repo-side deterministic guardrail を完了条件とする。"

Notes for Reviewer

Delivery Rule

  • 1 Issue = 1 PR
  • worktree は .claude/worktrees/issue-<番号>-<slug>/ を使う
  • Draft PR を既定とし、validator と fixture replay が通るまで Review Ready にしない

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    area/ai-ops
    on Jun 8, 2026
  2. squne121 commented on Jun 8, 2026

    @squne121
    Author
  3. changed the title [-]実装: Codex CLI で impl-review-loop の明示 SubAgent spawn と launch ledger gate を導入する[/-] [+]実装: Codex CLI で impl-review-loop の明示 SubAgent spawn 監査を repo-side deterministic guardrail として導入する[/+] on Jun 8, 2026
  4. squne121 commented on Jun 8, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-06-08T14:13:25Z)

    • Outcome: Codex CLI での impl-review-loop / post-merge-cleanup を、root thread 直接実行ではなく明示 spawn された custom agent と event-derived launch ledger で fail-closed 監査可能にする。
    • Acceptance Criteria: AC1-AC8 を Issue 本文記載どおり採用。
    • Verification Commands: AC1-AC8 は # preflight-scope: runtime_only を付けた runtime/deferred verification として扱う。
    • Allowed Paths: Issue 本文記載の 20 path entries を採用。
    • Worktree: .claude/worktrees/issue-764-codex-subagent-ledger
    • Branch: worktree-issue-764-codex-subagent-ledger
    • VC preflight: baseline fail = 0, 想定外 pass = 0, 実行不可 = 0, skipped(runtime_only) = 8
    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: 2026-06-08T14:13:25Z
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/764
      body_sha256: sha256:734703a3e6166530e57b8bc8efbdccdd4a1058269f4a91a8c0fa247c3d18b408
      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: 0
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 0
          vc_skipped: 8
          classifications:
            - ac: AC1
              command: python3 scripts/check_codex_agent_config.py --assert-required-fields
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC2
              command: python3 scripts/check_codex_agent_config.py --assert-runtime-contract
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC3
              command: python3 scripts/check_impl_review_loop_codex_dispatch.py --assert-max-depth --assert-no-project-profile-routing
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC4
              command: python3 scripts/check_impl_review_loop_codex_dispatch.py --assert-explicit-spawn-notes
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC5
              command: python3 scripts/check_subagent_launch_ledger.py tests/fixtures/subagent-ledger/valid.json
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC6
              command: python3 scripts/check_subagent_launch_ledger.py tests/fixtures/subagent-ledger/hook-untrusted.json
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC7
              command: python3 scripts/check_subagent_launch_ledger.py tests/fixtures/subagent-ledger/pr763-replay.json
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
            - ac: AC8
              command: python3 .claude/skills/review-issue/scripts/check_issue_contract.py --file tmp/issue-764-body.md --json
              exit_code: null
              classification: skipped
              category: preflight_scope_runtime_only
              scope_class: runtime_only
              confidence: low
              evidence:
                stdout_excerpt: ""
                stderr_excerpt: ""
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: VC marked runtime_only; verification deferred to post-implementation runtime
              runtime_verification_required: true
        ac_verifiability: pass
        product_spec_check:
          applicability: not_applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: false
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: false
          conditions:
            docs_product_requires_spec_evidence:
              status: pass
              evidence: []
            tasks_md_not_direct_source:
              status: pass
              evidence: []
            specify_not_canonical:
              status: pass
              evidence: []
            diff_first_rationale_present:
              status: pass
              evidence: []
            generated_task_trace_present:
              status: pass
              evidence: []
            task_dependencies_materialized:
              status: pass
              evidence: []
          blocked_reasons: []
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings: []
  5. squne121 commented on Jun 8, 2026

    @squne121
    OwnerAuthor

    Implemented by PR #767 and merged into main on 2026-06-09 JST. post-merge-cleanup で local branch/worktree cleanup に進みます。

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/implementerarea/ai-opsenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions