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
chore: files changed crates/openhuman-core/src/modules/storage_import_support.rs,crates/openhuman-co
Steven Enamakele8f93206134c
diff --git a/crates/openhuman-core/src/modules/storage_import_support.rs b/crates/openhuman-core/src/modules/storage_import_support.rsindex aef6ce6f1a..768f4d92c5 100644--- a/crates/openhuman-core/src/modules/storage_import_support.rs+++ b/crates/openhuman-core/src/modules/storage_import_support.rs@@ -32,17 +32,17 @@ pub(super) fn module_scope(Ok(Some(scoped))}-/// Runs one module import under a durable host claim. The marker check, every-/// payload write performed by `body`, and the completion marker are all made-/// through a storage handle bound to the same claim condition. A lost claim-/// therefore prevents late payload or completion writes.+/// Runs one module import under a durable host claim. The body receives a+/// storage handle bound to the same claim condition and must use it for both+/// payload writes and the completion marker. A lost claim therefore prevents+/// late payload or completion writes.pub(super) fn with_module_claim<T>(ctx: &crate::core::runtime::DispatchCtx,module_id: &str,marker_kind: &str,marker_id: &str,body: impl FnOnce(Storage) -> Result<T> + Send + 'static,-) -> Result<Option<ClaimedImport<T>>>+) -> Result<Option<T>>whereT: Send + 'static,{@@ -57,14 +57,12 @@ where"storage_import",crate::storage::import_state::collection_specs,)?;- let marker_kind = marker_kind.to_owned();- let marker_id = marker_id.to_owned();let claim_backend = Arc::clone(&backend);let claim_scope = scope.clone();let claimed = crate::storage::import_state::with_claim(&repo,crate::storage::import_state::HOST_OWNER,- &crate::storage::import_state::step_id(&marker_kind, &marker_id),+ &crate::storage::import_state::step_id(marker_kind, marker_id),move |condition| {let scoped_backend = crate::storage::import_state::backend_with_condition(claim_backend,@@ -73,30 +71,12 @@ wherelet scoped = scoped_backend.for_scope(&claim_scope).map_err(|error| anyhow!("open claim-bound module storage: {:?}", error.kind()))?;- crate::storage::block_on_anyhow(async move {- if crate::storage::import_state::host_import_done(&scoped, &marker_kind, &marker_id)- .await?- {- return Ok(ClaimedImport::AlreadyDone);- }- let result = body(scoped.clone())?;- crate::storage::import_state::host_import_mark(&scoped, &marker_kind, &marker_id)- .await?;- Ok(ClaimedImport::Imported(result))- })+ body(scoped)},)?;Ok(claimed)}-/// Outcome of a claim-protected import attempt.-pub(super) enum ClaimedImport<T> {- /// The completion marker already existed after acquiring the claim.- AlreadyDone,- /// The payload was imported and the completion marker was committed.- Imported(T),-}-/// A stable marker id for one source path: `<prefix>@<16 hex of sha256(path)>`.pub(super) fn marker_id(prefix: &str, source: &Path) -> String {let digest = sha2::Sha256::digest(source.as_os_str().as_encoded_bytes());diff --git a/crates/openhuman-core/src/modules/storage_import_tinybox.rs b/crates/openhuman-core/src/modules/storage_import_tinybox.rsindex 0f495ec8f6..bd29a4af7d 100644--- a/crates/openhuman-core/src/modules/storage_import_tinybox.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinybox.rs@@ -63,13 +63,10 @@ pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Resupport::with_module_claim(ctx, MODULE_ID, MARKER_COLLECTION, &marker, move |scoped| {crate::storage::block_on_anyhow(async move { import_into(&scoped, &base).await })})?;- let Some(result) = result else {+ let Some(outcome) = result else {return Ok(Outcome::NoBackend);};- Ok(match result {- support::ClaimedImport::AlreadyDone => Outcome::AlreadyDone,- support::ClaimedImport::Imported(outcome) => outcome,- })+ Ok(outcome)}async fn import_into(scoped: &Storage, base: &Path) -> Result<Outcome> {diff --git a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rsindex 9aba7f1e39..b89b97159b 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyconnectors.rs@@ -76,13 +76,10 @@ pub(crate) async fn import_legacy(ctx: &DispatchCtx, state_dir: &Path) -> Resultimport_into(&ctx_for_read, &scoped, &state_dir).await})})?;- let Some(result) = result else {+ let Some(outcome) = result else {return Ok(Outcome::NoBackend);};- Ok(match result {- support::ClaimedImport::AlreadyDone => Outcome::AlreadyDone,- support::ClaimedImport::Imported(outcome) => outcome,- })+ Ok(outcome)}/// A preference file: the toolkit key and its bare JSON value.diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rsindex 0f28a3a79c..a5c9b35a13 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice.rs@@ -84,13 +84,10 @@ pub(crate) async fn import_legacy(import_into(&ctx_for_read, &scoped, &root, ttl, SystemTime::now()).await})})?;- let Some(result) = result else {+ let Some(outcome) = result else {return Ok(Outcome::NoBackend);};- Ok(match result {- support::ClaimedImport::AlreadyDone => Outcome::AlreadyDone,- support::ClaimedImport::Imported(outcome) => outcome,- })+ Ok(outcome)}/// One readable original: its token, text and age.diff --git a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rsindex 9d83a8ab42..5a63d53501 100644--- a/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinyjuice_savings.rs@@ -72,13 +72,10 @@ wherelet result = support::with_module_claim(ctx, MODULE_ID, MARKER_KIND, &marker, move |scoped| {crate::storage::block_on_anyhow(async move { import_into(&scoped, &file, adopt).await })})?;- let Some(result) = result else {+ let Some(outcome) = result else {return Ok(Outcome::NoBackend);};- Ok(match result {- support::ClaimedImport::AlreadyDone => Outcome::AlreadyDone,- support::ClaimedImport::Imported(outcome) => outcome,- })+ Ok(outcome)}async fn import_into<F, Fut>(scoped: &Storage, file: &Path, adopt: F) -> Result<Outcome>diff --git a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs b/crates/openhuman-core/src/modules/storage_import_tinywallet.rsindex f7a0da3c83..a4637ceb36 100644--- a/crates/openhuman-core/src/modules/storage_import_tinywallet.rs+++ b/crates/openhuman-core/src/modules/storage_import_tinywallet.rs@@ -63,13 +63,10 @@ pub(crate) async fn import_legacy(ctx: &DispatchCtx, workspace_dir: &Path) -> Reimport_into(&ctx_for_read, &scoped, &workspace_dir).await})})?;- let Some(result) = result else {+ let Some(outcome) = result else {return Ok(Outcome::NoBackend);};- Ok(match result {- support::ClaimedImport::AlreadyDone => Outcome::AlreadyDone,- support::ClaimedImport::Imported(outcome) => outcome,- })+ Ok(outcome)}async fn import_into(ctx: &DispatchCtx, scoped: &Storage, workspace_dir: &Path) -> Result<Outcome> {