Add gated agent update planning, preserved handoff and Linux worker ports
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-14 21:48:21 +01:00
parent dc9cb1b096
commit 1e89c4577f
82 changed files with 25052 additions and 69 deletions
+52 -1
View File
@@ -181,6 +181,9 @@ pub enum Action {
recipe_version: String,
apt_manifest: crate::apt_transaction::AptExecutionManifest,
},
UpdateAgent {
update: Box<crate::agent_update::ResolvedAgentUpdate>,
},
Reboot {
reason: String,
reconnect_timeout_seconds: u32,
@@ -198,6 +201,7 @@ impl Action {
Self::ApplyUpdates { .. } => "apply_updates",
Self::AptNativeAcceptance { .. } => "apt_native_acceptance",
Self::Reboot { .. } => "reboot",
Self::UpdateAgent { .. } => "update_agent",
}
}
pub fn validate(&self) -> bool {
@@ -334,6 +338,7 @@ impl Action {
&& recipe_id == &m.resolved_apt_transaction.recipe_id
&& recipe_version == &m.resolved_apt_transaction.recipe_version
}
Self::UpdateAgent { update } => update.validate(),
Self::Reboot {
reason,
reconnect_timeout_seconds,
@@ -374,6 +379,9 @@ impl Action {
)
}
pub fn valid_execution_identity(&self, identity: &str) -> bool {
if let Self::UpdateAgent { update } = self {
return update.execution_identity() == Some(identity);
}
!self.full_maintenance()
|| matches!(
(identity, self.script_platform()),
@@ -387,6 +395,8 @@ impl Action {
/// its inner Event Log calls retain their own cooperative <=5s deadline.
pub fn valid_job_limits(&self, runtime_seconds: u32, output_bytes: u32) -> bool {
(1..=3600).contains(&runtime_seconds)
&& (!matches!(self, Self::UpdateAgent { .. })
|| (runtime_seconds == 600 && output_bytes <= 65536))
&& (!self.full_maintenance()
|| (output_bytes <= 65536
&& runtime_seconds
@@ -417,7 +427,9 @@ impl Action {
/// Shared plan/revalidation/start gate. Passive Windows never implies job support.
pub fn available_for(&self, identity: &str, capabilities: &[String]) -> bool {
if !self.valid_execution_identity(identity)
|| (identity == "system" && !self.valid_helper_denial_shape(identity))
|| (identity == "system"
&& !self.valid_helper_denial_shape(identity)
&& !matches!(self, Self::UpdateAgent { .. }))
{
return false;
}
@@ -436,6 +448,40 @@ impl Action {
return false;
}
match self {
Self::UpdateAgent { update } => {
let linux = update.execution_identity() == Some("root");
update.validate()
&& has(crate::agent_update::APPLY_CAPABILITY)
&& has("rmm.sync.v1")
&& has(if linux {
"linux.base/1"
} else {
"windows.base/1"
})
&& !has(if linux {
"windows.base/1"
} else {
"linux.base/1"
})
&& has(if linux {
"helper.root.v1"
} else {
"helper.system.v1"
})
&& has(&format!("{}:update_agent", identity))
&& has(&format!(
"updater.binary.sha256:{}",
update.updater.binary_sha256
))
&& has(&format!(
"updater.policy.sha256:{}",
update.updater.policy_sha256
))
&& has(&format!(
"helper.binary.sha256:{}",
update.predecessor.helper_sha256
))
}
Self::RunScript {
interpreter,
windows_execution_profile,
@@ -652,6 +698,10 @@ pub struct ExecutionPermitPayload {
pub start_before: DateTime<Utc>,
pub max_runtime_seconds: u32,
pub key_id: String,
/// Only update_agent needs its actual plan ID in the local durable handoff.
/// Omitted on every legacy action, preserving original signed grant bytes.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub agent_update_plan_id: Option<Uuid>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
@@ -1190,6 +1240,7 @@ mod tests {
let id = Uuid::nil();
let epoch = DateTime::<Utc>::from_timestamp(0, 0).unwrap();
let p = ExecutionPermitPayload {
agent_update_plan_id: None,
domain: "rmm.execution-permit".into(),
schema_version: 1,
grant_id: id,