Repository navigation
fix(query): demote image caption nodes in seed scoring alongside docs - #5394
ayushcodes10 wants to merge 1 commit into
Conversation
Query seed selection already demotes test, document and paper nodes and nodes without a source file, unless the question itself asks about tests or docs, so a precise code symbol is not beaten by a test or doc whose own label repeats the question's words. Image nodes got no such treatment at all, so a golden test render whose caption happens to mention the same terms as the question still won the seed slot a code node should get, exactly the repro issue Graphify-Labs#445 reported, three planes render images outranking the fifteen actual mutation sites for a cross cutting query. Add image to the same file_type check the document and paper demotion already uses, so it rides the same demote_docs toggle (the per corpus escape hatch for a doc first corpus) rather than a separate flag.
|
Thanks for the pull request, @ayushcodes10. 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.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
2 possible issues to check · High impact
Query scoring now applies the existing document-demotion weight to image nodes as well.
2 possible issues we couldn't confirm
- Image demotion test only checks that the image scores above zero, so it would still pass if the image outranked the source ·
tests/test_query_source_first.py:124 - Module docstring says only test, doc, config and source-less nodes are demoted, but image nodes are now demoted too ·
tests/test_query_source_first.py:5
They don't change the score.
Code graph · 872 functions depend on this change
- 2 functions became more coupled.
_query_terms()(31 callers),_score_query()(25 callers). - 28 of 613 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 05236da · Full report in the Graphify check
Maintainer tweaks on top of the #5299/#5394/#5315/#5374 batch: - Move `import anyio` in serve.py to module top (was re-imported per call inside _warm_graph), a trivial cleanup on #5374. - 0.9.117 changelog and version bump. No AST-cache schema change in this batch (query scoring, export filenames, serve reload, rcfile parsing). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.118 via an authorship-preserving cherry-pick. Image nodes are now demoted in seed scoring alongside documents and papers, so a caption-rich image no longer out-seeds real code for a query whose terms it happens to repeat. Thanks @ayushcodes10! |
Bug
Fixes #445 (the remaining gap after #4601 was closed; see that PR's closing comment for context).
/graphify queryseed selection already demotes test, document and paper nodes, and nodes without a source file, to_QUERY_DEMOTE_WEIGHT(0.3) unless the question itself asks about tests or docs (_query_path_weightingraphify/serve.py, introduced bya50ad2b4for the same issue #445 and since hardened by0caa1c39/01c0a859). Image nodes got no such treatment at all, so a golden test render whose caption happens to mention the same terms as the question still wins the seed slot a precise code node should get — exactly the issue's own repro: three*.pngterritory renders outranking the fifteen actual mutation sites for a cross cutting query.Fix
Add
"image"to the samefile_typecheck the document/paper demotion already uses (graphify/serve.py), so it rides the samedemote_docstoggle (the per corpus escape hatch for a doc first corpus, #5084) rather than a separate flag. No new weight tier, no new config surface — just closing the one file_type this mechanism forgot.Tests
Extended
tests/test_query_source_first.py:imgnode (file_type="image") to the shared graph fixture, sharingsrc's own label so name matching alone cannot tell them apart, mirroring how the existingtstnode is set up.test_image_caption_nodes_are_weighted_down: the image node scores competitively on label match alone,_query_path_weightdemotes it to_QUERY_DEMOTE_WEIGHT, and the combined ranking puts the source node ahead of it.test_disabling_doc_demotion_also_preserves_full_weight_for_images:demote_docs=Falsekeeps the image node at full weight, same escape hatch as docs.Verification
upstream/v8(confirmed by temporarily restoring the unmodified file); thedemote_docs=Falsecontrol passes unmodified too, as expected (that toggle already defeats all demotion regardless of file type).tests/test_query_source_first.pyfull file: 12 passed.pytest -k "query or serve"): 840 passed, 11 skipped, no regressions.1 failed, 11711 passed, 234 skipped, 1 xfailed— the one failure (test_erlang_extractor.py::test_erlang_attributes_includes_and_remote_calls) confirmed pre-existing and unrelated to this change.python3 -m tools.skillgen --check:check OK: 134 artifact(s) match committed output and expected/.