Repository navigation
Description
Pre-flight checks
- I have checked the Troubleshooting section in the README
What happened?
Graphify gives distinct nested Python classes the same node ID when they have the same name in one file but different enclosing classes. It emits one class node with multiple contains parents, losing the other definition and conflating relationships to it.
In xai-org/x-algorithm, phoenix/xrex/cutedsl/ranker_fa4/tile_scheduler.py defines five different nested Params classes. A focused extraction produced one ...tile_scheduler_params node, sourced to the first definition, with contains edges from multiple enclosing scheduler classes. A consumer that requires one lexical parent per symbol cannot process this graph; a consumer that accepts it may attribute definitions and references to the wrong class.
The likely cause is that the class ID is built from the file stem, namespace stack, and class name, but omits the enclosing class identity. The contains edge does use the enclosing class identity. The same ID construction remains in the v0.9.80 source; I reproduced the behavior at runtime on 0.9.77, not 0.9.80.
Steps to reproduce
from pathlib import Path
from tempfile import TemporaryDirectory
from graphify.extract import extract
with TemporaryDirectory() as tmp:
root = Path(tmp)
source = root / "scheduler.py"
source.write_text(
"class Forward:\n"
" class Params:\n"
" pass\n"
"\n"
"class Backward:\n"
" class Params:\n"
" pass\n"
)
result = extract([source], root=root, cache_root=root / "cache", parallel=False)
print([(n["id"], n.get("source_location"))
for n in result["nodes"] if n.get("label") == "Params"])
print([(e["source"], e["target"])
for e in result["edges"]
if e.get("relation") == "contains" and e.get("target") == "scheduler_params"])Error output or graph output
Actual output:
[('scheduler_params', 'L2')]
[('scheduler_forward', 'scheduler_params'),
('scheduler_backward', 'scheduler_params')]
Expected: two distinct `Params` nodes, each with its own source location and exactly one enclosing class. References to either nested class should resolve to the corresponding node.
Graphify version
0.9.77
Operating System
macOS
Python Version
3.13.7
Installation Method
uv tool install (recommended)
Additional Environment Details
No response
Additional context
No response
Activity
github-actions commentedon Oct 8, 2026
Thanks for opening this issue, @john-ramsey. 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.
safishamsi commentedon Oct 10, 2026
Already fixed on v8 by #4228 (nested class identities are qualified by their enclosing class). Closing as resolved.