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(profiles): reconcile cron admission after registering the fence
Steven Enamakel66389691e579
diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rsindex 4c1154e4e2..1e2ca219c1 100644--- a/crates/openhuman-core/src/profiles/host.rs+++ b/crates/openhuman-core/src/profiles/host.rs@@ -327,10 +327,6 @@ impl ProfileHost {let mut config = self.serving_config(&layout, id).map_err(OpenError::Storage)?;- if let Err(error) = super::lifecycle::reconcile_cron_admission(&config, id).await {- profile_lease::release_all(self, vec![(id.clone(), grant)]).await;- return Err(OpenError::Storage(error));- }if let Some(capabilities) = &self.capabilities {capabilities.configure(&mut config);}@@ -362,6 +358,11 @@ impl ProfileHost {let anchor: Arc<dyn std::any::Any + Send + Sync> = context.clone();fence.anchor_to(Arc::downgrade(&anchor));self.fences.register(Arc::clone(&fence));+ if let Err(error) = super::lifecycle::reconcile_cron_admission(&config, id).await {+ self.fences.retire(id.as_str(), grant.epoch);+ profile_lease::release_all(self, vec![(id.clone(), grant)]).await;+ return Err(OpenError::Storage(error));+ }if grant.previous_unclean {log::info!("[profiles] profile={id} taken over from a holder that never released it (epoch {}); recovering",diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rsindex 52e84d2d66..b4251ac3a4 100644--- a/crates/openhuman-core/src/profiles/host_tests.rs+++ b/crates/openhuman-core/src/profiles/host_tests.rs@@ -26,11 +26,7 @@ async fn provisioning_creates_the_layout_once() {let tmp = tempfile::tempdir().unwrap();let host = host(&tmp, 4, 60);let id = profile("alice");- let provisioned = host.provision(&id).await;- if let Err(error) = &provisioned {- eprintln!("profile provision error: {error}");- }- assert!(provisioned.unwrap());+ assert!(host.provision(&id).await.unwrap());assert!(!host.provision(&id).await.unwrap(),"second provision is a no-op"@@ -55,11 +51,7 @@ async fn an_open_profile_runs_under_its_own_scope() {let tmp = tempfile::tempdir().unwrap();let host = host(&tmp, 4, 60);let (a, b) = (profile("alice"), profile("bob"));- let provisioned = host.provision(&a).await;- if let Err(error) = &provisioned {- eprintln!("profile provision error: {error}");- }- provisioned.unwrap();+ host.provision(&a).await.unwrap();host.provision(&b).await.unwrap();let state_a = host.open(&a).await.unwrap();let state_b = host.open(&b).await.unwrap();@@ -380,11 +372,7 @@ async fn the_operators_iteration_cap_binds_every_profile_whatever_its_config_saysaas.max_tool_iterations = Some(4);let host = ProfileHost::new(saas, CoreContext::for_test(DomainSet::full(), None));let id = profile("alice");- let provisioned = host.provision(&id).await;- if let Err(error) = &provisioned {- eprintln!("enforced profile provision error: {error}");- }- provisioned.unwrap();+ host.provision(&id).await.unwrap();let layout = ProfileLayout::new(tmp.path(), &id);std::fs::write(&layout.config_path,diff --git a/crates/openhuman-core/src/profiles/lifecycle.rs b/crates/openhuman-core/src/profiles/lifecycle.rsindex 10e5d4e824..0e34ff4c6d 100644--- a/crates/openhuman-core/src/profiles/lifecycle.rs+++ b/crates/openhuman-core/src/profiles/lifecycle.rs@@ -126,14 +126,14 @@ impl ProfileHost {return Ok(false);}let grant = self.acquire_for_lifecycle(id, "provision").await?;- let created = self.provision_leased(id).await;+ let created = self.provision_leased(id, &grant).await;profile_lease::release_all(self, vec![(id.clone(), grant)]).await;let created = created?;log::info!("[profiles] provisioned profile={id} created={created}");Ok(created)}- async fn provision_leased(&self, id: &ProfileId) -> Result<bool, String> {+ async fn provision_leased(&self, id: &ProfileId, grant: &LeaseGrant) -> Result<bool, String> {// Again under the lease: another node may have provisioned it since.if self.registry.get(id).await?.is_some() {return Ok(false);@@ -141,7 +141,19 @@ impl ProfileHost {let layout = self.layout_of(id);create_dirs(&layout)?;let config = self.forced_config(&layout, id);- reconcile_cron_admission(&config, id).await?;+ let fence = super::fence::for_grant(+ Arc::clone(&self.leases),+ &self.node,+ id,+ grant,+ self.saas.lease_ttl(),+ );+ let anchor: Arc<dyn std::any::Any + Send + Sync> = Arc::new(());+ fence.anchor_to(Arc::downgrade(&anchor));+ self.fences.register(Arc::clone(&fence));+ let reconciled = reconcile_cron_admission(&config, id).await;+ self.fences.retire(id.as_str(), grant.epoch);+ reconciled?;let meta = ProfileMeta {profile_id: id.clone(),created_at: unix_now(),