[control] Store and recovery fixes: cross-process token lock, revert keeps its journal until done, epoch and deny list never roll back, journal errors propagate, lost confirm reloads edge, trial hash checked

This commit is contained in:
2026-11-07 18:51:58 +01:00
parent b9e14c6aee
commit 4448527b16
10 changed files with 305 additions and 66 deletions
+17
View File
@@ -5,6 +5,9 @@
//! Crash points for the crash-safety tests: with `IANITOR_TEST_CRASH_AT=<stage>` in its
//! environment, control aborts (no cleanup, like a kill -9) when an apply reaches that stage.
//! Without the variable this does nothing; the NixOS unit never sets it.
//!
//! `IANITOR_TEST_FAIL_WRITE=<file name>` makes every write of a state file with that name
//! fail, as on a full disk (fault injection for the same tests).
/// The stages, in order.
pub const STAGES: [&str; 9] = [
@@ -25,3 +28,17 @@ pub fn point(stage: &str) {
std::process::abort();
}
}
/// Fail a state-file write when `IANITOR_TEST_FAIL_WRITE` names this file.
pub fn fail_write(path: &std::path::Path) -> Result<(), String> {
match (
std::env::var_os("IANITOR_TEST_FAIL_WRITE"),
path.file_name(),
) {
(Some(want), Some(name)) if want == name => Err(format!(
"cannot write {}: IANITOR_TEST_FAIL_WRITE (injected)",
path.display()
)),
_ => Ok(()),
}
}