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(config): track source anchor on config snapshots
Steven Enamakel1fc196612059
diff --git a/crates/openhuman-core/src/config/schema/load/source/document.rs b/crates/openhuman-core/src/config/schema/load/source/document.rsindex 634b113bef..236355e5d8 100644--- a/crates/openhuman-core/src/config/schema/load/source/document.rs+++ b/crates/openhuman-core/src/config/schema/load/source/document.rs@@ -8,7 +8,7 @@ use serde_json::json;use tinystoragedrivers::secrets::{crypto, KeyProvider};use tinystoragedrivers::{CollectionSpec, DocumentStore, Precondition};-use super::{apply_bootstrap, strip_bootstrap, ConfigRead, ConfigSource, FileConfigSource};+use super::{apply_bootstrap, strip_bootstrap, ConfigRead, ConfigSource, ConfigSourceAnchor, FileConfigSource};use crate::storage::Scope;use super::storage_schema::document_id;@@ -37,6 +37,7 @@ pub(crate) struct DocumentConfigSource {keys: Arc<dyn KeyProvider>,file: FileConfigSource,observed_version: Mutex<Option<tinystoragedrivers::Version>>,+ backend_identity: usize,}impl DocumentConfigSource {@@ -45,6 +46,7 @@ impl DocumentConfigSource {scope: Scope,keys: Arc<dyn KeyProvider>,file: FileConfigSource,+ backend_identity: usize,) -> Self {Self {docs,@@ -52,6 +54,7 @@ impl DocumentConfigSource {keys,file,observed_version: Mutex::new(None),+ backend_identity,}}@@ -135,6 +138,14 @@ impl ConfigSource for DocumentConfigSource {"document"}+ fn anchor(&self) -> ConfigSourceAnchor {+ ConfigSourceAnchor::Document {+ backend: self.backend_identity,+ scope: self.scope.as_str().to_owned(),+ id: document_id(self.scope.as_str()).expect("validated scope has a document id"),+ }+ }+fn encrypts_body(&self) -> bool {true}@@ -162,7 +173,7 @@ impl ConfigSource for DocumentConfigSource {tracing::debug!(scope = %self.scope.as_str(), "[config] no config document; reading the file");let read = self.file.read().await?;*self.observed_version.lock().unwrap() = None;- return Ok(read);+ return Ok(ConfigRead { source_anchor: self.anchor(), ..read });};// Bootstrap tables come from the file, whatever the document says.// Through the file source, so its corruption recovery (a `.bak`, a@@ -184,6 +195,7 @@ impl ConfigSource for DocumentConfigSource {recovered: false,from_document: true,document_version: Some(document_version),+ source_anchor: self.anchor(),};*self.observed_version.lock().unwrap() = Some(document_version);Ok(read)diff --git a/crates/openhuman-core/src/config/schema/load/source/file.rs b/crates/openhuman-core/src/config/schema/load/source/file.rsindex 0e0909ce29..cba87670f0 100644--- a/crates/openhuman-core/src/config/schema/load/source/file.rs+++ b/crates/openhuman-core/src/config/schema/load/source/file.rs@@ -40,6 +40,10 @@ impl ConfigSource for FileConfigSource {"file"}+ fn anchor(&self) -> super::ConfigSourceAnchor {+ super::ConfigSourceAnchor::File(self.path.clone())+ }+async fn exists(&self) -> Result<bool> {fs::try_exists(&self.path).await@@ -53,6 +57,7 @@ impl ConfigSource for FileConfigSource {recovered,from_document: false,document_version: None,+ source_anchor: self.anchor(),})}diff --git a/crates/openhuman-core/src/config/schema/load/source/mod.rs b/crates/openhuman-core/src/config/schema/load/source/mod.rsindex 10bc5aaa8b..f0ec5d5fdb 100644--- a/crates/openhuman-core/src/config/schema/load/source/mod.rs+++ b/crates/openhuman-core/src/config/schema/load/source/mod.rs@@ -55,6 +55,14 @@ pub(crate) struct ConfigRead {/// no document yet: that text keeps the file's corruption recovery.pub from_document: bool,pub document_version: Option<tinystoragedrivers::Version>,+ pub source_anchor: ConfigSourceAnchor,+}++/// Identity of the exact persistence target a config snapshot was read from.+#[derive(Debug, Clone, PartialEq, Eq)]+pub(crate) enum ConfigSourceAnchor {+ File(std::path::PathBuf),+ Document { backend: usize, scope: String, id: String },}/// A place a config's TOML text is read from and written to.@@ -62,6 +70,7 @@ pub(crate) struct ConfigRead {pub(crate) trait ConfigSource: Send + Sync {/// A short, stable name for logs: `file` or `document`.fn label(&self) -> &'static str;+ fn anchor(&self) -> ConfigSourceAnchor;/// Whether the source holds a config at all.///@@ -125,6 +134,7 @@ pub(crate) fn for_config(config_path: &Path) -> Result<Box<dyn ConfigSource>> {forced.scope,forced.keys,file,+ std::sync::Arc::as_ptr(forced.scoped.documents()) as *const () as usize,)));}if !crate::storage::installed_is_shared() {@@ -143,6 +153,7 @@ pub(crate) fn for_config(config_path: &Path) -> Result<Box<dyn ConfigSource>> {scope,keys,file,+ crate::storage::installed().map_or(0, |backend| Arc::as_ptr(&backend) as *const () as usize),)))}Ok(None) => Ok(Box::new(file)),diff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rsindex 4febd8d8f0..997c5c0c92 100644--- a/crates/openhuman-core/src/config/schema/types/config.rs+++ b/crates/openhuman-core/src/config/schema/types/config.rs@@ -57,7 +57,10 @@ pub struct Config {/// Revision of the shared config document this snapshot was loaded from.#[serde(skip)]#[schemars(skip)]- pub(crate) document_version: std::sync::Mutex<Option<tinystoragedrivers::Version>>,+ pub(crate) document_snapshot: std::sync::Mutex<super::config_snapshot::DocumentSnapshot>,+ #[serde(skip)]+ #[schemars(skip)]+ pub(crate) context_snapshot: Option<std::sync::Weak<std::sync::Mutex<Config>>>,/// Immutable operator provider binding, absent from the user wire format.#[serde(skip)]#[schemars(skip)]