Skip to content

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

chore(store): add missing store modules

Steven Enamakel4c0895481b35
diff --git a/crates/openhuman-core/src/desktop/notifications/store.rs b/crates/openhuman-core/src/desktop/notifications/store.rs
index 48edf771cf..a9dc1c08e3 100644
--- a/crates/openhuman-core/src/desktop/notifications/store.rs
+++ b/crates/openhuman-core/src/desktop/notifications/store.rs
@@ -109,7 +109,7 @@ fn with_connection<T>(config: &Config, f: impl FnOnce(&Connection) -> Result<T>)
/// Persist a new notification to the store.
pub fn insert(config: &Config, n: &IntegrationNotification) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.insert(n, false).map(|_| ());
}
with_connection(config, |conn| {
@@ -150,7 +150,7 @@ pub fn insert(config: &Config, n: &IntegrationNotification) -> Result<()> {
/// event is ignored (no duplicates). Returns `true` when a new row was written,
/// `false` when an event with the same id already existed.
pub fn insert_core_notification(config: &Config, event: &CoreNotificationEvent) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.insert_core_notification(&config.workspace_dir.to_string_lossy(), event);
}
with_connection(config, |conn| {
@@ -181,7 +181,7 @@ pub fn list_core_notifications(
only_unread: bool,
limit: usize,
) -> Result<Vec<CoreNotificationEvent>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list_core_notifications(
&config.workspace_dir.to_string_lossy(),
only_unread,
@@ -223,7 +223,7 @@ pub fn list_core_notifications(
/// Mark a persisted core notification as read so it isn't re-surfaced on the
/// next sync-down. Returns `true` when a row was updated.
pub fn mark_core_notification_read(config: &Config, id: &str) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.mark_core_notification_read(&config.workspace_dir.to_string_lossy(), id);
}
with_connection(config, |conn| {
@@ -239,7 +239,7 @@ pub fn mark_core_notification_read(config: &Config, id: &str) -> Result<bool> {
/// Count unread persisted core notifications.
pub fn unread_core_notification_count(config: &Config) -> Result<i64> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.unread_core_notification_count(&config.workspace_dir.to_string_lossy());
}
with_connection(config, |conn| {
@@ -258,7 +258,7 @@ pub fn unread_core_notification_count(config: &Config) -> Result<i64> {
///
/// Returns `true` when inserted, `false` when skipped as duplicate.
pub fn insert_if_not_recent(config: &Config, n: &IntegrationNotification) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.insert(n, true);
}
with_connection(config, |conn| {
@@ -338,7 +338,7 @@ pub fn list(
provider_filter: Option<&str>,
min_score: Option<f32>,
) -> Result<Vec<IntegrationNotification>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list(limit, offset, provider_filter, min_score);
}
with_connection(config, |conn| {
@@ -388,7 +388,7 @@ pub fn update_triage(
action: &str,
reason: &str,
) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.update_triage(id, score, action, reason).map(|found| {
if !found {
tracing::warn!(id = %id, action = %action, "[notifications::store] update_triage matched no rows");
@@ -428,7 +428,7 @@ pub fn update_triage(
/// Transition a notification from `unread` to `read`.
pub fn mark_read(config: &Config, id: &str) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.set_status(id, NotificationStatus::Read).map(|found| {
if !found {
tracing::warn!(id = %id, "[notifications::store] mark_read matched no rows");
@@ -456,7 +456,7 @@ pub fn mark_read(config: &Config, id: &str) -> Result<()> {
/// Count unread notifications.
pub fn unread_count(config: &Config) -> Result<i64> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.unread_count();
}
with_connection(config, |conn| {
@@ -480,7 +480,7 @@ pub fn exists_recent(
title: &str,
body: &str,
) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.exists_recent(provider, account_id, title, body);
}
with_connection(config, |conn| {
@@ -511,7 +511,7 @@ pub fn exists_recent(
///
/// Returns `true` when at least one row matched and was updated.
pub fn mark_dismissed(config: &Config, id: &str) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.set_status(id, NotificationStatus::Dismissed);
}
with_connection(config, |conn| {
@@ -535,7 +535,7 @@ pub fn mark_dismissed(config: &Config, id: &str) -> Result<bool> {
///
/// Returns `true` when at least one row matched and was updated.
pub fn mark_acted(config: &Config, id: &str) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.set_status(id, NotificationStatus::Acted);
}
with_connection(config, |conn| {
@@ -557,7 +557,7 @@ pub fn mark_acted(config: &Config, id: &str) -> Result<bool> {
/// Return aggregate statistics for the notification intelligence pipeline.
pub fn stats(config: &Config) -> Result<super::types::NotificationStats> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.stats();
}
use std::collections::HashMap;
@@ -644,7 +644,7 @@ pub fn stats(config: &Config) -> Result<super::types::NotificationStats> {
/// Upsert provider-level notification settings.
pub fn upsert_settings(config: &Config, settings: &NotificationSettings) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.upsert_settings(settings);
}
with_connection(config, |conn| {
@@ -669,7 +669,7 @@ pub fn upsert_settings(config: &Config, settings: &NotificationSettings) -> Resu
/// Read provider-level notification settings with defaults when missing.
pub fn get_settings(config: &Config, provider: &str) -> Result<NotificationSettings> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.get_settings(provider);
}
with_connection(config, |conn| {
diff --git a/crates/openhuman-core/src/integrations/task_sources/store.rs b/crates/openhuman-core/src/integrations/task_sources/store.rs
index 866040a52c..38eb584222 100644
--- a/crates/openhuman-core/src/integrations/task_sources/store.rs
+++ b/crates/openhuman-core/src/integrations/task_sources/store.rs
@@ -90,7 +90,7 @@ pub fn add_source(
let filter_json = serde_json::to_string(&filter).context("serialize task source filter")?;
let target_json = serde_json::to_string(&target).context("serialize task source target")?;
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.add_source(&TaskSource {
id,
provider,
@@ -136,7 +136,7 @@ pub fn add_source(
}
pub fn get_source(config: &Config, id: &str) -> Result<TaskSource> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.get_source(id);
}
with_connection(config, |conn| {
@@ -151,7 +151,7 @@ pub fn get_source(config: &Config, id: &str) -> Result<TaskSource> {
}
pub fn list_sources(config: &Config) -> Result<Vec<TaskSource>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list_sources();
}
with_connection(config, |conn| {
@@ -214,7 +214,7 @@ pub(super) fn apply_patch(source: &mut TaskSource, patch: TaskSourcePatch) -> Re
/// a SQL `UPDATE … RETURNING` pattern. The document store applies the patch
/// under compare-and-swap, so it has no such window.
pub fn update_source(config: &Config, id: &str, patch: TaskSourcePatch) -> Result<TaskSource> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.update_source(id, patch);
}
let mut source = get_source(config, id)?;
@@ -250,7 +250,7 @@ pub fn update_source(config: &Config, id: &str, patch: TaskSourcePatch) -> Resul
}
pub fn remove_source(config: &Config, id: &str) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.remove_source(id);
}
let changed = with_connection(config, |conn| {
@@ -271,7 +271,7 @@ pub fn record_fetch(
reason: FetchReason,
status: &str,
) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.record_fetch(id, finished_at, reason, status);
}
let line = format!("{}: {status}", reason.as_str());
@@ -294,7 +294,7 @@ pub fn is_ingested(
external_id: &str,
hash: &str,
) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.is_ingested(source_id, external_id, hash);
}
with_connection(config, |conn| {
@@ -318,7 +318,7 @@ pub fn is_ingested(
/// todo board, the ledger row itself is the record. The column stays so
/// older databases open unchanged.
pub fn mark_ingested(config: &Config, source_id: &str, task: &NormalizedTask) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.mark_ingested(source_id, task);
}
let hash = content_hash(task);
@@ -345,7 +345,7 @@ pub fn mark_ingested(config: &Config, source_id: &str, task: &NormalizedTask) ->
/// content hash. The pipeline uses it to tell an edited upstream task from a
/// brand-new one in its logs.
pub fn was_ingested(config: &Config, source_id: &str, external_id: &str) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.was_ingested(source_id, external_id);
}
with_connection(config, |conn| {
@@ -359,7 +359,7 @@ pub fn was_ingested(config: &Config, source_id: &str, external_id: &str) -> Resu
/// Return ingested task ids for one source. Used by reconciliation to prune
/// ledger rows that no longer match the upstream source/filter.
pub fn list_ingested_refs(config: &Config, source_id: &str) -> Result<Vec<IngestedTaskRef>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list_ingested_refs(source_id);
}
with_connection(config, |conn| {
@@ -383,7 +383,7 @@ pub fn list_ingested_refs(config: &Config, source_id: &str) -> Result<Vec<Ingest
/// Delete one ingested ledger row after its board card has been reconciled.
pub fn remove_ingested(config: &Config, source_id: &str, external_id: &str) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.remove_ingested(source_id, external_id);
}
let changed = with_connection(config, |conn| {
@@ -402,7 +402,7 @@ pub fn list_ingested(
source_id: &str,
limit: usize,
) -> Result<Vec<NormalizedTask>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list_ingested(source_id, limit);
}
// Floor of 1: a caller passing `limit = 0` still gets at least one row
@@ -430,7 +430,7 @@ pub fn list_ingested(
/// Delete every task source (+ cascade ingested rows). Used by the E2E
/// `test_reset` RPC.
pub fn clear_all(config: &Config) -> Result<usize> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.clear_all();
}
with_connection(config, |conn| {
diff --git a/crates/openhuman-core/src/security/approval/store.rs b/crates/openhuman-core/src/security/approval/store.rs
index 81e467a169..cc94f8fffd 100644
--- a/crates/openhuman-core/src/security/approval/store.rs
+++ b/crates/openhuman-core/src/security/approval/store.rs
@@ -245,7 +245,7 @@ fn with_connection<T>(config: &Config, f: impl FnOnce(&Connection) -> Result<T>)
/// internal correlation only and is never re-exposed on
/// [`PendingApproval`] (see that type's doc-comment).
pub fn insert_pending(config: &Config, pending: &PendingApproval, session_id: &str) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.insert_pending(pending, session_id);
}
with_connection(config, |conn| {
@@ -291,7 +291,7 @@ pub fn insert_pending(config: &Config, pending: &PendingApproval, session_id: &s
/// (`decided_at` + `decision`) without leaving expired rows pending
/// forever.
pub fn expire_stale(config: &Config) -> Result<usize> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
let expired = docs.expire_stale(Utc::now())?;
publish_expired(&expired);
return Ok(expired.len());
@@ -305,7 +305,7 @@ pub fn expire_stale(config: &Config) -> Result<usize> {
/// which launch queued them. Orphan rows from prior sessions remain
/// visible until they are explicitly decided or expire.
pub fn list_pending(config: &Config) -> Result<Vec<PendingApproval>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
publish_expired(&docs.expire_stale(Utc::now())?);
return docs.list_pending();
}
@@ -338,7 +338,7 @@ pub fn list_pending(config: &Config) -> Result<Vec<PendingApproval>> {
/// where the TTL elapses concurrently with a committed approval
/// (CodeRabbit review on PR #2367).
pub fn get_decision(config: &Config, request_id: &str) -> Result<Option<ApprovalDecision>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.get_decision(request_id);
}
with_connection(config, |conn| {
@@ -397,7 +397,7 @@ pub fn decide(
request_id: &str,
decision: ApprovalDecision,
) -> Result<Option<PendingApproval>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
publish_expired(&docs.expire_stale(Utc::now())?);
return docs.decide(request_id, decision);
}
@@ -457,7 +457,7 @@ pub fn record_execution(
outcome: ExecutionOutcome,
error: Option<&str>,
) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.record_execution(request_id, outcome, error);
}
with_connection(config, |conn| {
@@ -505,7 +505,7 @@ pub fn record_execution(
/// List recently decided approval rows for durable audit views.
pub fn list_recent_decisions(config: &Config, limit: usize) -> Result<Vec<ApprovalAuditEntry>> {
let limit = limit.clamp(1, 500);
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list_recent_decisions(limit);
}
with_connection(config, |conn| {
@@ -533,7 +533,7 @@ pub fn list_recent_decisions(config: &Config, limit: usize) -> Result<Vec<Approv
/// Drop all rows owned by `session_id` — called when the gate detects
/// a session changeover so stale parked rows do not accumulate.
pub fn purge_session(config: &Config, session_id: &str) -> Result<usize> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.purge_session(session_id);
}
with_connection(config, |conn| {
diff --git a/crates/openhuman-core/src/security/approval/store_agent.rs b/crates/openhuman-core/src/security/approval/store_agent.rs
index 89a9923ff6..2dabb76630 100644
--- a/crates/openhuman-core/src/security/approval/store_agent.rs
+++ b/crates/openhuman-core/src/security/approval/store_agent.rs
@@ -28,7 +28,7 @@ pub fn list_pending_for_agent(
/// The agent that parked the still-undecided `request_id`: `Ok(None)` when no
/// such row exists, `Ok(Some(None))` for a row the process parked itself.
pub fn pending_agent(config: &Config, request_id: &str) -> Result<Option<Option<String>>> {
- if let Some(docs) = super::super::store_documents::current()? {
+ if let Some(docs) = super::super::store_documents::current(config)? {
return docs.pending_agent(request_id);
}
super::with_connection(config, |conn| {
diff --git a/crates/openhuman-core/src/security/approval/store_flow_trust.rs b/crates/openhuman-core/src/security/approval/store_flow_trust.rs
index 02f5edf1b3..89540d925e 100644
--- a/crates/openhuman-core/src/security/approval/store_flow_trust.rs
+++ b/crates/openhuman-core/src/security/approval/store_flow_trust.rs
@@ -32,7 +32,7 @@ pub fn record_flow_preauthorization(
tool_name: &str,
session_id: &str,
) -> Result<()> {
- if let Some(docs) = super::super::store_documents::current()? {
+ if let Some(docs) = super::super::store_documents::current(config)? {
return docs.insert_decided(
tool_name,
PREAUTHORIZATION_SUMMARY,
@@ -80,7 +80,7 @@ pub fn record_flow_preauthorization(
/// flow-origin park. `INSERT OR IGNORE` makes re-granting an already-trusted
/// pair a harmless no-op rather than a primary-key error.
pub fn insert_flow_trust(config: &Config, flow_id: &str, tool_name: &str) -> Result<()> {
- if let Some(docs) = super::super::store_documents::current()? {
+ if let Some(docs) = super::super::store_documents::current(config)? {
return docs.insert_flow_trust(flow_id, tool_name);
}
with_connection(config, |conn| {
@@ -99,7 +99,7 @@ pub fn insert_flow_trust(config: &Config, flow_id: &str, tool_name: &str) -> Res
/// save-time pre-authorization manifest (`flows_approval_manifest`) to diff
/// "what the graph needs" against "what is already granted".
pub fn list_flow_trust(config: &Config, flow_id: &str) -> Result<Vec<String>> {
- if let Some(docs) = super::super::store_documents::current()? {
+ if let Some(docs) = super::super::store_documents::current(config)? {
return docs.list_flow_trust(flow_id);
}
with_connection(config, |conn| {
@@ -127,7 +127,7 @@ pub fn delete_flow_trust(
flow_id: &str,
tool_names: Option<&[String]>,
) -> Result<usize> {
- if let Some(docs) = super::super::store_documents::current()? {
+ if let Some(docs) = super::super::store_documents::current(config)? {
return docs.delete_flow_trust(flow_id, tool_names);
}
with_connection(config, |conn| {
@@ -160,7 +160,7 @@ pub fn delete_flow_trust(
/// this flow" trust. Consulted by [`super::gate::ApprovalGate::intercept_audited`]
/// before parking a `Workflow`-origin tool call.
pub fn is_flow_tool_trusted(config: &Config, flow_id: &str, tool_name: &str) -> Result<bool> {
- if let Some(docs) = super::super::store_documents::current()? {
+ if let Some(docs) = super::super::store_documents::current(config)? {
return docs.is_flow_tool_trusted(flow_id, tool_name);
}
with_connection(config, |conn| {
diff --git a/crates/openhuman-core/src/security/devices/store.rs b/crates/openhuman-core/src/security/devices/store.rs
index e5bba9dbd1..326f1ede3c 100644
--- a/crates/openhuman-core/src/security/devices/store.rs
+++ b/crates/openhuman-core/src/security/devices/store.rs
@@ -27,7 +27,7 @@ pub fn insert_device(
device_pubkey: &str,
core_session_token_hash: &str,
) -> Result<PairedDevice> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.insert_device(channel_id, label, device_pubkey, core_session_token_hash);
}
let now = Utc::now().to_rfc3339();
@@ -53,7 +53,7 @@ pub fn insert_device(
/// Update `last_seen_at` for a device (called on `tunnel:peer-status` online events).
pub fn touch_device(config: &Config, channel_id: &str) -> Result<()> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.touch_device(channel_id);
}
let now = Utc::now().to_rfc3339();
@@ -69,7 +69,7 @@ pub fn touch_device(config: &Config, channel_id: &str) -> Result<()> {
/// Mark a device as revoked (soft delete).
pub fn revoke_device(config: &Config, channel_id: &str) -> Result<bool> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.revoke_device(channel_id);
}
let rows = with_connection(config, |conn| {
@@ -84,7 +84,7 @@ pub fn revoke_device(config: &Config, channel_id: &str) -> Result<bool> {
/// Load a single paired device by channel_id (returns None if not found).
pub fn get_device(config: &Config, channel_id: &str) -> Result<Option<PairedDevice>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.get_device(channel_id);
}
with_connection(config, |conn| {
@@ -99,7 +99,7 @@ pub fn get_device(config: &Config, channel_id: &str) -> Result<Option<PairedDevi
/// List all non-revoked paired devices ordered by creation time.
pub fn list_devices(config: &Config) -> Result<Vec<PairedDevice>> {
- if let Some(docs) = super::store_documents::current()? {
+ if let Some(docs) = super::store_documents::current(config)? {
return docs.list_devices();
}
with_connection(config, |conn| {