Skip to content

実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393

Closed

Description

@squne121

Source

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2190"
goal_ref: "#2190 AC1/AC3/AC5/AC9/AC10: migrate exactly the two contract_update mutation profiles excluded from #2199 to the dedicated control-plane runtime while preserving fail-closed behavior."
change_kind: code

Parent Issue

#2190

Parent Goal Ref

Current Validated Scope

  • Migrate only contract_update.run.with_anchor and contract_update.run.with_human_context from the current canonical-main-root / default-branch mutation lane to the dedicated control-plane runtime.

Remaining Parent Gaps

Outcome

PR #2495 が実装した既存の parent-controller(control_plane_dedicated_execution_session()、scripts/agent-ops/worktree_bootstrap_exec.py)を再利用し、対象2つの contract_update mutation profile(contract_update.run.with_anchor / contract_update.run.with_human_context)の child dispatch を、既存の dedicated worktree 実行経路へ追加する。新しい re-exec route、command entrypoint、lifecycle lock protocol は追加しない。invocation root(親プロセスが起動する canonical main root / default branch)と child execution root(dedicated worktree)を区別し、registry の required_cwd を機械的に dedicated root へ置き換えるだけの実装にしない。既存の explicit-lane authorization、trusted-anchor/human-context 区別、artifact write-root 限定、fail-closed 挙動、および mutation 成功/検証失敗/mutation 失敗の既存結果分類(disposition: patch/final_readback/fresh_review、status: handoff_required/disposition: full_rewrite_required/writes: 0 を含む)を維持したまま、GH_CONFIG_DIR の相対パス解決先を invocation cwd 基準で固定する。

Runtime Verification Applicability

decision: immediate
reason: Isolated Git fixtures can exercise dedicated-runtime dispatch, identity mismatch, unavailable-runtime failure paths, GH_CONFIG_DIR path resolution, and outer/inner result-classification preservation without operating on the production primary checkout.
applicable_acs: [AC1, AC2, AC3, AC4, AC5, AC6]
execution_environment:
  cli_tools: [python3, uv, git]
  auth_required: false
  network_required: false
skip_conditions:
  - If isolated Git fixtures cannot run, record environment_blocked and do not convert the result to a pass.
fallback_policy:
  fallback_success_is_pass: false
  notes: Canonical-main execution, primary-checkout fallback, or a non-fail-closed unavailable result is a failure.
artifact_requirements:
  - Focused pytest output for command-policy, runtime-executor profile, and dedicated-execution-boundary test cases

In Scope

  • Route only contract_update.run.with_anchor and contract_update.run.with_human_context through the existing dedicated control-plane runtime already delivered by PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495: the surviving parent-controller entered via control_plane_dedicated_execution_session(), which holds the existing lifecycle lock while supervising a dedicated-worktree child process. This is not a re-exec model; no new re-exec route, command entrypoint, or lock protocol is introduced by this issue.
  • Keep the invocation root (canonical main root / default branch, where the parent starts) and the child execution root (the dedicated worktree, where mutation work actually happens) distinct; do not implement this by mechanically flipping the registry's required_cwd to the dedicated root alone.
  • Update tests/agent_ops/test_control_plane_worktree_bootstrap.py's three existing boundary assertions from "4 production preflight profiles only are dedicated" to "4 production preflight profiles + the 2 named contract_update profiles are dedicated", while preserving (never deleting or skipping) its guarantee that test-only fixture profiles (preflight.run.fixture, preflight.run.fixture.with_human_context) remain excluded.
  • Anchor GH_CONFIG_DIR resolution to the invocation cwd before the child cwd switches to the dedicated worktree, for both named profiles, so a relative GH_CONFIG_DIR value continues to resolve to the same directory it resolved to under the current canonical-main-root execution (PR fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 non-regression). No token copying, config-content reads, or env-allowlist expansion.
  • Preserve the existing mutation-result classification vocabulary across the new outer dedicated-runtime supervision layer: a post-mutation verification/readback failure at the outer (dedicated-runtime supervisor) layer must not overwrite or discard an already-achieved inner-transaction disposition (e.g. disposition: patch + final_readback: verified + fresh_review: needs_fix, or status: handoff_required + disposition: full_rewrite_required + writes: 0); an unknown/unverifiable outer result must not trigger a blind mutation resend.
  • Correct the pre-existing network_effect: "github_read_only" label on both contract_update.run.* registry entries to accurately reflect their mutation: True GitHub-writing effect, since this issue already touches these entries' required_cwd.
  • Update the registry, runtime policy/executor, and focused profile tests needed to prove the two mutation profiles use the dedicated runtime while fixture profiles and the four preflight profiles retain their separately owned behavior.
  • Record the 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 overlap as intentional; no overlapping PR may be developed in parallel on shared dedicated-runtime paths.

Out of Scope

Acceptance Criteria

  • AC1: contract_update.run.with_anchor reaches the dedicated control-plane runtime only via the existing parent-controller (control_plane_dedicated_execution_session()) after its required bootstrap and identity checks; no new re-exec route, command entrypoint, or lock protocol is added; missing, duplicate, mismatched, or non-dedicated context fails closed with no canonical-main or primary-checkout fallback.
  • AC2: contract_update.run.with_human_context has the same dedicated-runtime-only behavior while retaining its required human-context argument binding and mutation-lane restrictions.
  • AC3: Focused tests prove neither named profile weakens explicit-lane authorization, allowed write roots, trusted-context requirements, or with_anchor's legitimate no-write/issue_editor_required handoff result path; tests/agent_ops/test_control_plane_worktree_bootstrap.py's three existing boundary assertions are updated (never deleted or skipped) to reflect the new "4 production preflight + 2 contract_update -> dedicated execution" / "test-only fixture profiles -> unchanged" boundary.
  • AC4: A relative GH_CONFIG_DIR value resolves to the same configuration directory after this migration as it did under the current canonical-main-root execution; both absolute and relative GH_CONFIG_DIR inputs are covered by focused tests. No token copying, config-content reads, or environment allowlist expansion.
  • AC5: A post-mutation outer-supervision failure (timeout, readback mismatch, artifact-verification failure) does not reclassify an already-achieved inner-transaction result (mutation-succeeded-but-review-failed, or a legitimate no-write handoff) as an unmutated/failed state, and does not trigger a blind mutation resend when the outer result is unknown.
  • AC6: Result, provenance, and transaction artifacts produced by the dedicated-runtime child are written to and verifiable from the correct (dedicated) root, and remain readable by the existing downstream consumer chain without an implicit fallback to a primary-root path of the same name.

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py -q
# AC3
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -q
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q
# AC6
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q

Allowed Paths

  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/skills/issue-refinement-loop/scripts/command_registry.py
  • scripts/agent-guards/skill_runtime_command_policy.py
  • scripts/agent-guards/skill_runtime_exec.py
  • scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py
  • scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
  • .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
  • tests/agent_ops/test_control_plane_worktree_bootstrap.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • 既存の parent-controller(control_plane_dedicated_execution_session())が両 profile の fixed authorization と fail-closed semantics を維持できない、または canonical-main/primary fallback を必要とすることが判明した場合

Required Skills

なし

Required Design References

Scope Collision Record

Delivery Rule

1 Issue = 1 PR. Use a dedicated implementation worktree and a Draft PR. #2199 (PR #2495) has merged into main (2026-09-05); the prerequisite is satisfied and implementation may proceed.

Scope Delta(任意)

N/A

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Aug 29, 2026
  2. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    判定:REQUEST_CHANGES

    移行する方向は妥当です。ただし、現在の #2393 は、依存先の最終実装に追従していない契約と、移行によって壊れ得る通常利用経路の検証不足があります。 新しいセキュリティ機構を足すのではなく、既存の parent-controller を再利用し、2つのプロファイルが実際に使えることを確認する変更に絞るのが適切です。

    取得した main 3b053dfb65cd1254b690657114f58cd4fa131b75 を基準に、#2393、親 #2190、依存先 #2199 と PR #2495、後続 #2200、起票元 #2378/PR #2381、認証設定の引き継ぎを修正した PR #2407、および関連コメント・実装・テストを照合しました。#2393 自体にはコメントがなく、本文は 2026年8月29日のままです。一方、#2199 の実装 PR #2495 は 9月5日にマージ済みなので、実装開始の前提は満たされています。

    以下はコードとテスト内容を照合したレビューです。この環境で pytest を実行した結果ではないため、実測していない回帰は、その発生条件と必要な検証を分けて示します。


    1. P1:移行に必須の既存テスト修正が Allowed Paths から漏れている

    これは、実装前に直すべき確定した契約矛盾です。

    現在の tests/agent_ops/test_control_plane_worktree_bootstrap.py は、次の3点を明示的に検証しています。

    • dedicated 実行対象は、既存の4つの production preflight profile だけである。

    • 2つの contract_update profile は、その集合に含まれない。

    • 実際の skill_runtime_exec.main() を通しても、contract_update.run.with_anchor の child は primary checkout で実行される。

    つまり、#2393 を正しく実装すると、現在のテストの期待値とは衝突します。ところが、このファイルは #2393 の Allowed Paths にも Verification Commands にも含まれていません。現在の Stop Conditions に従えば、実装者は正常な移行を進めるために停止することになります。

    最小修正

    Allowed Paths に、次の1ファイルを追加してください。

    tests/agent_ops/test_control_plane_worktree_bootstrap.py

    そのうえで、テストの意味を次のように更新します。

    既存4 production preflight + 対象2 contract_update
        → dedicated execution
    

    test-only fixture profiles
    → 従来どおり

    既存テストを削除・skip する必要はありません。 「以前は意図的に除外していた2件を今回移行する」という仕様変更に対応させれば十分です。

    指定された3本のテストだけを通し、別の既存テストが要求する動作と矛盾したまま完了する、という false green を防ぐ修正です。


    2. P1:#2199 が提供する実行方式について、Issue の前提が古い

    #2393 の In Scope は、#2199 が提供する次の仕組みを利用するよう要求しています。

    dedicated runtime command class と、その re-exec/identity checks

    しかし、現行 skill_runtime_exec.py は、親プロセスを re-exec する方式ではありません。親が control_plane_dedicated_execution_session() に入り、ロックを保持したまま dedicated worktree の child を起動・監督し、終了後の検証を行う構造です。

    #2199 の関連コメントでも、初期の「initializer → re-exec でロックが切れる」問題から、生存する parent-controller にロックを保持させる方式へ変更したことが明確に整理されています。

    この差は単なる用語の問題ではありません。古い文章に忠実に実装すると、存在しない command class を探して停止するか、不要な第二の起動経路を作る可能性があります。

    最小修正

    In Scope は、例えば次の内容に置き換えるのが適切です。

    #2199 / PR #2495 が実装した parent-controller と
    control_plane_dedicated_execution_session を再利用し、
    対象2 profile を既存の dedicated dispatch selection に追加する。

    親は既存 lifecycle lock を保持したまま child を supervise する。
    新しい re-exec 経路、command entrypoint、lock protocol は追加しない。

    operator-facing command shape と既存の authorization distinction は維持し、
    invocation root と child execution root を明確に区別する。

    特に、「親をどこから起動するか」と「更新処理をどこで実行するか」を同一視しないことが重要です。現行実装には canonical-main-root/default-branch の呼び出し検証があり、その後に dedicated child へ切り替える処理があります。registry の required_cwd を機械的に dedicated root に書き換えるだけでは、この境界を壊します。

    今回の目的には、既存の dispatch 対象を2件増やし、それに伴う root 依存処理を揃える変更で足ります。


    3. P1:GH_CONFIG_DIR を文字列のまま引き継ぐと、相対パス設定が別の場所を指す

    これは、外部実装との照合で見つかった具体的な移行リスクです。

    現行 _sanitize_env() は、対象2 profile を含む有限の command ID に対して GH_CONFIG_DIR を引き継ぎます。ただし、値は環境変数からそのままコピーされ、絶対パス化されません。

    GitHub CLI 側の公式実装 cli/go-gh/pkg/config/config.go を確認すると、ConfigDir() も GH_CONFIG_DIR があればその文字列をそのまま返します。呼び出し元の cwd に対する絶対パスへの固定は行いません。

    例えば、次の設定で現在の primary 実行が動いていた場合です。

    primary cwd:
    /repo

    GH_CONFIG_DIR:
    tmp/test-gh-config

    移行前に参照する場所:
    /repo/tmp/test-gh-config

    dedicated cwd へ変更した後に参照する場所:
    /repo/.claude/worktrees/control-plane-preflight/tmp/test-gh-config

    環境変数の値が同じでも、同じ認証設定を参照しているとは限りません。 cwd だけを変更する移行では、認証設定が消えたように見えたり、意図しない別設定を参照したりします。これは値のコピーだけでは防げない、パス解決上の回帰です。

    PR #2407 は、まさに対象2 profile の GH_CONFIG_DIR を下流の実プロセスまで届ける修正を含んでいます。その成果を、今回の cwd 変更で壊さないことが必要です。

    最小修正

    既に引き継ぎ対象となっている GH_CONFIG_DIR が明示されている場合だけ、child の cwd を変える前に、元の invocation cwd を基準として絶対パスへ固定してください。

    設定ファイルの中身を読む必要も、token をコピーする必要も、環境変数の許可範囲を広げる必要もありません。

    既存の isolated-HOME/fake-gh テストに、次の2ケースを加える程度で十分です。

    入力 移行後に確認すること
    絶対パスの GH_CONFIG_DIR 同じ設定ディレクトリを参照する
    相対パスの GH_CONFIG_DIR primary で解決した同じ設定ディレクトリを参照する

    下流の edit_issue_txn.py と controlled executor は、自身の実行ファイルの場所から repository root を導出しています。したがって AC2/AC6 は、単なる cwd の確認ではなく、dedicated 側の実ファイルを実行し、その root で成果物を扱うことを確認する必要があります。

    Allowed Paths と検証コマンド

    必須の追加は、先述の bootstrap テスト1ファイルです。まず次の4本を対象にすれば、現在の3本だけよりも仕様変更を正しく検証できます。

    uv run --locked pytest \
      tests/agent_ops/test_control_plane_worktree_bootstrap.py \
      scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py \
      scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py \
      .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py \
      -q

    run_refinement_preflight.py の timeout/結果処理まで今回修正する場合に限り、そのファイルを理由付きで Allowed Paths に追加してください。最初から広い scripts/** を許可する必要も、既存不備を理由に全 transaction 基盤の再設計へ進む必要もありません。


    今回、実装を止める条件に追加しない方がよいもの

    #2200 の artifact confinement 完成や #2190 全体の最終検証を、#2393 の新たな前提条件にする必要はありません。#2393 はそれらを明示的に対象外とし、#2200 も別スコープとして存在しています。今回確認すべきなのは、移行した更新処理の成果物が、既存の次工程から読めることです。

    また、#2199 の関連コメントでは、primary の変化を別プロセスに帰属できない監視が、並列ワークフローを誤停止させる問題も指摘されています。#2393 でその監視をさらに強化するのは逆効果です。primary を変更しないことは focused integration test で確認し、通常の並列編集を理由に無条件で「更新は失敗した、最初からやり直す」と扱わない設計にすべきです。

    最終的な推奨は、「#2495 の仕組みは戻さない」「#2393 の古い契約を直す」「2 profile の接続と通常利用の回帰だけを実証する」です。 特に、漏れている既存テストの追加、re-exec 前提の削除、相対 GH_CONFIG_DIR の解決先維持、更新済み/検証失敗の区別が、今回の変更で優先する価値の高い修正です。

    ## 判定:`REQUEST_CHANGES`

    移行する方向は妥当です。ただし、現在の #2393 は、依存先の最終実装に追従していない契約と、移行によって壊れ得る通常利用経路の検証不足があります。 新しいセキュリティ機構を足すのではなく、既存の parent-controller を再利用し、2つのプロファイルが実際に使えることを確認する変更に絞るのが適切です。

    取得した main 3b053dfb65cd1254b690657114f58cd4fa131b75 を基準に、#2393、親 #2190、依存先 #2199 と PR #2495、後続 #2200、起票元 #2378/PR #2381、認証設定の引き継ぎを修正した PR #2407、および関連コメント・実装・テストを照合しました。#2393 自体にはコメントがなく、本文は 2026年8月29日のままです。一方、#2199 の実装 PR #2495 は 9月5日にマージ済みなので、実装開始の前提は満たされています。

    以下はコードとテスト内容を照合したレビューです。この環境で pytest を実行した結果ではないため、実測していない回帰は、その発生条件と必要な検証を分けて示します。


    1. P1:移行に必須の既存テスト修正が Allowed Paths から漏れている

    これは、実装前に直すべき確定した契約矛盾です。

    現在の tests/agent_ops/test_control_plane_worktree_bootstrap.py は、次の3点を明示的に検証しています。

    • dedicated 実行対象は、既存の4つの production preflight profile だけである。
    • 2つの contract_update profile は、その集合に含まれない。
    • 実際の skill_runtime_exec.main() を通しても、contract_update.run.with_anchor の child は primary checkout で実行される。

    つまり、#2393 を正しく実装すると、現在のテストの期待値とは衝突します。ところが、このファイルは #2393 の Allowed Paths にも Verification Commands にも含まれていません。現在の Stop Conditions に従えば、実装者は正常な移行を進めるために停止することになります。

    最小修正

    Allowed Paths に、次の1ファイルを追加してください。

    tests/agent_ops/test_control_plane_worktree_bootstrap.py
    

    そのうえで、テストの意味を次のように更新します。

    既存4 production preflight + 対象2 contract_update
        → dedicated execution
    
    test-only fixture profiles
        → 従来どおり
    

    既存テストを削除・skip する必要はありません。 「以前は意図的に除外していた2件を今回移行する」という仕様変更に対応させれば十分です。

    指定された3本のテストだけを通し、別の既存テストが要求する動作と矛盾したまま完了する、という false green を防ぐ修正です。


    2. P1:#2199 が提供する実行方式について、Issue の前提が古い

    #2393 の In Scope は、#2199 が提供する次の仕組みを利用するよう要求しています。

    dedicated runtime command class と、その re-exec/identity checks

    しかし、現行 skill_runtime_exec.py は、親プロセスを re-exec する方式ではありません。親が control_plane_dedicated_execution_session() に入り、ロックを保持したまま dedicated worktree の child を起動・監督し、終了後の検証を行う構造です。

    #2199 の関連コメントでも、初期の「initializer → re-exec でロックが切れる」問題から、生存する parent-controller にロックを保持させる方式へ変更したことが明確に整理されています。

    この差は単なる用語の問題ではありません。古い文章に忠実に実装すると、存在しない command class を探して停止するか、不要な第二の起動経路を作る可能性があります。

    最小修正

    In Scope は、例えば次の内容に置き換えるのが適切です。

    #2199 / PR #2495 が実装した parent-controller と
    control_plane_dedicated_execution_session を再利用し、
    対象2 profile を既存の dedicated dispatch selection に追加する。
    
    親は既存 lifecycle lock を保持したまま child を supervise する。
    新しい re-exec 経路、command entrypoint、lock protocol は追加しない。
    
    operator-facing command shape と既存の authorization distinction は維持し、
    invocation root と child execution root を明確に区別する。
    

    特に、「親をどこから起動するか」と「更新処理をどこで実行するか」を同一視しないことが重要です。現行実装には canonical-main-root/default-branch の呼び出し検証があり、その後に dedicated child へ切り替える処理があります。registry の required_cwd を機械的に dedicated root に書き換えるだけでは、この境界を壊します。

    今回の目的には、既存の dispatch 対象を2件増やし、それに伴う root 依存処理を揃える変更で足ります。


    3. P1:GH_CONFIG_DIR を文字列のまま引き継ぐと、相対パス設定が別の場所を指す

    これは、外部実装との照合で見つかった具体的な移行リスクです。

    現行 _sanitize_env() は、対象2 profile を含む有限の command ID に対して GH_CONFIG_DIR を引き継ぎます。ただし、値は環境変数からそのままコピーされ、絶対パス化されません。

    GitHub CLI 側の公式実装 cli/go-gh/pkg/config/config.go を確認すると、ConfigDir() も GH_CONFIG_DIR があればその文字列をそのまま返します。呼び出し元の cwd に対する絶対パスへの固定は行いません。

    例えば、次の設定で現在の primary 実行が動いていた場合です。

    primary cwd:
      /repo
    
    GH_CONFIG_DIR:
      tmp/test-gh-config
    
    移行前に参照する場所:
      /repo/tmp/test-gh-config
    
    dedicated cwd へ変更した後に参照する場所:
      /repo/.claude/worktrees/control-plane-preflight/tmp/test-gh-config
    

    環境変数の値が同じでも、同じ認証設定を参照しているとは限りません。 cwd だけを変更する移行では、認証設定が消えたように見えたり、意図しない別設定を参照したりします。これは値のコピーだけでは防げない、パス解決上の回帰です。

    PR #2407 は、まさに対象2 profile の GH_CONFIG_DIR を下流の実プロセスまで届ける修正を含んでいます。その成果を、今回の cwd 変更で壊さないことが必要です。

    最小修正

    既に引き継ぎ対象となっている GH_CONFIG_DIR が明示されている場合だけ、child の cwd を変える前に、元の invocation cwd を基準として絶対パスへ固定してください。

    設定ファイルの中身を読む必要も、token をコピーする必要も、環境変数の許可範囲を広げる必要もありません。

    既存の isolated-HOME/fake-gh テストに、次の2ケースを加える程度で十分です。

    入力 移行後に確認すること
    絶対パスの GH_CONFIG_DIR 同じ設定ディレクトリを参照する
    相対パスの GH_CONFIG_DIR primary で解決した同じ設定ディレクトリを参照する

    これは「セキュリティのために通常設定を拒否する」のではなく、移動前に使えていた設定を、そのまま使えるようにする修正です。


    4. P1:更新済み・検証失敗・結果不明を分ける受け入れ条件がない

    #2393 の AC は dedicated dispatch と拒否条件に偏っています。しかし mutation profile では、child の失敗が GitHub 未更新を意味しないことが重要です。

    これは仮説ではなく、既存の実プロセステストにその状態が明示されています。

    {
      "status": "failed",
      "disposition": "patch",
      "writes": 1,
      "final_readback": "verified",
      "fresh_review": "needs_fix"
    }

    このテストでは、実際の controlled executor 経由で fixture の Issue 本文が更新され、その後のレビュー失敗により exit 2 になります。再実行では writes: 0 を確認しています。つまり、「更新は済んだが、次の工程へ進めない」は既存の正しい結果の一つです。

    一方、dedicated 側を監督する外側の executor には、timeout、書き込み検証、artifact 検証などによる失敗経路があります。これらを mutation profile に適用する際、外側の失敗だけを見て「未更新だから再実行」と判断すると、既存の結果表現を壊します。

    timeout は特に確認が必要

    対象2 profile の registry timeout は現在 120秒です。一方、更新処理内部には candidate readiness の30秒、transaction の60秒、その後の readiness・preflight・review などが連続しています。すべての内部処理が自身の timeout 内でも、全体では外側の120秒を超える構成です。

    隣接する repair_action.apply には既に、更新後の readback が外側の timeout で潰されないよう、readiness + transaction + readback reserve + margin を考慮する設計があります。今回、新しい deadline 管理基盤を作る必要はなく、この既存方針に揃えるのが自然です。

    最小修正

    AC に、次の意味を追加してください。

    更新後に fresh validation または外側の実行検証が失敗しても、既存の更新結果・readback 証拠を失わず、未更新とは扱わない。結果が不明な場合は readback で確認し、失敗だけを理由に mutation を再送しない。

    検証には、既存の「更新成功 → review 失敗 → replay は追加更新なし」のテストを dedicated 上へ移すことが有効です。これなら、新しい receipt schema や永続 ledger は不要です。

    なお、120秒の予算不足は今回の移行が新しく導入する不具合ではありません。移行時に露出・悪化させないための確認項目です。別の transaction 全体を再設計する作業へ膨らませる必要はありません。


    5. P2:2つの profile に同じ「更新成功」を要求してはいけない

    registry は、汎用の with_anchor と明示的な with_human_context を区別しています。with_anchor に human-context の意味を自動的に付与する設計ではありません。

    さらに既存テストでは、汎用 with_anchor から、書き込みを行わずに次の結果へ到達するケースがあります。

    NEXT_ACTION: issue_editor_required
    contract_update.status: handoff_required
    disposition: full_rewrite_required
    writes: 0
    

    これは mutation 失敗ではなく、正当な制御の引き継ぎです。 一方、別の generic-anchor ケースでは、更新せずに拒否されることも確認されています。

    したがって、AC の成功条件を「2つとも dedicated で PATCH できる」と解釈すると、権限境界を広げてしまいます。逆に「with_anchor は常に blocked」と決めつけても、正当な issue-editor への引き継ぎを壊します。

    固定すべき意味

    経路 保持する結果
    with_human_context +適用可能な明示的指示 controlled mutation、readback、fresh checks
    generic anchor の更新権限不足 書き込みなし
    正当な full rewrite 要求 書き込みなしで issue_editor_required
    適用済み内容の replay 重複更新なし

    既存の結果分類を変えず、実行場所だけを移すことを明記するのが適切です。


    6. P2:network_effect の宣言が実際の処理と整合していない

    対象2 profile は mutation: True ですが、registry の network_effect はどちらも github_read_only になっています。実際の human-context 経路は、先述のテストでも issue_content_patch を通ります。

    この宣言が現在の実行失敗を起こしている、とまでは断定しません。ただし、registry を読む側が「この操作は GitHub を変更しない」と判断するには不正確です。

    profile の下流を含めた効果を表すのか、直接呼び出す操作だけを表すのかを揃えるべきです。 前者なら、既存の mutation 用表現に合わせて registry と policy を同時に修正してください。新しい capability system を追加する必要はありません。


    外部実装・仕様を踏まえた、維持すべき設計

    Git:worktree --lock と実行の排他制御は別物

    Git の worktree lock は、worktree の管理情報の prune や move/remove を防ぐ仕組みです。処理全体の実行排他を代替しません。また linked worktree 間では、一部の ref や repository config が共有されます。(Git)

    したがって、既存の lifecycle mutex と parent-controller をそのまま再利用する方針が適切です。今回の2 profile のために、TTL、heartbeat、lease takeover、別 daemon を追加する価値はありません。

    uv:worktree 外の専用環境は残す

    uv は、絶対パスの UV_PROJECT_ENVIRONMENT を正式にサポートしています。指定先が存在しなければ環境を作成し、通常の uv run は環境の同期も行います。したがって、--locked を付けたことだけでは「依存関係の準備もファイル生成も起きない」とは言えません。([Astral Docs]2)

    PR #2495 の専用環境準備を再利用し、primary の .venv が準備済みだから dedicated でも動くはず、というテストにしないことが重要です。現行 executor には、dedicated checkout 外の環境を指定して準備する処理があります。

    同期の重複を減らす最適化は、遅延を測ってからで十分です。新しい environment manager やキャッシュ台帳は不要です。

    GitHub CLI:認証情報ではなく、同じ設定への参照を保つ

    GitHub CLI の設定ディレクトリ選択は、公式実装でも GH_CONFIG_DIR を優先しています。今回必要なのは、その参照先を cwd 変更の前後で保つことです。

    PR #2407 が実施した、isolated HOME、テスト所有の設定ディレクトリ、fake-gh による実プロセス検証を流用するのが適切です。実 token の読み出し、設定ファイルの内容保存、live GitHub mutation を必須にする理由はありません。


    #2393 に入れる修正案

    Outcome

    現在の Outcome を、次の内容へ具体化することを推奨します。

    PR #2495 の parent-controller/dedicated execution session を再利用し、対象2 contract-update profile の実処理と下流の transaction を、検証済み dedicated worktree で実行する。既存の authorization、結果分類、認証設定の参照先、artifact handoff、再実行時の重複更新防止を維持し、primary 実行への fallback は追加しない。

    Acceptance Criteria

    大量の新規テストを要求するのではなく、次の6項目を既存テストへ割り当てる形がよいです。

    AC 必要な確認
    AC1:実行場所 対象2 profile の child が既存 dedicated session を経由する。既存4 preflight と fixture profile の境界は維持する。
    AC2:実処理の接続 human-context の production chain が dedicated 上で transaction・readback・fresh checks まで到達する。cwd の観測だけで代替しない。
    AC3:結果分類 generic anchor の非更新、full-rewrite handoff、更新済みだが検証失敗、replay 時の追加更新なしを維持する。
    AC4:環境の互換性 絶対・相対 GH_CONFIG_DIR が同じ設定先を指し、専用 Python 環境の初回準備でも通常利用を壊さない。
    AC5:失敗時 identity 不成立では child/mutation を開始しない。更新後の失敗は未更新に変換せず、結果不明時に mutation を盲目的に再送しない。
    AC6:成果物 result・provenance・transaction artifact を正しい root で生成・検証し、次の consumer が読める。primary 側の同名ファイルへの暗黙 fallback はしない。

    下流の edit_issue_txn.py と controlled executor は、自身の実行ファイルの場所から repository root を導出しています。したがって AC2/AC6 は、単なる cwd の確認ではなく、dedicated 側の実ファイルを実行し、その root で成果物を扱うことを確認する必要があります。

    Allowed Paths と検証コマンド

    必須の追加は、先述の bootstrap テスト1ファイルです。まず次の4本を対象にすれば、現在の3本だけよりも仕様変更を正しく検証できます。

    uv run --locked pytest \
      tests/agent_ops/test_control_plane_worktree_bootstrap.py \
      scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py \
      scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py \
      .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py \
      -q

    run_refinement_preflight.py の timeout/結果処理まで今回修正する場合に限り、そのファイルを理由付きで Allowed Paths に追加してください。最初から広い scripts/** を許可する必要も、既存不備を理由に全 transaction 基盤の再設計へ進む必要もありません。


    今回、実装を止める条件に追加しない方がよいもの

    #2200 の artifact confinement 完成や #2190 全体の最終検証を、#2393 の新たな前提条件にする必要はありません。#2393 はそれらを明示的に対象外とし、#2200 も別スコープとして存在しています。今回確認すべきなのは、移行した更新処理の成果物が、既存の次工程から読めることです。

    また、#2199 の関連コメントでは、primary の変化を別プロセスに帰属できない監視が、並列ワークフローを誤停止させる問題も指摘されています。#2393 でその監視をさらに強化するのは逆効果です。primary を変更しないことは focused integration test で確認し、通常の並列編集を理由に無条件で「更新は失敗した、最初からやり直す」と扱わない設計にすべきです。

    最終的な推奨は、「#2495 の仕組みは戻さない」「#2393 の古い契約を直す」「2 profile の接続と通常利用の回帰だけを実証する」です。 特に、漏れている既存テストの追加、re-exec 前提の削除、相対 GH_CONFIG_DIR の解決先維持、更新済み/検証失敗の区別が、今回の変更で優先する価値の高い修正です。

  3. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    推奨アクション

    #2393 は、実装へ進む前に 指定コメントを operator-selected human context として issue-refinement-loop に投入し、Issue 本文を自動 refinement するのが適切です。コメントは Issue #2393 所属かつ author_association: OWNER です。

    特に反映すべきなのは次の5点です。

    1. 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 のブロック解除を本文へ反映する。 PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 は既にマージ済みで、そこで control_plane_dedicated_execution_session() を使う parent-controller 型の dedicated dispatch が実装されています。実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 の「実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 が提供する re-exec / command class」という古い前提は更新対象です。
    2. tests/agent_ops/test_control_plane_worktree_bootstrap.py を Allowed Paths と Verification Commands に追加する。 現 main のテストは4 production preflight profile のみを dedicated 対象としており、実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 を実装すると既存期待値と衝突します。
    3. GH_CONFIG_DIR の相対パス意味保存を契約化する。 PR fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 は対象 contract_update profile への GH_CONFIG_DIR 伝播を既に実装しているので、dedicated cwd 化によってその解決先を変えない AC/テストが必要です。
    4. 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 や 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 全体へスコープを広げない。 指定レビューの修正範囲に閉じ、既存 parent-controller を再利用する。
    5. Issue 本文 mutation 後に fresh preflight → review を再実行し、approve/proceed まで自動反復する。 issue-refinement-loop は iteration approval を既定で不要としており、semantic finding を issue-editor へ渡して AC/VC/Allowed Paths/Stop Conditions まで semantic rewrite できる設計になっています。

    このケースでは、人間承認を追加するより 既存 workflow をそのまま使わせる方がよいです。semantic review は sibling SubAgent の完了を待つ completion join barrier が既に契約化されています。 また現在の Claude Code は background SubAgent が既定ですが、結果が必要なら foreground 実行にでき、background の場合でも completion notification を待ってから結果を扱う契約です。([Claude Platform Docs]1)

    Auto mode についても、--dangerously-skip-permissions 等へ切り替える必要はありません。Auto mode は通常の permission prompt を減らすための正式な mode で、Auto mode 中の SubAgent は親と同じ classifier rules を継承します。([Claude]2)

    以下を、そのまま auto mode の対話的 Claude Code に渡すのを推奨します。

    リポジトリ squne121/loop-protocol の Issue #2393 を、repository-owned の issue-refinement-loop を使って refinement してください。

    対象:

    この anchor comment は、今回の operator-selected human context として明示的に指定します。
    preflight.run.with_human_context / contract_update.run.with_human_context の canonical lane を使用してください。
    unlabeled with_anchor や with_agent_report lane に勝手に変更しないでください。

    目的は Issue #2393 の refinement です。
    実装コードの開発を開始することではありません。
    Issue 本文を current main と指定コメントに整合させ、fresh review で implementation-ready になるところまで進めてください。

    この依頼は、Issue #2393 の本文を issue-refinement-loop の controlled mutation path で更新することを明示的に許可しています。
    ループ iteration ごとの人間確認や、「この修正を適用してよいですか」という確認は不要です。
    repository の loop_iteration_approval_gate.default_required: false に従って自動継続してください。
    max_iterations は既定の 3 を使用してください。

    Claude Code の現在の auto mode はそのまま使用してください。
    permission mode を変更しないでください。
    bypassPermissions、--dangerously-skip-permissions、--allow-dangerously-skip-permissions 等へ切り替えないでください。

    まず Issue 本文、anchor comment、current main、関連 Issue / PR / repository assets を読み、コメントの各 finding を current state に対して fact-check してください。

    最低限、以下を確認してください。

    SubAgent を使用してください。

    repo/code fact-check は codebase-investigator など repository-defined の適切な read-only SubAgent に委譲してください。
    外部実装の確認が disposition に必要なら、workflow が定める web-researcher を使用してください。
    semantic review applicability が成立する場合は repository contract に従って issue-design-reviewer を sibling SubAgent として起動してください。
    rewrite が必要なら repository contract に従って issue-editor を使用してください。

    重要:
    SubAgent を起動したら、その SubAgent の作業完了と結果取得を必ず待ってください。
    結果を必要とするフェーズでは foreground 実行を優先してください。
    Claude Code が background で起動した場合も、completion notification / final result を取得する前に次の dependent phase へ進んではいけません。
    SubAgent の未完了状態を成功扱いしないでください。
    複数の独立した read-only investigation は並列化して構いませんが、全 required result を join してから判定してください。
    issue-editor 自身に nested SubAgent delegation を要求しないでください。必要な chain は main thread から sequential に orchestration してください。

    anchor comment のレビュー指摘は、単なる参考情報ではなく fact-check 対象の refinement input として扱ってください。
    ただしコメントを盲目的に転記せず、current main で確認できた事実を source of truth にしてください。

    少なくとも以下の semantic delta を検証し、事実なら Issue 本文へ反映してください。

    1. 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 / PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 は既に完了しているため、
      「実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 は 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 が merge されるまで開始不可」という stale dependency 表現を現在状態へ更新する。

    2. 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 に残っている
      「dedicated runtime command class / re-exec」
      という前提を current implementation に合わせる。

      current implementation が PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 の
      control_plane_dedicated_execution_session() を使う surviving parent-controller 方式なら、
      In Scope / AC / Stop Conditions 等をその方式へ更新する。

      新しい re-exec route、command entrypoint、lock protocol を 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 で新設する要求にしない。

      invocation root と child execution root を混同しない。
      registry の required_cwd を機械的に dedicated root へ変えるだけ、という仕様にもしてはいけない。

    3. tests/agent_ops/test_control_plane_worktree_bootstrap.py が
      現在の「4 production preflight dedicated / contract_update 非dedicated」
      契約を明示的に検証していることを確認する。

      実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 の実装によりその期待値変更が必須なら、このファイルを
      Allowed Paths
      および relevant Verification Commands
      に追加する。

      既存テストを delete / skip する方向にはしない。
      期待値を
      「既存4 production preflight + 対象2 contract_update → dedicated execution」
      「test-only fixture profiles → 従来どおり」
      へ更新する仕様にする。

    4. GH_CONFIG_DIR の current behavior を確認する。

      PR fix: preserve GH_CONFIG_DIR for bare preflight.run #2407 により
      contract_update.run.with_anchor
      contract_update.run.with_human_context
      が GH_CONFIG_DIR carrier になっており、
      dedicated child cwd への migration で relative GH_CONFIG_DIR の解決先が変わるなら、
      invocation cwd を基準に同一 config directory を維持することを Issue contract に追加する。

      token のコピー、config 内容の読み出し、global env allowlist の拡大は要求しない。

      absolute GH_CONFIG_DIR
      relative GH_CONFIG_DIR
      の両ケースを focused test で検証する契約にする。

    5. runtime verification は cwd 文字列だけを確認する弱いものにしない。
      dedicated worktree 側の実ファイルが実際に実行され、その repository root で必要な artifact / downstream result が扱われることを focused integration test で証明する。

    6. 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 の artifact confinement 完成や 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 全体の最終 verification を、
      実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 の新しい blocker にしてはいけない。
      今回の migration に直接必要な範囲へ閉じる。

    7. primary checkout の変更検知を新しい広範な監視機構へ拡張しない。
      実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 で必要な invariant は focused integration tests で証明し、
      unrelated parallel workflow の変更を誤帰属する仕組みを追加要求しない。

    8. anchor review が指摘する
      「mutation 自体は完了したが post-update verification が失敗した」
      ケースと
      「mutation 自体が失敗した」
      ケースの区別が current contracts で必要かを確認する。
      実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 の目的達成に直接必要で、既存 contract で表現できるなら反映する。
      unrelated transaction framework redesign へ拡大しない。

    推奨 verification command の baseline は、current main を確認した上で少なくとも次を評価してください。

    uv run --locked pytest
    tests/agent_ops/test_control_plane_worktree_bootstrap.py
    scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py
    scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py
    .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py
    -q

    ただし、Issue refinement 中に implementation test を「PASS した」と偽装してはいけません。
    ここでの目的は Verification Commands / AC / Allowed Paths を正しく契約化することです。
    実際に安全に実行可能な mutation-free/static checks があれば実行して構いません。

    Issue 本文 rewrite は ad-hoc gh issue edit で行わず、
    issue-refinement-loop → repository-defined controlled issue-editor / edit-issue transaction route を使用してください。

    semantic finding がある場合、
    recommended_fix を文字列置換としてコピーするのではなく、
    evidence を根拠に AC、Verification Commands、Allowed Paths、In Scope、Out of Scope、Stop Conditions、dependency 状態を意味論的に整合させてください。

    指定コメントには HTML 表現と Markdown 表現が重複して含まれている可能性があります。
    同じ finding を二重の独立 requirement として数えず、snapshot provenance は維持したまま semantic に deduplicate してください。

    rewrite 後は必ず current Issue body を read back してください。
    その fresh body に対して canonical preflight と review を再実行してください。
    review が needs-fix/request_changes なら、max_iterations の範囲内で人間確認なしに rewrite loop を継続してください。

    deterministic checker が approve しても semantic review applicability が成立するなら semantic review を省略しないでください。
    semantic SubAgent の completion join barrier を満たしてから結果を join してください。

    終了条件:

    • fresh review が approve/proceed 相当
    • required readiness が implementation entry を許可
    • Issue body readback が今回の mutation と一致
    • blocker/high semantic findings が未解消で残っていない

    この条件を満たしたら refinement を終了してください。
    このプロンプトでは implementation PR の作成・実装開始までは行わないでください。

    真に human_judgment_required となるのは、
    既存 workflow contract が定める非自動化境界
    (例: destructive/non-idempotent scope change、permission boundary change、external service boundary change、Issue split が必要、解消不能な owner decision conflict)
    に到達した場合だけにしてください。

    単に

    • Allowed Paths に必要な既存テストが1ファイル漏れている
    • stale dependency を更新する必要がある
    • current implementation に合わせて re-exec 文言を書き換える必要がある
    • semantic AC/VC を修正する必要がある
      という理由だけで人間へ戻さないでください。

    最後に簡潔に報告してください:

    • refinement final status
    • Issue body を変更したか
    • 解消した findings
    • remaining warnings/blockers
    • 実行した SubAgent と、それぞれ完了結果を join 済みであること
    • fresh review/readiness の結果
    • implementation を開始していないこと

    このプロンプトなら、今回の REQUEST_CHANGES を単純な文字列パッチではなく、fact-check → semantic review → controlled Issue rewrite → fresh review の既存経路へ乗せつつ、途中の確認待ちをかなり抑えられます。

  4. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 完了報告(#2393)

    operator-selected human context(anchor: #2393 (comment) , author_association: OWNER)を preflight.run.with_human_context lane で fact-check し、以下の semantic delta を確認のうえ本文を更新しました。

    解消した findings

    1. stale dependency: 実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 (PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495) は 2026-09-05 に merge 済み。Delivery Rule / Scope Collision Record から「実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199 merge待ち」の記述を除去し、進行可能である旨へ更新。
    2. re-exec 前提の陳腐化: current main の実装は re-exec 方式ではなく、scripts/agent-ops/worktree_bootstrap_exec.py:617 の control_plane_dedicated_execution_session() を用いる surviving parent-controller 方式(scripts/agent-guards/skill_runtime_exec.py:2530 から呼び出し)。In Scope をこの実装に整合させ、新規 re-exec route / entrypoint / lock protocol を追加しない旨、invocation root と child execution root を混同しない旨を明記。
    3. Allowed Paths 漏れ: tests/agent_ops/test_control_plane_worktree_bootstrap.py(現状「4 production preflight のみ dedicated」「contract_update は非dedicated」を assert する既存3テスト、459/468/508行目)を Allowed Paths と AC3 / VC に追加。既存テストの削除・skip ではなく期待値更新として契約化。
    4. GH_CONFIG_DIR 相対パス回帰リスク: _sanitize_env()(skill_runtime_exec.py:1017-1027)が絶対パス化せず引き継ぐ現状を確認し、AC4 として invocation cwd 基準の固定要件・absolute/relative 両ケースの test 要件を追加。
    5. mutation成功/検証失敗の区別欠如: 既存の disposition: patch/final_readback/fresh_review、status: handoff_required/writes: 0 語彙を確認し、AC5 として outer supervision failure が inner disposition を上書きしない・unknown時に盲目的resendしない要件を追加。
    6. (non-blocking) network_effect ラベル不整合: 両 contract_update.run.* エントリの mutation: True と矛盾する network_effect: "github_read_only" を drive-by 訂正対象として In Scope に明記。

    AC は3件から6件に拡張し、Verification Commands・Allowed Paths も対応して更新済みです。

    実行した SubAgent(すべて完了・結果 join 済み)

    • codebase-investigator(fact-check、一部の結論はcontrol-planeが独立grep/readで再検証・訂正して採用)
    • issue-design-reviewer(1周目: REQUEST_CHANGES、4件blocking + 2件non-blocking)
    • issue-editor(controlled mutation transaction、body_sha256 事前一致確認 → 更新 → readback確認済み)
    • issue-design-reviewer(2周目 fresh review: APPROVE、live body sha256照合済み、findings: [])

    fresh review / readiness

    • 更新後 body_sha256: sha256:62669c51c1a79d8d1722afbf539f6d13d6eedec19fb41675606f5063e1601a83
    • deterministic checker(run_root_review_pipeline.py produce): verdict: approve / canonical_step2_route: step_2_5
    • semantic design review(2周目): APPROVE、findings なし

    remaining warnings

    • non-blocking checker warning: scope_cvs_in_scope_mismatch(Current Validated Scope と In Scope のトークンjaccardが低い旨の定型警告、severity: warning)。blocking ではないため対応不要と判断。

    実装について

    本ループの依頼スコープは Issue #2393 の refinement までであり、implementation PR の作成・実装着手は行っていません。

  5. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    結論として、#2393 は そのまま impl-review-loop に投入してよい状態です。Issue 本文は既に PR #2495 の parent-controller 実装に合わせて更新され、AC1–AC6、Allowed Paths、Verification Commands、Stop Conditions まで具体化されています。 一方、現行 main の skill_runtime_exec.py はまだ contract_update.run.with_anchor / .with_human_context を dedicated execution 対象から意図的に除外しており、実装作業自体は残っています。 Registry の network_effect: "github_read_only" も残っているため、#2393 の修正対象と一致します。

    推奨する運用は、直接 implementation-worker を起動せず、root から impl-review-loop の正規 entry を通すことです。現行 skill は Step 1 を implementation-worker、Step 2 を test runner、Step 4 を pr-reviewer に分離し、PR 作成まで worker に実行させる設計です。 また、SubAgent 完了判定も既にかなり厳密で、wait_agent だけでは完了扱いせず、final result の取得と list_agents 上の terminal completed の双方を要求しています。 これは今回の「SubAgent の作業完了を待つ」という要求にそのまま使えます。

    Claude Code 側では auto permission mode を使うのが適切です。Auto mode は tool call を background safety check で自動承認しますが、明示的な ask rule 等は prompt だけでは解除できません。([Claude]1) また現在の Claude Code は SubAgent が background 起動になる場合があるため、依存関係のある実装→検証→レビューでは foreground を指定するか、repo の Common Completion Protocol で terminal completion まで待たせるのが重要です。([Claude]2)

    セッションがまだ Auto でなければ claude --permission-mode auto で起動し、以下をそのまま投入するのを推奨します。

    Issue #2393 を、repository-defined impl-review-loop を使って実装・検証・PR review まで自律的に完遂してください。

    目的は 人間の途中承認なしで merge 直前の repository-defined ready state まで到達することです。
    実装だけして停止せず、REQUEST_CHANGES の修正、再検証、CI、fresh current-head review までループしてください。

    ただし merge 自体は絶対に実行しないでください。
    gh pr merge、auto-merge 有効化、merge button 相当操作は行わず、最終的な merge 判断だけを人間に残してください。

    Execution mode

    • 現在の live GitHub Issue 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 と current repository state を source of truth とする。
    • 古いコメント、過去の review head、過去の test result を current evidence として再利用しない。
    • repository の .claude/skills/impl-review-loop/SKILL.md とその steps/ を読み、独自の簡易ループを作らず canonical workflow を実行する。
    • max_iterations は 6 とする。ループ可能な問題を途中で人間へ返さない。
    • routine な edit、test、commit、push、Draft PR 作成・更新、PR/Issue コメント、CI 待機、review feedback 修正、branch update について私の承認を求めない。
    • 選択肢が複数あっても、Issue contract と既存設計から最小かつ scope-preserving な実装を判断して続行する。
    • AskUserQuestion は通常の設計判断・修正判断・retry 判断には使用しない。

    Root entry

    Step 1 の implementation-worker を直接 shortcut 起動しないでください。

    impl-review-loop が定義する Root-Owned Synchronous Entry Transition に従い、

    1. capability preflight
    2. live Issue fetch
    3. current-run issue-contract-review
    4. 直後の live Issue 再取得
    5. root routing decision
    6. route が implementation invocation を許可した場合のみ Step 1

    を同じ継続した control flow で行ってください。

    artifact/snapshot/ledger の欠落や stale だけを理由に停止しないでください。
    停止 authority は live Issue contract、actual worktree state、Allowed Paths、実テスト、CI、current-head review 等の repository-defined authoritative boundary に限定してください。

    Mandatory SubAgent orchestration

    canonical workflow の担当を root が肩代わりせず、少なくとも以下の SubAgent を使ってください。

    • Step 1: implementation-worker
    • Step 2: repository-defined verification / test-runner
    • Step 4: pr-reviewer

    依存する Step の SubAgent は、結果が必要なので foreground execution を優先してください。

    runtime の都合で background task になった場合を含め、SubAgent を起動しただけで次の Step に進んではいけません。

    各 canonical task について必ず Common Completion Protocol を満たしてください。

    • spawn 時に返された canonical task name を保存する。
    • wait_agent の timeout、mailbox update、途中経過、steer response は完了とみなさない。
    • SubAgent の final result を実際に取得・消費する。
    • その後 list_agents 等の canonical lifecycle observation で、同じ task name が terminal completed であることを確認する。
    • final result と terminal completed の 両方を確認して初めて次の routing を決める。
    • errored / interrupted / shutdown / not_found を completed とみなさない。
    • discovery failure について repository-defined Stage A/B/C recovery が存在する場合は、それを先に自動実行する。
    • child SubAgent からさらに nested SubAgent を spawn させない。実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 の Stop Conditions を守る。

    つまり、implementation-worker がまだ作業中なのに test-runner を走らせたり、test-runner が未完了なのに pr-reviewer を起動したりしないでください。

    #2393 implementation anchors

    live Issue 本文を最終 SSOT としつつ、今回の implementation recommendation は以下です。

    対象は厳密に次の2 profile です。

    • contract_update.run.with_anchor
    • contract_update.run.with_human_context

    PR #2495 / Issue #2199 が実装済みの既存 parent-controller と
    control_plane_dedicated_execution_session() を再利用してください。

    新しい re-exec route、command entrypoint、lifecycle lock protocol、generic runtime abstraction は追加しないでください。

    重要な境界は、

    • invocation root = canonical main root / default branch
    • actual mutation child execution root = dedicated control-plane worktree

    です。

    単純に registry の required_cwd を dedicated root に変更するだけの実装にしないでください。

    既存 parent-controller が lifecycle lock を保持した状態で dedicated child を supervise する既存方式へ、この2 profile を接続してください。

    GH_CONFIG_DIR

    relative GH_CONFIG_DIR が dedicated child cwd の変更によって別パスを指さないようにしてください。

    child cwd を切り替える前に、明示された relative GH_CONFIG_DIR は 元の invocation cwd 基準で同一 configuration directory を指すよう固定してください。

    absolute path は同一値・同一対象を維持してください。

    token copy、GitHub config contents の読み出し、新しい env allowlist 拡張は不要です。

    Result preservation

    outer dedicated-runtime supervision が失敗した場合でも、inner mutation transaction で既に確定した意味論を破壊しないでください。

    特に、

    • mutation succeeded + later review failed
    • legitimate no-write / issue_editor_required handoff
    • disposition: patch
    • final_readback
    • fresh_review
    • status: handoff_required
    • disposition: full_rewrite_required
    • writes: 0

    等の既存 classification を outer failure で「mutation 未実行」に潰さないでください。

    outer result が unknown / unverifiable の場合、blind mutation resend を行わないでください。

    Registry / tests

    対象2 profile の pre-existing
    network_effect: "github_read_only"
    は mutation 実態と一致する値へ修正してください。

    tests/agent_ops/test_control_plane_worktree_bootstrap.py の既存 boundary assertions は削除・skip せず、

    • 既存4 production preflight
    • 今回の2 contract_update

    の計6 profileが dedicated execution、

    • preflight.run.fixture
    • preflight.run.fixture.with_human_context

    は従来どおり excluded、

    という境界へ更新してください。

    fixture migration や broader runtime redesign は行わないでください。

    Scope discipline

    Issue #2393 の live Allowed Paths を厳守してください。

    現在の Issue contract が許可している対象以外へ変更を広げないでください。

    「ついでのリファクタリング」はしないでください。

    ただし Allowed Paths 内で、AC を満たすために必要な production code / test の変更は approval を求めず実行してください。

    既存 test を pass させるために assertion を弱める、skip する、削除する、実装を test 固有に hard-code することは禁止です。

    #2190 / #2200 全体の artifact confinement 完成を #2393 の新しい blocker にしないでください。

    Verification

    Issue #2393 に記載された AC1–AC6 の Verification Commands を current candidate head で実行してください。

    特に少なくとも以下の focused suites を実測してください。

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q

    uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py -q

    uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py .claude/skills/issue-refinement-loop/tests/test_preflight_run_with_anchor.py -q

    失敗した場合は結果を報告して停止するのではなく、原因を解析し、Issue scope 内で修正可能なら implementation-worker に fix_delta として戻して再実装してください。

    candidate head が変わるたびに stale test/review evidence を current-head evidence として使わないでください。

    PR and CI loop

    Step 1 で repository-defined implement-issue / open-pr route を使い、1 Issue = 1 PR を守ってください。

    PR 作成、commit、push について人間承認を求めないでください。

    PR が存在したら current head に対して required CI を待ってください。

    CI failure が implementation に起因し、Allowed Paths 内で修正可能なら、自動で修正 → commit → push → current-head verification を繰り返してください。

    BEHIND は repository-defined route_to_update_branch で自動処理してください。

    reviewed head が stale なら route_stale_head_rereview で fresh review を行ってください。

    mergeability UNKNOWN は repository-defined bounded retry を使って再取得してください。

    BLOCKED / UNSTABLE / DRAFT を、それだけで人間 escalation の理由にしないでください。current-head CI / branch protection / workflow routing を再評価してください。

    PR review loop

    Verification gate を通った current head だけを pr-reviewer に渡してください。

    pr-reviewer が REQUEST_CHANGES を返した場合、

    1. blockers を canonical fix_delta に変換
    2. implementation-worker に再委譲
    3. worker の terminal completion を待つ
    4. current head を再検証
    5. required CI を再確認
    6. fresh current-head pr-reviewer を再実行

    まで自動で継続してください。

    過去 head の APPROVE は使用禁止です。

    Step 1–4 の child が単に human_review_required: true と自己申告しただけでは停止せず、repository-defined root routing に従ってください。

    canonical HUMAN_REVIEW_REQUIRED route が生じた場合も、まず定義済みの automatic recovery をすべて尽くしてください。

    Hard-stop policy

    途中で私に「続けますか?」とは聞かないでください。

    本当に自動継続不能な場合だけ停止してください。

    例:

    • actual Git conflict / DIRTY mergeability で repository-defined automatic resolution route が成立しない
    • AC を満たすために live Allowed Paths 外の変更が不可避
    • Issue が禁止している fixed contract / schema / type の変更が不可避
    • 新規 Issue / scope split が不可避
    • nested SubAgent delegation が不可避
    • 必須外部権限・service がなく、repository-defined fallback/recovery もない
    • canonical SubAgent が recovery 後も実行不能
    • 6 iteration を使い切っても current-head blockers が解消不能

    この場合も approval question を出すのではなく、何が blocker で、どの evidence に基づき、どこまで完了したかを明示して停止してください。

    Definition of done

    以下をすべて current head で満たすまで作業を続けてください。

    • 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 の implementation が完了
    • Allowed Paths compliance
    • AC1–AC6 の Verification Commands PASS
    • required repository quality gates PASS
    • required CI PASS
    • current PR head に対する fresh pr-reviewer verdict = APPROVE
    • blockers: []
    • reviewed_head_sha == live PR head SHA
    • live mergeability が repository-defined approved condition
    • unresolved actionable review feedback がない
    • impl-review-loop の canonical approved termination conditionを満たす
    • IMPL_REVIEW_LOOP_RESULT_V1.status: draft_pr_ready 相当まで到達

    ここまで到達したら merge はせず停止してください。

    最終報告では簡潔に以下を出してください。

    • Issue URL
    • PR URL
    • final head SHA
    • changed files
    • AC1–AC6 verification results
    • required CI status
    • final pr-reviewer verdict / reviewed_head_sha
    • live mergeability
    • remaining warnings(ある場合のみ)
    • merge-ready: yes/no
    • merge は未実行であること

    説明だけで終わらず、実際に impl-review-loop を開始してください。

    この形なら、「auto mode だから何でも勝手にやれ」ではなく、既存の loop protocol が持っている recovery / current-head gate / SubAgent lifecycle を最大限使いながら、承認待ちだけを除去する指示になります。特に最後の「説明せず実行開始」と「final result + terminal completed の両方を待つ」は入れておいた方がよいです。

  6. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  7. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-06T02:32:07Z)

    • PR: feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520
    • Worktree: .claude/worktrees/issue-2393-contract-update-dedicated-runtime
    • Branch: worktree-issue-2393-contract-update-dedicated-runtime
    • Verification: 3/3 Issue VC PASS(test_skill_runtime_exec_anchor.py 13 passed / test_skill_runtime_command_policy_anchor.py 39 passed / test_control_plane_worktree_bootstrap.py+test_preflight_run_with_anchor.py 82 passed)、標準4ゲート(typecheck/lint/test/build)PASS
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  8. self-assigned this
    on Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions