tools/indexing/persistence/writer.py:409
merge_clause = f"MERGE (n:{label} {{name: row.name, path: $file_path, line_number: row.line_number}})"
# ...
UNWIND $batch AS row
{merge_clause}
SET n += row
Two distinct symbols in one file sharing a name and a line silently become one node, and SET n += row overwrites the first's args, class_context, end_line and cyclomatic_complexity with the last's.
This is the root cause of the 5530 vs 5501 discrepancy. Re-parsing the repo with the shipped parsers:
total parsed functions: 5530
distinct merge keys: 5501
lost: 29 (22 colliding keys)
Two sources of collision:
- CSS —
tools/languages/css.py:83 emits every selector as a Function. Grouped selectors (table, tbody, tr, td { }) produce several records with the same name and line.
- Minified/bundled JS —
website/public/wasm/tree-sitter-core.js is one line, so genuinely different functions all carry line_number: 1. Node.endIndex and TreeCursor.endIndex collapse into a single node whose class_context is whichever was written last.
Fix. Add a disambiguator to the merge key (end_line, class_context, or a per-file ordinal). At minimum, detect key collisions in add_file_to_graph and log them.
Audit environment
|
|
| Version |
codegraphcontext 0.5.2 (PyPI) |
| Commit |
df3af04 |
| Backend |
FalkorDB Lite (falkordblite 0.9.0), Python 3.12.3, Linux |
| Corpus |
the CodeGraphContext repo itself — 784 files, 23 languages, 5,501 Function nodes |
Audit ID I-H05 · severity high · from an end-to-end audit of CGC 0.5.2 (63 findings). Reported with the reproduction as run.
tools/indexing/persistence/writer.py:409Two distinct symbols in one file sharing a name and a line silently become one node, and
SET n += rowoverwrites the first'sargs,class_context,end_lineandcyclomatic_complexitywith the last's.This is the root cause of the 5530 vs 5501 discrepancy. Re-parsing the repo with the shipped parsers:
Two sources of collision:
tools/languages/css.py:83emits every selector as aFunction. Grouped selectors (table, tbody, tr, td { }) produce several records with the same name and line.website/public/wasm/tree-sitter-core.jsis one line, so genuinely different functions all carryline_number: 1.Node.endIndexandTreeCursor.endIndexcollapse into a single node whoseclass_contextis whichever was written last.Fix. Add a disambiguator to the merge key (
end_line,class_context, or a per-file ordinal). At minimum, detect key collisions inadd_file_to_graphand log them.Audit environment
codegraphcontext0.5.2 (PyPI)df3af04falkordblite0.9.0), Python 3.12.3, LinuxFunctionnodesAudit ID
I-H05· severity high · from an end-to-end audit of CGC 0.5.2 (63 findings). Reported with the reproduction as run.