Skip to content

調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: research
parent_issue: "none"
goal_ref: "Issue #3031 refinement 中の repair_action.apply が root_review_pipeline の一時ファイルを unauthorized_write_path として拒否した事象について writer attribution と最小回復策を確定する"
change_kind: research-only
dedupe_key: "agent-guards:repair-action-apply:root-review-pipeline-tmp-write-attribution:v1"

Parent Issue

none(#3031 の docs 実装スコープとは独立した control-plane runtime 調査)

Parent Goal Ref

  • Goal: repair_action.apply の正規利用を、他の review job の一時書き込み等で不必要に停止させない。ただし本当に不正な child write は引き続き拒否する。
  • Desired Destination: 再現・因果帰属と最小の regression/fix ownership を明確にし、既存 Issue に吸収できる場合は新たな実装 Issue を作らない。

Source / Observed Evidence

  • #3031 の approved 終了報告 に記載された 2026-10-11 の incident。対象 repo main の実行時 HEAD は 60f0fc838e8b76a84c769a72b6361cd58e958e4d。
  • preflight.run.with_human_context から生成された deterministic repair(Issue VC の # baseline-expect: fail 追加)を、root-owned repair_action.apply で consume したところ、外側 executor が SKILL_RUNTIME_FAIL: reason_code=unauthorized_write_path target_issue=3031 unauthorized write path=tmp/root_review_pipeline_wgf6ofxj/root_review_pipeline_body_o6qi_4ru.md、exit 2 を報告した。Issue 本文の fresh readback は同一 digest のままで、mutation が成功したとは扱っていない。
  • 既存 .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py は tempfile.TemporaryDirectory(dir=..., prefix="root_review_pipeline_") 配下に root_review_pipeline_body_*.md を tempfile.NamedTemporaryFile で生成する。外側の scripts/agent-guards/skill_runtime_exec.py にある TMP_DIRECTORY_NODE_HOUSEKEEPING_COMMAND_IDS の補正は repo-root tmp/ directory node を対象とし、任意の新規 tmp/** file write を許可する契約ではない。
  • 外側 executor の _snapshot_repo_paths() は path ごとの種別・mtime_ns・size のみを保存し、writer PID や write syscall は記録しない。_find_unauthorized_repo_changes() は追加だけでなく削除と既存 path の metadata 変化も検出し、複数変更があっても代表 1 path のみを返す。_dispatch_child_and_check_postconditions() は child の実行結果を取得した後にこの検査を行い、違反時は child の stdout / stderr 転送より前に outer の exit 2 を返す。incident HEAD と確認対象 main で skill_runtime_exec.py の blob は同一であり、この制約は main 更新で生じた差ではない。
  • 同じ 実装: Claude Code Auto memoryの保存判断を整理し、Issue/PR進捗の重複記録を抑制する #3031 の修正本文は issue-editor / edit_issue_txn.py の controlled path で適用でき、最終 refinement 自体は approved。従って 実装: Claude Code Auto memoryの保存判断を整理し、Issue/PR進捗の重複記録を抑制する #3031 の再実行や実装停止を要求しない。
  • 未確定: 当該 path の writer が repair consumer の child、自セッションの background review task、別セッションの独立 peer のいずれであるか。さらに当該 path が before snapshot 後の新規作成、before 時点で存在した path の削除、または既存 path の metadata 変化のどれとして検出されたか。child が先に失敗していたか。時刻の一致や path 名だけで guard の誤検出と断定しない。

Related / Deduplication

Outcome

current main で production-shaped な再現と writer lineage / before-after path evidence を得て、次の 3 分岐のいずれかで調査を終了する。

  1. confirmed_defect — 確認された欠陥、証拠、最小修復箇所、同一 path の negative control を含む regression 方針。
  2. confirmed_expected_behavior — 正しい拒否または期待された挙動を示す成立条件と証拠。
  3. inconclusive — 実施済み比較、不足証拠、未確定範囲、次に必要な観測を明記した有効な調査終了。

inconclusive は成功証明、欠陥不存在、guard 正常、repair 成功と同義にしない。incident 時点の writer が未確定でも、current main の controlled comparison が完了していれば調査成果として報告できる。incident HEAD の因果帰属と、current main の制御された fixture で証明できる挙動は別々に記録する。確認された欠陥に限り、既存 Issue への証拠追記または小さな実装 follow-up を起票可能な状態にする。許可範囲の全域拡大や新しい approval layer は採用しない。

Runtime Verification Applicability

decision: immediate
reason: "AC2 は process concurrency と filesystem lifecycle を実プロセスで比較する local fixture 実験を必須とする。research-only であることは runtime not_applicable の理由にならない。"
applicable_acs: [AC2]
execution_environment: "canonical main root とは別の invocation-owned temporary fixture(調査専用の隔離 directory 内の git repository)上で、production の skill_runtime_exec.py の _dispatch_child_and_check_postconditions() を実際に呼ぶ outer process、repair consumer 相当の child process、独立 peer process を起動する local 実験。tracked repository source・実 GitHub Issue・foreign worktree は対象外。新規 Claude-GPT live smoke、実サービス mutation、恒久 CI gate は追加しない。"
skip_conditions: "fixture / peer / child / outer プロセスを起動できない、または invocation-owned temporary workspace を作成できない場合は、実験 harness が SKIP(exit 77、stdout は SKIP: で開始)を宣言し、その SKIP を terminal report に記録して AC2 を未充足(Stop Condition 発火)とする。SKIP は inconclusive ではなく、また PASS でもない。未作成 fixture、未実行コマンド、単なる marker 出力も PASS と扱わない。"
fallback_policy: "fallback 経由の成功は FAIL とする(fallback_success_is_pass: false)。取得できない観測項目は unknown と記録し、PASS へ読み替えない。"
artifact_requirements: "bounded な sanitized evidence を #3035 の `## 調査 terminal report (#3035)` 見出しのコメント(refinement の終了報告とは別コメント)に記載する。AC2 evidence は条件ごとに 1 行の `AC2_COUNTERFACTUAL_EVIDENCE_V1` 行形式(In Scope 参照)で記載し、harness の source は同コメントまたは直後の連続コメント(GitHub の 1 コメント上限を超える場合は分割。外部 gist へは出さない)に sha256 付きで同梱する。secret と raw private transcript は含めない。"
vc_form_exception: "AC2 の VC は repo-owned VC 文法(baseline_vc_preflight の allowlist は任意 script 実行・heredoc・複合コマンドを許可しない)と Allowed Paths (none)(新規 tracked harness を作れない)の下で、実験そのものを VC として起動できない。そのため実験は invocation-owned の harness で実行し、AC2 の VC は gh による readback で、投稿済み evidence コメントが 5 条件すべての `condition=` 行(各行に outer_exit / child_exit / detection の実測値)、peer-add と unauthorized-child の同一 target_path、harness_sha256、fixture の command ID と main HEAD を含み、行頭の `SKIP:` を含まないことを機械判定する。この VC は実験実行の代替ではなく、実行済み証跡の存在と構造の判定である。この形式は `docs/dev/runtime-verification-policy.md` の runtime AC 要件(runtime-verification タグ、SKIP exit 77、fallback FAIL)を維持したまま runnable VC 文法の制約に合わせた限定形であり、policy 本体と新しい gate は変更しない。evidence の内容妥当性(実測値が fixture 実行に由来するか)は reviewer の因果関係判定が別途確認する。"

In Scope

  1. run_root_review_pipeline.py の一時 directory / file の生成・削除時点と、skill_runtime_exec.py の before/after snapshot / _find_unauthorized_repo_changes() / command policy を current HEAD で追う。TemporaryDirectory と NamedTemporaryFile(dir=...) の lifecycle を踏まえ、一意 directory 化だけで解決すると仮定しない。
  2. 調査専用の isolated / invocation-owned temporary fixture 上で、次の counterfactual を比較する(local I/O のみ。実 GitHub Issue の本文・状態は変更しない)。
    • no-peer: repair consumer 単独
    • peer-add: before snapshot 後に peer が file を作り、after まで保持する
    • peer-cleanup: before に存在する file を peer が実行中に正常削除する
    • transient-peer: before 後に生成し、after 前に完全削除する
    • unauthorized-child: peer-add と同一の検査対象 path(fixture repo root 相対の tmp/root_review_pipeline_<fixture-id>/root_review_pipeline_body_<fixture-id>.md)を child 自身が作成または変更する。同 path を peer が作る peer-add と対にして、同じ outer 検査が child 起因を拒否し続けることを示す
  3. 各条件で次の観測項目を分離して記録する。取得できない項目は unknown とする。
    • 対象 path の create / modify / delete
    • before / after snapshot における対象 path の存在状態
    • Git status 差分と filesystem snapshot 差分のどちらで検出されたか
    • path kind、mtime、size、必要な digest
    • child の process exit / semantic result
    • outer executor の exit / reason
    • remote Issue body mutation の有無と readback
    • 自セッション background task と独立 peer の writer 候補(inotify や mtime だけで writer PID が確定するとは仮定しない)
      unauthorized_write_path を「新規 write が防止された証拠」と扱わない。child が先に失敗し、その後 outer filesystem check が exit 2 を返した可能性も区別する。同一セッションの root review Bash task の join 漏れと、独立セッション peer による競合も区別する。
      fixture の構成: (a) fixture は invocation-owned の一時 directory 内に新規 git init した repository(.gitignore は repo 実体と同じく /tmp/ を無視)を作り、その root を production の _dispatch_child_and_check_postconditions() の dispatch_root として渡す。canonical main root は dispatch_root にしない。実験の前後で canonical main root の git status --porcelain が不変であることを evidence に記録する。(b) command ID は incident と同じ repair_action.apply(TMP_DIRECTORY_NODE_HOUSEKEEPING_COMMAND_IDS 所属)を使う。(c) child と peer の同期(barrier)は fixture repo の外(sibling の invocation-owned directory)に置き、barrier 自体が snapshot 差分にならないようにする。(d) peer は harness が独立に起動する別 process とし、PID / PPID を harness が実際に起動した値として記録する。harness が起動した outer / child / peer の全 process について exit と join(回収)の完了を evidence に含める。
      AC2 evidence の行形式(条件ごとに 1 行、AC2_COUNTERFACTUAL_EVIDENCE_V1 marker 行の後に記載): condition=<no-peer|peer-add|peer-cleanup|transient-peer|unauthorized-child> actor=<child|peer|none> target_path=<fixture repo root 相対 path> transition=<create|modify|delete|none> outer_exit=<整数> child_exit=<整数> detection=<snapshot|git_status|both|none> attribution=<attributable|unknown>。加えて fixture_command_id=repair_action.apply、main_head=<40 hex>、harness_sha256=<64 hex>、各 process の PID / PPID / join 結果を記載する。取得できない値は unknown と書く(5 条件のうち 1 つでも実行できなかった条件、または harness が exit 77 以外で異常終了した場合は AC2 未充足であり、inconclusive ではない)。
      補助条件(AC2 の必須 5 条件の外、結果は AC3 の結論に使う): child-own-scratch-transient(child 自身が TemporaryDirectory 相当の scratch を作り after 前に完全削除する)を 1 行追加で実行し、legitimate child scratch が outer 検査を通るかを記録する。
      証明範囲: outer の snapshot / git status / exit 投影は production の skill_runtime_exec.py を実際に呼んで実証する。child は repair consumer(edit_issue_txn.py 経由の実 GitHub mutation)の stand-in であり、remote mutation は not_attempted(fixture 内に remote が存在しない)と記録する。stand-in で示すのは outer 検査の挙動であり、実 consumer の内部挙動や incident 時点の writer の証明ではない。
  4. 確定した failure class にだけ狭い修復案を示す。peer false-positive なら既存 attribution 原則を利用し、legitimate child scratch なら producer の run-owned output placement を先に検討する。両者の negative control で不正な書込み検知が残ることを条件にする。
  5. 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 / 実装: Auto mode の固定 /tmp scratch 上書き false-deny を run-scoped temporary workspace で解消する #2860 / 実装: canonical executor の Vitest results cache write を writer attribution に基づき狭域で判定する #2887 / 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 の ownership と突き合わせ、既存スコープで対応できる場合は既存 Issue に sanitized evidence コメントを追加して本調査を終了する。
  6. 既存テストやコマンドが writer attribution の証明にならない場合、それを明示する。

Out of Scope

Acceptance Criteria

  • AC1: 実装: Claude Code Auto memoryの保存判断を整理し、Issue/PR進捗の重複記録を抑制する #3031 の exact failure path、command ID、remote mutation/readback、current producer/consumer の call chain を区別した RCA がコメントで残る。filesystem transition(create / modify / delete)と child result / outer result を分離し、取得できない項目は unknown と記録する。incident HEAD の因果帰属と current main の fixture で証明できる挙動を別々に記載する。
  • AC2: no-peer / peer-add / peer-cleanup / transient-peer / unauthorized-child の counterfactual を invocation-owned temporary fixture 上で production の _dispatch_child_and_check_postconditions() を実際に呼んで実行し、In Scope の行形式(actor・同期点・対象 path(unauthorized-child は peer-add と同一 path)・process identity・child result・outer result・検出経路・writer attribution の可否)で 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 の ## 調査 terminal report (#3035) コメントに記録する。fixture を起動できない場合は harness が exit 77 / 行頭 SKIP: を宣言し AC2 は未充足とする(inconclusive へ読み替えない)。一部条件のみ実行・harness 異常終了も AC2 未充足とする。実験が完了し incident 時点の writer だけが未確定の場合に限り、AC3 で inconclusive を使える。unknown は false positive と断定しない。
  • AC3: 調査結論を confirmed_defect / confirmed_expected_behavior / inconclusive のいずれかで terminal report に明記する。confirmed_defect は最小変更箇所と同一 path の negative control を含む regression 方針を、confirmed_expected_behavior は成立条件と証拠を、inconclusive は実施済み比較・不足証拠・未確定範囲・次に必要な観測を示す。inconclusive を欠陥不存在や guard 正常と同義にしない。 peer-add と unauthorized-child の outer 結果が同一(outer が child 起因と peer 起因を区別できない)場合は、confirmed_defect の regression 方針に attribution の導入または producer の run-owned output placement が必要であることを判断材料として明記する。結論は conclusion=<confirmed_defect|confirmed_expected_behavior|inconclusive> の 1 行で排他的に 1 つだけ記載する。
  • AC4: 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 / 実装: Auto mode の固定 /tmp scratch 上書き false-deny を run-scoped temporary workspace で解消する #2860 / 実装: canonical executor の Vitest results cache write を writer attribution に基づき狭域で判定する #2887 / 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 の各 Issue 本文を実際に読み、tmp/root_review_pipeline_* の child path 検出(同一 checkout の peer 競合)を所有するかを ownership_<Issue 番号>=<owns|not_owns> <所有範囲の要約> の行で terminal report に記録する。同一 root cause を既に所有する Issue があれば新規実装 Issue を起票せずそこへ sanitized evidence を追記する。所有者が CLOSED Issue の場合は reopen せず(状態変更は Owner 判断)、evidence をコメント追記したうえで新規実装 Issue を 1 件だけ起票し closed Issue を参照する。実装 Issue の起票は結論が confirmed_defect で所有者が存在しない場合に限り、confirmed_expected_behavior と inconclusive では起票しない。

Verification Commands

# AC1
# baseline-expect: pass
$ rg -n --fixed-strings 'root_review_pipeline_body_' .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
# AC2
# preflight-scope: runtime_only
$ gh issue view 3035 --repo squne121/loop-protocol --json comments --jq '[.comments[].body | select(contains("AC2_COUNTERFACTUAL_EVIDENCE_V1") and test("condition=no-peer [^\\n]*outer_exit=[0-9]+ child_exit=[0-9]+ detection=(snapshot|git_status|both|none)") and test("condition=peer-add [^\\n]*outer_exit=[0-9]+ child_exit=[0-9]+ detection=(snapshot|git_status|both|none)") and test("condition=peer-cleanup [^\\n]*outer_exit=[0-9]+ child_exit=[0-9]+ detection=(snapshot|git_status|both|none)") and test("condition=transient-peer [^\\n]*outer_exit=[0-9]+ child_exit=[0-9]+ detection=(snapshot|git_status|both|none)") and test("condition=unauthorized-child [^\\n]*outer_exit=[0-9]+ child_exit=[0-9]+ detection=(snapshot|git_status|both|none)") and ((capture("condition=peer-add actor=[a-z]+ target_path=(?<p>[^ ]+)") | .p) == (capture("condition=unauthorized-child actor=[a-z]+ target_path=(?<p>[^ ]+)") | .p)) and test("fixture_command_id=repair_action.apply") and test("main_head=[0-9a-f]{40}") and test("harness_sha256=[0-9a-f]{64}") and (test("(^|\\n)SKIP:") | not))] | if length > 0 then length else error("AC2 evidence comment missing, incomplete, or SKIP") end'
# AC3
# baseline-expect: pass
$ uv run --locked pytest scripts/agent-guards/tests/test_issue_metadata_write_capability.py -q
# AC4
# baseline-expect: pass
$ gh issue view 2584 --repo squne121/loop-protocol --json number,state --jq 'if .number == 2584 then .state else error("unexpected issue") end'
# AC4
# baseline-expect: pass
$ gh issue view 2860 --repo squne121/loop-protocol --json number,state --jq 'if .number == 2860 then .state else error("unexpected issue") end'
# AC4
# baseline-expect: pass
$ gh issue view 2887 --repo squne121/loop-protocol --json number,state --jq 'if .number == 2887 then .state else error("unexpected issue") end'
# AC4
# baseline-expect: pass
$ gh issue view 2610 --repo squne121/loop-protocol --json number,state --jq 'if .number == 2610 then .state else error("unexpected issue") end'

AC1 / AC3 / AC4 の VC は source・既存 regression・関連 Issue の存在証拠であり、writer attribution・結論・ownership 判定の代替ではない(AC3 の既存 pytest は #2584 の既存 regression が current main で壊れていないことの確認であり、結論 3 分岐の判定ではない。結論の conclusion= 行と AC4 の ownership_<番号>= 行は reviewer が terminal report で確認する)。AC2 の VC は上記 vc_form_exception のとおり実験を起動する VC ではなく、実行済み runtime evidence の構造 readback 判定である(harness source と sha256 を同梱した terminal report コメントが実行証跡を担う)。AC1-AC4 の成立には、実測の sanitized evidence を載せた terminal report と reviewer の因果関係判定を別途必要とする。未作成の fixture、未実行のコマンド、単なる marker 出力を runtime PASS と扱わない。

Allowed Paths

  • (none)

Stop Conditions

  • Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
  • Allowed Paths 外への書き込みを試みた場合は即停止
  • 補足: Allowed Paths (none) は tracked repository source 不変の境界であり、invocation-owned 隔離 fixture 内の local I/O と、調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 または同一 root cause を所有する既存 Issue への sanitized comment 投稿は Allowed Paths 外への書き込みに当たらず許可される
  • 権限不足(permission denied)により操作が完了できない場合は即停止
  • 成果物の書き込みに失敗した場合(I/O エラー等)は即停止(terminal report コメントの投稿失敗を含む)
  • fixture / peer / child / outer プロセスを起動できない場合は harness が exit 77 / SKIP: を宣言して停止し、AC2 を未充足とする。PASS・inconclusive と扱わない
  • writer attribution を証明できないが AC2 の実験が完了している場合は inconclusive として終了し、無条件な guard 緩和に進まない
  • 実 GitHub Issue の本文・状態の mutation(調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 の本文更新を除く)、secret/credential や raw private transcript の公開、permission bypass、foreign worktree や他セッションの temporary work の変更が必要なら停止する
  • 同一の root cause を所有する既存 Issue があれば重複修正を作らない

Handoff Contract

Required Skills

なし(current repository canonical scripts と production-shaped test を調査する)

Required Design References

Delivery Rule

独立・非ブロッキング調査。Allowed Paths は canonical no-tracked-path(none)であり、tracked repository source は変更しない。(none) は tracked source 不変の境界であり、invocation-owned temporary fixture への local I/O と bounded evidence の GitHub コメント投稿を禁じない。調査は tmp 配下全体の許可には拡張しない。#3031 の approved と後続実装の権限判定を変更しない。

join 契約(二種類を別々に確認する): (1) 起動した各 SubAgent の terminal result を取得して join する(dispatch 成功・Task ID・進捗通知は完了ではない)。(2) root が起動した background Bash task(Step 2 の root_review_pipeline.produce、#2610 / PR #2622 の background launch + completion join 契約)は task completion notification と完了 JSON を取得して join する。SubAgent join は background Bash task join の代替にならない。

evidence の投稿先: 主たる terminal report(AC1-AC3 の RCA、AC2_COUNTERFACTUAL_EVIDENCE_V1、harness source と実行 command、確認済み事実・推論・未検証の区別)は #3035 のコメントに投稿する。同一原因を所有する既存 Issue がある場合に限り、そこへ sanitized evidence コメントを追記する(#3035 のコメントは置換しない)。tracked source 変更・PR 作成は #3035 では行わない(確認された欠陥の実装は別の implementation Issue が所有する)。

Activity

  1. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    判定:REQUEST_CHANGES — 調査契約を小さく修正してから進める

    #3035 を独立・非ブロッキングの調査に切り出した判断は妥当です。ただし、現在の本文には、原因の取り違えにつながる観測項目の不足と、調査を完了できなくする契約上の不整合があります。 ここでの REQUEST_CHANGES は #3035 の調査契約に対するものであり、#3031 の approved を取り消したり、後続実装を止めたりする理由ではありません。

    主要な確認対象は、main d5c39a182ed81fd3b484440a34a5844020522b25 の executor・review producer・Skill・既存テスト、および関連 Issue/PR です。今回、元 incident の writer を確定する runtime evidence は取得していません。以下では、確認できた実装上の事実と、追加すべき調査条件を分けます。

    Findings

    1. P2 — RCA の観測項目が不足している:これは「write の拒否」とは限らず、cleanup の検出や child failure の上書きでもある

    現在の本文は writer attribution を主軸にしています。しかし、現行 executor の動作からは、**「誰が書いたか」に加えて「どの filesystem transition を検出したか」「その前に child が何を返したか」**が必要です。

    skill_runtime_exec.py の確認結果は次のとおりです。

    • _snapshot_repo_paths() が保存するのは、パスごとの種類・mtime_ns・サイズです。writer PID や書き込み syscall の記録ではありません。
    • _find_unauthorized_repo_changes() は、追加だけでなく、削除と既存パスの metadata 変化も検出します。複数の変更があっても、返すのは選択された一つのパスです。
    • _dispatch_child_and_check_postconditions() は、child の実行結果を取得した後にこの検査を行います。違反が見つかると、child の stdout/stderr を転送する処理より前に outer の exit 2 を返します。

    したがって、今回の一行だけから、以下は確定できません。

    当該ファイルが実行中に新規作成された。
    その書き込み自体が阻止された。
    child は正常終了していて、outer guard だけが失敗した。

    たとえば、review の一時ファイルが before snapshot 時点では存在し、repair 実行中に review が正常終了して削除されても、同じ unauthorized_write_path になり得ます。また、child が既に別理由で失敗していたところに peer の変更が重なると、outer の filesystem failure が child 本来の failure を表面上隠す構造です。これは現行コードから導ける可能性であり、元 incident でそうだったと断定するものではありません。

    影響: 原因を「正当な一時ファイルの新規 write が許可されていない」と早合点すると、cleanup の競合や内側の repair failure を残したまま allowlist だけを広げる修正になり得ます。

    最小修正: AC1/AC2 に、次の観測を追加してください。

    対象パスの create/modify/delete、before/after の存在状態、検出元が status 差分か filesystem snapshot 差分かを区別する。可能な範囲で child の exit/semantic result と outer の exit/reason を別採取し、remote readback と対応付ける。取得できない項目は unknown と記録する。

    新しい恒久ログや schema は不要です。既存 fixture 内で、outer 判定前の child result を採取する程度で足ります。なお、incident HEAD 60f0fc83… と確認対象 main の skill_runtime_exec.py は同じ blob SHA でした。この観測上の制約は、今回の main 更新だけで生じた差ではありません。

    2. P2 — 必須の再現実験・コメント納品と、read-only/停止条件が整合していない

    本文は In Scope 2 で、実際に repair consumer、peer review producer、child-owned write を比較すると定めています。一方で、Runtime Verification は「read-only root cause 調査」を理由に not_applicable、Allowed Paths は (none)、Stop Conditions は「実 GitHub mutation が必要なら停止」です。さらに AC と Delivery Rule は GitHub コメントへの報告を要求しています。

    ここには二つの問題があります。

    第一に、research-only と runtime 不要を同一視しています。 リポジトリの runtime policy は、not_applicable を静的検証のみで完結する場合としています。本 Issue が要求するプロセス間の並行動作・一時ファイルの寿命・前後観測の比較は、単なる source reading ではありません。少なくとも「コードを変更しないから runtime 対象外」という理由は成立しません。

    第二に、コメント投稿も GitHub への更新です。 現在の停止条件を文字どおり適用すると、必須の terminal report や既存 Issue への証拠追記の直前で停止できます。また、Allowed Paths の (none) が tracked source 変更だけを禁止するのか、再現に必要な一時 fixture/証跡への書き込みまで禁止するのかも不明です。

    最小修正: 禁止対象を増やすのではなく、境界を明確にするのが適切です。

    tracked repository source は変更しない。調査専用の隔離 fixture と owned temporary evidence への I/O は許可する。実 GitHub の本文・状態を変更する再現実験は行わない。本 Issue と、同一原因の所有先として確認した既存 Issue への sanitized 調査コメント投稿は許可する。

    実験を AC2 の必須成果に据えるなら、その限定されたローカル観測を runtime 対象として宣言することを推奨します。実サービスの live mutation、Claude-GPT の追加 smoke、常設 CI gate、新しい harness は不要です。 既存証跡の分析だけに限定する選択も可能ですが、その場合は「本 Issue 内で三条件を実行比較する」という要求を外す必要があります。

    3. P2 — inconclusive を許容しているのに、その終了条件が AC と接続されていない

    Outcome は D「再現不能・未確定」を許容し、Stop Conditions も writer を証明できなければ未確定で終了するとしています。しかし AC3 は、

    defect が実在すれば修復案、実在しなければ no-change/expected-denial

    という二分岐です。さらに VC の注記は、AC1–AC4 の成立に incident の sanitized runtime evidence を別途必須としています。

    「欠陥を確認できなかった」と「欠陥が存在しない」は別です。 原ログが不足している場合や、現在の fixture では再現しても過去の writer までは結び付かない場合、現行契約では D と報告できても、AC3 の成立をどう判定するか決まりません。これにより、調査終了が「未完了」扱いになったり、逆に expected-denial へ過剰に分類されたりする余地があります。

    最小修正: AC3 を三分岐にしてください。

    確認済み defect は最小修復案と regression を示す。確認済み expected behavior は、その成立条件を示す。証拠不足・未再現は inconclusive とし、不足証拠、実行した比較、断定できない範囲を記録して調査を終了できる。inconclusive は defect 不存在・guard 正常・repair 成功の証明にしない。

    併せて、過去 incident の帰属とcurrent main の制御された再現で証明した挙動を別項目にすれば、過去ログがなくても有用な調査成果を残せます。

    修復方針を選ぶ前に確認すべき技術的な点

    一意な temporary workspace は、既に実装されている

    現行 write_pinned_body_tempfile() は NamedTemporaryFile(delete=False, dir=...) を使い、produce では invocation ごとの TemporaryDirectory 内に配置する設計です。中間ファイル群は、その invocation の終了時にまとめて削除されます。したがって、「run-scoped directory にする」だけでは今回の差分検出問題を解決しません。既にその形だからです。

    CPython 3.13 の公式実装でも、TemporaryDirectory.__exit__() は cleanup() を呼び、配下を削除します。また、tempfile は明示された dir を使用し、既定の temporary directory を選ぶのは dir is None の場合です。このため、今回の経路を TMPDIR の変更だけで移設できると仮定するのも不適切です。これは上流実装との照合であり、incident 環境の Python バージョンを実測したという意味ではありません。GitHub

    SubAgent の join と、root review の Bash task の join は別

    ここは Related に #2610/PR #2622 を加える価値があります。

    current issue-refinement-loop の canonical Step 2 は、issue-reviewer SubAgent ではなく、main thread が起動する root_review_pipeline.produce の Bash background taskです。Skill は run_in_background: true に加え、その task の完了と結果取得まで join することを要求しています。PR #2622 は、この実行境界を扱った merged PR です。

    Claude Code の公式仕様でも、background 起動は task ID を直ちに返し、コマンドはその後も実行を継続します。task の起動や SubAgent の終了を、当該 Bash process の完了と同一視できません。Claude

    したがって、調査では次を分けるべきです。

    自セッションが前の review の完了を待たずに repair へ進んだのか。
    正しく完了を待っていても、独立した別セッションの review と競合したのか。

    前者なら、既存の task lifecycle/join 手順の修正が最小策になり得ます。後者なら、配置・監査範囲・帰属の問題です。前者の可能性を調べずに guard 改修へ進める必要はありません。 ただし、今回 join 漏れがあったという証拠は未確認です。

    path の除外は、writer attribution の代替ではない

    現行 _find_unauthorized_repo_changes() は、前後のパス情報を入力にする判定で、writer identity を入力にしていません。したがって、同じ観測結果を作る peer と child を、この入力だけで区別することはできません。

    B「peer false denial」の修正として特定の tmp/root_review_pipeline_* を除外する案を採るなら、同じ検査対象パスを unauthorized child が変更する negative controlが必要です。無関係な別パスだけを拒否できても、peer と child を区別できた証明にはなりません。

    観測方法にも限界があります。Linux の inotify はイベントを起こした process/user を通知しません。strace -f は traced process が生成した子を追跡しますが、それだけで無関係な peer process を観測できるわけではありません。mtime・digest・inotify event・child-only trace のいずれも、単独で未知の peer の身元を確定する証拠にはしない方がよいです。Man7

    今回の規模なら、まずはfixture が起動した既知の producer と同期点で順序を制御する比較で十分です。常設 strace、全セッション追跡、新しい ownership ledger を先に導入する理由はありません。

    推奨する最小再現マトリクス

    以下は実行済み結果ではなく、現行実装から導く調査設計です。単に「二つの process を同時に走らせる」のではなく、対象ファイルの寿命を snapshot に対して制御します。現行コードは追加・削除の双方を検出するため、この区別が重要です。

    条件 | 制御する順序 | 確認すること -- | -- | -- no-peer | repair consumer 単独 | 基準となる child result と outer result。別の readiness failure を隠さない peer による追加 | before の後に生成し、after まで保持 | 対象パスの追加が outer の拒否を生むか peer の正常 cleanup | before より前から存在し、実行中に削除 | 新規 write がなくても削除差分で拒否されるか 完全に一時的な peer | before 後に生成し、after 前に配下ごと削除 | 対象差分が残らない場合を、欠陥不存在と誤認しない unauthorized child | peer 除外案と同じ検査対象パスを child が変更 | peer 対応後も、意図した child violation を検出できるか

    結論

    推奨は、guard の例外追加ではなく、上記三つの契約修正と小さい隔離再現を先に行うことです。

    特に重要なのは、unauthorized_write_path を「新規 write を阻止した証拠」と読まず、追加・変更・削除のどれを検出し、その時点で child は何を終えていたのかを確定することです。そのうえで、join の問題なら既存の実行手順、legitimate scratch の配置不一致なら producer 側、独立 peer の監査干渉なら狭い監査設計へ修復先を分けます。現時点で新しい共通 guard や恒久的な承認層を増やす根拠はありません。

    今回のレビューでは runtime 再現・テスト実行・GitHub への変更は行っていません。元 incident の writer と、inner repair の実際の終了理由は未確定のままです。

    ## 判定:REQUEST_CHANGES — 調査契約を小さく修正してから進める

    #3035 を独立・非ブロッキングの調査に切り出した判断は妥当です。ただし、現在の本文には、原因の取り違えにつながる観測項目の不足と、調査を完了できなくする契約上の不整合があります。 ここでの REQUEST_CHANGES は #3035 の調査契約に対するものであり、#3031 の approved を取り消したり、後続実装を止めたりする理由ではありません。

    主要な確認対象は、main d5c39a182ed81fd3b484440a34a5844020522b25 の executor・review producer・Skill・既存テスト、および関連 Issue/PR です。今回、元 incident の writer を確定する runtime evidence は取得していません。以下では、確認できた実装上の事実と、追加すべき調査条件を分けます。

    Findings

    1. P2 — RCA の観測項目が不足している:これは「write の拒否」とは限らず、cleanup の検出や child failure の上書きでもある

    現在の本文は writer attribution を主軸にしています。しかし、現行 executor の動作からは、**「誰が書いたか」に加えて「どの filesystem transition を検出したか」「その前に child が何を返したか」**が必要です。

    skill_runtime_exec.py の確認結果は次のとおりです。

    • _snapshot_repo_paths() が保存するのは、パスごとの種類・mtime_ns・サイズです。writer PID や書き込み syscall の記録ではありません。
    • _find_unauthorized_repo_changes() は、追加だけでなく、削除と既存パスの metadata 変化も検出します。複数の変更があっても、返すのは選択された一つのパスです。
    • _dispatch_child_and_check_postconditions() は、child の実行結果を取得した後にこの検査を行います。違反が見つかると、child の stdout/stderr を転送する処理より前に outer の exit 2 を返します。

    したがって、今回の一行だけから、以下は確定できません。

    当該ファイルが実行中に新規作成された。
    その書き込み自体が阻止された。
    child は正常終了していて、outer guard だけが失敗した。

    たとえば、review の一時ファイルが before snapshot 時点では存在し、repair 実行中に review が正常終了して削除されても、同じ unauthorized_write_path になり得ます。また、child が既に別理由で失敗していたところに peer の変更が重なると、outer の filesystem failure が child 本来の failure を表面上隠す構造です。これは現行コードから導ける可能性であり、元 incident でそうだったと断定するものではありません。

    影響: 原因を「正当な一時ファイルの新規 write が許可されていない」と早合点すると、cleanup の競合や内側の repair failure を残したまま allowlist だけを広げる修正になり得ます。

    最小修正: AC1/AC2 に、次の観測を追加してください。

    対象パスの create/modify/delete、before/after の存在状態、検出元が status 差分か filesystem snapshot 差分かを区別する。可能な範囲で child の exit/semantic result と outer の exit/reason を別採取し、remote readback と対応付ける。取得できない項目は unknown と記録する。

    新しい恒久ログや schema は不要です。既存 fixture 内で、outer 判定前の child result を採取する程度で足ります。なお、incident HEAD 60f0fc83… と確認対象 main の skill_runtime_exec.py は同じ blob SHA でした。この観測上の制約は、今回の main 更新だけで生じた差ではありません。

    2. P2 — 必須の再現実験・コメント納品と、read-only/停止条件が整合していない

    本文は In Scope 2 で、実際に repair consumer、peer review producer、child-owned write を比較すると定めています。一方で、Runtime Verification は「read-only root cause 調査」を理由に not_applicable、Allowed Paths は (none)、Stop Conditions は「実 GitHub mutation が必要なら停止」です。さらに AC と Delivery Rule は GitHub コメントへの報告を要求しています。

    ここには二つの問題があります。

    第一に、research-only と runtime 不要を同一視しています。 リポジトリの runtime policy は、not_applicable を静的検証のみで完結する場合としています。本 Issue が要求するプロセス間の並行動作・一時ファイルの寿命・前後観測の比較は、単なる source reading ではありません。少なくとも「コードを変更しないから runtime 対象外」という理由は成立しません。

    第二に、コメント投稿も GitHub への更新です。 現在の停止条件を文字どおり適用すると、必須の terminal report や既存 Issue への証拠追記の直前で停止できます。また、Allowed Paths の (none) が tracked source 変更だけを禁止するのか、再現に必要な一時 fixture/証跡への書き込みまで禁止するのかも不明です。

    最小修正: 禁止対象を増やすのではなく、境界を明確にするのが適切です。

    tracked repository source は変更しない。調査専用の隔離 fixture と owned temporary evidence への I/O は許可する。実 GitHub の本文・状態を変更する再現実験は行わない。本 Issue と、同一原因の所有先として確認した既存 Issue への sanitized 調査コメント投稿は許可する。

    実験を AC2 の必須成果に据えるなら、その限定されたローカル観測を runtime 対象として宣言することを推奨します。実サービスの live mutation、Claude-GPT の追加 smoke、常設 CI gate、新しい harness は不要です。 既存証跡の分析だけに限定する選択も可能ですが、その場合は「本 Issue 内で三条件を実行比較する」という要求を外す必要があります。

    3. P2 — inconclusive を許容しているのに、その終了条件が AC と接続されていない

    Outcome は D「再現不能・未確定」を許容し、Stop Conditions も writer を証明できなければ未確定で終了するとしています。しかし AC3 は、

    defect が実在すれば修復案、実在しなければ no-change/expected-denial

    という二分岐です。さらに VC の注記は、AC1–AC4 の成立に incident の sanitized runtime evidence を別途必須としています。

    「欠陥を確認できなかった」と「欠陥が存在しない」は別です。 原ログが不足している場合や、現在の fixture では再現しても過去の writer までは結び付かない場合、現行契約では D と報告できても、AC3 の成立をどう判定するか決まりません。これにより、調査終了が「未完了」扱いになったり、逆に expected-denial へ過剰に分類されたりする余地があります。

    最小修正: AC3 を三分岐にしてください。

    確認済み defect は最小修復案と regression を示す。確認済み expected behavior は、その成立条件を示す。証拠不足・未再現は inconclusive とし、不足証拠、実行した比較、断定できない範囲を記録して調査を終了できる。inconclusive は defect 不存在・guard 正常・repair 成功の証明にしない。

    併せて、過去 incident の帰属とcurrent main の制御された再現で証明した挙動を別項目にすれば、過去ログがなくても有用な調査成果を残せます。

    修復方針を選ぶ前に確認すべき技術的な点

    一意な temporary workspace は、既に実装されている

    現行 write_pinned_body_tempfile() は NamedTemporaryFile(delete=False, dir=...) を使い、produce では invocation ごとの TemporaryDirectory 内に配置する設計です。中間ファイル群は、その invocation の終了時にまとめて削除されます。したがって、「run-scoped directory にする」だけでは今回の差分検出問題を解決しません。既にその形だからです。

    CPython 3.13 の公式実装でも、TemporaryDirectory.__exit__() は cleanup() を呼び、配下を削除します。また、tempfile は明示された dir を使用し、既定の temporary directory を選ぶのは dir is None の場合です。このため、今回の経路を TMPDIR の変更だけで移設できると仮定するのも不適切です。これは上流実装との照合であり、incident 環境の Python バージョンを実測したという意味ではありません。[GitHub](https://raw.githubusercontent.com/python/cpython/3.13/Lib/tempfile.py)

    SubAgent の join と、root review の Bash task の join は別

    ここは Related に #2610/PR #2622 を加える価値があります。

    current issue-refinement-loop の canonical Step 2 は、issue-reviewer SubAgent ではなく、main thread が起動する root_review_pipeline.produce の Bash background taskです。Skill は run_in_background: true に加え、その task の完了と結果取得まで join することを要求しています。PR #2622 は、この実行境界を扱った merged PR です。

    Claude Code の公式仕様でも、background 起動は task ID を直ちに返し、コマンドはその後も実行を継続します。task の起動や SubAgent の終了を、当該 Bash process の完了と同一視できません。[Claude](https://code.claude.com/docs/en/interactive-mode)

    したがって、調査では次を分けるべきです。

    自セッションが前の review の完了を待たずに repair へ進んだのか。
    正しく完了を待っていても、独立した別セッションの review と競合したのか。

    前者なら、既存の task lifecycle/join 手順の修正が最小策になり得ます。後者なら、配置・監査範囲・帰属の問題です。前者の可能性を調べずに guard 改修へ進める必要はありません。 ただし、今回 join 漏れがあったという証拠は未確認です。

    path の除外は、writer attribution の代替ではない

    現行 _find_unauthorized_repo_changes() は、前後のパス情報を入力にする判定で、writer identity を入力にしていません。したがって、同じ観測結果を作る peer と child を、この入力だけで区別することはできません。

    B「peer false denial」の修正として特定の tmp/root_review_pipeline_* を除外する案を採るなら、同じ検査対象パスを unauthorized child が変更する negative controlが必要です。無関係な別パスだけを拒否できても、peer と child を区別できた証明にはなりません。

    観測方法にも限界があります。Linux の inotify はイベントを起こした process/user を通知しません。strace -f は traced process が生成した子を追跡しますが、それだけで無関係な peer process を観測できるわけではありません。mtime・digest・inotify event・child-only trace のいずれも、単独で未知の peer の身元を確定する証拠にはしない方がよいです。[Man7](https://man7.org/linux/man-pages/man7/inotify.7.html?utm_source=chatgpt.com)

    今回の規模なら、まずはfixture が起動した既知の producer と同期点で順序を制御する比較で十分です。常設 strace、全セッション追跡、新しい ownership ledger を先に導入する理由はありません。

    推奨する最小再現マトリクス

    以下は実行済み結果ではなく、現行実装から導く調査設計です。単に「二つの process を同時に走らせる」のではなく、対象ファイルの寿命を snapshot に対して制御します。現行コードは追加・削除の双方を検出するため、この区別が重要です。

    条件 制御する順序 確認すること
    no-peer repair consumer 単独 基準となる child result と outer result。別の readiness failure を隠さない
    peer による追加 before の後に生成し、after まで保持 対象パスの追加が outer の拒否を生むか
    peer の正常 cleanup before より前から存在し、実行中に削除 新規 write がなくても削除差分で拒否されるか
    完全に一時的な peer before 後に生成し、after 前に配下ごと削除 対象差分が残らない場合を、欠陥不存在と誤認しない
    unauthorized child peer 除外案と同じ検査対象パスを child が変更 peer 対応後も、意図した child violation を検出できるか

    既存の test_issue_metadata_write_capability.py は、実 executor → repair consumer → edit_issue_txn.py → controlled mutation executor の chain を通し、GitHub network boundary を fake にする fixture を持っています。再利用する出発点として適しています。ただし、そのテストの PASS は今回の並行実行・writer attribution の証明ではありません。#3035 自身が VC を存在・既存回帰の証拠に限定している点は正しく、そこを false-green と誤って批判する必要はありません。

    関連 Issue/PR の ownership 判定

    対象 今回との関係・扱い
    #2584/PR #2676 metadata write-root と tmp/ directory-node housekeeping の修正。PR は merged。今回の review file の並行変化と同一原因とは未確認であり、完了済み修正の失敗と即断しない。
    #2610/PR #2622 root review の実行面、background 起動、mandatory completion join を所有。今回の「自セッションの background review」仮説に直接関係する追加参照先。
    #2860/PR #2931 固定 scratch の上書き可能性に対する Auto classifier の拒否と、Skill の scratch 手順が対象。PR は open。既に一意 directory を使う今回の producer と、同じ修復方法で直るとは限らない。
    #2887 Vitest cache の peer/child attribution を扱う近接課題。ただし、参照できる課題が存在することと、再利用可能な帰属機構が実装済みであることは別。
    #3006 candidate の pre-edit readiness と LP017 write guard の受理範囲不一致。今回の filesystem postcondition とは別責務。ただし child 本来の失敗を確認するときには、こうした validation failure と outer failure を区別する。

    結論

    推奨は、guard の例外追加ではなく、上記三つの契約修正と小さい隔離再現を先に行うことです。

    特に重要なのは、unauthorized_write_path を「新規 write を阻止した証拠」と読まず、追加・変更・削除のどれを検出し、その時点で child は何を終えていたのかを確定することです。そのうえで、join の問題なら既存の実行手順、legitimate scratch の配置不一致なら producer 側、独立 peer の監査干渉なら狭い監査設計へ修復先を分けます。現時点で新しい共通 guard や恒久的な承認層を増やす根拠はありません。

    今回のレビューでは runtime 再現・テスト実行・GitHub への変更は行っていません。元 incident の writer と、inner repair の実際の終了理由は未確定のままです。

  2. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    推奨方針

    対象は [Issue #3035](#3035) の [REQUEST_CHANGES コメント #6108040967](#3035 (comment)) です。

    推奨は、指摘された3件の P2 を Issue 本文へ反映し、現行 issue-refinement-loop を人間の反復承認なしで最後まで実行させることです。

    修正の重点は次の4点です。

    1. 因果帰属の精度:unauthorized_write_path を新規書き込み拒否と断定せず、create / modify / delete、child の終了結果、outer executor の判定を分離する。
    2. 実行契約の整合:隔離されたローカル再現と一時証跡への書き込み、必要な GitHub 調査コメントを明示的に許可する。実サービスへの再現用 mutation は禁止する。
    3. 終了条件の修正:confirmed defect、confirmed expected behavior、inconclusive の3分岐を AC に反映する。
    4. 正しい実行ライフサイクル:SubAgent の完了待ちだけでなく、Step 2 の root_review_pipeline.produce を実行する background Bash task の完了・結果取得も必須にする。

    この refinement は Issue #3035 の調査契約を改善する作業です。Issue #3031 の既存 approved 判定は変更せず、後続実装も停止させません。

    また、今回の段階で tmp/** の全面許可、guard 無効化、恒久的なログ収集基盤、新しい承認ゲートを導入する必要はありません。

    現行 repository で確認した実行上の重要事項

    確認時の main HEAD は d5c39a182ed81fd3b484440a34a5844020522b25 です。

    現行 Skill では、対象コメントを指定する root-owned entry が preflight.run.with_human_context であり、承認済み contract patch は contract_update.run.with_human_context が処理します。全面 rewrite が必要な場合は、既存の issue-editor に委譲する経路があります。

    また、Step 2 は issue-reviewer SubAgent を起動する方式ではありません。root_review_pipeline.produce を background Bash task として実行し、完了した JSON の canonical_step2_route に従う方式です。この契約は [Issue #2610](https://github.com/squne121/loop-protocol/issues/2610)/[[merged PR #2622](https://github.com/squne121/loop-protocol/pull/2622)](https://github.com/squne121/loop-protocol/pull/2622) にも記載されています。

    現時点で重複調査の対象となる既存 Issue は [#2584](https://github.com/squne121/loop-protocol/issues/2584)、[[#2860](https://github.com/squne121/loop-protocol/issues/2860)](https://github.com/squne121/loop-protocol/issues/2860)、[[#2887](https://github.com/squne121/loop-protocol/issues/2887)](https://github.com/squne121/loop-protocol/issues/2887) です。

    これらに加えて新しい guard 修正 Issue を直ちに作るのは推奨しません。#3035 の RCA で原因と修復 ownership を確定し、既存 Issue に吸収できない欠陥だけを follow-up とするのが適切です。

    Python の TemporaryDirectory は通常終了時に内部ファイルを削除し、明示的な dir は一時ファイルの配置を決めます。したがって、既に invocation-local な一時ディレクトリを使っている経路を単純に「run-scoped 化」しても、削除差分や監査対象の問題は解決しません。

    image

    Python 3.14.7 documentation

    +1

    再発防止 Issue を起票しました

    [Issue #3036 — research Issue テンプレートで一時 fixture・GitHub コメント・runtime 判定の境界を明示する](#3036)

    起票後の GitHub readback 確認済み。docs-only、#3035 に対して非ブロッキング。

    研究 Issue のテンプレートで同種の契約矛盾が再発することを防ぐための改善です。新しい schema、恒久 gate、permission layer は追加せず、既存テンプレートの説明を改善するスコープに限定しました。

    Claude Code に貼り付ける実行プロンプト

    以下は既に auto mode で起動している対話的 Claude Code 用です。新しいセッションへの切り替えは不要です。

    Task: Issue #3035 — issue-refinement-loop 自律実行

    あなたは既に Auto mode で起動している対話的 Claude Code の main control-plane です。

    Repository: squne121/loop-protocol

    対象 Issue:
    #3035

    今回の trusted OWNER review anchor:
    #3035 (comment)

    使用する repository-native Agent Skill:
    .claude/skills/issue-refinement-loop/SKILL.md

    目的は、指定レビューの REQUEST_CHANGES を #3035 の調査契約に反映し、現行 issue-refinement-loop を approved または正規の terminal condition まで自律実行することです。

    調査結果を提案するだけで終了しないでください。必要な Issue 本文の修正、controlled transaction、fresh review、termination report まで実行してください。

    1. 明示的な事前承認

    この依頼を、次の正規作業に対するユーザーの事前承認として扱ってください。

    • 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 の Issue 本文の編集、および sanitized review / termination コメントの投稿
    • canonical preflight、trusted contract update、issue-editor による controlled rewrite
    • Skill が必要とする SubAgent dispatch、結果取得、再委譲
    • canonical planner が許可する hygiene / deterministic repair
    • 関連 repository・Issue・PR・tests の調査
    • 必要なローカル static verification と invocation-owned temporary workspace の作成・利用
    • REQUEST_CHANGES に対する有界の修復・再レビュー・再検証
    • 重複チェック後の非破壊的 follow-up Issue materialization

    通常の修復、反復、コメント投稿、readback、再レビューについては、各ステップで人間の追加承認を要求しないでください。

    既存 Auto mode を維持し、新規 Claude Code / Claude-GPT セッションは原則起動しません。

    この承認は Claude Code の permission enforcement、repository-owned guard、hard stop を迂回する許可ではありません。bypassPermissions、--dangerously-skip-permissions、hook 無効化などは使わないでください。

    本 Issue の調査契約に対する semantic correction は許可しますが、無関係な機能追加や無制限な権限拡張は許可しません。

    2. Fresh state と canonical Skill の読み込み

    最初に live GitHub から以下を再取得してください。

    main HEAD を GitHub から取得し、local checkout / default branch / worktree の状態を照合してください。

    現在の .claude/skills/issue-refinement-loop/SKILL.md と以下の normative reference を読んでください。

    • references/termination-policy.md
    • references/anchor-comment-handling.md
    • references/scope-signal-guard.md
    • references/follow-up-materialization.md
    • scripts/command_registry.py
    • docs/dev/runtime-verification-policy.md
    • docs/dev/agent-skill-boundaries.md
    • 必要な issue-editor agent definition と edit-issue Skill

    Skill の現行実装と deterministic planner / router / checker を authority とし、過去の会話や古い手順を優先しないでください。

    3. Trusted human-context preflight

    指定コメントの所属 Issue、author identity、trusted association、snapshot を検証してください。

    今回のコメントは REQUEST_CHANGES を含む OWNER review です。raw HTML や Markdown の表現形だけから信頼性や scope を推定せず、canonical anchor handling を使用してください。

    canonical main root / default branch から、現行 registry に従い preflight.run.with_human_context を起動してください。

    現行の呼び出し形は次のとおりです。

    uv run --locked python3 scripts/agent-guards/skill_runtime_exec.py --command-id preflight.run.with_human_context --issue-number 3035 --repo squne121/loop-protocol --anchor-comment-url https://github.com/squne121/loop-protocol/issues/3035#issuecomment-6108040967

    出力の STATUS、NEXT_ACTION、BLOCKERS、ARTIFACT、REPAIR_ACTION と planner decision を確認してください。

    controlled contract patch が指定された場合は、root-owned contract_update.run.with_human_context を正規に使用してください。

    NEXT_ACTION: issue_editor_required または full rewrite が必要な場合、既存 issue-editor / edit-issue transaction に委譲してください。

    同じ deterministic patch を理由なく再実行しないでください。

    環境・provenance・mutation integrity の failure を通常の semantic rewrite と混同せず、現行 mutation_outcome / phase / failure_code の組合せに従ってください。

    4. REQUEST_CHANGES の具体的な反映

    #3035 の研究目的と research-only scope は維持し、以下の3件を最小限の変更で反映してください。

    P2-1: filesystem transition と child result の分離

    AC1 / AC2、In Scope、Verification Guidance を補正してください。

    調査で必ず区別する観測項目:

    • create / modify / delete
    • before / after snapshot における対象 path の存在状態
    • Git status 差分と filesystem snapshot 差分
    • path kind、mtime、size、必要な digest
    • child の process exit / semantic result
    • outer executor の exit / reason
    • remote Issue body mutation / readback
    • 自セッション background task と独立 peer の writer 候補

    取得できない項目は unknown とすること。

    unauthorized_write_path を「新規 write が防止された証拠」と扱わないでください。

    child が先に失敗し、その後 outer filesystem check が exit 2 を返している可能性も区別してください。

    incident HEAD の因果帰属と、current main の制御された fixture で証明できる挙動は別々に記録する契約にしてください。

    P2-2: read-only / local fixture / GitHub コメントの境界

    次の区別を Issue の In Scope、Allowed Paths、Runtime Verification Applicability、Stop Conditions、Delivery Rule に反映してください。

    • tracked repository source は変更しない
    • 調査専用の isolated / invocation-owned temporary fixture と bounded evidence のローカル I/O は許可する
    • 実 GitHub Issue の本文・状態を変更する再現実験は禁止する
    • 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 への sanitized terminal report コメント、および同一原因を所有する既存 Issue への sanitized evidence コメントは許可する
    • foreign worktree、他セッションの temporary work、secret や raw private transcript は変更・公開しない

    Allowed Paths: (none) の canonical no-tracked-path semantics は維持し、任意の tmp/** の全面許可へ変更しないでください。

    research-only という理由だけで runtime not_applicable にしないこと。

    ローカルの process concurrency / lifecycle 実験が AC2 の必須要件なら、current runtime policy に整合する applicability、対応 AC/VC、証跡要件を設定してください。

    ただし、新しい Claude-GPT live smoke、実サービス mutation、恒久 CI gate は追加しません。

    P2-3: inconclusive の正規の終了条件

    AC3 と Outcome / Stop Conditions を整合させてください。

    調査の結論を次の3分岐で定義します。

    1. confirmed_defect — 確認された欠陥、証拠、最小修復箇所、同一 path の negative control を含む regression 方針
    2. confirmed_expected_behavior — 正しい拒否または期待された挙動を示す成立条件と証拠
    3. inconclusive — 実施済み比較、不足証拠、未確定範囲、次に必要な観測を明記した有効な調査終了

    inconclusive は成功証明、欠陥不存在、guard 正常、repair 成功と同義にしません。

    過去 incident の writer が未確定でも、current main の controlled comparison が完了していれば調査成果を報告可能な contract にしてください。

    5. 再現マトリクスの設計

    #3035 の AC2 には、最低限次の counterfactual を含めてください。

    • no-peer: repair consumer 単独
    • peer-add: before snapshot 後に peer がファイルを作り、after まで保持
    • peer-cleanup: before に存在するファイルを peer が実行中に正常削除
    • transient-peer: before 後に生成、after 前に完全削除
    • unauthorized-child: peer 対応案と同じ検査対象 path を child が変更

    fixture の actor、同期点、対象 path、観測できた process identity、child / outer result を分離してください。

    既存 run_root_review_pipeline.py の TemporaryDirectory と NamedTemporaryFile(dir=...) を踏まえ、一意ディレクトリ化だけで解決すると仮定しないこと。

    inotify や mtime だけで writer PID が確定するとも仮定しないこと。

    同一セッションの root review Bash task join 漏れと、独立セッション peer による競合を区別してください。

    今回の refinement では調査要件と実行可能な検証方法を確定するのが目的です。#3035 の RCA 全体を、この refinement 作業の前提として先に実行する必要はありません。

    既存テストやコマンドが writer attribution の証明にならない場合、それを明示してください。未作成 fixture、未実行コマンド、単なる marker 出力を runtime PASS と扱わないこと。

    6. SubAgent の利用と terminal join

    適切な SubAgent を利用してください。

    現行 planner の required policy と canonical role ownership に従って dispatch してください。

    必要な read-only 調査は、例えば次のように分離できます。

    • codebase-investigator: executor の snapshot / postcondition / command policy と review producer の temporary path lifecycle の整合確認
    • 別の適切な read-only agent: runtime applicability と issue contract、既存 regression / Related Issue ownership の照合
    • web-researcher: planner が外部仕様の検証を要求する場合のみ利用
    • issue-editor: canonical Step 4 rewrite が必要な場合に利用

    SubAgent に渡す task には、対象 repo・Issue・trusted anchor・current authority・対象ファイル・禁止事項・必要証拠・期待する出力を明示してください。

    SubAgent は親の暗黙 context に依存させません。

    独立した read-only 調査は並列化して構いませんが、依存する作業は順序を守ってください。

    SubAgent を dispatch しただけで完了扱いにしないでください。全 SubAgent の terminal status、実際の結果、欠落 evidence を取得して join してから次の Step に進んでください。

    SubAgent の失敗・timeout・degraded output を成功へ読み替えないこと。

    Step 2 は別の completion boundary

    canonical Step 2 では issue-reviewer SubAgent を代行起動しないでください。

    現行 Skill に従い、main thread が root_review_pipeline.produce を Bash の run_in_background: true で起動し、同一 background task の completion notification と final JSON を取得してください。

    canonical_step2_route を確認してから次に進んでください。

    background task の開始・SubAgent の終了・部分ログ取得は、Step 2 の完了ではありません。

    7. Rewrite / review loop

    現在の issue-refinement-loop を終端まで実行してください。

    期待する流れ:

    preflight → trusted contract update / issue-editor → fresh body readback → root-owned Step 2 review → Step 2.5 applicability / semantic review → 必要な修正 → fresh review → final contract gate → terminal report

    REQUEST_CHANGES は通常の修復対象です。

    body 更新後は必ず fresh issue body と SHA を再取得してください。

    古い approval や stale body SHA を再利用してはいけません。

    canonical reviewer が needs-fix を返した場合は、iteration budget 内で自動修正・再レビューしてください。

    decide_rewrite_route.py、decide_next_loop_action.py、canonical_step2_route の判断を手書きルールで再実装しないこと。

    default の有界 iteration policy を守り、無限 retry にしないでください。

    通常の editable finding を人間判断要求に変換しない一方、真の human_judgment_required、scope conflict、integrity failure、明示的な canonical upper bound は無視しないでください。

    8. 重複防止と関連 Issue

    今回の調査契約の改善を #3031 approved の取り消しとして扱わないこと。

    #3031 の implementation を本作業の hard predecessor にしないでください。

    既存 ownership として #2584、#2860、#2887、#2610/#2622 を照合してください。

    テンプレート一般の再発防止は既に #3036 を起票済みです。重複起票せず、必要な場合は既存 Issue を参照してください。

    trusted directive の HTML / structured-list routing に問題があれば #2778 と照合してください。

    独立した concrete defect を新たに確認し、既存 Issue で所有されていない場合だけ、現行 create-issue / follow-up materialization contract で起票してください。単なる懸念や未確認 writer を根拠に新しい guard 修正 Issue を作らないこと。

    9. Terminal completion

    最終的に次を確認してください。

    • 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 の最新本文に P2-1 / P2-2 / P2-3 が反映済み
    • issue_kind / goal / research-only scope が維持されている
    • AC / Verification Commands / Runtime Verification Applicability / Allowed Paths / Stop Conditions に矛盾がない
    • 実際の GitHub readback と body SHA を取得済み
    • Step 2 background Bash task は全て terminal join 済み
    • 使用した全 SubAgent は terminal result 取得済み
    • current body に対する fresh review と contract review が完了済み
    • approved 判定の場合は、canonical publisher 経由で termination report 投稿済み

    Research Issue なので、implementation-only の handoff marker や impl-review-loop の自動起動を勝手に行わないでください。

    終了レポートは publish_termination_report.py による controlled publication を利用し、current termination policy に準拠してください。

    FOLLOW_UP_MATERIALIZATION_RESULT_V1 も canonical contract に従って出力してください。

    最後に以下を報告してください。

    1. termination reason / cause
    2. 修正した Issue 本文の要点と最終 body SHA
    3. 最終 review 判定と fresh contract gate
    4. 実際に使用した SubAgent と terminal join 結果
    5. 検証済みの事実と未検証事項
    6. follow-up の create / reuse / skip 結果(実装: research Issue テンプレートで一時 fixture・GitHub コメント・runtime 判定の境界を明示する #3036 を含む)
    7. 残存 blocker と Issue の URL

    途中の説明や作業計画だけで終了せず、GitHub 上の確認できる terminal state まで進めてください。実装作業・PR 作成・merge には進まず、refinement 完了で停止してください。

    このプロンプトでは、通常の GitHub 書き込みと review iteration を事前承認する一方、canonical な停止条件は維持しています。特に、SubAgent の terminal join と background Bash task の completion join を分離した点が今回の事故調査に重要です。

  3. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: human_escalation

    実施内容

    • OWNER の P2-1(filesystem transition と child result の分離)、P2-2(local fixture と GitHub コメントの境界、RVA を immediate へ)、P2-3(confirmed_defect / confirmed_expected_behavior / inconclusive の 3 分岐)を本文へ反映した。研究目的と research-only の scope は維持している。
    • research テンプレート必須の Handoff Contract 節と、テンプレート標準の Stop Conditions 4 項目を追加した。
    • Allowed Paths は canonical な (none) のみとし、tmp 配下全体の許可には拡張していない。
    • Step 2 の deterministic review は 1 回目と 2 回目が needs-fix(VC の broad search path と baseline 注記、Allowed Paths の no-path marker 不認識)で、3 回目に最終 body で approve となった。
    • Step 2.5 の semantic review は、最終 body に対して findings(high 1 件・medium 3 件・low 1 件)を返し、join_review_results.py は needs-fix(rewrite_lane: semantic)と判定した。decide_next_loop_action.py は iteration 2 で max_iterations_exceeded を返したため、ここで停止する。

    Blockers(未解決の semantic findings)

    • high(owner choice 必要): RVA は immediate だが、AC2 に紐づく機械判定可能な runtime VC(正常系・異常系、SKIP exit 77、fallback FAIL)が無い。runnable な fixture 実行 VC を AC2 に置くか、機械判定 VC を置かない policy 例外の根拠を明記するかの選択が必要。
    • medium: Stop Conditions のテンプレート標準項目「Allowed Paths 外への書き込みは即停止」が、必須の fixture local I/O と terminal report コメントと文字どおりには両立しない。tracked source と foreign worktree への書き込みに限定する旨の明記が必要。
    • medium(owner choice 必要): fixture 不起動による SKIP と AC3 の inconclusive の関係が未定義。
    • medium: unauthorized-child 条件が参照する「peer 対応案」が未存在であり、child の実体(実 skill_runtime_exec outer か stand-in か)が未固定。
    • low: evidence コメントの発生条件が 3 か所で異なる、Delivery Rule の「subagent 完了を join」が曖昧、AC4 の VC が 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 のみ。

    次の入力

    人間判断として、上記 high の選択(runnable VC を置くか policy 例外を明記するか)と、SKIP と inconclusive の関係を指示してもらえれば、同じ anchor を fix_delta として loop を再開できる。#3031 の approved 判定は変更していない。

    検証状況

    • 検証済み: GitHub readback の body SHA 一致、Step 2 の最終 body に対する approve、static readiness go。
    • 未検証: AC2 の counterfactual 実行は本 refinement の対象外で未実施。writer attribution は未確定のまま。
    LOOP_TERMINATION_RESULT_V1:
      termination_reason: human_escalation
      termination_cause: max_iterations_exceeded
      max_iterations: 3
      blockers_history:
        - iteration: 0
          blockers: [missing_required_section]
        - iteration: 1
          blockers: [VCP_BROAD_SEARCH_PATH_UN, missing_annotation]
        - iteration: 2
          blockers: [semantic_high_runtime_vc_missing]
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: issue-refinement-loop
      follow_up_issues: []
      note_only_observations:
        - "テンプレート一般の再発防止は既存 #3036 が所有しており、重複起票しない(skip)"
        - "HTML 貼り付けの directive routing は既存 #2778 が所有しており、本件では新規欠陥を確認していない(skip)"
    
    <!-- CONTROLLED_EXEC_MARKER:070bc44e2c3dd0cfcb8c29e7d472a64f -->
  4. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    1. 現状確認と推奨方針

    Issue #3035 は、まず調査契約の残存不整合を修正し、隔離された実プロセスによる原因調査を完了させる方針を推奨します。

    確認した GitHub の状態は以下のとおりです。

    項目 | 確認結果 -- | -- 対象 | Issue #3035 Issue 状態 | OPEN Issue 種別 | research / research-only 最新 refinement | human_escalation / max_iterations_exceeded deterministic review | 最終本文で APPROVE semantic review | high 1件・medium 3件・low 1件の未解決指摘 原インシデントの writer | 未確定 AC2 の runtime 再現 | 未実施 main HEAD | d5c39a1

    各条件で、次を個別に観測してください。

    • actor / process identity / PID / 親子関係

    • before / after の同期点

    • 対象pathの存在、file kind、mtime_ns、size、必要なdigest

    • create / modify / delete の区別

    • git status差分か filesystem snapshot差分か

    • child の process exit、stdout/stderr、semantic result

    • outer executor の exit、reason code

    • remote mutation が not_attempted / applied / unknown のいずれか

    • remote readback の実施有無と結果

    • 当該 actor を証拠から帰属できるか

    PID や writer lineage は、fixture が自ら起動・制御したプロセスから因果的に取得してください。

    inotify、mtime、digest、時刻の一致だけで元 incident の writer を確定しないでください。

    production executor に対する実証と、stand-in で示したモデル上の挙動を混同しないでください。

    既存テスト:

    scripts/agent-guards/tests/test_issue_metadata_write_capability.py

    を含め relevant regressions を実行してください。ただし、既存テストの成功だけで5条件の動的比較が完了したとは扱いません。

    runtime検証不能なら SKIP: / exit 77、fallbackのみ成功なら FAIL、未実行なら未実行と記録してください。

    5. RCA と disposition を確定する

    次の3分岐のどれかを証拠に基づいて採用します。

    confirmed_defect

    current main の制御された実験で不具合を確認した場合。

    • exact failure class を記載

    • producer / consumer / executor / orchestration の最小修正箇所を特定

    • positive control と同一pathの unauthorized-child negative control を設計

    • 広域 tmp/** allow や guard全無効化を提案しない

    • 既存 owner Issue に吸収できるか判定

    confirmed_expected_behavior

    当該拒否が期待された動作だと証拠で確認できた場合。

    inconclusive

    incident 時点の writer を確定できない場合。

    • 何を実行・確認したかを記載

    • 未確定の範囲を明記

    • 次に必要な証拠を示す

    • current main の再現結果と過去incidentの帰属を分ける

    • inconclusive を expected behavior や defect不存在へ変換しない

    AC2 の比較自体を実行できなかった場合は、単に inconclusive と記してAC完了・Issueクローズ扱いにしないでください。

    #3031 の既存 approved は変更せず、#3031 の refinement や関連 docs実装を再開しないでください。

    6. 確認された欠陥がある場合の実装まで行う

    confirmed_defect なら、単なる提案で止まらず、修復の実行に進んでください。

    ただし、#3035 の research-only / Allowed Paths (none) の契約を破ってコードを直接変更してはいけません。

    6.1 Ownership と重複排除

    最初に #2584 / #2860 / #2887 / #2610 と open Issues / PRs を照合します。

    • 同じroot causeを正確に所有する既存実装Issueがあれば、そのIssueを再利用

    • 既存Issueが異なるfailure classを所有する場合はscopeを横取りしない

    • 適切なownerが無ければ、最小スコープの新規 implementation Issue を作成

    • research Issue 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 と implementation Issue #N は責務を分離

    • evidence、exact files、AC、positive/negative controls、Allowed Paths、Stop Conditions、VC、dedupe_key を整える

    必要なら issue-refinement-loop で新しい implementation Issueを精緻化してください。

    6.2 実装・テスト・PR

    このプロンプトは、実装Issue #N が確定した場合にその実装を継続することも明示的に依頼しています。

    current impl-review-loop の Root-Owned Synchronous Entry Transition を正しく使用し、前提のcontract / capability確認を飛ばさないでください。

    既存 branch / PR があれば再利用してください。無ければ repository-native workflow に従って作成してください。

    以後は次の完了経路を実行します。

    inspect → implement → test → review → fix → re-test → Draft PR → CI → independent PR review → fix/review loop → merge-ready report

    PR本文に Closes #N を設定してください。Nは実際にコード修正を所有する implementation Issue 番号です。research Issue #3035を誤って実装PRの close targetにしないでください。

    実装の必須条件:

    • 修復前のfailure classが再現される

    • 修復後に当該false positive等が解消される

    • 同一pathへのunauthorized child writeは引き続き拒否される

    • peerとchildを区別できない広域除外を採用しない

    • 既存の正常なrepair consumerと他のcommand IDを壊さない

    • 修正差分を最小限に限定する

    test-runner、pr-reviewer 等のSubAgentには current HEAD と契約を渡し、全て terminal joinしてください。

    REQUEST_CHANGES は修復してfresh HEADで再reviewします。

    CI failure / stale review / branch behind は、既存runbookに従って自律回復してください。

    Required CIとreviewが現PR HEADへ紐づいていることを確認してください。古いHEADのPASSを再利用しないでください。

    最終状態は canonical impl-review-loop が認める draft_pr_ready 相当を目標とします。

    マージは行いません。Closes #N による実装Issueの自動closeは、GitHubの設定および後続のmainへのmergeに依存するため、PR作成時点でclose済みと報告しないでください。

    7. Issue #3035 の完了処理

    RCAの結果にかかわらず、research契約が要求する成果をGitHubに残してください。

    #3035 の terminal report には以下を含めます。

    1. current main SHA、検証対象のIssue body SHA、incident HEAD

    2. 原incidentの確認済み事実と unknown

    3. process / writer attribution 比較表

    4. 5条件それぞれの実行結果・child/outer result

    5. git status / filesystem snapshot の差

    6. confirmed_defect / confirmed_expected_behavior / inconclusive

    7. AC1〜AC4 の判定と根拠

    8. 使用した SubAgent 全員の completion / join

    9. background Bash task の completion / join

    10. 関連Issueへの吸収、新規implementation Issue、または修復不要の判定

    11. テスト、実行コマンド、CI、未検証事項

    12. 残blockerと次に必要な操作

    secret、token、raw private transcriptは公開しないでください。

    #3035 が定めた調査条件を満たし、必要な ownership handoff を完了したら、research Issue #3035 を completed でクローズしてください。GitHubのfresh readbackでclose結果も確認してください。

    inconclusive でも、ACが要求する有効な比較を実行し、限界を明示した成果物が揃えば、契約に従って研究完了を判断して構いません。

    一方、AC2がSKIP・未実施・不正なfallbackである場合は、完了を偽装して閉じないでください。回復可能な環境問題は修復を試み、それでも実行不能なら証拠付きで未達として報告してください。

    8. 最終報告と完了確認

    途中の作業計画やSubAgent dispatchだけで終了しないでください。

    最終報告は次の項目を必ず含めてください。

    • 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 の最終 state / URL / disposition

    • 最終 body SHA、contract review 判定

    • RCA と5条件の runtime evidence

    • incident writer の confirmed / unknown

    • SubAgent ごとの担当・結果・terminal join

    • background task join状況

    • 修復なし / 既存Issueへ吸収 / 新規Issue起票の判定

    • 実装した場合の Issue #N / PR #M / current HEAD

    • テスト・required CI・独立レビュー結果

    • Closes #N の確認

    • 既に満たしたクローズ条件と、merge後に初めて成立する条件

    • 残る technical blocker、権限上実行できなかった操作、今後の必要操作

    確認済み事実、推論、未検証を明確に区別してください。

    最優先は、正当な repair_action.apply を不必要に停止させる原因を特定し、本当に必要な場合だけ最小の修復を実行することです。

    品質と実際の開発有用性を優先し、新たな抽象層・恒久gate・permission wrapper・過剰なsecurity hardeningは導入しないでください。

    この作業を最後まで自律実行してください。

    4. 補足:Issue のクローズについて

    今回の指示では、#3035 は研究としての AC1〜AC4 と terminal report が揃えばクローズ可能です。一方、実装用 Issue #N に設定する Closes #N は、原則として PR がデフォルトブランチにマージされた際に自動クローズへつながります。

    GitHub Docs
    +1

    したがって、研究Issueの完了と、実装PRのmerge待ちを分離することが重要です。これにより #3035 を不必要に開き続けることなく、修復の品質判定と人間のmerge判断を維持できます。

    また、Python公式仕様でも TemporaryDirectory はコンテキスト終了時に内容を削除し、明示的な dir は環境変数 TMPDIR より優先されます。単純な環境変数変更で解決した扱いにしない方針は妥当です。

    Python 3.13.15 ドキュメント

    ## 1. 現状確認と推奨方針

    Issue #3035 は、まず調査契約の残存不整合を修正し、隔離された実プロセスによる原因調査を完了させる方針を推奨します。

    確認した GitHub の状態は以下のとおりです。

    項目 確認結果
    対象 [Issue #3035](#3035)
    Issue 状態 OPEN
    Issue 種別 research / research-only
    最新 refinement human_escalation / max_iterations_exceeded
    deterministic review 最終本文で APPROVE
    semantic review high 1件・medium 3件・low 1件の未解決指摘
    原インシデントの writer 未確定
    AC2 の runtime 再現 未実施
    main HEAD d5c39a182ed8

    直近の [refinement 終了報告](#3035 (comment)) では、Issue 本文の修正と readback は完了していますが、semantic review の指摘が残り、最大3回の反復に到達しています。

    この状態で impl-review-loop を直接起動するのは適切ではありません。#3035 の現在の契約は tracked source の変更を禁止しており、PR作成も研究の対象外です。

    推奨する実行順序は、契約修正 → runtime調査 → RCA判定 → 必要時のみ実装Issueへ移管 → 実装・テスト・PR・レビュー → クローズ条件の検証です。

    今回は人間から通常の作業継続を承認済みという前提で、Claude-GPT に判断と実行を委任するプロンプトを組み立てます。ただし、既存の deterministic gate を偽装したり、失敗を PASS に読み替えたりはさせません。

    2. 実装調査で優先すべき事項

    リポジトリの現行コードを確認すると、重要なのは次の3点です。

    1. skill_runtime_exec.py は、child の終了後に filesystem snapshot を比較します。追加だけでなく削除・metadata変更も拒否要因となり、child 自身の失敗が outer の exit 2 に隠れる可能性があります。
    2. run_root_review_pipeline.py は既に invocation ごとの TemporaryDirectory を使っています。単純な一意ディレクトリ化だけでは解決しません。
    3. [PR #2622](fix: root_review_pipeline.produce のouter timeout ownershipをinventoryしbackground+join契約を明記する #2622) で background Bash task の completion join が契約化されています。SubAgent の完了待ちと、Bash task の完了待ちは別々に検証する必要があります。

    修復先は原因に応じて選ぶべきです。単一セッションの join 漏れなら orchestration、正当な child scratch の配置不一致なら producer、独立 peer による誤帰属なら監査処理が候補です。

    関連 Issue は次のように整理できます。

    Issue 現在状態 今回との関係
    [#2584](#2584) CLOSED tmp/ directory-node housekeeping の既存修正
    [#2860](#2860) OPEN run-scoped scratch の所有先
    [#2887](#2887) OPEN 別種の peer/child attribution 問題
    [#2610](#2610) CLOSED background completion join の既存契約
    [#3036](#3036) OPEN research Issue テンプレートの再発防止

    #3035 に対応する実装PRは確認されませんでした。main は保護され、required checks に typecheck、lint、test、build、python-test、validate-generated-artifact が設定されています。現在の main HEAD では Issue コメント関連の Actions 成功が確認できますが、これは新しい実装PRの required CI 合格を意味しません。

    今回の推奨判断: 未解決の high finding は、原則として AC2 に実行可能な runtime VC を用意する方向で解決します。研究専用の隔離 fixture を利用し、tracked source や恒久CIを追加せずに、実プロセスで5条件を比較する構成とします。

    3. Claude-GPT 向け実行プロンプト

    以下を、既に auto mode で起動している対話的 Claude Code(Claude-GPT)へそのまま貼り付けてください。

    Issue #3035 — 自律RCA・必要時の実装修復・Issue完了

    対象 repository: squne121/loop-protocol

    対象 Issue: #3035

    あなたは既に auto mode で起動している対話的 Claude Code(Claude-GPT)です。現在のセッションを継続し、launcher、推論backend、permission modeを勝手に変更しないでください。

    本指示は、#3035 の残存契約修正、実プロセスでのRCA、GitHub証跡投稿、研究Issueの完了、欠陥が確認された場合の既存Issueへの吸収または必要な実装Issue起票、およびその実装・テスト・PR・レビュー対応までの明示的な実行承認です。

    計画・提案だけで終了しないでください。必要な通常の非破壊的な操作は人間への逐次確認なしで実行してください。

    0. 自律性と境界

    次を事前承認します。

    • repository / Issue / PR / comments / CI / logs / upstream documentation の取得・調査
    • 現行 canonical Skill に従った Issue本文の必要最小限の修正、GitHubコメント投稿、適切なIssueの完了クローズ
    • invocation-owned な隔離fixtureの作成、ローカルI/O、子プロセス起動、必要なテストと再検証
    • 必要な SubAgent の起動、並列調査、結果取得、修正指示、再実行
    • 確認された欠陥の既存 owner Issue への証拠追記、重複しない実装Issueの起票
    • 必要な実装Issueに対する impl-review-loop、branch/worktree、コード変更、commit、push、Draft PR作成・更新、Closes #N 設定、CI修復、レビュー再実行
    • 通常の REQUEST_CHANGES、テスト失敗、CI失敗、stale HEAD からの安全な自律回復

    破壊的操作と秘密情報・credentialに関わる操作だけは、人間承認を要する明示的な停止境界とします。

    force push、履歴破壊、foreign worktreeの変更・削除、secret取得・変更・公開、権限回避は行わないでください。

    通常の失敗は回復対象です。ただし、実際に証拠が欠ける場合、canonical checker が拒否する場合、実行権限が技術的に得られない場合に、結果を捏造したり PASS へ読み替えたりしてはいけません。取得不能な証拠は unknown、実行不能な runtime 検証は所定の SKIP として扱ってください。

    Claude Code の auto mode と repository loop の自動継続は別の機構です。bypassPermissions、--dangerously-skip-permissions 等を要求しないでください。

    実merge・auto-mergeは今回の明示対象に含めません。必要な実装PRは人間がmerge判断できる直前まで到達させます。research Issue #3035 自体は、契約上の完了条件が実際に満たされればクローズして構いません。

    1. 最初に live state を再取得する

    作業開始時に必ず fresh な情報を取得してください。

    参考となる過去の観測値:

    これらは historical reference であり、現在状態の保証ではありません。

    また、以下を current repository から実際に読んでください。

    • AGENTS.md、CLAUDE.md
    • .claude/skills/issue-refinement-loop/SKILL.md
    • .claude/skills/issue-refinement-loop/references/termination-policy.md
    • .claude/skills/issue-refinement-loop/scripts/run_root_review_pipeline.py
    • .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py
    • scripts/agent-guards/skill_runtime_exec.py
    • scripts/agent-guards/skill_runtime_command_policy.py
    • docs/dev/runtime-verification-policy.md
    • docs/dev/workflow.md
    • relevant test files と .claude/agents/*.md

    前回の refinement 終了を新しい approved と解釈しないでください。特に、deterministic approve と semantic needs-fix を区別してください。

    2. 残存 semantic findings を先に修正する

    #3035 の直近終了報告には high 1件、medium 3件、low 1件が残っています。

    本プロンプトにより、その解決方針の選択を明示的に委任します。

    High: AC2 の runtime VC 不足

    第一選択は、AC2 に実際に実行可能な runtime verification command を用意することです。

    既存 VC parser / command policy に適合する方式を選び、調査用の invocation-owned temporary fixture を構築してください。

    tracked source を増やさず、実行コマンド、期待される正常・異常結果、exit code、証拠出力が再現可能な構成を優先します。

    既存 pytest の成功や文字列検索だけで、AC2 の5条件を実行したことにはしないでください。

    research-only の制約と canonical VC grammar のため runnable VC が成立しない場合だけ、規定上許される限定的例外を検討してください。例外を採用するなら、その正当性を current SSOT で検証し、runtime evidence の代替として曖昧な prose を使わないでください。

    新しい恒久 CI gate、schema、wrapper、approval layer は追加しません。

    Medium / Low

    同じ Issue の範囲内で以下を修正してください。

    1. Allowed Paths (none) は tracked repository source を変更しないという境界として維持し、隔離fixtureへのI/Oと sanitized terminal comment を許可することを明確化する。
    2. fixture起動不能の場合は exit 77・SKIP: とし、AC2は未充足とする。実験が完了し、incidentのwriterだけが未確定な場合の inconclusive とは区別する。
    3. unauthorized-child の対象を、peer比較と同じ検査対象pathとして確定する。production executor / snapshot logic と、必要に応じた stand-in の証明範囲を区別する。
    4. sanitized evidence の投稿先、SubAgent join、background Bash task join の記述を一貫させる。
    5. AC4 の検証は 実装: repair_action.apply の unauthorized_write_path false negative を解消する #2584 だけに依存せず、実装: Auto mode の固定 /tmp scratch 上書き false-deny を run-scoped temporary workspace で解消する #2860 / 実装: canonical executor の Vitest results cache write を writer attribution に基づき狭域で判定する #2887 / 実装: root review outer timeout と invocation-local budget の parity を固定する #2610 との ownership を実際に確認する。

    必要な修正は repository-native issue-refinement-loop と controlled Issue transaction に従って行い、fresh readback、body SHA、contract review、semantic review を再実行してください。

    OWNER コメント 6108040967 を human-context anchor として使用することを明示的に承認します。既存の機械生成 termination comment を human-context へ自動昇格させないでください。

    前runの iteration 上限を黙って無効化してはいけません。今回の委任判断を入力に、新しい正規の修正・検証サイクルとして処理してください。

    3. SubAgent に独立調査を委譲する

    current .claude/agents/*.md を読み、実際に利用可能な agent、tool、permission、Skill を確認してください。

    最低限、次の責務を独立させてください。

    SubAgent A — Executor / Guard

    調査対象:

    期待成果物:

    • current HEAD に紐づく call chain
    • filesystem transition ごとの failure hypothesis
    • child / peer attribution の観測可能性と限界
    • 最小修復候補と negative-control 条件

    SubAgent B — Review Producer / Concurrency

    調査対象:

    期待成果物:

    • producer の実際の一時ファイル lifecycle
    • before/after snapshot との競合可能箇所
    • TMPDIR 変更や一意 directory 化だけで解決するかの判定
    • join 修正・producer 配置修正の適用条件

    SubAgent C — 契約・検証レビュー

    調査対象:

    期待成果物:

    • 未解決 blocker の一覧
    • 証明可能なものと unknown の区別
    • terminal report の合格条件
    • 不必要な scope expansion の指摘

    必要なら利用可能な reviewer / test-runner / investigator agent を適切に追加してください。

    AとBは独立に並列化して構いませんが、各SubAgentの terminal result を取得し、全員の完了をjoinしてからRCAを確定してください。

    単なる dispatch成功、Task ID、進捗通知、生成されたファイルだけで完了扱いしないでください。

    また、SubAgent join と root-owned background Bash task completion join は独立に実施してください。

    SubAgent に親会話の暗黙知を期待せず、対象Issue、HEAD、調査範囲、authority、禁止事項、期待する証拠と出力を明示してください。

    4. AC2 の production-shaped runtime 再現

    canonical main root と foreign worktreeを変更せず、調査専用の isolated / invocation-owned temporary fixture を用意してください。

    必要に応じ、Git repository のテスト用構造を fixture 内に作成し、実際の production snapshot/detection logic を使います。

    本番GitHub Issueへの mutation は行わず、必要な network boundary は fake にしてください。

    実際の子プロセスと独立peerプロセスを使い、同期点を明示的に制御してください。

    次の5条件を実行します。

    条件 実行する比較
    no-peer repair consumer 相当のchild単独
    peer-add before snapshot 後に peer が同pathへfileを作成し、afterまで保持
    peer-cleanup before時点のfileを peer がchild実行中に削除
    transient-peer before後に生成し、after前に完全削除
    unauthorized-child peerと同じ監査対象pathをchildが変更

    各条件で、次を個別に観測してください。

    • actor / process identity / PID / 親子関係
    • before / after の同期点
    • 対象pathの存在、file kind、mtime_ns、size、必要なdigest
    • create / modify / delete の区別
    • git status差分か filesystem snapshot差分か
    • child の process exit、stdout/stderr、semantic result
    • outer executor の exit、reason code
    • remote mutation が not_attempted / applied / unknown のいずれか
    • remote readback の実施有無と結果
    • 当該 actor を証拠から帰属できるか

    PID や writer lineage は、fixture が自ら起動・制御したプロセスから因果的に取得してください。

    inotify、mtime、digest、時刻の一致だけで元 incident の writer を確定しないでください。

    production executor に対する実証と、stand-in で示したモデル上の挙動を混同しないでください。

    既存テスト:

    scripts/agent-guards/tests/test_issue_metadata_write_capability.py

    を含め relevant regressions を実行してください。ただし、既存テストの成功だけで5条件の動的比較が完了したとは扱いません。

    runtime検証不能なら SKIP: / exit 77、fallbackのみ成功なら FAIL、未実行なら未実行と記録してください。

    5. RCA と disposition を確定する

    次の3分岐のどれかを証拠に基づいて採用します。

    confirmed_defect

    current main の制御された実験で不具合を確認した場合。

    • exact failure class を記載
    • producer / consumer / executor / orchestration の最小修正箇所を特定
    • positive control と同一pathの unauthorized-child negative control を設計
    • 広域 tmp/** allow や guard全無効化を提案しない
    • 既存 owner Issue に吸収できるか判定

    confirmed_expected_behavior

    当該拒否が期待された動作だと証拠で確認できた場合。

    inconclusive

    incident 時点の writer を確定できない場合。

    • 何を実行・確認したかを記載
    • 未確定の範囲を明記
    • 次に必要な証拠を示す
    • current main の再現結果と過去incidentの帰属を分ける
    • inconclusive を expected behavior や defect不存在へ変換しない

    AC2 の比較自体を実行できなかった場合は、単に inconclusive と記してAC完了・Issueクローズ扱いにしないでください。

    #3031 の既存 approved は変更せず、#3031 の refinement や関連 docs実装を再開しないでください。

    6. 確認された欠陥がある場合の実装まで行う

    confirmed_defect なら、単なる提案で止まらず、修復の実行に進んでください。

    ただし、#3035 の research-only / Allowed Paths (none) の契約を破ってコードを直接変更してはいけません。

    6.1 Ownership と重複排除

    最初に #2584 / #2860 / #2887 / #2610 と open Issues / PRs を照合します。

    • 同じroot causeを正確に所有する既存実装Issueがあれば、そのIssueを再利用
    • 既存Issueが異なるfailure classを所有する場合はscopeを横取りしない
    • 適切なownerが無ければ、最小スコープの新規 implementation Issue を作成
    • research Issue 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 と implementation Issue #N は責務を分離
    • evidence、exact files、AC、positive/negative controls、Allowed Paths、Stop Conditions、VC、dedupe_key を整える

    必要なら issue-refinement-loop で新しい implementation Issueを精緻化してください。

    6.2 実装・テスト・PR

    このプロンプトは、実装Issue #N が確定した場合にその実装を継続することも明示的に依頼しています。

    current impl-review-loop の Root-Owned Synchronous Entry Transition を正しく使用し、前提のcontract / capability確認を飛ばさないでください。

    既存 branch / PR があれば再利用してください。無ければ repository-native workflow に従って作成してください。

    以後は次の完了経路を実行します。

    inspect → implement → test → review → fix → re-test → Draft PR → CI → independent PR review → fix/review loop → merge-ready report

    PR本文に Closes #N を設定してください。Nは実際にコード修正を所有する implementation Issue 番号です。research Issue #3035を誤って実装PRの close targetにしないでください。

    実装の必須条件:

    • 修復前のfailure classが再現される
    • 修復後に当該false positive等が解消される
    • 同一pathへのunauthorized child writeは引き続き拒否される
    • peerとchildを区別できない広域除外を採用しない
    • 既存の正常なrepair consumerと他のcommand IDを壊さない
    • 修正差分を最小限に限定する

    test-runner、pr-reviewer 等のSubAgentには current HEAD と契約を渡し、全て terminal joinしてください。

    REQUEST_CHANGES は修復してfresh HEADで再reviewします。

    CI failure / stale review / branch behind は、既存runbookに従って自律回復してください。

    Required CIとreviewが現PR HEADへ紐づいていることを確認してください。古いHEADのPASSを再利用しないでください。

    最終状態は canonical impl-review-loop が認める draft_pr_ready 相当を目標とします。

    マージは行いません。Closes #N による実装Issueの自動closeは、GitHubの設定および後続のmainへのmergeに依存するため、PR作成時点でclose済みと報告しないでください。

    7. Issue #3035 の完了処理

    RCAの結果にかかわらず、research契約が要求する成果をGitHubに残してください。

    #3035 の terminal report には以下を含めます。

    1. current main SHA、検証対象のIssue body SHA、incident HEAD
    2. 原incidentの確認済み事実と unknown
    3. process / writer attribution 比較表
    4. 5条件それぞれの実行結果・child/outer result
    5. git status / filesystem snapshot の差
    6. confirmed_defect / confirmed_expected_behavior / inconclusive
    7. AC1〜AC4 の判定と根拠
    8. 使用した SubAgent 全員の completion / join
    9. background Bash task の completion / join
    10. 関連Issueへの吸収、新規implementation Issue、または修復不要の判定
    11. テスト、実行コマンド、CI、未検証事項
    12. 残blockerと次に必要な操作

    secret、token、raw private transcriptは公開しないでください。

    #3035 が定めた調査条件を満たし、必要な ownership handoff を完了したら、research Issue #3035 を completed でクローズしてください。GitHubのfresh readbackでclose結果も確認してください。

    inconclusive でも、ACが要求する有効な比較を実行し、限界を明示した成果物が揃えば、契約に従って研究完了を判断して構いません。

    一方、AC2がSKIP・未実施・不正なfallbackである場合は、完了を偽装して閉じないでください。回復可能な環境問題は修復を試み、それでも実行不能なら証拠付きで未達として報告してください。

    8. 最終報告と完了確認

    途中の作業計画やSubAgent dispatchだけで終了しないでください。

    最終報告は次の項目を必ず含めてください。

    • 調査: repair_action.apply の root_review_pipeline tmp 書き込み拒否を因果帰属する #3035 の最終 state / URL / disposition
    • 最終 body SHA、contract review 判定
    • RCA と5条件の runtime evidence
    • incident writer の confirmed / unknown
    • SubAgent ごとの担当・結果・terminal join
    • background task join状況
    • 修復なし / 既存Issueへ吸収 / 新規Issue起票の判定
    • 実装した場合の Issue #N / PR #M / current HEAD
    • テスト・required CI・独立レビュー結果
    • Closes #N の確認
    • 既に満たしたクローズ条件と、merge後に初めて成立する条件
    • 残る technical blocker、権限上実行できなかった操作、今後の必要操作

    確認済み事実、推論、未検証を明確に区別してください。

    最優先は、正当な repair_action.apply を不必要に停止させる原因を特定し、本当に必要な場合だけ最小の修復を実行することです。

    品質と実際の開発有用性を優先し、新たな抽象層・恒久gate・permission wrapper・過剰なsecurity hardeningは導入しないでください。

    この作業を最後まで自律実行してください。

    4. 補足:Issue のクローズについて

    今回の指示では、#3035 は研究としての AC1〜AC4 と terminal report が揃えばクローズ可能です。一方、実装用 Issue #N に設定する Closes #N は、原則として PR がデフォルトブランチにマージされた際に自動クローズへつながります。

    image

    GitHub Docs

    +1

    したがって、研究Issueの完了と、実装PRのmerge待ちを分離することが重要です。これにより #3035 を不必要に開き続けることなく、修復の品質判定と人間のmerge判断を維持できます。

    また、Python公式仕様でも TemporaryDirectory はコンテキスト終了時に内容を削除し、明示的な dir は環境変数 TMPDIR より優先されます。単純な環境変数変更で解決した扱いにしない方針は妥当です。

    image

    Python 3.13.15 ドキュメント

  5. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    issue-refinement-loop: approved

  6. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    調査 terminal report (#3035)

    実行対象: current main 5680a88970d93b2f73b9e92766e23b03347fcdbb、検証対象の #3035 body SHA-256 d60bd39a331970d885745fa53f4cd8d6c9dac9a8f2d11a51d2b50e96d855fe2f、incident HEAD 60f0fc838e8b76a84c769a72b6361cd58e958e4d。refinement の終了報告とは別コメント。以下で「確認済み」は実測または source read、「推論」と「unknown」は区別して記載する。

    結論: conclusion=confirmed_defect(current main の制御実験で確認した false-positive class。incident 時点の writer は inconclusive=unknown のまま)

    AC2: 実行結果(production の _dispatch_child_and_check_postconditions() を fixture で実行)

    AC2_COUNTERFACTUAL_EVIDENCE_V1
    condition=no-peer actor=none target_path=tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md transition=none outer_exit=0 child_exit=0 detection=none attribution=unknown
    condition=peer-add actor=peer target_path=tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md transition=create outer_exit=2 child_exit=0 detection=snapshot attribution=unknown
    condition=peer-cleanup actor=peer target_path=tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md transition=delete outer_exit=2 child_exit=0 detection=snapshot attribution=unknown
    condition=transient-peer actor=peer target_path=tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md transition=create+delete outer_exit=0 child_exit=0 detection=none attribution=unknown
    condition=unauthorized-child actor=child target_path=tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md transition=create outer_exit=2 child_exit=0 detection=snapshot attribution=unknown
    condition=child-own-scratch-transient actor=child target_path=tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md transition=create+delete outer_exit=0 child_exit=0 detection=none attribution=unknown
    fixture_command_id=repair_action.apply main_head=5680a88970d93b2f73b9e92766e23b03347fcdbb harness_sha256=d5757aee906eaeaf582fce20681b1217685dc3b89e8fef9b27ea85051c48fd71
    supplementary: condition=child-own-scratch-transient は上の 6 行目(child が scratch を作成し after 前に削除、outer_exit=0)

    • fixture は invocation-owned の一時 directory 内の新規 git init repo(.gitignore は /tmp/)。child と peer の同期 barrier は fixture repo の外に置いた。canonical main root の git status --porcelain は実験前後とも 0 件で不変。harness は exit 0(SKIP でも異常終了でもない)。remote Issue mutation は全条件で not_attempted(fixture に remote が無く readback は対象外)。
    • child は repair consumer の stand-in(edit_issue_txn.py は実行していない)。証明したのは outer 検査(snapshot / git status / exit 投影)の挙動であり、実 consumer の内部挙動や incident writer の証明ではない。
    • 5 条件 + 補助 1 条件の process identity(PID。peer と child は harness が実際に起動した値。全 process は exit 確認と join 済み):
    condition orchestrator outer peer child 実験後の target join
    no-peer 1142041 1142052 - 1142054 (ppid 1142052) False joined
    peer-add 1142041 1142064 1142063 1142067 (ppid 1142064) True size=10 sha256=b77aa184db5a7359 joined
    peer-cleanup 1142041 1142080 1142079 1142082 (ppid 1142080) False joined
    transient-peer 1142041 1142092 1142091 1142094 (ppid 1142092) False joined
    unauthorized-child 1142041 1142103 - 1142105 (ppid 1142103) True size=17 sha256=8aa0ccfa3f87e394 joined
    child-own-scratch-transient 1142041 1142114 - 1142116 (ppid 1142114) False joined

    観測で確認した事実

    • 検出経路: unauthorized_write_path は 3 条件(peer-add / peer-cleanup / unauthorized-child)とも filesystem snapshot の差分のみ(差分 path は tmp/root_review_pipeline_peerX の directory と配下 file の 2 件、outer は最深の file path を 1 件だけ報告)。git status 差分は全条件で空(--ignored=matching で tmp/ が before/after とも折り畳み表示されるため)。
    • peer-add と peer-cleanup は child が正常(child_exit=0、semantic result は fixture 内で ok)でも outer exit 2 になり、child の stdout / stderr は relay されず semantic result は失われる(確認済み)。create / delete のどちらでも検出される。
    • transient-peer(before 後に生成し after 前に完全削除)と child-own-scratch-transient は検出されず exit 0。つまり scratch の存在そのものではなく「before と after の間で存在状態が異なる path」が差分になる。
    • unauthorized-child と peer-add は同一 path で outer 結果が同一(exit 2、同じ報告 path)。outer は writer を区別できない(_snapshot_repo_paths() は path kind・mtime_ns・size のみ保存し PID を持たない)。したがって unauthorized_write_path を「child の新規 write が防止された証拠」とは扱えず、attribution は全条件で unknown。

    AC1: RCA(確認済み / 推論 / unknown)

    • 確認済み(source read): run_root_review_pipeline.py の produce は repo root の tmp/ に tempfile.TemporaryDirectory(prefix="root_review_pipeline_") を作り、NamedTemporaryFile(prefix="root_review_pipeline_body_") の pinned body と history snapshot をその実行中だけ置く。TMPDIR には依存しない。executor は _dispatch_child_and_check_postconditions() で before snapshot→child→_find_unauthorized_repo_changes() の順に実行し、検出時は child の結果を返す前に _emit_unauthorized_write_failure()(exit 2)を返す。repair_action.apply は TMP_DIRECTORY_NODE_HOUSEKEEPING_COMMAND_IDS 所属で、補正対象は tmp/ の directory node のみ(tmp/ の子 path は対象外)。run_refinement_preflight.py は producer を呼ばない(repair_action.apply の child ではない)。
    • 確認済み(実装: Claude Code Auto memoryの保存判断を整理し、Issue/PR進捗の重複記録を抑制する #3031 incident の記録): 拒否 path は tmp/root_review_pipeline_wgf6ofxj/root_review_pipeline_body_o6qi_4ru.md、command は repair_action.apply、exit 2。Issue 本文の fresh readback は同一 digest(mutation が成功したとは扱っていない)。
    • 推論: 上の path 名は producer の命名と一致するため、同一 checkout で並行した produce(同一セッションの未 join background task、または独立セッション)が before/after の間に走った peer-add / peer-cleanup に該当する。
    • unknown: incident 時点の writer(同一セッション background task か独立 peer か)、検出された transition(create か delete か)、child が先に失敗していたか。時刻・path 名・今回の再現だけでは確定しない。current main の再現結果と incident の帰属は別である。

    AC3: 結論と最小修復

    conclusion=confirmed_defect(current main で false-positive class を再現)。最小変更箇所は executor ではなく producer の placement: produce の scratch を executor の snapshot が走査する repo root の外へ置く(attempt scratch は既に dir 無指定の mkdtemp で repo 外)。executor で tmp/root_review_pipeline_* を除外すると unauthorized-child の同一 path negative control が成立しなくなるため採用しない。peer-add と unauthorized-child の outer 結果が同一であることから、executor 側で両者を区別する場合は attribution の新機構が必要になり、本修復はそれを避ける。TMPDIR 変更や一意 directory 化だけでは解決しない(dir が repo/tmp に固定、suffix は既に random)。regression 方針: produce の scratch が repo tmp/ に現れないこと、修復後 placement を再現する独立 peer で outer exit 0、child の同一 path 書込みは exit 2 を維持、修復前 placement の peer 書込みが exit 2 になる再現。

    AC4: ownership(ownership_<番号>=<owns|not_owns> は各 Issue 本文を読んで確認)

    • ownership_2584=not_owns(CLOSED。ISSUE_METADATA_WRITE_COMMAND_IDS と tmp/ directory node の housekeeping。tmp/ 配下の残存 file は拒否のままと明記)
    • ownership_2860=not_owns(OPEN。model 生成の固定 /tmp scratch の run-scoped 化。run_root_review_pipeline.py は mkdir の precedent として言及されるのみ。repo 内 tmp/ に scratch を置く方針のため同じ hazard を共有する旨を 実装: root review producer の scratch を executor snapshot の外へ移し repair_action.apply の peer 競合による unauthorized_write_path を解消する #3039 の Notes に記載)
    • ownership_2887=not_owns(OPEN。Vitest results cache の peer/child attribution。path も producer も別)
    • ownership_2610=not_owns(CLOSED。root review の outer timeout と Step 2 の background launch + completion join。同一セッションの join 契約であり、独立 peer と repo tmp 配置は所有しない)

    同一 root cause を所有する Issue は無く、confirmed_defect のため新規 implementation Issue #3039(Closes を持つ実装 PR はこちら。#3035 は close target にしない)を 1 件起票した。closed Issue の reopen は行っていない。

    検証・join・未検証

  7. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    調査 terminal report (#3035) 添付: harness source

    sha256 d5757aee906eaeaf582fce20681b1217685dc3b89e8fef9b27ea85051c48fd71。再現: uv run python3 ac2_harness.py orchestrate(AC2_SRC_ROOT で対象 repo root を指定可)。exit 0=完走、77=SKIP。

    #!/usr/bin/env python3
    """AC2 counterfactual harness (invocation-owned fixture; no tracked repo source touched).
    
    Modes:
      orchestrate  : build a fixture git repo, run 5 conditions with real child/peer/outer processes
      outer        : (internal) import production skill_runtime_exec and dispatch a child at fixture root
      child        : (internal) repair-consumer stand-in child process
      peer         : (internal) independent peer process
    Exit: 0 all conditions executed; 77 SKIP (fixture cannot start); 1 harness failure.
    """
    import hashlib, importlib.util, json, os, shutil, subprocess, sys, tempfile, time
    from pathlib import Path
    
    SRC = Path(os.environ.get("AC2_SRC_ROOT", "/home/squne/projects/LOOP_PROTOCOL"))
    EXEC = SRC / "scripts/agent-guards/skill_runtime_exec.py"
    SELF = Path(__file__).resolve()
    CMD_ID = "repair_action.apply"
    ISSUE = 3035
    
    
    def wait_for(p: Path, timeout=20.0):
        t = time.time()
        while not p.exists():
            if time.time() - t > timeout:
                raise TimeoutError(str(p))
            time.sleep(0.01)
    
    
    def stat_rec(p: Path):
        try:
            s = p.lstat()
        except FileNotFoundError:
            return {"exists": False}
        d = {"exists": True, "kind": "dir" if p.is_dir() else "file", "mtime_ns": s.st_mtime_ns, "size": s.st_size}
        if p.is_file():
            d["sha256"] = hashlib.sha256(p.read_bytes()).hexdigest()[:16]
        return d
    
    
    def log(sync: Path, actor: str, event: str, **kw):
        rec = {"t_ns": time.time_ns(), "actor": actor, "pid": os.getpid(), "ppid": os.getppid(), "event": event, **kw}
        with open(sync / "events.jsonl", "a") as f:
            f.write(json.dumps(rec) + "\n")
    
    
    # ---- child (stand-in for repair consumer; production child is edit_issue_txn) ----
    def child_main(root: Path, sync: Path, cond: str):
        target = root / "tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md"
        log(sync, "child", "started")
        (sync / "child_started").write_text(str(os.getpid()))  # before-snapshot is already captured
        if cond in ("peer-add", "peer-cleanup", "transient-peer"):
            wait_for(sync / "peer_done")
        if cond == "child-own-scratch-transient":
            target.parent.mkdir(parents=True, exist_ok=True); target.write_text("child scratch\n")
            log(sync, "child", "scratch_created", target=str(target.relative_to(root)))
            shutil.rmtree(target.parent)
            log(sync, "child", "scratch_removed")
        if cond == "unauthorized-child":
            target.parent.mkdir(parents=True, exist_ok=True)
            target.write_text("child wrote this\n")
            log(sync, "child", "wrote_target", target=str(target.relative_to(root)))
        log(sync, "child", "semantic_result", result="repair_ok_remote_not_attempted")
        print("CHILD_SEMANTIC_RESULT: ok")
        return 0
    
    
    # ---- peer (independent process) ----
    def peer_main(root: Path, sync: Path, cond: str):
        d = root / "tmp/root_review_pipeline_peerX"
        f = d / "root_review_pipeline_body_t.md"
        wait_for(sync / "child_started")
        log(sync, "peer", "begin", cond=cond, before=stat_rec(f))
        if cond in ("peer-add",):
            d.mkdir(parents=True, exist_ok=True); f.write_text("peer body\n")
            log(sync, "peer", "created", after=stat_rec(f))
        elif cond == "peer-cleanup":
            shutil.rmtree(d)
            log(sync, "peer", "deleted", after=stat_rec(f))
        elif cond == "transient-peer":
            d.mkdir(parents=True, exist_ok=True); f.write_text("peer body\n")
            log(sync, "peer", "created", after=stat_rec(f))
            shutil.rmtree(d)
            log(sync, "peer", "deleted", after=stat_rec(f))
        (sync / "peer_done").write_text(str(os.getpid()))
        return 0
    
    
    # ---- outer: production executor dispatch with observation wrappers ----
    def outer_main(root: Path, sync: Path, cond: str):
        sys.path.insert(0, str(EXEC.parent))
        spec = importlib.util.spec_from_file_location("skill_runtime_exec", EXEC)
        m = importlib.util.module_from_spec(spec); sys.modules["skill_runtime_exec"] = m
        spec.loader.exec_module(m)
        snap_calls = []
        orig_snap, orig_status, orig_find = m._snapshot_repo_paths, m._git_status_paths, m._find_unauthorized_repo_changes
    
        def w_snap(*a, **k):
            r = orig_snap(*a, **k)
            snap_calls.append({k2: list(v) for k2, v in r.items() if k2.startswith("tmp")})
            return r
    
        status_calls = []
        def w_status(*a, **k):
            r = orig_status(*a, **k); status_calls.append(sorted(p for p in r if p.startswith("tmp"))); return r
    
        found = {}
        def w_find(project_root, issue, before_snapshot, before_status, command_id=""):
            r = orig_find(project_root, issue, before_snapshot, before_status, command_id)
            after_snap = snap_calls[-1]
            bs = {k: list(v) for k, v in before_snapshot.items() if k.startswith("tmp")}
            found["snapshot_diff"] = sorted(set(bs) ^ set(after_snap) | {p for p in set(bs) & set(after_snap) if bs[p] != after_snap[p]})
            found["status_new_paths"] = sorted(set(status_calls[-1]) - set(p for p in before_status if p.startswith("tmp")))
            found["returned"] = r
            return r
    
        m._snapshot_repo_paths, m._git_status_paths, m._find_unauthorized_repo_changes = w_snap, w_status, w_find
        log(sync, "outer", "dispatch_begin")
        child_argv = [sys.executable, str(SELF), "child", str(root), str(sync), cond]
        rc = m._dispatch_child_and_check_postconditions(
            dispatch_root=str(root), issue_number=ISSUE, command_id=CMD_ID, child_argv=child_argv,
            env=dict(os.environ), timeout_seconds=60, binary_output=False)
        (sync / "outer_obs.json").write_text(json.dumps({
            "outer_exit": rc, "before_tmp_snapshot": snap_calls[0] if snap_calls else None,
            "after_tmp_snapshot": snap_calls[-1] if snap_calls else None,
            "before_status_tmp": status_calls[0] if status_calls else None,
            "after_status_tmp": status_calls[-1] if status_calls else None, **found}))
        log(sync, "outer", "dispatch_end", outer_exit=rc)
        return rc
    
    
    def make_fixture(base: Path) -> Path:
        root = base / "fixture_repo"; root.mkdir()
        g = lambda *a: subprocess.run(["git", "-C", str(root), *a], check=True, capture_output=True)
        g("init", "-q", "-b", "main"); g("config", "user.email", "f@x"); g("config", "user.name", "f")
        (root / ".gitignore").write_text("/tmp/\n"); (root / "README.md").write_text("fixture\n")
        g("add", "."); g("commit", "-qm", "init")
        return root
    
    
    def run_condition(base: Path, cond: str):
        root = make_fixture(base / cond if (base / cond).mkdir() is None else base)
        sync = base / f"sync_{cond}"; sync.mkdir()
        if cond == "peer-cleanup":  # pre-existing before-time file, owned by an earlier independent peer
            d = root / "tmp/root_review_pipeline_peerX"; d.mkdir(parents=True)
            (d / "root_review_pipeline_body_t.md").write_text("pre-existing peer body\n")
        target = root / "tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md"
        pre = stat_rec(target)
        peer = None
        if cond in ("peer-add", "peer-cleanup", "transient-peer"):
            peer = subprocess.Popen([sys.executable, str(SELF), "peer", str(root), str(sync), cond])
        outer = subprocess.Popen([sys.executable, str(SELF), "outer", str(root), str(sync), cond],
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
        out, err = outer.communicate(timeout=90)
        if peer: peer.wait(timeout=30)
        ev = [json.loads(l) for l in (sync / "events.jsonl").read_text().splitlines()]
        obs = json.loads((sync / "outer_obs.json").read_text())
        post = stat_rec(target)
        return {"cond": cond, "orchestrator_pid": os.getpid(), "outer_pid": outer.pid, "peer_pid": peer.pid if peer else None,
                "child_pid": next((e["pid"] for e in ev if e["actor"] == "child"), None),
                "child_ppid": next((e["ppid"] for e in ev if e["actor"] == "child"), None),
                "target_before_dispatch": pre, "target_after": post, "events": ev, "outer_obs": obs,
                "outer_stdout": out.strip()[:300], "outer_stderr": err.strip()[:400]}
    
    
    def orchestrate():
        base = Path(tempfile.mkdtemp(prefix="ac2_fixture_"))
        try:
            subprocess.run(["git", "--version"], check=True, capture_output=True)
            results = []
            for cond in ["no-peer", "peer-add", "peer-cleanup", "transient-peer", "unauthorized-child", "child-own-scratch-transient"]:
                cdir = base / cond; cdir.mkdir()
                results.append(run_condition(cdir, cond) if False else _run(cdir, cond))
        except (OSError, subprocess.SubprocessError, TimeoutError) as e:
            print(f"SKIP: fixture cannot start: {type(e).__name__}: {e}")
            return 77
        print(json.dumps(results, indent=1))
        shutil.rmtree(base, ignore_errors=True)
        return 0
    
    
    def _run(cdir: Path, cond: str):
        return run_condition_in(cdir, cond)
    
    
    def run_condition_in(cdir: Path, cond: str):
        global make_fixture_base
        root = make_fixture(cdir)
        sync = cdir / "sync"; sync.mkdir()
        if cond == "peer-cleanup":
            d = root / "tmp/root_review_pipeline_peerX"; d.mkdir(parents=True)
            (d / "root_review_pipeline_body_t.md").write_text("pre-existing peer body\n")
        target = root / "tmp/root_review_pipeline_peerX/root_review_pipeline_body_t.md"
        pre = stat_rec(target)
        peer = None
        if cond in ("peer-add", "peer-cleanup", "transient-peer"):
            peer = subprocess.Popen([sys.executable, str(SELF), "peer", str(root), str(sync), cond])
        outer = subprocess.Popen([sys.executable, str(SELF), "outer", str(root), str(sync), cond],
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
        out, err = outer.communicate(timeout=90)
        if peer: peer.wait(timeout=30)
        ev = [json.loads(l) for l in (sync / "events.jsonl").read_text().splitlines()]
        obs = json.loads((sync / "outer_obs.json").read_text())
        return {"cond": cond, "orchestrator_pid": os.getpid(), "outer_pid": outer.pid, "peer_pid": peer.pid if peer else None,
                "child_pid": next((e["pid"] for e in ev if e["actor"] == "child"), None),
                "child_ppid": next((e["ppid"] for e in ev if e["actor"] == "child"), None),
                "target_before_dispatch": pre, "target_after": stat_rec(target), "events": ev, "outer_obs": obs,
                "outer_stdout": out.strip()[:300], "outer_stderr": err.strip()[:400]}
    
    
    if __name__ == "__main__":
        mode = sys.argv[1] if len(sys.argv) > 1 else "orchestrate"
        if mode == "orchestrate":
            sys.exit(orchestrate())
        root, sync, cond = Path(sys.argv[2]), Path(sys.argv[3]), sys.argv[4]
        sys.exit({"outer": outer_main, "child": child_main, "peer": peer_main}[mode](root, sync, cond))
  8. squne121 commented on Oct 11, 2026

    @squne121
    OwnerAuthor

    調査完了: conclusion=confirmed_defect(current main の制御実験。incident writer は unknown のまま)。AC1-AC4 の evidence は #3035 (comment) 、harness は #3035 (comment) 。修復は実装 Issue #3039 が所有(#3035 は close target にしない)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions