Skip to content

Imports project only to :PyPackage spelling nodes — internal module→module import edges are structurally impossible (CLDK-003) #82

Description

@rahlk

Target: canonical schema v2 (epic #69) — import topology is contract surface, so the shape lands there. From the external v0.3.0/Odoo quality audit, finding CLDK-003 (severity High).

Audit evidence (Odoo, native export)

  • All 14,167 PY_IMPORTS edges target :PyPackage string nodes (926 of them); zero edges target a :PyModule.
  • Odoo imports its own code constantly (from odoo import models, relative addon imports) — none of it is connected at module granularity, so no cross-module reachability can be traversed through imports.

Root cause

Module→module import edges are structurally impossible in the current pipeline; this is not an Odoo quirk:

  1. The IR records only the import spelling: PyImport (codeanalyzer/schema/py_schema.py:173) has module, name, alias, positions — no resolved file. Relative imports are stored as "."*level + module (symbol_table_builder.py:165-182), so from .foo import bar yields the spelling ".foo".
  2. The projection maps every spelling to a shared :PyPackage node keyed on the raw string (codeanalyzer/neo4j/project.py:126-150, _project_imports) and never consults the analyzed module set (the file_keys it just emitted as :PyModule nodes). Relative spellings become packages named ".foo".

Fix direction (v2)

Resolve import spellings against the project's own module table (absolute imports via the project root / package layout, relative imports via the importer's path) and emit module→module edges for internal hits; keep package nodes only for genuinely external targets. Per the audit's acceptance gate: every statically resolvable internal import has exactly one module target, and the raw spelling plus an unresolved-reason stay available on the edge for the rest.

Sibling note: the TypeScript analyzer has the mirror defect for non-relative (tsconfig baseUrl) specifiers — filed separately on codellm-devkit/codeanalyzer-typescript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions