Repository navigation
Fix DreamMaker parent-relative #include paths (lstrip charset misuse) - #1978
Closed
Osamaali313 wants to merge 1 commit into
Closed
Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
`extract_dm` normalized include paths with `raw.lstrip("./")`. `str.lstrip`
treats its argument as a *set of characters*, not a prefix, so it strips
every leading `.` and `/` — destroying parent-relative includes:
"../shared/base.dm" -> "shared/base.dm"
"../../a.dm" -> "a.dm"
".hidden/x.dm" -> "hidden/x.dm"
`(path.parent / norm).resolve()` then points at the wrong directory,
`.exists()` returns False, and a correct internal `imports_from` edge to the
real included file becomes a bogus external `imports` edge to a phantom node,
silently losing the cross-file link.
The sibling local-include resolver in `extractors/bash.py` resolves
`(path.parent / raw)` from the raw path without stripping `..`, confirming
the intent. Strip only a literal leading `./` (re is already imported) so
`../` includes resolve correctly; the `./`-prefix and no-prefix cases are
unchanged.
safishamsi
added a commit
that referenced
this pull request
Jul 18, 2026
Member
|
Landed on v8 (ships in 0.9.19) in a038684, cherry-picked to preserve your authorship. Thanks @Osamaali313 — replaced the lstrip("./") character-set strip with a leading-./ prefix strip, so ../shared/base.dm and .hidden/x are no longer mangled. |
PerryLin-0420
pushed a commit
to PerryLin-0420/graphify-decouple
that referenced
this pull request
Aug 13, 2026
…raphify-Labs#1975/Graphify-Labs#1978/Graphify-Labs#1980 fixes Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Problem
extract_dmnormalizes DreamMaker#includepaths withstr.lstrip("./"):str.lstriptreats its argument as a set of characters, not a prefix. It's meant to drop a leading./, but it strips every leading.and/, which destroys parent-relative includes:lstrip("./")../shared/base.dmshared/base.dm❌../shared/base.dm../../a.dma.dm❌../../a.dm.hidden/x.dmhidden/x.dm❌.hidden/x.dm(path.parent / norm).resolve()then points at the wrong directory,.exists()returns False, and what should be an internalimports_fromedge to the real included file becomes a bogus externalimportsedge to a phantom node — silently losing the cross-file link in the knowledge graph.Evidence (sibling proves intent)
The local-include resolver in
extractors/bash.pydoes the same "resolve relative to the file's parent, emitimports_fromif it exists on disk, else externalimports" flow — but it resolves(path.parent / raw)from the raw path and never strips...dm.pyintends the identical resolution but corrupts the path first.Fix
Strip only a literal leading
./(reis already imported), preserving../:Reproduction
With a real
sub/child.dmincluding../shared/base.dm(andshared/base.dmon disk):imports(external), target = phantomshared/base.dm❌imports_from(internal), target = resolvedshared/base.dm✅The
./-prefix and no-prefix cases are unaffected.