Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/review/review-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const DEFAULT_DIFF_BUDGET = 80_000;
* Cypress/Playwright `.cy`/`.e2e`, a bare `spec/` dir), so those tests were ranked as SOURCE(0) and
* could displace real source under a tight budget — the exact opposite of this function's job. */
export function diffFilePriority(path: string): number {
if (/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|cargo\.lock|poetry\.lock|composer\.lock|go\.sum)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4;
if (/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lock|bun\.lockb|cargo\.lock|poetry\.lock|pipfile\.lock|composer\.lock|gemfile\.lock|go\.sum|go\.work\.sum|uv\.lock|packages\.lock\.json|flake\.lock|deno\.lock|pubspec\.lock|podfile\.lock|mix\.lock|package\.resolved|gradle\.lockfile|pdm\.lock|conan\.lock|pixi\.lock|cartfile\.resolved|gopkg\.lock|shard\.lock|rebar\.lock|renv\.lock|chart\.lock)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4;
if (/(^|\/)(dist|build|out|coverage|vendor|node_modules)\//i.test(path)) return 4;
if (/\.(md|mdx|markdown|rst|adoc|asciidoc|txt)$/i.test(path)) return 2;
if (isTestPath(path)) return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/review/review-grounding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function buildGrounding(f: GroundingFlags, checks?: CheckAggregate, fileC
* copy missed pytest `test_*.py`, Go `*_test.go`, Ruby `*_spec.rb`, Cypress/Playwright `.cy`/`.e2e`, and a
* bare `spec/` dir — so those tests ranked as SOURCE(0) and were inlined ahead of real source). */
export function diffFilePriority(path: string): number {
if (/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|cargo\.lock|poetry\.lock|composer\.lock|go\.sum)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4;
if (/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lock|bun\.lockb|cargo\.lock|poetry\.lock|pipfile\.lock|composer\.lock|gemfile\.lock|go\.sum|go\.work\.sum|uv\.lock|packages\.lock\.json|flake\.lock|deno\.lock|pubspec\.lock|podfile\.lock|mix\.lock|package\.resolved|gradle\.lockfile|pdm\.lock|conan\.lock|pixi\.lock|cartfile\.resolved|gopkg\.lock|shard\.lock|rebar\.lock|renv\.lock|chart\.lock)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4;
if (/(^|\/)(dist|build|out|coverage|vendor|node_modules)\//i.test(path)) return 4;
if (/\.(md|mdx|markdown|rst|adoc|asciidoc|txt)$/i.test(path)) return 2;
if (isTestPath(path)) return 1;
Expand Down
7 changes: 7 additions & 0 deletions test/unit/review-diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ describe("diffFilePriority — source survives, noise drops first", () => {
}
});

it("ranks every path-matchers lockfile as noise(4), not source(0)", () => {
for (const path of ["bun.lock", "uv.lock", "deno.lock", "flake.lock", "mix.lock", "chart.lock"]) {
expect(diffFilePriority(path)).toBe(4);
expect(diffFilePriority(path)).toBeGreaterThan(diffFilePriority("src/a.ts"));
}
});

it("ranks every canonical test convention as tests(1), not source(0)", () => {
// These are all tests; before delegating to isTestPath the inline regex missed them and ranked
// them SOURCE(0), so on a tight budget they could displace real source (the opposite of the goal).
Expand Down
7 changes: 7 additions & 0 deletions test/unit/review-grounding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ describe("review-grounding: diffFilePriority (source survives the budget first)"
expect(diffFilePriority("src/a.ts")).toBeLessThan(diffFilePriority("README.md"));
});

it("ranks every path-matchers lockfile as noise(4), not source(0)", () => {
for (const path of ["bun.lock", "uv.lock", "deno.lock", "flake.lock", "mix.lock", "chart.lock"]) {
expect(diffFilePriority(path)).toBe(4);
expect(diffFilePriority(path)).toBeGreaterThan(diffFilePriority("src/a.ts"));
}
});

it("ranks long-form doc spellings as docs(2), matching rag.ts and path-matchers", () => {
for (const path of ["GUIDE.markdown", "docs/spec.asciidoc", "notes.ADOC"]) {
expect(diffFilePriority(path)).toBe(2);
Expand Down
Loading