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): release document leases on drop
Steven Enamakel353314d68cab
diff --git a/crates/openhuman-core/src/storage/lease.rs b/crates/openhuman-core/src/storage/lease.rsindex 26c0e26055..fc9765b0a6 100644--- a/crates/openhuman-core/src/storage/lease.rs+++ b/crates/openhuman-core/src/storage/lease.rs@@ -166,6 +166,16 @@ pub trait LeaseStore: Send + Sync {////// [`LeaseError::Storage`].async fn holder(&self, key: &str) -> Result<Option<LeaseRecord>, LeaseError>;++ /// The storage scope whose [`LEASE_COLLECTION`] holds this store's+ /// records (document id = key), when they live in the storage ports at+ /// all. A storage driver with fencing can then check a write against the+ /// record in the same atomic step ([`super::fence::LeaseFence::driver_fence`]).+ /// `None` (the default) for stores that keep records elsewhere, such as+ /// file locks.+ fn record_scope(&self) -> Option<tinystoragedrivers::Scope> {+ None+ }}/// Rejects keys that could escape a directory or a document id: empty,diff --git a/crates/openhuman-core/src/storage/lease_documents.rs b/crates/openhuman-core/src/storage/lease_documents.rsindex 7109b34c2a..a152768b98 100644--- a/crates/openhuman-core/src/storage/lease_documents.rs+++ b/crates/openhuman-core/src/storage/lease_documents.rs@@ -27,6 +27,9 @@ const ACQUIRE_ATTEMPTS: usize = 16;/// Leases kept as documents. See the module docs.pub struct DocumentLeases {docs: Arc<dyn DocumentStore>,+ /// The scope `docs` is bound to, when known ([`Self::cluster`]); a+ /// fencing driver reads the lease record from there.+ scope: Option<Scope>,node: String,endpoint: Option<String>,ttl_ms: u64,@@ -62,6 +65,7 @@ impl DocumentLeases {) -> Self {Self {docs,+ scope: None,node: node.into(),endpoint,// A sub-millisecond TTL rounds up so a grant never expires at@@ -84,13 +88,18 @@ impl DocumentLeases {endpoint: Option<String>,ttl: Duration,) -> Result<Self, StorageError> {- let scoped = backend.for_scope(&Scope::new(CLUSTER_SCOPE)?)?;- Ok(Self::new(- Arc::clone(scoped.documents()),- node,- endpoint,- ttl,- ))+ let scope = Scope::new(CLUSTER_SCOPE)?;+ let scoped = backend.for_scope(&scope)?;+ Ok(Self::new(Arc::clone(scoped.documents()), node, endpoint, ttl).in_scope(scope))+ }++ /// Records that the document store this was built over is bound to+ /// `scope`, so storage fences can name the lease record+ /// ([`LeaseStore::record_scope`]).+ #[must_use]+ pub fn in_scope(mut self, scope: Scope) -> Self {+ self.scope = Some(scope);+ self}/// This node's id.