Skip to content

fix(importers): Canonicalize absolute importer paths - #161

Merged
JordanCoin merged 3 commits into
JordanCoin:mainfrom
reneleonhardt:fix/importers-absolute-root
Sep 1, 2026
Merged

JordanCoin merged 3 commits into
JordanCoin:mainfrom
reneleonhardt:fix/importers-absolute-root

Conversation

@reneleonhardt

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes absolute --importers queries use the same canonical project and file roots:

  • Infers the nearest Git project for an absolute importer launched outside the project.
  • Canonicalizes the importer in both explicit-root and inferred-root paths.
  • Preserves explicit project-root precedence.
  • Adds end-to-end coverage for canonicalized reports and root precedence.

Why it matters

On macOS, /tmp and /private/tmp can name the same file. Mismatched spellings produced incorrect relative paths and empty importer results.

CLI / MCP surface

No new commands, arguments, or MCP tools. Existing --importers queries now work consistently with absolute paths.

Verification

  • codemap . and codemap --deps .

The repository linter reports no new findings for this branch beyond its existing baseline.

Co-Authored-By: GPT-5.6 Sol codex@openai.com

reneleonhardt and others added 3 commits August 29, 2026 16:12
Infer the nearest Git repository for absolute importer queries launched outside the project while preserving explicit-root precedence.

Co-Authored-By: GPT-5.6 Sol <codex@openai.com>
The resolved project root is canonicalized (macOS /tmp -> /private/tmp), so an
absolute importer file left in its original spelling produced a broken relative
path in the report. Canonicalize the importer whenever it is absolute, in both
the explicit-root and inferred-root paths, and cover it with an end-to-end
report test plus a corrected 'explicit roots win' assertion.

Co-Authored-By: Whale integration <whale@local>
@JordanCoin
JordanCoin merged commit d65a0f7 into JordanCoin:main Sep 1, 2026
12 checks passed

Copy link
Copy Markdown
Owner

Verified and merged. Canonicalization holds up under the attacks that matter: cross-repo symlink aliasing, nested repo-in-repo, a submodule, and a linked worktree (.git as a file) all resolve to the file's true identity — I couldn't get it to map one file onto another's identity. Dangling symlinks and no-git-ancestor paths fail closed with bounded errors rather than a confident empty answer. Relative-path --importers output is byte-identical to main across a dozen real files, and the new tests are load-bearing (reverting the fix fails three of the four). Clean merge, suite at baseline.

One adjacent gap worth a follow-up, pre-existing and not from this PR (confirmed byte-identical on main, so nothing here regressed): in buildImportersReportFromGraph the filepath.Rel(root, file) result isn't checked for staying inside root. With an explicit root and an absolute --importers path outside it, Rel happily walks up and the tool prints No files import ../../home/user/... with exit 0 instead of erroring — a confident empty answer in exactly the shape this project treats as the cardinal sin. Guarding on strings.HasPrefix(rel, "..") || filepath.IsAbs(rel) would close it; happy to look at that separately whenever you want it picked up.


Generated by Claude Code

@reneleonhardt
reneleonhardt deleted the fix/importers-absolute-root branch September 1, 2026 15:44
@JordanCoin JordanCoin mentioned this pull request Sep 1, 2026
3 of 8 tasks
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