feat: add compound query tools (explore, understand, prepare_change)#149
feat: add compound query tools (explore, understand, prepare_change)#149maplenk wants to merge 10 commits intoDeusData:mainfrom
Conversation
|
Thanks @maplenk — compound query tools that combine multiple graph operations into higher-level actions is a nice abstraction. Will review. |
Account for optional signatures in the search_graph and trace_call_path size estimators, and improve compact trace chains to report omitted-node counts. This also documents the normal-path output enrichment introduced with Task 4: search_graph results now include file_path, start_line, end_line, and signature, and trace_call_path hop items now include file_path, start_line, and signature.
- Guard cbm_mcp_text_result() against NULL text - Fix memory leak in handle_get_key_symbols() REQUIRE_STORE path (focus not freed) - Wire qn_pattern through handle_search_graph() - Fix OOM infinite loop in markdown_builder_reserve() - Return 0 instead of CBM_STORE_ERR from summary_count_nodes() on prepare fail Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prefer non-test symbol matches before pagerank for ambiguous short names. Batch-load visited node metadata and pagerank scores to remove per-node query loops during impact analysis. Hide test counts from the public summary when include_tests=false, and add max_tokens truncation support to get_impact_analysis with MCP coverage.
Add the impact-analysis store API declaration, expose get_impact_analysis in CLI help text, and cover the tool with the existing integration fixture.
- Chunk impact_fetch_nodes_with_scores() into batches of 900 to stay under SQLite's SQLITE_MAX_VARIABLE_NUMBER bind limit - Replace REQUIRE_STORE in handle_get_impact_analysis() with explicit cleanup that frees symbol on early return - Fix pre-existing test_integration assertion that used escaped JSON field matching (was already failing on origin/feat/blast-radius) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 5: Three new compound MCP tools (explore, understand, prepare_change) that bundle multiple graph queries into single-call responses: - explore: area search with matches, dependencies, hotspots, entry points - understand: symbol deep-dive with 3-tier resolution (exact QN, exact name with auto-pick, QN suffix with suggestions), callers, callees, source, connected symbols, is_key_symbol flag - prepare_change: wraps impact analysis with review_scope (must_review, should_review, tests) and include_tests=false support - All three support max_tokens budget with progressive truncation - Wire qn_pattern in store search (completing pre-existing API contract) Bug fixes across all committed phases: - Fix REQUIRE_STORE leaking heap args in 5 handlers (get_key_symbols, get_impact_analysis, explore, understand, prepare_change) - Fix markdown_builder_reserve infinite loop on OOM (NULL check after safe_realloc) - Fix SQLite bind parameter limit in impact_fetch_nodes_with_scores (chunk into batches of 900) - Fix cbm_mcp_text_result(NULL) crash on OOM (guard with empty string) - Fix POSIX regex: remove invalid PCRE (?i) prefix from contains pattern - Fix search degree filter: set min_degree/max_degree to -1 (disabled) in compound search helpers - Fix summary_count_nodes returning -1 on SQL error (return 0 instead) - Fix explore total_results overcounting unfiltered hotspots - Fix qsort(NULL, 0) undefined behavior in explore - Fix handle_understand early return leaking search outputs (use goto) - Refactor handle_prepare_change to use goto cleanup pattern Output enrichment (non-breaking): - search_graph results now include start_line, end_line, signature - trace_call_path hops now include file_path, start_line, signature Tests: 2639 passed (+44 new), 0 failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
83f8e8b to
0e55891
Compare
|
@maplenk — same as #148: please open an issue first to discuss compound query tools before implementing them. See the updated CONTRIBUTING.md. I'm currently not convinced these are needed — the existing tool surface was designed to be composable by the AI client, not pre-composed on the server side. Happy to discuss the use case in an issue though. |
|
Thanks @maplenk for the extensive work. After review, we're passing on the compound tools (explore, understand, prepare_change) — these multi-step workflows are better composed by the agent itself, which can adapt the query chain to its actual needs rather than receiving a fixed bundle. The bug fixes in this PR were for code introduced in #147/#148 (which we closed), so they don't apply to the current codebase. The path traversal protection for file reads already exists in our Closing as part of the #147 series cleanup. |
Summary
Three new tools that bundle multiple graph queries into single-call responses, reducing agent round-trips from 4–5 tool calls to 1.
New tools
explore— Area exploration. Takes a keyword, runs 3 searches (name/QN/path), merges and dedupes, adds dependency summaries for top matches, hotspots from PageRank, entry points from architecture. Token-budgeted.understand— Symbol deep-dive. 3-tier resolution: exact QN → short name (auto-pick by PageRank) → suffix match (returns suggestions if ambiguous). Returns source code, 1-hop callers/callees sorted by PageRank, connected symbols with relation labels, key symbol status.prepare_change— Pre-change analysis. Wraps impact analysis withreview_scope:must_review(target + direct callers),should_review(indirect),tests. Token budget priority: root → direct → review scope → tests.Bug fixes included
12 fixes across all phases — highlights:
markdown_builder_reserveimpact_fetch_nodes_with_scores(?:...)→(...))REQUIRE_STOREearly-return paths)qsort(NULL, 0)undefined behaviorcbm_mcp_text_result(NULL)crash guardsummary_count_nodesreturning -1 on SQL errormin/max_degree = -1handlingexploretotal_results overcountingTests
15 new tests + 3 integration tests. Total: 2639 passing.
Part 3 of a 4-PR series. Depends on #148 → #147.
Built with OpenAI Codex and Claude Code.