Skip to content

実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#2190"
goal_ref: "#2190 AC6/AC11/AC12: artifact confinementを実装し、Child1-4の統合結果に対して#2190の全AC(AC1-AC12)を最終検証して親issueをクローズする"
change_kind: code

Parent Issue

#2190

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

Outcome

PR #2495 の既存 parent-controller(control_plane_dedicated_execution_session())と既存 producer/consumer path contract(stdout compact projection、refinement_preflight_result/v1)、および PR #2520/#2533 の contract_update inner-transaction-result-preservation契約を維持したまま、本番 preflight 経路(scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions())に artifact confinement 検証・bounded cleanup・結果公開順序の保証を実装/明文化する。

本Issueが実装する artifact lifetime semantics は generation invalidation 契約として定義する: accepted OID refresh や dedicated worktree recreation は artifact の generation boundary であり、旧 generation の artifact は consumer が未読であっても消えてよい(永続保全は要求しない)。ただし旧 generation の handoff から GitHub mutation を続行してはならない。stale / missing / provenance-invalid な artifact を検出した consumer(repair_action.apply 等)は mutation retry ではなく fresh preflight へ既存 transport を維持したまま deterministic に戻る。stale artifact を暗黙 reuse しない、primary checkout や同名 path へ fallback しない。永続的な artifact lifecycle manager(新しい lease DB、heartbeat、常駐 cleanup daemon 等)は追加しない。

Git の dirty/unknown-owner worktree 判定(git status --porcelain --untracked-files=all を使用し、--ignored は使わない)と、上記の artifact generation/lifetime 判定は別の判定軸であり、混同しない。前者は worktree の force-remove可否判定、後者は結果JSON等のartifactの新旧・利用可否判定である。

必須の artifact 検証・cleanup 判定が完了する前に、利用可能に見える STATUS/NEXT_ACTION/ARTIFACT を公開しない。ただし child の non-zero exit code を一律 failure と扱わず、既存 preflight protocol の warn/needs_fix 等の正当な control result と、confinement/cleanup/postcondition failure を分離する。

本Issueの PR で #2190 の残る critical regressions と本Issueの local AC を green にする。#2190 の全AC(AC1-AC12)最終検証結果の記録と親issueクローズは、本Issue PRのmerge後の delivery step として扱う(詳細は ## Acceptance Criteria AC7 および ## Delivery Rule を参照)。

Runtime Verification Applicability

decision: immediate
reason: "isolated tmp git repo fixtureに対しartifact confinementのdirty/unknown-owner worktree拒否・size/count上限・reason code固定・publish/cleanup順序・generation invalidation挙動を実証し、既存legacy regression test(PR #2520/#2533のinner-transaction-result-preservation契約を含む)の回帰有無を確認する。production primary checkoutを操作しない。"
applicable_acs:
  - AC1
  - AC2
  - AC3
  - AC4
  - AC5
  - AC6
  - AC7
execution_environment:
  cli_tools:
    - python3
    - uv
    - git
  auth_required: false
  network_required: false
skip_conditions:
  - "isolated tmp git repo fixture が構築できない場合は SKIP ではなく environment blocked として扱う"
fallback_policy:
  fallback_success_is_pass: false
  notes: "fallback経由の成功をPASSに変換しない"
artifact_requirements:
  - "pytest output"
  - "artifact confinement validation trace(no-follow / regular-file判定 / size・count上限判定の記録)"
  - "publish順序を示すsequence log(検証完了 → 公開 → cleanup の順序が確認できるもの)"

Local AC ↔ Parent (#2190) AC Crosswalk

machine consumer が本Issueのローカル AC 番号(applicable_acs に列挙)と親 #2190 の AC 番号を混同しないよう、対応表を分離する。

本Issue(#2200)ローカル AC 対応する #2190 の AC
AC1 AC6, AC11
AC2 AC6, AC11
AC3 AC6, AC11
AC4 AC6, AC11
AC5 AC7, AC11
AC6 AC7, AC11
AC7 親issueで定義された全ての Acceptance Criteria(本IssueのPRではlocal AC1-6 + 既存回帰の green化を実証し、#2190 最終検証結果の記録とクローズは ## Delivery Rule の delivery step で扱う)

In Scope

  • dedicated artifact cleanupのbounded処理実装
  • dirty/unknown-owner worktreeへの git worktree remove --force 禁止と、そのような場合の停止ロジック(git status --porcelain --untracked-files=all を使用し、--ignored は使わない。このGit cleanliness判定はAC3のartifact generation invalidation判定とは別軸であり混同しない)
  • cleanup_failed/artifact_escape/artifact_oversized/stale_artifact reason codeの固定
  • artifact handoff(refinement_preflight_result/v1 結果ファイルの re-serialize/re-encode なしの再利用、component-wise no-follow・regular-file限定・owner Issue一致・size/count上限検証)
  • artifact lifetime を以下の3カテゴリに分けて実装する(generation invalidation 契約。永続保全は要求しない):
    1. 未公開 temporary files / failed-run leftovers — 検証した範囲だけ bounded cleanup 対象とする
    2. 公開済みの result/artifact — accepted OID refresh / dedicated worktree recreation という generation boundary を跨いだ時点で、downstream consumer(repair_action.apply 等)が未読であっても cleanup / worktree refresh により消えてよい(永続保全は要求しない)。ただし旧 generation の handoff から GitHub mutation を続行してはならない
    3. 次回 run・accepted OID drift・worktree refresh で stale になった artifact — missing path や旧 artifact の暗黙 reuse として処理せず、provenance/freshness(mtime単独に依存しない)が成立しない場合は既存 transport を維持したまま fresh preflight へ deterministic に戻す(この fresh-preflight への実際の routing 実装は本Issueの Out of Scope。## Out of Scope 参照)
  • publish/cleanup/release ordering の明文化・実装: scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions() が既に維持している「検証 → 公開」の順序(artifact projection 検証失敗時は stdout 未公開のまま終了)を、cleanup 処理追加後も壊さないことを実装・テストで保証する。child の non-zero exit code(warn/needs_fix 等)は正当な control result として扱い、confinement/cleanup失敗と分離する
  • confinement の検証対象フィールドと bounds を固定する(下記 AC4 参照): target Issue root・issue_number/repo所有一致・consumerが実際に読む既知の参照先(repair_action.candidate_body_artifact 等)、各 path component の no-follow、開いた同一 FD での regular-file 判定と読み取り、1ファイル/合計の読み取り量上限・entry数上限、mtime単独に依存しない新規性判定、status/実行経路により生成されない artifact の正当な省略
  • lifecycle lockのartifact検証完了までの保持延長。失敗時も既存 finally release semantics を維持する。2プロセス同期は固定 sleep ではなく barrier を使う
  • 新しい cleanup/lifetime semantics(generation invalidation を含む)の対象 command-id は、PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDS のうち4 production preflight profile(preflight.run / preflight.run.with_anchor / preflight.run.with_human_context / preflight.run.with_agent_report)のみに限定する。contract_update 2 profile(contract_update.run.with_anchor / contract_update.run.with_human_context)はこの新しい semantics の対象外とし、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 で実装済みの inner-transaction-result-preservation契約(GitHub mutation 再送禁止・inner_transaction_state=unknown fallback)の regression がないことのみを求める
  • 既存legacy regression test(tests/agent_ops/test_worktree_bootstrap_exec.py、tests/codex/test_worktree_bootstrap_command_policy.py、scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py、scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py(PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 由来の contract_update inner-transaction regression testを含む)、scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py)の回帰確認
  • テスト設計は (1) artifact confinement/provenance/bounds の focused unit tests、(2) accepted-OID refresh + lifecycle lock の barrier-based integration test、(3) 実際の preflight → needs_fix → repair_action.apply の production-chain E2E 1本、の3層に絞る(巨大な profile×failure combination matrixは新設しない)
  • 本Issueの PR で 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 の残る critical regressions と本Issueの local AC(AC1-6) を green にする(AC7の範囲は本節および ## Delivery Rule 参照)

Out of Scope

  • sanitized Git subprocess実行基盤・remote OIDプロトコル・lifecycle lock・identity probeの本体実装(Child 1-4 で実装済み)
  • WORKTREE_CATALOG_ENTRY_V1 スキーマ変更
  • contract_update.run.with_anchor / contract_update.run.with_human_context の dedicated worktree 化(Issue 実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 で完了済み。PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 参照。本Issueはこの2 profileの新しい cleanup/lifetime semantics化を行わず、既存 inner-transaction-result-preservation契約の non-regression のみを扱う)
  • generic worktree強制hookやglobal permission planeの追加
  • 新しい lease DB、heartbeat、常駐 cleanup daemon、generic artifact broker、新しい receipt/state-store framework の追加(AC3の generation invalidation 契約は consumer acknowledgement機構を必要としない単純化された設計であり、永続的なartifact lifecycle manager を新設しない)
  • 新しい openat2 wrapper、security module、hardlink registry、generic broker、generic authorization/token framework の追加
  • worktree_catalog.py へのartifact内容検証責務の追加(identity/catalog責務のみ維持する)
  • stdout回収方式(communicate())の全面改修。stdout capture のメモリ上限保証は、本Issueが扱う artifact サイズ上限保証とは区別し scope外とする
  • child stdout の subprocess capture を binary mode(binary_output=True)へ切り替える変更。artifact handoff の byte-for-byte 要求は「preflight が書き込んだ結果JSONファイルを repair consumer が re-serialize/re-encode せずそのまま再読込する」ことを指し、child stdout の text-mode capture(改行の \n 正規化を含む)はこの要求の対象ではない。既存の compact stdout projection contract(STATUS/NEXT_ACTION/ARTIFACT 等の text projection)を別の JSON transport に再設計しない
  • stale artifact を検出した consumer(repair_action.apply 等)から実際に fresh preflight.run を再起動する routing 実装。本Issueが実装するのは confinement/cleanup/generation境界の判定(stale artifactの検出と not_attempted + secure_open_rejected の返却)までであり、consumer側のfresh-preflight復帰ロジック自体は .claude/skills/issue-refinement-loop/SKILL.md および .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py 側の別スコープとして扱う(別Issueで扱う。本Issueでは新規起票しない)

Acceptance Criteria

  • AC1: 実 executor(scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions())から dedicated child、artifact validator(_validate_stdout_artifact_projection() 拡張)までの経路が本番 dispatch から実際に呼ばれ、helper 単体の成功だけで AC 達成としないことを実証する
  • AC2: preflight → needs_fix → cleanup → repair_action.apply の通常 handoff で、結果JSONと候補本文を修復 consumer が手動移動なしに読み、処理が進むことを実証する(既存の dedicated artifact → repair consumer handoff テストを維持・強化する)
  • AC3: 同一Issue再実行、別Issue実行、accepted OID更新による worktree 再作成(recover_or_create_fixed_control_plane_worktree())の各ケースで、generation invalidation 契約(旧 generation の artifact は consumer未読でも消えてよく永続保全は要求しない。ただし旧 generationのhandoffからGitHub mutationを継続しない)が成立することを実証する。旧 artifact を誤って採用しない(暗黙reuse・primary checkoutや同名pathへのfallback禁止)ことを実証する。stale / missing / provenance-invalid と判定した artifact を検出した consumer(repair_action.apply 等)が mutation retry ではなく not_attempted + secure_open_rejected を返し既存 transport を維持したまま fresh-preflight-eligible な状態に戻ることを実証する(実際の fresh preflight 再起動routing自体は Out of Scope。本ACは検出・返却までを対象とする)
  • AC4: confinement の検証対象として、target Issue root・issue_number/repo所有一致、各 path component の no-follow、開いた同一 FD での regular-file 判定と読み取り、1ファイル/合計の読み取り量上限・entry数上限、mtime単独に依存しない新規性判定、正当な省略(status/実行経路により生成されない artifact を無条件欠落エラーにしない)を実装し、symlink・non-regular-file・Issue不一致・oversized・stale result の各異常系を focused unit/integration test で確認することを実証する。JSON内の任意文字列や must_read を生成 artifact と誤分類しないことも確認する。freshness判定は issue_number/repo + schema + preflight_run_identity + content digest 等、既存 schema に定義済みの provenance フィールドを優先し、新しい timestamp プロトコルや artifact registry は追加しない
  • AC5: 必須の artifact 検証・cleanup 判定が完了する前に利用可能に見える STATUS/NEXT_ACTION/ARTIFACT を公開しないことを実証する。child の non-zero exit code(warn/needs_fix 等の正当な control result)を一律 failure と扱わず、confinement/cleanup/postcondition failure と分離することを実証する
  • AC6: 検証・cleanup中は既存 lifecycle lock を保持し、失敗後は既存 finally release semantics により解放されることを実証する。2プロセスの同期には固定 sleep ではなく barrier を使うことを実証する。本Issueの cleanup/publish ordering 変更後も、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 で実装済みの contract_update inner-transaction-result-preservation契約(GitHub mutation 再送禁止・inner_transaction_state=unknown fallback)に回帰がないことを実証する
  • AC7: 新規dedicated-lane test群(本Issue、および Child 1-4 で追加された全新規テストファイル)と既存legacy regression testの両方がPASSし、normal regular issue-worktree bootstrapの既存positive/negative matrixに回帰がないことを実証する。既存legacy regression testには scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py(PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 由来の contract_update inner-transaction regression testを含む)を含める。本ACの runtime-verification 範囲は本Issue PRでの code acceptance(local ACとcritical regressionのgreen化)に限定し、親issue 実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 のクローズ自体は ## Delivery Rule に定義する merge後の delivery step として扱う

Delivery Rule

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q
# AC2
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py -q
# AC3
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_cleanup.py -q
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q
# AC5
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_control_plane_artifact_handoff.py -q
# AC6
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py -q
# AC7
$ uv run --locked pytest tests/agent_ops/test_control_plane_worktree_bootstrap.py tests/agent_ops/test_control_plane_worktree_remote_binding.py tests/agent_ops/test_control_plane_worktree_concurrency.py tests/agent_ops/test_control_plane_worktree_cleanup.py scripts/agent-guards/tests/test_skill_runtime_control_plane_policy.py scripts/agent-guards/tests/test_skill_runtime_control_plane_exec.py scripts/agent-guards/tests/test_control_plane_artifact_handoff.py tests/agent_ops/test_worktree_bootstrap_exec.py tests/codex/test_worktree_bootstrap_command_policy.py scripts/agent-guards/tests/test_skill_runtime_command_policy_anchor.py scripts/agent-guards/tests/test_skill_runtime_exec_anchor.py scripts/agent-guards/tests/test_skill_runtime_preflight_no_worktree.py -q
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
$ uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -q

Allowed Paths

scripts/agent-ops/worktree_bootstrap_exec.py
scripts/agent-ops/worktree_catalog.py
scripts/agent-guards/skill_runtime_exec.py
tests/agent_ops/test_control_plane_worktree_cleanup.py
scripts/agent-guards/tests/test_control_plane_artifact_handoff.py
tests/agent_ops/test_control_plane_worktree_bootstrap.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

なし

Required Design References

Scope Collision Record

Scope Delta(任意)

scope_delta_status: approved_by_trusted_anchor
source: "https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5556182485"
allowed_path_deltas:
  add:
    - scripts/agent-guards/skill_runtime_exec.py
    - tests/agent_ops/test_control_plane_worktree_bootstrap.py
reason: "production wiring(_dispatch_child_and_check_postconditions())と既存repair-consumer handoffテストが本Issueの実装対象そのものであり、これらのAllowed Paths欠落は#2495と同型のwiring失敗を誘発するため(OWNER anchor comment P1-1)"

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 16, 2026
  2. added a commit that references this issue on Sep 2, 2026
  3. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    結論

    Issue #2200 は、現状の仕様のまま実装に進めるのではなく、REQUEST_CHANGES として再 refinement するのが妥当です。
    ただし、専用 worktree 化そのものをやり直す必要はありません。問題の中心はセキュリティ機構の不足ではなく、**「成果物を検証した後、次の処理が本当に使えるか」「cleanup と結果公開の順序が正しいか」「実装を接続するファイルがスコープに入っているか」**です。

    確認対象のコードは main の b127017d9482fd3c0990b826a7b12b004d3e04eb です。前提となる PR #2495 はマージ済みで、現在は生存する親コントローラーがロックを保持し、専用 worktree 内の子プロセスを監督する構造になっています。この構造は維持すべきです。

    #2199 の OWNER コメントも、#2200 について「既存の producer/consumer transport を再設計せず、confinement・bounded cleanup・release ordering を追加し、修復 consumer の可読性を維持する」と明示しています。以下は、その方針を現行コードに照合したレビューです。


    P1-1:Allowed Paths が、実際に変更すべき executor を含んでいない

    #2200 の Allowed Paths は、worktree_bootstrap_exec.py、worktree_catalog.py、新しい cleanup/handoff テストの4ファイルです。しかし現行の本番経路で成果物の検証と stdout 公開を実行しているのは、scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions() です。

    現在の処理順は、概略次のとおりです。

    child 実行
      → 書き込み差分確認
      → stdout 内の artifact path 確認
      → stdout/stderr を外部へ出力
      → child の終了コードを返す

    一方、bootstrap 側の control_plane_dedicated_execution_session() は、ロックと worktree の実行コンテキストを管理しますが、対象 Issue 番号や child の stdout を直接受け取る構造ではありません。したがって、bootstrap に helper だけ追加しても、対象 Issue と実際の出力に結び付いた検証を本番経路へ接続できません。

    これは過去の #2495 で起きた失敗に近いです。当初は専用実行用の定数や primitive が存在し、Verification Commands も通っていましたが、実際の main() に配線されていないことがレビューで検出されています。その問題は現在は修正済みですが、#2200 のスコープ設定は同じ失敗を誘発します。

    修正案: 最初に有限の Scope Delta を入れ、少なくとも次を追加してください。

    scripts/agent-guards/skill_runtime_exec.py
    tests/agent_ops/test_control_plane_worktree_bootstrap.py

    後者には既に dedicated artifact を実際の修復 consumer に渡すテストがあります。新しい巨大 fixture を作るより、その経路へ cleanup を挟んで保証を強化する方が有用です。worktree_catalog.py は、artifact の内容検証を押し込む場所にせず、identity/catalog の責務に留めることを勧めます。

    P1-2:cleanup の対象だけでなく、公開した成果物の「寿命」が未定義

    今回、最も優先して直すべき点です。

    既存の修復経路は、preflight の結果 JSON と、その中で参照される候補本文を後から読みます。#2199 では dedicated worktree 内の artifact を repair_action.apply が読めるように修正され、関連テストも追加されています。つまり、preflight の終了は artifact の利用終了ではありません。

    ところが #2200 は、bounded cleanup、stale artifact の拒否、検証済み root への限定は要求する一方で、何をいつまで残し、何を削除してよいかを十分に固定していません。終了時に対象 root を消せば安全、という実装では通常の自動修復が壊れます。

    次回の worktree 再作成も、成果物を消す経路になる

    現行の recover_or_create_fixed_control_plane_worktree() は、accepted OID が変わった場合、clean と判定した既存 worktree を削除して再作成します。clean 判定は git status --porcelain --untracked-files=all ですが、リポジトリの .gitignore には artifacts/ が含まれています。

    ここで重要なのは、Git の clean 判定は、ignored な成果物が存在しないことを意味しない点です。Git 本体の check_clean_worktree() と削除処理も確認しました。通常の status で clean と判定した後、worktree のディレクトリを削除するため、ignored なファイルは保存されません。(raw.githubusercontent.com)

    ローカルの独立した最小 fixture、Git 2.47.3 でも、以下を確認しました。

    ignored artifact が存在する                   → true
    git status --porcelain --untracked-files=all   → 空
    git worktree remove(--force なし)             → exit 0
    削除後に artifact が存在する                   → false

    したがって、通常の並行作業でも次の経路が成立し得ます。

    A: preflight → needs_fix → 結果 JSON と候補本文を公開
    A: preflight の lifecycle lock を解放
    B: 別の preflight → remote OID 更新を検出 → worktree を再作成
    A: repair_action.apply → 入力 artifact が既にない

    preflight 実行中のロックを正しく保持するだけでは、この寿命の問題は解決しません。 現在のロック範囲と worktree 更新処理から導ける、後続 consumer との接続上のリスクです。

    修正案: cleanup 契約を、少なくとも次の3種類に分けてください。

    対象 | 推奨する扱い -- | -- 未公開の一時ファイル・失敗 run の残骸 | 検証した範囲だけ bounded cleanup する 今回公開した結果 JSON と、その処理に必要な参照ファイル | 通常の後続 consumer が読む前に削除しない 次回 run・OID 更新で失効する成果物 | 保全するか、明示的に stale と判定して自動で fresh preflight に戻す。暗黙の欠落や旧結果の再利用にしない

    テストは、既存の production-chain E2E を1〜2本強化し、異常系の組合せは小さな unit/integration test に寄せることを推奨します。#2495 では、配線変更に伴う fixture 不足から Scope Delta が何度も発生していました。今回も全 profile × 全異常系の巨大な synthetic repository 群を増やすと、目的物よりハーネスの保守が重くなります。

    今回、増やさなくてよいもの

    新しい broker、authorization token、lease DB、heartbeat、常駐 cleanup daemon、receipt framework は不要です。 対象 Issue の明示的な artifact root を扱うだけなら、既存ロック、既存 reader のパターン、小さな上限付き処理で進めるのが適切です。

    また、#2199 で修正された external venv、human-context evidence の primary-root 明示受け渡し、dedicated artifact を読む修復 consumer は戻さないでください。現在のコードに存在する、通常のワークフローを成立させるための修正です。primary checkout watchdog のコスト最適化まで #2200 の必須条件に広げることも勧めません。

    推奨順序は、親・子の契約整合 → 成果物の寿命と失効条件の確定 → 有限の Allowed Paths 拡張 → 既存 E2E を使った実装です。
    評価の中心は「安全そうな検査が増えたか」ではなく、**「初回も再実行も、成果物を手で移動・復旧せず、自動修復まで到達できるか」**に置くべきです。

    なお、今回実施したのは GitHub 上の Issue・関連コメント・PR 情報・固定 SHA のコード確認と、Git/Python の独立した最小再現です。プロジェクト全体の pytest や CI の再実行はしていません。 GitHub への書き込みも行っていません。

    ## 結論

    Issue #2200 は、現状の仕様のまま実装に進めるのではなく、REQUEST_CHANGES として再 refinement するのが妥当です。
    ただし、専用 worktree 化そのものをやり直す必要はありません。問題の中心はセキュリティ機構の不足ではなく、**「成果物を検証した後、次の処理が本当に使えるか」「cleanup と結果公開の順序が正しいか」「実装を接続するファイルがスコープに入っているか」**です。

    確認対象のコードは main の b127017d9482fd3c0990b826a7b12b004d3e04eb です。前提となる PR #2495 はマージ済みで、現在は生存する親コントローラーがロックを保持し、専用 worktree 内の子プロセスを監督する構造になっています。この構造は維持すべきです。

    #2199 の OWNER コメントも、#2200 について「既存の producer/consumer transport を再設計せず、confinement・bounded cleanup・release ordering を追加し、修復 consumer の可読性を維持する」と明示しています。以下は、その方針を現行コードに照合したレビューです。


    P1-1:Allowed Paths が、実際に変更すべき executor を含んでいない

    #2200 の Allowed Paths は、worktree_bootstrap_exec.py、worktree_catalog.py、新しい cleanup/handoff テストの4ファイルです。しかし現行の本番経路で成果物の検証と stdout 公開を実行しているのは、scripts/agent-guards/skill_runtime_exec.py の _dispatch_child_and_check_postconditions() です。

    現在の処理順は、概略次のとおりです。

    child 実行
      → 書き込み差分確認
      → stdout 内の artifact path 確認
      → stdout/stderr を外部へ出力
      → child の終了コードを返す
    

    一方、bootstrap 側の control_plane_dedicated_execution_session() は、ロックと worktree の実行コンテキストを管理しますが、対象 Issue 番号や child の stdout を直接受け取る構造ではありません。したがって、bootstrap に helper だけ追加しても、対象 Issue と実際の出力に結び付いた検証を本番経路へ接続できません。

    これは過去の #2495 で起きた失敗に近いです。当初は専用実行用の定数や primitive が存在し、Verification Commands も通っていましたが、実際の main() に配線されていないことがレビューで検出されています。その問題は現在は修正済みですが、#2200 のスコープ設定は同じ失敗を誘発します。

    修正案: 最初に有限の Scope Delta を入れ、少なくとも次を追加してください。

    scripts/agent-guards/skill_runtime_exec.py
    tests/agent_ops/test_control_plane_worktree_bootstrap.py
    

    後者には既に dedicated artifact を実際の修復 consumer に渡すテストがあります。新しい巨大 fixture を作るより、その経路へ cleanup を挟んで保証を強化する方が有用です。worktree_catalog.py は、artifact の内容検証を押し込む場所にせず、identity/catalog の責務に留めることを勧めます。

    P1-2:cleanup の対象だけでなく、公開した成果物の「寿命」が未定義

    今回、最も優先して直すべき点です。

    既存の修復経路は、preflight の結果 JSON と、その中で参照される候補本文を後から読みます。#2199 では dedicated worktree 内の artifact を repair_action.apply が読めるように修正され、関連テストも追加されています。つまり、preflight の終了は artifact の利用終了ではありません。

    ところが #2200 は、bounded cleanup、stale artifact の拒否、検証済み root への限定は要求する一方で、何をいつまで残し、何を削除してよいかを十分に固定していません。終了時に対象 root を消せば安全、という実装では通常の自動修復が壊れます。

    次回の worktree 再作成も、成果物を消す経路になる

    現行の recover_or_create_fixed_control_plane_worktree() は、accepted OID が変わった場合、clean と判定した既存 worktree を削除して再作成します。clean 判定は git status --porcelain --untracked-files=all ですが、リポジトリの .gitignore には artifacts/ が含まれています。

    ここで重要なのは、Git の clean 判定は、ignored な成果物が存在しないことを意味しない点です。Git 本体の check_clean_worktree() と削除処理も確認しました。通常の status で clean と判定した後、worktree のディレクトリを削除するため、ignored なファイルは保存されません。([raw.githubusercontent.com]1)

    ローカルの独立した最小 fixture、Git 2.47.3 でも、以下を確認しました。

    ignored artifact が存在する                   → true
    git status --porcelain --untracked-files=all   → 空
    git worktree remove(--force なし)             → exit 0
    削除後に artifact が存在する                   → false
    

    したがって、通常の並行作業でも次の経路が成立し得ます。

    A: preflight → needs_fix → 結果 JSON と候補本文を公開
    A: preflight の lifecycle lock を解放
    B: 別の preflight → remote OID 更新を検出 → worktree を再作成
    A: repair_action.apply → 入力 artifact が既にない
    

    preflight 実行中のロックを正しく保持するだけでは、この寿命の問題は解決しません。 現在のロック範囲と worktree 更新処理から導ける、後続 consumer との接続上のリスクです。

    修正案: cleanup 契約を、少なくとも次の3種類に分けてください。

    対象 推奨する扱い
    未公開の一時ファイル・失敗 run の残骸 検証した範囲だけ bounded cleanup する
    今回公開した結果 JSON と、その処理に必要な参照ファイル 通常の後続 consumer が読む前に削除しない
    次回 run・OID 更新で失効する成果物 保全するか、明示的に stale と判定して自動で fresh preflight に戻す。暗黙の欠落や旧結果の再利用にしない

    OID 更新をまたぐ保存方法まで、このレビューで未検証の方式に決め打ちするのは避けます。ただし、「未消費の成果物をどう扱うか未定のまま、cleanup と refresh を実装する」のは不可です。

    新しい lease DB や常駐 GC は不要です。まず通常の handoff を維持し、再実行・refresh 時の有効期限と自動復旧を明文化する方が、ユーザーのワークフローに合っています。

    P1-3:cleanup 失敗より先に、利用可能に見える stdout を公開してしまう

    現行 executor は、artifact projection の検証後、session を抜ける前に stdout を書き出します。その後に親 checkout の invariant 確認も行います。ここへ単純に「context manager の finally で cleanup」を追加すると、次の順序になります。

    STATUS / NEXT_ACTION / ARTIFACT を公開
      → cleanup が失敗
      → 外側はエラー終了
    

    これは、後続エージェントから見ると 「結果を使ってよいのか、処理全体が失敗したのか」 が分かりにくい出力です。問題は新しい status enum が必要なことではなく、採用可能な結果を公開するタイミングが早いことです。

    修正案: child の出力を一旦保持し、既存ロックの中で必要な検証と cleanup の判定を済ませてから公開するようにしてください。

    child の終了・既存の supervision
      → 成果物の検証
      → 公開する成果物の保持を確定
      → 削除可能な残骸だけ cleanup
      → 必須の postcondition を確認
      → 採用可能な stdout を公開
      → finally で lock 解放
    

    ここで exit 0 以外を一律に「公開禁止」にしてはいけません。preflight の既存契約には warn / exit 1、needs_fix / exit 4 などがあり、特に needs_fix は自動修復へ進む正常な制御結果です。整合性検証の失敗と、preflight 自体が返した正当な診断結果を分ける必要があります。

    また、失敗時にロックを保持し続ける設計にもせず、必要な失敗処理を試みた後は finally で解放する現在の基本構造を維持するべきです。

    P2:byte-for-byte 要求と、現在の text-mode capture も整合していない

    #2200 は stdout の byte-for-byte 再利用を求めていますが、現行の production preflight は binary_output=False で、supervisor は text=not binary_output を使用します。binary capture は既に存在しますが、現在それを選ぶのは structural repair の経路です。

    Python の text mode は stdout の改行を \n に変換します。独立した最小再現でも、child が出した b"STATUS: pass\r\n" は "STATUS: pass\n" になりました。通常の producer が LF のみを出していれば表面化しませんが、一般的な byte-for-byte 保証にはなりません。([Python documentation]2)

    厳密な bytes 保持が必要なら、既存の binary_output を対象 profile に適用し、検証用の解析結果と公開する元 bytes を分ければ足ります。stdout を JSON に作り直す変更は不要です。なお、実際の stdout は JSON 文書ではなく、STATUS、NEXT_ACTION、ARTIFACT などの compact projection です。

    P1-4:confinement の検証対象と、bounded の単位が曖昧

    現行の _validate_stdout_artifact_projection() は、stdout から抽出したパスを realpath() で解決し、許可 root 内かを確認する処理です。この関数自体は、component-wise no-follow、regular file、Issue 所有、内容のサイズ、今回 run の新規性を検証していません。#2200 が追加実装する必要のある部分ですが、現行 helper を呼んだだけで AC 達成と扱える書き方は避けるべきです。

    特に、トップレベルの結果 JSON の所在だけ確認して終わりにすると、repair_action.candidate_body_artifact のような、実際に次の処理が読む参照先が保証から抜けます。既存の結果・修復契約には、こうした参照と provenance 情報があります。

    一方で、JSON 内のすべての文字列や must_read を一律に「生成 artifact」として扱う検証も勧めません。既存 schema の must_read は一般的な読み取り対象を表すため、検証対象を広げすぎると正当な参照まで拒否する原因になります。

    修正案: Issue に、検証する既知の artifact field と、必要条件を小さな表で固定してください。

    観点 最低限、固定したい内容
    所有・参照 target Issue root、結果の issue_number / repo、consumer が実際に読む既知の参照先
    ファイルアクセス 各 path component の no-follow、開いた同じ FD で regular-file 判定と読み取り
    上限 1ファイルの読み取り量、合計読み取り量、entry 数、cleanup の処理量・時間
    新規性 以前の結果を今回の結果として採用しない条件。mtime だけに頼らない
    正常な省略 status や実行経路によって生成されない artifact を、無条件の欠落エラーにしない

    実装は新規のセキュリティ基盤ではなく、既存パターンの再利用がよいです。リポジトリには既に secure_read_repair_apply_artifact() と、それを共有する修復経路があり、FIFO を拒否するテストもあります。Python 標準ライブラリにも dir_fd 相対の open/stat/unlink などの仕組みがあります。似た reader を何個も新設するより、既存の実装・テストを利用する方が保守しやすいです。([Python documentation]3)

    なお、上限の検証は「全部読んでからサイズを判定」では不十分です。同様に stdout まで bounded と主張するなら、現在の communicate() は全出力をメモリに蓄えるため、回収後のサイズチェックだけではメモリ上限の保証になりません。ただし stdout の回収方式全面改修まで今回に入れるかは別判断であり、まず artifact の上限保証と区別して記述すべきです。([Python documentation]2)

    P1-5:「#2190 の全AC最終検証」が、古い親契約に引きずられる

    取得した #2190 の AC9 には、bootstrap 完了後に dedicated worktree 内の executor へ re-exec する要求が残っています。一方、採用済みの実装は、生存する親コントローラーがロックを保持して dedicated child を監督する構造です。

    そのため、#2200 の成果物処理だけを完成させても、旧 AC をそのまま機械的に検証すると、次のどちらかになります。

    正しい現行実装を旧仕様へ巻き戻すか、満たしていない旧 AC を PASS と記録するか。

    どちらも避けるべきです。#2200 の実装前に、親 #2190 の AC と既に採用した実装を整合させ、「親コントローラーを維持する」ことを正規の契約にする必要があります。ロックも、既に child と既存 post-checks まで保持されているため、「新しいロック方式を導入する」「initializer から FD を渡して re-exec する」といった再設計は不要です。

    また、#2200 に残る contract-update follow-up の新規作成指示は、既存の #2393 を参照する形へ更新してください。#2393 は2つの mutation profile の dedicated runtime 移行を所有し、#2200 の confinement と親全体の最終検証は明示的に対象外としています。重複 Issue を作る必要はありません。

    ただし、#2393 の完了まで #2200 を無条件に待たせる提案ではありません。 担当範囲は分けたまま、共有 executor の変更を並行して衝突させず、最終的な profile 境界に対して回帰確認する扱いで十分です。#2393 自体も共有 runtime path の並行編集を避ける契約です。

    P2:Runtime Verification の AC 番号が、この Issue の AC と一致していない

    #2200 のローカル AC は AC1〜AC5 ですが、Runtime Verification Applicability は applicable_acs: [AC6, AC11, AC12] です。親 AC を指しているように見えますが、その区別が記述上ありません。

    これは小さい修正で済む一方、機械処理上は無視できません。ローカル AC の適用範囲と、親 AC への対応表を分離してください。親の番号をローカル AC 欄へ流用しない方が明確です。


    私なら、#2200 をこの完了条件に書き換える

    Outcome は、次の方向に絞ります。

    PR #2495 の既存 parent-controller と producer/consumer path contract を維持したまま、本番 preflight 経路に artifact 検証・限定的 cleanup・結果公開順序を接続する。公開された成果物は通常の後続 consumer が読めることを保証し、再実行・worktree refresh による失効は明示的かつ自動復旧可能に扱う。親 #2190 の採用済み設計との契約差分を解消したうえで、親 AC の検証結果を記録する。

    追加・改訂する AC は、この程度のまとまりで十分です。

    AC のまとまり 実証すること
    本番への接続 実 executor → dedicated child → artifact validator の経路を通る。helper 単体の成功だけで済ませない
    通常の handoff preflight → needs_fix → cleanup → repair_action.apply で、結果 JSON と候補本文を読み、処理が進む
    再実行・refresh 同一 Issue の再実行、別 Issue の実行、OID 更新で、旧 artifact を誤採用せず、未消費入力の消失を黙殺しない
    検証と上限 symlink、非 regular file、Issue 不一致、過大ファイル・過多数 entry、stale result を小さな focused test で確認する
    公開順序 必須検証・cleanup 失敗時に採用可能な結果を先行公開しない。正当な warn / needs_fix などは維持する
    ロックと失敗復旧 検証・cleanup 中は既存 lock を保持し、失敗後は解放する。2プロセスの同期には固定 sleep ではなく barrier を使う
    親契約と回帰 #2190 の修正済み AC への対応表を残し、fixture と対象外 profile を壊さない

    テストは、既存の production-chain E2E を1〜2本強化し、異常系の組合せは小さな unit/integration test に寄せることを推奨します。#2495 では、配線変更に伴う fixture 不足から Scope Delta が何度も発生していました。今回も全 profile × 全異常系の巨大な synthetic repository 群を増やすと、目的物よりハーネスの保守が重くなります。

    今回、増やさなくてよいもの

    新しい broker、authorization token、lease DB、heartbeat、常駐 cleanup daemon、receipt framework は不要です。 対象 Issue の明示的な artifact root を扱うだけなら、既存ロック、既存 reader のパターン、小さな上限付き処理で進めるのが適切です。

    また、#2199 で修正された external venv、human-context evidence の primary-root 明示受け渡し、dedicated artifact を読む修復 consumer は戻さないでください。現在のコードに存在する、通常のワークフローを成立させるための修正です。primary checkout watchdog のコスト最適化まで #2200 の必須条件に広げることも勧めません。

    推奨順序は、親・子の契約整合 → 成果物の寿命と失効条件の確定 → 有限の Allowed Paths 拡張 → 既存 E2E を使った実装です。
    評価の中心は「安全そうな検査が増えたか」ではなく、**「初回も再実行も、成果物を手で移動・復旧せず、自動修復まで到達できるか」**に置くべきです。

    なお、今回実施したのは GitHub 上の Issue・関連コメント・PR 情報・固定 SHA のコード確認と、Git/Python の独立した最小再現です。プロジェクト全体の pytest や CI の再実行はしていません。 GitHub への書き込みも行っていません。

  4. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    推奨は、#2200 をそのまま実装フェーズへ送らず、対象コメントを trusted human context とした issue-refinement-loop を自律実行し、semantic reframe まで完了させることです。現在の #2200 は Allowed Paths が4ファイルに限定されている一方、レビューでは production executor の skill_runtime_exec.py と既存 production-chain test が実変更点として不足していると指摘されています。さらに artifact の「検証」だけでなく、後続 repair_action.apply が読むまでの寿命、cleanup→公開順序、stale 時の fresh-preflight 復帰まで契約化する必要があります。

    加えて、親 #2190 に残る re-exec 契約が PR #2495 後の parent-controller 実装と食い違うなら、#2200 だけで無理に吸収せず、#2190 の契約を先に semantic refinement して現行実装へ合わせるべきです。一方 contract_update.* の dedicated runtime 移行については既に #2393 が所有しているため、新規 follow-up を重複起票せず、#2200 から #2393 を参照して shared-path collision/順序だけ扱うのが適切です。

    issue-refinement-loop 自体は iteration ごとの人間承認をデフォルトで要求しません。また semantic design review は issue-design-reviewer sibling SubAgent の完了を待つ join barrierを明示的に持ち、blocker/high finding は semantic rewrite に送れます。したがって、今回の「承認なしで semantic に直す」は既存設計に沿っています。

    Claude Code の Auto mode はリポジトリの loop approval と別物です。Auto mode は permission prompt をなくしつつ classifier を残すモードなので、今回はこちらを使うのが適切です。チャットの指示で Auto mode に切り替えるのではなく、interactive CLI 側で選択する必要があります。([Claude]1)

    推奨する実行方針は次の5点です。

    1. interactive Claude Code を Auto mode で開始し、実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 と anchor comment #issuecomment-5556182485 を入力にする。ループ間承認は要求しない。
    2. main thread から sibling SubAgent を使って、少なくとも「production execution/artifact lifecycle」と「実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190/実装: control-plane preflight を dedicated linked worktree の identity probe と command class 分離で 4 production profile へ移行する #2199/実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393/PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 の契約整合」を独立調査させ、全 SubAgent 完了まで mutation を開始しない。nested delegation は禁止する。
    3. deterministic repair が適用可能なら自動適用する。一方、今回の主要 finding は semantic なので、deterministic checker を通過しても semantic review を明示的に起動し、必要なら rewrite_lane: semantic → issue-editor まで自動継続する。semantic rewrite は AC/VC/Allowed Paths/Stop Conditions の変更を正式に扱える契約になっています。
    4. 実装: control-plane preflight の artifact confinement と #2190 全AC最終検証を実装する #2200 には少なくとも skill_runtime_exec.py と test_control_plane_worktree_bootstrap.py の有限 Scope Delta、artifact lifetime、公開/cleanup ordering、known artifact fields の confinement、byte-for-byte 要求と binary/text capture の整合、local AC と parent AC crosswalk の分離を反映する。新しい lease DB、broker、daemon、巨大 synthetic harness は作らない。
    5. 書換え後は fresh preflight → deterministic review → semantic review を再実行し、approve/proceed になるまで bounded loopする。途中の needs_fix は承認を求めず修復する。停止対象は、証拠から一意に決められない本物の human_judgment_required、権限/環境不能、または no-progress のみとする。

    Claude Code には以下をそのまま渡すのがよいです。

    あなたは squne121/loop-protocol の maintainer として、Issue #2200 を issue-refinement-loop で refinement してください。

    対象:

    最終目的

    Issue #2200 を、実装開始可能な approve / proceed 相当の状態まで自律的に refinement する。

    これはレビューだけを返すタスクではない。
    必要な Issue 本文修正、semantic rewrite、deterministic repair、fresh review の再実行まで実際に行うこと。

    人間による iteration ごとの承認は要求しない。
    私は、この anchor comment に記載された evidence-backed な REQUEST_CHANGES を、矛盾がない限り Issue 契約へ反映することを明示的に承認する。

    ただしコード実装や PR 作成には進まない。
    今回のゴールは Issue contract の refinement 完了まで。

    Claude Code / loop execution policy

    現在の interactive session の Auto mode をそのまま使用する。

    issue-refinement-loop の canonical procedure、planner、controlled Issue mutation path を使用し、raw gh issue edit 等で canonical workflow を迂回しないこと。

    loop iteration approval gate は不要。
    needs_fix、request_changes、deterministic repair、semantic rewrite の各反復では、人間への「続けますか?」確認を挟まず自動継続する。

    max_iterations は 5 とする。
    同一 mutation の no-progress retry は行わない。

    以下だけを terminal escalation とする:

    • repository evidence と anchor decision を合わせても複数の相反する設計から一意に選べない、真の human_judgment_required
    • authority / authentication / environment failure により canonical mutation が実行不能
    • fresh review を繰り返しても同一 blocker が解消せず no-progress
    • scope を成立させるために、今回の明示的 owner instruction から導けない新しい product decision が必要

    単なる Allowed Paths の有限拡張、AC/VC の semantic rewrite、既存 Issue への参照変更、stale contract の現行実装への整合は human approval 理由にしない。

    SubAgent orchestration — 必須

    main thread だけで調査を完結させないこと。

    最初の mutation より前に、少なくとも以下の sibling SubAgent workstream を起動する。

    SubAgent A — runtime / artifact lifecycle investigator

    以下を current main で調査する:

    • scripts/agent-guards/skill_runtime_exec.py
    • scripts/agent-ops/worktree_bootstrap_exec.py
    • scripts/agent-ops/worktree_catalog.py
    • tests/agent_ops/test_control_plane_worktree_bootstrap.py
    • artifact producer → stdout projection → repair_action.apply 等の consumer chain
    • ignored artifacts/ と dedicated worktree refresh/remove の関係
    • stdout publication と postconditions / cleanup / lock release の現在の実行順序
    • existing secure artifact reader / no-follow / regular-file validation / size-bound implementation
    • binary_output / text-mode stdout capture

    目的は「helper が存在するか」ではなく、production main() 経路へ実際に配線されているかを確認すること。

    SubAgent B — cross-Issue contract investigator

    以下を current state で突き合わせる:

    特に確認する:

    必要なら web-researcher を sibling として追加してよい。ただし repository evidence だけで決着する論点に不要な web research を増やさないこと。

    Join barrier

    すべての上記 SubAgent の作業完了を待つこと。

    SubAgent がまだ running の状態で:

    • Issue body mutation
    • semantic rewrite
    • parent Issue mutation
    • final verdict

    へ進んではならない。

    各 SubAgent は nested SubAgent を起動しないこと。
    必要な追加 delegation は必ず main thread から sibling として行う。

    SubAgent の findings を main thread で統合してから canonical issue-refinement-loop の decision に投入する。

    Anchor comment の主要 finding を必ず検証する

    anchor comment を盲目的にコピーするのではなく current main に対して freshness を確認すること。
    ただし freshness が確認できた finding は semantic rewrite の入力として扱う。

    最低限、以下を disposition すること。

    1. Allowed Paths / production wiring

    #2200 の現在の Allowed Paths だけで production path を実装可能か確認する。

    anchor finding が current main でも成立する場合、有限 Scope Delta として少なくとも:

    • scripts/agent-guards/skill_runtime_exec.py
    • tests/agent_ops/test_control_plane_worktree_bootstrap.py

    を #2200 の Allowed Paths / In Scope / Verification に整合的に追加する。

    必要な focused test path が他にも存在する場合は evidence を示して有限追加してよい。
    「後で必要になるかもしれない」という理由で広い wildcard scope にしない。

    worktree_catalog.py に artifact content validation の責務を押し込まない。
    identity/catalog responsibility は維持する。

    2. Artifact lifetime

    #2200 に artifact の「場所の安全性」だけでなく「寿命」を明記する。

    少なくとも次の3カテゴリを区別する:

    1. 未公開 temporary files / failed-run leftovers

      • verified scope 内だけ bounded cleanup 対象。
    2. outward result として公開済みで、通常の downstream consumer がまだ必要とする result/artifact

      • consumer が読む前に cleanup / worktree refresh によって消してはならない。
    3. 次回 run / accepted OID drift / worktree refresh によって stale になった artifact

      • missing path や旧 artifact の implicit reuse として処理しない。
      • provenance/freshness が成立しない場合は、既存 transport を維持したまま fresh preflight へ deterministic に戻せる契約を優先する。

    保存方式として新しい lease DB、heartbeat、daemon、broker、receipt framework を追加しない。
    既存 producer/consumer transport と existing provenance を最大限再利用する。

    実装方式を Issue refinement 段階で証拠なしに過剰固定する必要はないが、
    「未消費 artifact を refresh が削除してよいか未定」の状態は残さない。

    3. Publish / cleanup / release ordering

    現在の production ordering を確認し、usable-looking な

    • STATUS
    • NEXT_ACTION
    • ARTIFACT

    を外部公開した後で confinement/cleanup/postcondition failure が発生する契約にしない。

    必要な validation と、公開前に完了すべき cleanup/postconditions を明示すること。

    一方で child process の non-zero exit code を一律 failure と扱わない。
    既存 preflight protocol の warn / needs_fix 等は正常な control result になり得るため、

    • valid child diagnostic/control result
    • supervisor / confinement / cleanup / invariant failure

    を分離すること。

    failure path でも lock を永久保持せず、必要な failure handling 後は existing finally release semantics を維持する。

    4. byte-for-byte contract

    #2200 の refinement_preflight_result/v1 byte-for-byte 要求と、current executor の text/binary capture を照合する。

    text-mode capture のまま一般的な byte-for-byte preservation を AC として主張しない。

    strict byte preservation が本当に必要なら、既存 binary_output capability の bounded reuse を第一候補とする。
    検証用 parsed representation と outward に再公開する original bytes を分離できるか調査する。

    stdout contract を別 JSON transport に再設計しない。

    strict byte identity が product requirement ではなく、単に既存 semantic contract を変えないことが本旨なら、AC の表現を実際に保証できる semantics に修正する。

    どちらを選んだかを Issue に明示し、AC と Verification Command を一致させる。

    5. Confinement の validation surface

    既存 _validate_stdout_artifact_projection() を呼ぶだけで AC を満たしたことにしない。

    既存 schema と downstream consumer を調べ、
    「今回の run が生成し、後続処理が実際に読む known artifact fields」を列挙・分類する。

    少なくとも必要に応じて:

    • component-wise no-follow
    • regular-file only
    • expected target Issue ownership
    • verified dedicated Issue root
    • count bound
    • per-file / aggregate size bound
    • freshness / provenance
    • stale artifact rejection

    を扱う。

    一方 must_read や JSON 内の任意文字列まで生成 artifact と誤分類しない。

    既存 secure_read_repair_apply_artifact() 等の reader/validator が利用可能なら再利用し、
    類似 security framework を複製しない。

    「全内容を読み込んだ後に size over を判定」するだけで bounded read と主張しない。

    stdout buffering 全面再設計まで本 Issue に含める必要がないなら、
    artifact bound と stdout-memory bound を意図的に区別して Scope/Out of Scope に書く。

    6. #2190 contract alignment

    #2190 の current body を fresh に確認する。

    もし、PR #2495 で既に parent-controller 型へ移行済みなのに、
    #2190 の AC/VC に bootstrap 後 re-exec を要求する stale contract が残っているなら、
    #2200 の final verification より先に整合させる必要がある。

    この user instruction は、以下の semantic decision を owner-authorized とする:

    • surviving parent controller を正規 architecture とする
    • existing lifecycle lock + supervised dedicated child model を維持する
    • re-exec / inherited lock FD / 新しい lock protocol へ巻き戻さない

    canonical workflow が cross-Issue mutation を許可するなら、
    #2190 に対して別の bounded issue-refinement-loop を起動し、semantic contract repair を完了すること。
    その場合も approval checkpoint は要求しない。

    cross-Issue direct mutation が canonical workflow 上許可されない場合は、
    #2200 に stale parent contract を無視して PASS する文言を書かず、
    canonical dependency/follow-up materialization route を使用すること。

    7. #2393

    contract_update.run.with_anchor /
    contract_update.run.with_human_context
    の dedicated runtime migration について新規 follow-up Issue を重複作成しない。

    #2393 が現在もその責務を所有していることを確認したうえで、
    #2200 の Remaining Parent Gaps / Out of Scope / references を #2393 参照へ更新する。

    ただし #2393 完了を無条件の hard dependency にする必要があるとは仮定しない。

    skill_runtime_exec.py 等の shared paths を両 Issue が同時に変更する場合の collision を明示し、
    repository の scope-rollup / collision policy に従って sequencing を決める。

    「並列編集しない」が十分なら、そのためだけに新規 broker/branch coordination mechanism を作らない。

    8. Runtime Verification AC numbering

    #2200 ローカル AC が AC1〜AC5 なのに
    Runtime Verification Applicability.applicable_acs
    が親 #2190 の AC 番号を直接指している状態が残っていないか確認する。

    ローカル AC applicability と parent AC crosswalk を分離する。

    例:

    machine consumer が local/parent numbering を混同しない形にする。

    Deterministic repair / semantic repair policy

    issue-refinement-loop の canonical preflight が:

    • NEXT_ACTION: apply_deterministic_repair
    • NEXT_ACTION: apply_deterministic_structural_repair

    を返し、repair disposition が safe/eligible なら、人間確認なしで canonical repair consumer を実行する。

    repair 後は必ず fresh preflight を行い、old artifact / old verdict を再利用しない。

    deterministic repair だけでは anchor finding を解消できない場合、そこで停止しない。

    今回の anchor は:

    • architecture contract
    • artifact lifetime
    • release ordering
    • AC/VC semantics
    • Allowed Paths

    を含むため、semantic review applicability を明示的に評価すること。

    semantic design review が applicable なら、
    canonical issue-design-reviewer sibling SubAgent を起動し、
    その完了を待つ completion join barrier を守ること。

    blocker/high semantic finding が open の場合は
    rewrite_lane: semantic /
    SEMANTIC_REWRITE_CONSTRAINTS_V1
    を再構築せずそのまま issue-editor へ渡す。

    issue-editor の semantic rewrite では、
    finding の単語を機械置換するのではなく evidence と production topology に基づき:

    • Outcome
    • Current Validated Scope
    • Remaining Parent Gaps
    • In Scope
    • Out of Scope
    • Acceptance Criteria
    • Verification Commands
    • Allowed Paths
    • Stop Conditions
    • Required Design References / dependency records

    を一貫して更新する。

    既存 Machine-Readable Contract の required keys や unrelated design decisions を不用意に変更しない。

    Review loop

    各 mutation 後:

    1. GitHub から current Issue body を fresh readback
    2. fresh canonical preflight
    3. deterministic review
    4. applicable なら fresh semantic design review
    5. result join
    6. needs-fix なら次 iteration の rewrite
    7. approve / proceed なら終了

    を行う。

    SubAgent / review result は body SHA 等の freshness binding を守り、古い review artifact を次 iteration に流用しない。

    VERDICT: approve を deterministic checker が返しただけで終了せず、
    今回の architecture/semantic finding に semantic review が applicable なら Step 2.5 を必ず完了する。

    Quality priorities

    個人趣味開発であることを踏まえ、品質・有用性・workflow completion を優先する。

    追加しないもの:

    既存 primitive、existing production-chain E2E、focused unit/integration tests を再利用する。

    テスト設計は、
    「安全そうな helper が単体で存在する」
    ではなく、
    「production chain が初回・needs_fix・repair・再実行で手動 artifact 移動なしに完走する」
    ことを中心にする。

    Completion criteria

    以下をすべて満たしてから終了する:

    最後に、コード実装へ進まず、簡潔に以下だけ報告する:

    この形なら、単に「コメントを Issue に反映する」のではなく、既存の deterministic repair と semantic review/editor を使って 実装可能になるまで自動で収束させる指示になります。

  5. self-assigned this
    on Sep 6, 2026
  6. squne121 commented on Sep 6, 2026

    @squne121
    OwnerAuthor

    結論

    現状の Issue #2200 は REQUEST_CHANGES が妥当です。 前回レビューで問題だった「実 executor が Allowed Paths にない」「artifact lifetime が未定義」はかなり改善されています。実 production path、cleanup/publish ordering、既存 repair consumer E2E まで AC に入った点は良いです。

    ただし、現在は別の問題が残っています。特に AC3 の artifact lifetime 契約が、現在の architecture では過剰に強く、しかも stale → fresh-preflight の責任主体が Allowed Paths に存在しません。加えて #2393/PR #2520/PR #2533 が既に完了しているため、Issue 本文の実装前提そのものが stale です。

    重要度 | Finding | 判定 -- | -- | -- P1-1 | #2393 を OPEN/in-flight とする baseline が stale。現在は #2393 closed、PR #2520 merged で contract-update 2 profile も dedicated runtime に入っている | 実装前修正必須 P1-2 | AC3 の「未消費 artifact を refresh が消さない」と「refresh 後は stale → fresh preflight」を同時要求しているが、現在は「未消費」を判定する acknowledgement/lease がない | 契約を単純化すべき P1-3 | stale artifact を実際に読む repair_action.apply は、missing/unsafe input を secure_open_rejected で停止するだけで fresh preflight への routing を所有していない | routing owner が欠落 P1-4 | _dispatch_child_and_check_postconditions() は現在6 profile共有。#2200 の generic confinement変更が contract-update の「mutation済み inner result 保全」を壊し得る | explicit regression contract 必須 P2-1 | ignored artifact 問題を git status --ignored で worktree dirty 化して解決すると refresh を常時妨害しかねない | targeted invalidation にする P2-2 | mtime/size ベース freshness を canonical 判定へ昇格すると既存 provenance より弱い | existing run identity/digest を使う P2-3 | AC7 の親Issue closeを pytest 的ACとして扱うとハーネスが肥大化する | post-merge delivery conditionへ移す P2-4 | filesystem hardening は既に consumer がかなり持っている | openat2 等を追加しない

    P1-1: Issue の baseline が既に現行 main と食い違っている

    #2200 は現在も「#2393 は OPEN」「#2393 と shared path collision 中」「PR #2495 時点の b127017d を main HEAD」と記述しています。

    しかし #2393 は completed/closed で、PR #2520 も merge 済みです。 現行コードでは PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDS に、4つの preflight に加えて contract_update.run.with_anchor / .with_human_context が入っています。

    さらに PR #2533 まで merge され、contract-update について artifact-projection failure 後も inner mutation result を保全し、blind resend しない real-dispatcher regression が追加されています。 確認時点の main は 9e4a0065b478038d0d1eb6228fe07eaf4fb33627 です。

    これは単なる説明文の古さではありません。#2200 が編集する skill_runtime_exec.py の共通 dispatcher が、今は GitHub mutation lane まで supervision しているためです。

    したがって Current Validated Scope はもう一度 fresh 化し、#2393 collision 記述を削除し、PR #2520/#2533 を既存 non-regression baseline として取り込むべきです。長寿命 Issue に「main HEAD = 固定SHA」を書き続けるより、実装開始時/PR作成時に baseline_commit を記録する方が陳腐化しません。

    P1-2: AC3 は「artifact を保存する」のではなく「generation を失効させる」に寄せるべき

    現在の AC3 は、accepted OID 更新などで worktree を再作成した際に、**「未消費の公開済み成果物を暗黙に削除しない」**ことと、stale なら fresh preflight へ戻すことの両方を要求しています。

    ここで「未消費」をどう判定するかが定義されていません。preflight と repair_action.apply は別 dispatch なので、artifact consumer acknowledgement を保持しない限り、bootstrap は「まだ読む予定なのか」「もう不要なのか」を知れません。これを厳密に実装すると、まさに今回避けたい lease/refcount/receipt-store のような仕組みが必要になります。

    前回レビューで示されていた選択肢は「保全 または stale として fresh preflight に戻す」でした。 現在の AC3 は refinement 過程で実質的に両方を要求する形になっています。

    このプロジェクトなら、artifact の永続保全を捨てて generation invalidation を正規契約にするのが適切です。accepted OID refresh は artifact generation の境界とし、旧 worktree 内 artifact は消えてよい。ただし旧 handoff から mutation してはいけず、fresh preflight を生成し直す。この方が圧倒的に単純です。

    P1-3: その stale → fresh-preflight route が、現在の Allowed Paths にはない

    これは AC3 の実装可能性に直結します。

    現在の run_repair_action_apply() は preflight result と candidate body を component-wise no-follow で secure-read していますが、artifact が missing/unsafe なら phase="candidate_load", failure_code="secure_open_rejected" の not_attempted に落とします。そこで fresh preflight を起動する処理はありません。 secure_open_rejected 自体は既存 schema の正式な failure code です。

    一方、#2200 の Allowed Paths には run_refinement_preflight.py も .claude/skills/issue-refinement-loop/SKILL.md もありません。

    ここは low-level bootstrap に workflow routing を押し込むべきではありません。最小構成なら、既存の not_attempted + secure_open_rejected を mutation retry せず fresh preflight.run へ戻す routing を issue-refinement-loop 側に追加するのがよいです。新しい schema/version/reason code を consumer に増やす必要もありません。persistent artifact lifecycle manager も不要です。

    この方針なら「盲目的な mutation retry 禁止」とも矛盾しません。再実行するのは mutation ではなく read-only producer/preflight です。

    P1-4: #2200 は contract-update を変更対象外ではなく「明示的 non-regression 対象」にする必要がある

    PR #2520 は、outer timeout / unauthorized-write / artifact-projection failure が起きても、inner GitHub transaction がすでに成立していた場合は inner_transaction_result_ref / inner_transaction_disposition を回収し、状態不明なら inner_transaction_state=unknown として mutation を再送しない契約を実装しました。 PR #2533 は artifact-projection branch も real dispatcher で直接検証しています。

    #2200 はまさに _validate_stdout_artifact_projection() と publish ordering を変更します。したがって「4 preflight の artifact confinement」という認識だけで実装すると危険です。

    ここは scope を広げて contract-update cleanup を再設計する必要はありません。新しい cleanup/lifetime semantics の対象 command-id は4 production preflight のみと固定しつつ、6-profile共有 dispatcherについて PR #2520/#2533 の inner-result-preservation test を regression として必須にするのが最小です。

    Git の worktree cleanup は「ignored 全件を dirty 扱い」にしてはいけない

    現行 recovery は dedicated worktree の cleanliness を git status --porcelain --untracked-files=all で確認しています。 Git の公式仕様では ignored files は --ignored を指定しない限り status に現れません。(Git) 一方 git worktree remove は clean worktree を削除可能で、locked worktree の remove は force 指定を要求します。(Git)

    したがって前回レビューで再現された「ignored artifact があっても cleanliness probe は空、worktree refresh で artifact が消える」は構造上妥当です。

    ただし解決策を git status --ignored=matching に変えるのは勧めません。artifact が普通に存在するだけで worktree を恒久的に dirty 扱いし、accepted OID refresh が止まるからです。

    Git cleanliness と artifact lifetime を分離してください。 Git source の dirty/unknown-owner 判定は現状維持し、refresh 前には schemaで既知の artifact refs だけを bounded に確認する。旧 generation は stale として捨ててよく、その後の consumer が fresh preflight に復帰する。この設計なら ignored tree 全走査も不要です。

    freshness は mtime ではなく、既にある provenance を使える

    現行 schema には既に repair_action.preflight_run_identity があり、consumer 側には candidate digest 検証も存在します。

    PR #2520 の (mtime_ns, size) は「今回の dispatch 中に inner result が生成されたらしいか」を outer failure diagnostic で保守的に判断するための仕組みです。これを #2200 の canonical freshness authority に流用しない方がよいです。

    #2200 の AC4 にある「mtime 単独に依存しない」は正しいので、既存の issue_number/repo + schema + preflight_run_identity + content digest を優先し、新しい artifact registry や timestamp protocol は増やさない方が整合します。

    filesystem hardening はこれ以上増やさなくてよい

    現行 repair consumer は既に ancestor を O_DIRECTORY | O_NOFOLLOW で1段ずつ dir-fd 相対 open し、leaf も O_NOFOLLOW で開き、同じ FD から fstat、size check、byte read、UTF-8 decode、SHA-256、post-read inode check まで行っています。

    Linux の O_NOFOLLOW は本来 final component にしか効かず、全 path component をまとめて禁止できる openat2(RESOLVE_NO_SYMLINKS) もあります。(man7.org) ただし openat2 は Linux 固有で glibc wrapper もなく、man page 自身も一般用途での過剰な symlink 禁止は互換性問題を生み得ると警告しています。(man7.org) Python は os.open(..., dir_fd=...) を正式にサポートしています。(Python documentation)

    したがって #2200 で openat2 wrapper、新 security module、hardlink registry 等を追加する価値はありません。現行の stdlib/dir-fd パターンを pre-publish validator に必要な範囲だけ適用すれば十分です。

    テスト設計も少し削った方がよい

    PR #2495 は production wiring を実際に行った結果、fixture の Scope Delta が3ラウンドまで広がった前例があります。 #2200 で同じことを繰り返さないため、証明の中心は「artifact confinement unit」「OID refresh + barrier の lifecycle integration」「real preflight → needs_fix → repair_action.apply の1本の production-chain E2E」で十分です。既存 bootstrap E2E は既に real repair consumer まで届いているので、そこを強化する方が新巨大fixtureより有用です。

    また AC7 の「#2190 をクローズすることを pytest 等で実証」は、code acceptance と GitHub delivery postcondition が混ざっています。 親 #2190 は既に surviving_parent_controller / re_exec: forbidden に semantic contract が更新済みです。 そのため全 Child の歴史的テストを毎 iteration 再演するより、#2200 merge 後に既存 PR evidence + fresh critical regression を #2190 に記録して close、を Delivery Rule にする方が実用的です。

    推奨する再-refinement

    実装前に #2200 をもう1回だけ semantic rewrite する価値があります。中心はセキュリティ強化ではなく、「artifact を保存する」という要求を捨て、「worktree refresh は generation invalidation。旧 handoff は mutation せず fresh preflight へ戻る」と固定することです。

    その上で、#2393/PR #2520/#2533 を current baseline に反映し、stale recovery の owner として issue-refinement-loop routing の最小 Scope Delta を許可し、contract-update は既存 inner-result-preservation の regression のみに留める。この形なら、broker・lease DB・cleanup daemon・新しい receipt framework は不要で、通常ワークフローの成功率を落とさず #2200 の本来の correctness gap を閉じられます。

    ## 結論

    現状の Issue #2200 は REQUEST_CHANGES が妥当です。 前回レビューで問題だった「実 executor が Allowed Paths にない」「artifact lifetime が未定義」はかなり改善されています。実 production path、cleanup/publish ordering、既存 repair consumer E2E まで AC に入った点は良いです。

    ただし、現在は別の問題が残っています。特に AC3 の artifact lifetime 契約が、現在の architecture では過剰に強く、しかも stale → fresh-preflight の責任主体が Allowed Paths に存在しません。加えて #2393/PR #2520/PR #2533 が既に完了しているため、Issue 本文の実装前提そのものが stale です。

    重要度 Finding 判定
    P1-1 #2393 を OPEN/in-flight とする baseline が stale。現在は #2393 closed、PR #2520 merged で contract-update 2 profile も dedicated runtime に入っている 実装前修正必須
    P1-2 AC3 の「未消費 artifact を refresh が消さない」と「refresh 後は stale → fresh preflight」を同時要求しているが、現在は「未消費」を判定する acknowledgement/lease がない 契約を単純化すべき
    P1-3 stale artifact を実際に読む repair_action.apply は、missing/unsafe input を secure_open_rejected で停止するだけで fresh preflight への routing を所有していない routing owner が欠落
    P1-4 _dispatch_child_and_check_postconditions() は現在6 profile共有。#2200 の generic confinement変更が contract-update の「mutation済み inner result 保全」を壊し得る explicit regression contract 必須
    P2-1 ignored artifact 問題を git status --ignored で worktree dirty 化して解決すると refresh を常時妨害しかねない targeted invalidation にする
    P2-2 mtime/size ベース freshness を canonical 判定へ昇格すると既存 provenance より弱い existing run identity/digest を使う
    P2-3 AC7 の親Issue closeを pytest 的ACとして扱うとハーネスが肥大化する post-merge delivery conditionへ移す
    P2-4 filesystem hardening は既に consumer がかなり持っている openat2 等を追加しない

    P1-1: Issue の baseline が既に現行 main と食い違っている

    #2200 は現在も「#2393 は OPEN」「#2393 と shared path collision 中」「PR #2495 時点の b127017d を main HEAD」と記述しています。

    しかし #2393 は completed/closed で、PR #2520 も merge 済みです。 現行コードでは PRODUCTION_DEDICATED_WORKTREE_COMMAND_IDS に、4つの preflight に加えて contract_update.run.with_anchor / .with_human_context が入っています。

    さらに PR #2533 まで merge され、contract-update について artifact-projection failure 後も inner mutation result を保全し、blind resend しない real-dispatcher regression が追加されています。 確認時点の main は 9e4a0065b478038d0d1eb6228fe07eaf4fb33627 です。

    これは単なる説明文の古さではありません。#2200 が編集する skill_runtime_exec.py の共通 dispatcher が、今は GitHub mutation lane まで supervision しているためです。

    したがって Current Validated Scope はもう一度 fresh 化し、#2393 collision 記述を削除し、PR #2520/#2533 を既存 non-regression baseline として取り込むべきです。長寿命 Issue に「main HEAD = 固定SHA」を書き続けるより、実装開始時/PR作成時に baseline_commit を記録する方が陳腐化しません。

    P1-2: AC3 は「artifact を保存する」のではなく「generation を失効させる」に寄せるべき

    現在の AC3 は、accepted OID 更新などで worktree を再作成した際に、**「未消費の公開済み成果物を暗黙に削除しない」**ことと、stale なら fresh preflight へ戻すことの両方を要求しています。

    ここで「未消費」をどう判定するかが定義されていません。preflight と repair_action.apply は別 dispatch なので、artifact consumer acknowledgement を保持しない限り、bootstrap は「まだ読む予定なのか」「もう不要なのか」を知れません。これを厳密に実装すると、まさに今回避けたい lease/refcount/receipt-store のような仕組みが必要になります。

    前回レビューで示されていた選択肢は「保全 または stale として fresh preflight に戻す」でした。 現在の AC3 は refinement 過程で実質的に両方を要求する形になっています。

    このプロジェクトなら、artifact の永続保全を捨てて generation invalidation を正規契約にするのが適切です。accepted OID refresh は artifact generation の境界とし、旧 worktree 内 artifact は消えてよい。ただし旧 handoff から mutation してはいけず、fresh preflight を生成し直す。この方が圧倒的に単純です。

    P1-3: その stale → fresh-preflight route が、現在の Allowed Paths にはない

    これは AC3 の実装可能性に直結します。

    現在の run_repair_action_apply() は preflight result と candidate body を component-wise no-follow で secure-read していますが、artifact が missing/unsafe なら phase="candidate_load", failure_code="secure_open_rejected" の not_attempted に落とします。そこで fresh preflight を起動する処理はありません。 secure_open_rejected 自体は既存 schema の正式な failure code です。

    一方、#2200 の Allowed Paths には run_refinement_preflight.py も .claude/skills/issue-refinement-loop/SKILL.md もありません。

    ここは low-level bootstrap に workflow routing を押し込むべきではありません。最小構成なら、既存の not_attempted + secure_open_rejected を mutation retry せず fresh preflight.run へ戻す routing を issue-refinement-loop 側に追加するのがよいです。新しい schema/version/reason code を consumer に増やす必要もありません。persistent artifact lifecycle manager も不要です。

    この方針なら「盲目的な mutation retry 禁止」とも矛盾しません。再実行するのは mutation ではなく read-only producer/preflight です。

    P1-4: #2200 は contract-update を変更対象外ではなく「明示的 non-regression 対象」にする必要がある

    PR #2520 は、outer timeout / unauthorized-write / artifact-projection failure が起きても、inner GitHub transaction がすでに成立していた場合は inner_transaction_result_ref / inner_transaction_disposition を回収し、状態不明なら inner_transaction_state=unknown として mutation を再送しない契約を実装しました。 PR #2533 は artifact-projection branch も real dispatcher で直接検証しています。

    #2200 はまさに _validate_stdout_artifact_projection() と publish ordering を変更します。したがって「4 preflight の artifact confinement」という認識だけで実装すると危険です。

    ここは scope を広げて contract-update cleanup を再設計する必要はありません。新しい cleanup/lifetime semantics の対象 command-id は4 production preflight のみと固定しつつ、6-profile共有 dispatcherについて PR #2520/#2533 の inner-result-preservation test を regression として必須にするのが最小です。

    Git の worktree cleanup は「ignored 全件を dirty 扱い」にしてはいけない

    現行 recovery は dedicated worktree の cleanliness を git status --porcelain --untracked-files=all で確認しています。 Git の公式仕様では ignored files は --ignored を指定しない限り status に現れません。(Git) 一方 git worktree remove は clean worktree を削除可能で、locked worktree の remove は force 指定を要求します。(Git)

    したがって前回レビューで再現された「ignored artifact があっても cleanliness probe は空、worktree refresh で artifact が消える」は構造上妥当です。

    ただし解決策を git status --ignored=matching に変えるのは勧めません。artifact が普通に存在するだけで worktree を恒久的に dirty 扱いし、accepted OID refresh が止まるからです。

    Git cleanliness と artifact lifetime を分離してください。 Git source の dirty/unknown-owner 判定は現状維持し、refresh 前には schemaで既知の artifact refs だけを bounded に確認する。旧 generation は stale として捨ててよく、その後の consumer が fresh preflight に復帰する。この設計なら ignored tree 全走査も不要です。

    freshness は mtime ではなく、既にある provenance を使える

    現行 schema には既に repair_action.preflight_run_identity があり、consumer 側には candidate digest 検証も存在します。

    PR #2520 の (mtime_ns, size) は「今回の dispatch 中に inner result が生成されたらしいか」を outer failure diagnostic で保守的に判断するための仕組みです。これを #2200 の canonical freshness authority に流用しない方がよいです。

    #2200 の AC4 にある「mtime 単独に依存しない」は正しいので、既存の issue_number/repo + schema + preflight_run_identity + content digest を優先し、新しい artifact registry や timestamp protocol は増やさない方が整合します。

    filesystem hardening はこれ以上増やさなくてよい

    現行 repair consumer は既に ancestor を O_DIRECTORY | O_NOFOLLOW で1段ずつ dir-fd 相対 open し、leaf も O_NOFOLLOW で開き、同じ FD から fstat、size check、byte read、UTF-8 decode、SHA-256、post-read inode check まで行っています。

    Linux の O_NOFOLLOW は本来 final component にしか効かず、全 path component をまとめて禁止できる openat2(RESOLVE_NO_SYMLINKS) もあります。([man7.org]3) ただし openat2 は Linux 固有で glibc wrapper もなく、man page 自身も一般用途での過剰な symlink 禁止は互換性問題を生み得ると警告しています。([man7.org]4) Python は os.open(..., dir_fd=...) を正式にサポートしています。([Python documentation]5)

    したがって #2200 で openat2 wrapper、新 security module、hardlink registry 等を追加する価値はありません。現行の stdlib/dir-fd パターンを pre-publish validator に必要な範囲だけ適用すれば十分です。

    テスト設計も少し削った方がよい

    PR #2495 は production wiring を実際に行った結果、fixture の Scope Delta が3ラウンドまで広がった前例があります。 #2200 で同じことを繰り返さないため、証明の中心は「artifact confinement unit」「OID refresh + barrier の lifecycle integration」「real preflight → needs_fix → repair_action.apply の1本の production-chain E2E」で十分です。既存 bootstrap E2E は既に real repair consumer まで届いているので、そこを強化する方が新巨大fixtureより有用です。

    また AC7 の「#2190 をクローズすることを pytest 等で実証」は、code acceptance と GitHub delivery postcondition が混ざっています。 親 #2190 は既に surviving_parent_controller / re_exec: forbidden に semantic contract が更新済みです。 そのため全 Child の歴史的テストを毎 iteration 再演するより、#2200 merge 後に既存 PR evidence + fresh critical regression を #2190 に記録して close、を Delivery Rule にする方が実用的です。

    推奨する再-refinement

    実装前に #2200 をもう1回だけ semantic rewrite する価値があります。中心はセキュリティ強化ではなく、「artifact を保存する」という要求を捨て、「worktree refresh は generation invalidation。旧 handoff は mutation せず fresh preflight へ戻る」と固定することです。

    その上で、#2393/PR #2520/#2533 を current baseline に反映し、stale recovery の owner として issue-refinement-loop routing の最小 Scope Delta を許可し、contract-update は既存 inner-result-preservation の regression のみに留める。この形なら、broker・lease DB・cleanup daemon・新しい receipt framework は不要で、通常ワークフローの成功率を落とさず #2200 の本来の correctness gap を閉じられます。

  7. squne121 commented on Sep 7, 2026

    @squne121
    OwnerAuthor

    推奨は、#2200 を実装へ進めず、対象コメントを trusted human-context anchor にして issue-refinement-loop をもう1回だけ収束させることです。

    理由は明確です。現在の #2200 本文はまだ #2393 を OPEN/in-flight と記述していますが、#2393 は completed/closed、PR #2520 と #2533 は merge 済みです。 また対象コメント時点では main が 9e4a0065... でしたが、現在はさらに fa932bb3... へ進んでいるため、固定 SHA を本文の「current main」にする設計自体を外すべきです。

    また現行 AC3 は「未消費 artifact を消さない」と「refresh 後 stale なら fresh preflight」を同時要求しています。 対象レビューが提案する generation invalidation を正規契約にし、旧 handoff では mutation せず fresh preflight に戻す方が、lease/receipt/broker を増やさず現行 architecture と整合します。

    以下をそのまま、既に auto mode で起動中の Claude Code に渡すのがよいです。

    Issue #2200 を、次の human-context anchor comment を対象に .claude/skills/issue-refinement-loop で再 refinement してください。

    • Repository: squne121/loop-protocol
    • Issue: #2200
    • Anchor comment:
      https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5562621548
    • max_iterations: 3
    • 既に Claude Code は auto mode で起動済みです。
    • repo loop iteration の途中で人間承認を求めず、canonical routing が許す限り自動継続してください。

    最重要方針

    これは実装作業ではなく、Issue #2200 を implementation-ready に収束させる refinement task です。

    .claude/skills/issue-refinement-loop/SKILL.md を SSOT として読み、独自の簡略化した refinement 手順を作らず、canonical planner / preflight / review / rewrite / final readiness routing に従ってください。

    anchor comment は operator が明示的に選択した human context です。URL だけから origin を推測せず、repository/issue/comment binding と authority を検証したうえで canonical preflight.run.with_human_context lane を使用してください。

    通常の iteration、read-only investigation、Issue 本文の controlled rewrite、canonical deterministic repair、canonical structural repair、review の再実行について、人間承認を挟まないでください。

    SubAgent の使用

    必ず SubAgent を使用してください。

    Step 0f の planner result に従い、少なくとも repository/current-code の検証が必要な場合は codebase-investigator を起動してください。

    外部技術 claim の検証が planner により required と判定された場合は web-researcher も起動してください。

    Step 1 と Step 1b が両方 required なら並列実行して構いません。ただし、

    すべての起動済み SubAgent の完了を必ず待ち、その structured result を回収・join してから Step 2 に進んでください。

    SubAgent を fire-and-forget して main thread だけ先に終了してはいけません。

    Issue rewrite が必要なら canonical Step 4 の issue-editor SubAgent を使用し、その完了・author result・GitHub readback を待ってから fresh review に戻ってください。

    終了時にも未完了の SubAgent が残っていないことを確認してください。

    最初に fresh baseline を取り直す

    anchor comment 内の SHA や Issue 本文の「current main」を現在値として信用しないでください。

    実行開始時点の live repository state を再取得し、少なくとも以下を確認してください。

    長寿命 Issue の本文に「main HEAD = <固定SHA>」を current-state contract として残さず、必要なら baseline_commit を implementation start / PR evidence として取得する契約へ修正してください。

    Anchor comment の主要 findings を fact-check する

    anchor comment をそのまま採用するのではなく、current main のコード・関連 Issue/PR・tests と照合してください。

    特に以下を検証してください。

    1. #2393 baseline の stale 化

    #2393 が既に completed で、PR #2520 が merge 済みなら、

    • #2393 OPEN
    • #2393 と in-flight scope collision
    • contract_update.run.* はまだ dedicated runtime 外

    という #2200 の記述を削除・更新してください。

    PR #2520 / #2533 によって成立した contract-update behavior は、#2200 が shared dispatcher を変更しても壊してはいけない current non-regression baseline としてください。

    2. AC3 を generation invalidation 契約へ単純化する

    現在の AC3 にある、

    • 「未消費の公開済み artifact を refresh が削除してはいけない」
    • 「refresh 後 stale なら fresh preflight に戻る」

    を同時に満たすために acknowledgement / lease / receipt / refcount 等を新設する設計にはしないでください。

    current architecture で consumer acknowledgement が存在しないことを確認したうえで、原則として次の契約へ寄せてください。

    • accepted OID refresh / dedicated worktree recreation は artifact generation boundary
    • old generation の artifact は永続保全を要求しない
    • old generation が消えること自体は許容する
    • ただし old handoff から GitHub mutation を続行してはいけない
    • stale / missing / provenance-invalid handoff を検出した consumer は mutation retry ではなく fresh preflight に戻る
    • stale artifact を暗黙 reuse しない
    • primary checkout や同名 path へ fallback しない
    • persistent artifact lifecycle manager を追加しない

    Git cleanliness と artifact lifetime を混同しないでください。
    ignored artifact があることだけを理由に dedicated worktree 全体を dirty と扱う git status --ignored 型の解決へ寄せないでください。

    3. stale → fresh-preflight routing owner を明示する

    current repair_action.apply が missing / unsafe / provenance-invalid artifact に対し、どの phase / failure_code / mutation_outcome を返すか current code で確認してください。

    low-level worktree_bootstrap_exec.py に workflow routing を押し込まないでください。

    既存 consumer の「mutation 未実行」を示す formal outcome を利用して、issue-refinement-loop orchestrator が fresh preflight.run に復帰するのが最小なら、それを正規 ownership としてください。

    特に anchor comment が指摘する not_attempted + secure_open_rejected 等について、

    • stale generation に起因する再生成可能ケース
    • genuine unsafe/path/provenance violation
    • environment/integrity failure

    を現行 failure vocabulary で区別できるか調査してください。

    既存 failure code を雑にすべて fresh-preflight retry に変換してはいけません。
    blind mutation retry も禁止です。

    必要な Scope Delta は current implementation から最小限に導出してください。

    少なくとも .claude/skills/issue-refinement-loop/SKILL.md が routing contract の owner になるか確認してください。
    run_refinement_preflight.py、references、tests 等の追加 edit path が本当に必要なら codebase evidence に基づいて有限に追加してください。
    将来必要そうという理由だけで Allowed Paths を広げないでください。

    4. contract-update を shared-dispatcher non-regression 対象にする

    #2200 の新しい artifact confinement / cleanup / publish semantics の適用対象を、意図せず contract-update mutation profiles へ拡張しないでください。

    一方で skill_runtime_exec.py の shared dispatcher を変更する以上、PR #2520 / #2533 が保証した以下は必須 regression としてください。

    • inner transaction result preservation
    • outer timeout / unauthorized-write / artifact-projection failure 時の result preservation
    • unknown inner state で blind mutation resend しない
    • artifact-projection failure の real-dispatcher regression
    • dedicated contract-update profiles の既存 behavior

    原則:

    • 新 cleanup/lifetime semantics: 対象 production preflight profiles のみに限定
    • shared dispatcher: 6-profile 境界の existing regression を維持

    としてください。

    5. freshness authority を増やしすぎない

    mtime を canonical freshness authority にしないでください。

    current schema/consumer に既に存在する provenance を調べ、

    • repo
    • issue_number
    • schema/version
    • preflight_run_identity
    • candidate/content digest
    • generation と current dedicated runtime identity の binding

    など、既存の強い identity を再利用してください。

    新しい timestamp protocol、artifact registry、receipt store は原則追加しないでください。

    6. filesystem hardening を目的化しない

    current consumer の component-wise dir-fd relative open、O_NOFOLLOW、same-FD fstat / bounded read / digest / post-read identity check 等を確認してください。

    既存 stdlib mechanism で要件を満たせるなら、

    • openat2 wrapper
    • 新 security module
    • hardlink registry
    • generic broker
    • generic authorization/token framework

    を追加しないでください。

    個人趣味開発として、workflow correctness と保守容易性を優先してください。

    7. テスト契約を実用的な最小構成にする

    巨大な profile × failure combination fixture matrix を新設しないでください。

    証明の中心は原則として次の3層に絞ってください。

    1. artifact confinement / provenance / bounds の focused unit tests
    2. accepted-OID refresh + lifecycle lock の barrier-based integration test
    3. real preflight → needs_fix → repair_action.apply production-chain E2E 1本

    必要な contract-update regression は既存 PR #2520/#2533 tests を再利用・維持してください。

    fixed sleep による concurrency test は避け、barrier/synchronization primitive を使ってください。

    8. #2190 closure を code AC と delivery postcondition に分離する

    #2200 AC7 で「#2190 を close すること」を pytest の runtime evidence のように扱わないでください。

    code acceptance と GitHub delivery postcondition を分離してください。

    望ましい形は概ね:

    です。

    #2190 の historical test を毎 iteration 全件再演する必要性も current cost/benefit で見直してください。

    issue-refinement-loop を canonical に最後まで回す

    手作業で Issue 本文を直接書き換えて終わらず、skill の canonical flow を実行してください。

    概念的には:

    1. Preconditions
    2. human-context preflight
    3. planner result consume
    4. required investigation
    5. required web research
    6. 全 SubAgent 完了待ち
    7. canonical Step 2 root review
    8. deterministic repair / structural repair が選ばれたら canonical consumer
    9. semantic review applicable なら canonical Step 2.5
    10. needs-fix なら issue-editor による Step 4
    11. readback
    12. fresh preflight
    13. fresh final review
    14. implementation readiness 判定

    を max_iterations の範囲で自動反復してください。

    canonical_step2_route や planner decision を prose で再判定せず、SSOT の routing result に従ってください。

    Approval-free execution policy

    次の操作について「実行してよいですか?」と人間へ確認しないでください。

    • repository / GitHub の read
    • SubAgent 起動
    • web research
    • focused tests / static checks
    • canonical preflight/review
    • Issue body の canonical controlled rewrite
    • deterministic repair
    • structural repair
    • stale label hygiene
    • refinement loop の次 iteration
    • final readiness readback

    auto mode の既存 permission state を変更する必要はありません。
    repo loop iteration approval と Claude Code permission mode を混同しないでください。

    停止条件

    通常の「確認のための人間承認」では停止しないでください。

    ただし次の場合だけは安全側に停止し、実行済み内容・未完了内容・blocker を簡潔に報告してください。

    • secret / credential / token の表示・コピー・変更が必要
    • destructive / irreversible operation が必要
    • canonical issue-refinement-loop 自身が environment/integrity failure として fail-closed を要求
    • canonical semantic routing が genuine human_judgment_required を返し、自動で意味を決定する authority が存在しない
    • GitHub mutation の成立状態が unknown で、再送すると二重 mutation の可能性がある

    「Allowed Paths の変更が必要」というだけでは、trusted anchor と canonical Scope Delta mechanism で自動解決できる場合は停止しないでください。
    まず codebase-investigator と canonical scope-delta routing を使ってください。

    完了条件

    次をすべて満たすまで作業完了としないでください。

    最後に、以下だけを簡潔に報告してください。

    この形なら、対象コメントを単に本文へ転記するのではなく、現行 main で fact-check → semantic rewrite → controlled mutation → fresh review → READY 判定まで自動で収束させられます。特に secure_open_rejected を無条件 retry に変えない点は残しておくべきです。現行スキルではこの failure class は blind retry を避ける扱いになっているため、#2200 では「stale generation と確認できる場合だけ fresh producer に戻す」境界を refinement で明文化するのが重要です。

  8. squne121 commented on Sep 7, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  9. squne121 commented on Sep 7, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop 終了報告

    anchor comment(https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5562621548)の
    P1-1〜P1-4 / P2-1〜P2-4 全 finding を repository evidence(codebase-investigator)と一次資料
    (web-researcher)で fact-check した上で、Step 2.5 semantic design review(1回目: blocker 2件・
    high 2件・medium 1件・low 1件)→ Step 4 rewrite → 2回目 confirm semantic review(残 low 2件、
    rewrite 不要)を経て、fresh preflight / fresh deterministic review / fresh semantic confirm
    review まで収束しました。

    • Final Gate: passed(run_root_review_pipeline.py produce fresh review, VERDICT: approve,
      canonical_step2_route: step_2_5 → semantic confirm effective_verdict: approve)
    • root_entry_router.run_root_transition(): route: invoke_impl_review_loop,
      reason: fresh_review_go_live_equality(live body / reviewed body / base SHA 完全一致)
    LOOP_HANDOFF_RESULT_V1:
      status: impl_ready
      routing_action: run_impl_review_loop
      contract_review:
        status: go
        gate_result: fresh_go
        latest_comment_url: null
        generated_at: "2026-09-07T09:32:00Z"
        body_sha256: "sha256:d202985fe83cb5a23d7ef137d7ddaf4a69c38871cde392f0ceceaf5710dc2d6c"
      metadata:
        title_prefix_ready: true
      label_sync_observation:
        kind: presentation_sync
        result: noop
        detail: "no state/* label mutation performed this cycle"
      auto_fixes:
        result: auto_fixed
        required:
          - kind: known_marker_fix
            executor: implementation-worker
            result: applied
            evidence:
              before: "sha256:64605a13753c0f5e1e5d5155a8eeb3c1a90bce709939d7bee2fa9fd23022dc6f"
              after: "sha256:d202985fe83cb5a23d7ef137d7ddaf4a69c38871cde392f0ceceaf5710dc2d6c"
              comment_url: "https://github.com/squne121/loop-protocol/issues/2200"
        skipped: []
      blockers: []
      permissions:
        unavailable: []
      generated_at: "2026-09-07T09:33:00Z"
      checked_body_sha256: "sha256:d202985fe83cb5a23d7ef137d7ddaf4a69c38871cde392f0ceceaf5710dc2d6c"
      checker_exit_code: 0
      missing_sections: []
      missing_contract_keys: []

    主要変更点(rewrite要約)

    1. AC3 を「未消費 artifact の永続保全」要求から generation invalidation 契約へ単純化(accepted OID refresh は generation 境界、旧 artifact は消えてよいが旧 handoff から mutation しない)
    2. stale→fresh-preflight routing の実装責務を明示的に Out of Scope(issue-refinement-loop 側の別スコープ)へ切り出し、Allowed Paths は本Issueの4スクリプト+3テストに限定したまま維持
    3. Current Validated Scope / Remaining Parent Gaps / Required Design References / Scope Collision Record を fresh 化(実装: Migrate contract_update control-plane mutation profiles to the dedicated runtime worktree #2393 CLOSED、PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 MERGED を既存 non-regression baseline として反映、固定 SHA 記述を baseline_commit 記録方式へ変更)
    4. AC6 に PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520/test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 の inner-transaction-result-preservation の non-regression 要件を明記、新 cleanup semantics の対象を4 preflight profile のみに限定
    5. AC7 を code acceptance(#2190全AC最終検証)と ## Delivery Rule(実装: fix: bind issue-refinement control-plane preflight to a dedicated linked worktree #2190 close の post-merge delivery条件)に分離
    6. AC4 に freshness authority の限定(既存 provenance フィールド優先、新規 timestamp protocol/registry 不要)を追記

    未解決の軽微事項(rewrite対象外、warning記録のみ)

    semantic confirm review で low severity 2件(Outcome文言とAC3/In Scopeの限定句の粒度不一致、
    Remaining Parent Gaps のチェックボックス表記矛盾)が残存。finding_policy: route_high_open_to_rewrite
    により rewrite 対象外(medium/low は warning 止まり)。実装着手のブロッカーではない。

    実装着手について

    本 loop は Issue #2200 を implementation-ready にする refinement task であり、実装作業そのものは
    スコープ外のため、impl-review-loop の起動はここでは行っていません。root_entry_router の判定は
    invoke_impl_review_loop で fresh go ですが、実際の実装着手は別途明示的なトリガーを待ちます。

  10. squne121 commented on Sep 7, 2026

    @squne121
    OwnerAuthor

    推奨は、#2200 を再 refinement せず、そのまま impl-review-loop の正式な Root-Owned Entry から実装へ入れることです。最新の refinement 終了報告は impl_ready / run_impl_review_loop、blocker 0、fresh review approve まで到達しています。

    ただし、過去の LOOP_HANDOFF_RESULT_V1 だけを Step 1 の authorization にしてはいけません。impl-review-loop の現行契約では、root thread が live Issue取得 → current-run contract review → live再取得 → routing → 同一継続 turn 内で Step 1 起動まで行う必要があります。 また SubAgent は implementation-worker → test-runner → pr-reviewer が正規経路で、終了判定は PR reviewer の APPROVE だけでなく live mergeability と blocker 0 まで確認します。

    特に「SubAgent の完了待ち」は明示した方がよいです。正規契約では wait_agent の戻りだけでは不十分で、final result を受け取り、その後 list_agents で同一 canonical task が terminal completed になったことの両方を確認してから次へ進む必要があります。

    以下を、現在 Auto mode で動いている Claude Code にそのまま投入する形を推奨します。

    squne121/loop-protocol の Issue #2200 を対象に、.claude/skills/impl-review-loop を正規手順どおり実行してください。

    Target:

    • Repository: squne121/loop-protocol
    • Issue: #2200
    • Issue URL: https://github.com/squne121/loop-protocol/issues/2200
    • 最新 refinement handoff telemetry:
      https://github.com/squne121/loop-protocol/issues/2200#issuecomment-5568615928
    • max_iterations: 5

    この Claude Code session は既に Auto mode で起動済みです。permission mode の変更は不要です。

    最終目的

    Issue #2200 の live contract に基づいて、

    1. 実装
    2. Verification Commands による current-head 独立検証
    3. PR 作成・更新
    4. 独立 pr-reviewer によるレビュー
    5. REQUEST_CHANGES の自動修正
    6. required CI / live mergeability の確認
    7. stale head / BEHIND / mechanical PR hygiene の自動処理
    8. 再検証・再レビュー

    を bounded loop で繰り返し、.claude/skills/impl-review-loop が定義する route: approved、すなわち マージ直前の merge-ready 状態まで到達してください。

    実際の merge だけは行わないでください。
    gh pr merge、auto-merge 有効化、merge 後の delivery、Issue #2190 の post-merge close は実行禁止です。
    そこが今回唯一の通常系 human approval boundary です。

    重要: 過去の handoff を authorization にしない

    最新コメントの LOOP_HANDOFF_RESULT_V1.status: impl_ready / routing_action: run_impl_review_loop は readiness telemetry として参照してください。ただし、それ単独で Step 1 を開始しないでください。

    .claude/skills/impl-review-loop/SKILL.md と steps/preparation.md の Root-Owned Synchronous Entry Transition を正規経路として使い、root/main thread 自身が同一の継続した invocation / turn 内で、

    まで連続して実行してください。

    過去コメント、artifact、digest、snapshot、launch ledger の存在だけを authorization にしないでください。

    現在の live contract が refinement 終了時から変化していた場合も、canonical routing が自動回復可能なら人間承認を求めず fresh review まで行い、その結果 invoke_impl_review_loop に戻ればそのまま実装を開始してください。

    Issue #2200 固有の実装方針

    live Issue 本文を正本としてください。

    特に以下を維持してください。

    • PR feat: control-plane preflight に dedicated-lane identity probe primitive を追加 (#2199) #2495 の parent-controller architecture を維持し、re-exec architecture に戻さない。
    • PR feat: contract_update mutation profileをdedicated control-plane runtimeへ移行する #2520 / test: contract_update artifact-projection failure の real-dispatcher テストを追加する #2533 の contract_update inner-transaction-result-preservation を non-regression baseline とする。
    • artifact lifetime は「未消費 artifact の永続保存」ではなく generation invalidation とする。
    • accepted OID refresh / dedicated worktree recreation は generation boundary。
    • old-generation handoff から GitHub mutation を継続しない。
    • stale / missing / provenance-invalid artifact を暗黙 reuse しない。
    • primary checkout や同名 path へ fallback しない。
    • stale→fresh-preflight の routing 自体が live Issue で Out of Scope のままなら、本 Issue に勝手に取り込まない。
    • 新しい lease DB、broker、heartbeat、daemon、巨大な lifecycle framework を作らない。
    • STATUS / NEXT_ACTION / ARTIFACT は mandatory validation / cleanup / postcondition が完了する前に usable-looking な形で公開しない。
    • child の non-zero exit を一律 failure にせず、既存 warn / needs_fix 等の control result と confinement/cleanup failure を分離する。
    • Issue の Allowed Paths を厳守する。
    • fixed SHA を Issue 本文へ埋め込まず、実装開始時の baseline_commit は PR description / contract evidence に記録する。
    • refinement 終了報告に残った low severity warning 2件は、current-run contract review が blocker/high に昇格させない限り、実装を止める理由にしない。

    SubAgent の使用を必須とする

    root/main thread が実装・テスト・レビューを自分で代行しないでください。
    .claude/skills/impl-review-loop の canonical delegation を使ってください。

    Step 1

    implementation-worker SubAgent を起動し、.claude/skills/implement-issue/SKILL.md に従わせる。

    担当:

    • canonical issue worktree / branch の準備
    • live Allowed Paths 内の実装
    • focused verification
    • commit / bounded publish
    • PR 作成または既存対象PR更新
    • Closes #2200 を含む適切な PR body
    • baseline_commit と検証証跡の記録

    Step 2

    Step 1 完了後に test-runner SubAgent を新規 task として起動する。

    担当:

    Step 2 の current-head adjudication が blocking == false になるまで Step 4 を開始しない。

    Step 4

    current-head VC gate を再照合した直後に pr-reviewer SubAgent を起動し、.claude/skills/pr-review-judge/SKILL.md に従って独立レビューさせる。

    reviewer には必ず実値として以下を渡すこと:

    placeholder や stale head を渡さない。

    SubAgent の完了待ちを厳格に行う

    各 SubAgent を起動したら、その作業完了を必ず待ってください。

    implementation-worker、test-runner、pr-reviewer、および loop 内で追加起動した canonical worker task すべてについて Common Completion Protocol を守ること。

    各 task ごとに:

    1. spawn_agent で得た canonical task_name を保存する。
    2. wait_agent は mailbox activity の待機にだけ使う。
    3. timeout、途中経過、steer acknowledgement、部分出力を「完了」と扱わない。
    4. SubAgent の final result を実際に受け取る。
    5. その後 list_agents で同じ canonical task name を確認する。
    6. task が terminal completed であることを確認する。
    7. final result と terminal completed の両方が揃うまで次の Step、routing、commit判断、review判断へ進まない。
    8. errored / interrupted / shutdown / task-level not_found は成功扱いしない。

    特に:

    • implementation-worker 完了前に Step 2 を始めない。
    • test-runner の final report + terminal completed の両方を確認するまで Step 4 を始めない。
    • pr-reviewer の final LOOP_VERDICT + terminal completed の両方を確認するまで Step 5 routing を決めない。

    SubAgent を fire-and-forget しないこと。

    canonical skill が明示的に要求しない限り nested delegation を増やさず、root/main thread が sibling SubAgent の join を管理してください。

    人間承認を要求せず自動継続する操作

    次の通常操作について、iteration ごと・ファイルごと・commit ごとの人間承認を求めないでください。

    • Allowed Paths 内の編集
    • regression test の追加・修正
    • Issue が指定する Verification Commands の実行
    • lint / typecheck / pytest / build
    • issue worktree / branch の作成と利用
    • commit
    • bounded push / publish retry
    • PR 作成
    • PR body の更新
    • Closes #2200 の追加・修正
    • reviewer feedback に基づく fix_delta
    • reviewer の再起動
    • current-head verification の再実行
    • stale-head re-review
    • BEHIND 時の canonical update_branch
    • required CI の待機
    • transient CI failure の原因調査と、同一 head の安全な bounded rerun
    • mergeability の再取得
    • mechanical PR hygiene
    • loop の次 iteration への遷移

    「この修正をしてよいですか」「PRを作ってよいですか」「pushしてよいですか」「再レビューしますか」のような routine approval request はしないでください。

    REVIEW → FIX の自動ループ

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

    • blockers をそのまま無視せず、root が canonical fix_delta に正規化する。
    • 次 iteration の implementation-worker に渡す。
    • scope を勝手に拡張せず blocker の解消に必要な最小差分を実装する。
    • head が変わったら Step 2 を fresh に再実行する。
    • current-head VC が nonblocking になった後だけ Step 4 を fresh に再実行する。
    • reviewer verdict が stale head に bind されていたら、人間を呼ばず current head で re-review する。
    • BEHIND なら canonical mechanical update-branch route を使い、その後 verification と review を fresh にやり直す。

    PR review と修正の各 iteration で人間承認を求めないでください。

    CI / mergeability

    PR review 前後で required checks を current head に bind して確認してください。

    APPROVE 単独で終了しないこと。

    最終的に次をすべて満たす必要があります。

    • latest pr-reviewer verdict: APPROVE
    • reviewed_head_sha == current PR head
    • blockers == []
    • current-head Verification Commands nonblocking
    • required CI green
    • live GitHub mergeable == MERGEABLE
    • live merge_state_status が canonical approvable state (CLEAN / HAS_HOOKS)
    • Allowed Paths compliance
    • unresolved actual Git conflict なし

    ここまで到達したら impl-review-loop の approved termination として終了してください。

    停止条件

    routine approval では停止しないでください。

    ただし canonical skill が定める genuine hard gate は迂回しないこと。少なくとも以下では停止して事実を報告してください。

    • live Issue が存在しない、または target identity が一致しない
    • canonical worktree identity を安全に確立できない
    • Allowed Paths 外の変更が不可避で、live contract にその権限がない
    • secret / protected-path Decision Gate が必要
    • GitHub/API 権限不足で canonical operation を実行不能
    • actual Git conflict (CONFLICTING / DIRTY) を canonical runbook でも自動解消できない
    • pr-reviewer の正式 verdict が HUMAN_REVIEW_REQUIRED
    • SubAgent task が genuinely recovery 不可能な errored/interrupted/shutdown/not_found
    • environment blocked
    • max_iterations=5 到達
    • bounded retry / no-progress budget 枯渇
    • 破壊的操作・force rewrite・secret 情報を必要とする操作

    単なる artifact/snapshot/ledger の欠落、SubAgent の boolean human_review_required: true 自己申告、stale review、BEHIND、recoverable agent discovery failure、transient CI state は、それだけで人間承認停止にしないでください。canonical recovery routing を先に使ってください。

    マージ境界

    route_loop_verdict_v2() が最終的に route: approved を返した時点で停止してください。

    その時点では以下を 実行しない:

    PR body に closing keyword があること自体は問題ありません。実際の merge を発生させないでください。

    最終報告

    停止時は冗長な作業日誌ではなく、最低限以下を返してください。

    開始してください。途中で通常の承認確認は挟まず、SubAgent の完了を確実に join しながら、マージ直前まで自律的に進めてください。

    この形なら、#2200 の最新 refinement を尊重しつつ、過去 handoff を不正に authorization として再利用せず、現行 impl-review-loop の同期 entry・SubAgent join・current-head VC gate・PR review・mergeability routingまで通せます。#2200 自体も artifact confinement と generation invalidation、PR #2520/#2533 の非回帰を現在の実装範囲として明示しています。

  11. squne121 commented on Sep 7, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  12. squne121 commented on Sep 7, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-09-07T10:35:26Z)

  13. added 2 commits that reference this issue on Sep 7, 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/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions