Skip to content

diff-filter: ignore Anchor's .anchor/ generated directory #67

@tomazzi14

Description

@tomazzi14

Bug

packages/diff-filter's GENERATED_DIR_PREFIXES includes target/ (Cargo build output) but is missing .anchor/, the directory the Anchor framework writes during anchor build / anchor test.

We use Anchor in this very repo at contracts/solana/ — every time someone opens a PR that touches an instruction or struct, the .anchor/ ledger artifacts + IDL caches leak into the diff Sonnet sees, inflating the token count and pushing the signal-to-noise down.

Repro

import { classifyPath } from "@ghbounty/diff-filter";

classifyPath("contracts/solana/.anchor/test-ledger/genesis.bin");
// expected: { ignore: true, reason: "generated_dir" }
// actual:   { ignore: false }

Why it matters

  • Sonnet scoring quality drops when the diff contains regenerated ledger state.
  • Reviewers waste time scrolling past binary noise on the Files Changed tab.
  • Other tooling that consumes the filter (relayer, MCP) inherits the same blind spot.

Acceptance criteria

  • classifyPath returns { ignore: true, reason: "generated_dir" } for any path under .anchor/ (top-level or nested, e.g. contracts/solana/.anchor/test-ledger/genesis.bin).
  • At least one new test case in packages/diff-filter/tests/classify.test.ts covers an .anchor/ path.
  • All existing tests still pass.

Out of scope

  • Other Solana-toolchain caches (.solana/, solana-test-validator-* ledger dirs created outside .anchor/). Open separate issues if needed.
  • Anchor's target/idl/*.json (covered by the existing target/ prefix).

Notes

The fix is almost certainly a one-line addition to packages/diff-filter/src/patterns.ts::GENERATED_DIR_PREFIXES. Keep the test-and-fix tightly scoped — this is a perfect "bug fix with red-green test" candidate for our own AI scorer to grade well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions