Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Parent Issue
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "1608"
goal_ref: "isolation worktree agent が生成する bounded Issue comment request を parent-owned materializer/delegation を通して issue_comment.publish controlled mutation lane へ接続する"
change_kind: mixed
fixed_base_sha: "4ab8ec2d9495638695ef774fb8737b509585f492"Parent Goal Ref
- Goal: isolation worktree agent が生成した Issue comment mutation request を、raw
gh issue commentや preflight 専用 skill_runtime_exec.py の汎用化に依存せず、既存issue_comment.publishcontrolled mutation lane(controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.py)へ安全に受け渡す canonical producer/parent delegation/execution contract を確定する(調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608 research)。 - Desired Destination: OWNER の敵対的レビュー(issuecomment-5013579411)で採用された「第一候補: controlled metadata executor を再利用する」案(isolation worktree agent が bounded comment request を生成し、parent/orchestrator が issue-scoped input namespace へ materialize し、
controlled_skill_mutation_exec.py --command-id issue_comment.publishを起動して GitHub へ投稿し、marker/readback/idempotency を検証する)を実装する。
Current Validated Scope
- isolation worktree agent 向けの bounded comment request schema(閉じたキーのみ)の新規定義
- parent 側 materializer 関数(bounded request から issue-scoped input namespace への JSON 書き込み、
controlled_skill_mutation_exec.py --command-id issue_comment.publishの exact argv 起動)の追加 .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py(_post_github_comment関数、rawgh issue comment --body-file -を直接呼んでいる唯一の production 箇所として grep で特定済み)を、上記 bounded request 経路へ置き換える- fake
ghを用いた no-live-mutation integration test(positive/negative)の追加 .codex/rules/default.rulesへのcontrolled_skill_mutation_exec.pyallow エントリ追加(Codex 側は現状 exact allow を持たないことを docs/dev/hook-boundaries.md:730 で確認済み)- 対応する docs 更新(
docs/dev/agent-skill-boundaries.md/docs/dev/hook-boundaries.md)
Remaining Parent Gaps
- skill_runtime_exec.py の
gh.issue.comment汎用化案(Option 1)・新規 worktree-scoped execution class 新設案(Option 3)は不採用のため、本 Issue では扱わない local_main_branch_guard.py側のissue_refinement_directblock と worktree 側の artifact write root 制約の間の実行経路ギャップ(調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608 iteration 3 コメントで観測済み)は、本 Issue の Allowed Paths・AC の対象外とし、必要であれば別 Issue とする
Outcome
isolation worktree agent が生成する bounded Issue comment request(issue_number / repo / comment_body / marker の閉じたフィールドのみ)が、canonical main root 上の parent orchestrator(issue-refinement-loop の comment 投稿箇所)が持つ materializer 関数によって issue-scoped input namespace(artifacts/{issue_number}/issue-metadata/issue_comment.publish/)へ書き込まれ、既存の controlled_skill_mutation_exec.py --command-id issue_comment.publish の exact argv で起動されて GitHub へ投稿される状態になっている。isolation worktree agent 側に残っていた raw gh issue comment production 呼び出し(publish_termination_report.py::_post_github_comment)が上記経路へ置き換わり、.codex/rules/default.rules に controlled_skill_mutation_exec.py の allow エントリが追加され、fake gh を用いた no-live-mutation integration test と関連 docs 更新を含む状態で PR が open されている。
In Scope
- isolation worktree agent 向けの bounded comment request schema(JSON、閉じたキーのみ:
schema/issue_number/repo/comment_body/marker)を新規定義する - parent 側の materializer 関数(bounded request を受け取り、
artifacts/{issue_number}/issue-metadata/issue_comment.publish/配下へISSUE_COMMENT_PUBLISH_INPUT_V1互換 JSON を書き込み、controlled_skill_mutation_exec.py --command-id issue_comment.publish --issue-number (対象issue番号) --input-file (materialize済みJSONパス) --repo squne121/loop-protocolの exact argv を起動する)を追加する .claude/skills/issue-refinement-loop/scripts/publish_termination_report.pyの_post_github_comment(rawgh issue comment --body-file -呼び出し)を、上記 bounded request 生成 + materializer 呼び出しへ置き換える- fake
ghを用いた no-live-mutation integration test(positive: request 生成 → materialize → controlled executor 起動 → fake gh POST → marker readback 成功 → idempotent retry。negative: absolute path/../symlink/hardlink/schema mismatch/wrong repo/wrong issue number/duplicate marker/marker-body conflict)を追加する .codex/rules/default.rulesにcontrolled_skill_mutation_exec.pyの allow エントリを追加し、Codex 側でも同じ controlled mutation lane が使えるようにする- 上記変更に対応する docs 更新(
docs/dev/agent-skill-boundaries.mdおよび/またはdocs/dev/hook-boundaries.md)
Out of Scope
- skill_runtime_exec.py 自体の汎用化(調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608 Option 1、不採用)
- 新規 worktree-scoped execution class の新設(調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608 Option 3、不採用)
- looks_like_skill_runtime_executor_command の argv-aware classifier 化(実装: skill-runtime target predicate を Issue #1595 の共有 launcher classifier ベースに置換する #1565 のスコープ、重複させない)
- 共有 launcher parser 抽出(実装: launcher command 共有 parser(argv boundary 保持・cwd/project_root 対応)を抽出し全 consumer の invocation contract を移行する #1595 のスコープ、重複させない)
scope_rollup.runの sibling profile 統合(実装:scope_rollup.runをskill_runtime_execのsiblingexactprofileへ統合する #1601 のスコープ、重複させない)- PR feat: live Issue scope snapshot materializer を追加 #1630(実装: live GitHub-bound Issue scope snapshot materializer を追加する #1629)の変更内容そのもの。着手前に PR feat: live Issue scope snapshot materializer を追加 #1630(2026-07-19 時点 Draft/OPEN/APPROVE/merge_ready:true/CI 全 green、head 2702ae7)の最新状態を確認し、マージ済みなら最新 origin/main へ rebase、未マージなら
controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.pyへの同時並行変更衝突を避ける
Acceptance Criteria
- AC1: isolation worktree agent 向けの bounded comment request schema が定義され、閉じたキーのみを許可する
- AC2: parent 側 materializer 関数が、request を
artifacts/{issue_number}/issue-metadata/issue_comment.publish/へ書き込み、既存controlled_skill_mutation_exec.py --command-id issue_comment.publishの exact argv を起動する - AC3:
publish_termination_report.pyの rawgh issue comment呼び出し(_post_github_comment)が上記経路へ置き換わっている - AC4: fake
ghによる no-live-mutation 統合テスト(positive/negative 双方)が追加され、実際の GitHub へのネットワーク呼び出しが一切発生しないことが検証されている - AC5:
.codex/rules/default.rulesにcontrolled_skill_mutation_exec.pyの allow エントリが追加され、Codex 側でも既存の Claude 側 hook parity が成立する - AC6:
pnpm typecheck/pnpm lint/pnpm test/pnpm buildが全て pass する - AC7: 関連 docs が更新されている
Verification Commands
# AC1
# baseline-expect: fail
$ rg -n "ISOLATION_ISSUE_COMMENT_REQUEST_V1" scripts/agent-guards/controlled_skill_mutation_policy.py
# AC2
# baseline-expect: fail
$ rg -n "def materialize_isolation_issue_comment_request" .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
# AC3
# baseline-expect: pass
$ rg -c "issue., .comment." .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
# AC4
# baseline-expect: fail
$ test -f scripts/agent-guards/tests/test_isolation_issue_comment_publish_bridge.py
# AC5
# baseline-expect: fail
$ rg -n "controlled_skill_mutation_exec.py" .codex/rules/default.rules
# AC6
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
# AC7
# baseline-expect: fail
$ rg -n "isolation_issue_comment_request" docs/dev/agent-skill-boundaries.mdAllowed Paths
- scripts/agent-guards/controlled_skill_mutation_exec.py
- scripts/agent-guards/controlled_skill_mutation_policy.py
- scripts/agent-guards/tests/
- .codex/rules/default.rules
- .claude/skills/issue-refinement-loop/scripts/publish_termination_report.py
- .claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py
- docs/dev/agent-skill-boundaries.md
- docs/dev/hook-boundaries.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- PR feat: live Issue scope snapshot materializer を追加 #1630 がマージ済みで origin/main の
controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.pyが本 Issue 起票時点と実質的に異なる場合は、rebase 後に AC1/AC2 の実装方針を再確認する
Required Skills
- Python(stdlib のみ、subprocess/argparse/pathlib)
- GitHub CLI(
gh apiargv-list 呼び出しの安全設計) - pytest(fake subprocess ハーネスによる no-live-mutation テスト設計)
Required Design References
- docs/dev/hook-boundaries.md 内 Parallel Agent Runtime Safety セクション
- docs/dev/agent-skill-boundaries.md
Scope Delta(該当時のみ記載)
- 2026-07-19: implementation-worker が AC3 実装着手前に、
.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.py(元の Allowed Paths 外)が_post_github_commentの rawgh issue commentargv shape(["gh", "issue", "comment", ...])を前提にsubprocess.runを mock する既存テスト約20件(TestGhBodyFile/TestIntegrationpositive path /TestRepoFlag/TestExecMarkerInjection等)を持つことを検出した。AC3 実装(_post_github_commentを bounded request 生成 + materializer 呼び出しへ置き換え)はこれらのテストの前提(cmd[0] == "gh")を変えるため、追随修正が必須。 - 対応: 既存テストを削除せず、
.claude/skills/issue-refinement-loop/tests/test_publish_termination_report.pyを Allowed Paths へ追加し、新しい呼び出し経路(materializer 経由のcontrolled_skill_mutation_exec.py起動)に合わせてテストを更新する(fake subprocess mock の対象コマンドをghからcontrolled_skill_mutation_exec.pyinvocation へ変更)。既存テストが検証していた intent(body-file 経由の投稿・repo flag・exec marker injection・integration path)は維持し、経路のみ更新する。
Delivery Rule
- 1 Issue = 1 PR
- 実装は issue-worktree(
.claude/worktrees/issue-番号-x等)で行う - PR は Draft PR として作成する
Notes for Reviewer
- 依存: 実装: Issue metadata mutation を worktree ではなく controlled metadata executor 経由にする #1284(CLOSED)/ PR 実装: Issue metadata mutation を controlled metadata executor 経由にする #1295(MERGED)の
issue_comment.publishcontrolled mutation lane をそのまま再利用する(新規 executor 不要) - 依存/整合: 実装: issue-refinement-loop Step 0f を parent-owned preflight 運用で明文化し isolation agent の exact executor 実行を契約テストで禁止する #1478(CLOSED)の parent-owned preflight 方針と矛盾しないこと(isolation agent が exact executor を直接起動しない原則を維持する)
- 衝突回避: PR feat: live Issue scope snapshot materializer を追加 #1630(実装: live GitHub-bound Issue scope snapshot materializer を追加する #1629)が
controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.pyを変更中(2026-07-19 時点で Draft/OPEN/APPROVE/merge_ready:true/CI 全 green、head 2702ae7)。実装着手時に最新状態を再確認すること - Scope 重複チェック: check_issue_overlap.py を実行した結果、decision: ambiguous_requires_human、reason_code: parent_child_collision(policy_class C3)を検出した。これは parent-ref に 1608 を明示したことによる親 Issue 調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608 との Allowed Paths 重複(
controlled_skill_mutation_exec.py/controlled_skill_mutation_policy.py)が原因である。調査: skill runtime exec 経由の worktree mutation command-id 実行が block される根本原因を特定する #1608 の Allowed Paths は「読み取り専用。リポジトリ変更なし(既定)」と明記された research issue であり、実コード変更を行わない。したがって本 collision は非衝突(親 Issue は調査目的の read-only 参照であり、本 Issue が唯一の実コード変更者である)と判断し、起票を続行した。実装: 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 / 実装: live GitHub-bound Issue scope snapshot materializer を追加する #1629 との重複は、それぞれ異なる対象(looks_like_skill_runtime_executor_command の classifier 化 / 共有 launcher parser 抽出 /scope_rollup.runsibling 統合 / live issue scope snapshot materializer)であり scope 重複なしを確認済み
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
fix: docs 例示コマンドに --locked を追加し governed Python invocation policy(#1193…
fix: docs 見出しに日本語併記を追加し PR Body Japanese Check の changed-markdown 全文検…
squne121 commentedon Jul 19, 2026
敵対的レビュー結果
判定:
REQUEST_CHANGES— 現状のままではマージ不可対象は PR #1639 の current head
11758655ad8e49f65db977abcbc1c03c7ca60dc8。Draft/Open で、現在の CI は全成功しています。直前の CI failure は日本語見出し修正で解消済みです。したがって、以下は CI では検出されていない設計・認可・並行実行上の問題です。Blocker 1: parent delegation ではなく controlled executor の自己ネストになっている
Issue #1633 の意図は、isolation agent が生成した bounded request を canonical main root の parent が materialize し、
issue_comment.publishexecutor を一度だけ起動する構造です。実装は次の経路です。
外側 executor が publisher を subprocess 起動し、その publisher が同じ executor をもう一度 subprocess 起動しています。
さらに、materializer は isolation agent 由来の request object を受け取らず、既に parent 内に存在する引数から request を自分で再構築しています。closed-key validator は、呼び出し元が作った dict に対して実行されるため、実際の agent→parent 境界を検査していません。
必要な修正
termination_report.publishからissue_comment.publishへの処理を executor 内部の関数呼び出しとして統合し、executor subprocess の再帰起動を廃止する。issue_comment.publishを一度だけ起動する。ISOLATION_ISSUE_COMMENT_REQUEST_V1object/artifact を validator に渡す producer/consumer 経路を実装する。Blocker 2: Codex に Issue comment 以外の全 remote mutation を許可している
追加された Codex rule は、
controlled_skill_mutation_exec.pyというスクリプト prefix 全体をallowにしています。コメントと justification も、issue_body.update、contract_snapshot.publish、pr_review.publishなど全 remote mutation を許可する内容です。executor の allowlist には実際に五種類の command ID が登録されています。したがって #1633 の Issue comment bridge を理由に、Issue body 更新や PR review 投稿まで Codex の無承認経路へ追加されています。
Codex rules は、sandbox 外のコマンドを無承認で許可するか、承認対象または block にするかを決定する認可レイヤーです。単なるコマンド補完設定ではありません。 ([OpenAI]1)
必要な修正
issue_comment.publish専用の小さい wrapper executable を設け、その固定 path だけを Codex rule で許可する。Blocker 3: 固定ファイル名による TOCTOU と cross-run 上書きがある
materializer は常に次の固定ファイルへ通常の
write_text()で上書きします。その後に別 subprocess が同じファイルを読みます。
同じ Issue に対する二つの publish が並行すると、以下が成立します。
この場合、A の処理が B の本文を投稿できます。local marker や remote readback では、投稿前に入力が差し替わった事実を検出できません。
必要な修正
O_CREAT | O_EXCL相当で immutable に生成し、既存ファイルを上書きしない。comment_body_sha256とinput_sha256を含め、読込後に再検証する。High 1: 「integration test」が process boundary を検証していない
新規テストは、
_find_gh_bin、remote 検証、POST、marker 検索、readback をすべて mock し、_exec.main()を同一 Python process 内で直接呼び出しています。このテストでは、実運用で重要な以下を検証できません。
ghexecutable の実呼び出し必要な修正
一時ディレクトリに実行可能な fake
ghを作り、PATH の先頭に置いた状態でpublish_termination_report.pyまたは外側 executor を本当に subprocess 起動してください。fakeghは argv/stdin/env を記録し、指定シナリオに応じて GitHub API 互換 JSON と exit code を返す構成にします。GitHub の comment endpoint は
201に加え、403、404、410、422を返し得て、短時間の連続投稿は secondary rate limiting の対象です。少なくともこれらと429、POST 成功後の readback timeout を matrix 化すべきです。 ([GitHub Docs]2)High 2: 新しく追加された trusted module が realpath trust chain に入っていない
publisher は
scripts/agent-guardsをsys.path先頭へ挿入し、controlled_skill_mutation_policy.pyを importしています。また child executor path も同じ場所から組み立てています。一方、外側 executor の module realpath check は publisher、renderer、
prose_boundary_policyしか検査していません。新しい policy module と child executor は対象外です。必要な修正
controlled_skill_mutation_policy.pycontrolled_skill_mutation_exec.pyを
_check_module_realpaths()の trusted chain に追加し、単純な文字列startswithではなくPath.is_relative_to(project_root.resolve())で ancestry を検証してください。import 後のmodule.__file__も canonical path と一致させるべきです。High 3: request schema と marker identity が弱い
bounded validator は marker が非空で、本文中に substring として存在することしか要求しません。executor の remote precheck/readback も同じ substring 検索です。
また materialized executor input からは
repoが落ち、body hash もありません。そのため、直接 executor を呼べる caller は、短い一般文字列や既存コメントに含まれ得る文字列を marker に指定できます。誤衝突時には無関係なコメントを idempotency authority として扱う可能性があります。
必要な修正
repo、comment_body_sha256、producer_role、必要なら request ID を input に含める。<!-- CONTROLLED_EXEC_MARKER:<32-or-64 hex> -->に固定する。count == 1かつ trailing position であることを要求する。High 4: direct Codex path では GitHub host/env binding が不足する
Issue comment lane の
gh issue viewとgh api呼び出しには、sanitizedenvも--hostname github.comも渡されていません。GitHub CLI では
GH_HOSTが hostname 未指定時の対象 host を決め、GH_REPOも repository context に影響します。外側termination_report.publishからのネスト経路では偶然 sanitized env を継承しますが、新設された Codex direct allow 経路ではその前提がありません。 ([GitHub CLI]3)必要な修正
すべての issue-comment read/precheck/POST/readback 呼び出しに、PR review lane と同等の sanitized env と明示的な
--hostname github.comを適用してください。High 5: 30 秒 timeout は内部トランザクションの予算より短い
publisher は child executor を三十秒で kill します。
inner executor は正常系でも、marker precheck 十五秒、POST 十五秒、readback 十五秒を個別に許容します。つまり、POST が成功した後、readback 前後で親が child を kill し、「コメントは存在するが処理は失敗」という ambiguous outcome を作れます。
根本解は executor 自己ネストの廃止です。暫定対応でも、timeout は下流最大予算と後処理を上回らせ、POST 後 timeout は通常の failure ではなく
published_but_unverifiedとして扱う必要があります。依存関係ゲート
PR #1630 は現在も Draft/Open で、同じ
controlled_skill_mutation_policy.pyとcontrolled_skill_mutation_exec.pyを変更しています。Issue #1633 自身も、PR #1630 が未マージの場合は同時変更衝突を避けるよう要求しています。したがって、上記修正とは別に、#1630 を先に確定・マージし、#1639 を最新
mainへ rebase した後、policy/executor の契約レビューをやり直す必要があります。マージ可能にする最低条件
issue_comment.publish専用に縮小する。ghexecutable を通る真の統合テストを追加する。実装: isolation worktree agent の Issue comment request を issue_comment.…
実装: review/refinementのreplay・envelope・custom publisherをbounded loopへ置…