Skip to content

fix(explore): return requested test callbacks and caller-linked test source - #390

Merged
bompus merged 1 commit into
fork/consolidatedfrom
feat/explore-named-tests
Oct 4, 2026
Merged

bompus merged 1 commit into
fork/consolidatedfrom
feat/explore-named-tests

Conversation

@bompus

@bompus bompus commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Pinned JavaScript and TypeScript test files could return only helpers. Questions about tests could list a test in the blast radius while omitting its source. Explore now prioritizes matching callbacks and includes source from the nearest test callers of named symbols.

Test discovery follows at most three caller hops. A bounded walk through test-local helpers recovers callback call sites. Complete statements around those calls remain available when a long callback exceeds its allowance. Examples keep their ranking penalty and cannot terminate the search for actual tests. Architecture questions still exclude test source; file and output limits still apply.

Validation:

  • Regression fixtures cover file-only and generic test requests, exact callback titles, indirect aliased calls, test-local helpers, examples, and explicit file limits.
  • All 52 targeted requested-source, blast-radius and budget controls pass.
  • Four Vite/Flask control answers are byte-identical to the base. Both original test-source gaps reproduce on the base and pass with this change on a private downstream project.
  • Full suite passes: 577 files, 7,366 tests, 39 skips.
  • Test floor guard and whitespace checks pass.

README rows checked: added Requested test source; checked Missing names reported and Change questions. The MCP reference, server instructions and changelog describe the new behavior. No quoted benchmark numbers changed. Extraction and resolution are unchanged, so no re-index is required.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (4)
.cursor/rules/codegraph.mdc — auto-discovered
AGENTS.md — auto-discovered
Generated by CodeRabbit — auto-discovered
docs/viewer-launch-changelog.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0422a228-a1c6-4afa-bfae-ee68c2c3e7be
📥 Commits

Reviewing files that changed from the base of the PR and between 7b1ac6f and 9d5864f.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • README.md
  • __tests__/explore-requested-source.test.ts
  • site/src/content/docs/reference/mcp-server.md
  • src/mcp/explore-source-ranges.ts
  • src/mcp/server-instructions.ts
  • src/mcp/tools.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features
    • Test-related code exploration now surfaces matching test callbacks from pinned JavaScript and TypeScript test files.
    • Questions about tests covering named symbols can include source from nearby test callers, including indirect callers, within search and output limits.
  • Documentation
    • Clarified that test links are based on static caller relationships, not measured runtime coverage.

Walkthrough

codegraph_explore now discovers static test callers for named symbols and includes relevant test source. Pinned JavaScript and TypeScript test files prioritize matching it and test callbacks, subject to file and output budgets.

Changes

Requested test source

Layer / File(s) Summary
Discover test callers
src/mcp/tools.ts
Test-related queries search up to three caller hops with a per-root lookup budget. The search records test callers and call-site lines, and distinguishes an exhausted search from one that found no tests.
Select requested test statements
src/mcp/explore-source-ranges.ts
requestedSourceRanges uses call-site lines and text matches to select complete test statements. It can include fallback test ranges when the query does not name an indexed function or method.
Retain and validate requested test source
src/mcp/tools.ts, __tests__/explore-requested-source.test.ts, src/mcp/server-instructions.ts, site/src/content/docs/reference/mcp-server.md, README.md, CHANGELOG.md
Discovered test files are retained through relevance and allocation filtering. Tests cover callback selection, caller discovery, file limits, and exclusion from architecture queries. Documentation describes the static caller links and pinned-test behavior.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 9d586

No actionable issue remains that should prevent merging after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 9d586

The change expands which repository text is returned, without a demonstrated increase in read authority or executable actions. Existing traversal, file-selection, and response limits remain in place. Deployment-specific access controls were not established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed response can expose additional test text from the selected indexed project. Existing projectPath behavior also permits selecting other indexed local projects, so total exposure depends on the caller's existing process and deployment access; the inspected resolution checks are not proof of tenant authorization.

Trust Boundaries and Controls

  • observed — Client arguments pass through centralized validation and project resolution. Before reading caller-linked test source, the handler applies validatePathWithinRoot to the derived path and skips it when validation fails. Caller discovery does not bypass this source-read check.

Resilience and Maintainability Implications

  • observed — Requested test-source retention changes admission and ranking, not the final response envelope: allocation still applies maxFiles, and rendering charges source against the existing output ceiling.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Explore returns requested test callbacks and source from caller-linked tests.
Description check ✅ Passed The description explains the test-source gaps, the change, its limits, and the reported validation. It is directly related to the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Suppressions Explained ✅ Passed The reviewed diff adds no lint, type-check, or compiler suppression directive. The added-line scans found no suppression markers, and the changed-file inventory contains no lint or type-check configur…
User-Visible Changes Documented ✅ Passed The diff adds no CLI command or flag, MCP tool or MCP argument, supported language or framework, agent target, or config key. The optional callLines parameter belongs to the internal `requestedSourc…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bompus
bompus merged commit 66878d7 into fork/consolidated Oct 4, 2026
1 check passed
@bompus
bompus deleted the feat/explore-named-tests branch October 4, 2026 22:59
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.

1 participant