Skip to content

Normalize relative source_file to POSIX separators - #2764

Open
ayushcodes10 wants to merge 2 commits into
Graphify-Labs:v8from
ayushcodes10:fix-2625-mixed-path-separators
Open

ayushcodes10 wants to merge 2 commits into
Graphify-Labs:v8from
ayushcodes10:fix-2625-mixed-path-separators

Conversation

@ayushcodes10

Copy link
Copy Markdown
Contributor

extract()'s canonicalization pass only ran source_file through
as_posix() on the absolute-input branch. A relative-input source_file
-- from the documented extract(paths) entry point with no root, or
python -m graphify.extract ... -- was left exactly as the
extractor's plain str(path) produced it, which renders with a native
backslash separator on Windows. That diverges from the POSIX form the
explicit-root and CLI paths already produce, fragmenting the
string-equality lookups keyed on source_file (build._norm_source_file,
analyze.find_import_cycles, the semantic-cache key) into two spellings
of one file.

Normalize the relative branch too: replace any backslash in the raw
source_file string. No id-remap needed there, since ids are minted
independently of this field.

A real WindowsPath can't be constructed on this (POSIX) dev machine, so
the added regression test monkeypatches one extension's dispatch to
return a node/edge with a literal backslash-separated source_file --
exactly the shape str(WindowsPath(...)) produces on Windows -- and
asserts extract()'s post-pass normalizes it. This exercises the actual
fixed code path directly rather than depending on OS-native path
rendering.

Fixes #2625.

@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.

Graphify reviewed this change.

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

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

This PR modifies the canonicalization pass in extract() so that relative source_file values containing backslashes are rewritten to use forward slashes. Previously, only the absolute-path branch applied POSIX normalization, so relative-path callers (e.g. extract(paths) with no root) could retain native Windows separators. It also adds a test that monkeypatches an extractor to emit backslash-separated source_file strings on both a node and an edge, then asserts they are normalized to POSIX form after extraction.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 1655 functions depend on the 546 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 455 callers, 41 callees
  • new: _rebuild_code() — 95 callers, 51 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: dispatch_command() — 2 callers, 117 callees
  • new: extract_js() — 76 callers, 3 callees
  • new: _get_extractor() — 26 callers, 6 callees
  • new: run_pipeline() — 8 callers, 13 callees
  • new: collect_files() — 17 callers, 6 callees
  • …and 22 more

Verification — 1655 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: 1515 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify extract.

The verifier did not have enough to check extract, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `cache_root` is annotated `Path | None` — outside the synthesizable primitive/collection set

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

extract()'s canonicalization pass only ran source_file through
as_posix() on the absolute input branch. A relative input source_file
(from the documented extract(paths) entry point with no root, or
python m graphify.extract <file>...) was left exactly as the
extractor's plain str(path) produced it, which renders with a native
backslash separator on Windows. That diverges from the POSIX form the
explicit root and CLI paths already produce, fragmenting the string
equality lookups keyed on source_file (build._norm_source_file,
analyze.find_import_cycles, the semantic cache key) into two
spellings of one file.

Normalize the relative branch too: replace any backslash in the raw
source_file string. No id remap needed there, since ids are minted
independently of this field.

Fixes Graphify-Labs#2625.
@ayushcodes10
ayushcodes10 force-pushed the fix-2625-mixed-path-separators branch from 840a4b7 to 1bd4f06 Compare September 5, 2026 23:39

@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.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Normalizes backslash-bearing source_file strings to POSIX separators in extract's canonicalization pass for the no-root case (the extract(paths) entry point and python -m graphify.extract <file>...), so relative inputs no longer keep the native Windows \ spelling that only the explicit-root branch previously ran through as_posix(). This keeps source_file consistent across every code path and prevents string-equality lookups keyed on it (build._norm_source_file, analyze.find_import_cycles, the semantic cache key) from splitting one file into two spellings. Adds a test that monkeypatches an extractor to emit backslash-separated source_file values and asserts they're normalized, exercising the fix without needing a real Windows runner.

Worth a look

  • Backslash normalization only applied to nodes, not edge source_file — graphify/extract.py:7448 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2066 functions depend on the 632 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract() — 545 callers, 43 callees
  • new: _rebuild_code() — 115 callers, 51 callees
  • new: extract_js() — 85 callers, 4 callees
  • new: extract_xaml() — 19 callers, 17 callees
  • new: dispatch_command() — 2 callers, 124 callees
  • new: _get_extractor() — 26 callers, 6 callees
  • new: run_pipeline() — 8 callers, 13 callees
  • new: collect_files() — 17 callers, 6 callees
  • …and 27 more — each is listed as a finding

Verification — 2066 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: 1901 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify extract.

The verifier did not have enough to check extract, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `cache_root` is annotated `Path | None` — outside the synthesizable primitive/collection set

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

@ayushcodes10

Copy link
Copy Markdown
Contributor Author

@safishamsi rebased onto the latest v8 and all checks are green now — ready for review whenever you get a chance.

@ayushcodes10

Copy link
Copy Markdown
Contributor Author

Checked this finding: the fix already applies to both. for item in all_nodes + all_edges: (extract.py:7430) is a single unified loop, and the backslash normalization inside it runs against item["source_file"] regardless of whether item is a node or an edge dict. test_relative_input_source_file_is_normalized_to_posix already asserts on both node["source_file"] and edge["source_file"] and passes. Looks like a false positive.

Resolves a conflict in test_extract.py: this branch's own regression
test for the POSIX normalization fix and an unrelated incremental
extraction test upstream added after this branch diverged both land
at the same spot in the file. Neither shares any state with the
other, so both are kept.

graphify/extract.py itself auto merged without a conflict.
@github-actions github-actions Bot added the needs:title PR title should follow the conventional-commit format label Oct 10, 2026
@github-actions

Copy link
Copy Markdown

Thanks @ayushcodes10! One small thing: our changelog and release notes are built from PR titles, so we use the conventional-commits format, for example:

fix(python): resolve a bare stdlib import correctly

Prefixes we use: feat, fix, docs, chore, refactor, test, perf, build, ci. Editing the PR title clears this automatically. This is just a nudge and does not block review.

@ayushcodes10
ayushcodes10 force-pushed the fix-2625-mixed-path-separators branch from 2a42392 to d20700a Compare October 16, 2026 13:20

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:title PR title should follow the conventional-commit format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A single extraction emits source_file with mixed path separators (src\lib\content.ts and src/pages/index.astro in the same output) on Windows

1 participant