Day 2: roads, the compiler, explain, CBOR control messages, the via command #1
@@ -402,7 +402,14 @@ pub fn compile(store: &Store, now: Instant) -> Compiled {
|
||||
),
|
||||
Place::Exit(_) => unreachable!("the parser refuses exit objects for can-reach"),
|
||||
};
|
||||
let mut other_family: Vec<&str> = Vec::new();
|
||||
for from in subject.iter().filter(|d| **d != host) {
|
||||
// A device has one mesh address. From an IPv4 address to an IPv6 place (or the other way)
|
||||
// the rule could never match: grant nothing, and say so (QA F-06).
|
||||
if devs.devices[from].address.0.is_ipv4() != dst.inner().addr().is_ipv4() {
|
||||
other_family.push(&devs.devices[from].name);
|
||||
continue;
|
||||
}
|
||||
touch(from, road);
|
||||
effects += 1;
|
||||
touch(&host, road);
|
||||
@@ -417,6 +424,25 @@ pub fn compile(store: &Store, now: Instant) -> Compiled {
|
||||
via: road.via.clone(),
|
||||
});
|
||||
}
|
||||
if !other_family.is_empty() {
|
||||
other_family.sort();
|
||||
out.problems.push(inactive(
|
||||
Some("object"),
|
||||
r::ROAD_FAMILY,
|
||||
format!(
|
||||
"{dst} is {}, and the mesh address of {} is not: nothing granted there",
|
||||
if dst.inner().addr().is_ipv4() {
|
||||
"IPv4"
|
||||
} else {
|
||||
"IPv6"
|
||||
},
|
||||
other_family.join(", ")
|
||||
),
|
||||
));
|
||||
if effects == 0 {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
(Verb::ExitsThrough, Some(Place::Exit(exit))) => {
|
||||
for from in subject.iter().filter(|d| *d != exit) {
|
||||
@@ -473,7 +499,9 @@ pub fn compile(store: &Store, now: Instant) -> Compiled {
|
||||
.custom
|
||||
.push(plan::Custom {
|
||||
road: road.id.clone(),
|
||||
classic: road.is_classic(),
|
||||
// The device decides, like a peer's flag: a classic device's raw block is never
|
||||
// labelled post-quantum, whatever the road says (QA F-05).
|
||||
classic: road.is_classic() || devs.devices[d].classic,
|
||||
raw: raw.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ pub struct Direct {
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Custom {
|
||||
pub road: RoadId,
|
||||
/// The road said this is for a classic peer: not post-quantum.
|
||||
/// For a classic device (or a road that says so): not post-quantum.
|
||||
pub classic: bool,
|
||||
/// The raw block, byte for byte. **Never checked by the compiler.**
|
||||
pub raw: String,
|
||||
|
||||
@@ -48,6 +48,7 @@ pub const ROAD_NO_DEVICES: &str = "road.no-devices";
|
||||
pub const ROAD_SELF: &str = "road.self";
|
||||
pub const EXIT_CONFLICT: &str = "exit.conflict";
|
||||
pub const DIRECT_KILL_SWITCH: &str = "direct.kill-switch";
|
||||
pub const ROAD_FAMILY: &str = "road.family";
|
||||
|
||||
// Snapshots
|
||||
pub const SNAPSHOT_JSON: &str = "snapshot.json";
|
||||
@@ -113,6 +114,7 @@ pub const ALL: &[&str] = &[
|
||||
ROAD_SELF,
|
||||
EXIT_CONFLICT,
|
||||
DIRECT_KILL_SWITCH,
|
||||
ROAD_FAMILY,
|
||||
SNAPSHOT_JSON,
|
||||
SNAPSHOT_FORMAT,
|
||||
DIRECTORY_ID,
|
||||
|
||||
@@ -175,7 +175,6 @@ fn f04_deleting_a_person_revokes_them_and_nobody_else() {
|
||||
/// F-05. A custom road on a classic device is carried as `classic: false` unless the road says otherwise, so the
|
||||
/// plan labels a classic peer's raw block as post-quantum (CLAUDE.md: classic peers are labelled everywhere).
|
||||
#[test]
|
||||
#[ignore = "QA F-05 (minor): plan.custom takes `classic` from the road, not from the device"]
|
||||
fn f05_a_custom_block_on_a_classic_device_is_labelled_classic() {
|
||||
let router = key(5);
|
||||
let text = Parts::home()
|
||||
@@ -198,7 +197,6 @@ fn f05_a_custom_block_on_a_classic_device_is_labelled_classic() {
|
||||
/// other way round) compile cleanly into rules that can never match: a road that grants nothing, reported as
|
||||
/// nothing.
|
||||
#[test]
|
||||
#[ignore = "QA F-06 (minor): a road across address families compiles into a rule that never matches"]
|
||||
fn f06_a_road_across_address_families_is_reported() {
|
||||
let parts = with(
|
||||
Parts::home().edit_devices(|d| {
|
||||
|
||||
@@ -42,6 +42,7 @@ fn inactive_code(code: &str) -> bool {
|
||||
rules::ROAD_SELF,
|
||||
rules::EXIT_CONFLICT,
|
||||
rules::DIRECT_KILL_SWITCH,
|
||||
rules::ROAD_FAMILY,
|
||||
]
|
||||
.contains(&code)
|
||||
}
|
||||
@@ -242,6 +243,29 @@ fn generated(baseline: &[u8]) -> BTreeSet<String> {
|
||||
);
|
||||
}
|
||||
hit.insert(rules::STORE_ROADS.into());
|
||||
// road.family: an IPv4 subject to an IPv6 subnet needs an IPv6 route in devices.json (QA F-06).
|
||||
let v6 = Parts::home()
|
||||
.edit_devices(|d| {
|
||||
d.replace(
|
||||
r#""routes": ["192.168.100.0/24"]"#,
|
||||
r#""routes": ["192.168.100.0/24", "fd00:1::/64"]"#,
|
||||
)
|
||||
})
|
||||
.with_road(
|
||||
"b00004-mark-v6.md",
|
||||
"---\nid: b00004\nsubject: person:mark\nverb: can-reach\nobject: subnet:fd00:1::/64\ncreated: 2026-11-25T10:00:00Z\n---\n",
|
||||
);
|
||||
let c = v6.compile();
|
||||
let hit_family = c
|
||||
.problems
|
||||
.iter()
|
||||
.find(|p| p.path == "roads/b00004-mark-v6.md" && p.code == rules::ROAD_FAMILY);
|
||||
assert!(
|
||||
hit_family.is_some_and(|p| !p.is_error() && p.field.as_deref() == Some("object")),
|
||||
"{:?}",
|
||||
c.problems
|
||||
);
|
||||
hit.insert(rules::ROAD_FAMILY.into());
|
||||
hit
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ Valid roads that grant nothing right now, reported with their reason (not errors
|
||||
| `road.no-devices` | the subject has no devices |
|
||||
| `road.self` | every subject device is the object's own device |
|
||||
| `exit.conflict` | for one device: active `exits-through` roads to two different exits (that device gets neither; reported per road, naming the device) |
|
||||
| `road.family` | a `can-reach` road from devices whose mesh address is IPv4 to an IPv6 place, or the other way: those devices get nothing (a rule that could never match), reported naming them (QA F-06) |
|
||||
| `direct.kill-switch` | for one device with a kill switch: a `goes-direct` road to a subnet that reaches the internet; the kill switch wins and the subnet stays in the tunnel (reported per road, naming the device). Going direct to a private subnet stays allowed |
|
||||
|
||||
## `directory.json` — the people directory snapshot
|
||||
|
||||
Reference in New Issue
Block a user