feat: preserve failed APT history for one signed UI-approved recovery
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-13 15:50:34 +01:00
parent a5c2dce4fb
commit fd7225600b
18 changed files with 1345 additions and 34 deletions
+54 -1
View File
@@ -33,6 +33,24 @@ pub struct PackageArchive {
}
pub type AptExpectation = ResolvedAptTransaction;
pub type AptExpectedPackage = PackageArchive;
/// One explicitly approved recovery of a fixture acceptance that failed before
/// the trusted pre-dpkg hook. The original create-once marker remains intact.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, schemars::JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct AptNativeRetry {
pub schema_version: u32,
pub previous_grant_id: uuid::Uuid,
pub previous_attempt_id: uuid::Uuid,
pub bootstrap_marker_sha256: String,
}
impl AptNativeRetry {
pub fn validate(&self) -> bool {
self.schema_version == 1
&& !self.previous_grant_id.is_nil()
&& !self.previous_attempt_id.is_nil()
&& digest(&self.bootstrap_marker_sha256)
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, schemars::JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct AptExecutionManifest {
@@ -49,6 +67,8 @@ pub struct AptExecutionManifest {
pub apt_config_sha256: String,
pub runtime_sha256: String,
pub test_result_id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub native_retry: Option<AptNativeRetry>,
}
impl ResolvedAptTransaction {
pub fn validate_fixture(&self) -> bool {
@@ -86,7 +106,11 @@ impl ResolvedAptTransaction {
impl AptExecutionManifest {
pub fn validate(&self) -> bool {
self.kind == "rmm.apt.helper-action"
&& self.schema_version == 2
&& match (&self.native_retry, self.schema_version) {
(None, 2) => true,
(Some(retry), 3) => self.action == "apt-native-acceptance" && retry.validate(),
_ => false,
}
&& matches!(
self.action.as_str(),
"apt-native-acceptance" | "apt-execute"
@@ -320,8 +344,37 @@ mod tests {
apt_config_sha256: hash(b"config"),
runtime_sha256: hash(b"runtime"),
test_result_id: "fixture-test-1".into(),
native_retry: None,
};
assert!(m.validate());
assert!(
!serde_json::to_value(&m)
.unwrap()
.as_object()
.unwrap()
.contains_key("native_retry")
);
let mut retry = m.clone();
retry.schema_version = 3;
assert!(!retry.validate());
retry.native_retry = Some(AptNativeRetry {
schema_version: 1,
previous_grant_id: Uuid::new_v4(),
previous_attempt_id: Uuid::new_v4(),
bootstrap_marker_sha256: hash(b"immutable original marker"),
});
assert!(retry.validate());
let encoded_retry = crate::jobs::encode(&retry).unwrap();
let parsed_retry: AptExecutionManifest = serde_json::from_slice(&encoded_retry).unwrap();
assert_eq!(crate::jobs::encode(&parsed_retry).unwrap(), encoded_retry);
retry.schema_version = 2;
assert!(!retry.validate());
retry.schema_version = 3;
retry.action = "apt-execute".into();
assert!(!retry.validate());
retry.action = "apt-native-acceptance".into();
retry.native_retry.as_mut().unwrap().previous_attempt_id = Uuid::nil();
assert!(!retry.validate());
let a = Action::AptNativeAcceptance {
recipe_id: INSTALL_RECIPE.into(),
recipe_version: "1".into(),