Skip to content

fix(affected): resolve absolute-path seed via graph-derived root (#2706) - #2750

Closed
ousamabenyounes wants to merge 1 commit into
Graphify-Labs:v8from
ousamabenyounes:fix/affected-absolute-seed-graph-root
Closed

ousamabenyounes wants to merge 1 commit into
Graphify-Labs:v8from
ousamabenyounes:fix/affected-absolute-seed-graph-root

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Fixes #2706.

affected resolved an absolute-path seed only when the working directory happened to be the analysed repo root: resolve_seed anchored an absolute path to Path.cwd(), so from anywhere else relative_to(cwd) raised and the query was compared verbatim — matching no stored (repo-relative) source_file. The result was an empty blast radius with exit 0, indistinguishable from a genuine zero or a typo. An absolute path is exactly what an editor integration or a script passes, and neither can guarantee cwd is the repo root.

This is the follow-up the maintainer noted when the ./-relative case shipped in #2707:

an absolute-path seed still requires the working directory to be the analysed repo root — a follow-up could derive the root from the graph location.

The change

  • Derive the analysed repo root from the graph's own location — the graph is written to <root>/graphify-out/graph.json, so the root is the output dir's parent (GRAPHIFY_OUT_NAME); a graph pointed at directly by --graph falls back to its own directory.
  • Thread an optional root through _as_repo_relative → resolve_seed → format_affected, and anchor an absolute seed to it. root defaults to the current directory, so every existing caller and the label/non-path branches are unchanged. An absolute path outside the derived root is still left verbatim — no basename guessing.

Scope is the affected seed path only; explain/shortest_path and the shared scoring helper are untouched.

Test verification (RED → GREEN)

New test test_affected_absolute_seed_resolves_via_graph_root_off_cwd runs the CLI end-to-end with the graph under <root>/graphify-out/graph.json, cwd set to a different directory, and an absolute seed.

RED — new test on the branch with only the two production files reverted to v8:

FAILED tests/test_affected_cli.py::test_affected_absolute_seed_resolves_via_graph_root_off_cwd
E   AssertionError: assert 'Affected nodes for Foo' in 'No unique node match for /tmp/.../repo/pkg/foo.py\n'
1 failed

GREEN — full affected suite with the fix:

tests/test_affected_cli.py ......... 17 passed

Full local suite

uv run --frozen pytest tests/ -q — 4465 passed, 3 failed, 7 skipped. The 4465 is the pre-fix 4464 plus the new test; the 3 failures are the pre-existing tests/test_ollama.py::test_detect_backend_* cases (local ollama env), identical before and after this change. ruff and the tools.skillgen guards (--check, --audit-coverage, --schema-singleton, --monolith-roundtrip, --always-on-roundtrip) are green.

…phify-Labs#2706)

`affected` anchored an absolute-path seed to the current working directory,
so it only resolved when cwd happened to be the analysed repo root — the case
no editor or script integration can guarantee. `resolve_seed` then matched
nothing and printed an empty blast radius with exit 0, indistinguishable from
a genuine zero or a typo.

Derive the repo root from the graph's own location
(<root>/graphify-out/graph.json) and anchor the seed there instead of cwd,
completing the ./-relative seed fix shipped in Graphify-Labs#2707. A non-path query, or an
absolute path outside the derived root, is unchanged; the root argument
defaults to cwd so every other caller keeps its behaviour.

@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. 1 change(s) tested, no difference found (not proven).


Graphify review — findings

This PR adds an optional root parameter to the affected command's seed-resolution path (_as_repo_relative, resolve_seed, and format_affected) so that absolute-path seeds are anchored to a repo root rather than the current working directory. In the CLI's dispatch_command, it derives this root from the loaded graph's own file location (the parent of the graphify-out output directory, or the graph's directory when pointed at directly). It also adds a test verifying an absolute-path seed resolves when the command is run from outside the repo root, and appends a corresponding CHANGELOG entry. The remaining changed symbols are CHANGELOG version entries and pre-existing test/helper functions in the touched files.

Worth a look

  • graph_root derivation wrong when --graph points to a symlink or non-standard path parent — graphify/cli.py:1119 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review Execution auto-disposal is off for this run; enable it (with sandbox isolation) to have Graphify try to confirm or refute this automatically.
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 454 functions depend on the 276 functions this change touches.

Health — grade A; 5 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • dispatch_command() — 2 callers, 117 callees (high)
  • resolve_seed() — 11 callers, 4 callees (high)
  • _stale_graph_sources() — 7 callers, 6 callees (high)
  • _run_hook_guard() — 3 callers, 6 callees (medium)
  • test_poisoned_manifest_is_healed() — 0 callers, 6 callees (medium)

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

Formal verification

Could not verify: Could not verify \_as\_repo\_relative.

The verifier did not have enough to check \_as\_repo\_relative, 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 | None` — outside the synthesizable primitive/collection set

No difference found (not proven): No behavior difference found in format\_affected (not a proof).

The verifier ran both versions of format\_affected on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

Could not verify: Could not verify resolve\_seed.

The verifier did not have enough to check resolve\_seed, 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 | None` — outside the synthesizable primitive/collection set

Could not verify: Could not verify dispatch\_command.

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

@safishamsi

Copy link
Copy Markdown
Member

Landed in v0.9.44, just published to PyPI. I cherry-picked this onto v8 with your authorship preserved in the commit, so both the change and the credit are in the history. Thanks @ousamabenyounes for the fix. Closing since it is now released.

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.

affected silently returns nothing when the path is spelled differently (./ or absolute)

2 participants