Skip to content

fix(neo4j): derive the code property from module source spans - #105

Merged
rahlk merged 1 commit into
mainfrom
fix/issue-104-neo4j-code-property
Jul 17, 2026
Merged

fix(neo4j): derive the code property from module source spans#105
rahlk merged 1 commit into
mainfrom
fix/issue-104-neo4j-code-property

Conversation

@rahlk

@rahlk rahlk commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Closes #104.

Schema v2 removed the per-node code field (module source is stored once on PyModule.source, sliced by spans), but the Neo4j projection still read the old field via getattr(..., "code", None) — so every :PyClass / :PyCallable node was written without code. That deadened the py_code_fts fulltext index and the python-sdk Neo4j backend's RETURN c.code queries, breaking local ↔ Neo4j backend parity.

Fix: thread the owning module's source through the declaration walk (_project_module_body_project_class / _project_callable) and derive code at projection time by slicing the module source with each node's utf-8 byte span (_span_code). This restores the declared graph contract — neo4j/schema.py already declares the property and index — without touching analysis.json, so no schema or version bump is needed.

Tests: new regression test_projected_code_property_is_the_module_source_span_slice walks every projected class/callable in the sample app and asserts code equals the exact span slice of module.source. Full suite green: 178 passed, 5 skipped.

Schema v2 removed the per-node code field (module source is stored once,
sliced by spans), but the Neo4j projection still read it via
getattr(..., 'code', None) — so every :PyClass and :PyCallable node was
written without code, deadening the py_code_fts fulltext index and the
python-sdk's RETURN c.code queries.

Thread the owning module's source through the declaration walk and slice
it by each node's utf-8 byte span at projection time, restoring the
declared graph contract without touching analysis.json.
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.

Neo4j projection emits code: None on every :PyCallable / :PyClass node (schema 2.0.0)

1 participant