Skip to content

grep and callers have no test handling — #37 reached ask and blast only (5 of 8 grep hits in a small repro are test lines; ~80% of a real answer) #425

Open

Description

@serdarcida

Summary

#37 (exclude or down-weight test files) is closed as completed, and in 0.18.0 the installed code shows where it landed: ask applies TEST_RANK_PENALTY unless the query asks for tests, and blast lists testModules apart from modules. grep and callers have neither. Test files come back alongside production code, unlabelled, and neither command has a flag to leave them out.

--in <path> narrows to a prefix but cannot exclude, so it does not help in the common TypeScript layout where a test sits next to the file it tests (service.ts + service.test.ts).

On a production TypeScript backend, about 80% of one grep answer (~4,300 tokens) was test lines — the answer the agent needed was the remaining 20%.

Version: graft 0.18.0 (@nanonets/graft), macOS 26.6.2 (arm64), node v26.6.0.

Repro — the TypeScript twin from #423, plus one colocated test

// src/service.ts
export class AuthService {
  signedIn(): boolean { return true; }
}

export function formatName(name: string): string { return name.trim(); }
// src/home.ts
import { AuthService, formatName } from "./service";

export class Home {
  auth: AuthService = new AuthService();

  title(): string { return formatName(" home "); }

  ready(): boolean { return this.auth.signedIn(); }
}
// src/service.test.ts
import { formatName } from "./service";

describe("formatName", () => {
  it("trims", () => { expect(formatName(" a ")).toBe("a"); });
  it("keeps inner spaces", () => { expect(formatName(" a b ")).toBe("a b"); });
  it("handles empty", () => { expect(formatName("")).toBe(""); });
});

graft callers formatName — the test file is listed as a caller, same shape as production

formatName · function · src/service.ts:L5-L5
  calls ← title (src/home.ts:L6-L6)
      6: title(): string { return formatName(" home "); }
  calls ← service.test.ts (src/service.test.ts:L1-L8)
      1: import { formatName } from "./service";

graft grep formatName — 5 of 8 hits are in the test file

"formatName" — 8 hits in 4 symbols across 3 files (searched 6 indexed files)
formatName · function · src/service.ts:L5-L5 · 2 in-edges
  L5: export function formatName(name: string): string { return name.trim(); }
src/home.ts (module level) · 0 in-edges
  L1: import { AuthService, formatName } from "./service";
Home.title · method · src/home.ts:L6-L6 · 0 in-edges
  L6: title(): string { return formatName(" home "); }
src/service.test.ts (module level) · 0 in-edges
  L1: import { formatName } from "./service";
  L3: describe("formatName", () => {
  L4: it("trims", () => { expect(formatName(" a ")).toBe("a"); });
  L5: it("keeps inner spaces", () => { expect(formatName(" a b ")).toBe("a b"); });
  L6: it("handles empty", () => { expect(formatName("")).toBe(""); });

What would help

Either would do:

  • a --no-tests flag on grep and callers, or
  • labelling test hits and test callers (calls ← service.test.ts [test]) and listing them after production ones — the way blast already separates testModules.

The detection already exists (isTestPath in ask), so this looks like wiring rather than new logic.

Happy to test a change against the repro above.

Activity

  1. hr1juldey commented on Nov 18, 2026

    @hr1juldey

    Picked this up. isTestPath moved to the search layer (grep/callers/ask now share one predicate), both commands label test hits [test] and list them after production, and both gain --no-tests — excluded files don't count into "searched N indexed files" either. Threaded through the workspace federation, and the MCP tools render through the same formatters so they pick it up for free. Draft: #862. The repro from this issue passes: grep NEEDLE with the twin-plus-test fixture labels the test group and --no-tests leaves only src/service.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions