File, layer, and slice dependency policies
ArchUnitZig
Architecture testing for Zig. ArchUnitZig turns source dependencies into lazy, owned rule values. Its preview includes file boundaries, layers, slices, PlantUML, metrics, graph reports, native test helpers, and explicit memory ownership.
Zig package
zig fetch --save-exact=archunit https://github.com/LukasNiessen/ArchUnitZig/archive/refs/tags/v0.0.2.tar.gzconst std = @import("std");
const archunit = @import("archunit");
test "production files have no cycles" {
var files = try archunit.files(std.testing.allocator, .{});
defer files.deinit();
var scope = try files.inPath(&.{.{ .glob = "src/**/*.zig" }});
defer scope.deinit();
var should = try scope.should();
defer should.deinit();
var rule = try should.haveNoCycles();
defer rule.deinit(std.testing.allocator);
try archunit.expectPasses(&rule, .init(.init(std.testing.allocator, std.testing.io)));
}The ecosystem
Zig, in context.
Zig is a compiled systems language with explicit memory management, straightforward cross-compilation, and close interoperability with C. Its build system and allocator model keep resource ownership visible, so ArchUnitZig follows the same principle in both analysis and rule lifecycles.
Explicit allocators and predictable native binaries
Cross-compilation, systems tooling, and C interoperability
Architecture checks compiled as native Zig tests
Adoption snapshot
Public adoption, in context.
ArchUnitZig is installed from its versioned GitHub release. Zig has no central package registry that reports a comparable download total.
- Package status
- Versioned GitHub release No ecosystem download counter
- Reported history
- Unavailable Not reported by the ecosystem
- Latest 30 days
- Unavailable Not reported by the ecosystem
- GitHub stars
- 2 Snapshot of October 4, 2026
Capabilities
What ArchUnitZig brings to the test suite.
The family shares a recognizable architecture vocabulary while each implementation stays honest about its language, toolchain, and maturity.
Explicit allocator and ownership model
Zig-native metrics
PlantUML diagrams and graph reports
Structured errors and native test helpers
Versioned, immutable installation archive
Go deeper
Make ownership explicit, including in tests.
Rule values own their analysis data and expose clear cleanup points. The architecture test remains honest about allocation while still expressing a recognizable dependency policy.
test "api does not import storage" {
var files = try archunit.files(std.testing.allocator, .{});
defer files.deinit();
var api = try files.inPath(&.{.{ .glob = "src/api/**" }});
defer api.deinit();
try archunit.expectNoDependency(&api, "src/storage/**");
}Documentation highlights
Work with ArchUnitZig beyond the quickstart.
ArchUnitZig uses Zig 0.16 ASTs and explicit compilation-unit information to model imports without executing build.zig. Ownership and allocation stay visible in the public API.
Classify more than Zig source imports
Literal @import, @embedFile, @cImport, and @cInclude references retain target class, availability, import kind, and source location.
- Relative Zig and ZON files can remain project-owned, while std, builtin, and unresolved aliases stay external and visible.
- CompilationUnitOverride maps named imports and root for each library, executable, or test without pretending to understand arbitrary build scripts.
- Strict parsing rejects malformed source; permissive parsing returns diagnostics without partial edges from that file.
Model packages and workspaces honestly
Single packages, explicit workspace lists, and discovered build.zig.zon packages use qualified identifiers so equal paths in different packages cannot collapse.
- Workspace and package .archignore files apply at their documented scope and participate in graph cache identity.
- Symlink, cache, output, VCS, documentation, and dependency trees are not followed during discovery.
- Every extraction option that changes the graph is included in the cache key.
Evaluate and report with owned data
File, layer, slice, metric, and graph modules return owned violations or artifacts with explicit error context.
- Architecture disagreements are values; invalid selectors are user errors; parsing, I/O, and allocation failures are technical errors.
- assertAllPass combines heterogeneous rules without losing the rule sentence behind each finding.
- The v0.0.2 release is a preview pinned to Zig 0.16 rather than a stable compatibility promise.
Release and compatibility
0.0.2 preview
The v0.0.2 preview targets exactly Zig 0.16.0 and documents ownership and compatibility explicitly.
Where it fits
Put boundaries next to the code they protect.
Common starting points for ArchUnitZig include the following project shapes.
More ecosystems
The same intent, expressed natively.
Explore sibling implementations and carry the architecture vocabulary across a polyglot system.
Make the first boundary executable.
Add one meaningful rule, run it with the existing tests, and grow the architecture suite as the system reveals where it needs protection.
Start with ArchUnitZig ↗