fix(neo4j): derive the code property from module source spans - #105
Merged
Conversation
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.
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 #104.
Schema v2 removed the per-node
codefield (module source is stored once onPyModule.source, sliced by spans), but the Neo4j projection still read the old field viagetattr(..., "code", None)— so every:PyClass/:PyCallablenode was written withoutcode. That deadened thepy_code_ftsfulltext index and the python-sdk Neo4j backend'sRETURN c.codequeries, breaking local ↔ Neo4j backend parity.Fix: thread the owning module's
sourcethrough the declaration walk (_project_module_body→_project_class/_project_callable) and derivecodeat 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.pyalready declares the property and index — without touchinganalysis.json, so no schema or version bump is needed.Tests: new regression
test_projected_code_property_is_the_module_source_span_slicewalks every projected class/callable in the sample app and assertscodeequals the exact span slice ofmodule.source. Full suite green: 178 passed, 5 skipped.