Skip to content

調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608

Closed
1 of 1 issue completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: research
parent_issue: "none"
goal_ref: "isolation worktree agent が生成した Issue comment mutation request を、raw gh issue comment や preflight 専用 skill_runtime_exec.py の汎用化に依存せず、既存 issue_comment.publish controlled mutation lane へ安全に受け渡す canonical producer/parent delegation/execution contract を確定し、修正方針を implementation Issue として起票可能な状態にする"
change_kind: research-only

Parent Issue

なし(単独改善)

Outcome

isolation worktree agent が生成した Issue comment request を、raw gh issue comment や preflight 専用 skill_runtime_exec.py の汎用化に依存せず、既存 issue_comment.publish controlled mutation lane(controlled_skill_mutation_exec.py / controlled_skill_mutation_policy.py)へ安全に受け渡す canonical producer/parent delegation/execution contract が確定している。現行 block を hook(worktree_scope_guard.py)・exact classifier(looks_like_skill_runtime_executor_command 等)・policy validation(skill_runtime_command_policy.py の SKILL_RUNTIME_COMMAND_POLICY_V2)・executor(skill_runtime_exec.py)の各層で再現した evidence が本文に記載され、採用案を実装する implementation Issue が起票され、本 Issue がそれを link している状態。

In Scope

Out of Scope

  • worktree_scope_guard.py、skill_runtime_command_policy.py、command_registry.py、controlled_skill_mutation_policy.py、local_main_branch_guard.py の実際のコード変更(採用された修正方針は後続 implementation Issue で実施する)
  • looks_like_skill_runtime_executor_command の argv-aware classifier 化そのもの(既存 OPEN Issue 1595 および 1565 のスコープであり、本 Issue はそのスコープを重複させない)
  • scope_rollup.run を sibling profile として SKILL_RUNTIME_COMMAND_POLICY_V2 に統合する作業そのもの(既存 OPEN Issue 実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601 のスコープ)

Acceptance Criteria

  • AC1: temp repository + real linked issue worktree から skill_runtime_exec.py --command-id gh.issue.comment ... 相当のコマンドを実行し、worktree_scope_guard.py の block 経路(exact profile 不一致 → looks_like_skill_runtime_executor_command 一致 → controlled mutation executor 到達前に block)と reason code が本 Issue 本文に記載されている
  • AC2: SKILL_RUNTIME_COMMAND_POLICY_V2.eligible_command_ids の現行 3 件(preflight.run、preflight.run.fixture、preflight.run.with_anchor)と、scope_rollup.run がこの集合に含まれない事実、および validate_registry_entry() が cwd_policy/write root/argv template/placeholders を preflight 三形状に固定している点が本 Issue 本文に記載されている
  • AC3: 4 案(skill_runtime_exec 拡張/issue_comment.publish 再利用/新規 worktree-scoped execution class/raw gh 継続)の比較表が本 Issue 本文に記載され、採用案が明示されている
  • AC4: 採用案を実装する implementation Issue が起票され、fixed base SHA・consumer inventory・Claude/Codex parity・Allowed Paths・rollback 条件を含んだ状態で本 Issue がそれを link している
  • AC5: 本 Issue は close 可能、もしくは追加調査要件が明示されている

Verification Commands

# AC1
# baseline-expect: pass
$ rg -n "looks_like_skill_runtime_executor_command" .claude/hooks/worktree_scope_guard.py
# AC2
# baseline-expect: pass
$ rg -n "eligible_command_ids" scripts/agent-guards/skill_runtime_command_policy.py
# baseline-expect: pass
$ rg -n "validate_registry_entry" scripts/agent-guards/skill_runtime_command_policy.py
# AC3
# baseline-expect: pass
$ gh issue view 1608 --repo squne121/loop-protocol --json body --jq '.body'
# AC4
# baseline-expect: pass
$ gh issue list --repo squne121/loop-protocol --search "Closes #1608 in:body" --state all --json number,title
# AC5
# baseline-expect: pass
$ gh issue view 1608 --repo squne121/loop-protocol --json state

Allowed Paths

  • 読み取り専用。リポジトリ変更なし(既定)
  • .claude/hooks/worktree_scope_guard.py
  • scripts/agent-guards/skill_runtime_command_policy.py
  • scripts/agent-guards/command_registry.py
  • scripts/agent-guards/controlled_skill_mutation_policy.py
  • scripts/agent-guards/skill_runtime_exec.py
  • scripts/agent-guards/controlled_skill_mutation_exec.py
  • .claude/skills/issue-refinement-loop/SKILL.md

Stop Conditions

  • Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
  • Allowed Paths 外への書き込みを試みた場合は即停止
  • 権限不足(permission denied)により操作が完了できない場合は即停止
  • 成果物の書き込みに失敗した場合(I/O エラー等)は即停止

Handoff Contract

  • Current Objective: isolation worktree agent の Issue comment mutation を、既存 issue_comment.publish controlled metadata executor lane(または比較の結果採用された案)へ接続する方式を確定する
  • Bounded Current Context: skill_runtime_exec.py は preflight 専用 executor であり、gh.issue.comment 等の registry mutation command-id を実行する汎用 engine ではない。SKILL_RUNTIME_COMMAND_POLICY_V2.eligible_command_ids は現行 main で 4 件(preflight.run / preflight.run.fixture / preflight.run.with_anchor / scope_rollup.run)に増えているが、validate_registry_entry() の argv/placeholder 契約は依然 preflight 三形状のみに固定されている。既存の issue_comment.publish controlled mutation lane(controlled_skill_mutation_exec.py)は trusted repository binding・issue-scoped input namespace・closed input schema・artifact-only write root・remote comment readback・idempotency marker を既に備えている。
  • Open Questions: なし(採用案 Option 2 で確定。詳細は Adopted Direction 参照)
  • Next Action: 採用案 Option 2 を実装する implementation Issue(本文末尾 Implementation Handoff 参照)の実装を進める
  • Artifact Refs: なし(読み取り専用調査)

Notes for Reviewer

Research Result

research_base_sha: 4ab8ec2d9495638695ef774fb8737b509585f492(fetch 確認済み、origin/main HEAD と一致、drift 無し)

調査は control-plane が直接(git show / git grep / Read ツール)で実施した。一部は実際の Claude Code PreToolUse hook 経由での live re-invocation で確認した(no-live-mutation、GitHub への POST は一度も発生していない)。

Reproduction Environment

現在の canonical main root checkout(squne121/loop-protocol、branch main、HEAD 4ab8ec2d9495638695ef774fb8737b509585f492)から、実際の Claude Code PreToolUse hook チェーン経由で以下のコマンドを実行した(temp repository ではなく実環境での再現。理由: このリポジトリ自身の hook chain がまさに調査対象であり、実環境での再現が temp repository での模擬より高精度であるため採用した)。

$ uv run python3 scripts/agent-guards/skill_runtime_exec.py --command-id gh.issue.comment --issue-number 1608 --repo squne121/loop-protocol

結果: local_main_branch_guard.sh フックが即座に block。

reason_code: unparseable_branch_mutation
rule_id: skill_runtime_guess
command_kind: unknown_command
parser_stage: skill_runtime_like_block
$ uv run python3 scripts/agent-guards/skill_runtime_exec.py --command-id gh.issue.comment --issue-number 1608 --repo squne121/loop-protocol --body-file /tmp/x.txt

結果: 上と同一の hook で同一 reason_code/rule_id により即 block(--body-file は executor の argparse に到達すらしない)。

対照実験として、既存の controlled metadata executor を意図的に失敗する入力(存在しない input-file)で呼び出した。

$ uv run python3 scripts/agent-guards/controlled_skill_mutation_exec.py --command-id issue_comment.publish --issue-number 1608 --repo squne121/loop-protocol --input-file artifacts/1608/issue-metadata/issue_comment.publish/nonexistent.json

結果: hook はこのコマンドを allow し、Python script が実際に実行され、input_file_not_found で exit code 2。GitHub への POST は一度も行われていない(executor 内の _validate_and_resolve_input_file が gh 呼び出し前に fail-closed するため、コードパス上到達不可能)。

さらに、本調査作業中に git grep -n "add_argument" -- scripts/agent-guards/skill_runtime_exec.py という無関係な読み取り専用コマンド(mutation ではない)も同一の skill_runtime_guess ルールで block された実例を観測した。これは「コマンド文字列に skill_runtime_exec.py という部分文字列が含まれるだけで block する」という broad target predicate の過検知を、調査対象外の read-only コマンドに対してさえ引き起こす実例であり、本 Issue の根本原因候補(broad substring match)を補強する一次証拠である。

Layer-by-Layer Failure Evidence

Layer 結果
Claude Code session-level hook (local_main_branch_guard.sh) skill_runtime_exec.py を含むコマンド文字列を実行前に即 block(rule_id: skill_runtime_guess)。repo 側 .claude/hooks/worktree_scope_guard.py / scripts/agent-guards/skill_runtime_command_policy.py に到達する前の、より外側の層
exact privileged command classifier (is_exact_skill_runtime_executor_command / looks_like_skill_runtime_executor_command, .claude/hooks/worktree_scope_guard.py:2070-2075, _decide_bash) --command-id gh.issue.comment は SKILL_RUNTIME_COMMAND_POLICY_V2.eligible_command_ids に無いため is_exact_skill_runtime_executor_command は False。その後 looks_like_skill_runtime_executor_command(command)("skill_runtime_exec.py" in command、scripts/agent-guards/skill_runtime_command_policy.py:564-565)が True となり block(worktree_scope_guard.py:2074-2075)
policy lookup (SKILL_RUNTIME_COMMAND_POLICY_V2.eligible_command_ids) gh.issue.comment は不在。現行 4 件は preflight.run / preflight.run.fixture / preflight.run.with_anchor / scope_rollup.run(scripts/agent-guards/skill_runtime_command_policy.py:61-101、scope_rollup.run は 581-587 行で module load 後に dict mutation として追加)
registry lookup (command_registry.py の ISSUE_REFINEMENT_COMMAND_REGISTRY_V1) gh.issue.comment は 存在する(287-305 行、cwd_policy: any、argv: ["gh","issue","comment","{issue_number}","--repo","{repo}","--body-file","{body_file}"]、mutation: True)。ただしこれは他の消費者(orchestrator が argv を直接組み立てて gh 呼び出しする用途)向けの定義であり、skill_runtime_exec.py の policy とは独立
registry validation (validate_registry_entry(), skill_runtime_command_policy.py:791-825) _EXPECTED_ARGV_BY_COMMAND / _EXPECTED_PLACEHOLDERS_BY_COMMAND は preflight.run / preflight.run.fixture / preflight.run.with_anchor の 3 キーのみ(736-788 行)。gh.issue.comment も scope_rollup.run も無いため、command_id が policy の eligible_command_ids にあってもここで必ず argv_template_mismatch で例外
executor argparse (skill_runtime_exec.py:1449-1457) --command-id(必須)/--issue-number(必須,int)/--repo(必須)/--fixture(任意)/--anchor-comment-url(任意)の 5 個のみ。--body-file は存在しない。追加すれば argparse が unrecognized arguments で即エラー
executor internal self-check (main(), 1538-1554 行) --body-file なしで --command-id gh.issue.comment を渡しても、is_exact_skill_runtime_executor_command が False を返すため "exact command class rejected" で exit 2(hook をバイパスして直接スクリプトを呼んでも同様に拒否される)
child dispatch 到達不可。gh.issue.comment は eligible_command_ids に無いため _validate_runtime_context にすら到達しない
controlled metadata executor allow (is_controlled_skill_mutation_exec_command, worktree_scope_guard.py:2092-2093) controlled_skill_mutation_exec.py --command-id issue_comment.publish ... は exact command class として無条件 allow(Issue #1166/#1284)。実行結果は上記 Reproduction Environment 参照
mutation proof 全実行で GitHub への POST は一度も発生していない(hook block または argparse block または input-file 検証 fail のいずれかで、gh 呼び出し到達前に必ず停止する構造)
Claude/Codex parity docs/dev/hook-boundaries.md:727 に明記: .codex/rules/default.rules は controlled_skill_mutation_exec.py 自体への allow エントリを持たない。すなわち Option 2 の controlled metadata executor lane は現状 Claude session 専用であり、Codex 側には同等の allow が無い(split-brain ではなく、単に未実装)。後続 implementation Issue の AC に Codex 側 allow rule 追加を含めるか、Out of Scope として明示的に別 Issue 化する必要がある

Current Repository Ground Truth(AC2 訂正)

  • SKILL_RUNTIME_COMMAND_POLICY_V2.eligible_command_ids は 4 件: preflight.run、preflight.run.fixture、preflight.run.with_anchor、scope_rollup.run(scripts/agent-guards/skill_runtime_command_policy.py:61-101, 581-587)。旧 AC2 記載の「preflight 系三件のみで scope_rollup.run は含まれない」は現行 source では不正確。
  • ただし scope_rollup.run は skill_runtime_exec.py を経由しない独立 exact command class(is_scope_rollup_run_command、run_scope_rollup_preflight.py に固定バインド、skill_runtime_command_policy.py:684-707)であり、skill_runtime_exec.py の eligible としての実務的な意味は無い。
  • validate_registry_entry() の _EXPECTED_ARGV_BY_COMMAND / _EXPECTED_PLACEHOLDERS_BY_COMMAND(skill_runtime_command_policy.py:736-788)は依然として preflight.run / preflight.run.fixture / preflight.run.with_anchor の 3 形状に固定されたまま(scope_rollup.run も含まれていない)。この点で従来指摘の「registry validator が preflight 三形状に固定」は現行 source でも正しい。
  • skill_runtime_exec.py の CLI は --command-id/--issue-number/--repo/--fixture/--anchor-comment-url の 5 フラグのみで --body-file は存在しない(実際に追加実行を試みて argparse エラーで確認済み、上記 Reproduction Environment 参照)。

Option Comparison

案 least privilege isolation agent 権限 parent 責務 write roots credential 露出 既存資産再利用 Claude/Codex parity #1478 整合 実装コスト
1. skill_runtime_exec.py 汎用化 低(preflight 専用 executor の責務拡大) 変化なし(そもそも到達不可) 変わらず preflight artifact subtree 前提を崩す必要 変化なし 低(新規 executor 責務を追加) 未対応(新規に両方実装必要) 中立 高(registry validator/argparse/write audit/child dispatch 全て再設計)
2. issue_comment.publish 再利用(第一候補・採用) 高(既存の閉じた schema/namespace/readback/idempotency をそのまま利用) isolation agent は bounded request のみ生成、GitHub credential 非保持 parent が input JSON materialize + controlled executor 起動 artifacts/{issue}/issue-metadata/issue_comment.publish/(既存) 変化なし(既存 executor) 高(hook の exact allow も既存、#1284/PR#1295 の資産をそのまま使う) Claude 側は既存 allow 済み、Codex 側は .codex/rules/default.rules に未 allow(要追加) 完全整合(#1478 の parent-owned preflight 方針を metadata mutation は別 lane として維持、supersede しない) 中(parent-side materializer + Codex allow rule 追加が主 work)
3. 新規 worktree-scoped execution class 低〜中(新しい特権 executor を追加) isolation agent に直接実行権限を与える設計もあり得るため #1478 と緊張関係 新設計次第 新設計次第 新設計次第 新規に両方実装必要 #1478 supersede の是非を明記する必要があり、明記しない限り採用不可 要検討(supersede か併存か不明瞭なら不可) 高(#1478 相当の vertical slice を新規に構築)
4. raw gh 継続 低(監査・readback・idempotency が無い) 変化なし 変化なし 制御なし 変化なし 低(既存資産を活用しない) 現状のまま(worktree_scope_guard.py の一般 mutation policy により許可されているだけで、guard bypass ではない) 整合するが改善なし 最小だが根本解決にならない

PR #1630 / Issue #1629 との衝突 evidence: PR #1630(Draft、OPEN、head 2702ae7fd7b0d15863cc414ba54a92d379ce7646、mergeable: MERGEABLE、merge_state_status: CLEAN、直近レビュー APPROVE・merge_ready: true、CI 全 green)が scripts/agent-guards/controlled_skill_mutation_exec.py と scripts/agent-guards/controlled_skill_mutation_policy.py の両方を変更中(live Issue scope snapshot materializer 追加)。これは Option 2 が触るファイルと完全に重複する。他の open PR(#1628/#1627/#1626/#1534/#1528)はこの領域に触れていない。

Adopted Direction

採用案: Option 2 — isolation worktree agent は bounded comment request のみ生成し、canonical main/default-branch 上の parent orchestrator が既存 issue_comment.publish controlled mutation lane(controlled_skill_mutation_exec.py)へ委譲する。

理由(上記 Option Comparison の根拠):

  • 既存 issue_comment.publish は既に trusted repository binding・issue-scoped input namespace(artifacts/{issue}/issue-metadata/issue_comment.publish/)・closed input schema(ISSUE_COMMENT_PUBLISH_INPUT_V1)・absolute path/../symlink/hardlink 拒否・must-be-regular-file・remote comment readback・idempotency marker を備えている(controlled_skill_mutation_exec.py:353-441)。
  • worktree_scope_guard.py は既に is_controlled_skill_mutation_exec_command を exact allow しており(2092-2093 行)、root/default branch からの実行は追加の hook 変更なしに機能する(本 Issue の再現実験で確認済み)。
  • Issue 実装: issue-refinement-loop Step 0f を parent-owned preflight 運用で明文化し isolation agent の exact executor 実行を契約テストで禁止する #1478 の「isolation agent は parent-owned preflight の exact executor を直接起動しない」という方針と完全に整合する(metadata mutation は別 lane であり、supersede の必要が無い)。
  • Option 1・3 は新規の特権実行系を要求し、コストとセキュリティ境界の複雑性が増す一方、Option 2 はゼロ新規 executor で達成できる。
  • Option 4 は監査性・readback・idempotency を欠くため不採用。

Rejected Alternatives:

  • Option 1(skill_runtime_exec.py 汎用化): registry validator・argparse・child dispatch・write audit の 4 層すべてが preflight 専用に固定されており、汎用化は事実上の再設計に等しい。既存の issue_comment.publish という同等機能を持つ資産と重複するため採用しない。
  • Option 3(新規 worktree-scoped execution class): Issue 実装: issue-refinement-loop Step 0f を parent-owned preflight 運用で明文化し isolation agent の exact executor 実行を契約テストで禁止する #1478 の parent-owned preflight 方針との関係(supersede するか否か)を明記しない限り採用不可であり、既存資産(Option 2)で同等の安全性が達成できる以上、新設計コストを正当化する強い理由がない。
  • Option 4(raw gh 継続): 現状の worktree_scope_guard.py の一般 mutation policy により許可されているだけであり、"guard bypass" ではないが、監査・readback・idempotency の契約が無いため、production path としては不採用。

Body Input Threat Model

issue_comment.publish lane(既存 controlled_skill_mutation_exec.py)における実装済み制御と不足制御。

Existing Controls(実装済み、_validate_and_resolve_input_file controlled_skill_mutation_exec.py:368-441 および _load_and_validate_input_json 447-477 行)

  • canonical input namespace: artifacts/{issue_number}/issue-metadata/issue_comment.publish/
  • absolute path 拒否(389-390 行)
  • .. 拒否(393-394 行)
  • symlink component 拒否(lstat 各 component、396-407 行)
  • hardlink 拒否(st_nlink != 1、424-426 行)
  • regular file 以外の拒否(S_ISREG チェックにより FIFO/device/socket/directory は暗黙に拒否、416-422 行)
  • exact-key schema(ISSUE_COMMENT_PUBLISH_INPUT_V1、issue_number 型/値 cross-check、447-477 行)
  • repository binding(TRUSTED_REPO、実行時の git remote origin 検証)
  • issue number binding(input JSON 内 issue_number と CLI 引数の一致チェック)
  • comment body 内へのマーカー埋め込み必須(_validate_issue_comment_publish_fields、510-516 行)
  • remote-state-is-authority idempotency: 投稿前にマーカー文字列でリモートコメントを検索し重複 POST を防止(pre-mutation precheck、1380-1420 行付近)、投稿後 readback(local marker は audit 専用で GitHub 側が正)

Missing Controls(未実装、後続 implementation Issue の AC へ移す)

  • stdin 指定 - の拒否: input-file は常にファイルパス前提のため、- という文字列がそのまま相対パス扱いされ input_file_not_found になる可能性はあるが、明示的な - 拒否ロジックは無い(要確認・明示テスト化)
  • UTF-8 decode failure 時の挙動: read_text(encoding="utf-8") 失敗時は input_json_read_error に丸められる(generic な例外捕捉であり、専用 reason code ではない)
  • NUL 拒否: input JSON 文字列内容への NUL 拒否は明示的に実装されていない
  • 最大 file byte size の明示的な upper bound: 未確認(read_text に上限が無い可能性、後続 Issue で確認・追加が必要)
  • 最大 comment body byte size の明示的な upper bound: 未確認
  • duplicate marker 0 件/1 件/複数件の扱いの網羅的なテスト: 既存実装の precheck はあるが、複数 marker 検出時の挙動の明示的な仕様化が必要
  • 同一 marker・異なる body(conflict)の扱い: 明示的な仕様が必要
  • POST 後 timeout、POST 成功・readback 失敗、pagination 境界、403/404/410/422/429/503 の分類別処理: 既存実装の gh 呼び出しエラーハンドリングの粒度を後続 Issue で精査する必要がある

Dependency and Reuse Matrix

Issue/PR state #1608 との関係
#1284(CLOSED)/ PR #1295(MERGED) 完了 issue_comment.publish controlled mutation lane そのものを実装した Issue。Option 2 はこの資産をそのまま再利用する
#1478(CLOSED) 完了 isolation agent が parent-owned preflight の exact executor を直接起動しない方針を確定。Option 2 はこの方針と整合し、supersede しない
#1565(OPEN) 重複無し looks_like_skill_runtime_executor_command の argv-aware classifier 化。#1608 の Out of Scope 記載の通りスコープ非重複
#1595(OPEN) 重複無し 共有 launcher parser 抽出。同上、スコープ非重複
#1601(OPEN) 重複無し scope_rollup.run の sibling profile 統合。同上、スコープ非重複
#1629(OPEN)/ PR #1630(Draft、OPEN、APPROVE、merge_ready: true、CI 全 green、head 2702ae7fd7b0d15863cc414ba54a92d379ce7646) 衝突・要調整 controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.py を変更中。Option 2 実装 Issue は、この PR の merge 後に rebase し、live snapshot materializer 実装との統合を確認する前提で設計する。PR #1630 自体は merge・close・編集しない(既存の独立した承認済み PR として扱う)

Fake-gh Integration Test Design

採用案(Option 2)の no-live-mutation 統合テスト設計。

  • fake gh バイナリ(PATH 上のスタブスクリプト、または gh 呼び出しを subprocess mock する既存テストパターンに準拠、scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py 等の既存 fixture パターンを踏襲)を用い、実際の GitHub へのネットワーク呼び出しを一切発生させない。
  • Positive: isolation agent request 生成(bounded JSON) → parent materialization(input file 書き込み) → controlled_skill_mutation_exec.py --command-id issue_comment.publish 実行 → fake gh が comment POST を模擬 → marker readback 成功 → 同一 marker 再実行時の idempotent skip 確認。
  • Negative: 既存 _validate_and_resolve_input_file の各分岐(absolute path/../symlink/hardlink/non-regular file/artifact subtree 外)を個別テスト、schema mismatch、issue_number 不一致、wrong repository、wrong producer(未実装なら追加要件として明記)、duplicate marker、marker/body conflict、POST timeout、readback mismatch、403/404/410/422/429/503 相当の fake gh 応答。
  • Claude/Codex parity: Claude 側は既存 hook で allow 済みのため回帰テストのみ、Codex 側は .codex/rules/default.rules への allow 追加後の契約テストを新規に必要とする。

Implementation Handoff

後続 implementation Issue(#1633、詳細はリンク先本文参照)に、以下を必須要件として含めた。

  • fixed_base_sha: PR feat: live Issue scope snapshot materializer を追加 #1630 merge 後の最新 origin/main SHA(実装着手時に再取得する)
  • consumer inventory: controlled_skill_mutation_exec.py、controlled_skill_mutation_policy.py、.claude/hooks/worktree_scope_guard.py(allow は既存のため変更不要の可能性が高いが確認要)、scripts/agent-guards/local_main_branch_guard.py、.codex/rules/default.rules、isolation worktree agent 側の request 生成箇所(issue-refinement-loop の comment 投稿箇所)
  • Claude/Codex parity: Codex 側 .codex/rules/default.rules への controlled_skill_mutation_exec.py allow 追加を含める
  • Allowed Paths: 上記 consumer inventory のファイル群
  • rollback: 新規 executor を追加しないため、変更差分は parent-side materializer 関数の追加と Codex allow rule の追加に限定され、rollback は単純な revert で可能

Close Evidence

Implementation Result

本 Issue はこれにより close 可能(AC1〜AC5 全充足、実装完了)。

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    phase/research
    state/queued
    agent/research
    on Jul 18, 2026
  2. squne121 commented on Jul 19, 2026

    @squne121
    OwnerAuthor

    敵対的レビュー結果

    判定: REQUEST_CHANGES

    調査テーマ自体は妥当です。しかし Issue #1608 は、原因候補・既存アーキテクチャ・解決案の設定を誤っています。

    特に重大なのは、**ISSUE_REFINEMENT_COMMAND_REGISTRY_V1 に登録されていることと、`skill_runtime_exec([GitHub CLI]1)です。

    このまま後続 Implementation Issue を起票すると、すでに存在する controlled metadata mutation lane を重複実装するか、preflight 専用 executor を不必要に汎用化する可能性が高いです。


    実際の失敗経路

    isolation worktree から次のような呼び出しを行った場合、

    skill_runtime_exec.py --command-id gh.issue.comment ...
    

    失敗は一段ではなく、少なくとも次の四段階に存在します。

    1. Worktree guard の exact allow に一致しない

    worktree_scope_guard.py は次の順序で処理しています。

    1. 通常の skill-runtime exact profile
    2. anchor profile
    3. looks_like_skill_runtime_executor_command()
    4. controlled mutation executor
    5. 通常の worktree mutation 判定

    exact profile が不一致である一方、コマンド文字列に skill_runtime_exec.py が含まれるため、通常の worktree mutation 判定へ進む前に block されます。

    したがって Issue が挙げている「required cwd」「未登録 command ID」「広い target predicate」は、hook 上の直接の block 経路としては関連しています。

    2. Policy の eligible_command_ids に入っていない

    現行 SKILL_RUNTIME_COMMAND_POLICY_V2 の eligible_command_ids は、以下の三件です。

    • preflight.run
    • preflight.run.fixture
    • preflight.run.with_anchor

    すべて canonical_main_root、default branch、preflight artifact subtree に固定されています。

    Issue 本文は「preflight 系三件と scope_rollup.run」と記載していますが、現行 main の scope_rollup.run はこの集合には入っておらず、別の専用 parser として存在します。

    つまり、Issue の Repo Ground Truth はすでに不正確です。scope_rollup.run を sibling profile に統合する作業自体が、別の OPEN Issue #1601 で提案されています。

    3. Registry validator が preflight 三形状に固定されている

    仮に gh.issue.comment を eligible_command_ids に追加しても動きません。

    validate_registry_entry() は以下を固定的に要求しています。

    • cwd_policy == "repo_root"
    • write root が .claude/artifacts/issue-refinement-loop/{active_issue}/
    • argv が三種類の preflight template のいずれか
    • placeholders が三種類の preflight contract のいずれか

    gh.issue.comment はこれらを満たさないため、cwd_policy_mismatch、allowed_write_roots_mismatch、argv_template_mismatch、または placeholder_mismatch で拒否されます。

    一方、registry 側の gh.issue.comment は cwd_policy: any、mutation: true、body_file placeholder を持つ、単なる canonical argv 定義です。

    4. Executor 本体が preflight 専用

    skill_runtime_exec.py の CLI は現在、次の引数しか受け付けません。

    • --command-id
    • --issue-number
    • --repo
    • --fixture
    • --anchor-comment-url

    --body-file は存在しません。

    さらに、executor は command ID ごとに fixture/anchor/通常 preflight を明示分岐し、最後には run_refinement_preflight.py の存在を無条件に検証します。

    registry へ渡す render parameter も issue_number、repo、必要に応じて fixture または anchor URL だけです。body_file を渡す手段がありません。子プロセスの cwd も常に project root です。

    結論として、guard だけ直しても実行不能です。


    主要 Findings

    [Blocker 1] Registry と privileged executor の責務を混同している

    Issue は次の前提を置いています。

    registry に gh.issue.comment があるのに、skill runtime executor から実行できないのは contract mismatch

    これは不正確です。

    Registry は各 workflow が利用する canonical argv の集合です。skill_runtime_exec.py はその全件を実行する汎用 engine ではなく、歴史的に追加された少数の privileged preflight profile 専用 executor です。

    過去の Issue #1154 でも、認可対象は preflight.run のみに限定され、gh.* や他 command ID は明示的に対象外でした。

    Issue #1498 で anchor profile を一件追加した際も、registry、policy、executor、二つの guard、settings、tests、docs をまたぐ vertical slice が必要でした。

    eligible_command_ids への一件追加で解消する問題ではありません。


    [Blocker 2] 根本原因の候補集合が不完全

    Issue が列挙する三点は、hook block の説明には使えます。

    • command ID 未登録
    • canonical root 固定
    • broad target predicate

    しかし、executor 内部にある以下の制約を根本原因候補に含めていません。

    • argparse に body_file がない
    • registry validation が preflight 三形状に固定
    • child script identity が run_refinement_preflight.py に固定
    • write audit が preflight artifact subtree 前提
    • render parameter が preflight 専用
    • remote mutation向けの readback/idempotency contract がない

    この状態で AC1・AC2を満たしても、後続 Implementation Issue の設計入力として不十分です。


    [Blocker 3] 既存の issue_comment.publish lane を比較対象から落としている

    リポジトリにはすでに、Issue comment 投稿専用の controlled mutation lane があります。

    controlled_skill_mutation_policy.py は preflight policy と明示的に分離されており、以下の command ID を管理しています。

    • issue_body.update

    • issue_comment.publish

    • contract_snapshot.publish

    • termination_report.publish

    • pr_review.publish

    issue_comment.publish にはすでに以下があります。

    • trusted repository binding
    • issue-scoped input namespace
    • closed input schema
    • artifact-only write root
    • remote comment readback
    • idempotency marker

    executor 側にはさらに、origin URL 検証、symlink/hardlink 拒否、schema binding、trusted gh binary、環境変数 sanitization、投稿前 marker check、投稿後 readback が実装されています。

    worktree guard もこの executor を exact command class として既に許可しています。

    この資産を評価せず、skill_runtime_exec.py に第二の GitHub comment publisher を追加する案を主要候補にしているのは、アーキテクチャレビューとして受理できません。


    [High 1] Issue #1478 の確定設計と衝突している

    Issue #1478 では、isolation worktree agent が skill_runtime_exec.py を直接起動しないことを確定しています。

    • parent が canonical main root で実行
    • isolation agent は bounded result のみ consume
    • generic isolation worktree 名を authorization 根拠にしない
    • required cwd/branch invariant を緩和しない

    現行 issue-refinement-loop/SKILL.md にも同じ parent-owned preflight 方針が残っています。

    Issue #1608 は、「worktree-scoped execution class」を採用する場合にこの設計を supersede するのか、metadata mutation は別 lane なので矛盾しないと整理するのかを明記していません。


    [High 2] 素の gh issue comment 成功を「guard bypass」と呼ぶのは不正確

    worktree_scope_guard.py の一般 mutation policy は、active issue に対応する expected worktree 内で、外部 write target がなければ mutating command を許可します。

    したがって expected worktree 内で raw gh issue comment が成功したなら、これは通常、

    • guard を回避した

    のではなく、

    • generic worktree-scoped mutation policy により許可された
    • registry/controlled executor の監査・readback経路を通らなかった

    と表現すべきです。

    この区別を誤ると、修正対象を guard authorization とするのか、workflow の canonical mutation route とするのかが曖昧になります。


    [High 3] body_file の脅威モデルがない

    公式 gh issue comment は --body-file で任意ファイルを読み、値が - の場合は標準入力を読みます。また同じ command は直近コメントの編集・削除系 option も持ちます。 ([GitHub CLI]1)try placeholder の body_file を executor CLI に追加すると、少なくとも次を決める必要があります。

    • 許可する input namespace
    • absolute path/../symlink/hardlink の扱い
    • FIFO、device、socket、巨大ファイルの拒否
    • UTF-8、NUL、size upper bound
    • - による stdin 読み込み禁止
    • issue number/repository/comment marker binding
    • duplicate invocation と timeout 後の再試行
    • 投稿後 readback
    • 403、404、410、422、429相当の分類

    GitHub の Issue comment API は mutation 権限を必要とし、content creation は secondary rate limiting の対象にもなり得ます。 ([GitHub Docs]2)olled executor はこの問題の多くをすでに扱っています。


    [Medium 1] local_main_branch_guard.py を Out of Scope にできない

    Issue は Claude 側 worktree_scope_guard.py のみを調査対象とし、local_main_branch_guard.py を除外しています。

    しかし、このリポジトリでは exact executor の認可集合を両 guard で共有し、split-brain を避けることが既存設計です。controlled mutation policy 自体も「両 guard の shared policy」と明記されています。

    さらに OPEN Issue #1595 は launcher parser を四つの consumer へ同時移行する方針です。

    後続 Implementation Issue は、少なくとも Claude/Codex parity と fastpath consumer を inventory に含める必要があります。


    [Medium 2] Acceptance Criteria が再現性を保証していない

    現在の AC は、ほぼ本文記載と後続 Issue 起票だけです。

    不足しているものは次です。

    • exact command の再現 fixture
    • 各層の判定結果
    • reason code
    • parser outcome
    • registry validation outcome
    • executor exit code
    • mutation zero証明
    • temp repository+real worktree の process test
    • fake gh を用いた投稿/readback/retry試験
    • Claude/Codex parity
    • negative matrix

    これでは、誤った原因分析を書いて Implementation Issue を起票しても AC を満たせます。


    [Medium 3] 時点固定と dependency 契約がない

    現在の main は Issue 起票時から進んでおり、周辺では #1595、#1565、#1601 が同じ guard/policy/executor surface を変更予定です。現在の repository head も #1608 起票後の commit です。

    Research 結果には少なくとも以下が必要です。


    推奨する採用方針

    第一候補: controlled metadata executor を再利用する

    gh.issue.comment を skill_runtime_exec.py に追加しない方がよいです。

    推奨フローは次です。

    isolation worktree agent
      ↓ bounded comment requestを生成
    parent / orchestrator
      ↓ canonical input JSONをissue-scoped namespaceへmaterialize
    controlled_skill_mutation_exec.py
      --command-id issue_comment.publish
      ↓
    GitHubへ投稿
      ↓
    marker/readback/idempotencyを検証
    

    この構成なら、

    Issue #1284 と merged PR #1295 は、まさに metadata mutation を worktree mutation から分離するために実装されています。

    直接 worktree 実行が本当に必要な場合

    その場合も skill_runtime_exec.py の既存 preflight profileへ混ぜるべきではありません。

    専用の worktree-scoped metadata profile または executor を設計し、以下を明示する必要があります。

    ただし、既存 issue_comment.publish と機能が重複するため、採用理由はかなり強くなければなりません。


    Issue #1608 の推奨リフレーム

    推奨タイトル

    調査: isolation worktree の Issue comment mutation を既存 controlled metadata executor lane へ接続する方式を確定する

    推奨 Outcome

    isolation worktree agent が生成した Issue comment requestを、raw gh issue comment や preflight専用 skill_runtime_exec.py の汎用化に依存せず、既存 issue_comment.publish controlled mutation laneへ安全に受け渡す canonical producer/parent delegation/execution contractが確定している。現行 blockをhook、policy、registry、executorの各層で再現した evidenceと、採用案を実装する後続Issueがリンクされている。

    最低限必要な AC

    1. 現行 commandを temp repository+real linked worktreeで実行し、hook、exact classifier、policy validation、executorの各結果と reason codeを記録する。
    2. skill_runtime_exec 拡張、既存 issue_comment.publish 再利用、parent delegation、raw gh 継続の四案を比較する。
    3. body_file/input JSON/stdin/symlink/hardlink/size/encoding/duplicate/timeout/readback/403・422・rate limitの脅威モデルを記載する。
    4. 実装: Issue metadata mutation を worktree ではなく controlled metadata executor 経由にする #1284、実装: Issue metadata mutation を controlled metadata executor 経由にする #1295、実装: issue-refinement-loop Step 0f を parent-owned preflight 運用で明文化し isolation agent の exact executor 実行を契約テストで禁止する #1478、実装: skill-runtime target predicate を Issue #1595 の共有 launcher classifier ベースに置換する #1565、実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595、#1601との reuse・dependency・supersede関係を確定する。
    5. 採用案について fake gh を使った no-live-mutation integration test設計を示す。
    6. 後続 Implementation Issueに fixed base SHA、全 consumer inventory、Claude/Codex parity、allowed paths、rollback条件を含める。

    総括

    Issue #1608 が問うべきなのは、

    なぜ skill_runtime_exec.py が gh.issue.comment を拒否するのか

    だけではありません。

    正しい問いは、

    isolation workflow の GitHub metadata mutation は、どの既存 canonical laneを通すべきか

    です。

    現行資産から判断すると、採用すべき方向は preflight専用 skill_runtime_exec.py の worktree対応化ではなく、既存 issue_comment.publish controlled metadata executorへの parent-owned delegation です。

    現状の Issue 本文は、後続 Implementation Issue 起票前にリフレームが必要です。

  3. squne121 commented on Jul 19, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(human_escalation)

    termination_reason: human_escalation
    termination_cause: human_judgment_required
    issue_number: 1608
    iteration: 3 / max_iterations 3

    経緯

    1. iteration 1: OWNER の敵対的レビューコメント(issuecomment-5013579411、REQUEST_CHANGES)を反映し、Outcome / In Scope / Out of Scope / Acceptance Criteria / Verification Commands / Notes for Reviewer を全面リフレームした。
    2. iteration 2: レビューで検出された VC (Verification Commands) preflight の形式違反 6 件(AC1 の括弧書き説明・broad search path、AC2 の broad search path、AC3/AC5 の baseline-expect annotation 欠落、AC4 のプレースホルダ未置換)を修正し、Allowed Paths に具体パスを追加した。
    3. iteration 3 のレビューで、contract_readiness_check.py --mode execute が新たに 4 件の VCP_UNEXPECTED_PASS(AC1・AC2 の 2 行・AC4 の VC が # baseline-expect: pass 注釈なしに成功したため)を検出した。

    現在の Blocker(未解消・4件)

    • AC1 の VC 行(rg -n "looks_like_skill_runtime_executor_command" .claude/hooks/worktree_scope_guard.py)に # baseline-expect: pass 注釈が必要
    • AC2 の VC 2 行(eligible_command_ids / validate_registry_entry 検索)にそれぞれ # baseline-expect: pass 注釈が必要
    • AC4 の VC 行(gh issue list --search "Closes #1608 in:body" ...)に # baseline-expect: pass 注釈が必要

    停止理由

    issue-refinement-loop の loop policy 上、max_iterations(既定 3)に達したため、これ以上の自動 rewrite は行わず、human_escalation として停止する。修正自体は機械的(上記 4 行に注釈を追加するのみ)であり、次回 iteration で解消できる見込み。

    副次的に判明した事項(参考)

    本ループの実行中、.claude/skills/issue-refinement-loop/scripts/ 配下の一部スクリプト(build_refinement_phase_state.py、publish_termination_report.py 等)が、canonical main root・default branch から直接実行できず(local_main_branch_guard.py の issue_refinement_direct block)、かつ isolation/issue-worktree 側では worktree_scope_guard.py により preflight 系の artifact write root(main root の .claude/artifacts/issue-refinement-loop/1608/)へ書き込めない、という実行経路上のギャップを実際に観測した。これは本 Issue #1608 自体が調査対象としている worktree eligibility gap と隣接する事象であり、本コメントは control-plane 側の一次証跡として記録する(本 Issue の Allowed Paths・AC の変更は提案しない)。

  4. squne121 commented on Jul 19, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告(approved)

    termination_reason: approved
    issue_number: 1608

    決定論的チェッカー2種が両方とも良好な結果を返したため、本 Issue の contract 品質は承認基準を満たしていると判断する。

    • check_issue_contract.py: verdict=approve(C3-C8 pass、C9 は advisory warning のみで non-blocking)
    • contract_readiness_check.py(VC preflight): status=go(errors なし)

    本 Issue は issue_kind: research であり、通常の implementation issue 向け impl-review-loop へのルーティングは対象外

    本 Issue の Outcome は「調査結果と採用案が本文に記載され、実装 Issue が起票・link されている状態」であり、本 Issue 自体を実装する Issue ではない。したがって承認は「この Issue の記述内容で調査に着手してよい」ことを意味し、impl-review-loop を自動起動する対象ではない。

    Next Action

    In Scope に記載された調査(temp repository + real linked issue worktree での block 再現、4 案比較、脅威モデル記載、既存 Issue との依存関係確定、fake gh 統合テスト設計)を実施し、結果を本文(Outcome / In Scope 該当箇所)に反映したうえで、採用案の implementation Issue を起票して AC3・AC4 を満たすこと。

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/researchphase/researchstate/queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions