🔧 fix: 検出器のファイル集合を repo-tracked に一致させる (#30) - #33
Merged
Conversation
#32 で landing した検出コマンドは rg が隠しディレクトリを既定で飛ばすため `.claude/**` を走査していなかった。プロジェクトの rules / skills / agents が 置かれる、このアンチパターンの主生息域がまるごと死角になる。 コンシューマのミラーで実測: 既定 2 件、`--hidden` 付き 3 件(差分は `.claude/rules/knowledge-layering.md`)。`.claude/` 配下に違反を1件植えた control も、既定では見逃し `--hidden` で捕捉することを確認した。 #32 の negative control はリポジトリ直下に置いており、ガードが既に届く場所 だったので「正しい理由で」発火していなかった。docs/claim-verification.md に control は claim のパターンではなく生息域に合わせて置くこと、そして shipped detector は「書かれたのとは別のリポジトリ」で走らせるのが最も安い一般形で あることを追記。 常時ロード3ファイル: 11,542 → 11,649 B (+107)。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DdbkSg6gQ1YzRkPhLxUGkk
前コミットの --hidden は dot-dir スキップという1インスタンスを塞いだだけで、 クラスは開いたままだった。再帰 grep は「ここに転がっているファイル」を、 ルールは「repo-tracked なファイル」を対象にしており、両者は双方向にずれる: - ignore 配下の追跡済みファイルは**見逃す**(.claude/ を丸ごと gitignore して 共有ルールだけ git add -f する形。フィクスチャで再現) - 逆に never-committed な作業ファイルを**誤検出**する(ルール自身が 「never-committed places なら memory 参照は可」と言っている) 再帰をやめ、scripts/scrub-check.sh が同じ問いに既に使っている `git ls-files --cached --others --exclude-standard` で列挙する形に変更。 同一リポジトリ内で「どのファイルを数えるか」に2つの機構があるとドリフトする。 rg 依存も外れる(当環境には rg の実体が無くシェル関数だった)。単一ファイル時に ファイル名が落ちるため grep は -H を付ける。 実測: フィクスチャの見逃しケースを捕捉、kit 0件、ミラー3件(--hidden 版と同一、 worktree の重複なし)、空リポジトリで cwd を走査せずハングもしない。 .claude/worktrees/ を .gitignore に追加。--others が駐機中の worktree を 重複ツリーとして列挙するため。従来 .git/info/exclude にしか無く、これは per-machine で他のクローンや CI には効かない。 docs/claim-verification.md は worked example を書き直し、再測不能だった 「2件/3件」の数値を落として、差分が何だったのか(ミラー自身のルール散文で、 まだ <name> プレースホルダ化されていないもの)を明示。 常時ロード3ファイル: 11,649 → 11,693 B (+44)。#32 landing 比では +151。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DdbkSg6gQ1YzRkPhLxUGkk
冗長な語(by default / in this repo / 反復する説明)を削り、意味を落とさず docs/claim-verification.md を 3 行、rules/knowledge-layering.md を 1 行短縮。 consumer ミラーの帰結(自分の rule ファイルが違反として報告される)は 本文に残した。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X41DihUZcmTVTpdq95r2R6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#32(#30 の逆昇格)で landing した検出コマンドの欠陥修正。#32 の形は使わないこと。
何が壊れていたか
rgは隠しディレクトリを既定で走査しないので、この形は.claude/**を一切見ていなかった。プロジェクトの
rules/skills/agents/が置かれる場所が丸ごと死角。そして
--hiddenを足すのは1インスタンスを塞ぐだけでクラスは開いたままだった、というのがこのPRの本題。再帰 grep は「ここに転がっているファイル」を、ルールは「repo-tracked な
ファイル」を対象にしており、両者は双方向にずれる:
.claude/を丸ごと gitignore して共有ルールだけgit add -fしている形。ファイルは追跡済みなのに
rgは ignore を尊重して飛ばす → 静かに0件、塞いだはずの失敗モードの再演memory 参照は可」と明言しているので、これはルールの主張に対する偽陽性
採用した形
再帰をやめ、
scripts/scrub-check.shが同じ問いに既に使っている列挙に揃えた。同一リポジトリ内で「どのファイルを数えるか」に2つの機構があるのはドリフトの元。副次的に
rg依存も外れる(当環境にはrgの実体が無く、Claude Code のシェル関数だった)。実測
rg(#32)rg --hidden.claude/配下に植えた controlrgバイナリ依存grepは-Hが要る(単一ファイル時にファイル名が落ちてfile:lineが壊れる)。実測して確認済み。./scripts/scrub-check.sh→PASS。その他
.claude/worktrees/を.gitignoreに追加。--othersが駐機中の worktree を重複ツリーとして列挙するため。従来
.git/info/excludeにしか無く、これは per-machine なので他のクローンや CI には効かない
docs/claim-verification.mdの worked example を書き直し。📝 docs: ミラー由来の3件を kit へ逆昇格する (#30) #32 で書いた「2件 /--hiddenで3件」という数値は、(a) private な別リポジトリの状態依存で public な kit の読者には再測不能、(b) 次の
ミラー同期で陳腐化する、(c) 「生きた dead link を捕まえた」と読めるが実際の差分はミラー自身の
ルール散文だった、の3点で不適切だったため落とした。代わりに差分の正体を明示し、「コンシューマは
検出器と一緒に
<name>プレースホルダ化も取り込まないと、自分のルールファイルが違反として出る」という downstream への注意を書いた
なぜ #32 の検証を通り抜けたか
#32 の negative control をリポジトリ直下に置いていた。ガードが既に届く場所なので、発火はしたが
問いを検証していない。
docs/claim-verification.md§ "A detector / guard / gate" の「a control whose fixture a sibling arm can also reach reddens for the wrong reason」の habitat 版。
なお #32 の「4/4 BLOCK」自体は有効。あのプローブが測ったのは「新しいレビュアーが shipped command を
実際に実行して、自己申告の偽の件数を捕まえるか」というレビュアー挙動で、検出器のスコープは
測っていない。結論は生き残るが、その根拠として引用されたコマンド出力ブロックは無効なので、
#32 にその旨コメントする。
常時ロードの byte
knowledge-layering.mdsubagent-usage.mdcontext-budget.mdDownstream
ミラー側(
.claude/rules/knowledge-layering.md)は #32 以前の形を既に持っている。reconcile にはこのPRの形を下ろすこと。#32 の形で同期を「完了」にすると、静かに壊れた検出器が残る。