Skip to content

Make path handling work on Windows - #2380

Closed
lovrentertainment-droid wants to merge 3 commits into
Graphify-Labs:v8from
lovrentertainment-droid:windows-path-portability
Closed

lovrentertainment-droid wants to merge 3 commits into
Graphify-Labs:v8from
lovrentertainment-droid:windows-path-portability

Conversation

@lovrentertainment-droid

Copy link
Copy Markdown

What

A Windows portability pass. A large share of the suite fails on Windows because of host-separator and path-grammar assumptions; these commits fix the causes rather than the symptoms.

Three commits, each independently reviewable:

1. Make path handling work on Windows — the code change.

  • Absolute-path detection under both grammars: a POSIX-absolute string is not absolute to PureWindowsPath and vice versa, so paths that could never resolve inside the project root were being retained (build.py, cli.py).
  • source_file persisted via as_posix() so stored node ids stay portable instead of carrying the host separator (extract.py, llm.py).
  • Filesystem writes routed through extended-length paths (and the UNC form for shares) so long paths stop failing against MAX_PATH in deep checkouts (cache.py).
  • The shell allowlist escaping had lost a backslash level and rejected legitimate Windows paths (hooks.py).
  • Symlink-dependent tests skip when Windows denies the privilege (winerror 1314) instead of being reported as failures (tests/conftest.py).

2. test(js): key source_file lookups on as_posix(), not str() — test_alias_import_does_not_remap_an_owned_symbol_id keyed its lookups with str(Path), which yields backslashes on Windows and raised KeyError: 'src\lib\utils.ts'. The test encoded exactly the behaviour commit 1 deliberately replaces.

3. test(cache): give the prune rewrites a different byte length — worth a maintainer's attention; details below.

The prune fix is worth a look

Two test_semantic_prune_* tests rewrote a fixture from "# A\n\nContent A.\n" to "# B\n\nContent B.\n" — both exactly 16 bytes. file_hash has a stat fastpath keyed on (size, mtime_ns), so when both writes land in the same mtime tick it skips the re-read and returns the stale digest. The two saves then collapse onto a single cache entry, the exists() assertions pass trivially against that one file, and prune_semantic_cache correctly reports 0 orphans — because none was ever created.

It presents as a prune bug, and it moves between the two tests depending on machine load. Forcing an identical mtime with os.utime reproduces it every time on the old contents and never on the new:

contents sizes stale-digest collision
old 16 vs 16 yes
new 16 vs 27 no

Prune itself is correct; only the fixtures were unsound.

Related, and deliberately not changed here: the same fastpath means a real edit preserving byte length within one mtime tick will serve a stale cache entry in production too. That is the documented size+mtime tradeoff, so I have left the design alone and am flagging it rather than changing it.

Test results

CPython 3.13.14 on Windows 11.

failed passed
before (0b2bd93) 48 3728
after 16 3744

All 16 remaining failures are pre-existing — every one is present at 0b2bd93 before these commits, verified by diffing the two failure sets. None is introduced here. They appear to be further Windows-specific issues (test_watch.py, test_install*.py, test_obsidian_filename_cap.py, test_ollama_retry_cap.py) and are out of scope for this PR.

I do not have a Linux or macOS machine to hand, so CI verification on those platforms would be worth having. The as_posix() change in extract.py is the one most worth a second pair of eyes, since it changes the persisted form of source_file.

lovrentertainment-droid and others added 3 commits August 1, 2026 16:57
Windows portability pass across path construction, comparison, and
filesystem writes.

- Detect absolute paths under both path grammars. A POSIX-absolute string
  is not absolute to PureWindowsPath and vice versa, so paths that could
  not resolve inside the project root were being kept.
- Persist source_file via as_posix() so stored ids stay portable instead
  of carrying the host separator.
- Route filesystem writes through an extended-length \?\ path, and
  \?\UNC\ for shares, so long paths stop failing.
- Fix the shell allowlist escaping, which lost a backslash level and so
  rejected legitimate Windows paths.
- Skip symlink-dependent tests when Windows denies the privilege
  (winerror 1314) rather than reporting them as failures.

The two commits that follow update tests that encoded the old
host-separator behaviour.

Co-Authored-By: Claude Opus 5 <[email protected]>
extract() now persists source_file posix-normalized, so str(Path) yielded
backslashes on Windows and the symbol lookup raised KeyError on
'src\lib\utils.ts'. Key the four lookups in
test_alias_import_does_not_remap_an_owned_symbol_id on as_posix() to match
what the extractor writes. The test encoded the OS-separator behaviour the
path fix deliberately replaced.

Co-Authored-By: Claude Opus 5 <[email protected]>
test_semantic_prune_removes_orphan_entries and
test_semantic_prune_sweeps_both_namespaces_against_same_live_set rewrote
doc.md from "# A\n\nContent A.\n" to "# B\n\nContent B.\n" -- same 16 bytes.
file_hash has a stat fastpath keyed on (size, mtime_ns), so when both writes
land in the same mtime tick it skips the re-read and returns the stale digest.
h_a == h_b, both saves collapse onto a single entry, the two exists() asserts
pass trivially against that one file, and prune correctly reports 0 orphans.

The failure looked like a prune bug and moved between the two tests run to
run, since which one loses the race depends on machine load. Forcing an
identical mtime with os.utime reproduces it every time on the old contents
and never on the new ones.

Prune itself is correct; only the fixtures were unsound.

Co-Authored-By: Claude Opus 5 <[email protected]>

@graphify-labs graphify-labs Bot 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.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).


Graphify review — findings

This PR appears to revert or roll back several recently added changes. It removes the changelog entries for versions 0.9.30, 0.9.31, and 0.9.32 (unreleased), and updates the README to remove references to app.graphify.com early access, drop Bedrock backend mentions from environment variable docs, and remove the GRAPHIFY_MAX_CONTEXTS entry. The truncated diff and the list of changed symbols indicate accompanying modifications across source modules (caching, extraction, detection, LLM backend, serving) and their corresponding test files, touching areas like path normalization, Kotlin/C++/C# extraction, noise-directory detection, and backend selection. The surface area spans documentation, core graphify modules, and a broad set of tests.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 4469 functions depend on the 2748 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: _find_node() — 13 callers, 3 callees

Verification — 4469 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 4446 function(s) in the blast radius were not formally verified this run

· 1 more finding(s) on lines outside this diff (see the check run).

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.

1 participant