From a77d1a00c7900371efaf24ea1edc393e1036d539 Mon Sep 17 00:00:00 2001 From: Fat Tom Date: Fri, 8 May 2026 11:17:03 -0300 Subject: [PATCH] fix: ignore Anchor's `.anchor/` generated directory (closes #67) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `packages/diff-filter` already filtered Cargo's `target/` but missed `.anchor/` — the directory the Anchor framework writes during `anchor build` / `anchor test` (test-ledger state, program-test snapshots, IDL caches). This repo uses Anchor at `contracts/solana/`, so PRs touching the escrow program were leaking regenerated ledger artifacts into the diff Sonnet scored. The fix is a one-line addition to `GENERATED_DIR_PREFIXES`; the existing nested-prefix check (`includes("/" + prefix)`) covers the realistic path `contracts/solana/.anchor/...` for free. Tests added in `classify.test.ts`: - `.anchor/test-ledger/genesis.bin` (top-level) - `contracts/solana/.anchor/test-ledger/...` (nested, the actual repo path) - `contracts/solana/.anchor/program-logs/...` 71/71 in @ghbounty/diff-filter pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/diff-filter/src/patterns.ts | 8 ++++++++ packages/diff-filter/tests/classify.test.ts | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/packages/diff-filter/src/patterns.ts b/packages/diff-filter/src/patterns.ts index bbc23b7..e29a973 100644 --- a/packages/diff-filter/src/patterns.ts +++ b/packages/diff-filter/src/patterns.ts @@ -83,6 +83,14 @@ export const GENERATED_DIR_PREFIXES = [ ".ruff_cache/", ".venv/", "venv/", + // Anchor framework (Solana). Sibling to Cargo's `target/` which is + // already covered above, but `.anchor/` holds the test-ledger + // genesis, IDL caches, and program-test snapshots that change on + // every `anchor build` / `anchor test` run. We use Anchor in this + // very repo at `contracts/solana/`, so PRs touching escrow + // instructions previously leaked these regen artifacts into the + // diff Sonnet scored. + ".anchor/", ]; export const GENERATED_FILE_SUFFIXES = [ diff --git a/packages/diff-filter/tests/classify.test.ts b/packages/diff-filter/tests/classify.test.ts index 34ce8b7..85f7393 100644 --- a/packages/diff-filter/tests/classify.test.ts +++ b/packages/diff-filter/tests/classify.test.ts @@ -49,6 +49,12 @@ describe("classifyPath — generated dirs", () => { "app/.next/static/chunks/webpack.js", "coverage/lcov-report/index.html", "__pycache__/module.cpython-311.pyc", + // Anchor framework — `.anchor/` holds regenerated ledger state and + // IDL caches. Both top-level and nested (under the actual workspace + // path used in this repo) must be filtered. + ".anchor/test-ledger/genesis.bin", + "contracts/solana/.anchor/test-ledger/rocksdb/CURRENT", + "contracts/solana/.anchor/program-logs/escrow.log", ])("marks %s as generated_dir", (path) => { const r = classifyPath(path); expect(r.ignore).toBe(true);