Skip to content

fix(tests): compare paths separator-agnostically so Windows assertions aren't vacuous - #2621

Closed
rajarshidattapy wants to merge 2 commits into
Graphify-Labs:v8from
rajarshidattapy:fix/windows-path-assertions-in-tests
Closed

rajarshidattapy wants to merge 2 commits into
Graphify-Labs:v8from
rajarshidattapy:fix/windows-path-assertions-in-tests

Conversation

@rajarshidattapy

Copy link
Copy Markdown
Contributor

Fixes #2620.

Problem

Several tests compare produced paths against string literals containing forward slashes. On
Windows the produced paths use \, so the assertions fail.

The failures are the visible half. The damaging half is silent: some of these tests put a
negative assertion first —

assert not any(path.endswith("src/main.py") for path in files)   # vacuous on Windows
assert any(path.endswith("src/app/main.py") for path in files)   # fails

— and a not any(...) against a literal that can never match passes unconditionally. In
test_path_pattern_single_star_does_not_cross_segment that first line is the subject of
the test (that * did not cross a separator). On Windows it proved nothing, and the test then
failed on the next line for an unrelated reason.

These are test defects — with two exceptions

I checked the underlying behaviour separator-agnostically before touching anything. The
gitignore precedence logic and _match_anchored_ignore_pattern are correct, as #2620 says.

Two of the six turned out to be product bugs rather than assertion bugs, so I fixed the
product and left those tests as written:

Changes

Test Change
test_gitignore_nested_negation_overrides_broader_root_rule compare via a new as_posix_list() helper
test_nested_ignore_overrides_git_info_exclude_and_root same
test_path_pattern_single_star_does_not_cross_segment same, and the negative assertion now actually runs
test_build_image_refs_sets_rel_media_and_bytes unchanged — llm.py fixed instead
test_queue_and_drain_pending_round_trip compare [Path(line) for line in lines] == paths; the documented contract is "one path per line", not a separator convention
test_cpp_preprocess_passes_absolute_path os.path.isabs(...) instead of startswith("/")

Verification: every repaired assertion was mutation-tested

A test-hygiene PR is worthless if the repaired tests merely pass — that is exactly the false
signal being fixed. Each one was re-run against a deliberately broken product:

Mutation Result
single-star * allowed to cross a path segment caught
nested-gitignore negation ignored (negation test) caught
nested-gitignore negation ignored (info/exclude precedence test) caught
_queue_pending writes every path on one line caught
_build_image_refs reverted to native separators caught
_cpp_preprocess passes a relative path caught

6/6 caught. Before this PR, four of the six could not fail on Windows at all.

One extra test, found by that exercise

test_cpp_preprocess_passes_absolute_path survived its mutation at first: it hands in an
already-absolute tmp_path / "weird.F90", so removing .resolve() changes nothing and the
test passes either way — vacuous on every platform, not just Windows. The original
startswith("/") had the same hole, so #2620's suggested one-line swap would have left it
vacuous. Added test_cpp_preprocess_absolutises_a_relative_attacker_named_file, exercising the
case the hardening exists for: a corpus file named -Ietc.F90 reached by a relative path.
That mutation is now caught.

Not in scope

tests/test_astro_import_ids.py::test_astro_relative_inputs_keep_canonical_ids looks like the
same class but is a genuine product defect — the astro/TS extractor really does write
src\lib\content.ts into source_file. Tracked separately, as #2620 notes.

graphify/extractors/fortran.py |  4 +++-
graphify/llm.py                | 16 ++++++++++----
tests/test_cpp_preprocess.py   | 49 +++++++++++++++++++++++++++++++++++++-----
tests/test_detect.py           | 35 ++++++++++++++++++++++++------
tests/test_watch.py            | 10 +++++----

@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

This pull request appears to revert a set of changes that were previously staged as "unreleased" (version 0.9.39). The changes: - Remove the _content_token_swap, _same_word_variant, _STOPWORDS, and related fuzzy-dedup logic from graphify/dedup.py, along with their call sites in deduplicate_entities and _llm_tiebreak, and drop the DamerauLevenshtein import. - Revert the JS dynamic-import rescue logic in graphify/extract.py back to keying on target alone rather than on the importing file's node, simplifying the associated docstring and comments. - Update the CHANGELOG to remove the 0.9.39 section and reset 0.9.38 back to "unreleased." The surface area touched spans dedup, extract, watch/LLM helpers, and a large number of associated tests referenced in the changed-symbols list.

Worth a look

  • Dynamic-import dedupe reverts to target-only key, dropping file-level dynamic_import edges for in-function imports — graphify/extract.py:1271 · Escalate · high
    • 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 — 3352 functions depend on the 2000 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: _build_image_refs() — 14 callers, 3 callees
  • worse: _read_files() — 6 callers, 6 callees

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

Formal verification

Could not verify: Could not verify \_llm\_tiebreak.

The verifier did not have enough to check \_llm\_tiebreak, 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: not verifiable: all 105 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify deduplicate\_entities.

The verifier did not have enough to check deduplicate\_entities, 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: not verifiable: all 7 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)

Could not verify: Could not verify \_rescue\_js\_dynamic\_imports.

The verifier did not have enough to check \_rescue\_js\_dynamic\_imports, 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 `path` is annotated `Path` — outside the synthesizable primitive/collection set

Could not verify: Could not verify \_resolve\_objc\_member\_calls.

The verifier did not have enough to check \_resolve\_objc\_member\_calls, 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: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous

Could not verify: Could not verify \_extract\_generic.

The verifier did not have enough to check \_extract\_generic, 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 `path` is annotated `Path` — outside the synthesizable primitive/collection set

Could not verify: Could not verify \_cpp\_preprocess.

The verifier did not have enough to check \_cpp\_preprocess, 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 `path` is annotated `Path` — outside the synthesizable primitive/collection set

Could not verify: Could not verify extract\_objc.

The verifier did not have enough to check extract\_objc, 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 `path` is annotated `Path` — outside the synthesizable primitive/collection set

Could not verify: Could not verify \_merge\_decl\_def\_classes.

The verifier did not have enough to check \_merge\_decl\_def\_classes, 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: not verifiable: the input domain has 49 values but only 7 distinct were tested — a small finite domain must be EXHAUSTED, not sampled (an untested input could invert the result)

Could not verify: Could not verify \_build\_image\_refs.

The verifier did not have enough to check \_build\_image\_refs, 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 `root` is annotated `Path` — outside the synthesizable primitive/collection set

Could not verify: Could not verify \_read\_files.

The verifier did not have enough to check \_read\_files, 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 `units` is annotated `'list[Path | FileSlice]'` — outside the synthesizable primitive/collection set

Could not verify: Could not verify watch.

The verifier did not have enough to check watch, 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 `watch_path` is annotated `Path` — outside the synthesizable primitive/collection set

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

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.42 (graphifyy==0.9.42 on PyPI) (#2620). Windows path-portability test fixes + POSIX source_file to the model. Credited in the release notes. Thanks @rajarshidattapy!

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.

Tests hardcode / in path assertions, so they fail on Windows — and some pass vacuously, hiding the assertion they were meant to make

2 participants