Skip to content

fix(scanner): forward-slash file-graph keys on every OS; .exe test binary on Windows (#214 A-C) - #218

Merged
JordanCoin merged 2 commits into
mainfrom
fix/214-windows-paths
Oct 11, 2026
Merged

JordanCoin merged 2 commits into
mainfrom
fix/214-windows-paths

Conversation

@JordanCoin

Copy link
Copy Markdown
Owner

Groups A, B and C of #214 (88 of the 124 Windows failures). D to G are not touched.

Root cause (B and C, one bug)

On Windows the walker and ast-grep emit native paths, filepath.Clean/Join/Dir rebuild every probe with \, and imports are written with /. The index key and the probe never agreed, so every file reported no importers on Windows. Group B is the same bug seen from the output side: tests expect /, the graph emitted \.

Fix: one spelling for graph keys

scanner.keyPath = filepath.ToSlash(filepath.Clean(p)), applied:

where what
paths enter walker.go FileInfo.Path, astgrep.go FileAnalysis.Path
keys stored fileIndex (byExact, byDir, bySuffix), FileGraph.Imports/Importers at the resolver-loop write, applyPrecomputedFileEdges (Cargo fallback), Swift type-reference edges
probes looked up new fileIndex.exact() and fileIndex.dir() replace every direct byExact[...]/byDir[...] read in filegraph.go, rustgraph.go, rustbuildscript.go, jsworkspace.go; suffixMatches, tryExactMatch (also returns the key, not the probe), suffix helpers compare against /
module separators normalizeImport emits / for Python dots and Rust :: instead of filepath.Separator
MCP normalizeImporterFile returns the same slash key (test renamed from ...UsesNativeGraphKeys to ...UsesSlashGraphKeys)

Resolvers keep filepath for filesystem access; Windows accepts / in paths.

Group A: TestMain appends .exe on Windows (one line, 34 tests).

Verification

  • macOS: go build ./... && go test ./... && gofmt -l . clean (go vet ./scanner/ ./mcp/ . too).
  • Cross-compile: GOOS=windows go build ./... ok; GOOS=windows go test -c ./scanner/ -o /dev/null, same for . and ./mcp/: ok.
  • New test TestIndexMatchesNativeProbeAgainstSlashKeys (scanner/filegraph_test.go): slash-form keys, filepath.FromSlash probes for exact, dir and suffix lookups; passes on both OSes, would have failed on Windows before.
  • TestNormalizeImport / TestDepsNormalizeImport expectations changed from filepath.Join(...) to / literals (identical on Unix).

Windows counts

Before (run 38169675758): A 34, B 23, C 31.
After: not measured by CI on this PR. main at the time of this PR has the Windows build cell but not the Windows test cell; that arrives with #209. Once #209 merges and this branch picks it up, the informational Windows job will report the remaining list. Expected residue in these groups: tests that build Rust/JS internal maps from filepath.Clean paths and compare them to each other are unaffected (consistent on both sides); anything that compares those internal native paths against graph keys would still miss and belongs to the D-G follow-up.

Not changed: watch/events.go graph lookups by native relPath (group G), cmd/hooks.go importer lookups by filepath.Rel output (group G), the dead nativePath branch in tryDirMatch (harmless now).

Refs #214

🤖 Generated with Claude Code

https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T

…inary gets .exe on Windows

Group C of #214 was a product bug: on Windows the walker and ast-grep
emitted native paths, filepath.Clean/Join/Dir rebuilt probes with "\",
and every import written with "/" missed the index, so every file
reported no importers. One spelling now, scanner.keyPath (Clean then
ToSlash), applied where paths enter (walker FileInfo.Path, ast-grep
FileAnalysis.Path), where keys are stored (fileIndex, FileGraph.Imports
and Importers, precomputed Cargo and Swift edges) and where probes are
looked up (fileIndex.exact, fileIndex.dir, suffixMatches, tryExactMatch,
normalizeImport). Resolvers keep using filepath for filesystem access.

Group B followed: tests expect "/" and the graph now emits "/", so the
Rust fallback and Cargo assertions hold on Windows. The MCP
normalizeImporterFile returns the same slash key.

Group A: TestMain builds codemap_test_binary.exe on Windows so the 34
end-to-end CLI tests can exec it.

Refs #214

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T
Copilot AI balanced review requested due to automatic review settings October 11, 2026 20:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@JordanCoin
JordanCoin merged commit 0a324a7 into main Oct 11, 2026
12 of 13 checks passed
JordanCoin added a commit that referenced this pull request Oct 11, 2026
…bes, cargo edges as slash keys; tests spell keys with slashes (#219)

* fix(scanner): workspace roots, gitignore probes and cargo edges use slash keys; tests spell keys with slashes

Residue of #214 after #218. Graph keys are forward-slashed on every OS,
but the JS and Dart workspace resolvers still derived package roots with
filepath.Dir and compared them to keys with the native separator, so on
Windows pathContains was false for every member file and workspace
imports resolved to nothing. Nested .gitignore matching handed
go-gitignore a native relative path, which never matched a slash
pattern, so ignored files were scanned and visible ones dropped. The
cargo-metadata fallback emitted native edges that no slash key matched.

cleanRepoPath, the CUE and Go fallback file keys, nested-repo paths and
cargo edges now go through keyPath; pathContains splits on "/".

Test side: 123 filepath.Join calls whose arguments were all string
literals were graph keys written the long way; they are slash literals
now. Fixture creation that joins a temp root is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T

* fix(scanner): Rust module paths, Go fallback repos and workspace expectations as slash keys; skip the residue outside the resolvers by name

The Rust resolver kept every repo-relative path in native form through
filepath.Clean/Join/Dir and compared it to slash graph keys, so on
Windows crate-rooted, super:: and literal-path modules resolved to
nothing. Repo-relative paths now go through keyPath and path.Join; only
calls that touch the disk keep filepath. Same for the Go fallback's
nested-repo check.

Test side: filepath.FromSlash wrappers on expectations in scanner tests
were spelling graph keys in native form; removed. The literal rewrite
from the previous commit is reverted outside scanner, where native
paths are the right expectation (config path, topology repo path,
git exclude path).

Twenty-four tests outside the resolvers now skip on Windows with the
cause named and "tracked in #214", so the residue is explicit in the
informational cell instead of a wall of red.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NRaBgKRAZMX9hjbkkefA7T

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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