Skip to content

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

feat(boot-guard): reject clustered nodes without a shared CAS backend

Steven Enamakeld492b9ffe4c7
diff --git a/crates/openhuman-core/src/core/runtime/boot_guard.rs b/crates/openhuman-core/src/core/runtime/boot_guard.rs
index a9cb77c123..3ff5705f4b 100644
--- a/crates/openhuman-core/src/core/runtime/boot_guard.rs
+++ b/crates/openhuman-core/src/core/runtime/boot_guard.rs
@@ -142,6 +142,7 @@ pub enum Violation {
Root(String),
ServiceToken(String),
Platform(&'static str),
+ Cluster(String),
}
impl std::fmt::Display for Violation {
@@ -163,6 +164,7 @@ impl std::fmt::Display for Violation {
Self::Root(why) => write!(f, "root: {why}"),
Self::ServiceToken(why) => write!(f, "service token: {why}"),
Self::Platform(why) => write!(f, "platform: {why}"),
+ Self::Cluster(why) => write!(f, "cluster: {why}"),
}
}
}
@@ -263,6 +265,9 @@ pub fn check(inputs: &BootInputs<'_>) -> Result<(), BootGuardError> {
if let ServiceToken::Invalid(why) = inputs.token {
violations.push(Violation::ServiceToken(why.clone()));
}
+ if let Some(why) = cluster_problem(inputs) {
+ violations.push(Violation::Cluster(why));
+ }
if violations.is_empty() {
log::info!("[saas][boot-guard] deployment checks passed");
@@ -275,6 +280,36 @@ pub fn check(inputs: &BootInputs<'_>) -> Result<(), BootGuardError> {
}
}
+/// Why a clustered node (one that sets `advertise_url`) cannot keep its
+/// profiles exclusive, if it cannot: its leases need a shared backend whose
+/// compare-and-swap holds across processes
+/// ([`crate::storage::driver_has_cross_process_cas`]). Only the driver name
+/// is reported, never the URL (it may carry a password).
+pub(crate) fn cluster_problem(inputs: &BootInputs<'_>) -> Option<String> {
+ if !inputs.config.is_clustered() {
+ return None;
+ }
+ let env_url = inputs
+ .env
+ .iter()
+ .find(|(var, _)| var == crate::storage::STORAGE_URL_VAR)
+ .map(|(_, value)| value.as_str());
+ let Some(url) = inputs.config.storage_url_with(env_url) else {
+ return Some(
+ "advertise_url is set but no storage_url: nodes of a cluster need one shared backend"
+ .to_string(),
+ );
+ };
+ match crate::storage::StorageUrl::parse(&url) {
+ Ok(parsed) if crate::storage::driver_has_cross_process_cas(parsed.driver()) => None,
+ Ok(parsed) => Some(format!(
+ "storage driver `{}` cannot exclude other nodes from a profile; use sqlite or mongodb",
+ parsed.driver()
+ )),
+ Err(_) => Some("the storage URL does not parse".to_string()),
+ }
+}
+
/// Why the allowlisted tool groups cannot run safely, if they cannot.
fn sandbox_problems(inputs: &BootInputs<'_>) -> Vec<String> {
if !needs_sandbox(inputs.config) {