[roads] QA F-09: a present but empty until: or ports: is key.empty, never absent

Clearing a narrowing field (until:, until: # comment, ports:) used to read as
absent, which is the widest value: a permanent grant or all traffic. It is now
an error, so the road grants nothing. Three fixtures, FORMATS.md updated, and
the F-09 test is no longer ignored.
This commit is contained in:
2026-11-25 08:40:01 +01:00
parent 635d3802c1
commit 93ab087648
8 changed files with 52 additions and 3 deletions
+19
View File
@@ -16,6 +16,8 @@ pub const MAX_FILE: usize = 256 * 1024;
pub const REQUIRED: [&str; 4] = ["id", "subject", "verb", "created"];
pub const OPTIONAL: [&str; 5] = ["object", "until", "ports", "via", "classic"];
/// Optional keys whose absence is their widest value; present but empty is `key.empty`.
pub const NARROWING: [&str; 2] = ["until", "ports"];
/// The canonical key order.
pub const ORDER: [&str; 9] = [
"id", "subject", "verb", "object", "until", "ports", "via", "classic", "created",
@@ -481,6 +483,23 @@ impl Road {
problems.push(p(&f.key, r::KEY_UNKNOWN, "unknown key".into()));
}
}
// A condition that narrows a road is widest when it is absent (no end, all traffic), so a key that is
// present but empty is an error, never "absent": clearing a field must not widen a road (QA F-09).
for k in NARROWING {
if fields
.iter()
.any(|f| f.key == k && f.value == Value::Absent)
{
problems.push(p(
k,
r::KEY_EMPTY,
format!(
"`{k}:` is empty, which would widen the road to {}; give a value or remove the key",
if k == "until" { "a permanent grant" } else { "all traffic" }
),
));
}
}
for k in REQUIRED {
if get(k).is_none() {
problems.push(