Skip to content

実装: pnpm test から .claude/tmp の一時 worktree を除外する #1545

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: none
goal_ref: "repo-approved temporary workspace(.claude/tmp/ と tmp/ の両方)を Vitest の test discovery から除外し、pnpm test をこれらの working tree に依存させない"
change_kind: workflow

Runtime Verification Applicability

decision: immediate
applicable_acs:
  - AC3
execution_environment:
  cli_tools:
    - node
    - pnpm
  auth_required: false
  network_required: false
skip_conditions:
  - "local repository checkout に node_modules が存在せず pnpm exec / node が利用できない場合は SKIP ではなく environment blocked として扱う"
fallback_policy:
  fallback_success_is_pass: false
  notes: "fallback 経由の成功を PASS に変換しない"
artifact_requirements:
  - "scripts/verify-vitest-discovery-policy.mjs の probe 実行 stdout/stderr"
  - "pnpm test の実行結果"

reason: AC3 相当が .claude/tmp/ と tmp/ の双方に sentinel test file を実配置し、Vitest discovery / pnpm test プロセスの実挙動を確認することを要求するため。

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: repo-approved temporary workspace(.claude/tmp/ と tmp/ の class 単位)が unit-test discovery を汚染しないようにする。
  • Desired Destination: N/A(単独改善 Issue のため)

Current Validated Scope

  • package.json の test script と .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py の test gate 定義の両方に .claude/tmp/** と tmp/** の Vitest exclude を同期して追加する。
  • tests/vitest-test-discovery-policy.test.ts を新設し、test script が .claude/tmp/** / tmp/** と既存の .claude/worktrees/** / tests/e2e/** exclusion を保持することを検証する。
  • scripts/verify-vitest-discovery-policy.mjs を新設し、.claude/tmp/ と tmp/ 双方に sentinel test file を実配置する probe で discovery 除外を実行時検証する。

Remaining Parent Gaps

なし(単独改善 Issue のため)

Outcome

package.json の unit-test script、およびそれを fail-closed で検証する pnpm_gate_registry.py の test gate 定義が、.claude/tmp/** と tmp/** の双方を Vitest discovery から class 単位で除外し、その契約テストと sentinel probe が repo-approved temporary workspace 内の test file を収集せずに PASS する状態。

In Scope

  • package.json の test script へ .claude/tmp/** と tmp/** の exclude を追加する。
  • .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py の _SCRIPTS["test"] を package.json の test script と同一の canonical 文字列へ同期する(pnpm_gate_registry.py は package.json の test script と完全一致比較で fail-closed 検証するため)。
  • test discovery exclusion の static contract test(tests/vitest-test-discovery-policy.test.ts)を新設する。
  • .claude/tmp/ と tmp/ 双方に一意な sentinel test file を実配置し、discovery 除外の有無で収集結果が変わることを検証する probe script(scripts/verify-vitest-discovery-policy.mjs)を新設する。probe は成功・失敗いずれの場合も配置した sentinel を cleanup する。
  • 既存の tests/e2e/** と .claude/worktrees/** exclusion が維持されることを test で固定する。
  • .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py の既存 regression が壊れないことを維持する。

Out of Scope

  • tmp/ / .claude/tmp/ / .claude/worktrees/ の削除、cleanup authority、ownership marker の変更。
  • Vitest の dependency 追加・更新、test / pnpm_gate_registry.py の test gate 以外の package script・gate 定義の変更。
  • E2E / Playwright の test discovery 変更。

Acceptance Criteria

  • AC1: package.json の test script と .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py の _SCRIPTS["test"] が、tests/e2e/**、.claude/worktrees/**、.claude/tmp/**、tmp/** の 4 exclude を同一の canonical 文字列として保持する(両ファイルの同期)。
  • AC2: tests/vitest-test-discovery-policy.test.ts が test script の上記 4 exclusion 文字列(tests/e2e/**、.claude/worktrees/**、.claude/tmp/**、tmp/**)すべてをソース内で参照する静的契約テストとして新設される(実行時の discovery 除外確認は AC3 の sentinel probe に一本化する)。
  • AC3: scripts/verify-vitest-discovery-policy.mjs が .claude/tmp/ と tmp/ 双方に一意な sentinel test file を作成する probe を実行し、(a) 除外を外した discovery では sentinel が発見されること、(b) canonical exclude 設定では発見されないこと、(c) sentinel が存在する状態で pnpm test が成功すること、(d) probe directory が成功・失敗いずれの場合も cleanup されること、を検証する。
  • AC4: .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py の既存 regression test が引き続き PASS する(registry と package.json の同期が壊れていないことの確認)。

Verification Commands

# AC1
$ rg -n -F -- "--exclude '.claude/tmp/**'" package.json
$ rg -n -F -- "--exclude 'tmp/**'" package.json
$ rg -n -F -- "--exclude '.claude/tmp/**'" .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py
$ rg -n -F -- "--exclude 'tmp/**'" .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py

# AC2
# baseline-expect: fail
$ rg -n -F -- "'.claude/tmp/**'" tests/vitest-test-discovery-policy.test.ts
# baseline-expect: fail
$ rg -n -F -- "'tmp/**'" tests/vitest-test-discovery-policy.test.ts
# baseline-expect: fail
$ rg -n -F -- "'.claude/worktrees/**'" tests/vitest-test-discovery-policy.test.ts
# baseline-expect: fail
$ rg -n -F -- "'tests/e2e/**'" tests/vitest-test-discovery-policy.test.ts

# AC3
# baseline-expect: fail
$ test -f scripts/verify-vitest-discovery-policy.mjs

# AC4
$ uv run --locked pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py

Allowed Paths

  • package.json
  • .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py
  • .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py
  • tests/vitest-test-discovery-policy.test.ts
  • scripts/verify-vitest-discovery-policy.mjs

Stop Conditions

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

Required Skills

  • なし

Required Design References

  • docs/dev/workflow.md
  • docs/dev/repository-folder-policy.md

Scope Delta(該当時のみ記載)

  • 追加: .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py(_SCRIPTS["test"] の同期)、.claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py(既存 regression 維持確認)、scripts/verify-vitest-discovery-policy.mjs(sentinel probe 新設)を Allowed Paths に追加。
  • 追加: tmp/** を discovery exclusion の scope に追加し、.claude/tmp/** のみだった元の class-instance 単位の記述を、temporary workspace class 単位(.claude/tmp/ と tmp/ 双方)へ拡張。
  • 変更: 既存の .claude/worktrees/** / tests/e2e/** exclusion を維持したまま、.claude/tmp/** と tmp/** を同じ test discovery boundary に追加。AC2 の検証手段をファイル存在チェックから pnpm test の focused 実行に変更(pnpm exec vitest run は pnpm gate allowlist 違反のため)。AC3 相当を静的チェックから sentinel probe による実行時検証(runtime-verification: true)に変更。
  • 変更理由: OWNER の敵対的レビュー(issuecomment-5001909838)で以下が fact-check 済み(confirmed)として指摘され、続く issuecomment-5002227104 の ANCHOR_SCOPE_REFRAME_V1 で scope 拡張と Allowed Paths delta が承認された。
    • Blocker 1: pnpm_gate_registry.py の _SCRIPTS["test"] が package.json の test script と完全一致比較され、不一致だと manifest_integrity:closure_drift:test で fail-closed 拒否するため、pnpm_gate_registry.py を Allowed Paths と AC に含める必要がある。
    • Blocker 2: 単なる pnpm test の実行だけでは除外漏れでも意図せず PASS しうるため、sentinel を用いた再現性のある probe が必要。
    • Blocker 3: rg -n -- "--exclude '.claude/tmp/**'" package.json は ripgrep のデフォルト正規表現モードで ** がリテラルマッチせず no-match(exit 1)になるため、-F(fixed-strings)が必須。
    • Major 1: test -f tests/vitest-test-discovery-policy.test.ts はファイル存在しか検証しないため、pnpm exec vitest run の focused 実行に変更する。
    • Major 2(ユーザー選択): scope を .claude/tmp/ のみでなく tmp/** も含む class 単位に拡張する。
    • AC2 VC 再設計(impl-review-loop preparation preflight で確認): pnpm_gate_registry.py の gate_for_request は ("pnpm", "test") の厳密 2-token 一致のみを受理し、追加引数を渡す focused 実行(pnpm test <file> や pnpm exec vitest run <file>)はいずれも pnpm_gate:noncanonical_request_argv / command_not_allowed で fail-closed に拒否される。この VC 実行環境では CLI 経由の focused vitest 実行が構造的に不可能なため、AC2 を「focused 実行で欠落時に fail する」設計から「tests/vitest-test-discovery-policy.test.ts が 4 exclusion 文字列を静的に参照することを rg -n -F で確認する」設計へ変更した。新設ファイルに対する rg の baseline 実行(ファイル未作成)は baseline_vc_preflight.py の new_file_missing_expected 分類(exit_code 2、stdout 空、stderr が missing-path pattern、path operand が Allowed Paths 内)で expected_fail/go に決定論的に分類される。実行時の discovery 除外確認は AC3 の sentinel probe(test-runner が直接実行する runtime-verification: true 経路)に一本化し、AC2 は静的整合性確認に専念させる。
  • 削除: なし。

Delivery Rule

  • 1 Issue = 1 PR
  • isolation worktree で実装する。
  • Draft PR を既定とする。

Notes for Reviewer

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 16, 2026
  2. squne121 commented on Jul 17, 2026

    @squne121
    OwnerAuthor

    From: https://chatgpt.com/c/6a595424-c3d8-83e8-83cb-cf0c7e9b1c0c?add_source=github_connector

    you asked

    message time: 2026-07-17 06:58:59

    #1545
    内容について関連Issue、PR、リポジトリ資産、コメントを参照した上で敵対的レビューして。
    取り扱う技術や配布物の実装をWEB検索し高品質化してほしい。


    chatgpt response

    Issue本文・コメント・関連PR/Issue・実装を照合し、主張の弱点、破壊条件、未検証前提、代替案を敵対的に検証します。外部仕様は一次資料と実装を優先します。


    chatgpt response

    Issue #1545 はコメントがなく、静的検査では実行時の収集境界を証明できません。Vitest の list --filesOnly --static-parse と汚れたローカル環境での再現試験が必要です。


    chatgpt response

    さらに、.claude/tmp/ は正規worktree配置規約に反し、除外追加は逸脱を隠蔽します。加えて test script の重複固定により、Allowed Paths内の変更だけでは closure_drift:test に拒否されます。


    chatgpt response

    判定

    REQUEST_CHANGES — 現状の Issue 契約では実装着手不可です。

    .claude/tmp/** を Vitest の discovery から除外する技術判断自体は妥当です。しかし #1545 は、リポジトリ固有の pnpm test セキュリティ境界をスコープから落としており、AC3 は再現条件を生成せず、AC1 の Verification Command も成立しません。Allowed Paths のまま実装すると、Issue 自身の Stop Condition に到達します。なお #1545 には現時点でコメントがないため、以下は実装差分ではなく Issue 契約に対するレビューです。

    関連 Issue / PR の位置づけ

    Blocker 1 — Allowed Paths が pnpm test の正本を漏らしている

    現在の package.json は次の script を持っています。

    "test": "vitest run --exclude 'tests/e2e/**' --exclude '.claude/worktrees/**'"

    ところが同じ文字列は、.claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py の _SCRIPTS["test"] に完全一致値として重複定義されています。registry は package.json の script と期待値を完全一致比較し、差があれば manifest_integrity:closure_drift:test として実行前に拒否します。

    したがって、Issue の Allowed Paths に従って package.json だけを変更すると、リポジトリの canonical gate が壊れます。これは単なるテスト漏れではなく、#1511/#1529 で追加された fail-closed 境界との衝突です。既存の security-boundary test も registry を唯一の authority として扱い、manifest drift を launch 前に拒否する設計です。

    必須修正

    Allowed Paths に最低限、次を追加する必要があります。

    .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py
    .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py
    

    後者は既存テストが自動追従するだけなら編集不要かもしれませんが、変更可能範囲として明示し、少なくとも focused regression を実行すべきです。

    Blocker 2 — AC3 は再現条件を作っておらず、実装前後を区別できない

    AC3 は「.claude/tmp/ 配下に一時 worktree が存在する状態で、そこにあるテストファイルを収集しない」と要求しています。しかし VC は単に次の一行です。

    pnpm test

    .claude/tmp/ は .gitignore 対象です。CI は actions/checkout したクリーンな Ubuntu 環境で pnpm test を実行するため、通常は問題を起こしたローカル一時 worktreeが存在しません。

    結果として、現在の AC3 は以下のすべてで PASS し得ます。

    • 修正前だが .claude/tmp/ が空
    • 修正前だが、一時 worktree 内のテストも偶然 PASS
    • 修正後で正しく除外されている

    これは Issue authoring 規約が禁止する unexpected_pass 型の VC です。同規約も、実装前に確実に失敗する条件へ書き換えることを求めています。

    必要なのは negative control を含む sentinel probe です。

    1. .claude/tmp/vitest-discovery-probe-<unique>/sentinel.test.ts を作る。
    2. 新しい除外を外した discovery では sentinel が見つかることを確認する。
    3. canonical 設定では sentinel が見つからないことを確認する。
    4. sentinel が存在するまま pnpm test が成功することを確認する。
    5. finally 相当で自分が作った probe directory を削除する。

    Vitest 4.1 には vitest list --filesOnly があり、--json と --static-parse を組み合わせて、テストを実行せず discovery 結果を機械判定できます。全 suite の成否だけを見るより、この機能を negative control に使う方が決定的です。 (Vitest)

    Blocker 3 — AC1 の rg コマンドが意図した文字列を検査しない

    現在の VC は次の形です。

    rg -n -- "--exclude \'.claude/tmp/**\'" package.json

    ripgrep は既定で検索パターンを正規表現として解釈します。この VC は glob の ** を正規表現として扱ううえ、二重引用符内の \' も不要です。意図した post-change の script 行に対する固定文字列検査になっていません。ripgrep でリテラル検索する場合は -F / --fixed-strings が必要です。 (GitHub)

    最低限、次に修正すべきです。

    rg -n -F -- "--exclude '.claude/tmp/**'" package.json

    より強くするなら、exclude の部分文字列ではなく scripts.test の完全な期待値を JSON として検査してください。部分文字列検査では、無効な位置への追記、重複指定、別 script への混入でも PASS します。

    Major 1 — AC2 はテストの存在しか証明していない

    AC2 は「3つの除外を検証し、どれかが欠ければ失敗する test」を要求しています。一方 VC は次だけです。

    test -f tests/vitest-test-discovery-policy.test.ts

    これは空ファイル、全 test が skip されたファイル、常に PASS する無意味な assertion でも成功します。リポジトリの workflow は各 AC が独立に検証可能であることを要求しており、AC2 はその条件を満たしていません。

    少なくとも focused 実行に変えるべきです。

    pnpm exec vitest run tests/vitest-test-discovery-policy.test.ts

    PR #1534 の検証でも、同形式の focused Vitest command が使われています。

    ただし、この静的 test は補助的な regression guard に留めるべきです。文字列が存在することと、Vitest が実際にファイルを除外することは別の性質です。

    Major 2 — Outcome の境界が folder policy と一致していない

    Issue の goal は「repo-approved temporary workspace を Vitest discovery から除外する」と一般化されています。しかし folder policy 上、同じ repo_approved_temporary_workspace に属するのは次の2つです。

    • tmp/
    • .claude/tmp/

    Issue が除外するのは .claude/tmp/** だけです。Vitest 4 は既定で node_modules と .git しか除外しないため、tmp/ 内に *.test.ts があれば同じ汚染が起き得ます。 (Vitest)

    どちらかを明示的に選ぶ必要があります。

    • 狭い修正: goal/outcome を「.claude/tmp/ のみ」に限定する。
    • class 単位の修正: tmp/** も除外し、双方に対する sentinel test を置く。

    現在のタイトルは前者ですが、goal_ref と説明は後者を主張しており、契約が過剰に一般化されています。

    Major 3 — 「cleanup は policy 違反」という説明が不正確

    folder policy は、現在の post-merge-cleanup Skill/SubAgent の権限を常に report_only としています。一方で lifecycle policy は、tmp/ と .claude/tmp/ の所有者が自分の session subdirectory を削除するか残置理由を報告することを求めています。valid marker child は将来の executor に対する eligible_for_delete です。

    したがって、正確な説明は次です。

    cleanup は現在の post-merge-cleanup component に任せられず、残置物の有無にも依存できないため、test discovery 側で防御的に隔離する。

    「cleanup 自体が folder policy に違反する」と一般化するのは誤りです。除外追加が必要であるという結論は変わりませんが、根拠は修正すべきです。

    Major 4 — .claude/tmp/ に実 Git worktree を作る producer が未特定

    workflow の canonical worktree 配置先は .claude/worktrees/... です。

    #1545 は .claude/tmp/pr1534-step2-{current,final,rerun} を「一時 worktree」と呼んでいます。この記述が正しいなら、以下のいずれかです。

    • managed worktree が非 canonical path に作成されている
    • 実際には worktree ではなく、repository copy / temporary checkout である
    • 例外的な review fixture だが、その設計が文書化されていない

    除外追加は defense-in-depth として正しいものの、producer、作成コマンド、ownership marker、残置理由を特定しないままでは、原因分析が「Vitest が見つけた」地点で止まっています。producer 側を直さない理由、または別 Issue へ送ることを明記すべきです。

    Runtime Verification Applicability も再判定が必要

    現在の not_applicable 理由は「外部サービス・権限・ネットワークが不要」であることを中心にしています。しかし repo policy の判定基準はネットワークの有無ではなく、静的検査だけで完結するか、プロセス・I/O を必要とするかです。AC3 は実ファイルを配置して Vitest discovery/process を確認する要求なので、本文どおりに検証するなら immediate 側です。

    標準 pnpm test だけで完結する静的回帰ゲートは runtime policy の対象外ですが、現在の AC3 は fixture の作成が欠落しているため「標準コマンドだけで十分」な状態ではありません。

    推奨は次のいずれかです。

    • AC3 に runtime-verification: true を付け、sentinel discovery log を evidence とする。
    • AC3 を削除して純粋な設定 contract test に限定し、not_applicable を維持する。ただしこの場合、「実際に収集されない」という保証は弱くなります。

    前者が妥当です。

    技術選択自体の評価

    リポジトリは lockfile 上で Vitest 4.1.6 を使用しています。

    Vitest v4 の仕様では、

    • exclude は project root、既定では process.cwd() を基準に解決される
    • CLI の --exclude は複数回指定でき、設定値に加算される
    • glob 解決には tinyglobby が使われる

    ため、repo root からの .claude/tmp/** というパターン自体は正当です。 (Vitest)

    現行 upstream 実装も、project cwd に対して dot: true を設定し、exclude を tinyglobby の ignore に渡しています。したがって dot-directory である .claude/ を対象にできる点にも問題はありません。

    つまり、問題は 修正内容ではなく、Issue のスコープ・正本同期・検証設計 です。

    推奨する修正版契約

    最小修正案

    Allowed Paths
    - package.json
    - .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py
    - .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py
    - tests/vitest-test-discovery-policy.test.ts
    - scripts/verify-vitest-discovery-policy.mjs
    

    Acceptance Criteria は次の形に再編するのが妥当です。

    1. package.json と pnpm_gate_registry.py が、3つの exclude を含む同一の canonical test script を保持する。
    2. focused contract test が、各 exclude の欠落・重複・順序不整合を検出する。
    3. probe script が .claude/tmp/ に一意な failing sentinel を作る。
    4. negative control では sentinel が discovery される。
    5. canonical pnpm test では sentinel が収集されず、suite が成功する。
    6. probe directory は成功・失敗を問わず cleanup される。
    7. pnpm gate security-boundary regression が成功する。

    Verification Commands の最低構成は次です。

    rg -n -F -- "--exclude '.claude/tmp/**'" package.json
    
    pnpm exec vitest run tests/vitest-test-discovery-policy.test.ts
    
    uv run pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py
    
    node scripts/verify-vitest-discovery-policy.mjs
    
    pnpm test

    より良い設計案

    長期的には discovery policy を長い package.json script に保持せず、既存の vite.config.ts の test.exclude に移す方が堅牢です。現在の vite.config.ts には Vitest 設定がありません。

    Vitest は既存の Vite config を読み取るため、同じファイルへ test 設定を追加すれば、pnpm test だけでなく直接の Vitest CLI や editor integration にも同じ discovery policy が適用されます。公式にも Vite/Vitest で同じ config を使う構成が推奨されています。別の vitest.config.ts を作る場合は vite.config.ts を上書きするため、明示的な merge が必要です。 (Vitest)

    設定で exclude を指定すると Vitest の既定値を置き換えるため、次のように configDefaults.exclude を保持する必要があります。 (Vitest)

    test: {
      exclude: [
        ...configDefaults.exclude,
        'tests/e2e/**',
        '.claude/worktrees/**',
        '.claude/tmp/**',
      ],
    }

    ただし、この案でも package.json の script を短縮・変更するなら pnpm_gate_registry.py の同期は必須です。

    結論として、#1545 の実装意図は採用可能ですが、現状は最低でも Blocker 1〜3と Runtime Verification Applicability を修正してから着手すべきです。


    you asked

    message time: 2026-07-17 07:50:43

    そもそも .claude/tmp の運用について認識していない。tmp/ではないのか。リポジトリ資産に.claude/tmp の運用についてドキュメントかエージェントスキルなどに書かれているか?ClaudeやCodexのメモリなどに書かれてしまっていないか? tmp/ へ集約したい。


    chatgpt response

    .claude/tmp/ の記載箇所、導入経緯、Claude/Codex向け指示面を横断して確認します。tmp/ 集約時に変更が必要な正本・consumer・テストまで特定します。

    現時点で、.claude/tmp/ は偶発的な残骸ではなく、AGENTS.md、フォルダポリシー、cleanup skill、schema、guard、classifier にまで組み込まれています。Codex向け指示面には明示されています。

    現行資産では .claude/tmp/ の常用 producer は見つかっていません。一方、利用を許可・推奨するルールだけが広範囲に残っており、運用実態よりポリシーが先行している状態です。

    結論

    はい。.claude/tmp/ は現在、リポジトリ固有の正式な運用ルールとして複数箇所に埋め込まれています。
    Claude/Codexの製品標準ではなく、Issue #1404 で正式ポリシーへ昇格され、#1417 で schema・classifier・cleanup 契約にまで固定されたものです。tmp/ への一本化が妥当です。

    Claude / Codexの「メモリ・指示」に入っているか

    Codex:明示的に入っている

    ルートの AGENTS.md に、次の記述があります。

    repo-approved local temporary workspace は tmp/ と .claude/tmp/

    OpenAIの公式説明では、リポジトリ内の AGENTS.md はCodexへ持続的なリポジトリ文脈として与えられます。したがって、これは実質的にCodexのrepo-level memory/instructionです。(OpenAI)

    Claude:CLAUDE.md 本体にはないが、動的に注入される

    現在の CLAUDE.md 自体には .claude/tmp/ の記載はありません。記載されているのは、.claude/skills/**/SKILL.md をCodexにも流用するという入口だけです。

    しかし、Claude Codeの .claude/settings.json は root_temporary_residue_advisory.sh をPreToolUse hookとして登録しています。

    このhookが呼ぶproducerは、エージェントの追加コンテキストに次の内容を注入します。

    • approved roots: tmp/, .claude/tmp/
    • メッセージ: tmp/ または .claude/tmp/ を使う

    Codex側にも同じhookが登録されています。

    つまり、Claude/Codexの両方が作業中に .claude/tmp/ を推奨候補として受け取る構造です。

    Claude Codeのユーザー領域にある ~/.claude/CLAUDE.md などはGitHubからは確認できません。Claude Codeでは /memory によりロード済みmemory fileを確認できます。(Claude Platform Docs)

    埋め込まれている主なリポジトリ資産

    指示・SSOT

    • AGENTS.md
    • docs/dev/repository-folder-policy.md
    • docs/dev/agent-skill-boundaries.md
    • docs/dev/hook-boundaries.md
    • .claude/skills/post-merge-cleanup/SKILL.md

    folder policyは tmp/ と .claude/tmp/ を同じ repo_approved_temporary_workspace として定義しています。

    agent boundaryも、両方を正規rootとして扱っています。

    cleanup skillも両方を削除禁止・将来の削除候補rootとして列挙しています。

    実装

    • scripts/agent-guards/root_temporary_residue_policy.py
    • scripts/agent-ops/temp_residue_marker.py
    • scripts/agent-ops/temp_residue_classifier.py

    classifierは両方をapproved rootとしてハードコードしています。

    APPROVED_ROOTS = ("tmp", ".claude/tmp")

    marker validatorも両方を許可しています。

    _TARGET_RELPATH_RE = re.compile(r"^(tmp|\.claude/tmp)/[^/]+$")

    Schema

    • schemas/temp_residue_owner_v1.schema.json
    • schemas/repo_temp_folder_advice_v1.schema.json

    owner schemaは .claude/tmp を正規の target_relpath として受理します。

    advisory schemaはapproved rootsを2件必須としており、tmp/ と .claude/tmp/ の両方をenumに持ちます。

    Tests

    • scripts/agent-guards/tests/test_root_temporary_residue_policy.py
    • .claude/hooks/tests/test_root_temporary_residue_advisory.py
    • tests/codex/test_root_temporary_residue_advisory.py
    • tests/agent_ops/test_temp_residue_classifier.py

    テストは .claude/tmp/ を「advisoryを出さない正規パス」として明示的に固定しています。

    classifier testも .claude/tmp/session-owned を削除候補になり得るapproved sessionとして固定しています。

    .gitignore

    .claude/tmp/ はignore対象です。

    .claude/tmp/pr1534-step2-* は何だったのか

    tracked repository内には、.claude/tmp/ にworktreeを作成する恒常的なproducerは見つかりませんでした。

    正式なworktree配置先は次です。

    .claude/worktrees/issue-<番号>-<slug>/
    .claude/worktrees/<task-name>/
    

    したがって .claude/tmp/pr1534-step2-* は、既存scriptの正規動作ではなく、エージェントが「.claude/tmp/ はapproved workspace」という指示を解釈して一時checkout/worktreeを作った可能性が高いです。

    つまり原因はVitestだけではなく、

    1. .claude/tmp/ を正式なworkspaceとして宣伝している
    2. 具体的な用途境界がない
    3. worktreeの正式配置先と競合している

    というポリシー設計です。

    tmp/ 一本化の方針

    #1545をそのまま実装して .claude/tmp/** をVitestから除外するのは推奨しません。問題のある運用を温存します。

    Issueは次の目的へ置き換えるべきです。

    repo-approved temporary workspaceを tmp/ に一本化し、.claude/tmp/ をlegacy residueとして扱う

    第1段階:新規利用を停止

    • AGENTS.md は tmp/ のみを正本とする
    • folder policyから .claude/tmp/ のapproved指定を外す
    • .claude/tmp/** への新規Write/Bashには、tmp/ へ移行するnon-blocking advisoryを返す
    • classifierでは .claude/tmp/ をlegacy/report-onlyとして検出する
    • 新規ownership markerは tmp/<session> のみ許可する
    • cleanup skillは .claude/tmp/ をapproved候補ではなくlegacy residueとして報告する
    • #1545はsupersededとしてcloseする

    現在のguardは先頭segmentが .claude の場合、無条件に検出対象外へ落としています。したがって .claude/tmp の明示的なdeprecated判定が必要です。

    第2段階:残置物を除去してignoreを外す

    • ローカルの .claude/tmp/ をread-onlyで棚卸し
    • 実Git worktreeなら git worktree list --porcelain と照合
    • 必要なものを tmp/ または .claude/worktrees/ へ移行
    • 不要な残置物を所有者判断で削除
    • .gitignore から .claude/tmp/ を削除
    • legacy marker/schemaサポートを削除またはv2へ移行

    Schema上の注意

    temp_residue_owner/v1 から .claude/tmp を単純に削除すると、許可値の縮小=breaking changeです。

    schema catalogも narrow_type とtrust model変更をbreaking changeとして扱い、migrationとfollow-up Issueを要求しています。

    そのため、第1段階では次が安全です。

    • v1 parserは古い .claude/tmp markerを読めるまま残す
    • ただし新規producerは tmp/ しか生成しない
    • .claude/tmp markerは常にlegacy/report-only
    • 完全除去時にv2化またはv1廃止を行う

    最終判断

    tmp/ への集約に賛成です。

    現在の構成では、

    • tmp/ は既にIssue本文・中間成果物・artifact exportの正規パスとして使用されている。
    • worktreeには .claude/worktrees/ という専用rootがある。
    • .claude/tmp/ に固有の用途は定義されていない。
    • .claude/tmp/ の存在が一時checkoutの誤配置とtest discovery汚染を誘発している。

    したがって、tmp/=一般一時ファイル、.claude/worktrees/=Git worktreeという2区分に整理し、.claude/tmp/ は廃止するのが最も明確です。


    Powered by AI Exporter

  3. squne121 commented on Jul 17, 2026

    @squne121
    OwnerAuthor
    schema_version: ANCHOR_SCOPE_REFRAME_V1
    target:
      repo: squne121/loop-protocol
      issue_number: 1545
    decision: approve_scope_delta
    allowed_path_deltas:
      - ".claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py"
      - ".claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py"
      - "scripts/verify-vitest-discovery-policy.mjs"
    rationale: "上記 issuecomment (敵対的レビュー) の Blocker 1 (pnpm_gate_registry.py との closure_drift 回避のための同期変更) と Major 2 (class 単位の修正: tmp/** も .claude/tmp/** と同じ discovery boundary に含め、双方向 sentinel test を置く) を採用するため、Allowed Paths を拡張する。"
    required_rerun:
      - contract_review
      - refinement_preflight
      - allowed_paths_gate
  4. squne121 commented on Jul 17, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  5. squne121 commented on Jul 17, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-07-17T11:57:37Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1545
      body_sha256: "sha256:f0d068caca4cc2975ddb64e88c42990f7baf7968d4a296223260407244c314b0"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        product_spec_check: {"schema":"product_spec_check/v1","applicability":"applicable","decision":"pass","triggers":{"docs_product_allowed_paths":false,"tasks_md_mentioned":false,"specify_artifact_mentioned":false,"generated_task_mentioned":false,"product_spec_context_present":false,"machine_readable_contract_present":true},"conditions":{"docs_product_requires_spec_evidence":{"status":"pass","evidence":[]},"tasks_md_not_direct_source":{"status":"pass","evidence":[]},"specify_not_canonical":{"status":"pass","evidence":[]},"diff_first_rationale_present":{"status":"pass","evidence":[]},"generated_task_trace_present":{"status":"pass","evidence":[]},"task_dependencies_materialized":{"status":"pass","evidence":[]}},"blocked_reasons":[],"body_sha256":"sha256:f0d068caca4cc2975ddb64e88c42990f7baf7968d4a296223260407244c314b0","source_provenance":{"source_type":"github_api","body_file":null}}
        vc_preflight:
          decision: pass
          classifications: [{"ac":"AC1","line":2,"raw_command":"rg -n -F -- \"--exclude '.claude/tmp/**'\" package.json","command_hash":"sha256:53d215784f7a6031230b5226a8facd01e2ee0c28080b4c49cf15f14e95196cd3","execution_key_hash":"sha256:d892c562d04a7c547c5be37e66744bbc329d930b9d72756b5d999fac995c41be","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":3,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC1","line":3,"raw_command":"rg -n -F -- \"--exclude 'tmp/**'\" package.json","command_hash":"sha256:23d1bee2bd08e59d164c068bdec0a227fbcba05f500b48202f56c077715090a7","execution_key_hash":"sha256:27d5ad1fd26b888fb7a52c2d9801d5f3f0e8fc19bdb6845a5f3d2a967815465e","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC1","line":4,"raw_command":"rg -n -F -- \"--exclude '.claude/tmp/**'\" .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py","command_hash":"sha256:5fc1afedff815465f92939e469895e1b04fe3040a14f507c84a7ce9ccbaa664f","execution_key_hash":"sha256:4c4d8fe98d506df1741b22bb8ac7ebb09fddd033fd21975308a51f127a854d01","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC1","line":5,"raw_command":"rg -n -F -- \"--exclude 'tmp/**'\" .claude/skills/issue-contract-review/scripts/pnpm_gate_registry.py","command_hash":"sha256:275521536263b6d94a6c4cd56ade2b379790f9a110113aaeaa89ea1ba073d6fa","execution_key_hash":"sha256:ba348f65783c01578c1df8722b9122ed6678b15952c4fec99c00e39f0042f77c","runner":"exec","exit_code":1,"classification":"expected_fail","category":"expected_baseline_fail","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":1,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null},{"ac":"AC2","line":9,"raw_command":"rg -n -F -- \"'.claude/tmp/**'\" tests/vitest-test-discovery-policy.test.ts","command_hash":"sha256:e7441ba4b01eeba2cc888e682475257bdcfcef8d2aa7d88fc542d3e31de9dac2","execution_key_hash":"sha256:e2a83e37b80b84d23e66a46696fca3a92553eb6095744488a52ae64057cac81d","runner":"exec","exit_code":2,"classification":"expected_fail","category":"new_file_missing_expected","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":["rg: tests/vitest-test-discovery-policy.test.ts: No such file or directory (os error 2)"],"stderr_truncated":false,"stderr_original_line_count":2,"runner_env_delta":{},"duration_ms":1,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":8,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC2","line":11,"raw_command":"rg -n -F -- \"'tmp/**'\" tests/vitest-test-discovery-policy.test.ts","command_hash":"sha256:be9377dd016ee390a713c851cc65039548ab841213803992a665f6d49d21abbc","execution_key_hash":"sha256:e567d0377f1d63c824ec60028f36186e57c9a0376dd4b62c7f0620bafc6f3c62","runner":"exec","exit_code":2,"classification":"expected_fail","category":"new_file_missing_expected","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":["rg: tests/vitest-test-discovery-policy.test.ts: No such file or directory (os error 2)"],"stderr_truncated":false,"stderr_original_line_count":2,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":10,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC2","line":13,"raw_command":"rg -n -F -- \"'.claude/worktrees/**'\" tests/vitest-test-discovery-policy.test.ts","command_hash":"sha256:788569acae42ebb2db8aad5a320fda4f579ab01acd85228afb2a156dae5c296a","execution_key_hash":"sha256:41c6dde144026a3c52e0511a54ae7e2bd1b4e3f7c1f2fb50849e6e4df5e5563d","runner":"exec","exit_code":2,"classification":"expected_fail","category":"new_file_missing_expected","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":["rg: tests/vitest-test-discovery-policy.test.ts: No such file or directory (os error 2)"],"stderr_truncated":false,"stderr_original_line_count":2,"runner_env_delta":{},"duration_ms":2,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":12,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC2","line":15,"raw_command":"rg -n -F -- \"'tests/e2e/**'\" tests/vitest-test-discovery-policy.test.ts","command_hash":"sha256:f4decdfb535df0fcf018e547e441d924a85c7fcc1243e0e559cda2bbd557a0a9","execution_key_hash":"sha256:7a1c1642ea094496d25364e53b16c32b1663a51a03be345ff1790dcaf0da6089","runner":"exec","exit_code":2,"classification":"expected_fail","category":"new_file_missing_expected","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":["rg: tests/vitest-test-discovery-policy.test.ts: No such file or directory (os error 2)"],"stderr_truncated":false,"stderr_original_line_count":2,"runner_env_delta":{},"duration_ms":3,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":14,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC3","line":19,"raw_command":"test -f scripts/verify-vitest-discovery-policy.mjs","command_hash":"sha256:1efa504e8a165d98c30789ffe4dcea1f3d3dcb5c9b2166e2af51021c8aaa366c","execution_key_hash":"sha256:b628b14fab4e66a855864824d794b850a68fe98cef13884a48364bb30a89c101","runner":"exec","exit_code":1,"classification":"expected_fail","category":"file_not_found_expected","decision":"go","scope_class":"baseline_fail_expected","confidence":"high","stdout_head":[],"stdout_truncated":false,"stdout_original_line_count":1,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":0,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":"fail","vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":18,"raw":"# baseline-expect: fail"},"strict":null,"repair":null},{"ac":"AC4","line":22,"raw_command":"uv run --locked pytest .claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py","command_hash":"sha256:07e84a66bd0562368e5366f909db035cd46e2b1ff363f621fdb3972c7d30de75","execution_key_hash":"sha256:69c45fab9b38968776c9778051333f9cec5887d92c87de208abe6db5f3894d32","runner":"exec","exit_code":0,"classification":"expected_pass","category":"regression_gate","decision":"go","scope_class":"regression_gate","confidence":"low","stdout_head":["============================= test session starts ==============================","platform linux -- Python 3.12.3, pytest-9.0.3, pluggy-1.6.0","rootdir: /home/squne/projects/LOOP_PROTOCOL","configfile: pyproject.toml","plugins: xdist-3.8.0","collected 11 items",".claude/skills/issue-contract-review/tests/test_pnpm_gate_security_boundary.py . [  9%]","..........                                                               [100%]","============================== 11 passed in 0.05s =============================="],"stdout_truncated":false,"stdout_original_line_count":12,"stderr_head":[],"stderr_truncated":false,"stderr_original_line_count":1,"runner_env_delta":{},"duration_ms":328,"fix_hint":null,"certified_target_paths":null,"annotations":{"baseline_expect":null,"vc_role":null,"missing_baseline_expect":false},"annotation_source":{"line":null,"raw":null},"strict":null,"repair":null}]
      source: ensure_contract_snapshot_auto
  6. squne121 commented on Jul 17, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了・PR起票は overlap preflight hard gate によりブロック(2026-07-17)

    • Worktree: .claude/worktrees/issue-1545-vitest-tmp-discovery-exclude
    • Branch: worktree-issue-1545-vitest-tmp-discovery-exclude(push 済み、head 55fe582e01273548802e02c8ecb93450aae862b4)
    • Verification: 4/4 PASS(pnpm typecheck / pnpm lint / pnpm test(97 files, 1580 tests)/ pnpm build)
    • AC1〜AC4 の Verification Commands: すべて PASS(scripts/verify-vitest-discovery-policy.mjs の runtime probe を含む)

    PR 起票がブロックされている理由

    open_pr.py の overlap preflight hard gate(Issue #1458)が check_implementation_overlap.py をオンライン再実行し、route: human_review_required を返すため gh pr create を実行できません。

    原因は本 Issue と無関係な2件の候補 Issue が、classifier の厳密な見出しマッチ(^##\s+Outcome\s*$ / ^##\s+In Scope\s*$)を満たさないことです。

    両候補とも本文を直接確認し、本 Issue(Vitest discovery exclusion)と意味的に disjoint であることを手動確認済みです(詳細は PR body ドラフトの Notes セクション参照)。ただし open_pr.py の hard gate は fresh route が proceed / proceed_with_collision_evidence のときのみ通過する設計であり、手動確認による override機構は用意されていません(既存の overlap_readback_waiver は #519/#520/#1429 に固定・期限切れのため対象外)。

    次のアクション(人間判断が必要)

    1. check_implementation_overlap.py の見出しマッチを緩和する fix、または 実装: schema-governance.md の Initial Known Schemas を catalog から生成するスクリプト(#131 FU-5) #521/実装: e2e 実行前に CJK フォント可用性を fail-fast 検査し豆腐 baseline の誤再生成を防ぐ #754 の本文を canonical 見出し(## Outcome / ## In Scope)に修正する fix を別 Issue で検討する。
    2. 本 Issue の PR は人間が gh pr create(または update_pr.py/open_pr.py の override)で直接起票する。
    3. branch は push 済みのため、実装内容自体の再作業は不要です。

    Verification 詳細・PR body ドラフトは worktree 内に用意済みです。

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

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions