Skip to content

refactor(neo4j): consolidate the graph schema into a single source of truth #15

Description

@rahlk

The Neo4j graph schema is split across two files — catalog.ts (node labels, relationship types + endpoints, marker labels, schema version) and schema.ts (the Cypher CONSTRAINTS/INDEXES DDL) — and the constraint list hand-duplicates the (mergeLabel, key) pairs already declared in NODE_LABELS, so adding a node label means also remembering to add its uniqueness constraint in a second file (exactly the kind of drift the conformance test exists to catch). Consolidate the entire graph contract into one source-of-truth module, mirroring how src/schema/schema.ts holds the IR schema: fold the DDL in, derive the uniqueness CONSTRAINTS from NODE_LABELS (one per distinct (mergeLabel, key)) so labels drive their own constraints, keep the curated INDEXES list co-located, and route consumers through the neo4j/index.ts barrel instead of deep-importing. Behavior-preserving and guarded by the existing schema-conformance test plus a schema.neo4j.json regen; the only contract delta is cosmetic constraint naming/ordering (Neo4j's IF NOT EXISTS matches on schema+type, so existing DBs are unaffected). Making project.ts's emission itself schema-driven (so label tuples/props aren't restated in code) is a larger follow-up, out of scope here.

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