Repository navigation
fix(search): find a symbol by its docstring (#985) - #4504
SrijanSriv wants to merge 2 commits into
Conversation
|
Thanks for the pull request, @SrijanSriv. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 4 changed function(s) (2 sampled, not proven, 2 not verified).
Formal verification. PR-changed functions: 2/4 verified (0 proven, 2 may-equivalent, 0 distinguished) · 2 not verified (2 unsupported).
Not verified on this run: \_extract\_js\_rationale (unsupported), \_extract\_python\_rationale (unsupported).
Graphify review — findings
Makes search find a symbol by words that appear only in its docstring (#985): previously a function whose name shared nothing with the question was unreachable even when its docstring answered it. Truncated Python and JS rationale nodes now keep their whitespace-collapsed full text (capped at 600 chars) in a text field, while untruncated ones add nothing. At search time, _attach_docstrings copies that text onto the documented symbol as an in-memory _docstring, which the rationale scoring tier matches, falling back to the truncated label for graphs built before text existed. The attachment is never written back to graph.json, and the AST cache schema is bumped to 17 so existing caches re-extract.
No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 3866 functions depend on the 641 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_query_graph_text()— 49 callers, 5 callees - worse:
_query_terms()— 20 callers, 3 callees - worse:
_build_server()— 2 callers, 18 callees - worse:
_get_trigram_index()— 6 callers, 3 callees
Verification — 3866 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 3655 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
231 of 423 test file(s) selected (55%) via static blast radius.
tests/test_affected_overrides.py— impacttests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_blade_extractor.py— impacttests/test_build.py— impacttests/test_builtin_global_type_refs.py— impacttests/test_c_include_resolution.py— impacttests/test_cache.py— impacttests/test_cache_stale_import_target.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_cjs_module_extension.py— impacttests/test_cobol_extractor.py— impacttests/test_cpp_method_declarations.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cpp_template_type_params.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_language_call_resolution.py— impacttests/test_cross_repo_external_call_guards.py— impacttests/test_cross_repo_member_calls.py— impacttests/test_csharp_call_site_generic_args.py— impacttests/test_csharp_enum_members.py— impacttests/test_csharp_field_generic_args.py— impacttests/test_csharp_foreach_loop_variable.py— impacttests/test_csharp_generic_callsites.py— impacttests/test_csharp_interface_dispatch.py— impacttests/test_csharp_member_calls.py— impacttests/test_csharp_member_chain_calls.py— impacttests/test_csharp_member_nodes.py— impacttests/test_csharp_object_creation.py— impacttests/test_csharp_partial_classes.py— impacttests/test_csharp_tuple_type_refs.py— impacttests/test_csharp_type_resolution.py— impacttests/test_csharp_underscore_collisions.py— impacttests/test_csharp_var_call_return_type.py— impacttests/test_csharp_verbatim_interpolation.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_docstring_search.py— impact, changed-testtests/test_dotnet.py— impacttests/test_duplicate_annotation_edges.py— impacttests/test_ejs_extractor.py— impacttests/test_elixir_defdelegate.py— impacttests/test_elixir_import_resolution.py— impacttests/test_elixir_keyword_def_calls.py— impact- … and 181 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.9.84 (2026-10-10) (lines 144-157): references changed symbolsprocessCHANGELOG.md§ 0.9.49 (2026-08-24) (lines 611-634): references changed symbolsprocessCHANGELOG.md§ 0.9.22 (2026-07-20) (lines 932-941): references changed symbolsprocessCHANGELOG.md§ 0.9.5 (2026-07-02) (lines 1209-1232): references changed symbolsfetchData
Formal verification
Could not verify: Could not verify \_extract\_js\_rationale.
The verifier did not have enough to check \_extract\_js\_rationale, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: the input domain has 59 values but only 24 distinct were tested — a small finite domain must be EXHAUSTED, not sampled (an untested input could invert the result)
Could not verify: Could not verify \_extract\_python\_rationale.
The verifier did not have enough to check \_extract\_python\_rationale, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: the input domain has 59 values but only 24 distinct were tested — a small finite domain must be EXHAUSTED, not sampled (an untested input could invert the result)
No difference found (not proven): No behavior difference found in \_get\_trigram\_index (not a proof).
The verifier ran both versions of \_get\_trigram\_index on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
No difference found (not proven): No behavior difference found in \_node\_rationale\_text (not a proof).
The verifier ran both versions of \_node\_rationale\_text on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
· 4 more finding(s) on lines outside this diff (see the check run).
… node (Graphify-Labs#985) A docstring or WHY comment longer than the 80-character label lost every word past the cut, and those are often the words a question uses. Python and JS/TS rationale nodes now carry the whitespace-collapsed full text in `text` when the label had to truncate it, capped at 600 characters to bound graph.json growth. Short docstrings add no field. AST cache schema bumped to 18. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AST extraction stores a docstring as its own rationale node linked by a
`rationale_for` edge, so a function whose name shares no words with a question
("which function resolves generic call sites?") was unreachable even when its
docstring answers it. Before building the trigram index, copy each rationale
node's text onto the symbol it documents as in-memory `_docstring`, and let the
rationale tier match it. Idempotent per graph object; never written back to
graph.json. Every search path (CLI query, MCP, find_node) goes through the index.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
4d94962 to
85e6d37
Compare
What does this PR do?
Related to #985.
A function whose name shares no words with a question was unreachable by search, even when its docstring answers the question ("which function resolves generic call sites?"). AST extraction keeps a docstring as its own
rationalenode, linked byrationale_for, and its label is cut at 80 characters.fix(extract): when the 80-character label had to truncate a Python docstring or a JS/TSWHY/NOTEcomment, the rationale node also carries the whitespace-collapsed full text intext, capped at 600 characters. Short docstrings add no field. AST cache schema bumped to 18.fix(search): before the trigram index is built,_attach_docstringscopies each rationale node's text (text, elselabel) onto the symbol it documents as in-memory_docstring, and_node_rationale_textincludes it. Every search path (CLIquery, MCP,find_node) builds the index first. Idempotent per graph object; never written back to graph.json.Type of change
Verification & Invariants
Invariant: a symbol is findable by the words of its own docstring, and graph.json does not grow without bound. Search behaviour for nodes without a docstring is unchanged.
Limitations: only Python docstrings and JS/TS rationale comments get
text, the extractors that already produce rationale nodes. The cache schema bump re-extracts ASTs once.How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.🤖 Generated with Claude Code