affected and query --seed reject path::Symbol and dotted names that explain resolves; affected exits 0 when ambiguous
Pre-flight checks
- [x] I have checked the Troubleshooting section in the README. It covers installation; nothing there applies to name resolution.
- [x] I searched existing issues. #4698 (path lookup with a shared basename) and #2706 (path spelling) are related but closed, and both are about file paths rather than
path::Symbolor dotted symbol references.
What happened?
explain resolves a path-scoped reference (path::Symbol, #3485) or a dotted Python name (pkg.mod.func, #4366) to a single node. affected and query --seed do not accept either form. They answer No unique node match, even when explain resolves the same string to exactly one node.
The README advises "If several concepts have similar names, use the precise ID returned by the graph". Following that advice, a script or agent has to call explain first just to get the node id before it can scope affected.
Also, affected exits 0 when the name is ambiguous or unmatched. The README documents exit 3 for an ambiguous name and 4 for no matching node, and explain follows that, so scripts cannot branch on affected's outcome.
Steps to reproduce
Two functions named state in different modules, plus one caller:
mkdir -p repro/pkg/auth repro/pkg/other && cd repro && git init -q
printf 'def state():\n return 1\n' > pkg/auth/mfa.py
printf 'def state():\n return 2\n' > pkg/other/flow.py
printf 'from pkg.auth.mfa import state\n\ndef use():\n return state()\n' > pkg/user.py
touch pkg/__init__.py pkg/auth/__init__.py pkg/other/__init__.py
git add . && git commit -qm repro
graphify update .
G=graphify-out/graph.json
graphify explain "pkg/auth/mfa.py::state" --graph $G # Node: state() ID: pkg_auth_mfa_state
graphify affected "pkg/auth/mfa.py::state" --depth 1 --graph $G # No unique node match ... (exit 0)
graphify affected "pkg.auth.mfa.state" --depth 1 --graph $G # No unique node match ... (exit 0)
graphify affected "state" --depth 1 --graph $G # No unique node match ... (exit 0, no candidates)
graphify query "who uses state" --seed "pkg/auth/mfa.py::state" --graph $G # No unique node match for --seed: ...
graphify affected "pkg_auth_mfa_state" --depth 1 --graph $G # works: use() [calls] pkg/user.py:L4
Error output or graph output
$ graphify explain "pkg/auth/mfa.py::state" --graph graphify-out/graph.json
Node: state()
ID: pkg_auth_mfa_state
Source: pkg/auth/mfa.py L1
$ graphify affected "pkg/auth/mfa.py::state" --depth 1 --graph graphify-out/graph.json
No unique node match for pkg/auth/mfa.py::state
$ echo $?
0
$ graphify affected "pkg_auth_mfa_state" --depth 1 --graph graphify-out/graph.json
Affected nodes for state()
Depth: 1
- use() [calls] pkg/user.py:L4
- user.py [imports] pkg/user.py:L1
Expected
affectedandquery --seedaccept the same reference forms asexplain(path::Symboland dotted names). One way to do this is foraffected.resolve_seedto share the tiered matcherexplainuses (serve._find_node_tiers/find_node_ambiguity).- An ambiguous
affectedseed exits3and lists the candidates, asexplaindoes. No match exits4.
Graphify version
0.9.96 (latest; installed from PyPI into a clean venv). Also reproduced on 0.9.92.
Operating System
macOS 26 (arm64)
Python Version
3.13
Installation Method
pip (pip install graphifyy==0.9.96 in a fresh venv). 0.9.92 was installed via uv tool install graphifyy.
Additional context
We run affected from scripts and coding agents on a large Python monorepo, where generic names such as state, get and run are common. Path scoping is the documented way to avoid guessing. Today the only path that works for affected is a two-step explain → id → affected.
Thanks for opening this issue, @utkusafak. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
Wanted to say thanks for the write-up — the explain vs affected asymmetry was easy to reproduce from your steps.
I went ahead and sent #4797 for this: both halves, i.e. affected / query --seed accepting path::Symbol and dotted names, and the documented 3 / 4 exit codes.
Two things I found while working on it, in case they matter to you:
query --seedfalls out of the same fix, since it calls the sameresolve_seed. So the workaround you described (explain → id → affected) is no longer needed for either command.- On v8 a bare name shared by two files also exits 0 today, so the exit-code half is not limited to path-scoped seeds.
graphify affected "state"with your repro prints "No unique node match" and returns 0.
Implementation-wise I reused serve._find_node_tiers rather than writing a second matcher, so affected and explain cannot drift apart on what a reference means. I kept the bare-name tiers untouched, because an exact-name tie there should stay unresolved instead of being broken by graph-iteration order — that behaviour is covered by an existing test and still passes.
I also had to touch test_affected_absolute_seed_outside_root_misses_cleanly, which pinned the old exit 0 for an unmatched absolute seed. Its #2706 intent (never traverse from a wrong node) is unchanged; only the exit-code assertion moved. Flagging it since it is a deliberate behaviour change rather than an incidental edit.
If you would rather have this split into two PRs (resolution forms vs exit codes), happy to do that.