Day 2: roads, the compiler, explain, CBOR control messages, the via command #1

Merged
mnovak merged 25 commits from feature/roads into main 2026-11-26 05:24:39 +01:00
Showing only changes of commit 31a46d0367 - Show all commits
+32
View File
@@ -149,6 +149,31 @@ impl Renaming {
for (o, _) in &olds {
taken.insert(o.clone());
}
// `back` maps strings anywhere in the output, so a new id must never spell a word the output already
// holds for another reason: a group renamed to `in` turned every firewall `"direction": "in"` into
// the group's old name (seed 8124609985917702487). Reserve every string the plans and problems hold.
fn strings(v: &Value, out: &mut BTreeSet<String>) {
match v {
Value::String(s) => {
out.insert(s.clone());
}
Value::Array(a) => a.iter().for_each(|x| strings(x, out)),
Value::Object(m) => m.iter().for_each(|(k, x)| {
out.insert(k.clone());
strings(x, out);
}),
_ => {}
}
}
let c = compile(
&Store::from_parts(&parts.roads, Some(&parts.directory), Some(&parts.devices)),
now(),
);
strings(
&serde_json::to_value(c.plans.values().collect::<Vec<_>>()).unwrap(),
&mut taken,
);
strings(&serde_json::to_value(&c.problems).unwrap(), &mut taken);
let mut to_new = BTreeMap::new();
for (old, kind) in olds {
let new = loop {
@@ -385,6 +410,13 @@ fn the_extra_roads_reach_the_order_sensitive_paths() {
);
}
/// A seed that once renamed the household group to `in`, a word the plans already hold (a firewall
/// direction). The renaming must avoid it, not the comparison.
#[test]
fn a_new_id_never_spells_a_word_of_the_output() {
check_isomorphic(8124609985917702487).unwrap();
}
#[test]
fn the_identity_renaming_changes_nothing() {
let parts = base_parts();