bench: fix find_symbol exact-match against nested properties.name#674
Conversation
Smoke #3 revealed cg find-symbol --name <exact> returned [] for symbols the graph clearly contained (cg auto-complete --prefix found the same symbol with full file:line+docstring). Root cause: the filter compared item['name'] to the requested name, but the /api/auto_complete payload nests the symbol name under item['properties']['name'] (FalkorDB node properties), so the top-level lookup always returned None and nothing matched. Fix: prefer item['properties']['name'], fall back to item['name'] for flatter shapes the unit tests pass in. Added a regression test that uses the real payload structure. Verified end-to-end against the live FastAPI service: cg find-symbol --repo pytest-dev__pytest-6202__code_graph \ --name getmodpath # -> [{id:2714, labels:[Function], properties:{name,path,doc,...}}] This was the bug that made the smoke #3 code_graph agent burn 3 of 5 cg calls retrying exact-name lookups before falling back to auto-complete. With this fix, an agent doing the natural workflow (find-symbol -> get-neighbors -> note-edit) should land far fewer wasted calls. Also: norecursedirs in [tool.pytest.ini_options] to keep pytest from walking into per-instance bench worktrees that ship their own pytest sources (was breaking host pytest's AST rewriter on import). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes find_symbol in the bench code-graph adapter so it correctly matches the FalkorDB-encoded /api/auto_complete payload shape, where the symbol name lives under properties.name rather than top-level name. Also adjusts pytest to avoid recursing into bench-generated worktree caches.
Changes:
- Update
CodeGraphClient.find_symbolto match onitem["properties"]["name"], falling back to top-levelnamefor legacy/test fixtures. - Add regression test covering the nested
properties.namepayload shape. - Add
norecursedirsto pytest config to skipbench/cacheand other build/venv dirs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| bench/agents/code_graph_adapter.py | Filter against nested properties.name with fallback to top-level name. |
| tests/test_bench_code_graph_adapter.py | New regression test using FalkorDB node-shaped completions. |
| pyproject.toml | Add norecursedirs to prevent pytest collection in bench worktrees. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Problem
bench/agents/code_graph_adapter.py::find_symbolalways returned[]for exact-name lookups against the live/api/auto_completeendpoint, because it filtered on a top-levelnamefield that doesn't exist in the real response payload.The real
/api/auto_completepayload returns FalkorDB node shape:{ "id": ..., "labels": [...], "properties": { "name": "...", "path": "...", "doc": "...", ... } }The adapter was filtering
item.get("name") == name, which never matched.Fix
Filter checks
item["properties"]["name"]first, then falls back to top-levelname(for backward compat with older unit-test fixtures).Verification
test_find_symbol_reads_nested_properties_namecg find-symbol --name getmodpathnow returns the function record with path + line range, where before it returned an empty listNotes
/api/auto_completeendpoint is unaffecteddvirdukhan/benchmark-planbecause the affected file only exists there (benchmark suite not yet merged to staging)Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com