Skip to content

fix(semantic-query): read symbols from graph_nodes, not empty symbols table (closes #188)#191

Merged
Wolfvin merged 1 commit into
mainfrom
fix/issue-188-semantic-query-graph-nodes
Jul 4, 2026
Merged

fix(semantic-query): read symbols from graph_nodes, not empty symbols table (closes #188)#191
Wolfvin merged 1 commit into
mainfrom
fix/issue-188-semantic-query-graph-nodes

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Closes #188

Root Cause

semantic_search_engine._load_symbols_from_db read from the symbols table declared by persistent_registry, but the scan flow never calls insert_symbols_batchscan populates graph_nodes/graph_edges via graph_model.populate_graph_tables instead. So on every real workspace:

  • SELECT COUNT(*) FROM symbols → 0
  • SELECT COUNT(*) FROM graph_nodes → 652 (data lives here)

Result: semantic-query returned index_size: 0, returned: 0 on every query.

Fix (Option A from the issue)

Changed _load_symbols_from_db to read from graph_nodes with the column mapping prescribed in the issue:

graph_nodes symbol dict (existing engine contract)
node_id id
name name
file file_path
node_type kind
line line_start
extra_json extra_json

No schema change. Fields graph_nodes does not carry (signature, language, line_end, hash) are defaulted so _build_symbol_text and semantic_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 from name + file_path + kind + extra_json, which is enough for the "find by meaning" queries the engine targets.

Sebelum → Sesudah

Sebelum: _load_symbols_from_db ran SELECT * FROM symbols. On any workspace that has been codelens scan-ned, this returned [] (the table is created by persistent_registry.init_schema but never written to by the scan flow), so build_index produced an empty index and every semantic_query call returned index_size: 0, returned: 0.

Sesudah: _load_symbols_from_db runs SELECT 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 by scan via graph_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.json with 6 nodes (mix of auth/session/utils/io, classes + functions), runs the real graph_model.populate_graph_tables against it (the same function scan calls), then invokes semantic_query(ws, "google auth session flow"):

populate_graph_tables counts: {'nodes': 6, 'edges': 0}

status: ok
stats: {'total_symbols': 6, 'returned': 4, 'truncated': False, 'index_size': 22}
results:
  - GoogleAuthSession      score=0.6988 file=auth/session.py line=8   matched=['google','auth','session']
  - start_session_flow     score=0.6612 file=auth/session.py line=30  matched=['auth','session','flow']
  - loginUser              score=0.0840 file=auth/login.py    line=15  matched=['auth']
  - verify_jwt_claims      score=0.0775 file=auth/jwt.py      line=42  matched=['auth']
  • index_size > 0 ✓ (22)
  • returned > 0 ✓ (4)
  • index_size ≈ number of functions/classes ✓ (22 unique TF-IDF terms across 6 nodes)
  • Results ranked by TF-IDF relevance ✓ (top result GoogleAuthSession matches 3 of 4 query terms, score 0.6988)

Tests

tests/test_semantic_search_engine.py fixtures updated to mirror what scan actually produces (graph_nodes table, not the legacy symbols table). All 31 tests in that file pass.

Focused regression run on related modules (registry, graph, command-registry, query-graph, affected, CLI, command-count, codelens):

341 passed, 17 skipped, 0 failed

Files changed

  • scripts/semantic_search_engine.py_load_symbols_from_db now reads from graph_nodes; module + function docstrings updated to reflect the new source table.
  • tests/test_semantic_search_engine.py_make_db fixture now creates graph_nodes (mirroring scripts/graph_model.py:_CREATE_GRAPH_NODES); two degradation tests renamed from *_symbols_table_* to *_graph_nodes_table_*; cache-invalidation test's raw INSERT INTO symbols rewritten to INSERT INTO graph_nodes with the correct column set.

Notes

  • No design doc needed — both files are modifications, not additions, so check_design_doc.py does not fire.
  • No sync_command_count.py --apply needed — no command added or removed.
  • No schema change — the fix only changes which existing table the engine reads from.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@Wolfvin Wolfvin merged commit db28a72 into main Jul 4, 2026
2 of 8 checks passed
@Wolfvin Wolfvin deleted the fix/issue-188-semantic-query-graph-nodes branch July 4, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(semantic-query): symbols table never populated — index_size always 0

1 participant