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
+48 -6
View File
@@ -489,12 +489,17 @@ impl Agent {
ensure!(expected == generation, "HELPER_CHANNEL_CHANGED");
let snapshot = task.await??;
self.helper_anchor = snapshot.no_start_anchor;
self.sync
.as_mut()
.context("SYNC_NOT_CONFIGURED")?
.confirm_helper(&rmm_agent_windows::helper_runtime::map_snapshot(
&snapshot.raw,
))?;
let mapped = rmm_agent_windows::helper_runtime::map_snapshot(&snapshot.raw);
let sync = self.sync.as_mut().context("SYNC_NOT_CONFIGURED")?;
if mapped
.attempts
.iter()
.any(|a| !a.update_handoff_bytes.is_empty())
{
sync.confirm_update_helper(&mapped)?;
} else {
sync.confirm_helper(&mapped)?;
}
self.open_fence(generation)?;
}
}
@@ -602,6 +607,7 @@ impl Agent {
}
fn capabilities(&self) -> Vec<String> {
let mut caps: Vec<String> = CAPABILITIES.iter().map(|c| c.to_string()).collect();
caps.push("agent.update/1".into());
if self.config.enable_jobs
&& self.binding.is_some()
&& native::require_local_service().is_ok()
@@ -1243,6 +1249,36 @@ impl Agent {
self.journal.save(&envelope)
}
}
fn queue_update_observation(&mut self, generation: u64) -> Result<()> {
if self.journal.count()? > 0 || !jobs::events(self.journal.connection())?.is_empty() {
return Ok(());
}
// Schema support is passive only; no qualified updater/helper observer
// is configured by this source checkpoint, so apply remains closed.
let observation = rmm_domain::agent_update::AgentUpdateObservation::not_configured(
rmm_domain::agent_update::Platform::WindowsX64,
Utc::now(),
);
let data = serde_json::to_vec(&serde_json::json!({"agent_update":observation}))?;
let envelope = self.envelope(
generation,
Payload::InventorySnapshot(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(),
}),
)?;
if self.binding.is_some() {
jobs::event(self.journal.connection(), &envelope)
} else {
self.journal.save(&envelope)
}
}
async fn session(&mut self, stop: &AtomicBool) -> Result<()> {
self.close_gate();
let result = self.session_inner(stop).await;
@@ -1296,6 +1332,7 @@ impl Agent {
"SERVER_LIMITS"
);
self.queue_inventory(generation)?;
self.queue_update_observation(generation)?;
self.replay(&channel, generation).await?;
let mut needs_sync = self.sync.is_some();
if self.sync.is_some() && self.running.is_none() {
@@ -1309,6 +1346,7 @@ impl Agent {
let mut capabilities_at = Instant::now();
let mut replay = Instant::now() - Duration::from_secs(10);
let mut inventory = Instant::now();
let mut update_at = Instant::now();
let mut heartbeat = Instant::now() - Duration::from_secs(60);
let mut heartbeat_after = Duration::from_secs(30);
let mut tick = tokio::time::interval(Duration::from_secs(1));
@@ -1422,6 +1460,10 @@ impl Agent {
self.queue_inventory(generation)?;
inventory = Instant::now();
}
if !stop.load(Ordering::SeqCst) && update_at.elapsed() >= Duration::from_secs(60) {
self.queue_update_observation(generation)?;
update_at = Instant::now();
}
}
Ok(())
}