Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#791"
goal_ref: "agent ops の token/context 浪費を決定論的 preflight / compact contract / hook 規律で削減する"
change_kind: workflowParent Issue
Parent Goal Ref
- Goal: agent ops(issue refinement / subagent handoff / hooks)の token・context 浪費を決定論的 script と compact contract で削減する
- Desired Destination: refinement loop が「失敗 preflight 0 回・compact stdout ≤ 2KB + artifact・VC scope 不備の author 前検出」で完走できる状態(parent 導入: agent ops の token/context 浪費を決定論的 preflight / compact contract / hook 規律で削減する #791 のスコープ)
Current Validated Scope
- 既存
scripts/check_claude_codex_agent_parity.pyを拡張する(責務 / 出力 schema 名 / mutation permission / nested delegation 禁止の drift 検出) tests/test_agent_parity.pyを新規追加する
Remaining Parent Gaps
- parity チェックの CI required gate 化の要否判断(既存 CI 構成への組み込みは別判断。GitHub Actions 変更は chore(ci): GitHub Actions workflow の SHA pin / actionlint 統合 #280 系の方針に従う)
Background
.claude/agents/issue-author.md(245 行)と .codex/agents/issue-author.toml(35 行)のように、同名 agent の launcher 別定義は情報量が大きく異なり、出力契約・permission・delegation 制約の drift が発生しやすい。既存の check_claude_codex_agent_parity.py は基本 parity を検証済みのため、これを拡張して compact schema 名参照・mutation permission・nested delegation 禁止の比較を追加する。
- model / reasoning effort は config declaration として比較・報告するのみとし、runtime proof とは扱わない(runtime 検証は transcript / ledger の責務)
- drift は
STATUS: warn|failで報告し、launcher 固有で正当な差分は allowlist で明示する
Outcome
check_claude_codex_agent_parity.py が issue-reviewer / issue-author の Claude / Codex 定義間で出力 schema 名・mutation permission・nested delegation 禁止の drift を検出できるよう拡張され、tests/test_agent_parity.py が追加されて全 PASS した状態のコミットが作成され、pnpm 品質ゲートが全 PASS している。
In Scope
check_claude_codex_agent_parity.pyの拡張- 同名 agent(issue-reviewer / issue-author)が同じ compact result schema 名(
ISSUE_REVIEW_RESULT_COMPACT_V1/ISSUE_AUTHOR_RESULT_COMPACT_V1)を参照しているかの比較 - mutation permission(readonly / write 境界)の差分の明示出力
- nested delegation prohibition 記述の有無比較
- model / reasoning effort を「config declaration」として report に含める(一致は要求しない)
- drift 時の
STATUS: warn|failと evidence(file:line)出力
- 同名 agent(issue-reviewer / issue-author)が同じ compact result schema 名(
tests/test_agent_parity.py(drift fixture / allowlist / 正常系)
Out of Scope
- Claude と Codex の設定の完全一致化
- model choice / reasoning effort の変更
- agent 定義の削除・統合
.github/workflows/**への CI 組み込み(chore(ci): GitHub Actions workflow の SHA pin / actionlint 統合 #280 系の方針判断)
Acceptance Criteria
- AC1: issue-reviewer / issue-author の Claude / Codex 定義が同一 compact schema 名を参照しない場合に drift が報告されることが pytest で検証されている
- AC2: mutation permission の差分が出力に明示されることが pytest で検証されている
- AC3: model / reasoning effort が config declaration として report に含まれ、runtime proof と扱われない旨が出力に明示されている
- AC4: nested delegation prohibition の有無比較が行われることが pytest で検証されている
- AC5: drift 検出時に
STATUS: warnまたはSTATUS: failが返ることが pytest で検証されている - AC6: pnpm typecheck / lint / test / build が全 PASS する
- AC7: final output schema(
ISSUE_*_COMPACT_V1)と artifact-only schema(旧REVIEW_ISSUE_RESULT_V1/ISSUE_AUTHOR_RESULT_V1)を区別して抽出し、artifact-only schema が残っていても compact schema parity fail にならないことが pytest で検証されている - AC8: permission comparison は
DECLARED_PERMISSION(claude.permissionMode / claude.disallowedTools / codex.default_permissions)/MUTATION_BOUNDARY(readonly / issue-mutation / repo-write)/RUNTIME_PROOF_NOTE(宣言は runtime proof ではない)の 3 層に分離して report されることが pytest で検証されている - AC9: Claude nested delegation 禁止は
tools/disallowedToolsの構造から判定し、Codex nested delegation 禁止は.codex/config.tomlの[agents].max_depth == 1と agent instruction から判定することが pytest で検証されている(check_codex_agent_config.pyとの責務重複を避け、max_depth事実の参照は read-only dependency として扱う) - AC10: drift evidence は必ず
rule_id、file:line、launcher、agent、expected、actualを含み、line number が fixture で安定検証されている - AC11:
STATUS: warnの exit code は default 0、--strictフラグ指定時は 1 になることが pytest で検証されている
Verification Commands
# AC1
$ uv run pytest tests/test_agent_parity.py -v # baseline-expect: fail
# AC2
$ rg -n "permission" scripts/check_claude_codex_agent_parity.py # baseline-expect: pass
# AC3
$ rg -n "declaration" scripts/check_claude_codex_agent_parity.py # baseline-expect: fail
# AC4
$ rg -n "nested" scripts/check_claude_codex_agent_parity.py # baseline-expect: fail
# AC5
$ rg -n "STATUS" scripts/check_claude_codex_agent_parity.py # baseline-expect: pass
# AC6
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
# AC7
$ uv run pytest tests/test_agent_parity.py -v -k artifact_only # baseline-expect: fail
# AC8
$ rg -n "DECLARED_PERMISSION|MUTATION_BOUNDARY|RUNTIME_PROOF" scripts/check_claude_codex_agent_parity.py # baseline-expect: fail
# AC9
$ rg -n "max_depth|disallowedTools" scripts/check_claude_codex_agent_parity.py # baseline-expect: fail
# AC10
$ rg -n "rule_id" scripts/check_claude_codex_agent_parity.py # baseline-expect: fail
# AC11
$ rg -n "strict" scripts/check_claude_codex_agent_parity.py # baseline-expect: failAllowed Paths
- scripts/check_claude_codex_agent_parity.py
- tests/test_agent_parity.py(新規)
- tests/fixtures/agent-parity/(新規。fixture が必要な場合)
- tests/fixtures/agent-parity/expected-agent-parity.json(新規。parity 検証専用 fixture)
Runtime Verification Applicability
decision: deferred
reason: "Verification Commands は pytest と pnpm ゲートで構成されており、実行環境依存の runtime probe なし。実装完了後に CI で検証する。"
deferred_destination: "CI (pnpm test / uv run pytest tests/test_agent_parity.py)"
deferred_verification_condition: "PR CI が全 PASS した時点で verification 完了とみなす"Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 既存 parity check の利用箇所(CI / 他 script)との互換が壊れる場合
Required Skills
なし
Scope Delta(任意)
N/A
Delivery Rule
1 Issue = 1 PR、worktree 上で実装し Draft PR を作成する- Depends on 実装: issue-reviewer / issue-author に compact subagent result contract を導入し raw 出力の main 還流を止める #794 merge(compact schema 名が agent 定義に入った後でないと AC1 の比較対象が存在しないため)
Notes for Reviewer
- 出典: parent 導入: agent ops の token/context 浪費を決定論的 preflight / compact contract / hook 規律で削減する #791 の分析レポート「I. Prioritized implementation issues / Issue 8」
- agent 定義ファイル自体(
.claude/agents/*/.codex/agents/*)の修正は 実装: issue-reviewer / issue-author に compact subagent result contract を導入し raw 出力の main 還流を止める #794 のスコープであり、本 Issue は linter とテストのみ
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jun 15, 2026
判定
REQUEST_CHANGES。#799 は必要だが、現Issue契約のままだと “文字列 grep parity linter” になりやすく、#794 で整備した compact output contract の drift を十分に止められません。
#799 は、既存
scripts/check_claude_codex_agent_parity.pyを拡張し、issue-reviewer/issue-authorの compact schema 名、mutation permission、nested delegation 禁止、model / reasoning effort declaration を比較するIssueです。#799 自体にコメントはありません。#799 の親 #791 は、agent ops の token/context 浪費を preflight / compact contract / hook 規律 / parity linter で減らす delivery-rollup です。特に #799 は、#794 の compact subagent result contract が入った後の drift 検出が役割です。
関連実装では、#794 / PR #805 が
ISSUE_REVIEW_RESULT_COMPACT_V1/ISSUE_AUTHOR_RESULT_COMPACT_V1、compact script、stdout 2048 UTF-8 bytes 制限、raw diff/log 禁止、Claude/Codex agent 定義更新、SKILL.md consumer 更新を入れています。したがって #799 は「schema名があるか」ではなく「final output contract として同じ compact schema が維持されているか」を検出しないと価値が薄いです。ブロッカー
1. 現行 parity linter は #799 の検出対象に届いていない
現行
check_claude_codex_agent_parity.pyは、期待値JSONを読み、Claude frontmatter / Codex TOML の name、model、permissionMode、runtime route などを軽く比較するだけです。schema 名、final stdout contract、artifact-only schema、permission boundary、nested delegation prohibition は構造化抽出されていません。修正:
AgentParityFactsのような正規化モデルを作り、Claude/Codex それぞれから次を抽出してください。2. schema drift 検出が naive grep だと false positive になる
現行 Claude
issue-reviewer.mdには final output としてISSUE_REVIEW_RESULT_COMPACT_V1がありつつ、内部 artifact 用に旧REVIEW_ISSUE_RESULT_V1も残っています。これは #794 の設計上正しい状態です。同様に Claude
issue-author.mdには旧ISSUE_AUTHOR_RESULT_V1の説明と、後段に final output のISSUE_AUTHOR_RESULT_COMPACT_V1が共存しています。単純に schema 名集合を比較すると、旧 schema が混じって drift と誤判定します。修正: 抽出対象を以下に限定してください。
## 出力契約(ISSUE_*_COMPACT_V1)セクション配下OUTPUT_CONTRACTセクション配下REVIEW_ISSUE_RESULT_V1/ISSUE_AUTHOR_RESULT_V1はartifact_only_schema_namesとして扱い、final parity の比較対象から除外3. permission parity は “宣言一致” と “実効保証” を分けないと危険
Codex custom agent は TOML で
model/model_reasoning_effort/default_permissionsなどを定義できますが、Codex の subagent は親セッションの sandbox policy を継承し、親ターンの runtime override、たとえば/permissionsや--yoloも子 agent 起動時に再適用されます。つまり TOML のdefault_permissionsは runtime proof ではありません。([OpenAI Developers]1)Codex permission profile には
:read-only、:workspace、:danger-full-accessがあり、default_permissionsは profile 名または built-in を指します。read-only と write-capable の境界は linter が明示すべきですが、「Claude permissionMode と Codex default_permissions が同じ意味」と扱うのは不正確です。([OpenAI Developers]2)現行の期待値では
issue-authorは Codexloop-protocol-rtk/ ClaudeacceptEdits、issue-reviewerは Codexloop-protocol-readonly/ ClaudedontAskです。修正:
permissionは単一比較ではなく、最低限この3層で report してください。4. nested delegation 禁止は prose 検出だけでは不十分
Claude Code docs では、特定 subagent がさらに subagent を spawn しないようにするには
Agentを tools list から除外するかdisallowedToolsに追加するとされています。現在の Claudeissue-reviewer/issue-authorはdisallowedTools: Agentを持っており、この点は実装上の evidence として使えます。([Claude API Docs]3)Codex 側は
[agents].max_depthが重要です。OpenAI docs ではagents.max_depthの default は 1 で、直接 child は許すが deeper nesting を防ぐ設計です。上げると fan-out、token、latency、予測可能性リスクが増えます。([OpenAI Developers]1)既存
check_codex_agent_config.pyはすでに[agents].max_depth == 1を検査しています。#799 はこれと責務重複しやすいので、同じ事実を別ロジックで再実装するのではなく、共通 helper 化または明示的な read-only dependency として扱うべきです。修正: nested delegation rule は以下を fail 条件にしてください。
Agentが tools に許可され、かつdisallowedToolsにない.codex/config.tomlの[agents].max_depthが 1 でないspawn_agents_on_csv/ recursive delegation / child agent spawn 指示がある5.
STATUS: warn|failの exit code が未定義#799 は drift 時に
STATUS: warn|failを返すことを求めていますが、現行 linter は failure を[FAIL]で出して exit 1、成功時はOKで exit 0 です。warn を CI で失敗にするのか、report-only にするのかが未定義です。修正: 次のように固定してください。
加えて
--format text|jsonを追加し、pytest は JSON を検証、PR body / human 用は text を使う構成がよいです。6. Allowed Paths が expectation fixture 更新を許していない
現行 linter は
tests/fixtures/codex-agent-config/expected-runtime-contract.jsonを参照しています。#799 の Allowed Paths はscripts/check_claude_codex_agent_parity.py、tests/test_agent_parity.py、tests/fixtures/agent-parity/だけなので、既存 expectation JSON に parity 用フィールドを足すとスコープ違反になります。修正案: 既存
expected-runtime-contract.jsonは runtime contract 用として維持し、#799 ではtests/fixtures/agent-parity/expected-agent-parity.jsonを新設するのが安全です。既存 JSON を拡張したいなら、Allowed Paths に明示追加してください。追加すべき Acceptance Criteria
実装方針
最小実装はこの形です。
Codex Skills は progressive disclosure で
SKILL.md全文を必要時だけ読む設計なので、長大な schema を agent 定義に直書きして検査するより、script/constants/tests 側を正本にする #794 の方針は妥当です。#799 も同じ方向で、agent prose ではなく正規化された抽出結果を比較するべきです。([OpenAI Developers]4)そのまま Issue コメントに貼る文案
squne121 commentedon Jun 15, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: max iterations exceeded
human_escalationmax_iterations_exceededBlockers
squne121 commentedon Jun 15, 2026
CONTRACT_REVIEW_RESULT_V1
checks
Worktree / Branch
contract_snapshot
fix(#799): @DataClass を通常クラスに変換 — exec 競合を解消する
fix(#799): parse_known_args で exec() 経由 sys.argv 汚染を解消する
fix(#799): fix_delta B1-B8 — parity linter 正確性・テスト網羅性の改善
implement(#799): parity linter を拡張し schema/permission/delegation drif…