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
+34 -3
View File
@@ -25,6 +25,7 @@ fn map(s: &root::Snapshot) -> reconcile::HelperSnapshot {
.attempts
.iter()
.map(|a| SyncAttempt {
update_handoff_bytes: a.update_handoff_bytes.clone(),
job_id: a.job_id.to_string(),
attempt_id: a.attempt_id.to_string(),
job_payload_hash: a.job_payload_hash.clone(),
@@ -115,7 +116,12 @@ impl Helpers {
for _ in 0..3 {
let mut snapshots = vec![];
let mut inodes = None;
for e in &self.endpoints {
// Full is the only provisioned update owner authority. General
// cannot inspect its broader process capability context; it must
// stay closed without classifying the original effect Unknown.
let mut ordered: Vec<_> = self.endpoints.iter().collect();
ordered.sort_by_key(|e| e.profile != "full_maintenance_v1");
for e in ordered {
let q = control::Request::Snapshot {
challenge: Uuid::new_v4(),
identity: readiness::Identity::from_binding(&self.binding)?,
@@ -128,7 +134,19 @@ impl Helpers {
ensure!(old == ids, "HELPERS_MUST_SHARE_LEDGER_AND_LOCK");
}
inodes = Some(ids);
snapshots.push(r.snapshot.context("HELPER_SNAPSHOT_REQUIRED")?);
let snapshot = r.snapshot.context("HELPER_SNAPSHOT_REQUIRED")?;
if snapshot
.attempts
.iter()
.any(|a| !a.update_handoff_bytes.is_empty())
{
ensure!(
e.profile == "full_maintenance_v1",
"UPDATE_FULL_OWNER_REQUIRED"
);
return Ok(Some(map(&snapshot)));
}
snapshots.push(snapshot);
}
let first = &snapshots[0];
if snapshots.iter().all(|s| {
@@ -150,7 +168,20 @@ impl Helpers {
) -> Result<Option<reconcile::HelperSnapshot>> {
use prost::Message;
let mut applied: Option<root::Snapshot> = None;
for e in &self.endpoints {
let update_control = request
.attempts
.iter()
.any(|a| !a.update_handoff_bytes.is_empty());
let endpoints: Vec<_> = self
.endpoints
.iter()
.filter(|e| !update_control || e.profile == "full_maintenance_v1")
.collect();
ensure!(
!update_control || endpoints.len() == 1,
"UPDATE_FULL_OWNER_REQUIRED"
);
for e in endpoints {
let q = control::Request::Apply {
challenge: Uuid::new_v4(),
identity: readiness::Identity::from_binding(&self.binding)?,
+47 -1
View File
@@ -184,6 +184,15 @@ impl<C: reconcile::SyncClock> Agent<C> {
.as_mut()
.context("SYNC_REQUIRED")?
.confirm_helper(&snapshot)?;
} else if snapshot
.attempts
.iter()
.any(|a| !a.update_handoff_bytes.is_empty())
{
self.sync
.as_mut()
.context("SYNC_REQUIRED")?
.confirm_update_helper(&snapshot)?;
}
}
if self.ready(generation, false) {
@@ -389,7 +398,11 @@ impl<C: reconcile::SyncClock> Agent<C> {
})
}
fn capabilities(&self) -> Vec<String> {
let mut capabilities = vec!["linux.base/1".into(), "heartbeat/1".into()];
let mut capabilities = vec![
"linux.base/1".into(),
"heartbeat/1".into(),
"agent.update/1".into(),
];
if self.binding.is_some() {
capabilities.push("rmm.sync.v1".into());
}
@@ -435,6 +448,33 @@ impl<C: reconcile::SyncClock> Agent<C> {
let _ = sender.blocking_send(result);
});
}
fn queue_update_observation(&mut self, generation: u64) -> Result<()> {
if !storage::passive_collection_ready(&self.db)? {
return Ok(());
}
// Until the separately qualified protected updater/helper observer is
// provisioned, report its real absence; never infer apply readiness from
// this schema support or the agent's own code/build version.
let observation = rmm_domain::agent_update::AgentUpdateObservation::not_configured(
rmm_domain::agent_update::Platform::LinuxX64,
Utc::now(),
);
let data = serde_json::to_vec(&serde_json::json!({"agent_update":observation}))?;
let envelope = self.envelope(
generation,
Payload::InventorySnapshot(rmm_protocol::InventorySnapshot {
snapshot_id: Uuid::new_v4().to_string(),
scope: "agent.update".into(),
schema_version: 1,
chunk_index: 0,
chunk_count: 1,
sha256: Sha256::digest(&data).to_vec(),
data,
completeness: "partial".into(),
}),
)?;
jobs::event(&self.db, &envelope)
}
fn inventory_envelope(
&mut self,
generation: u64,
@@ -507,6 +547,7 @@ impl<C: reconcile::SyncClock> Agent<C> {
storage::clear_pending(&self.db)?;
}
self.queue_inventory();
self.queue_update_observation(generation)?;
self.replay(&ws, generation).await?;
let mut needs_sync = false;
if self.sync.is_some()
@@ -518,6 +559,7 @@ impl<C: reconcile::SyncClock> Agent<C> {
}
eprintln!("authenticated channel established; inventory queued for durable acknowledgment");
let mut inventory_at = Instant::now();
let mut update_at = Instant::now();
let mut heartbeat_at = Instant::now();
let mut heartbeat_after = Duration::from_millis(rand::random_range(27_000..33_000));
let mut tick = tokio::time::interval(Duration::from_secs(5));
@@ -648,6 +690,10 @@ impl<C: reconcile::SyncClock> Agent<C> {
// Planning pins must be refreshed before the 90-second stored-data
// planning limit. One inflight blocking collector bounds pressure;
// heartbeats never perform this metadata work.
if update_at.elapsed() >= Duration::from_secs(60) {
self.queue_update_observation(generation)?;
update_at = Instant::now();
}
if inventory_at.elapsed() >= Duration::from_secs(60) {
self.queue_inventory();
inventory_at = Instant::now();
+1
View File
@@ -60,6 +60,7 @@ fn new_process_persists_interruption_before_helper_io_without_unlock_or_repeat()
max_output_bytes: 4096,
};
let permit = ExecutionPermitPayload {
agent_update_plan_id: None,
domain: "rmm.execution-permit".into(),
schema_version: 1,
grant_id: Uuid::new_v4(),