fix: reconcile configured APT effect without retroactive acceptance and retain host reboot evidence
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 20:00:20 +01:00
parent 34d695a778
commit b08734065a
26 changed files with 2006 additions and 36 deletions
+18
View File
@@ -97,6 +97,15 @@ pub fn validate_for_scope(
}
let o: Observation =
serde_json::from_value(item.clone()).map_err(|_| "INVALID_OBSERVATION")?;
// Old durable observations without this additive field remain
// acknowledgeable. A present host-level flag must stay a boolean.
let invalid_host_reboot = matches!(
o.scope.as_str(),
"linux.apt.planning" | "linux.apt.recovery-planning"
) && o
.data
.get("host_reboot_required")
.is_some_and(|v| !v.is_boolean());
if !o.scope.starts_with(prefix)
|| o.scope.len() > 64
|| !(o
@@ -121,6 +130,7 @@ pub fn validate_for_scope(
|| (o.truncated && o.completeness == "complete")
|| o.error_code.as_ref().is_some_and(|s| s.len() > 128)
|| (o.quality == "valid" && o.data.is_null())
|| invalid_host_reboot
{
return Err("INVALID_OBSERVATION_METADATA");
}
@@ -187,6 +197,14 @@ mod tests {
v["observations"] = json!([{"scope":"linux.apt.recovery-planning","source_id":"root-helper:apt_recovery_planning_v1","observed_at":now,"quality":"valid","completeness":"complete","truncated":false,"error_code":null,"data":{"native_recovery":{"schema_version":1}}}]);
let original = serde_json::to_vec(&v).unwrap();
assert_eq!(validate(&original, now).unwrap(), v);
v["observations"][0]["data"]["host_reboot_required"] = json!(true);
assert!(validate(&serde_json::to_vec(&v).unwrap(), now).is_ok());
v["observations"][0]["data"]["host_reboot_required"] = json!("true");
assert_eq!(
validate(&serde_json::to_vec(&v).unwrap(), now).unwrap_err(),
"INVALID_OBSERVATION_METADATA"
);
v = serde_json::from_slice(&original).unwrap();
for rejected in [
"linux.apt.other-planning",
"linux.apt.recovery-planning-extra",