fix(semantic-query): read symbols from graph_nodes, not empty symbols table (closes #188)#191
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #188
Root Cause
semantic_search_engine._load_symbols_from_dbread from thesymbolstable declared bypersistent_registry, but the scan flow never callsinsert_symbols_batch—scanpopulatesgraph_nodes/graph_edgesviagraph_model.populate_graph_tablesinstead. So on every real workspace:SELECT COUNT(*) FROM symbols→ 0SELECT COUNT(*) FROM graph_nodes→ 652 (data lives here)Result:
semantic-queryreturnedindex_size: 0, returned: 0on every query.Fix (Option A from the issue)
Changed
_load_symbols_from_dbto read fromgraph_nodeswith the column mapping prescribed in the issue:node_ididnamenamefilefile_pathnode_typekindlineline_startextra_jsonextra_jsonNo schema change. Fields
graph_nodesdoes not carry (signature,language,line_end,hash) are defaulted so_build_symbol_textandsemantic_query's result construction keep working unchanged. Signatures/language are not part of the flat-registry node format produced by parsers, so there is no signal loss in practice — the TF-IDF document is still built fromname + file_path + kind + extra_json, which is enough for the "find by meaning" queries the engine targets.Sebelum → Sesudah
Sebelum:
_load_symbols_from_dbranSELECT * FROM symbols. On any workspace that has beencodelens scan-ned, this returned[](the table is created bypersistent_registry.init_schemabut never written to by the scan flow), sobuild_indexproduced an empty index and everysemantic_querycall returnedindex_size: 0, returned: 0.Sesudah:
_load_symbols_from_dbrunsSELECT node_id AS id, name, node_type AS kind, file AS file_path, line AS line_start, extra_json FROM graph_nodes. The table is populated byscanviagraph_model.populate_graph_tables, so the index now reflects the actual scanned symbol graph.Definition of Done — verified
Ran a verification script that builds a
backend.jsonwith 6 nodes (mix of auth/session/utils/io, classes + functions), runs the realgraph_model.populate_graph_tablesagainst it (the same functionscancalls), then invokessemantic_query(ws, "google auth session flow"):index_size > 0✓ (22)returned > 0✓ (4)index_size ≈ number of functions/classes✓ (22 unique TF-IDF terms across 6 nodes)GoogleAuthSessionmatches 3 of 4 query terms, score 0.6988)Tests
tests/test_semantic_search_engine.pyfixtures updated to mirror whatscanactually produces (graph_nodestable, not the legacysymbolstable). All 31 tests in that file pass.Focused regression run on related modules (registry, graph, command-registry, query-graph, affected, CLI, command-count, codelens):
Files changed
scripts/semantic_search_engine.py—_load_symbols_from_dbnow reads fromgraph_nodes; module + function docstrings updated to reflect the new source table.tests/test_semantic_search_engine.py—_make_dbfixture now createsgraph_nodes(mirroringscripts/graph_model.py:_CREATE_GRAPH_NODES); two degradation tests renamed from*_symbols_table_*to*_graph_nodes_table_*; cache-invalidation test's rawINSERT INTO symbolsrewritten toINSERT INTO graph_nodeswith the correct column set.Notes
check_design_doc.pydoes not fire.sync_command_count.py --applyneeded — no command added or removed.