Repository navigation
Conversation
Member
|
Landed on v8 (ships in 0.9.19) in d56b70a, cherry-picked to preserve your authorship. Thanks @alphanury for the fix and @Greg-Moskalenko for the report — a same-basename cross-extension re-export (foo.ts re-exporting ./foo.mjs) no longer manufactures a phantom self-cycle; the re-export edge target is salted by the resolved sibling file, no absolute path leaks, node ids unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1814.
Summary
A same-basename cross-extension re-export — a typed
.tswrapper re-exporting a hand-written.mjsruntime,export { N } from "./foo.mjs"— produced a phantom self-cycle:foo.ts → foo.ts, reported as a 1-file import cycle inGRAPH_REPORT.md.Root cause
foo.tsandfoo.mjscollapse onto one base file id (the id stem drops the extension)._disambiguate_colliding_node_idscorrectly salts the two file nodes apart (foo_ts_foo/foo_mjs_foo), but the re-export edge keyed its target salt by the importer's ownsource_file. So the./foo.mjstarget was salted back ontofoo.ts— asource == targetself-loop. The residual was purely at the edge layer; node ids were already correct.Fix
When an import/re-export edge is emitted, the emitter now stamps the resolved target file on the edge as a transient
target_filehint. During disambiguation, animports/imports_from/re_exportsedge keys its target salt by that file instead of the importer's, so the salt lands on the real sibling node and the phantom cycle disappears. This generalizes the C/ObjC.h-sibling carve-out from #1475 to every language and tore_exports.The hint has no downstream reader and holds an absolute path, so it must never persist into
graph.json:poped the moment disambiguation consumes it (both the colliding and the no-collision early-exit paths);target_fileas a backstop, so an incrementalbuild_mergethat re-serializes base edges without re-running disambiguation can't leak one either.graph.jsonstays deterministic and byte-identical across checkout locations. Node ids are unchanged, so no forced rebuild. (The extension-aware-id alternative was rejected: it would rewrite every file and symbol id and force a full-rebuild migration in lockstep with the skill/validation id spec, #1033.)One caveat, called out in the CHANGELOG: a graph written by a pre-fix build still records the stale self-loop, and because
graphify updateonly re-extracts changed files, an unchanged wrapper keeps that edge until it is next edited or a--forcefull rebuild runs.Testing
New
tests/test_cross_extension_reexport_self_cycle.py(10 cases): the reported.ts/.mjsrepro, static + dynamic +requireimport forms, star and namespace re-exports, the no-collision path (target salt untouched), and a serializer check that notarget_filesurvives into the persisted graph.tests/test_ollama_retry_cap.py) are pre-existing and unrelated — they fail identically on a cleanv8checkout (an ollama SDK module missing from the test env).