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
refactor(profiles): simplify lease renewal to use grants snapshot
Steven Enamakelbeab4dd0a515
diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rsindex 8989401409..e24f80b1bb 100644--- a/crates/openhuman-core/src/profiles/host.rs+++ b/crates/openhuman-core/src/profiles/host.rs@@ -538,11 +538,6 @@ impl ProfileHost {.collect()}- /// The current grant of `id`, when it is open here.- pub(crate) fn grant_of(&self, id: &ProfileId) -> Option<LeaseGrant> {- self.lock().get(id).map(|slot| slot.grant.clone())- }-/// Replace `id`'s grant `old` with `renewed`, unless the slot moved on/// (closed, or re-opened under a newer grant) meanwhile.pub(crate) fn store_grant(&self, id: &ProfileId, old: &LeaseGrant, renewed: LeaseGrant) {diff --git a/crates/openhuman-core/src/profiles/lease.rs b/crates/openhuman-core/src/profiles/lease.rsindex 00b0f07bcd..a45ccbe0b2 100644--- a/crates/openhuman-core/src/profiles/lease.rs+++ b/crates/openhuman-core/src/profiles/lease.rs@@ -147,25 +147,11 @@ pub struct HeartbeatReport {/// is gone (see the module docs).pub async fn renew_once(host: &ProfileHost) -> HeartbeatReport {let mut report = HeartbeatReport::default();- for (id, _) in host.grants() {- // Renew and store the new grant under the host gate, which every- // close-and-release holds: a renewal supersedes the slot's grant in- // the lease store, so a release that took the slot's grant between- // the two would carry the superseded one and fail as lost. Read the- // grant again under the gate, since the slot may have moved on.- let gate = host.gate.lock().await;- let Some(grant) = host.grant_of(&id) else {- log::debug!("[profiles][lease] profile={id} closed before its renewal");- continue;- };+ for (id, grant) in host.grants() {let now = now_ms();- let outcome = host.leases().renew(&grant, now).await;- if let Ok(renewed) = &outcome {- host.store_grant(&id, &grant, renewed.clone());- }- drop(gate);- match outcome {- Ok(_) => {+ match host.leases().renew(&grant, now).await {+ Ok(renewed) => {+ host.store_grant(&id, &grant, renewed);report.renewed += 1;}Err(LeaseError::Lost) => {