From ecafe194a58fd1e721c45931bf2c9a6b836351f3 Mon Sep 17 00:00:00 2001 From: mnovak Date: Wed, 25 Nov 2026 08:52:01 +0100 Subject: [PATCH] [roads] QA F-05 and F-06: classic custom blocks, and roads across address families F-05: plan.custom took classic from the road only, so a raw block on a classic device without classic: true was labelled post-quantum. The device's flag now counts too, as it already did for peers. F-06: a device has one mesh address, so a can-reach road from IPv4 devices to an IPv6 place compiled to rules that could never match, silently. Those devices now get nothing for that road, and the road is reported inactive (road.family) naming them. --- crates/roads/src/compile.rs | 30 +++++++++++++++++++++++++++++- crates/roads/src/plan.rs | 2 +- crates/roads/src/rules.rs | 2 ++ crates/roads/tests/qa_findings.rs | 2 -- crates/roads/tests/validation.rs | 24 ++++++++++++++++++++++++ docs/FORMATS.md | 1 + 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/crates/roads/src/compile.rs b/crates/roads/src/compile.rs index a7f800a..a8a99ab 100644 --- a/crates/roads/src/compile.rs +++ b/crates/roads/src/compile.rs @@ -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(), }); } diff --git a/crates/roads/src/plan.rs b/crates/roads/src/plan.rs index af5a531..b619bea 100644 --- a/crates/roads/src/plan.rs +++ b/crates/roads/src/plan.rs @@ -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, diff --git a/crates/roads/src/rules.rs b/crates/roads/src/rules.rs index f9589a5..42a0a92 100644 --- a/crates/roads/src/rules.rs +++ b/crates/roads/src/rules.rs @@ -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, diff --git a/crates/roads/tests/qa_findings.rs b/crates/roads/tests/qa_findings.rs index 74fd7de..a92fd89 100644 --- a/crates/roads/tests/qa_findings.rs +++ b/crates/roads/tests/qa_findings.rs @@ -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| { diff --git a/crates/roads/tests/validation.rs b/crates/roads/tests/validation.rs index 06c4513..ef5866b 100644 --- a/crates/roads/tests/validation.rs +++ b/crates/roads/tests/validation.rs @@ -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 { ); } 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 } diff --git a/docs/FORMATS.md b/docs/FORMATS.md index 7ac1e43..c488042 100644 --- a/docs/FORMATS.md +++ b/docs/FORMATS.md @@ -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