Skip to content

refactor(neo4j): consolidate the graph schema into one source of truth (closes #15)#16

Open
rahlk wants to merge 1 commit into
mainfrom
refactor/issue-15-consolidate-neo4j-schema
Open

refactor(neo4j): consolidate the graph schema into one source of truth (closes #15)#16
rahlk wants to merge 1 commit into
mainfrom
refactor/issue-15-consolidate-neo4j-schema

Conversation

@rahlk

@rahlk rahlk commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

The Neo4j graph contract was split across catalog.ts (node labels, relationship types + endpoints, marker labels, schema version) and schema.ts (the Cypher CONSTRAINTS/INDEXES DDL), and the constraint list hand-duplicated the (mergeLabel, key) pairs already declared in NODE_LABELS — a second place to update whenever a label was added. This consolidates the entire schema into one source-of-truth module mirroring src/schema/schema.ts: the DDL is folded in and the separate schema.ts deleted, catalog.ts is renamed to schema.ts, the uniqueness CONSTRAINTS are now derived from NODE_LABELS (one per distinct (mergeLabel, key), so a new label brings its own constraint with no second list to maintain), the curated INDEXES stay co-located, and MARKER_LABELS is exported from the barrel so consumers stop deep-importing. Behavior-preserving — same 8 constraints + 3 indexes; the only delta is cosmetic constraint naming/ordering (derived names like symbol_signature, bind variable x), and since Neo4j's IF NOT EXISTS matches on schema+type, existing databases are unaffected. Verified by typecheck, the schema-conformance suite (11 pass/5 skip/0 fail), a schema.neo4j.json regen, and a neo4j-emit smoke (graph.cypher still renders 8 constraints + 3 indexes). Git shows the move as catalog.ts deleted + schema.ts rewritten because the thin old schema.ts already occupied that path. Follow-up, out of scope: make project.ts emission schema-driven so label tuples/property names aren't restated in code. Closes #15.

closes #15)

The graph contract was split across catalog.ts (labels, relationships, marker
labels, version) and schema.ts (the CONSTRAINTS/INDEXES DDL), and the constraint
list hand-duplicated the (mergeLabel, key) pairs already in NODE_LABELS — a
second place to update whenever a label was added.

- Fold the DDL into the schema module and delete the separate schema.ts;
  rename catalog.ts -> schema.ts to mirror src/schema/schema.ts (the IR schema).
- Derive CONSTRAINTS from NODE_LABELS (one per distinct mergeLabel/key), so a new
  label brings its own uniqueness constraint with no second list to maintain.
- Keep the curated INDEXES list co-located; export MARKER_LABELS from the barrel
  so consumers stop deep-importing.

Behavior-preserving: same 8 constraints + 3 indexes. The only delta is cosmetic
constraint naming/ordering (derived names like symbol_signature, bind variable x);
Neo4j's IF NOT EXISTS matches on schema+type, so existing databases are unaffected.
Guarded by the schema-conformance test; schema.neo4j.json regenerated.

Follow-up (out of scope): make project.ts emission schema-driven so label tuples
and property names aren't restated in code.
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.

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

1 participant