Skip to content

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

refactor(config): remove conflict refresh path from config save

Steven Enamakela8f5cf4605a2
diff --git a/crates/openhuman-core/src/config/schema/load/impl_load.rs b/crates/openhuman-core/src/config/schema/load/impl_load.rs
index c40991bc87..2a347f42d4 100644
--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs
+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs
@@ -399,8 +399,7 @@ impl Config {
(
Some(super::source::ConfigSourceAnchor::File(path)),
super::source::ConfigSourceAnchor::Document { .. }
- ) if path == &super::source::normalized_path(&self.config_path)
- && expected_snapshot.version.is_none()
+ ) if path == &self.config_path && expected_snapshot.version.is_none()
);
if update_snapshot
&& expected_snapshot.anchor.as_ref().is_some_and(|anchor| {
@@ -440,15 +439,7 @@ impl Config {
} else {
None
};
- let version = match source.write_versioned(&toml_str, expected).await {
- Ok(version) => version,
- Err(error) => {
- if is_document_conflict(&error) {
- self.refresh_context_after_conflict(&expected_snapshot).await;
- }
- return Err(error);
- }
- };
+ let version = source.write_versioned(&toml_str, expected).await?;
if !update_snapshot {
return Ok(());
}
@@ -477,55 +468,6 @@ impl Config {
Ok(())
}
-
- async fn refresh_context_after_conflict(
- &self,
- expected: &super::super::ConfigDocumentSnapshot,
- ) {
- let Some(snapshot) = self
- .context_snapshot
- .as_ref()
- .and_then(std::sync::Weak::upgrade)
- else {
- return;
- };
- let (config_path, workspace_dir, runtime) = {
- let current = snapshot.lock().unwrap();
- if *current.document_snapshot.lock().unwrap() != *expected {
- return;
- }
- (current.config_path.clone(), current.workspace_dir.clone(), current.clone())
- };
- let Ok(mut refreshed) = Self::load_from_config_path(&config_path, &workspace_dir).await
- else {
- return;
- };
- if refreshed.document_snapshot.lock().unwrap().anchor != expected.anchor {
- return;
- }
- refreshed.profile_providers = runtime.profile_providers.clone();
- refreshed.workspace_dir = runtime.workspace_dir;
- refreshed.action_dir = runtime.action_dir;
- refreshed.config_path = runtime.config_path;
- refreshed.cli_inference_snapshot = runtime.cli_inference_snapshot;
- refreshed.recovered_from_corruption = runtime.recovered_from_corruption;
- refreshed.ephemeral_route = runtime.ephemeral_route;
- refreshed.resolved_endpoints = runtime.resolved_endpoints;
- refreshed.context_snapshot = Some(std::sync::Arc::downgrade(&snapshot));
-
- let mut current = snapshot.lock().unwrap();
- if *current.document_snapshot.lock().unwrap() == *expected {
- *current = refreshed;
- }
- }
-}
-
-fn is_document_conflict(error: &anyhow::Error) -> bool {
- error.chain().any(|cause| {
- cause
- .downcast_ref::<tinystoragedrivers::StorageError>()
- .is_some_and(|error| error.kind() == tinystoragedrivers::ErrorKind::Conflict)
- })
}
impl Config {
diff --git a/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs b/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs
index db4268a805..aafbfddc46 100644
--- a/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs
+++ b/crates/openhuman-core/src/config/schema/load/source/concurrency_tests.rs
@@ -307,7 +307,7 @@ async fn a_file_snapshot_can_seed_an_absent_document_after_storage_bootstrap() {
let tmp = tempfile::tempdir().unwrap();
let path = tmp.path().join("config.toml");
let workspace = tmp.path().join("workspace");
- let mut file_config = config_at(tmp.path(), "file-seed");
+ let file_config = config_at(tmp.path(), "file-seed");
file_config.save().await.unwrap();
let mut snapshot = Config::load_from_config_path(&path, &workspace)
.await
diff --git a/crates/openhuman-core/src/config/schema/load/source/document.rs b/crates/openhuman-core/src/config/schema/load/source/document.rs
index d093547132..43831c48b0 100644
--- a/crates/openhuman-core/src/config/schema/load/source/document.rs
+++ b/crates/openhuman-core/src/config/schema/load/source/document.rs
@@ -143,7 +143,7 @@ impl ConfigSource for DocumentConfigSource {
fn anchor(&self) -> ConfigSourceAnchor {
ConfigSourceAnchor::Document {
- backend: self.backend_identity,
+ backend: self.backend_identity.clone(),
scope: self.scope.as_str().to_owned(),
id: document_id(self.scope.as_str()).expect("validated scope has a document id"),
}