Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "independent peer pytest が生成する repo-root .pytest_cache/** の generated state を executor child の不正書込みへ誤帰属せず、.pytest_cache/** 以外の repository integrity boundary は従来どおり fail-close する"
change_kind: codeParent Issue
なし(単独改善。#1516 の anchor-bound preflight が runtime guard の誤検知で停止したための follow-up)
Parent Goal Ref
- Goal: 実装: overlap preflight classifier の package.json/broad-path/AC番号連番による false positive を抑制する #1516 の refinement preflight を正規 executor 経路で再開可能にする
- Desired Destination:
skill_runtime_exec.pyの race-tolerant attribution 判定と pytest cache regression test
Current Validated Scope
scripts/agent-guards/skill_runtime_exec.pyは_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSと_find_unauthorized_repo_changesで executor child 外の既知 peer write を snapshot / git status 差分から除外する directory-root exclusion class(.claude/worktrees、.claude/artifacts/issue-refinement-loop、artifacts/session-manifest-runtime)と、_LEDGER_*/_SHADOW_LOG_EXACT_RELの typed exact-file policy(実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502 / 実装: 契約実行ラッパーのunauthorized_write_path誤検知が.guard_shadow_log.jsonlでも発生する問題を修正する #1563 由来)の2種類の peer-write 免除機構を持つ- 実装: overlap preflight classifier の package.json/broad-path/AC番号連番による false positive を抑制する #1516 の
preflight.run.with_anchorは.pytest_cache/v/cache/nodeidsの更新をunauthorized_write_pathとして fail-close した - 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502(
artifacts/codex/subagent-launch-ledger.jsonの exact-path 例外)は PR 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1552 として 2026-07-17 に merge 済み。同一 executor file への directory-root exclusion 追加の precedent として確立している
Remaining Parent Gaps
- 実装: overlap preflight classifier の package.json/broad-path/AC番号連番による false positive を抑制する #1516 の Issue 本文改善と contract snapshot 再生成は本 Issue の対象外
Outcome
skill_runtime_exec.py と regression test が、独立した peer pytest process による repo-root .pytest_cache/**(cache/nodeids、cache/lastfailed、plugin 独自 config.cache key を含む)の作成・更新では guarded execution を誤停止させない一方、.pytest_cache/** 以外の repository 上の許可外書込みおよび tracked/source file への不正変更は引き続き unauthorized_write_path で fail-close する状態になる。
Background
root executor は実行前後の repository snapshot を比較し、active issue artifact root 外の差分を fail-close する。#1516 の正規 preflight は child / wrapper / hook に pytest 起動経路が見つからないにもかかわらず、peer test process が更新したとみられる .pytest_cache/v/cache/nodeids により停止した。
当初案は .pytest_cache/v/cache/nodeids 単体を exact-path 例外にし、cache/lastfailed は引き続き unauthorized 扱いとするものだったが、pytest 本体の _pytest/cacheprovider.py 実装(NFPlugin.pytest_sessionfinish / LFPlugin.pytest_sessionfinish、いずれも同じ pytest_configure hookimpl で登録され、同じ Config.cache.set() API を介して pytest_sessionfinish から無条件に書き込まれる)を確認した結果、nodeids のみを正当としその他を疑わしいとする技術的根拠は存在しないことが判明した。cache/lastfailed は成功のみの session でも空 dict {} として実際に書き込まれ、サードパーティ plugin も cache fixture 経由で .pytest_cache/v/cache/<custom-key> へ任意の key を書き込める。
このため、修正方針を「.pytest_cache/v/cache/nodeids の exact-path 例外」から「repo-root .pytest_cache/** 全体を、既存の _RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS directory-root exclusion class(.claude/worktrees 等と同種の disposable / generated / volatile state 分類)へ追加する」設計へ reframe する。.pytest_cache/ は repo-root .gitignore(.gitignore:69)で無視されており、pytest 自身が .pytest_cache/CACHEDIR.TAG と .pytest_cache/.gitignore(*)を自動生成して disposable/regenerable であることを自己宣言している。_LEDGER_* / _SHADOW_LOG_EXACT_REL のような typed exact-file policy は、canonical evidence・append-only log 等「特定の意味を持つ安定ファイル」の symlink/directory/FIFO/socket/device 置換を検出する目的のものであり、その保護対象は .pytest_cache/** のような純粋な disposable キャッシュツリーには当てはまらない。
preflight wrapper の直接実行、cache 削除、環境変数による argv 迂回、-p no:cacheprovider や repository 外 cache_dir を production fix として採用することは引き続き行わない(テストランナー自身の fixture 汚染回避に限定してテスト側だけで使うことは許容する)。
Bootstrap 経緯(本 Issue 固有)
本 Issue 自身の Verification Commands も pytest を使うため、通常の issue-refinement-loop / issue-contract-review の baseline VC preflight(--mode execute で実際に pytest を起動する経路)が、対象バグそのものにより .pytest_cache を unauthorized_write_path と誤判定し、本 Issue を通常経路で前進不能にする自己参照デッドロックが実測で確認された(preflight.run.with_human_context --issue-number 1526 が .pytest_cache/v/cache/nodeids で fail-close)。これを受け、人間オペレーターが本 Issue に限定した one-shot bootstrap authorization として、通常の実装前提ゲート(issue-refinement-loop / issue-contract-review / impl-review-loop の preflight gate)を経由しない直接実装・直接 PR 作成を承認した。本文の reframe 自体は --mode static(pytest 非実行)のみを使う edit_issue_txn.py controlled transaction 経由で行っており、broken gate をこの範囲では回避していない。
In Scope
- repo-root
.pytest_cache/**を_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSの volatile / generated-state exclusion として追加する .pytest_cache/v/cache/nodeidsの create/update を許可する.pytest_cache/v/cache/lastfailedの create/update を許可する- plugin/custom cache key を含む
.pytest_cache/**配下の generated state を許可する .pytest_cache/**以外の repo-root sibling write は引き続きunauthorized_write_pathとする negative control regression test- exemption の root-specificity(
.pytest_cacheそのものだけであり、nestedfoo/.pytest_cache/**や.pytest_cache2/**のような prefix 類似 path には適用されないこと)の検証 - 独立 OS process(実際の pytest サブプロセス)を使った behavior-level regression test
Out of Scope
- executor child 自身の Allowed Write Roots の拡張
- ledger(
_LEDGER_*)/shadow-log(_SHADOW_LOG_EXACT_REL)の typed exact-file policy の変更 - repository root 全体(
.pytest_cache以外を含む)の exemption - nested
foo/.pytest_cache等、任意ディレクトリ配下の.pytest_cacheへの exemption 拡張 .pytest_cacheの内容整合性・セキュリティハーネス(symlink/FIFO 置換の thorough detection 等)- writer の strict process attribution
- グローバルな pytest 設定変更(
cache_dirの repository 外移動、-p no:cacheproviderの production 適用等)
Acceptance Criteria
- AC1: peer pytest による
.pytest_cache/v/cache/nodeidsの create/update が guarded execution を停止させない - AC2: failing peer pytest による
.pytest_cache/v/cache/lastfailedの create/update も guarded execution を停止させない - AC3: plugin/custom cache key を含む
.pytest_cache/**内の generated state も guarded execution を停止させない - AC4:
.pytest_cache/**外の repo-root sibling write は引き続きunauthorized_write_pathで fail-close する - AC5: tracked/source file への unauthorized modification は引き続き fail-close する
- AC6: exemption は repo-root
.pytest_cacheのみに限定され、nestedfoo/.pytest_cacheや prefix 類似 path(.pytest_cache2等)には適用されない - AC7: 独立 OS process(実 pytest subprocess)を使った behavior-level regression test が存在し PASS する
Runtime Verification Applicability
- decision: not_applicable
- reason: ローカル fixture の executor snapshot / attribution 判定を対象とし、外部サービスや runtime smoke を必要としない
Verification Commands
# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -k test_peer_pytest_nodeids_write_is_permitted -q
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -k test_peer_pytest_lastfailed_write_is_permitted -q
# AC3
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -k test_peer_pytest_custom_cache_key_write_is_permitted -q
# AC4
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -k test_repo_root_sibling_write_outside_pytest_cache_is_rejected -q
# AC5
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -k test_tracked_source_file_unauthorized_write_is_rejected -q
# AC6
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -k test_exemption_is_repo_root_specific_not_nested_or_prefix_lookalike -q
# AC7
$ uv run --locked pytest scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py -qAllowed Paths
- scripts/agent-guards/skill_runtime_exec.py
- scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.py
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
.pytest_cacheより広い repository root exemption が必要と判明した場合- SubAgent 調査で
.pytest_cacheroot exemption に重大な current-main-specific contradiction が見つかった場合
Required Skills
- Python 3
- pytest
Required Design References
- docs/dev/agent-skill-boundaries.md#Parallel Agent Runtime Safety
- docs/dev/workflow.md#Scope Collision Preflight
- scripts/agent-guards/skill_runtime_exec.py
Scope Delta(任意)
N/A
Delivery Rule
- 1 Issue = 1 PR で完結する
- worktree:
.claude/worktrees/issue-1526-runtime-guard-pytest-cache - Draft PR を既定とする
- 本 Issue は 実装: overlap preflight classifier の package.json/broad-path/AC番号連番による false positive を抑制する #1516 の自己参照デッドロックを解消する bootstrap recovery として、通常の実装前提ゲート(issue-refinement-loop / issue-contract-review / impl-review-loop の preflight gate)を経由せず、専用 worktree での直接実装 → focused validation → 独立 SubAgent review → direct PR 作成という one-shot 経路で進める(人間オペレーター明示 authorization、2026-08-27)
- 実装: overlap preflight classifier の package.json/broad-path/AC番号連番による false positive を抑制する #1516 の refinement loop は本 Issue がマージされ、正常 preflight が確認できるまで fail-closed を維持する
Notes for Reviewer
nodeids単体の exact-path allowlist は不採用(pytest 実装上nodeids/lastfailed/custom key を区別する技術的根拠がないため)。repo-root.pytest_cache/**全体を directory-root exclusion class に加える設計に変更した- exemption は repo-root
.pytest_cacheのみに厳密に限定し、nestedfoo/.pytest_cacheや.pytest_cache2等の prefix 類似 path には一切波及させない - ledger(実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502/PR 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1552)・shadow-log(実装: 契約実行ラッパーのunauthorized_write_path誤検知が.guard_shadow_log.jsonlでも発生する問題を修正する #1563)の typed exact-file policy とは責務が異なり、変更しない
- 本 Issue は bootstrap 例外として通常 preflight gate を bypass しているが、bypass は本 Issue に限定し、他 Issue・他用途へ横展開しない
Activity
squne121 commentedon Aug 27, 2026
判定
REQUEST_CHANGES — #1526 は問題自体は実在しますが、現在の Issue contract のまま実装するのは非推奨です。
特に「
.pytest_cache/v/cache/nodeidsだけを exact-path 例外にする」という設計は、観測された1ケースに過適合しています。個人趣味開発でワークフロー継続性を優先するなら、Issue を reframe してから実装するのが妥当です。#1526 の発端となった障害には実証があります。#1516 の refinement 再開時に
preflight.run.with_anchorがunauthorized_write_pathで停止し、問題のパスが.pytest_cache/v/cache/nodeidsだったこと、正規 child/wrapper/hook から pytest 起動経路を特定できなかったことまで記録されています。したがって「false positive が存在しない」というレビューではありません。敵対的レビュー結果
Severity | 指摘 | 評価 -- | -- | -- P0 | Issue の前提が stale | 本文は「#1502 は OPEN、未マージなので待つ」「既存 _RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS に exact nodeids を追加する」という前提です。 しかし #1502 は 7月17日に closed 済みで、PR #1552 も merged。 P0 | nodeids 限定は pytest の実際の write model と矛盾 | pytest の cache provider は nodeids だけを書くものではありません。lastfailed、任意の config.cache key、stepwise 等も同じ cache namespace を使います。 P0 | AC2 が legitimate peer pytest を意図的に false-positive にする | #1526 は lastfailed の変更を明示的に fail-close させます。ところが通常の「失敗する pytest」がまさに lastfailed を更新します。つまり peer pytest が成功すると許容、失敗すると runtime guard が unrelated write として停止する設計になります。 P1 | 非正規生成物を security/integrity boundary として扱いすぎ | このリポジトリ自身が .pytest_cache/ を .gitignore しています。 pytest 自身も .pytest_cache 内に「version control に commit しない」ための .gitignore を生成します。(pytestドキュメンテーション) P1 | typed exact-file policy の横展開が不適切 | ledger や shadow log は canonical evidence / append-only log なので、型・inode・内容遷移を検証する価値があります。一方 pytest cache は disposable cache です。同じハードニングを適用する合理性がありません。 P1 | Out of Scope が解法を先に縛っている | 「directory-wide exclusion 不可」「cache redirect/argv 回避不可」を先に固定しており、障害の性質より過去のガード設計を優先しています。個人開発の目的とは逆です。 P2 | regression test が observed case の再現に寄りすぎ | nodeids positive / lastfailed negative の2点だけでは、pytest plugin が新しい cache key を使った瞬間に同じ Issue が再発します。これなら「false positive は消えるが、実際に保護したい repository state は引き続き止める」という契約になります。
#1526 の具体的な disposition
そのまま implementation に流すべきではありません。
reframe_in_placeが適切です。タイトルも現在の
より、
程度まで抽象度を上げた方がよいです。
Issue 本文の
#1502 が未マージという dependency は削除。#1502 / PR #1552 を 既に成立した設計背景として書き直すべきです。#1526 自身にはコメントがなく、2026年7月14日の作成以来本文も実質更新されていないため、新しい判断で契約を更新して問題ありません。また、PR #1552 自身でも overlap preflight の unrelated false-positive が原因で正規 wrapper を bypass して PR を作成した経緯があります。 この repository はすでに 「安全用ハーネスの false positive が実作業を阻害する」コストを現実に何度も払っています。#1526 でさらに cache key 単位の policy を増やすのは、その問題をもう一段増幅します。
最終評価
問題の重要度: Medium
実害はあるものの repository correctness を壊すバグではなく、guard の usability defect です。
現 Issue contract の品質: Low / stale
観測事象は正しいものの、解法が path-specific すぎ、現在の main と pytest の write semantics の双方に合っていません。
推奨: REQUEST_CHANGES → reframe_in_place →
.pytest_cache/**volatile-root exemption を最小実装。
## 判定nodeids専用 typed exception、lastfailednegative control、pytest cache の symlink/FIFO/content integrity harness は、今回の用途では削った方が品質が上がります。守る価値のある canonical state に厳しい guard を集中させ、捨てられる cache は作業を止めない、という境界がこのリポジトリには合っています。REQUEST_CHANGES — #1526 は問題自体は実在しますが、現在の Issue contract のまま実装するのは非推奨です。
特に「
.pytest_cache/v/cache/nodeidsだけを exact-path 例外にする」という設計は、観測された1ケースに過適合しています。個人趣味開発でワークフロー継続性を優先するなら、Issue を reframe してから実装するのが妥当です。#1526 の発端となった障害には実証があります。#1516 の refinement 再開時に
preflight.run.with_anchorがunauthorized_write_pathで停止し、問題のパスが.pytest_cache/v/cache/nodeidsだったこと、正規 child/wrapper/hook から pytest 起動経路を特定できなかったことまで記録されています。したがって「false positive が存在しない」というレビューではありません。敵対的レビュー結果
_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSに exact nodeids を追加する」という前提です。 しかし #1502 は 7月17日に closed 済みで、PR #1552 も merged。nodeids限定は pytest の実際の write model と矛盾nodeidsだけを書くものではありません。lastfailed、任意のconfig.cachekey、stepwise 等も同じ cache namespace を使います。lastfailedの変更を明示的に fail-close させます。ところが通常の「失敗する pytest」がまさにlastfailedを更新します。つまり peer pytest が成功すると許容、失敗すると runtime guard が unrelated write として停止する設計になります。.pytest_cache/を.gitignoreしています。 pytest 自身も.pytest_cache内に「version control に commit しない」ための.gitignoreを生成します。([pytestドキュメンテーション]1)nodeidspositive /lastfailednegative の2点だけでは、pytest plugin が新しい cache key を使った瞬間に同じ Issue が再発します。一番大きい問題:
lastfailedは「不正な近似パス」ではないpytest 公式ドキュメントでは cache provider はデフォルト有効で、
config.cacheを他 plugin も自由に利用できます。公式の--cache-showの例ですらcache/lastfailedとcache/nodeidsの双方が表示されています。([pytestドキュメンテーション]2)さらに現在の pytest 実装を見ると、
NFPlugin.pytest_sessionfinish()は通常の test session 終了時にcache/nodeidsを保存します。一方LFPluginは test failure をlastfailedに記録し、状態が変われば session finish でcache/lastfailedを保存します。つまり、nodeids = 正常な peer writelastfailed = suspicious writeという #1526 の分類には pytest 側の意味論的根拠がありません。どちらも cacheprovider の正常動作です。 ([GitHub]3)
さらに pytest plugin は
config.cache.set("plugin-name/key", ...)のような独自値を保存できます。公式にもその用途が明記されています。([pytestドキュメンテーション]2)したがって exact-path 方式を続けると、
nodeids→ 例外追加lastfailed→ 次の false positivestepwise→ 次の false positiveplugin 固有 cache → 次の false positive
という whack-a-mole になります。
現在の repository architecture ともズレている
#1502 / PR #1552 後の
skill_runtime_exec.pyは、単純な path allowlist ではありません。_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSは明確に directory-root exclusion class として残し、canonical ledger については_LEDGER_STABLE_EXACT_RELと transient protocol entries を別の typed transition policy で処理しています。その後の #1563 / PR #1572 でも、canonical な
.guard_shadow_log.jsonlは ledger と同様に typed exact-file policy を採用し、append-only、non-regular substitution、truncate 等まで検証しています。PR #1572 は merged 済みです。これは設計としては一貫しています。ただし、ここで重要なのは canonical ledger / audit log と disposable pytest cache を同格に扱わないこと です。
ledger は後続 consumer が読む正本です。shadow log は監査証跡です。
.pytest_cacheはそのどちらでもありません。推奨する reframe
個人趣味開発という前提なら、私は repo-root の
.pytest_cache/**全体を volatile/generated state として runtime guard の repo-integrity 判定から外す 方針を推します。つまり
_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSに、".pytest_cache",を追加する方向です。
#1526 は「directory-wide exclusion は不可」と断言していますが、ここは撤回した方がよいです。現在の tuple はもともと「writer provenance を stdlib snapshot では判別できず、並行 process が正当に変更する directory」を対象にしています。
.pytest_cacheはその分類にかなり素直に当てはまります。これによって
.pytest_cache自体が symlink/FIFO に置換されたケース等を runtime guard が検出しなくなる点はあります。しかし、そこを守ることで得られる実用価値がほぼありません。同一ユーザー権限のローカル process が pytest cache を悪意を持って細工できる状況を threat model に入れるなら、repo snapshot guard ではなく別の isolation が必要です。特にこのリポジトリでは
.pytest_cache/自体を既に gitignore しています。 ソース、contract、artifact、credential、実行バイナリなどを守るのと、pytest の disposable cache を守るのは分けるべきです。pytest 側での isolation は第二候補
よりクリーンな方法は pytest cache を repository 外へ移すことです。pytest は
cache_dirを公式設定として提供しており、絶対パスを指定でき、CLI からもたとえば-o cache_dir=/tmp/mycacheのように上書きできます。([pytestドキュメンテーション]4)cache 自体が不要な自動テストなら
cacheproviderを無効にする方法もあります。pytest 公式はpytest -p no:NAMEをサポートしており、cache plugin の内部名はcacheproviderです。したがって-p no:cacheproviderが正規の無効化方法です。([pytestドキュメンテーション]2) ([pytestドキュメンテーション]5)ただし #1516 で問題になったのは executor が所有していない peer pytest です。executor 自身の argv だけを変更しても、別 terminal / 別 agent が普通に
pytestを走らせれば.pytest_cacheは更新されます。このため根本的な guard false-positive 対策としては、cache redirect より runtime guard 側で.pytest_cache/**を無関係な generated state と認識する方が堅いです。executor が自分で起動する pytest についてだけ、追加で cache を repo 外へ隔離するのは有効です。
改訂するなら Acceptance Criteria はこうする
現状の AC1〜AC4 は捨ててよいです。特に AC2 の「
lastfailedは fail-close」は逆方向です。.pytest_cache/v/cache/nodeidsを create/update しても guarded command は停止しない.pytest_cache/v/cache/lastfailedを create/update しても停止しない.pytest_cache/**内に別 cache key を生成しても停止しない.pytest_cache/**以外の repo-root sibling file を peer process が変更すれば従来どおりunauthorized_write_path.pytest_cacheの exemption は repo-root のその directory に限定し、foo/.pytest_cacheや類似文字列には波及しないこれなら「false positive は消えるが、実際に保護したい repository state は引き続き止める」という契約になります。
#1526 の具体的な disposition
そのまま implementation に流すべきではありません。
reframe_in_placeが適切です。タイトルも現在の
より、
程度まで抽象度を上げた方がよいです。
Issue 本文の
#1502 が未マージという dependency は削除。#1502 / PR #1552 を 既に成立した設計背景として書き直すべきです。#1526 自身にはコメントがなく、2026年7月14日の作成以来本文も実質更新されていないため、新しい判断で契約を更新して問題ありません。また、PR #1552 自身でも overlap preflight の unrelated false-positive が原因で正規 wrapper を bypass して PR を作成した経緯があります。 この repository はすでに 「安全用ハーネスの false positive が実作業を阻害する」コストを現実に何度も払っています。#1526 でさらに cache key 単位の policy を増やすのは、その問題をもう一段増幅します。
最終評価
問題の重要度: Medium
実害はあるものの repository correctness を壊すバグではなく、guard の usability defect です。
現 Issue contract の品質: Low / stale
観測事象は正しいものの、解法が path-specific すぎ、現在の main と pytest の write semantics の双方に合っていません。
推奨: REQUEST_CHANGES → reframe_in_place →
.pytest_cache/**volatile-root exemption を最小実装。nodeids専用 typed exception、lastfailednegative control、pytest cache の symlink/FIFO/content integrity harness は、今回の用途では削った方が品質が上がります。守る価値のある canonical state に厳しい guard を集中させ、捨てられる cache は作業を止めない、という境界がこのリポジトリには合っています。squne121 commentedon Aug 27, 2026
推奨は 選択肢2の修正版「2′」 です。つまり、#1526 だけを one-shot の bootstrap recovery として preflight 依存から外し、先に制御面を復旧する方針です。ただし、現在の #1526 に書かれている「
nodeidsexact path だけ例外化」はそのまま実装しない方がよいです。理由は明確です。#1526 の本文はいまだに「#1502 が未マージなので待つ」としていますが、#1502 は 2026年7月17日に完了済みです。さらに最新レビューは、
nodeids限定設計をREQUEST_CHANGESとし、.pytest_cache/**を generated/volatile state として扱うようreframe_in_placeを推奨しています。この reframe は pytest の実装とも整合します。現在の pytest は正常終了時に
cache/nodeidsを書くだけでなく、失敗状態に応じてcache/lastfailedも書きます。またconfig.cacheは plugin が独自 key を永続化するための公開 API です。したがってnodeids=許可 / lastfailed=拒否は、成功した peer pytest は通るのに失敗した peer pytest は guard に止められる、という不自然な境界になります。 ([GitHub]1)リポジトリ側でも
.pytest_cache/は既に Git 管理対象外です。現在の_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS自体が「並行 writer を stdlib snapshot では帰属できない directory root」のためのクラスなので、canonical ledger や audit log と違って disposable な pytest cache をここへ分類する方が設計として自然です。選択肢1は推奨しません。 entrypoint を
implement-issueに替えても同じskill_runtime_exec.pyを通れば循環を切れないからです。また、この種の control-plane false positive については PR #1552 でも、正規 wrapper が無関係な blocker で停止した際に、理由と検証証跡を残して直接 PR を作成した前例があります。したがって「guard を恒久的に無効化」するのではなく、#1526 の復旧作業だけ procedural gate を限定 bypass するのが妥当です。Claude Code には以下を渡すのがよいです。
Issue #1526 を、壊れている control-plane 自身を復旧する bootstrap recovery として処理してください。
今回の作業では、通常の
issue-refinement-loop/issue-contract-review/impl-review-loopを実装前提ゲートとして使用しないでください。現在それらの Step 0f / baseline VC preflight 自体が Issue #1526 の対象バグにより.pytest_cacheをunauthorized_write_pathと誤判定し、#1526 自身を前進不能にする自己参照デッドロックが確認されています。この人間指示を、Issue #1526 に限定した one-shot bootstrap authorization として扱ってください。
最終目的
reframe_in_placeする。重要な設計方針
現在の #1526 本文にある、
.pytest_cache/v/cache/nodeidsだけを race-tolerant exception にする.pytest_cache/v/cache/lastfailedは引き続き unauthorized とする.pytest_cachedirectory-wide exclusion は禁止するという契約をそのまま実装してはいけません。
最新の #1526 コメント、現在の pytest cacheprovider 実装、current main の
skill_runtime_exec.pyを再確認してください。現時点の第一候補は、
という設計です。
pytest は正常な session でも
cache/nodeidsを更新し、失敗時にはcache/lastfailedを更新します。また plugin はconfig.cacheで独自 key を生成できます。したがってnodeids単体の allowlist は採用しないでください。一方で、以下は維持してください。
.pytest_cache/**以外の unauthorized repository write は fail-close。-p no:cacheproviderや externalcache_dirは今回の production fix にしない。.pytest_cacheだけとし、foo/.pytest_cache/**、.pytest_cache2/**等へ波及させない。ただし SubAgent の調査で、この設計が current main の実装上明確に不適切である証拠が出た場合は、勝手に別設計を実装せず、証拠と代案をまとめて停止してください。
Phase 1: 現状確認
最初に mutation を行わず、以下を確認してください。
current repository root / branch / HEAD
git status --shortrepository の
CLAUDE.md、project constitution、workflow / agent boundary 関連文書Issue 実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526 の現在の本文と全コメント
Issue 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1502 と PR 実装: SubAgent 起動 ledger の更新を runtime guard の誤検知から除外する #1552 の最終状態
Issue 実装: 契約実行ラッパーのunauthorized_write_path誤検知が.guard_shadow_log.jsonlでも発生する問題を修正する #1563 等、
skill_runtime_exec.pyの peer-write policy に関する precedentcurrent main の:
scripts/agent-guards/skill_runtime_exec.py_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELS_is_race_tolerant_unattributable_path_snapshot_repo_paths_find_unauthorized_repo_changes関連既存テスト:
skill_runtime_exec.pyを現在変更中の OPEN PR がないか、および実際の edit region が衝突しないか既存 user change、untracked file、他 worktree を削除・reset・stash しないでください。
Phase 2: 第一波 SubAgent 調査
必ず SubAgent を使ってください。
main thread は、編集を開始する前に少なくとも次の3つの read-only SubAgent を並列起動してください。
SubAgent A: runtime-policy-investigator
調査対象:
skill_runtime_exec.pyの snapshot / race-tolerant policy.pytest_cacheroot exemption の blast radiusmutation 禁止。
SubAgent B: pytest-semantics-investigator
調査対象:
cache/nodeidscache/lastfailedconfig.cachecache_dir-p no:cacheprovider公式 pytest documentation / source を優先してください。
「nodeids だけ正当で lastfailed は suspicious」という分類に技術的根拠があるかを敵対的に検証してください。
mutation 禁止。
SubAgent C: contract-bootstrap-reviewer
調査対象:
mutation 禁止。
SubAgent 共通制約
3 SubAgent 全員の作業完了を待ってください。
全員が完了する前に Issue 編集・コード編集・worktree implementation を開始してはいけません。
main thread で3結果を突き合わせ、矛盾を解消してから方針を確定してください。
Phase 3: #1526 を reframe_in_place
調査結果が上記第一候補を支持する場合、Issue #1526 の契約を実装前に更新してください。
通常の refinement preflight は今回の defect そのものにより使用不能なので、その gate の成功を reframe の前提にしないでください。
GitHub mutation は以下の順で選んでください。
skill_runtime_exec.pyの broken preflight を通らずに利用できる既存 controlled Issue transaction helper があるならそれを使う。raw/direct mutation を他 Issue や他用途へ横展開してはいけません。
Issue body の reframe は最低限次を反映してください。
Goal / Outcome
nodeids単体ではなく、という目的へ変更する。
dependency
In Scope
.pytest_cache/**の volatile generated-state exemptionnodeidslastfailedOut of Scope
.pytest_cacheAcceptance Criteria
少なくとも次へ置き換えてください。
.pytest_cache/v/cache/nodeidscreate/update が guarded execution を停止させない。.pytest_cache/v/cache/lastfailedcreate/update も停止させない。.pytest_cache/**内の generated state も停止させない。.pytest_cache/**外の repo-root sibling write は引き続きunauthorized_write_path。.pytest_cacheのみに限定され、nestedfoo/.pytest_cacheや prefix 類似 path には適用されない。Allowed Paths は原則として現在の2ファイルを維持してください。
scripts/agent-guards/skill_runtime_exec.pyscripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.pyこの2ファイル外の tracked code change が必要なら実装せず停止してください。
Phase 4: 専用 worktree で直接実装
最新
origin/mainを基点に #1526 専用 worktree / branch を作成してください。既存 worktree を破壊・再利用しないでください。
main thread が実装を所有し、調査 SubAgent に mutation をさせないでください。
第一候補の実装では、
_RACE_TOLERANT_UNATTRIBUTABLE_ROOT_RELSに repo-root.pytest_cacheを追加します。コメントには、
ことを簡潔に記載してください。
不必要な abstraction / policy registry / schema / security harness は追加しないでください。
個人趣味開発の repository なので、今回の優先順位は:
です。
Phase 5: Regression test
新規:
scripts/agent-guards/tests/test_skill_runtime_exec_pytest_cache.pyを使用してください。
既存 guard tests の fixture / subprocess pattern を再利用し、sleep 頼みの race test は避けてください。必要なら pipe/event/barrier で同期してください。
少なくとも behavior-level で以下を固定してください。
nodeidswrite → 許可lastfailedwrite → 許可.pytest_cache内の別/custom key → 許可.pytest_cache外 sibling write → 拒否foo/.pytest_cache/...→ 拒否.pytest_cache2/...→ 拒否可能なら大量の path-predicate unit test より、1〜2本の現実的な independent-process behavioral test と、小さな specificity test を優先してください。
テストランナー自身の pytest cache が fixture を汚染する場合に限り、テストランナー側だけ
-p no:cacheproviderや repository 外cache_dirを使って isolation して構いません。ただし、それを production fix や Issue の解決策にしてはいけません。Phase 6: focused validation
最低限、以下の relevant suites を current repository の実名に合わせて実行してください。
test_skill_runtime_exec_pytest_cache.pyテストファイル名が current main で異なる場合は、実在する対応 suite を選んでください。
無関係な既知 flake を修正するために Allowed Paths を拡大しないでください。
失敗した場合:
Phase 7: 第二波 SubAgent adversarial review
実装とテストが完了したら、main thread は再度 read-only SubAgent を最低2つ起動してください。
Reviewer 1: guard-boundary-reviewer
確認:
.pytest_cache以外の fail-close を広げていないかReviewer 2: pytest-regression-reviewer
確認:
mutation 禁止、nested delegation 禁止。
両 Reviewer の完了を待ってください。
P0/P1 相当の指摘があれば main thread で修正し、focused validation を再実行してください。
解消不能なら PR を「成功」として作らず停止してください。
Phase 8: commit / Draft PR
最終 diff を確認し、tracked change が #1526 の reframe 後 Allowed Paths に収まっていることを確認してください。
commit → push してください。
PR 作成については、この bootstrap defect が open-pr wrapper の preflight にも波及する可能性があります。
.pytest_cacheunauthorized_write_pathで停止することが確認された場合、同じ command を繰り返さない。gh pr create --draft相当を bootstrap exception として使用してよい。PR は Draft。
PR body には最低限以下を明示してください。
Closes #1526.pytest_cache/**generated-state policy に reframe した理由.pytest_cache/**外の fail-close が維持されることmerge しないでください。
Phase 9: 完了報告
次をまとめて報告してください。
post-merge canary としては、#1526 が main に入った後に初めて、通常の
issue-refinement-loop/issue-contract-reviewを canonical main から再実行してください。その後、pytest VC を持ち今回実際にブロックされていた Issue(#2339 等)を1件 canary として通常ループで通し、control-plane recovery を確認するのが望ましいです。
PR 作成時点ではまだ main に修正が入っていないので、#2339 を無理に通常ループへ流して「復旧済み」と判定してはいけません。
絶対停止条件
以下だけは自律継続せず停止してください。
.pytest_cacheより広い repository root exemption が必要.pytest_cacheroot exemption に重大な current-main-specific contradiction が見つかったそれ以外の通常の実装判断、テスト修正、rebase、commit、push、Draft PR 作成については人間承認を待たず進めてください。
この形なら、「壊れている安全ハーネスを通過するために安全ハーネスを直せない」状態だけを例外扱いし、通常運用へ戻る地点も明確です。特に重要なのは、PR 作成を完了条件にせず「merge 後に #1526 → #2339 の順で canonical preflight canary を通す」ことを recovery closure として残しておく点です。
squne121 commentedon Aug 28, 2026
post-merge-cleanup: 完了 (2026-08-28)
worktree/branch cleanup:
issue-1526-runtime-guard-pytest-cache削除済み(PR #2364, merge commitcc5e3633)。superseded PR なし。parent issue なし。stash 復元済み。human_review_required: false。