Skip to content

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

fix(config): track document version on load and save

Steven Enamakelcee97ba5e75a
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 3581846693..a09a405e57 100644
--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs
+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs
@@ -162,6 +162,7 @@ pub(super) async fn parse_source_contents(
.map_err(|error| {
anyhow::anyhow!("the config document for this scope could not be parsed: {error}")
})?;
+ *config.document_version.lock().unwrap() = read.document_version;
return Ok((config, false));
}
if read_was_recovered && contents.is_empty() {
@@ -579,7 +580,9 @@ impl Config {
toml::to_string_pretty(&config_to_save).context("Failed to serialize config")?;
tracing::debug!(source = source.label(), "[config] saving config");
- source.write(&toml_str).await?;
+ let expected = *config_to_save.document_version.lock().unwrap();
+ let version = source.write(&toml_str, expected).await?;
+ *self.document_version.lock().unwrap() = version;
Ok(())
}
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 8a1c501d88..cfc6383f2c 100644
--- a/crates/openhuman-core/src/config/schema/load/source/document.rs
+++ b/crates/openhuman-core/src/config/schema/load/source/document.rs
@@ -178,7 +178,6 @@ impl ConfigSource for DocumentConfigSource {
recovered: false,
from_document: true,
document_version: Some(document_version),
- document_version: Some(document_version),
})
}