[roads] QA F-07: a missing roads/ folder is store.roads, and roads/ is never followed through a link

A store folder without roads/ compiled to plans with no access and no problem,
kill switches included. It is now an error naming roads. A roads/ that is a
file or a symbolic link is refused the same way (the builder's self-review #8):
entries inside were already refused, the folder itself was followed.
This commit is contained in:
2026-11-25 08:41:10 +01:00
parent 93ab087648
commit b6cf29b9a0
5 changed files with 55 additions and 3 deletions
+2
View File
@@ -8,6 +8,7 @@ pub const FILE_SIZE: &str = "file.size";
pub const FILE_ENCODING: &str = "file.encoding";
pub const FILE_HEADER: &str = "file.header";
pub const FILE_COUNT: &str = "file.count";
pub const STORE_ROADS: &str = "store.roads";
pub const YAML_REFUSED: &str = "yaml.refused";
pub const YAML_SYNTAX: &str = "yaml.syntax";
pub const KEY_UNKNOWN: &str = "key.unknown";
@@ -72,6 +73,7 @@ pub const ALL: &[&str] = &[
FILE_ENCODING,
FILE_HEADER,
FILE_COUNT,
STORE_ROADS,
YAML_REFUSED,
YAML_SYNTAX,
KEY_UNKNOWN,
+30 -1
View File
@@ -104,7 +104,36 @@ impl Store {
let mut files = Vec::new();
let mut problems = Vec::new();
let roads = root.join(ROADS_DIR);
if roads.is_dir() {
// A missing roads/ folder means no road grants anything, kill switches included: say so (QA F-07). The
// folder itself is never followed through a symbolic link, like the entries inside it.
let readable = match std::fs::symlink_metadata(&roads) {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
problems.push(Problem::error(
ROADS_DIR,
None,
r::STORE_ROADS,
"missing: there is no roads/ folder, so no road grants anything and no kill switch is on",
));
false
}
Err(e) => return Err(e),
Ok(m) if !m.file_type().is_dir() => {
let what = if m.file_type().is_symlink() {
"a symbolic link"
} else {
"not a folder"
};
problems.push(Problem::error(
ROADS_DIR,
None,
r::STORE_ROADS,
format!("{what}; roads/ must be a real folder, so no road was read"),
));
false
}
Ok(_) => true,
};
if readable {
for entry in std::fs::read_dir(&roads)? {
let entry = entry?;
let name = entry.file_name().to_string_lossy().into_owned();
-1
View File
@@ -200,7 +200,6 @@ fn f06_a_road_across_address_families_is_reported() {
/// F-07. A store folder without `roads/` compiles to plans with no access and no problem at all, so pointing
/// `--store` one folder too high revokes everything, kill switches included, without a word.
#[test]
#[ignore = "QA F-07 (minor): a missing roads/ folder is not reported"]
fn f07_a_missing_roads_folder_is_reported() {
let dir = tempfile::tempdir().unwrap();
std::fs::copy(
+19
View File
@@ -207,6 +207,25 @@ fn generated(baseline: &[u8]) -> BTreeSet<String> {
.any(|p| p.path == "directory.json" && p.code == rules::SNAPSHOT_JSON)
);
assert!(c.plans.is_empty());
// store.roads: a store folder without roads/, and one whose roads/ is a file (QA F-07).
for make_roads in [false, true] {
let tmp = tempfile::tempdir().unwrap();
for f in ["directory.json", "devices.json"] {
std::fs::copy(common::home_dir().join(f), tmp.path().join(f)).unwrap();
}
if make_roads {
std::fs::write(tmp.path().join("roads"), "not a folder").unwrap();
}
let s = Store::load_dir(tmp.path()).unwrap();
assert!(
s.problems
.iter()
.any(|p| p.path == "roads" && p.code == rules::STORE_ROADS && p.is_error()),
"{:?}",
s.problems
);
}
hit.insert(rules::STORE_ROADS.into());
hit
}
+4 -1
View File
@@ -14,7 +14,10 @@ versioned; a change that an older build would misread bumps the version.
`roads/` holds only regular files named `<id>-<slug>.md`. Anything else in it — a folder, a symbolic link, a
file with another name — is an error (`file.kind`), so the folder can never hold something the compiler does
not read. Files are read in byte order of their names. At most 10,000 road files.
not read. Files are read in byte order of their names. At most 10,000 road files. A store without a `roads/`
folder, or whose `roads/` is a file or a symbolic link, is `store.roads`: nothing is read, nothing is granted,
and it is said out loud, because pointing `--store` one folder too high would otherwise revoke everything,
kill switches included, without a word (QA F-07).
## Road files