Skip to content

Network fabric (scale and corruption probes)

Source: examples/fabric/ — one of the domain examples that validated the language on real-world shapes (ROADMAP Phase 5).

fabric.decl
// Network-fabric schema: the third Phase 5 domain library, committable
// stand-in for the local-only proprietary sweep. A fictional spine-leaf
// datacenter fabric with the same structural stress points — recursive
// node containers keyed by maps, string type tags, open parameter bags,
// cross-references, scale — expressed as plain Decl types with no
// domain keywords.
export type Ident = /[a-z][a-z0-9_]*/
export type NodeKind = /fabric\.node\.[a-z0-9_.]+/
export type PortKind = /fabric\.port\.[a-z0-9_.]+/
export type Direction = "up" | "down"
export dimension Bandwidth = DataSize / Time
export unit bps: Bandwidth
export unit Gbps = 1e9 bps
export type PortParams = {
speed?: quantity<Bandwidth>
mtu?: 512..65535
vlan?: 1..4094
trunk?: bool
...
}
export type Port = {
kind?: PortKind
name: Ident
dir: Direction
params?: PortParams
// an ethernet port must state a positive line rate
assert eth_has_speed: (
($this["kind"] ?? "") != "fabric.port.eth"
|| (params?.speed ?? 0bps) > 0bps)
else error `ethernet port ${name} needs params.speed > 0`
}
export type Edge = {
kind: "fabric.edge.link"
name: Ident
endpoints: Ident[2]
}
export type Subnet = {
cidr: /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\/[0-9]+/
vlan: 1..4094
gateway?: Ident
}
export type Node = {
kind: NodeKind
name: Ident
params?: { ... }
ports?: map<Ident, Port> = { }
nodes?: map<Ident, Node> = { }
edges?: map<Ident, Edge> = { }
assert port_keys_match:
std.array.all(std.map.entries(ports), (en) => en.value.name == en.key)
else error `a port's name differs from its map key in ${name}`
assert node_keys_match:
std.array.all(std.map.entries(nodes), (en) => en.value.name == en.key)
else error `a child node's name differs from its map key in ${name}`
assert edge_keys_match:
std.array.all(std.map.entries(edges), (en) => en.value.name == en.key)
else error `an edge's name differs from its map key in ${name}`
// every edge endpoint names a sibling port or child node
assert edge_endpoints_exist:
std.array.all(std.map.values(edges), (e) =>
std.array.all(e.endpoints, (p) => p in ports || p in nodes))
else error `an edge of ${name} references a missing port or node`
}
export type SiteParams = {
subnets?: Subnet[] = []
uplink?: "" | Ident
oversubscription?: 1..64
...
}
export type Fabric = Node {
kind: "fabric.node.site"
params?: SiteParams
assert uplink_exists: (
(params?.uplink ?? "") == "" || (params?.uplink ?? "") in ports)
else error `the declared uplink is not a boundary port`
assert subnet_vlans_distinct:
std.array.all_distinct([s.vlan for s in (params?.subnets ?? [])])
else error `two subnets share a vlan`
}

What decl evaluate fabric.decl prints, one section per output.

© 2026 Luuvish. Decl is open source under the MIT License.

Type: Literata and IBM Plex, under the SIL Open Font License. Built with Astro Starlight.