Blast Radius, Explain & Rollout Waves
As a fleet grows, two practical questions come up before every rollout:
- “Why did
webreceive this firewall rule or service?” - “Which hosts depend on
pg, and in what parallel order should CI deploy them?”
Yen answers both directly from your terminal using .#yen inspection attributes and named queries under yen.queries.
1. Model host dependencies once
Section titled “1. Model host dependencies once”{ yen, std, types, ...}:{ imports = [ std.modules.all ];
# Declare startup / deployment dependencies between hosts. yen.kinds.host.fields.after = types.opt (types.listOf yen.kinds.host) [ ];
yen.host.pg.addr = "198.51.100.10"; yen.host.redis.addr = "198.51.100.11";
yen.host.api = { addr = "198.51.100.20"; after = [ yen.host.pg yen.host.redis ]; };
yen.host.web = { addr = "198.51.100.30"; after = [ yen.host.api ]; };
yen.aspects.web-edge = { at = yen.host.web; firewall.tcp = [ 80 443 ]; };}2. Add reusable queries (yen.queries)
Section titled “2. Add reusable queries (yen.queries)”Use yen.lib.graphs.waves to group hosts into parallel deployment waves (pg and redis first, then api, then web) and yen.lib.graphs.cycles to catch circular dependencies:
{ yen, ... }:let b = builtins;in{ # Stored query runnable via: nix eval --json .#yen.ask.deployWaves --apply 'f: f {}' yen.queries.deployWaves.answer = { result }: (edges: yen.lib.graphs.waves (yen.lib.graphs.fromEdges edges)) ( b.concatMap ( name: map (dep: { from = name; to = dep.name; }) result.data.host.${name}.after ) (b.attrNames result.data.host) );
# Check for circular host dependencies before CI ever runs. yen.queries.dependencyCycles.answer = { result }: yen.lib.graphs.cycles ( yen.lib.graphs.fromEdges ( b.concatMap ( name: map (dep: { from = name; to = dep.name; }) result.data.host.${name}.after ) (b.attrNames result.data.host) ) );}Run your stored queries from the terminal or CI (pipe deployWaves straight into colmena, deploy-rs, or a GitHub Actions matrix):
nix eval --json .#yen.ask.deployWaves --apply 'f: f {}'nix eval --json .#yen.ask.dependencyCycles --apply 'f: f {}'{ dependencyCycles = [ ]; deployWaves = [ [ "pg" "redis" ] [ "api" ] [ "web" ] ];}Built-in inspection commands on every yen.mkFlake
Section titled “Built-in inspection commands on every yen.mkFlake”| Command | What question it answers |
|---|---|
nix eval .#yen.ok |
Did every type check, sink merge, and fleet invariant pass? |
nix eval --json .#yen.errors |
List all structured errors with file paths, error codes, and typo suggestions |
nix eval --json .#yen.check.violations |
List every failed whole-fleet invariant and the offending host |
nix eval --json .#yen.active |
List every active aspect on every host and user |
nix eval --json .#yen.explain --apply 'f: f "web-edge" "host:web"' |
Prove why a specific aspect activated (or did not activate) on a host |
nix eval --json .#yen.impact |
Reverse-reference blast radius: which hosts depend on a given host or aspect |
nix eval --json .#yen.declaredIn |
Which .nix file declared every field, host, and aspect |
nix eval --json .#yen.inventory |
Export the full fleet inventory as JSON with types.secret fields redacted |
Graph helpers available under yen.lib.graphs: fromEdges, nodesOf, reverseGraph, reachFrom, cycles, topo, sccs, and waves.
Next, learn how to split reusable module libraries from personal host data in Reusable Libraries vs Personal Fleets.