Skip to content

Python Neo4j reconstruct drops three fields the graph already carries: node id, attribute initializer, call-site arguments #361

Description

@rahlk

Problem

Three fields the Python Neo4j projection already carries on the graph never reach the model, because no reconstruct function reads them. Each surfaces as an empty value that is indistinguishable from "the analyzer found nothing".

model field what the graph holds what the model gets
PyModule.id / PyClass.id / PyCallable.id the can:// id, on every node ""
PyAttribute.initializer :PyAttribute.initializer (e.g. 'default', 'name') None
PyCallsite.arguments :PyBodyNode.arguments_json []

The id one is the most visible: it is the node's canonical address, it is present on every projected node — the teardown in test_python_neo4j_backend.py matches on it — and the in-memory backend populates it. So the same model, describing the same code, carries its address in process and an empty string over Neo4j.

How it was found

These were uncovered while fixing #360. The write-gated parity module had been skipped through every leg, so nothing compared the two backends field by field. Each of the three is now asserted in both halves by that module — the graph property is asserted present, and the model field is asserted empty — so closing any of them breaks the test loudly rather than silently passing.

Scope boundary

In scope: read the three properties in cldk/analysis/python/neo4j/reconstruct.py and drop the corresponding tolerance in the parity module.

Out of scope: the tolerances in that module whose cause is a genuine projection loss — source, imports and body are not projected at all, and those are asserted empty on purpose.

Goals

  • id is populated on the reconstructed PyModule, PyClass and PyCallable, and equals the in-memory backend's id for the same node
  • PyAttribute.initializer is read from the node property
  • PyCallsite.arguments is read from arguments_json
  • The corresponding assertions in tests/analysis/python/test_python_neo4j_backend.py flip from "asserted empty" to exact parity, and the module docstring's tolerance list shrinks by three entries

Caveats and known risks

  • arguments_json is a JSON string on the node; decoding it must tolerate a malformed or absent value without failing the whole reconstruction, and must not silently swallow a decode error into [] — that would recreate the ambiguity this issue is about.
  • Check the TypeScript and Java projections for the same three gaps before assuming this is Python-only. The parity clause means a field recovered in one language should be recovered in all of them where the graph carries it.

Definition of done

  • The three fields round-trip through the Neo4j backend with the same values the in-process backend gives, asserted by the parity module rather than by inspection.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions