[roads] The road model, validator, compiler and explain; proto's versioned CBOR messages; the via command

Road files in Pensum's strict header subset (unknown keys are errors, random ids), the
directory and device snapshots, deny-by-default compilation to one plan per device,
explain from the compiler's own grants, CBOR envelope v1 with version-first refusals.

Tests: the six mandatory ones (validation fixtures for every rule, revocation, the
least-privilege property against an independent oracle, determinism with golden plans,
explain, custom round-trip), QA's attack cases, the protocol and the CLI.
This commit is contained in:
2026-11-25 07:55:38 +01:00
parent f134ec652c
commit 38a2fea043
119 changed files with 9123 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
{
"format": 1,
"devices": [
{ "key": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE", "name": "mark-pc", "owner": "mark", "address": "100.96.0.1" },
{ "key": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI", "name": "home-server", "owner": "mark", "address": "100.96.0.2", "exit": true, "relay": true,
"routes": ["192.168.100.0/24"],
"services": [
{ "host": "photos.home.arpa", "ports": ["tcp/443"] },
{ "host": "git.home.arpa", "ports": ["tcp/443", "tcp/22"] }
] },
{ "key": "AwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM", "name": "jana-phone", "owner": "jana", "address": "100.96.0.3" },
{ "key": "BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ", "name": "jana-laptop", "owner": "jana", "address": "100.96.0.4" },
{ "key": "BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU", "name": "router", "address": "100.96.0.5", "classic": true },
{ "key": "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY", "name": "friend-node", "owner": "petr", "address": "100.96.0.6", "exit": true },
{ "key": "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc", "name": "petr-phone", "owner": "petr", "address": "100.96.0.7" }
]
}
+12
View File
@@ -0,0 +1,12 @@
{
"format": 1,
"people": [
{ "id": "mark", "name": "Mark" },
{ "id": "jana", "name": "Jana" },
{ "id": "petr", "name": "Petr" },
{ "id": "eva", "name": "Eva" }
],
"groups": [
{ "id": "household", "name": "Household", "members": ["mark", "jana"] }
]
}
@@ -0,0 +1,51 @@
{
"format": 1,
"device": "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY",
"name": "friend-node",
"address": "100.96.0.6",
"classic": false,
"expires": null,
"peers": [
{
"key": "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc",
"name": "petr-phone",
"address": "100.96.0.7",
"classic": false,
"allowed_ips": [
"100.96.0.7/32"
],
"via": null,
"roads": [
"c0z5wn"
]
}
],
"firewall": {
"default": "deny",
"rules": [
{
"direction": "forward",
"src": "100.96.0.7/32",
"dst": "internet",
"proto": "any",
"ports": null,
"roads": [
"c0z5wn"
]
}
]
},
"dns": [],
"exit": null,
"kill_switch": null,
"direct": [
{
"app": "steam",
"subnet": "0.0.0.0/0",
"roads": [
"e5yj1s"
]
}
],
"custom": []
}
@@ -0,0 +1,186 @@
{
"format": 1,
"device": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"name": "home-server",
"address": "100.96.0.2",
"classic": false,
"expires": "2026-11-29T22:59:59Z",
"peers": [
{
"key": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE",
"name": "mark-pc",
"address": "100.96.0.1",
"classic": false,
"allowed_ips": [
"100.96.0.1/32"
],
"via": null,
"roads": [
"h2x8vd",
"k3f9q2",
"p4n6rb"
]
},
{
"key": "AwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM",
"name": "jana-phone",
"address": "100.96.0.3",
"classic": false,
"allowed_ips": [
"100.96.0.3/32"
],
"via": null,
"roads": [
"7tq0mz",
"k3f9q2"
]
},
{
"key": "BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ",
"name": "jana-laptop",
"address": "100.96.0.4",
"classic": false,
"allowed_ips": [
"100.96.0.4/32"
],
"via": null,
"roads": [
"7tq0mz",
"k3f9q2"
]
},
{
"key": "BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU",
"name": "router",
"address": "100.96.0.5",
"classic": true,
"allowed_ips": [
"100.96.0.5/32"
],
"via": null,
"roads": [
"r8m2tg"
]
}
],
"firewall": {
"default": "deny",
"rules": [
{
"direction": "in",
"src": "100.96.0.1/32",
"dst": "100.96.0.2/32",
"proto": "any",
"ports": null,
"roads": [
"k3f9q2"
]
},
{
"direction": "in",
"src": "100.96.0.3/32",
"dst": "100.96.0.2/32",
"proto": "any",
"ports": null,
"roads": [
"k3f9q2"
]
},
{
"direction": "in",
"src": "100.96.0.3/32",
"dst": "100.96.0.2/32",
"proto": "tcp",
"ports": [
443,
443
],
"roads": [
"7tq0mz"
]
},
{
"direction": "in",
"src": "100.96.0.4/32",
"dst": "100.96.0.2/32",
"proto": "any",
"ports": null,
"roads": [
"k3f9q2"
]
},
{
"direction": "in",
"src": "100.96.0.4/32",
"dst": "100.96.0.2/32",
"proto": "tcp",
"ports": [
443,
443
],
"roads": [
"7tq0mz"
]
},
{
"direction": "in",
"src": "100.96.0.5/32",
"dst": "100.96.0.2/32",
"proto": "tcp",
"ports": [
22,
22
],
"roads": [
"r8m2tg"
]
},
{
"direction": "in",
"src": "100.96.0.5/32",
"dst": "100.96.0.2/32",
"proto": "udp",
"ports": [
53,
53
],
"roads": [
"r8m2tg"
]
},
{
"direction": "forward",
"src": "100.96.0.1/32",
"dst": "192.168.100.0/24",
"proto": "any",
"ports": null,
"roads": [
"h2x8vd"
]
},
{
"direction": "forward",
"src": "100.96.0.1/32",
"dst": "internet",
"proto": "any",
"ports": null,
"roads": [
"p4n6rb"
]
}
]
},
"dns": [],
"exit": null,
"kill_switch": null,
"direct": [
{
"app": "steam",
"subnet": "0.0.0.0/0",
"roads": [
"e5yj1s"
]
}
],
"custom": []
}
@@ -0,0 +1,49 @@
{
"format": 1,
"device": "BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ",
"name": "jana-laptop",
"address": "100.96.0.4",
"classic": false,
"expires": "2026-11-29T22:59:59Z",
"peers": [
{
"key": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"name": "home-server",
"address": "100.96.0.2",
"classic": false,
"allowed_ips": [
"100.96.0.2/32"
],
"via": null,
"roads": [
"7tq0mz",
"k3f9q2"
]
}
],
"firewall": {
"default": "deny",
"rules": []
},
"dns": [
{
"host": "photos.home.arpa",
"address": "100.96.0.2",
"roads": [
"7tq0mz"
]
}
],
"exit": null,
"kill_switch": null,
"direct": [
{
"app": "steam",
"subnet": "0.0.0.0/0",
"roads": [
"e5yj1s"
]
}
],
"custom": []
}
@@ -0,0 +1,49 @@
{
"format": 1,
"device": "AwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM",
"name": "jana-phone",
"address": "100.96.0.3",
"classic": false,
"expires": "2026-11-29T22:59:59Z",
"peers": [
{
"key": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"name": "home-server",
"address": "100.96.0.2",
"classic": false,
"allowed_ips": [
"100.96.0.2/32"
],
"via": null,
"roads": [
"7tq0mz",
"k3f9q2"
]
}
],
"firewall": {
"default": "deny",
"rules": []
},
"dns": [
{
"host": "photos.home.arpa",
"address": "100.96.0.2",
"roads": [
"7tq0mz"
]
}
],
"exit": null,
"kill_switch": null,
"direct": [
{
"app": "steam",
"subnet": "0.0.0.0/0",
"roads": [
"e5yj1s"
]
}
],
"custom": []
}
+47
View File
@@ -0,0 +1,47 @@
{
"format": 1,
"device": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE",
"name": "mark-pc",
"address": "100.96.0.1",
"classic": false,
"expires": null,
"peers": [
{
"key": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"name": "home-server",
"address": "100.96.0.2",
"classic": false,
"allowed_ips": [
"0.0.0.0/0",
"100.96.0.2/32",
"192.168.100.0/24",
"::/0"
],
"via": null,
"roads": [
"h2x8vd",
"k3f9q2",
"p4n6rb"
]
}
],
"firewall": {
"default": "deny",
"rules": []
},
"dns": [],
"exit": {
"through": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"roads": [
"p4n6rb"
]
},
"kill_switch": {
"through": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"roads": [
"w9c3ke"
]
},
"direct": [],
"custom": []
}
@@ -0,0 +1,46 @@
{
"format": 1,
"device": "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc",
"name": "petr-phone",
"address": "100.96.0.7",
"classic": false,
"expires": null,
"peers": [
{
"key": "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY",
"name": "friend-node",
"address": "100.96.0.6",
"classic": false,
"allowed_ips": [
"0.0.0.0/0",
"::/0"
],
"via": null,
"roads": [
"c0z5wn"
]
}
],
"firewall": {
"default": "deny",
"rules": []
},
"dns": [],
"exit": {
"through": "BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY",
"roads": [
"c0z5wn"
]
},
"kill_switch": null,
"direct": [
{
"app": "steam",
"subnet": "0.0.0.0/0",
"roads": [
"e5yj1s"
]
}
],
"custom": []
}
+46
View File
@@ -0,0 +1,46 @@
{
"format": 1,
"device": "BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU",
"name": "router",
"address": "100.96.0.5",
"classic": true,
"expires": null,
"peers": [
{
"key": "AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI",
"name": "home-server",
"address": "100.96.0.2",
"classic": false,
"allowed_ips": [
"100.96.0.2/32"
],
"via": null,
"roads": [
"r8m2tg"
]
}
],
"firewall": {
"default": "deny",
"rules": []
},
"dns": [],
"exit": null,
"kill_switch": null,
"direct": [
{
"app": "steam",
"subnet": "0.0.0.0/0",
"roads": [
"e5yj1s"
]
}
],
"custom": [
{
"road": "x1d7qa",
"classic": true,
"raw": "[Interface]\nMTU = 1380 \nJc = 4\nH1 = 1234567\n\n[Peer]\nPersistentKeepalive = 25\n# kept exactly as the router had it\n"
}
]
}
@@ -0,0 +1,10 @@
---
id: 7tq0mz
subject: person:jana
verb: can-reach
object: service:photos.home.arpa
until: 2026-11-29T23:59:59+01:00
ports: [tcp/443]
created: 2026-11-25T10:00:00+01:00
---
Jana sees the photos until Sunday.
@@ -0,0 +1,7 @@
---
id: c0z5wn
subject: person:petr
verb: exits-through
object: exit:BgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgYGBgY
created: 2026-11-23T20:00:00+01:00
---
@@ -0,0 +1,8 @@
---
id: e5yj1s
subject: app:steam
verb: goes-direct
object: subnet:0.0.0.0/0
created: 2026-11-21T18:30:00+01:00
---
Games do not go through the tunnel.
@@ -0,0 +1,7 @@
---
id: h2x8vd
subject: person:mark
verb: can-reach
object: subnet:192.168.100.0/24
created: 2026-11-20T09:00:00+01:00
---
@@ -0,0 +1,8 @@
---
id: k3f9q2
subject: group:household
verb: can-reach
object: device:AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
created: 2026-11-20T09:00:00+01:00
---
The household reaches the home server.
@@ -0,0 +1,8 @@
---
id: m6v0hp
subject: person:petr
verb: can-reach
object: service:git.home.arpa
until: 2026-11-01T00:00:00+01:00
created: 2026-10-01T12:00:00+02:00
---
@@ -0,0 +1,7 @@
---
id: p4n6rb
subject: device:AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE
verb: exits-through
object: exit:AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
created: 2026-11-20T09:00:00+01:00
---
@@ -0,0 +1,10 @@
---
id: r8m2tg
subject: device:BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU
verb: can-reach
object: device:AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
ports: [udp/53, tcp/22]
classic: true
created: 2026-11-22T11:00:00+01:00
---
The old router is a classic WireGuard peer.
@@ -0,0 +1,7 @@
---
id: w9c3ke
subject: device:AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE
verb: never-online-without
object: exit:AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI
created: 2026-11-20T09:00:00+01:00
---
@@ -0,0 +1,17 @@
---
id: x1d7qa
subject: device:BQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU
verb: custom
classic: true
created: 2026-11-22T11:05:00+01:00
---
```raw
[Interface]
MTU = 1380
Jc = 4
H1 = 1234567
[Peer]
PersistentKeepalive = 25
# kept exactly as the router had it
```