Skip to content

JS/TS graph build resolves internal imports to missing nodes and overwrites parallel directed edges #2849

Open

Description

@Neonsy

Summary

A fresh directed Graphify build of NeonFlux extracted 21,703 edge records but exported 17,993 edges

A dangling endpoint is an edge whose source or target ID has no matching extracted node

A same-endpoint collision occurs when multiple edge records share the same ordered source and target while the graph representation stores only one

The missing relationships affect imports, workspace packages, generated declarations, re-exports, source evidence, queries, path searches, and reports

Environment

Item Value
Repository NeonTechSpace/NeonFlux
Audit snapshot Local working tree based on 341d66b
Graphify 0.9.46
Platform Windows
Project TypeScript and JavaScript pnpm monorepo
Mode Directed build from the repository root
Corpus 876 code files, 30 documents, 3 images

The classification was verified against the source files, package exports, TypeScript resolution candidates, tsconfig.paths, generated declarations, re-export chains, node-ID construction, and collision remapping

Verified results

Stage Cause Lost edge records Unique endpoints
Dangling External dependency references 1,270 147
Dangling Workspace packages resolve to ignored dist 1,529 540
Dangling .js fails to resolve .tsx or .d.ts 218 87
Dangling Convex generated declarations or members 72 3
Dangling Member or re-export origin is unresolved 105 39
Dangling tsconfig.paths target is excluded 3 3
Dangling Generated-route ID is not remapped 2 2
Dangling Resource-query import is unresolved 1 1
Collision Exact duplicate record 23 n/a
Collision Additional relationship type 354 n/a
Collision Same relationship with different evidence 133 n/a
Total 3,710

1. Workspace exports select ignored dist output

Observed behavior

bot-app.ts imports @neonflux/db

The package exposes source through types and development, while runtime conditions point to build output in package.json

Graphify selects the runtime target when the ignored dist file exists

The target was excluded from the corpus, so Graphify creates edges to missing IDs such as:

projects_packages_db_dist_index

Package breakdown

Package Edge records
@neonflux/db 551
@neonflux/blueprint 356
@neonflux/fluxer 179
@neonflux/core 98
@neonflux/messaging 95
@neonflux/config 92
@neonflux/reaction-roles 72
@neonflux/convex 37
@neonflux/captcha 36
@neonflux/member-access 13
Minimal reproduction
{
  "name": "@acme/lib",
  "exports": {
    ".": {
      "types": "./src/index.ts",
      "development": "./src/index.ts",
      "import": "./dist/index.js"
    }
  }
}
**/dist/
import { value } from "@acme/lib"

Required behavior

Workspace imports must resolve to nodes included in the scanned source corpus

A local target excluded from the corpus must not become a normal internal edge to a missing node

Suggested implementation

  • Collect every eligible export-condition target
  • Prefer candidates included in the scanned corpus
  • Prioritize source, development, and source-bearing types during source analysis
  • Represent excluded local targets explicitly or suppress their edges

2. .js specifiers do not resolve TypeScript source

Observed behavior

dashboard-audit-event-row.tsx imports ./dashboard-ui.js

The source is dashboard-ui.tsx

Graphify tries .js → .ts but not .js → .tsx or .js → .d.ts

The generic extension search can instead test incorrect paths such as:

dashboard-ui.js.tsx
Minimal reproduction
// consumer.ts
import { Button } from "./button.js"
// button.tsx
export function Button() {
  return null
}

Required behavior

A JavaScript specifier in TypeScript source must resolve to the corresponding supported TypeScript source or declaration file

Suggested implementation

Replace .js with each candidate instead of appending extensions:

foo.js
├── foo.ts
├── foo.tsx
├── foo.mts
├── foo.cts
└── foo.d.ts

Add equivalent replacement handling for .jsx

3. Companion .d.ts declarations are not combined with .js

Observed behavior

access_permissions.ts imports runtime values and types from _generated/server.js

The declaration file defines QueryCtx and MutationCtx

blueprint_artifact_persistence.ts imports dataModel.js, while the generated module is declaration-only

Minimal reproduction
// generated/server.js
export const mutation = mutationGeneric
// generated/server.d.ts
export declare const mutation: MutationBuilder
export type MutationCtx = GenericMutationCtx<Model>
// consumer.ts
import { mutation, type MutationCtx } from "./generated/server.js"

Required behavior

Runtime and declaration files representing the same module must provide one resolvable export surface

Declaration-only members must resolve for import type

Suggested implementation

  • Associate .js modules with companion .d.ts files
  • Resolve members against both runtime and declaration symbols
  • Prefer declaration symbols for import type
  • Resolve directly to .d.ts when the requested .js file is absent

4. Re-exported members do not resolve to their declaration origin

Observed behavior

dashboard-blueprint-diff.ts aliases and re-exports workspace symbols

runtime_contract_model.ts re-exports BLUEPRINT_RUN_PROTOCOL_VERSION

Graphify creates the imported member beneath the barrel module instead of tracing its declaration

Minimal reproduction
// origin.ts
export const value = 1
// barrel.ts
import { value } from "./origin.js"

export { value }
// consumer.ts
import { value } from "./barrel.js"

Graphify targets:

barrel_value

The declaration belongs to:

origin_value

Required behavior

An imported member must resolve to its declaration origin through local exports, aliases, barrels, and workspace exports

Suggested implementation

  • Extend resolve_exported_origin() to follow exports of imported bindings
  • Preserve aliases through export { original as alias } from ...
  • Continue through workspace exports after workspace source resolution
  • Detect cycles using (file, exported_name)

5. Smaller resolver failures

Excluded tsconfig.paths targets

Observed behavior

The collections/* alias in tsconfig.json resolves into hidden .source files excluded from the corpus

Required behavior

A resolved but excluded local target must not become a dangling internal ID

Suggested implementation

Represent excluded local targets explicitly or suppress their edges

Resource-query import

Observed behavior

__root.tsx imports:

../styles.css?url

Required behavior

The resource path must resolve independently of its bundler query

Suggested implementation

Strip the query or hash before filesystem lookup and retain it as edge context

Collision-remapped route nodes

Observed behavior

routeTree.gen.ts targets unsalted IDs while collision handling salted the extracted Route nodes

Required behavior

Every edge endpoint must use the final collision-remapped node ID

Suggested implementation

Apply collision remapping to every target_file-guided symbol endpoint

6. Parallel directed edge records are overwritten

Observed behavior

The affected records span 489 ordered endpoint pairs

Among those records:

  • 353 pairs contain multiple relationship names
  • 128 same-relation groups contain different source locations
  • 12 same-relation groups contain different contexts

bot-feature-router.ts imports and re-exports from bot-feature-types.js

Extraction creates imports_from, imports, and re_exports records for the same ordered endpoints

ephemeral-convex.ts imports values and types from the same module at different locations

build_from_json() constructs nx.DiGraph, so repeated G.add_edge(source, target, **attributes) calls overwrite the record stored for that ordered pair

The exact duplicates appear to come from extractor or resolver duplication where one named import emits the same member edge twice

Minimal reproduction
{
  "nodes": [
    {
      "id": "a"
    },
    {
      "id": "b"
    }
  ],
  "edges": [
    {
      "source": "a",
      "target": "b",
      "relation": "imports_from",
      "source_location": "L1"
    },
    {
      "source": "a",
      "target": "b",
      "relation": "re_exports",
      "source_location": "L2"
    },
    {
      "source": "a",
      "target": "b",
      "relation": "imports_from",
      "source_location": "L3"
    }
  ]
}

Expected:

a → b  imports_from  L1
a → b  re_exports    L2
a → b  imports_from  L3

Current result:

One edge whose attributes depend on overwrite policy

Required behavior

Every non-identical edge record must survive graph construction, export, querying, and reporting

Exact duplicates may be deduplicated if their occurrence count remains available

Suggested implementation

  • Use nx.MultiDiGraph as the authoritative directed representation
  • Give each edge a deterministic key based on relation, source file, source location, context, confidence, and occurrence index
  • Deduplicate byte-identical records before insertion with optional occurrence_count
  • Create a separate simple projection only for algorithms requiring one edge per pair

7. External references trigger the corruption warning

Observed behavior

External package references are counted as dangling because their endpoint nodes are not materialized

The diagnostic presents these references together with unresolved project-internal targets

Required behavior

External references must be distinguished from missing internal targets and must not independently trigger a graph-corruption warning

Suggested implementation

Report separate categories for:

External references
Resolved but excluded local targets
Unresolved internal targets
Missing endpoint fields
Exact duplicate edges
Distinct parallel edges
Self-loops

Related issues

Issue Overlap
#2791 Simple graph construction drops parallel edge records
#2391 Relationship types overwrite each other on the same node pair
#2191 External dependencies are counted as dangling corruption
#2130 JavaScript imports reference missing ref_* nodes
#2265 AST edges target node IDs the extractor never creates
#2443 Named exports produce dangling targets
#2604 External imports and internal JavaScript or TypeScript targets produce dangling endpoints

The linked issues cover parts of the result but not the complete combination reproduced in NeonFlux

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