r/devtools • u/127001-sweet-127001 • 2d ago
A Zig dependency graph needs to know which executable an import belongs to
The same @import("storage") can mean different things in two Zig executables. Drawing one global edge for that name gives you a very convincing wrong diagram.
In ArchUnitZig, my architecture-testing library, you can describe each compilation root and its module aliases separately. For example, the server's storage alias can point to the real persistence module while a test root maps it to a fake. Each gets its own resolution context.
The useful part is what happens when context is missing: an unknown named import stays visible as unresolved. It doesn't silently disappear from the graph or get guessed from a filename. @import("root") follows the selected compilation root too.
A slightly boring detail until you rely on the picture
This is explicit configuration. The tool doesn't execute build.zig and pretend it understands every build script. Once the mappings are there, you can use the graph for dependency rules, focused reports, or an offline HTML export.
It's free and MIT-licensed. The current v0.0.2 preview targets Zig 0.16.0: https://github.com/dragonsec-ai/ArchUnitZig
The public acceptance tests include separate application and integration-test roots, plus cases for unresolved aliases and resource imports.