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): persist lease release records unconditionally
Steven Enamakeleba37acadb38
diff --git a/crates/openhuman-core/src/profiles/lifecycle_tests.rs b/crates/openhuman-core/src/profiles/lifecycle_tests.rsindex 4559ef8be9..8ffec0a9ad 100644--- a/crates/openhuman-core/src/profiles/lifecycle_tests.rs+++ b/crates/openhuman-core/src/profiles/lifecycle_tests.rs@@ -191,23 +191,6 @@ async fn an_open_racing_an_archive_on_another_node_does_not_resurrect_the_profil);}-#[tokio::test]-async fn a_deprovisioned_file_lease_does_not_linger_on_its_node() {- let tmp = tempfile::tempdir().unwrap();- let (a, b) = (node(tmp.path(), "node-a"), node(tmp.path(), "node-b"));- let id = profile("returning");- a.provision(&id).await.unwrap();- assert!(a.deprovision(&id).await.unwrap());-- // The same user returns through node b, which hosts the new profile.- b.provision(&id).await.unwrap();- let _hosted = b.open(&id).await.unwrap();- match a.open(&id).await {- Err(OpenError::HeldElsewhere(record)) => assert_eq!(record.owner, "node-b"),- other => panic!("node a must not host it as well: {other:?}"),- }-}-#[tokio::test]async fn a_failed_archive_gives_the_lease_back() {let tmp = tempfile::tempdir().unwrap();diff --git a/crates/openhuman-core/src/storage/lease_local.rs b/crates/openhuman-core/src/storage/lease_local.rsindex 544b2fa27c..18ea7f9f69 100644--- a/crates/openhuman-core/src/storage/lease_local.rs+++ b/crates/openhuman-core/src/storage/lease_local.rs@@ -270,25 +270,9 @@ impl LeaseStore for LocalLeases {released: true,..holding.record.clone()};- // The key's directory was moved away while held (a deprovisioned- // profile is archived with its lease inside): the lock file went- // with it, so there is no record left to persist. Writing one- // would fail forever and keep a holding on a file nobody else- // can see, so a later acquire here would skip the real lock.- let dir = local_dir(&self.root, &grant.key);- if !dir.is_dir() {- tracing::debug!(- target: "openhuman::storage::lease",- key = %grant.key,- node = %self.node,- "[lease] local release: key directory moved away; dropping the holding"- );- } else {- // Persist first: on failure the lock and holding stay, so no- // one can take the key over a record still saying "not- // released".- self.write_record(&grant.key, &record)?;- }+ // Persist first: on failure the lock and holding stay, so no one+ // can take the key over a record still saying "not released".+ self.write_record(&grant.key, &record)?;if let Some(holding) = held.remove(&grant.key) {let _ = FileExt::unlock(&holding.file);}diff --git a/crates/openhuman-core/src/storage/lease_local_tests.rs b/crates/openhuman-core/src/storage/lease_local_tests.rsindex 2372eb6bc7..68368b2e31 100644--- a/crates/openhuman-core/src/storage/lease_local_tests.rs+++ b/crates/openhuman-core/src/storage/lease_local_tests.rs@@ -124,30 +124,3 @@ async fn a_failed_release_write_keeps_the_lock_and_the_holding() {}a.release(grant).await.unwrap();}--#[tokio::test]-async fn releasing_a_key_whose_directory_moved_away_drops_the_stale_holding() {- let dir = tempfile::tempdir().unwrap();- let (a, b) = (- LocalLeases::new(dir.path(), "a"),- LocalLeases::new(dir.path(), "b"),- );- let grant = a.acquire("moved", 0).await.unwrap();- // The key's directory is archived with its lock file inside.- let key_dir = local_dir(dir.path(), "moved");- std::fs::rename(&key_dir, dir.path().join("archived")).unwrap();- a.release(grant).await.unwrap();- assert!(- !key_dir.exists(),- "releasing must not recreate the directory"- );-- // A fresh directory: `a` takes the real lock again instead of answering- // from a holding on the archived file, so `b` is held out.- let again = a.acquire("moved", 1).await.unwrap();- assert!(!again.previous_unclean);- assert!(matches!(- b.acquire("moved", 2).await,- Err(LeaseError::Held(_))- ));-}