Skip to content

fix: prevent machine-specific Dart absolute paths from leaking into child node IDs - #999

Merged
safishamsi merged 1 commit into
Graphify-Labs:v8from
Overman775:fix/dart-absolute-node-ids
May 26, 2026
Merged

safishamsi merged 1 commit into
Graphify-Labs:v8from
Overman775:fix/dart-absolute-node-ids

Conversation

@Overman775

@Overman775 Overman775 commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

extract_dart was building class and function node IDs from str(path) — the absolute local filesystem path — instead of _file_stem(path), which is the convention used by every other extractor.

As a result, the same Dart symbol got a different node ID on every machine:

# Developer A
users_alice_projects_myapp_lib_auth_user_service_UserService

# Developer B — same file, different ID
users_bob_desktop_myapp_lib_auth_user_service_UserService

The id_remap post-processor (introduced in #502) remaps file node IDs to project-root-relative paths, but does not touch compound child node IDs — so class and function nodes permanently retained the absolute path of whoever ran graphify last.

This broke three things for any team sharing graphify-out/ in version control:

  • Duplicate nodes — every developer appends new orphaned nodes on incremental update instead of overwriting the existing ones.
  • Broken edges — cross-file import and call edges point to non-existent IDs on other machines.
  • AI context degradation — ghost nodes and dead edges cause incorrect code suggestions and hallucinated imports.

⚠️ Migration note

This is a breaking ID change for existing Dart graphs. Old absolute-path-derived node IDs will become orphans on the next incremental run. Rebuild from scratch after updating:

graphify . --force

@safishamsi safishamsi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct fix — Dart was the only remaining extractor embedding absolute paths in child node IDs, and switching to _file_stem matches every other extractor's convention. Two small cleanup items:

  1. Test assertion: assert 'tmp' not in nid is a fragile negative check that would pass trivially on most CIs and miss a regression that swaps in a different non-portable identifier. Better to assert the positive expected value: assert nid == _make_id('sample', 'MyClass') (or equivalent based on the fixture).

  2. Scope wording: the PR title says "all affected extractors" but Dart was the only one — every other extractor already uses _file_stem. Worth correcting the description so reviewers don't think there are other files touched.

  3. Migration note: this is a format-breaking change for anyone with existing Dart entries in graphify-out/ — old absolute-path IDs become orphans on next run. A one-line note in the PR body ("existing Dart graphs should be rebuilt with --force") would help users hit by this.

Otherwise solid — ready to merge after those tweaks.

@Overman775
Overman775 force-pushed the fix/dart-absolute-node-ids branch 2 times, most recently from 1b172bd to 7b42df3 Compare May 25, 2026 10:13
… IDs to prevent machine-specific absolute paths in graph.json
@Overman775
Overman775 force-pushed the fix/dart-absolute-node-ids branch from 7b42df3 to 7f11d2d Compare May 25, 2026 10:17
@Overman775

Copy link
Copy Markdown
Contributor Author

Correct fix — Dart was the only remaining extractor embedding absolute paths in child node IDs, and switching to _file_stem matches every other extractor's convention. Two small cleanup items:

  1. Test assertion: assert 'tmp' not in nid is a fragile negative check that would pass trivially on most CIs and miss a regression that swaps in a different non-portable identifier. Better to assert the positive expected value: assert nid == _make_id('sample', 'MyClass') (or equivalent based on the fixture).
  2. Scope wording: the PR title says "all affected extractors" but Dart was the only one — every other extractor already uses _file_stem. Worth correcting the description so reviewers don't think there are other files touched.
  3. Migration note: this is a format-breaking change for anyone with existing Dart entries in graphify-out/ — old absolute-path IDs become orphans on next run. A one-line note in the PR body ("existing Dart graphs should be rebuilt with --force") would help users hit by this.

Otherwise solid — ready to merge after those tweaks.

Hey Sami, thanks for the feedback!

I've updated the PR and squashed everything into one clean commit:

  • Replaced the negative check in tests with a proper positive assertion using _make_id and _file_stem. Shortened the docstring too.
  • Scoped the PR title/description strictly to Dart.
  • Added a quick note in the description about rebuilding with --force.

Let me know if it looks good to merge now!

@Overman775 Overman775 changed the title fix: prevent machine-specific absolute paths from leaking into child node IDs fix: prevent machine-specific Dart absolute paths from leaking into child node IDs May 25, 2026
@Overman775

Copy link
Copy Markdown
Contributor Author

@safishamsi all done, please recheck )

@safishamsi
safishamsi merged commit baaab5f into Graphify-Labs:v8 May 26, 2026
PerryLin-0420 pushed a commit to PerryLin-0420/graphify-decouple that referenced this pull request Aug 13, 2026
… IDs to prevent machine-specific absolute paths in graph.json (Graphify-Labs#999)
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.

2 participants