Repository navigation
Description
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-onlyParent 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
- 現行の block を temp repository + real linked issue worktree で再現し、hook・exact classifier・policy validation・executor の各層の判定結果、reason code、parser outcome、registry validation outcome、executor exit code を本 Issue 本文に記載する。
- 以下 4 案を比較し、採用案を提案する(実装はしない)。
skill_runtime_exec.pyのeligible_command_ids/ registry validator / executor CLI(--body-file等)をgh.issue.comment向けに汎用化する案- 既存の
issue_comment.publishcontrolled metadata 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 を既に持つ)へ、isolation worktree agent の comment request を parent delegation 経由で接続する案 - isolation worktree agent からの直接実行を許可する新しい worktree-scoped execution class を新設する案(Issue 実装: issue-refinement-loop Step 0f を parent-owned preflight 運用で明文化し isolation agent の exact executor 実行を契約テストで禁止する #1478 の parent-owned preflight 方針を supersede するか、metadata mutation は別 lane として矛盾しないかを明記する)
- 素の
gh issue commentフォールバックを運用上許容し続ける案(この場合、worktree_scope_guard.pyの一般 mutation policy による許可であり "guard bypass" ではないことを本文で正確に表現する)
body_file(または同等の comment 本文 input)の脅威モデルを記載する: 許可する 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 相当の分類。- 採用案と既存 Issue(実装: Issue metadata mutation を worktree ではなく controlled metadata executor 経由にする #1284、PR 実装: 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、実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601)との reuse・dependency・supersede 関係を確定する。
local_main_branch_guard.pyは exact executor の認可集合をworktree_scope_guard.pyと共有する既存設計であるため、コード変更は Out of Scope としつつ、認可集合の共有関係の調査は In Scope に含める。 - 採用案について、fake
ghを用いた no-live-mutation な投稿/readback/retry integration test の設計を示す(Claude/Codex parity・negative matrix を含む)。 - 後続 implementation Issue が満たすべき最低限の要件(fixed base SHA、変更対象の全 consumer inventory、Claude/Codex parity、Allowed Paths、rollback 条件)を明示する。
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 stateAllowed 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.publishcontrolled 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.publishcontrolled 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
- 本 Issue は当初、
skill_runtime_exec.pyのeligible_command_ids未登録・required_cwd固定・looks_like_skill_runtime_executor_commandの広い部分文字列一致の 3 点を根本原因候補として起票されたが、OWNER による敵対的レビュー(issuecomment-5013579411、body_sha256: 37c31af503e94537177ffe19d520819d199d2a5d6bbab2ca2e3a64557b5b156b)で REQUEST_CHANGES 判定を受けた。 - 主要な指摘: (1) registry 登録と privileged executor の実行権限は別概念であり、
skill_runtime_exec.pyは preflight 専用の少数 profile executor である(Issue 実装: hooks: preflight.run 専用 privileged executor を root checkout から安全実行可能にする #1154/実装: preflight.run に anchor comment 対応の sibling exact profile (preflight.run.with_anchor) を追加する #1498 の経緯参照)。(2) 根本原因候補が executor 内部制約(--body-file不在、registry validation の preflight 三形状固定、child script identity 固定、write audit の preflight artifact subtree 前提、remote mutation の readback/idempotency 契約欠如)を欠いていた。(3) 既存のissue_comment.publishcontrolled metadata lane を比較対象から落としていた。 - 上記指摘を反映し、本 Issue の Outcome / In Scope / Acceptance Criteria / Verification Commands を全面的にリフレームした。VC に含まれていた
git grep(git 読み取り専用 allowlist 外)とNEW_IMPLEMENTATION_ISSUE_NUMBER/THIS_ISSUE_NUMBERのプレースホルダ未置換も本改訂で修正した。 - 重複確認: 実装: skill-runtime target predicate を Issue #1595 の共有 launcher classifier ベースに置換する #1565(
looks_like_skill_runtime_executor_commandの argv-aware classifier 化)、実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595(共有 launcher parser 抽出)、実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601(scope_rollup.runの sibling profile 統合)とはスコープが重複しない。本 Issue はgh.issue.comment等 registry mutation command-id の worktree eligibility gap と、既存issue_comment.publishlane との関係確定を対象とする。 - 2026-07-19 改訂: OWNER 再レビューの contract_readiness_check.py(VC preflight)指摘6件を形式面のみ修正した。(1) AC1 の VC から括弧書き説明文の行を削除し(本文への reason code 記載確認は human review 側の確認事項とし VC からは除外)、.claude/artifacts/issue-refinement-loop/1608/ への broad search を含む行を除去した。(2) AC1/AC2 の rg 対象ファイルを Allowed Paths に具体パスとして列挙し、broad search path 判定を解消した。(3) AC3/AC5 の VC は実行すれば成功する読み取りコマンドであるため、直前行に baseline-expect: pass アノテーションを追加した。(4) AC4 の NEW_IMPLEMENTATION_ISSUE_NUMBER プレースホルダを、gh issue list --search で後続 implementation Issue の起票有無を検索する形の VC に置き換え、未確定の Issue 番号を直接参照しない形にした。Outcome / In Scope / Out of Scope / Acceptance Criteria の文章内容は変更していない。
- 2026-07-19 research 完了: 下記 Research Result 以下の全セクションを追記し、AC1〜AC5 を充足させた。採用案は Option 2(
issue_comment.publish再利用)。実装 Issue は 実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ parent delegation で接続する #1633(本文「Implementation Handoff」参照)。
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.pyallow 追加を含める - Allowed Paths: 上記 consumer inventory のファイル群
- rollback: 新規 executor を追加しないため、変更差分は parent-side materializer 関数の追加と Codex allow rule の追加に限定され、rollback は単純な revert で可能
Close Evidence
- AC1: 満たす(本 Issue「Reproduction Environment」「Layer-by-Layer Failure Evidence」参照)
- AC2: 満たす(本 Issue「Current Repository Ground Truth」参照、旧 AC2 記載を訂正)
- AC3: 満たす(本 Issue「Option Comparison」「Adopted Direction」参照)
- AC4: 満たす(本 Issue「Implementation Handoff」に実装 Issue 実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ parent delegation で接続する #1633 をリンク)
- AC5: close 可能(追加調査要件なし)
Implementation Result
- 実装 Issue 実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ parent delegation で接続する #1633 は PR 実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ接続する (#1633) #1639 のマージにより CLOSED(COMPLETED、closedAt: 2026-07-19T13:57:02Z)。
- PR 実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ接続する (#1633) #1639: 実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ接続する (実装: isolation worktree agent の Issue comment request を issue_comment.publish controlled mutation lane へ parent delegation で接続する #1633)
- merge head:
77b86457865e4e275ac5b6fb501e07ac24e58a39(fix_delta 後、squash merge) - changed files(8):
scripts/agent-guards/controlled_skill_mutation_policy.py,.claude/skills/issue-refinement-loop/scripts/publish_termination_report.py,.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py,scripts/agent-guards/tests/test_controlled_skill_mutation_policy.py,scripts/agent-guards/tests/test_isolation_issue_comment_publish_bridge.py(新規),.codex/rules/default.rules,docs/dev/agent-skill-boundaries.md,docs/dev/hook-boundaries.md - CI: 全項目 SUCCESS
- review: OWNER REQUEST_CHANGES(P0: materializer symlink/TOCTOU 任意ファイル上書き、P1×2: bounded request 検証境界欠如・fallback marker 衝突)を fix_delta で全件修正し、再レビューで APPROVE・merge_ready: true 取得後に squash merge。
- worktree(
.claude/worktrees/issue-1633-isolation-issue-comment-bridge)・branch(worktree-issue-1633-isolation-issue-comment-bridge)はcleanup_exec.pyで削除済み(status: ok)。 - 残存リスク: PR feat: live Issue scope snapshot materializer を追加 #1630(実装: live GitHub-bound Issue scope snapshot materializer を追加する #1629)が同一ファイルを先行変更していたが、feat: live Issue scope snapshot materializer を追加 #1630 が先にマージされたため conflict 無し。Codex 側
.codex/rules/default.rulesの allow rule は本 PR で追加済み。
- merge head:
本 Issue はこれにより close 可能(AC1〜AC5 全充足、実装完了)。
Activity
squne121 commentedon Jul 19, 2026
敵対的レビュー結果
判定: 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 から次のような呼び出しを行った場合、
失敗は一段ではなく、少なくとも次の四段階に存在します。
1. Worktree guard の exact allow に一致しない
worktree_scope_guard.pyは次の順序で処理しています。looks_like_skill_runtime_executor_command()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.runpreflight.run.fixturepreflight.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".claude/artifacts/issue-refinement-loop/{active_issue}/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_fileplaceholder を持つ、単なる 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 は各 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 の説明には使えます。
しかし、executor 内部にある以下の制約を根本原因候補に含めていません。
body_fileがないrun_refinement_preflight.pyに固定この状態で AC1・AC2を満たしても、後続 Implementation Issue の設計入力として不十分です。
[Blocker 3] 既存の
issue_comment.publishlane を比較対象から落としているリポジトリにはすでに、Issue comment 投稿専用の controlled mutation lane があります。
controlled_skill_mutation_policy.pyは preflight policy と明示的に分離されており、以下の command ID を管理しています。issue_body.updateissue_comment.publishcontract_snapshot.publishtermination_report.publishpr_review.publishissue_comment.publishにはすでに以下があります。executor 側にはさらに、origin URL 検証、symlink/hardlink 拒否、schema binding、trusted
ghbinary、環境変数 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を直接起動しないことを確定しています。現行
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 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 に追加すると、少なくとも次を決める必要があります。../symlink/hardlink の扱い-による stdin 読み込み禁止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 起票だけです。
不足しているものは次です。
ghを用いた投稿/readback/retry試験これでは、誤った原因分析を書いて Implementation Issue を起票しても AC を満たせます。
[Medium 3] 時点固定と dependency 契約がない
現在の main は Issue 起票時から進んでおり、周辺では #1595、#1565、#1601 が同じ guard/policy/executor surface を変更予定です。現在の repository head も #1608 起票後の commit です。
Research 結果には少なくとも以下が必要です。
fixed_base_sha推奨する採用方針
第一候補: controlled metadata executor を再利用する
gh.issue.commentをskill_runtime_exec.pyに追加しない方がよいです。推奨フローは次です。
この構成なら、
ghfallback を production path から除去できるIssue #1284 と merged PR #1295 は、まさに metadata mutation を worktree mutation から分離するために実装されています。
直接 worktree 実行が本当に必要な場合
その場合も
skill_runtime_exec.pyの既存 preflight profileへ混ぜるべきではありません。専用の worktree-scoped metadata profile または executor を設計し、以下を明示する必要があります。
gh issue commentの deny cutoverただし、既存
issue_comment.publishと機能が重複するため、採用理由はかなり強くなければなりません。Issue #1608 の推奨リフレーム
推奨タイトル
推奨 Outcome
最低限必要な AC
skill_runtime_exec拡張、既存issue_comment.publish再利用、parent delegation、rawgh継続の四案を比較する。body_file/input JSON/stdin/symlink/hardlink/size/encoding/duplicate/timeout/readback/403・422・rate limitの脅威モデルを記載する。ghを使った no-live-mutation integration test設計を示す。総括
Issue #1608 が問うべきなのは、
だけではありません。
正しい問いは、
です。
現行資産から判断すると、採用すべき方向は preflight専用
skill_runtime_exec.pyの worktree対応化ではなく、既存issue_comment.publishcontrolled metadata executorへの parent-owned delegation です。現状の Issue 本文は、後続 Implementation Issue 起票前にリフレームが必要です。
squne121 commentedon Jul 19, 2026
issue-refinement-loop 終了報告(human_escalation)
termination_reason: human_escalation
termination_cause: human_judgment_required
issue_number: 1608
iteration: 3 / max_iterations 3
経緯
baseline-expectannotation 欠落、AC4 のプレースホルダ未置換)を修正し、Allowed Pathsに具体パスを追加した。contract_readiness_check.py --mode executeが新たに 4 件のVCP_UNEXPECTED_PASS(AC1・AC2 の 2 行・AC4 の VC が# baseline-expect: pass注釈なしに成功したため)を検出した。現在の Blocker(未解消・4件)
rg -n "looks_like_skill_runtime_executor_command" .claude/hooks/worktree_scope_guard.py)に# baseline-expect: pass注釈が必要eligible_command_ids/validate_registry_entry検索)にそれぞれ# baseline-expect: pass注釈が必要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_directblock)、かつ 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 の変更は提案しない)。squne121 commentedon Jul 19, 2026
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 を満たすこと。