Skip to content

fix: exclude .claude/artifacts exact entry from permission-profile fixture copytree - #2103

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-2078-test-codex-permission-profile-config-fix
Aug 11, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-2078-test-codex-permission-profile-config-fix

Conversation

@squne121

@squne121 squne121 commented Aug 11, 2026 •

Copy link
Copy Markdown
Owner

概要

test_codex_permission_profile_config.py の _fixture_repo() が使う exclude_relpaths は、トップレベル "artifacts" エントリのみを含んでおり、ネストされた .claude/artifacts/ パスにはマッチしなかった。.claude/artifacts/issue-refinement-loop/<issue>/ は CI 並列実行下で run_refinement_preflight.py が継続的に書き込む volatile な writer subtree であり、shutil.copytree() によるコピー中に稀に shutil.Error を引き起こしうる。

本 PR は exclude_relpaths に exact entry .claude/artifacts を追加し(prefix matching は導入しない)、_fixture_repo() docstring を更新して、この除外が fixture-local な措置であり .claude/artifacts を repository-wide に disposable と定義するものではないことを明記する。あわせて除外挙動を検証する新規テストファイル tests/codex/test_fixture_repo_artifact_exclusion.py を追加した。

本 Issue をクローズする: Closes #2078

変更内容

  • tests/codex/test_codex_permission_profile_config.py: _fixture_repo() の exclude_relpaths に exact entry .claude/artifacts を追加し、docstring を更新(fixture-local な措置であることを明記)
  • tests/codex/test_fixture_repo_artifact_exclusion.py(新規): test_fixture_repo_excludes_claude_artifacts を追加し、.claude/artifacts がコピー先に存在しないこと、他の .claude 配下は引き続きコピーされることを検証

検証コマンド結果

# AC1
$ uv run --locked pytest tests/codex/test_fixture_repo_artifact_exclusion.py::test_fixture_repo_excludes_claude_artifacts -q
1 passed in 0.23s

# AC2
$ uv run --locked pytest tests/codex/test_codex_permission_profile_config.py tests/codex/test_fixture_repo_artifact_exclusion.py -q
24 passed in 7.72s

# AC3
$ uv run --locked pytest tests/codex/test_fixture_repo_artifact_exclusion.py::test_fixture_repo_excludes_claude_artifacts -q
1 passed in 0.23s

# AC4
$ rg -n "fixture-local" tests/codex/test_codex_permission_profile_config.py
73:    `.claude/artifacts` is also excluded as a fixture-local measure: it mixes

Allowed Paths 遵守

変更ファイルは Issue #2078 の Allowed Paths と完全一致:

  • tests/codex/test_codex_permission_profile_config.py
  • tests/codex/test_fixture_repo_artifact_exclusion.py(新規ファイル)
  • .github/ci/python-test-plan.json(Scope Delta、iteration 3、人間 OWNER 承認済み。CI の uncovered_changed_test_files gate(G1)が新規テストファイル tests/codex/test_fixture_repo_artifact_exclusion.py を検出できず FAIL していたため、targets 配列への1行追加のみを行った。dedicated_lanes / secondary_coverage / スケジューラ等は変更していない)

Runtime Verification Applicability

  • decision: not_applicable(Issue 本文どおり。全 AC は hermetic な pytest で完結する)

…xture copytree (#2078)

`_fixture_repo()` in test_codex_permission_profile_config.py excluded a
top-level "artifacts" entry, which does not match the nested
`.claude/artifacts/` tree. Since `.claude/artifacts/issue-refinement-loop/<issue>/`
is continuously rewritten by run_refinement_preflight.py during CI's
parallel test execution, copying it via shutil.copytree() could
intermittently raise shutil.Error for a file that vanished mid-copy.

Add an exact entry ".claude/artifacts" to exclude_relpaths (no prefix
matching introduced), update the _fixture_repo() docstring to clarify this
is a fixture-local measure and not a repository-wide disposable-policy
statement (since .claude/artifacts also holds committed historical/evidence
assets), and add a new regression test file
tests/codex/test_fixture_repo_artifact_exclusion.py verifying the exclusion
behaviorally.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2103/

The preview will be removed when this PR is closed.

CI の node-backed-hook-tests job にある uncovered_changed_test_files
gate (G1) が、PR #2103 で追加した新規テストファイル
tests/codex/test_fixture_repo_artifact_exclusion.py を検出できず
FAIL していた。.github/ci/python-test-plan.json の targets 配列に
1行追加のみで登録する(dedicated_lanes / secondary_coverage /
スケジューラ等は変更しない)。Issue #2078 iteration 3 Scope Delta
(人間 OWNER 承認済み)に基づく修正。
@squne121

Copy link
Copy Markdown
Owner Author

結論

判定: REQUEST_CHANGES。P0/P1 は見つかりませんでしたが、P2 を1件修正してから merge するのが妥当です。

PR #2103 の実装修正そのもの、つまり _fixture_repo() の exact exclusion に .claude/artifacts を追加する方針は正しいです。PR は現在 Draft / open / mergeable、HEAD は 79aef8c91f6aca6a68d33f4f441afc1546c88733、3 files changed / +73 -1 です。 現在 submitted review はありません。

P2 — regression test が「他の .claude 内容を保持する」という主張を実際には検証していない

PR 本文は新規テストについて、

.claude/artifacts がコピー先に存在しないこと、他の .claude 配下は引き続きコピーされることを検証

と明示しています。

しかし実際のテスト後半は、

copied_claude_dir = dest / ".claude"
assert copied_claude_dir.is_dir()

しか確認していません。コメントでは「skill canonical bodies も引き続き copied」「exclusion is scoped to .claude/artifacts only」と説明していますが、.claude という空ディレクトリだけ残して配下を全部落とす壊れた実装でもこの assertion は PASS します。

これは単なるテスト強化案ではなく、PR が宣言する regression guarantee と実際の assertion の不一致です。特に _fixture_repo() の docstring 自身が .agents/skills/* から参照される .claude の skill canonical bodies を保持することを重要な fixture contract としています。

修正は小さくて済みます。たとえば既に repository asset として存在し、この Issue の writer 説明にも使われている安定した sibling を1つ assertion すれば十分です。

copied_skill = (
    dest
    / ".claude"
    / "skills"
    / "issue-refinement-loop"
    / "scripts"
    / "run_refinement_preflight.py"
)
assert copied_skill.is_file()

このファイルは HEAD に実在し、run_refinement_preflight.py 自身も canonical artifact output を .claude/artifacts/issue-refinement-loop/<issue_number>/ と定義しています。

これなら「.claude/artifacts は落とすが、必要な .claude canonical surface は残す」という load-bearing property を直接検証できます。

実装修正自体は妥当

ここは反証を試みましたが、問題ありません。

Python 3.12 の shutil.copytree() 実装では、各 directory について ignore callback が名前一覧を受け取り、返された名前は その場で continue され、再帰コピーに入らない実装です。したがって .claude を走査したとき exact name artifacts を返せば .claude/artifacts 全体を安全に prune できます。prefix matcher は不要です。 ([GitHub]1) 公式 API 契約も、ignore が「現在の directory に対する相対名」を返す仕様であり、コピー中の例外は shutil.Error に集約されます。 ([Python documentation]2)

つまり今回の

exclude_relpaths = {
    ...
    ".claude/worktrees",
    ".claude/artifacts",
}

と既存の

rel = os.path.relpath(dirpath, REPO_ROOT)
relpath = name if rel == "." else f"{rel}/{name}"
if relpath in exclude_relpaths ...

の組み合わせは、狙った subtree を必要最小限に除外する実装として適切です。

また .claude/artifacts を repository-wide disposable と誤って一般化しない docstring 変更も重要です。実際、.claude/artifacts/context-mode/profile-scope-definition.json は repository に存在し、その中で install_scope / scope_semantics が project-shared-commit-tracked と記録されています。 したがって「volatile writer がいるから .claude/artifacts は全部ゴミ」という設計にしなかったのは正しいです。

関連 Issue / PR との整合性

Issue #2078 は OWNER adversarial review で一度 REQUEST_CHANGES になっており、その際に「prefix matching をやめ exact entry にする」「volatile と commit-tracked asset の混在を明記」「historical failure の provenance が不足しているので root cause confirmed と断定しない」「grep ではなく behavioral verification にする」「source-side precondition を置く」が要求されました。現在の Issue/PR はこれらをほぼ正しく反映しています。

PR #1864 との整合性も悪くありません。#1864 では、permission-profile validator が現実的な repository surface を使わないことで false-green になる問題を受けて fixture と mutation test が強化されました。今回 .claude/artifacts を全部 fixture から抜く以上、「それは fixture-local で、validator に不要な mutable surface だけを切る」という境界説明は不可欠です。現在の docstring はそこを押さえています。

一方 #2073/#2074 とは分離して扱うべきです。#2074 は当初 xdist/timeout 仮説から serial lane 化しましたが、#2073 の最終 RCA は os.path.realpath(sys.executable) による venv identity 喪失 → jsonschema import failure という別問題に確定しています。 したがって #2103 を「#2073 系 flake の本質的解決」と説明していない現在の整理は正しいです。

CI / 並列性について

.github/ci/python-test-plan.json への新規ファイル追加も必要な変更です。現在は新規 regression file が target に登録され、xdist は workers: 4, dist: loadscope のままです。 HEAD commit 自身も、この追加が uncovered_changed_test_files gate を通すための Scope Delta だったと記録しています。

loadscope は test function を module 単位で group 化し、各 group を worker に配る仕様なので、新規 module と元の permission-profile module が別 worker で同時実行され得ます。 ([pytest-xdist]3) その意味でも、live source 内の既知 volatile subtree をコピー対象から入口で prune する今回の修正は、serial quarantine より設計として良いです。

ただし 「これで _fixture_repo() の live-repo copy が race-free になった」とまでは言えません。Issue #2078 自身もその residual risk を認識しており、今回除外したのは既知 writer subtree 1つです。将来的に同様の flake が別 path で発生するなら、exclude list を増やし続けるより「validator が本当に必要な repository surface を allowlist materialization する」方式を別 Issue で検討する価値があります。現 PRでやるべきではありません。

最終評価

P0: 0 / P1: 0 / P2: 1

修正の causal mechanism、exact-match の選択、.claude/artifacts の mixed-lifecycle 説明、python-test plan への登録はいずれも妥当です。CI green もこの方向を支持していますが、green だけでは regression test の assertion 不足は検出できません。

merge 前に最低限、

assert (dest / ".claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py").is_file()

相当を追加し、「artifact subtree は消える」「必要な .claude sibling は残る」双方を behavioral に固定することを推奨します。これを直せば、私は #2103 を APPROVE 相当と評価します。

PR #2103 への OWNER レビュー (REQUEST_CHANGES) 対応。

test_fixture_repo_excludes_claude_artifacts は `.claude/artifacts` が
コピー先に存在しないことのみ検証しており、`.claude` ディレクトリが
存在すること (`is_dir()`) しか確認していなかった。これでは `.claude`
配下を丸ごと空にして残す壊れた実装でも PASS してしまう。

実在する安定した `.claude` 配下ファイル
(`.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py`)
がコピー先に実ファイルとして存在することを検証する assertion を追加し、
「`.claude/artifacts` は除外される」「他の `.claude` 配下は引き続き
コピーされる」の両方を behavioral に検証するようにした。
@squne121

Copy link
Copy Markdown
Owner Author

OWNER レビュー(P2×1, REQUEST_CHANGES)に対応しました。

修正内容

tests/codex/test_fixture_repo_excludes_claude_artifacts に、実在する安定した .claude 配下ファイル
(.claude/skills/issue-refinement-loop/scripts/run_refinement_preflight.py) がコピー先に実ファイルとして
存在することを検証する assertion を追加しました(既存の assertion は削除せず、追加のみ)。

これにより、以下の両方を behavioral に検証します。

  • .claude/artifacts はコピー先から除外される(既存 assertion)
  • .claude 配下の他ファイル(skill canonical bodies)は引き続きコピーされる(今回追加した assertion)

修正前は .claude という空ディレクトリだけを残して配下を全部落とす壊れた実装でも
copied_claude_dir.is_dir() は PASS してしまう構造でしたが、これを解消しています。

検証結果

uv run --locked pytest tests/codex/test_codex_permission_profile_config.py tests/codex/test_fixture_repo_artifact_exclusion.py -q
........................                                                 [100%]
24 passed in 6.52s

commit: b60598e

@squne121 squne121 self-assigned this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: test_codex_permission_profile_config fixtureの.claude/artifacts除外パターン不備を修正する

1 participant