Skip to content

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

refactor(core): use ? operator for early returns in owner lookups

Steven Enamakel04e37933ddd4
diff --git a/crates/openhuman-core/src/desktop/notifications/bus.rs b/crates/openhuman-core/src/desktop/notifications/bus.rs
index d8ce148038..4fc100db80 100644
--- a/crates/openhuman-core/src/desktop/notifications/bus.rs
+++ b/crates/openhuman-core/src/desktop/notifications/bus.rs
@@ -477,9 +477,8 @@ async fn event_owner(config: &crate::config::Config, event: &DomainEvent) -> Opt
let DomainEvent::CronJobCompleted { job_id, .. } = event else {
return None;
};
- if crate::storage::installed().is_none() {
- return None;
- }
+ // No backend: every record is `local`.
+ crate::storage::installed()?;
crate::storage::agents::find_owner("notification owner", || async {
crate::cron::get_job(config, job_id).is_ok()
})
diff --git a/crates/openhuman-core/src/flows/bus/owner.rs b/crates/openhuman-core/src/flows/bus/owner.rs
index 702a3bc228..34dfe1f83e 100644
--- a/crates/openhuman-core/src/flows/bus/owner.rs
+++ b/crates/openhuman-core/src/flows/bus/owner.rs
@@ -18,9 +18,8 @@ static OWNERS: LazyLock<Mutex<HashMap<String, Option<String>>>> = LazyLock::new(
/// The agent `flow_id` belongs to: `None` for `local`, or when no scope has
/// the flow (the handler then reports the flow as unknown, as before).
pub(super) async fn flow_owner(config: &Config, flow_id: &str) -> Option<String> {
- if crate::storage::installed().is_none() {
- return None;
- }
+ // No backend: every record is `local`.
+ crate::storage::installed()?;
if let Some(owner) = OWNERS
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
@@ -33,9 +32,7 @@ pub(super) async fn flow_owner(config: &Config, flow_id: &str) -> Option<String>
matches!(crate::flows::store::get_flow(config, flow_id), Ok(Some(_)))
})
.await;
- let Some(owner) = found else {
- return None;
- };
+ let owner = found?;
tracing::debug!(
target: "flows",
%flow_id,