Permit proven closed-control fresh sync and retry only precommit clock reads
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-16 22:29:45 +01:00
parent 2092596936
commit 052456f133
13 changed files with 1349 additions and 39 deletions
+51 -9
View File
@@ -922,8 +922,54 @@ impl SystemHelper {
);
Ok(())
}
fn wait_apply_clock(&self,issued:chrono::DateTime<chrono::Utc>,until:chrono::DateTime<chrono::Utc>)->Result<()> {
crate::job_readiness::wait_for_helper_apply_clock(&self.clock,issued,until)
// One authenticated control call, same original bytes/capture/deadline.
// Only a typed clock failure proven before BEGIN can be retried.
fn apply_control_with_clock(
&mut self,
response: &rmm_agent_core::helper_reconcile::SignedResponse,
request: &[u8],
issued: chrono::DateTime<chrono::Utc>,
until: chrono::DateTime<chrono::Utc>,
) -> Result<rmm_agent_core::helper_reconcile::Applied> {
let began = Instant::now();
loop {
ensure!(
began.elapsed() < Duration::from_secs(3),
"SYSTEM_APPLY_CLOCK_WAIT_EXPIRED"
);
match crate::job_readiness::response_window(
issued,
until,
began.elapsed(),
self.clock.reading().ok().map(|r| (r.own_wall, r.upper)),
) {
crate::job_readiness::ResponseWindow::WaitForClock => {
std::thread::sleep(Duration::from_millis(20));
continue;
}
crate::job_readiness::ResponseWindow::Expired => {
anyhow::bail!("SYSTEM_APPLY_ORIGINAL_DEADLINE_EXPIRED")
}
crate::job_readiness::ResponseWindow::WithinWindow => {}
}
self.sync()?;
match self.sync.as_mut().unwrap().apply(
&mut self.db,
&self.guard,
response,
request,
&self.clock,
&self.boot,
) {
Ok(value) => return Ok(value),
Err(error)
if rmm_agent_core::helper_reconcile::retryable_precommit_clock(&error) =>
{
std::thread::sleep(Duration::from_millis(20))
}
Err(error) => return Err(error),
}
}
}
/// Passive, bounded static denial metadata only. Never feeds a gate.
fn record_apply_error(&mut self,error:&anyhow::Error)->Result<()> {
@@ -1025,15 +1071,11 @@ impl SystemHelper {
// Same authenticated original call, BEFORE any application.
// The independent time pipe continues on its own thread.
// No signature/deadline/lease is relaxed and no Execute retry.
self.wait_apply_clock(decision.issued_at,decision.valid_until)?;
self.sync()?;
let value = self.sync.as_mut().unwrap().apply(
&mut self.db,
&self.guard,
let value = self.apply_control_with_clock(
response,
request_bytes,
&self.clock,
&self.boot,
decision.issued_at,
decision.valid_until,
)?;
let no_start_anchor = if value.ready && self.settings.enable_effects {
let guard = DenialGuard {
+25 -1
View File
@@ -1448,13 +1448,37 @@ impl Agent {
helper: Option<&reconcile::HelperSnapshot>,
) -> Result<()> {
let context = self.channel(generation)?;
let closed_control_idle = {
#[cfg(feature = "system-helper")]
{
self.running.is_none()
&& !self.prepared
&& self.deferred_sync.is_none()
&& self.deferred_permit.is_none()
&& self.helper_control.is_none()
&& self.helper_probe.is_none()
&& helper.is_some()
&& (if Path::new(rmm_agent_windows::helper_runtime::intent::DB).exists() {
rmm_agent_windows::helper_runtime::intent::Store::open(false)
.and_then(|store| store.pending())
.is_ok_and(|pending| pending.is_empty())
} else {
helper.is_some_and(|snapshot| snapshot.attempts.is_empty())
})
}
#[cfg(not(feature = "system-helper"))]
{
false
}
};
let sync = self.sync.as_mut().context("SYNC_NOT_CONFIGURED")?;
let prepared = sync.prepare(
let prepared = sync.prepare_with_closed_control_idle(
self.journal.connection_mut(),
self.ledger.as_ref().context("LEDGER_REQUIRED")?,
context,
helper,
&self.clock,
closed_control_idle,
);
#[cfg(feature = "system-helper")]
if helper.is_some()