Add human WebUI closure of unknown jobs as final closed_unknown state (spec 1.31); bound agent sync restart interval
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-17 11:13:36 +01:00
parent 2660f6a88d
commit d6dfd01a9c
11 changed files with 363 additions and 29 deletions
+18 -11
View File
@@ -62,18 +62,22 @@ pub fn clock_code(error: &anyhow::Error) -> &'static str {
/// Refresh is control work, not permission. A temporary loss of the100ms clock
/// evidence never discards an otherwise retained signed decision or extends it.
/// Fresh clock/readiness checks remain mandatory at each actual job gate.
/// A requested refresh waits at least `MIN_SYNC_INTERVAL` after the previous
/// start, so a persistently not-ready decision cannot become a tight loop.
pub const MIN_SYNC_INTERVAL: std::time::Duration = std::time::Duration::from_secs(3);
pub fn refresh_due(
needs_sync: bool,
elapsed: std::time::Duration,
valid_until: Option<chrono::DateTime<chrono::Utc>>,
clock_upper: Option<chrono::DateTime<chrono::Utc>>,
) -> bool {
needs_sync
|| elapsed >= std::time::Duration::from_secs(40)
|| valid_until.is_none()
|| valid_until
.zip(clock_upper)
.is_some_and(|(until, upper)| upper >= until)
elapsed >= MIN_SYNC_INTERVAL
&& (needs_sync
|| elapsed >= std::time::Duration::from_secs(40)
|| valid_until.is_none()
|| valid_until
.zip(clock_upper)
.is_some_and(|(until, upper)| upper >= until))
}
#[cfg(windows)]
pub fn persist(state: &Path, value: &Observation) -> Result<()> {
@@ -143,11 +147,14 @@ mod tests {
let now = chrono::DateTime::from_timestamp(100, 0).unwrap();
let until = now + chrono::Duration::seconds(30);
let one = std::time::Duration::from_secs(1);
assert!(!refresh_due(false, one, Some(until), None));
assert!(!refresh_due(false, one, Some(until), Some(now)));
assert!(refresh_due(false, one, Some(until), Some(until)));
assert!(refresh_due(false, one, None, None));
assert!(refresh_due(true, one, Some(until), None));
let min = MIN_SYNC_INTERVAL;
assert!(!refresh_due(false, min, Some(until), None));
assert!(!refresh_due(false, min, Some(until), Some(now)));
assert!(refresh_due(false, min, Some(until), Some(until)));
assert!(refresh_due(false, min, None, None));
assert!(refresh_due(true, min, Some(until), None));
// No trigger may restart Sync sooner than the minimum interval.
assert!(!refresh_due(true, one, None, Some(until)));
assert!(refresh_due(
false,
std::time::Duration::from_secs(40),