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
feat(storage): add document import state tracking
Steven Enamakeled072f2a3a3e
diff --git a/crates/openhuman-core/src/storage/documents.rs b/crates/openhuman-core/src/storage/documents.rsindex b337bd68c3..f23f243805 100644--- a/crates/openhuman-core/src/storage/documents.rs+++ b/crates/openhuman-core/src/storage/documents.rs@@ -79,6 +79,7 @@ struct Origin {/// One domain's document store under one storage scope.#[derive(Clone)]pub struct Repo {+ scoped: ScopedStorage,docs: Arc<dyn DocumentStore>,domain: &'static str,collections: fn() -> Vec<CollectionSpec>,@@ -152,6 +153,7 @@ impl Repo {collections: fn() -> Vec<CollectionSpec>,) -> Self {Self {+ scoped: scoped.clone(),docs: Arc::clone(scoped.documents()),domain,collections,@@ -159,6 +161,12 @@ impl Repo {}}+ /// The scoped storage this repo was opened on, for the primitives that+ /// bind to a whole scope (`tsd.migrations`).+ pub fn scoped(&self) -> &ScopedStorage {+ &self.scoped+ }+/// Runs `f` once per process for this repo's backend instance, scope and/// `key` (a legacy import keyed by its source path). Calls are serialized,/// and the run is recorded only when `f` succeeds, so a failed one isdiff --git a/crates/openhuman-core/src/storage/import_state.rs b/crates/openhuman-core/src/storage/import_state.rsindex 5668854f74..d49f2b1b84 100644--- a/crates/openhuman-core/src/storage/import_state.rs+++ b/crates/openhuman-core/src/storage/import_state.rs@@ -25,7 +25,7 @@use std::sync::Arc;use std::time::{Duration, Instant};-use anyhow::{anyhow, Result};+use anyhow::Result;use tinystoragedrivers::schema::Migrations;use tinystoragedrivers::{Capability, DocumentStore, DocumentStoreExt, Leases, Query, ScopedStorage, StorageError,@@ -182,7 +182,7 @@ pub fn with_claim_at<T>(.await})?};- let Some(mut held) = acquired else {+ let Some(held) = acquired else {tracing::debug!(target: "openhuman::storage_import",owner,@@ -214,7 +214,7 @@ pub fn with_claim_at<T>(.await});match renewed {- Ok(Some(next)) => held = next,+ Ok(Some(_)) => {}Ok(None) | Err(_) => {tracing::warn!(target: "openhuman::storage_import",@@ -224,12 +224,11 @@ pub fn with_claim_at<T>(}}}- held.epoch})};let result = body();let _ = stop_tx.send(());- let epoch = heartbeat.join().unwrap_or(epoch);+ let _ = heartbeat.join();let released = {let key = lease_key(&claim_owner, &claim_key);repo.run(move |docs| async move {@@ -295,11 +294,6 @@ pub async fn migrate_legacy_markers(scoped: &ScopedStorage) -> Result<usize, StoOk(moved)}-/// A claim failure as an `anyhow` error naming the step.-pub fn claim_error(step: &str, error: impl std::fmt::Display) -> anyhow::Error {- anyhow!("{LOG_PREFIX} claim {step}: {error}")-}-#[cfg(test)]#[path = "import_state_tests.rs"]mod tests;