Skip to content

neo4j: add TS-prefixed twin node labels (dual-label, graph schema 1.1.0) #65

Description

@rahlk

PROBLEM

The Neo4j projection emits only bare node labels (Application, Module, Class, Interface, Enum, TypeAlias, Namespace, Callable, External, AnonymousCallable, Package, Decorator, CallSite, Attribute, Variable; marker Entrypoint), which a shared multi-language database cannot attribute to TypeScript. This issue adds a TS-prefixed twin label to every node, additively, so downstream queries can namespace by language without breaking any existing consumer.

SCOPE BOUNDARY

Node labels only. Relationship types stay unprefixed (CALLS, HAS_MODULE, …) — their rename is breaking and lands with the v2/CanNode contract (stage 2). Merge labels (Symbol, Module, Package, Decorator, CallSite, Attribute, Variable, Application), uniqueness constraints, keys, and analysis.json are untouched. No in-place migration of existing databases.

GOALS

  1. Every NodeLabel in src/build/neo4j/schema.ts declares its TS-prefixed twin (e.g. Callable + TSCallable), and the marker set gains TSEntrypoint alongside Entrypoint; the declarative schema remains the single source of truth.
  2. Both writers (cypher.ts snapshot and bolt.ts incremental) stamp both labels on every node; MERGE still targets the unchanged merge label + key.
  3. SCHEMA_VERSION1.1.0 (additive MINOR per the schema's own rule).
  4. Conformance test (test/neo4j-schema.test.ts) covers the twin labels; schema.neo4j.json and the README help block regenerated.

CAVEATS AND KNOWN RISKS

  • Dual labels double the label count per node; Neo4j handles multi-labels natively, but any consumer doing labels(n)[0] or exact-set label comparisons will see the new twin — additive, yet worth a release-note line.
  • The old branch patch/ts-prefix-neo4j-schema is NOT a starting point: it rewrote catalog.ts, which the refactor(neo4j): consolidate the graph schema into one source of truth (closes #15) #16 consolidation deleted. Re-author against schema.ts; use the branch only as a checklist of touch points.
  • Bolt writer batches: ensure the twin label is applied in the same MERGE/SET statement so a crash mid-load never leaves half-labeled nodes.

DEFINITION OF DONE

  • On the fixture app, for every declared label L: MATCH (n:L) and MATCH (n:TSL) return identical counts; total relationship count is byte-identical to the pre-change graph.
  • Conformance test green; :Application carries schema_version = "1.1.0".
  • schema.neo4j.json regenerated and committed; bun run gen:readme clean.

Delivers #8 additively (merge label deliberately stays shared — see the epic's design decisions).

Part of #64

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