Skip to content

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

style(config): reformat long expressions to satisfy line width

Steven Enamakel03dacf9fc8e3
diff --git a/crates/openhuman-core/src/config/schema/load/context_overlay.rs b/crates/openhuman-core/src/config/schema/load/context_overlay.rs
index 3f7f7e0db3..61042f92e5 100644
--- a/crates/openhuman-core/src/config/schema/load/context_overlay.rs
+++ b/crates/openhuman-core/src/config/schema/load/context_overlay.rs
@@ -112,8 +112,14 @@ impl ConfigContextOverlay {
let mut result: Config = serde_json::from_value(value)?;
copy_runtime_bindings(fresh, &mut result);
self.runtime.apply(&mut result);
- result.runtime_state.document_snapshot =
- std::sync::Mutex::new(fresh.runtime_state.document_snapshot.lock().unwrap().clone());
+ result.runtime_state.document_snapshot = std::sync::Mutex::new(
+ fresh
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .clone(),
+ );
result.runtime_state.context_snapshot = fresh.runtime_state.context_snapshot.clone();
result.runtime_state.context_overlay = std::sync::Mutex::new(Some(Arc::new(Self {
changes: self.changes.clone(),
@@ -137,8 +143,20 @@ const PROFILE_OWNED_PATHS: &[&[&str]] = &[
];
fn same_source(parent: &Config, child: &Config) -> bool {
- let parent_anchor = parent.runtime_state.document_snapshot.lock().unwrap().anchor.clone();
- let child_anchor = child.runtime_state.document_snapshot.lock().unwrap().anchor.clone();
+ let parent_anchor = parent
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .anchor
+ .clone();
+ let child_anchor = child
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .anchor
+ .clone();
match (&parent_anchor, &child_anchor) {
(Some(parent), Some(child)) => parent == child,
(None, None) => {
diff --git a/crates/openhuman-core/src/config/schema/load/context_refresh.rs b/crates/openhuman-core/src/config/schema/load/context_refresh.rs
index 76be3a2a56..07fd9f6e18 100644
--- a/crates/openhuman-core/src/config/schema/load/context_refresh.rs
+++ b/crates/openhuman-core/src/config/schema/load/context_refresh.rs
@@ -12,7 +12,8 @@ pub(super) fn is_document_conflict(error: &anyhow::Error) -> bool {
impl Config {
pub(crate) fn bind_context_snapshot(snapshot: &std::sync::Arc<std::sync::Mutex<Config>>) {
- snapshot.lock().unwrap().runtime_state.context_snapshot = Some(std::sync::Arc::downgrade(snapshot));
+ snapshot.lock().unwrap().runtime_state.context_snapshot =
+ Some(std::sync::Arc::downgrade(snapshot));
}
pub(super) fn refresh_context_after_conflict<'a>(
@@ -21,7 +22,8 @@ impl Config {
) -> std::pin::Pin<Box<dyn std::future::Future<Output = ()> + Send + 'a>> {
Box::pin(async move {
let Some(snapshot) = self
- .runtime_state.context_snapshot
+ .runtime_state
+ .context_snapshot
.as_ref()
.and_then(std::sync::Weak::upgrade)
else {
@@ -42,10 +44,22 @@ impl Config {
else {
return;
};
- if refreshed.runtime_state.document_snapshot.lock().unwrap().anchor != expected.anchor {
+ if refreshed
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .anchor
+ != expected.anchor
+ {
return;
}
- let overlay = runtime.runtime_state.context_overlay.lock().unwrap().clone();
+ let overlay = runtime
+ .runtime_state
+ .context_overlay
+ .lock()
+ .unwrap()
+ .clone();
if let Some(overlay) = overlay {
let Ok(merged) = overlay.reapply(&refreshed) else {
return;
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 d10a45c813..93d599865c 100644
--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs
+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs
@@ -471,18 +471,25 @@ impl Config {
if !update_snapshot {
return Ok(());
}
- *self.runtime_state.document_snapshot.lock().unwrap() = super::super::ConfigDocumentSnapshot {
- version,
- anchor: Some(source_anchor.clone()),
- };
+ *self.runtime_state.document_snapshot.lock().unwrap() =
+ super::super::ConfigDocumentSnapshot {
+ version,
+ anchor: Some(source_anchor.clone()),
+ };
if let Some(snapshot) = self
- .runtime_state.context_snapshot
+ .runtime_state
+ .context_snapshot
.as_ref()
.and_then(std::sync::Weak::upgrade)
{
let mut current = snapshot.lock().unwrap();
- let current_state = current.runtime_state.document_snapshot.lock().unwrap().clone();
+ let current_state = current
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .clone();
if current_state == expected_snapshot {
let published = self.clone();
*published.runtime_state.document_snapshot.lock().unwrap() =
diff --git a/crates/openhuman-core/src/config/schema/load/parse_source.rs b/crates/openhuman-core/src/config/schema/load/parse_source.rs
index 148594c443..840941b848 100644
--- a/crates/openhuman-core/src/config/schema/load/parse_source.rs
+++ b/crates/openhuman-core/src/config/schema/load/parse_source.rs
@@ -26,24 +26,27 @@ pub(super) async fn parse_source_contents(
.map_err(|error| {
anyhow::anyhow!("the config document for this scope could not be parsed: {error}")
})?;
- *config.runtime_state.document_snapshot.lock().unwrap() = super::super::ConfigDocumentSnapshot {
- version: read.document_version,
- anchor: Some(read.source_anchor.clone()),
- };
+ *config.runtime_state.document_snapshot.lock().unwrap() =
+ super::super::ConfigDocumentSnapshot {
+ version: read.document_version,
+ anchor: Some(read.source_anchor.clone()),
+ };
return Ok((config, false));
}
if read_was_recovered && contents.is_empty() {
let config = super::branches::default_config_boxed();
- *config.runtime_state.document_snapshot.lock().unwrap() = super::super::ConfigDocumentSnapshot {
- version: read.document_version,
- anchor: Some(read.source_anchor.clone()),
- };
+ *config.runtime_state.document_snapshot.lock().unwrap() =
+ super::super::ConfigDocumentSnapshot {
+ version: read.document_version,
+ anchor: Some(read.source_anchor.clone()),
+ };
return Ok((config, true));
}
let (config, recovered) = Box::pin(parse_config_boxed(config_path, contents)).await;
- *config.runtime_state.document_snapshot.lock().unwrap() = super::super::ConfigDocumentSnapshot {
- version: read.document_version,
- anchor: Some(read.source_anchor.clone()),
- };
+ *config.runtime_state.document_snapshot.lock().unwrap() =
+ super::super::ConfigDocumentSnapshot {
+ version: read.document_version,
+ anchor: Some(read.source_anchor.clone()),
+ };
Ok((config, recovered))
}
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 007c5d6eec..66f8868cba 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
@@ -428,7 +428,12 @@ async fn config_snapshot_cannot_be_saved_into_a_different_tenant_scope() {
let config = Config::load_from_config_path(&path, &workspace)
.await
.unwrap();
- let version = config.runtime_state.document_snapshot.lock().unwrap().version;
+ let version = config
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .version;
(config, version)
};
@@ -442,7 +447,12 @@ async fn config_snapshot_cannot_be_saved_into_a_different_tenant_scope() {
let config = Config::load_from_config_path(&path, &workspace)
.await
.unwrap();
- let version = config.runtime_state.document_snapshot.lock().unwrap().version;
+ let version = config
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .version;
let docs = Arc::clone(scoped(&storage, "tenant-source-b").documents());
let stored = docs
.get(
@@ -521,16 +531,38 @@ async fn config_snapshot_is_bound_to_its_backend_instance() {
let config = Config::load_from_config_path(&path, &workspace)
.await
.unwrap();
- let version = config.runtime_state.document_snapshot.lock().unwrap().version;
+ let version = config
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .version;
(config, version)
};
- let version_a = config_a.runtime_state.document_snapshot.lock().unwrap().version;
+ let version_a = config_a
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .version;
assert_eq!(
version_a, version_b,
"fixture uses colliding document versions"
);
- let anchor_a = config_a.runtime_state.document_snapshot.lock().unwrap().anchor.clone();
- let anchor_b = config_b.runtime_state.document_snapshot.lock().unwrap().anchor.clone();
+ let anchor_a = config_a
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .anchor
+ .clone();
+ let anchor_b = config_b
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .anchor
+ .clone();
assert_ne!(anchor_a, anchor_b, "source anchors retain backend identity");
let error = {
@@ -557,7 +589,13 @@ async fn a_file_snapshot_can_seed_an_absent_document_after_storage_bootstrap() {
.await
.unwrap();
assert!(matches!(
- snapshot.runtime_state.document_snapshot.lock().unwrap().anchor.clone(),
+ snapshot
+ .runtime_state
+ .document_snapshot
+ .lock()
+ .unwrap()
+ .anchor
+ .clone(),
Some(ConfigSourceAnchor::File(_))
));
diff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rs
index 1cdffb974f..bb03459d47 100644
--- a/crates/openhuman-core/src/config/schema/types/config.rs
+++ b/crates/openhuman-core/src/config/schema/types/config.rs
@@ -31,7 +31,9 @@ pub struct ConfigRuntimeState {
impl Clone for ConfigRuntimeState {
fn clone(&self) -> Self {
Self {
- document_snapshot: std::sync::Mutex::new(self.document_snapshot.lock().unwrap().clone()),
+ document_snapshot: std::sync::Mutex::new(
+ self.document_snapshot.lock().unwrap().clone(),
+ ),
context_snapshot: self.context_snapshot.clone(),
context_overlay: std::sync::Mutex::new(self.context_overlay.lock().unwrap().clone()),
}
diff --git a/crates/openhuman-core/src/core/runtime/context_config.rs b/crates/openhuman-core/src/core/runtime/context_config.rs
index 416a0e1d8e..ed5dc8877b 100644
--- a/crates/openhuman-core/src/core/runtime/context_config.rs
+++ b/crates/openhuman-core/src/core/runtime/context_config.rs
@@ -28,7 +28,8 @@ pub(super) fn record_context_config_overlay(
if let Some(config_overlay) = config_overlay {
match config_overlay {
Ok(config_overlay) => {
- overlay.config.runtime_state.context_overlay = std::sync::Mutex::new(Some(config_overlay));
+ overlay.config.runtime_state.context_overlay =
+ std::sync::Mutex::new(Some(config_overlay));
}
Err(error) => {
log::warn!("[core-context] unable to record derived config overrides: {error}")