The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(storage): track lease version in local lease store
Steven Enamakel00a890c32a2b
diff --git a/crates/openhuman-core/src/storage/fence_tests.rs b/crates/openhuman-core/src/storage/fence_tests.rsindex eaf7c7145a..a154f3c57d 100644--- a/crates/openhuman-core/src/storage/fence_tests.rs+++ b/crates/openhuman-core/src/storage/fence_tests.rs@@ -53,6 +53,7 @@ fn the_local_check_refuses_inside_the_skew_margin_and_after_renewal_admits_againlet grant = LeaseGrant {key: "alice".into(),epoch: 3,+ version: tinystoragedrivers::Version(1),expires_at_ms: 30_000,previous_unclean: false,};diff --git a/crates/openhuman-core/src/storage/lease_local.rs b/crates/openhuman-core/src/storage/lease_local.rsindex 92c230def0..18ea7f9f69 100644--- a/crates/openhuman-core/src/storage/lease_local.rs+++ b/crates/openhuman-core/src/storage/lease_local.rs@@ -23,6 +23,7 @@ use std::sync::Mutex;use async_trait::async_trait;use fs2::FileExt;+use tinystoragedrivers::Version;use super::lease::{local_dir, validate_key, LeaseError, LeaseGrant, LeaseRecord, LeaseStore};use super::StorageError;@@ -35,6 +36,7 @@ struct Holding {/// Kept open: closing it drops the lock.file: File,record: LeaseRecord,+ version: Version,}/// Leases kept as file locks under one root. See the module docs.@@ -137,7 +139,7 @@ impl LocalLeases {let mut held = self.held();let current = held.get(&grant.key)- .is_some_and(|h| h.record.epoch == grant.epoch);+ .is_some_and(|h| h.record.epoch == grant.epoch && h.version == grant.version);if !current {tracing::info!(target: "openhuman::storage::lease",@@ -161,6 +163,7 @@ impl LeaseStore for LocalLeases {return Ok(LeaseGrant {key: key.to_string(),epoch: holding.record.epoch,+ version: holding.version,expires_at_ms: holding.record.expires_at_ms,previous_unclean: false,});@@ -229,10 +232,18 @@ impl LeaseStore for LocalLeases {previous_unclean = unclean,"[lease] local acquired");- held.insert(key.to_string(), Holding { file, record });+ held.insert(+ key.to_string(),+ Holding {+ file,+ record,+ version: Version::FIRST,+ },+ );Ok(LeaseGrant {key: key.to_string(),epoch,+ version: Version::FIRST,expires_at_ms: u64::MAX,previous_unclean: unclean,})@@ -240,8 +251,15 @@ impl LeaseStore for LocalLeases {async fn renew(&self, grant: &LeaseGrant, _now_ms: u64) -> Result<LeaseGrant, LeaseError> {self.with_current(grant, |held| {- held.get(&grant.key).ok_or(LeaseError::Lost)?;- Ok(grant.clone())+ let holding = held.get_mut(&grant.key).ok_or(LeaseError::Lost)?;+ holding.version = holding+ .version+ .next()+ .ok_or_else(|| StorageError::backend("lease version space exhausted"))?;+ Ok(LeaseGrant {+ version: holding.version,+ ..grant.clone()+ })})}