Skip to content

fix(search): grep and callers get the test handling #37 gave ask (#425) - #862

Open
hr1juldey wants to merge 1 commit into
trailhq:mainfrom
hr1juldey:fix/425-test-files-label
Open

hr1juldey wants to merge 1 commit into
trailhq:mainfrom
hr1juldey:fix/425-test-files-label

Conversation

@hr1juldey

Copy link
Copy Markdown

Fixes #425.

What was missing

#37 landed test handling in ask (a rank penalty) and blast (separate testModules) — grep and callers got neither. Test hits came back unlabelled next to production code, and --in can narrow but cannot exclude, which does not help the colocated layout (service.ts + service.test.ts). In the reporter's production repro ~80% of one grep answer (~4,300 tokens) was test lines.

Fix

  • isTestPath moves to the search layer (src/search/grep.ts) with the pattern extracted to a named constant (TEST_PATH_RE) and the discriminating choices documented (why .test. needs the dots — testing.ts stays production). ask imports it from there and re-exports, so its behavior and public surface are unchanged; grep, callers and ask now share one predicate.
  • Label + order (the issue's second option): the grep formatter marks test-file groups [test] and lists them after production groups — a stable partition, so the in-degree ordering inside each half is untouched. callers labels a test-file edge calls ← service.test.ts (…) [test] and orders those after production callers.
  • The flag (the issue's first option): --no-tests on both commands drops test files entirely. Excluded files are not counted into grep's "searched N indexed files" — they were not searched.
  • Threaded through the workspace federation (federateGrep / federateCallers), so workspace grep/callers behave the same as single-repo ones.

JSON shapes are unchanged; the label and ordering live in the formatters, which the MCP tools (graft_find_all, graft_trace_calls) already share — they pick the behavior up for free.

Tests (RED→GREEN, adversarial)

  • grepGraph default keeps both files; includeTests: false leaves only production, and filesSearched drops by the excluded file (it was not searched);
  • the formatter labels the test group [test], does NOT label the production file (including the service.ts suffix-inside-service.test.ts trap), and lists the test group last even when it sorted first;
  • isTestPath covers the documented shapes (*.test.ts, *.spec.js, __tests__/, tests/, _test.go, conftest.py, test_*.py) and refuses lookalikes (testing.ts, contest.py, latest.ts);
  • hitLine labels a test-file edge, leaves production unlabelled, and leaves unresolved-import rows (no path to judge) unlabelled.
  • Full suite: fail-6 (the six pre-existing main failures), 4552 tests.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🌱 graft blast radius

4 areas changed → 7 areas can be affected. 14 dependent symbols, depth 2.
Tests: 2 areas updated their tests.
Tag: @anirudhkumar-nanonets — 7 of 11 areas · Julien Letessier — Workspace Federation, Engine · Rushabh Nagda — Cloud Activity Management, First Minute Initialization

flowchart TB
  A0(("Tool Invocation<br/>6 symbols"))
  A1(("Cloud Activity Management<br/>3 symbols"))
  A2(("Note Asking<br/>1 symbol"))
  A3(("Engine<br/>1 symbol"))
  A4(("First Minute Initialization<br/>1 symbol"))
  AX(("2 smaller areas<br/>2 symbols"))
  classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
  class A0,A1,A2,A3,A4 reached;
  classDef tail fill:#EEF2F3,stroke:#9AA4A9,stroke-width:1px,color:#3A4247;
  class AX tail;
Loading
Can be affected Symbols Nearest hop Reached from
Tool Invocation 6 src/mcp/tools.ts:L1-L352 tools.ts — imports, depth 1 Ask Feature, Workspace Federation +1
Cloud Activity Management 3 src/cloud/lookup-activity.ts:L1-L60 lookup-activity.ts — imports, depth 1 Ask Feature
Note Asking 1 src/notes/ask-notes.ts:L1-L25 ask-notes.ts — imports, depth 1 Ask Feature
Engine 1 src/engine.ts:L1-L194 engine.ts — imports, depth 1 Ask Feature
First Minute Initialization 1 src/init/first-minute.ts:L1-L646 first-minute.ts — imports, depth 2 Ask Feature
Graph Root 1 src/graph/root.ts:L1-L98 root.ts — imports, depth 2 Ask Feature
1 smaller area 1 Sync Run see below
Who knows this code — 8 people across 11 areas
Area Who knows it
Ask Feature · changed Ercan Er — 1 commit, last 10d ago · @insuffer — 1 commit, last 10d ago
Workspace Federation · changed Rohan Shah — 1 commit, last 10d ago · Julien Letessier — 1 commit, last 10d ago
Grep Functionality · changed @anirudhkumar-nanonets — 1 commit, last 11d ago
Command Line Interface · changed @anirudhkumar-nanonets — 5 commits, last 2d ago
Tool Invocation · affected @anirudhkumar-nanonets — 1 commit, last 11d ago
Cloud Activity Management · affected Rushabh Nagda — 1 commit, last 2d ago · @anirudhkumar-nanonets — 1 commit, last 11d ago
Note Asking · affected @anirudhkumar-nanonets — 1 commit, last 11d ago
Engine · affected Julien Letessier — 1 commit, last 10d ago · @qoole — 1 commit, last 10d ago
…3 further areas

Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no @ has no GitHub handle in its commit email — tag them by hand, or add a .mailmap entry. A suggestion from history, not a CODEOWNERS rule.

All 14 dependent symbols, grouped by area

Tool Invocation — 6 symbols in 2 files

  • src/mcp/tools.ts:L1-L352 — tools.ts (imports, depth 1)
  • src/mcp/tools.ts:L136-L151 — renderMatches (calls, depth 1)
  • src/mcp/tools.ts:L157-L203 — callWorkspaceTool (calls, depth 1)
  • src/mcp/tools.ts:L265-L351 — callSingleTool (calls, depth 1)
  • src/mcp/server.ts:L1-L257 — server.ts (imports, depth 2)
  • src/mcp/tools.ts:L233-L262 — callTool (calls, depth 2)

Cloud Activity Management — 3 symbols in 3 files

  • src/cloud/lookup-activity.ts:L1-L60 — lookup-activity.ts (imports, depth 1)
  • src/cloud/onboarding.ts:L1-L735 — onboarding.ts (imports, depth 1)
  • src/cloud/pair.ts:L1-L368 — pair.ts (imports, depth 2)

Note Asking — 1 symbol in 1 file

  • src/notes/ask-notes.ts:L1-L25 — ask-notes.ts (imports, depth 1)

Engine — 1 symbol in 1 file

  • src/engine.ts:L1-L194 — engine.ts (imports, depth 1)

First Minute Initialization — 1 symbol in 1 file

  • src/init/first-minute.ts:L1-L646 — first-minute.ts (imports, depth 2)

Graph Root — 1 symbol in 1 file

  • src/graph/root.ts:L1-L98 — root.ts (imports, depth 2)

Sync Run — 1 symbol in 1 file

  • src/claude/sync-run.ts:L1-L77 — sync-run.ts (imports, depth 2)
Test signal per changed area — 2 ✓ · 2 –

Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.

  • – Ask Feature — 12 test files reach it, none changed here
  • ✓ Workspace Federation — 3 of 7 reached · 1 test file changed here: test/traverse-test-label.test.ts
    • not reached: orderAndFilterTestHits, runCallersCommand, runWorkspaceGrep, runWorkspaceCallers
  • ✓ Grep Functionality — 3 of 5 reached · 2 test files changed here: test/search-grep.test.ts, test/traverse-test-label.test.ts
    • not reached: groupHeader, runGrepCommand
  • – Command Line Interface — no function, method or class changed here
26 test suites also reference this code

27 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.

  • test/ask-fusion.test.ts
  • test/ask-index.test.ts
  • test/ask.test.ts
  • test/claude-hooks.test.ts
  • test/context-only-dir.test.ts
  • test/engine-init-concurrency.test.ts
  • test/engine-synth-model.test.ts
  • test/generic-extract.test.ts
  • test/graph-extensions.test.ts
  • test/graph-follow-submodules.test.ts
  • test/graph-imported-call-mcp.test.ts
  • test/graph-load.test.ts
  • test/graph-posix-paths.test.ts
  • test/graph-refresh.test.ts
  • test/graph-seed.test.ts
  • test/graph-workspace-include-dir.test.ts
  • test/graphrank.test.ts
  • test/mcp-tools.test.ts
  • test/regression-single-repo.test.ts
  • test/savings-locale.test.ts
  • …6 more

graft blast · refs/graft/base...HEAD · depth 2 · 9 changed files

Open the interactive graph → — click an area to see the code that changed, and the line that reaches it.

@hr1juldey
hr1juldey marked this pull request as ready for review November 19, 2026 04:36
@hr1juldey
hr1juldey force-pushed the fix/425-test-files-label branch from aba3f9f to 9aaa68d Compare November 19, 2026 09:39
…sk (trailhq#425)

Test files came back from `grep` and `callers` unlabelled, next to
production code, with no way to leave them out — in the reporter's
production repro about 80% of a grep answer (~4,300 tokens) was test
lines. trailhq#37's detection existed (`isTestPath` in ask) but never reached
these two commands.

- isTestPath moves to the search layer (grep.ts) with the pattern as a
  named constant (TEST_PATH_RE), so grep, callers and ask share one
  predicate; ask re-exports it, behavior unchanged.
- grep/callers: test hits carry a [test] label and list after
  production ones (stable partition — in-degree/BFS order inside each
  half untouched).
- both commands gain --no-tests to drop test files entirely; excluded
  files are not counted into grep's "searched N indexed files" (they
  were not searched).
- Threaded through the workspace federation too, so a workspace grep or
  callers behaves the same as a single-repo one.

The JSON shapes are unchanged; the label and ordering are formatter
behavior, and the MCP tools render through the same formatters, so
graft_find_all picks the label up for free.
@hr1juldey
hr1juldey force-pushed the fix/425-test-files-label branch from 9aaa68d to a1c7f80 Compare November 19, 2026 17:37

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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)

1 participant