diff --git a/HANDOVER.md b/HANDOVER.md index a9d2f9e..2bf3419 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -16,7 +16,7 @@ head named in the PR. | Run | Result | |:--|:--| -| `cargo test --workspace` | **90 passed, 0 failed, 0 ignored** (debug and `--release`) | +| `cargo test --workspace` | **91 passed, 0 failed, 0 ignored** (debug and `--release`) | | `cargo clippy --workspace --all-targets -- -D warnings` | clean | | `cargo fmt --all --check` | clean | | `cargo deny check` | advisories ok, bans ok, licenses ok, sources ok | @@ -26,7 +26,7 @@ head named in the PR. Per file: `proto/roundtrip` 6 · `roads` unit 16 · `attacks` 8 · `custom` 6 · `determinism` 4 · `explain` 6 · `least_privilege` 6 (P-1 5,000 cases: 1,706 with rules, 4,420 rules and 7,784 allowed IPs checked against the -oracle; P-6v6 1,000) · `qa_findings` 13 · `rename` 4 · `revocation` 9 · `validation` 5 (83 fixture files, 65 +oracle; P-6v6 1,000) · `qa_findings` 13 · `rename` 4 · `revocation` 10 · `validation` 5 (83 fixture files, 65 rules) · `via-cli/cli` 7. **What changed after QA** (details in `docs/02_via-core.md`, "QA review of PR #1"): @@ -45,6 +45,7 @@ rules) · `via-cli/cli` 7. | F-10 | P-6v6: IPv6 compiles like IPv4, by embedding into `fd00::/96` | | B-3 | `app:` roads need `on:` (person, group or device) and reach only those devices | | R-55 | QA's renaming property was flaky (a group renamed to `in`); fixed in the test, seed pinned | +| Mark | "Leave classic out" (2026-11-25): person and group grants cover only post-quantum devices; a classic device needs its own `device:` road with `classic: true`. Test `revocation.rs::a_person_grant_never_covers_their_classic_device`, mutation-checked | The plan format gained `services` and `direct[].except`. Format 1 has not been released, so it changed in place; the golden plans and the pinned CBOR digest were regenerated and the diff read by hand. diff --git a/crates/roads/src/compile.rs b/crates/roads/src/compile.rs index 286dbdb..e617a4e 100644 --- a/crates/roads/src/compile.rs +++ b/crates/roads/src/compile.rs @@ -95,8 +95,10 @@ impl Extras { } } -/// The devices a subject covers: a person's are the devices they own; a group's, its members'; an app's, those -/// of its `on` (QA B-3: never every device of the mesh). +/// The devices a subject covers: a person's are the post-quantum devices they own; a group's, its members'; +/// an app's, those of its `on` (QA B-3: never every device of the mesh). A classic (not post-quantum) device is +/// never covered by a person or a group: it is reached only by a `device:` road of its own, which says +/// `classic: true` (Mark, 2026-11-25: "Leave classic out"). pub fn subject_devices( subject: &Subject, on: Option<&Subject>, @@ -114,11 +116,14 @@ pub fn subject_devices( devs.devices .values() .filter(|d| match subject { - Subject::Person(p) => d.owner.as_ref() == Some(p), - Subject::Group(g) => dir - .groups - .get(g) - .is_some_and(|g| d.owner.as_ref().is_some_and(|o| g.members.contains(o))), + Subject::Person(p) => !d.classic && d.owner.as_ref() == Some(p), + Subject::Group(g) => { + !d.classic + && dir + .groups + .get(g) + .is_some_and(|g| d.owner.as_ref().is_some_and(|o| g.members.contains(o))) + } Subject::Device(k) => &d.key == k, Subject::App(_) => false, }) @@ -126,7 +131,8 @@ pub fn subject_devices( .collect() } -/// Devices by owner, built once per compile so resolving a subject does not scan every device. +/// Post-quantum devices by owner, built once per compile so resolving a subject does not scan every device. +/// Classic devices are left out: no person or group grant covers them. struct Index { by_owner: BTreeMap>, } @@ -134,7 +140,7 @@ struct Index { impl Index { fn new(devs: &Devices) -> Index { let mut by_owner: BTreeMap<_, BTreeSet> = BTreeMap::new(); - for d in devs.devices.values() { + for d in devs.devices.values().filter(|d| !d.classic) { if let Some(o) = &d.owner { by_owner.entry(o.clone()).or_default().insert(d.key.clone()); } diff --git a/crates/roads/tests/revocation.rs b/crates/roads/tests/revocation.rs index 8198248..cd1cdb5 100644 --- a/crates/roads/tests/revocation.rs +++ b/crates/roads/tests/revocation.rs @@ -200,3 +200,44 @@ fn a_person_deleted_from_the_directory_leaves_their_roads_reported_and_void() { "the friend node kept petr-phone as a peer" ); } + +/// Mark, 2026-11-25, "Leave classic out": a grant to a person or a group covers only their post-quantum +/// devices. A classic router that Mark owns is reached by none of Mark's or the household's roads, only by +/// its own `device:` road with `classic: true`, and that road keeps working. +#[test] +fn a_person_grant_never_covers_their_classic_device() { + let parts = Parts::home().edit_devices(|d| { + d.replace( + r#""name": "router", "address""#, + r#""name": "router", "owner": "mark", "address""#, + ) + }); + let c = parts.compile(); + assert_eq!(c.errors().count(), 0, "{:?}", c.problems); + let router = &c.plans[&key(5)]; + // h2x8vd (person:mark -> the home LAN) and k3f9q2 (group:household -> home-server) leave it out. + for p in &router.peers { + assert!( + p.roads.iter().all(|r| r.as_str() == "r8m2tg"), + "the router got a peer from a person or group road: {:?}", + p.roads + ); + } + assert!( + !router + .peers + .iter() + .flat_map(|p| p.allowed_ips.iter()) + .any(|n| n.to_string() == "192.168.100.0/24"), + "mark's LAN road reached his classic router" + ); + // Its own classic road still gives it the home server on udp/53 and tcp/22. + assert!(fw_accepts( + &c, + &key(5), + "100.96.0.2".parse().unwrap(), + Some(("tcp", 22)) + )); + // And mark's post-quantum devices keep their access. + assert!(c.plans[&key(1)].peers.iter().any(|p| p.key == key(2))); +} diff --git a/docs/02_via-core.md b/docs/02_via-core.md index 572ce3d..a70e70e 100644 --- a/docs/02_via-core.md +++ b/docs/02_via-core.md @@ -57,8 +57,11 @@ change. | `never-online-without` | person, group, device | exit | `until` | nothing: the kill switch | | `custom` | device | — | `until`, `classic` | nothing the compiler checks: the raw block is carried, verbatim and labelled | -- A person's grant covers **every device whose owner is that person** in `devices.json`; a group's covers every - member's devices. Removing a device from a person removes its access on the next compile. +- A person's grant covers **every post-quantum device whose owner is that person** in `devices.json`; a group's + covers every member's post-quantum devices. Removing a device from a person removes its access on the next + compile. **Classic devices are left out** of person and group grants (Mark, 2026-11-25, "Leave classic + out"): a classic router is reached only by a `device:` road of its own, which says `classic: true`. So one + classic device no longer blocks its owner's roads (the builder's self-review #5). - `classic` must be `true` on any road that would create a peer with a classic (not post-quantum) device. It is the road saying out loud that this path is not post-quantum. Without it the road grants nothing. - `until` is exclusive and compared with `now`, which is a parameter. Each plan carries `expires`, the earliest diff --git a/docs/FORMATS.md b/docs/FORMATS.md index 60bdd3c..397cb3a 100644 --- a/docs/FORMATS.md +++ b/docs/FORMATS.md @@ -75,7 +75,7 @@ never widens a road (QA F-09). `ports: []` is `ports.format`. | Form | Meaning | Id rules | |:--|:--|:--| -| `person:` | a person in `directory.json` | opaque: 1–64 of `[A-Za-z0-9_-]` (no people directory exists in Fundamentum yet) | +| `person:` | a person in `directory.json`: their post-quantum devices (classic devices are never covered by a person or group, only by their own `device:` road) | opaque: 1–64 of `[A-Za-z0-9_-]` (no people directory exists in Fundamentum yet) | | `group:` | a group in `directory.json` | as a person id | | `device:` | a device in `devices.json` | the Tessera device subkey: 32-byte Ed25519 public key, base64url without padding, 43 characters, canonical | | `app:` | a Domi app, on the devices its road's `on` names (QA B-3) | the Tessera id: 1–32 of `[a-z0-9-]`, not starting or ending with `-` |