Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "契約実行ラッパー(scripts/agent-guards/skill_runtime_exec.py)の before/after repo-wide スナップショット比較が、session-manifest hook(.claude/hooks/session_manifest_debounce.mjs 等)自身の非同期書き込みを実行コマンドの unauthorized write と誤認し unauthorized_write_path で fail-close するバグを、hook 専用の新設 subtree artifacts/session-manifest-runtime/ を race-tolerant 除外対象に加えることで修正する(#1343 の修正範囲外だった穴。OWNER レビュー https://github.com/squne121/loop-protocol/issues/1409#issuecomment-4935283248 により repo-root artifacts/ 全体除外案は REQUEST_CHANGES、専用 subtree 方式を採用)"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: N/A(parent なし)
- Desired Destination: N/A
Current Validated Scope
- session-manifest hook(
.claude/hooks/session_manifest_debounce.mjs/.claude/hooks/generate_session_manifest_from_hook.mjs)が書き込む runtime file(events / lock / tmp / final manifest)の出力先を、repo root 直下のartifacts/から hook 専用の新設 subtreeartifacts/session-manifest-runtime/(events//locks//tmp//manifests/)へ変更する scripts/agent-guards/skill_runtime_exec.pyの_VOLATILE_PEER_SESSION_ROOT_RELSに、repo-rootartifacts/全体ではなくartifacts/session-manifest-runtimeのみを追加する(_snapshot_repo_pathsの os.walk pruning と_find_unauthorized_repo_changes/_is_volatile_peer_session_pathの両方に反映)- 上記シンボルは「他セッション由来」に限らない実態(同一セッションの非同期 background worker)を正確に表すため
_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS/_is_race_tolerant_unattributable_pathへ改名する - 固定 sleep ベースではなく、実際の debounce process / generator を用いた同期型 lifecycle integration test を追加する
docs/dev/agent-skill-boundaries.mdの Parallel Agent Runtime Safety inventory を更新し、新 subtree・改名後シンボル名・known limitation・実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 strict mode との mode 別保証を明記する
Remaining Parent Gaps
なし
Outcome
scripts/agent-guards/skill_runtime_exec.py が、実行セッション自身の PostToolUse / SubagentStop hook が専用 subtree artifacts/session-manifest-runtime/ 配下へ非同期に書き込む session manifest 関連ファイル(events / lock / tmp / atomic rename / final manifest)を、実行コマンド自身の unauthorized write と誤認せず、unauthorized_write_path で誤って fail-close しない状態になる。一方で artifacts/ 配下のそれ以外の領域(artifacts/<issue>/issue-metadata/** を含む controlled mutation の入力・marker namespace や、その他 child command による任意の書き込み)は、従来どおり監査対象として残る。対応する実際の lifecycle に基づく統合テストと known-limitation テストが追加され、全件 PASS している状態。
In Scope
.claude/hooks/session_manifest_debounce.mjsおよび.claude/hooks/generate_session_manifest_from_hook.mjsの出力先パス構築ロジックを、repo root 直下artifacts/*.json/artifacts/.lock-*/artifacts/.tmp-*からartifacts/session-manifest-runtime/{events,locks,tmp,manifests}/へ変更するscripts/agent-guards/skill_runtime_exec.pyの_VOLATILE_PEER_SESSION_ROOT_RELS(_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSへ改名)にartifacts/session-manifest-runtimeのみを追加する(repo-rootartifacts/全体は追加しない)_is_volatile_peer_session_path(_is_race_tolerant_unattributable_pathへ改名)と_snapshot_repo_pathsの os.walk pruning ロジックの両方が新 subtree のみを正しく除外し、artifacts/<issue>/issue-metadata/**等それ以外のartifacts/配下は引き続き監査対象のままであることを確認する- 既存の
.claude/worktrees/.claude/artifacts/issue-refinement-loop除外ロジックと同一パターンで実装する(新しい除外機構は導入しない) - 実際の
.claude/hooks/session_manifest_debounce.mjs(または debounce worker)を別プロセスとして起動し、ready-file または同等の同期バリアで「wrapper の before snapshot 完了」を待ってから lock 作成・metadata 更新・temporary file 作成・atomic rename・event file 削除・failed rename を実行する、固定 sleep に依存しない同期型 integration test をscripts/agent-guards/tests/に追加する - child command 自身が新 subtree の外側(
artifacts/unrelated/**、artifacts/<issue>/issue-metadata/**、artifacts/.envを含む)へ書き込んだ場合は、従来どおりunauthorized_write_pathで fail-close することを検証する回帰テストを追加する - race-tolerant stdlib mode では child 自身による新 subtree への self-write を区別できないことを、既存の
test_self_write_to_worktrees_is_known_unsupported_in_stdlib_modeと同じパターンの known-limitation テストとして明示する docs/dev/agent-skill-boundaries.mdの Parallel Agent Runtime Safety セクションを更新し、volatile/race-tolerant-unattributable root inventory にartifacts/session-manifest-runtimeを追加し、改名後のシンボル名・known limitation・#1363(strict_strace mode)との mode 別契約(race_tolerant では subtree を無条件除外するが、strict_strace では traced child による同 subtree への write は fail-close する)を明記する
Out of Scope
- repo-root
artifacts/全体を除外対象に加える変更(OWNER レビューで REQUEST_CHANGES、Blocker 1/2 により却下) _VOLATILE_PEER_SESSION_ROOT_RELS(改名後_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS)以外の除外機構の新規導入(inotify/fanotify/stracestrict mode / Landlock 等。いずれも 実装: 契約実行ラッパーの unauthorized_write_path 誤検知が repo root artifacts/ 配下でも発生する問題を修正する #1409 の外部技術調査で不採用または将来課題と判断済み。stracestrict mode 自体は 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 の担当)#1363(Linux-only optional strict trace attribution mode)自体の実装。本 Issue は#1363との mode 別契約を明記するのみで、strict mode の実装は行わないallowed_write_rootsの値そのものの変更(各コマンド定義はcommand_registry.pyの既存契約を維持する)issue-refinement-loopや他 skill 側の呼び出しフローの変更local_main_branch_guard等、他の hook / guard スクリプトの変更- Landlock ベースの将来の Linux-only prevention mode(別 Issue で扱う)
Acceptance Criteria
- AC1: 実際の
.claude/hooks/session_manifest_debounce.mjs(または同等の generator process)を別プロセスで起動し、ready-file/barrier で before-snapshot 完了後にartifacts/session-manifest-runtime/配下へ書き込む同期型 integration test で、修正前コードではunauthorized_write_pathが再現し、修正後コードでは成功することを示す - AC2: race-tolerant stdlib mode で、
artifacts/session-manifest-runtime/**への peer/background write(新規ファイル作成・既存ファイル更新の両方)がunauthorized_write_pathを誤検知しないことを確認する - AC3: child command 自身が
artifacts/session-manifest-runtime/の外側(artifacts/unrelated/**/artifacts/<issue>/issue-metadata/**/artifacts/.envを含む)へ実際に書き込んだ場合は、従来どおりunauthorized_write_pathで fail-close する(回帰なし) - AC4: race-tolerant stdlib mode では child command 自身による
artifacts/session-manifest-runtime/への self-write を hook 由来の write と区別できないことを、known-limitation テストとして明示する - AC5: lock 作成・metadata 更新・temporary file 作成・atomic rename・event file 削除・failed rename という実際の writer lifecycle を、固定 sleep のみに依存しない同期バリアで検証する
- AC6: 既存の
.claude/worktrees/.claude/artifacts/issue-refinement-loop除外に対する既存6テスト(test_unrelated_process_write_to_worktrees_does_not_fail/test_unrelated_process_write_to_other_issue_artifacts_does_not_fail/test_self_write_outside_allowed_roots_still_fails/test_self_write_inside_allowed_roots_still_succeeds/test_self_write_to_worktrees_is_known_unsupported_in_stdlib_mode/test_self_write_to_other_issue_artifacts_is_known_unsupported_in_stdlib_mode)が引き続き全件 PASS する - AC7:
#1363(Linux-only optional strict trace attribution mode)へのハンドオフとして、race_tolerant_stdlib mode ではartifacts/session-manifest-runtime/**の peer/background write を無条件で無視するが、strict_strace mode(#1363で実装予定)では traced child process による同 subtree への write を fail-close すべきであり、tracer 外の peer/hook process による write は誤帰属してはならないという mode 別契約がdocs/dev/agent-skill-boundaries.mdに明記されている - AC8:
docs/dev/agent-skill-boundaries.mdの Parallel Agent Runtime Safety セクションの volatile/race-tolerant-unattributable root inventory がartifacts/session-manifest-runtimeを含むよう更新され、改名後のシンボル名(_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS)と known limitation が記載されている
Verification Commands
実装前は AC1〜AC5・AC7・AC8 対応の test/file/記述がまだ存在しないため、
対応する VC はいずれも baseline で fail する(AC1〜AC5 は未作成ファイル
test_skill_runtime_exec_session_manifest_lifecycle.py への pytest nodeid 指定で
collection error、AC7・AC8 は rg が該当記述なしで exit 1)。AC6 は既存回帰のため
baseline から PASS する。
# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_real_debounce_process_write_to_session_manifest_runtime_does_not_fail
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_race_tolerant_stdlib_excludes_session_manifest_runtime_subtree
# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_self_write_outside_session_manifest_runtime_still_fails
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_self_write_to_session_manifest_runtime_is_known_unsupported_in_stdlib_mode
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py::test_real_debounce_process_lock_rename_and_failed_rename_lifecycle
# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
# AC7
$ rg -n "strict_strace" docs/dev/agent-skill-boundaries.md
# AC8
$ rg -n "artifacts/session-manifest-runtime" docs/dev/agent-skill-boundaries.mdAllowed Paths
- scripts/agent-guards/skill_runtime_exec.py
- scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py
- scripts/agent-guards/tests/test_skill_runtime_exec_session_manifest_lifecycle.py
- .claude/hooks/session_manifest_debounce.mjs
- .claude/hooks/generate_session_manifest_from_hook.mjs
- .claude/hooks/tests/test_session_manifest_debounce.py
- .claude/hooks/tests/test_generate_session_manifest_from_hook.py
- docs/dev/agent-skill-boundaries.md
Runtime Verification Applicability
- decision: immediate
- reason: 本 Issue の障害は Claude Code の
async: truePostToolUsehook、detached debounce worker、複数プロセス、filesystem の write/rename/delete タイミングの重なりに起因するため、process 起動・プロセス間同期・実際の I/O タイミングを伴う runtime 動作検証が必要であり、static verification(unit test のみ)では不十分である - required_evidence:
- 実際の hook payload(
.claude/hooks/session_manifest_debounce.mjsの実行ログ) - child process と background debounce worker との同期証跡(ready-file/barrier 経由)
- 作成・rename・削除された repo-relative path の実測値
skill_runtime_exec.pyの実行 return code とreason_code- race_tolerant mode と(将来の)strict mode の ownership matrix
applicable_acs: AC1, AC2, AC3, AC4, AC5(実プロセス起動・実ファイル I/O タイミングを伴うため runtime 検証必須。AC6〜AC8 は既存回帰確認 / ドキュメント記述確認のため static verification で十分)
execution_environment: ローカル Linux(wsl2-ubuntu)環境上で、.claude/hooks/session_manifest_debounce.mjs(Node.js,node実行可能であること)を実プロセスとしてsubprocess.Popen等で別プロセス起動できること。ネットワークアクセス不要。CI(GitHub Actions ubuntu-latest runner)でも同条件で再現可能
skip_conditions:node実行系が利用できない、または別プロセス起動権限がサンドボックスで禁止されている環境では該当 AC の runtime 検証をスキップし、fallback_policyに従う。static-only な CI lane(pnpm lint等)では対象外
fallback_policy: runtime 実行環境が利用できない場合は、当該 AC の VC 実行結果をhuman_judgmentとして扱い、実装者は known-limitation として PR 本文にスキップ理由と代替の static 検証結果(該当テストファイル・関数の存在確認、コードレビューによるロジック確認)を明記する。fallback 時に AC をgoとして自己申告してはならない
artifact_requirements: 同期型 integration test の実行ログ(pytest 標準出力、debounce worker の stdout/stderr、ready-file 生成タイムスタンプ)をscripts/agent-guards/tests/配下のテスト実行結果として保存し、PR の Verification Commands 実行結果に添付する
- 実際の hook payload(
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
#1363の strict_strace mode 実装そのものに踏み込む必要が生じた場合(本 Issue は mode 別契約の明記までに限定する)
Required Skills
なし
Required Design References
- docs/dev/agent-skill-boundaries.md#Parallel Agent Runtime Safety(並列エージェント実行安全性) — volatile/race-tolerant-unattributable root inventory の正本
- docs/dev/runtime-verification-policy.md#Runtime Verification Applicability —
immediate判定基準 - docs/dev/hook-boundaries.md — hook はセキュリティ境界でなく fail-closed local guardrail であるという前提の正本
- Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343(クローズ済み)—
_VOLATILE_PEER_SESSION_ROOT_RELSを導入した先行修正 - Issue 調査: volatile peer-session root への child プロセス自己書き込みの strict attribution を検討する #1356(クローズ済み)— volatile peer-session root への child self-write の strict attribution 調査
- Issue 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363(OPEN)— strict_strace mode 追加。本 Issue との mode 別契約 handoff 先
- Issue worktree_scope_guard に local main scratch 出力先の安全な例外 (LOCAL_MAIN_SCRATCH_ALLOW_V1) を追加する #974(クローズ済み)—
.gitignoreのLOCAL_MAIN_SCRATCH_ALLOW_V1safe scratch 例外。ただし本 Issue の除外判断は gitignore 単独を根拠にせず、artifacts/session-manifest-runtimeという hook 専有 subtree への限定を根拠とする - PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 の Safety Claim Matrix と human REQUEST_CHANGES 記録 —
.claude/worktrees/.claude/artifacts/issue-refinement-loopを known limitation として受容した先例
Scope Delta(任意)
N/A
Notes for Reviewer
- 発端: 2026-07-09、Issue 実装: ChatGPT GitHub retro E2E proof と Issue/PR operation session index を追加する #1405 の issue-refinement-loop 実行中に
uv run python3 scripts/agent-guards/skill_runtime_exec.py --command-id preflight.run --issue-number 1405 --repo squne121/loop-protocolを root から複数回連続実行し、毎回unauthorized_write_pathで失敗した。報告された unauthorized path は毎回artifacts/private-agent-session-manifest-posttooluse-*.json/...-subagentstop-*.jsonという、当該コマンドを実行しているセッション自身のPostToolUsehook(.claude/hooks/session_manifest_debounce.mjs、async 実行)が書き込むファイルだった。原因の正確な記述は「当該コマンド自身のPostToolUsehook が割り込む」ではなく、「同一セッションの先行PostToolUseevent から非同期継続している debounce worker、または concurrent Stop/SubagentStop hook が、後続のskill_runtime_exec.py実行区間と重なってartifacts/を更新する」である。 - OWNER レビュー(https://github.com/squne121/loop-protocol/issues/1409#issuecomment-4935283248)は、当初提案の「repo-root
artifacts/全体を_VOLATILE_PEER_SESSION_ROOT_RELSに追加する」修正を REQUEST_CHANGES とした。理由は、artifacts/が session-manifest 専用の disposable telemetry namespace ではなく、controlled mutation policy がartifacts/{issue}/issue-metadata/{command-id}/を machine-readable な入力・marker namespace として使用しているため、artifacts/全体を除外すると provenance detector としての機能が失われる点にある。 - 採用した設計は、OWNER レビューの「第一選択」である hook-owned namespace の分離(
artifacts/session-manifest-runtime/への出力先変更 + 当該 subtree のみを race-tolerant 除外対象に追加)。「次善策」(root 直下の厳密な path matcher による部分除外)は、child が同じ filename pattern を偽装できる spoofability を残すため不採用とした。 inotify/fanotify/ Landlock はいずれも本 Issue の解決策としては不採用(inotifyは書き込み元プロセスを区別できない、fanotifyの recursive directory monitoring は race を伴う、Landlock は将来の prevention mode 候補だが本 Issue の snapshot-diff 方式の小規模修正には過大なため別 Issue に分離)。
Activity
squne121 commentedon Jul 10, 2026
判定
REQUEST_CHANGES。現行の契約のまま実装を開始すべきではありません。
#1409 の障害診断自体には妥当性があります。リポジトリ設定では
Bash|Edit|WriteのPostToolUseに非同期 session-manifest hook が登録され、debounce worker は detached process として継続し、最終的にリポジトリ直下のartifacts/に lock、temporary file、manifest を書き込みます。したがって、別のコマンドの before/after snapshot 中に同一セッション由来のバックグラウンド書き込みが混入し、unauthorized_write_pathが誤検知する状況は成立します。しかし提案されている「
artifacts/全体を_VOLATILE_PEER_SESSION_ROOT_RELSに追加する」修正は、誤検知の除去範囲を大幅に超えます。これは局所的な false-positive 修正ではなく、リポジトリ直下artifacts/**全域を unauthorized-write 監査から外す変更です。既存の #1343 / PR #1349 で明示的に受容した known limitation を、性質の異なるファイル群まで無条件に拡大しています。2026年7月10日時点で #1409 はコメント0件で、検索した範囲では対応PRも確認できませんでした。以下は実装差分ではなく、Issue契約そのものに対する敵対的レビューです。なお、本件の重大性はOSレベルのセキュリティ境界ではなく、リポジトリが定義する guardrail と provenance integrity の劣化として評価しています。リポジトリ自身も hook を完全なセキュリティ境界とは位置付けていません。
Blocker 1 —
artifacts/**全体の除外は、無制限の false-negative aperture を作る現在の実装では volatile root は
os.walk()の走査時点で再帰ごと prune され、git statusの差分でも同じ prefix が除外されます。ここにartifactsを追加すると、その配下で child command が行った作成、更新、削除、rename 等は、race-tolerant stdlib mode から構造的に見えなくなります。この副作用は推測ではありません。既存テストは、child command 自身が
.claude/worktrees/**や別Issueの.claude/artifacts/issue-refinement-loop/**に書き込んでも成功することを、意図的な known limitation として固定しています。PR #1349 の Safety Claim Matrix も、人間のREQUEST_CHANGES後にこの制限を明文化して承認された経緯を記録しています。対して #1409 の AC3 は「
artifacts/**と既存 volatile root 以外への書き込みが失敗すること」しか要求していません。つまり、新たに作る最大の盲点をテスト対象から意図的に外した構造です。最低でも次のテストが必要です。ただし、このテストを追加して known limitation として受容するだけでは、次の Blocker 2 を解消できません。
Blocker 2 —
artifacts/は純粋な disposable telemetry namespace ではないこのリポジトリでは、リポジトリ直下
artifacts/は単なる session-manifest 出力先ではありません。controlled mutation policy はartifacts/{issue_number}/issue-metadata/{command-id}/を入力・marker namespace として使用し、issue_body.update、issue_comment.publish、contract_snapshot.publishなどの操作に関係する machine-readable data を配置します。ポリシー上の write root 自体もartifacts/です。したがって
artifacts/**全体を監査対象外にすると、例えば child command が次のようなファイルを変更しても、この wrapper は検出できなくなります。controlled executor 側には schema、binding、symlink、readback 等の追加検証があるため、これだけで直接的なremote mutation bypassが成立するとまでは断定しません。しかし、「どのプロセスが、どの意図で、その入力を作成・変更したか」という独立した provenance detector が消えることは確実です。
skill_runtime_exec.pyが本来検出しようとしている unauthorized side effect の範囲と正面から衝突します。修正は
artifacts/全体ではなく、session-manifest hook が排他的に所有する専用namespaceだけに限定すべきです。Blocker 3 — Issue契約が現行の readiness rule に違反している
#1409 は
issue_kind: implementationであるにもかかわらず、Required Design Referencesが「なし」です。現行の contract readiness checker は「なし」を placeholder として扱い、implementation issue には少なくとも1件の実在する repository-relative design document を要求します。この契約は現在の checker でRDR001になる構造です。さらに SSOT の Parallel Agent Runtime Safety は volatile root として
.claude/worktrees/**、.claude/artifacts/**等を列挙していますが、リポジトリ直下artifacts/**は含んでいません。#1409 は normative root inventory を変更する提案であるにもかかわらず、Allowed Paths に設計文書がなく、SSOT更新も不可能です。最低限、次を Required Design References に追加する必要があります。
Allowed Paths にも少なくとも
docs/dev/agent-skill-boundaries.mdを追加すべきです。Blocker 4 — Runtime Verification
not_applicableは、Issueの主張と矛盾しているリポジトリの runtime verification policy では、
not_applicableは process launch、communication、I/O なしに static verification だけで保証できる場合の判断です。#1409 の障害は async hook、detached worker、複数プロセス、filesystem timing の重なりを原因としており、「process起動・I/O・runtime動作検証は不要」という記述は成立しません。また因果関係の記述にも修正が必要です。Claude Code の公式仕様では
PostToolUseは tool call が成功した後に発火し、async: trueの hook はClaude Codeが完了を待たずにバックグラウンドで継続します。したがってskill_runtime_exec.pyを実行している当該 Bash tool call 自身のPostToolUseが、同じ wrapper の内部 snapshot 区間に割り込むことはありません。重なる可能性があるのは、先行tool callから残っている async hook、debounce worker、または同時進行の SubagentStop/Stop 系処理です。([Claude]1) (Claude)Issueの原因記述は次のように直すべきです。
Runtime Verification Applicability は
immediateが妥当です。Major 5 — 提案テストが実際のwriter lifecycleを再現していない
#1409 のACは「新規ファイル」と「既存ファイル更新」の2形態だけですが、実際のsession-manifest実装は以下を行います。
artifacts/session-manifest-debounce/events/*.jsonworker.lockの作成、metadata更新、削除root
artifacts/.lock-*root
artifacts/.tmp-*temporary fileからfinal manifestへのatomic rename
failure時の
.failedrenamefinal
private-agent-session-manifest-*.json既存の concurrency test helper も「unrelated process」というテスト名に反して、実際には同じpytest process内の
threading.Threadと固定sleepを使っています。race-tolerant snapshotの簡易回帰テストとしては機能しますが、今回の「同一セッションの別background process」という因果関係の証拠にはなりません。さらに Python の公式仕様では、
os.walk()がdirectory listingを生成中に追加・削除されたfileを含むかどうかは未規定です。sleep依存テストは実行環境によって false green / flaky になり得ます。([Python documentation]2)必要なのは固定sleepではなく、次のような同期型integration testです。
session_manifest_debounce.mjsまたは generator を別processで起動する。Major 6 — #1363 の strict attribution mode と契約が衝突する
#1363 は同じ
skill_runtime_exec.pyに Linux-only optionalstrict_stracemode を追加し、race-tolerant modeで除外されるrootについても、child process由来と証明できたwriteはfail-closeする設計です。#1409 はこのIssueを参照せず、merge順序、mode別挙動、test ownershipを定義していません。strict modeでは、
artifacts/session-manifest-...namespaceを race-tolerant用の除外リストに追加したとしても、child-attributed writeまで除外してはいけません。次のhandoffを明文化すべきです。外部仕様上も、
strace -fは fork/vfork/clone の子孫を追跡しますが、%fileはpathname引数を取るsyscallだけです。既にopen済みのFDに対するwrite()、pwrite*()、ftruncate()等をpathに帰属させるには%desc系syscall、FD table、dup/fork inheritance、--decode-fds=path相当の処理が必要です。#1356 / #1363 の設計がこの複雑さを要求しているのは妥当です。([man7.org]3) ([man7.org]3) ([man7.org]3)Major 7 — 「gitignored safe scratchだから全体除外可能」は不正確
.gitignoreには確かにartifacts/が local scratch prefix として登録されています。しかし #974 が定義したsafe scratch例外は、単にgitignoredであることを条件としていません。untracked、safe prefix、非機密、symlink componentなし、containment確認などの複数条件を満たす直接のWrite/Edit系操作に限定され、Bash child process全体への包括的な許可は延期されています。したがって、
という推論は成立しません。gitignoreはversion-control policyであり、write authorityやprovenance trustを付与するものではありません。
外部技術調査を踏まえた実装判断
inotify:不採用inotifyeventには書き込み元user/process情報がなく、自分自身のwriteと他processのwriteを区別できません。またmmap系変更を捕捉せず、recursive monitoringにもraceがあります。今回のattribution問題の解決策にはなりません。([man7.org]4)fanotify:主方式としては不採用fanotifyはeventにPIDを含められますが、directory monitoringは標準ではrecursiveではなく、新規subdirectoryへのmark追加にはraceがあり、queue overflow時にはevent lossも発生します。権限、kernel configuration、platform portabilityを含めると、stdlib default modeの代替としては過大です。([man7.org]5) ([man7.org]5) ([man7.org]5)strace:Linux-only optional strict modeとして妥当#1356 / #1363 の方針どおり、defaultにはせず、availability check、parse failure fail-close、raw trace非公開、child tree + FD attributionを満たす場合に限定すべきです。
--read/--writedumpはfile contentを含み得るため使用しない判断も妥当です。Landlock:将来のLinux strict-prevention modeとして優先検討
Linux Landlock はunprivileged processが自分自身と将来の子孫をfilesystem rulesetで制約でき、write、create、remove、rename、truncateを実行前に拒否できます。事後snapshotやtrace parsingより構造的に強く、専用telemetry namespaceとallowed artifact rootだけにwrite権限を与える設計に適しています。([Linux カーネル ドキュメント]6) ([Linux カーネル ドキュメント]6) ([Linux カーネル ドキュメント]6)
ただし、sandbox適用前にopenされたFDは制約外で、
chmod、chown、utime等は現時点で完全には制約できません。ABI/kernel support検査と、適用前FDの管理が必要です。したがって #1409 の小規模修正に混ぜず、将来のLinux-only prevention modeとして分離するのが妥当です。([Linux カーネル ドキュメント]6) ([Linux カーネル ドキュメント]6)推奨する設計
第一選択:hook-owned namespaceを分離する
session-manifest関連の全runtime fileを、例えば次の専用subtreeに集約します。
race-tolerant modeで除外するのは、このsubtreeだけです。
_VOLATILE_PEER_SESSION_ROOT_RELSという名前も修正対象です。今回のwriterは「peer session」とは限らず、同一セッションの非同期background workerです。_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS等の方が実際の保証内容を正確に表します。この設計なら以下を維持できます。
このため、#1409 の「session manifestの出力先変更はOut of Scope」は撤回が必要です。出力先を変えずにroot全体を除外する方が、明らかに大きい設計変更だからです。
次善策:root直下の厳密なpath matcher
互換性上どうしてもmanifestをroot直下に残す場合は、少なくとも以下だけを除外します。
ただし race-tolerant modeではchild自身が同じfilename patternを偽装できるため、専用subtreeより弱い方式です。このspoofabilityをknown limitationとして明記する必要があります。
修正後の最低限のAcceptance Criteria
Runtime Verificationは次の形が適切です。
Allowed Pathsも少なくとも次まで拡張すべきです。
最終レビューコメント
squne121 commentedon Jul 10, 2026
Refinement Loop 実行状態報告(isolation worktree 経由)
実行したコマンドと結果
uv run --locked python3 .claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py --issue-number 1409 --repo squne121/loop-protocol --anchor-comment-url https://github.com/squne121/loop-protocol/issues/1409#issuecomment-4935283248STATUS: pass/NEXT_ACTION: proceed(planner_fail_closed: false、blockers: [])plan_refinement_loop.py(同じ planner input を stdin 投入)でdecisionsを確認investigation_policy.required = true(target_paths にscripts/agent-guards/skill_runtime_exec.py等)web_research_policy.required = true(ただしcritical_external_claimsの中身は VC のpytest -kコマンド文字列・AC本文であり、外部仕様主張の誤検知の可能性が高い。実際に外部 web 調査が必要な技術的主張は見当たらなかった)scope_delta_decision.status = fail_closed,reason = no_anchor_scope_reframe_v1_payload,implementation_go = false(アンカーコメントに構造化ANCHOR_SCOPE_REFRAME_V1payload が無いため、Allowed Paths 等の自動拡張は不可)scripts/agent-guards/skill_runtime_exec.py、scripts/agent-guards/tests/test_skill_runtime_exec_unauthorized_write_path.py、.gitignore)_VOLATILE_PEER_SESSION_ROOT_RELSは現状.claude/worktreesと.claude/artifacts/issue-refinement-loopのみで、repo root 直下artifacts/は未登録であることを確認(Issue の障害診断自体は技術的に正確)。test_unrelated_write_to_repo_root_artifacts_does_not_fail/test_existing_repo_root_artifacts_file_update_does_not_failは未実装(baseline:pytest -kで exit 5 / collected 0 selected を確認)。AC3/AC4 が指す既存テスト名は既に存在し PASS 済み。uv run --locked python3 .claude/skills/review-issue/scripts/check_issue_contract.py --issue 1409 --repo squne121/loop-protocol --jsonVERDICT: approve(blocking_issues: [])。ただしこれは C1〜C13 の構造的・決定論的チェックのみであり、契約の技術的妥当性(設計判断の是非)は対象外。重要な未反映事項: アンカーコメントの REQUEST_CHANGES が Issue 本文に未反映
アンカーコメント(#1409 (comment) 、OWNER・squne121)は
REQUEST_CHANGES判定であり、現行の Issue 契約のままでの実装着手に反対しています。要旨:artifacts/全体を_VOLATILE_PEER_SESSION_ROOT_RELSに追加する現行案は、誤検知除去の範囲を大幅に超え、repo rootartifacts/**全域を unauthorized-write 監査から外してしまう。artifacts/は disposable telemetry 専用ではなく、controlled mutation policy の write root(artifacts/{issue_number}/issue-metadata/...)でもあるため、全域除外は provenance detector を消してしまう。issue_kind: implementationにもかかわらずRequired Design References: なしは readiness rule 違反(RDR001相当)。SSOT(docs/dev/agent-skill-boundaries.mdの Parallel Agent Runtime Safety)が repo rootartifacts/**を volatile root として列挙しておらず、SSOT 更新も必要。Runtime Verification Applicability: not_applicableは矛盾(非同期 hook・detached worker・複数プロセス・filesystem timing が絡むためimmediateが妥当)。原因記述(「当該コマンド自身の PostToolUse hook が更新する」)も不正確で、正しくは「先行 tool call から継続する async debounce worker / 並行 Stop・SubagentStop hook」。#1363(strict_stracemode 追加)との mode 別保証の handoff が未定義。.gitignoreで scratch 領域だから監査除外してよい」という推論は worktree_scope_guard に local main scratch 出力先の安全な例外 (LOCAL_MAIN_SCRATCH_ALLOW_V1) を追加する #974 の safe scratch 例外の前提(untracked / safe prefix / Write・Edit 系操作限定)と矛盾。推奨設計(第一選択)は、
artifacts/全体ではなく専用 subtreeartifacts/session-manifest-runtime/のみを race-tolerant 除外対象にし、artifacts/<issue>/issue-metadata/**等は引き続き監査対象に残すというもので、AC1〜AC8 の全面差し替え、Required Design Referencesの追加、Runtime Verification: immediateへの変更、Allowed Paths の拡張(.claude/hooks/session_manifest_debounce.mjs等を含む)を要求しています。なぜ本文を自動書き換えしなかったか
scope_delta_decisionがfail_closed(reason: no_anchor_scope_reframe_v1_payload,implementation_go: false)であり、このアンカーコメントには機械可読なANCHOR_SCOPE_REFRAME_V1payload が含まれていないため、Allowed Paths 拡張や AC 全面差し替えを自動反映する権限が preflight/planner レベルで fail-close されています。_VOLATILE_PEER_SESSION_ROOT_RELS全体除外 → 専用 subtree 方式への転換)と検証方式(sleep ベース → 同期 integration test)を変更する設計判断であり、review-issueの決定論的チェック(構造チェックのみ)がapproveを返したことは、この設計判断の妥当性を保証しません。codebase-investigator相当の調査で確認できたのは「障害の技術的原因診断は正確」という点のみで、OWNER が求める再設計(artifacts/session-manifest-runtime/の新設、.claude/hooks/session_manifest_debounce.mjs側の出力先変更是非を含む)を implementation contract として確定するには、人間の設計判断が必要と判断しました。次アクション(人間判断が必要)
issue-refinement-loop/review-issueを再実行し、構造チェックと意味論的内容の双方が揃った状態でissue-contract-reviewに進めてください。現時点で Issue 本文は変更していません。VERDICT(決定論的チェック)は
approveですが、OWNER アンカーコメントのREQUEST_CHANGESが実質的なブロッカーです。squne121 commentedon Jul 10, 2026
Issue 本文を OWNER レビュー(専用subtree方式)に沿って全面改訂
OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/1409#issuecomment-4935283248)の
REQUEST_CHANGESを反映し、本文を書き換えました(body_sha256:sha256:be201f55f376778f22b64cd7c950efd796fe441d7608a65965147fd1513f6b77)。採用した設計判断
artifacts/全体除外案を撤回し、hook 専用の新設 subtreeartifacts/session-manifest-runtime/(events//locks//tmp//manifests/)へ session-manifest hook の出力先を変更した上で、この subtree のみを race-tolerant 除外対象に加える「第一選択」方式を採用しました。次善策(root 直下の path matcher)は spoofability の懸念があり不採用としています。_VOLATILE_PEER_SESSION_ROOT_RELS/_is_volatile_peer_session_pathを_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS/_is_race_tolerant_unattributable_pathへ改名する方針を In Scope に追加しました(実際の保証内容が「他セッション由来」に限らないため)。Blocker / Major の解消状況
artifacts/全体ではなく専用 subtree のみを除外する設計に変更したため、artifacts/<issue>/issue-metadata/**等それ以外のartifacts/配下は引き続き監査対象として残ることを Outcome / In Scope / AC3 に明記しました。docs/dev/agent-skill-boundaries.md#Parallel Agent Runtime Safety、docs/dev/runtime-verification-policy.md#Runtime Verification Applicability、docs/dev/hook-boundaries.md、Issue 実装: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1343 / 調査: volatile peer-session root への child プロセス自己書き込みの strict attribution を検討する #1356 / 実装: 契約実行ラッパーに Linux-only optional strict trace attribution mode を追加する #1363 / worktree_scope_guard に local main scratch 出力先の安全な例外 (LOCAL_MAIN_SCRATCH_ALLOW_V1) を追加する #974、PR fix: 契約実行ラッパーの unauthorized_write_path 誤検知を修正する #1349 Safety Claim Matrix を Required Design References に追加し、Allowed Paths にもdocs/dev/agent-skill-boundaries.mdを追加しました。not_applicableからimmediateに修正し、AC1〜AC6 に<!-- runtime-verification: true -->タグを付与、原因記述も「当該コマンド自身の PostToolUse hook が割り込む」という誤った記述から「同一セッションの先行 PostToolUse event から非同期継続している debounce worker、または concurrent Stop/SubagentStop hook が重なる」という正確な記述に修正しました。.claude/hooks/session_manifest_debounce.mjs(または同等の generator process)を別プロセスで起動し ready-file/barrier で同期する integration test に置き換えました。lock 作成・metadata 更新・temporary file 作成・atomic rename・event file 削除・failed rename の実際の lifecycle を検証対象にしています。#1363の strict_strace mode では traced child による同 subtree への write は fail-close すべき、という mode 別契約の handoff を明記しました。review-issue 検証結果
.claude/skills/review-issue/scripts/check_issue_contract.py --issue 1409 --repo squne121/loop-protocol --jsonを実行し、verdict: approve(C1〜C11 全 pass、C12/C13 は n/a)を確認済みです。次のステップとして issue-contract-review(実装着手前 preflight)に進めます。
squne121 commentedon Jul 10, 2026
Contract Review Result
squne121 commentedon Jul 10, 2026
implement-issue: 実装完了 (2026-07-10T13:26:02Z)
.claude/worktrees/issue-1409-skill-runtime-exec-write-pathworktree-issue-1409-skill-runtime-exec-write-pathfix: ignored-ancestor folding cold-start blocker in race-tolerant sta…
fix: session-manifest hook 専用 subtree を race-tolerant 除外に追加する (#1426)