Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(storage): record lease holder endpoint in local leases

Steven Enamakel87c9e985c535
diff --git a/crates/openhuman-core/src/storage/lease_local.rs b/crates/openhuman-core/src/storage/lease_local.rs
index 645578b13f..f704bc6de8 100644
--- a/crates/openhuman-core/src/storage/lease_local.rs
+++ b/crates/openhuman-core/src/storage/lease_local.rs
@@ -43,6 +43,7 @@ struct Holding {
pub struct LocalLeases {
root: PathBuf,
node: String,
+ endpoint: Option<String>,
held: Mutex<HashMap<String, Holding>>,
}
@@ -70,10 +71,19 @@ impl LocalLeases {
Self {
root: root.into(),
node: node.into(),
+ endpoint: None,
held: Mutex::new(HashMap::new()),
}
}
+ /// Names `endpoint` in the records this instance writes, so a refused
+ /// caller can be pointed at the holder.
+ #[must_use]
+ pub fn with_endpoint(mut self, endpoint: Option<String>) -> Self {
+ self.endpoint = endpoint;
+ self
+ }
+
fn held(&self) -> std::sync::MutexGuard<'_, HashMap<String, Holding>> {
self.held
.lock()
@@ -186,7 +196,7 @@ impl LeaseStore for LocalLeases {
let epoch = previous.map_or(1, |record| record.epoch.saturating_add(1));
let record = LeaseRecord {
owner: self.node.clone(),
- endpoint: None,
+ endpoint: self.endpoint.clone(),
epoch,
expires_at_ms: u64::MAX,
released: false,