Skip to content

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

fix(ops_discover): resolve collision precedence to match historical behavior

Steven Enamakeld790ed6d7590
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context.rs b/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context.rs
index 85f67e5571..19d27e614d 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/agent_prepare_context.rs
@@ -28,4 +28,6 @@ pub use scout_run::{run_context_scout, run_context_scout_with_catalog};
pub use tool::AgentPrepareContextTool;
#[cfg(test)]
-use scout_run::{extract_context_bundle, is_expected_billing_failure, log_scout_failure, scout_failure_signal};
+use scout_run::{
+ extract_context_bundle, is_expected_billing_failure, log_scout_failure, scout_failure_signal,
+};
diff --git a/crates/openhuman-core/src/skills/ops_discover/collision.rs b/crates/openhuman-core/src/skills/ops_discover/collision.rs
index a5fc2fa1a9..c9cf1f5cba 100644
--- a/crates/openhuman-core/src/skills/ops_discover/collision.rs
+++ b/crates/openhuman-core/src/skills/ops_discover/collision.rs
@@ -15,25 +15,30 @@ pub(super) fn absorb(by_name: &mut HashMap<String, Workflow>, incoming: Vec<Work
.map(|(existing_name, _)| existing_name.clone())
.collect();
- if let Some((highest_name, highest_scope)) = collision_keys
+ let highest = collision_keys
.iter()
.filter_map(|collision_key| by_name.get(collision_key))
.map(|existing| (existing.name.clone(), existing.scope))
- .max_by_key(|(_, scope)| precedence(*scope))
- && precedence(skill.scope) < precedence(highest_scope)
- {
- if let Some(kept) = by_name.get_mut(&highest_name) {
- kept.warnings.push(format!(
- "workflow id '{}' or name '{}' also declared in {:?} scope at {} (ignored)",
- skill.dir_name,
- skill.name,
- skill.scope,
- skill.location
- .as_deref()
- .map_or_else(|| "<unknown>".to_owned(), |path| path.display().to_string())
- ));
+ .max_by_key(|(_, scope)| precedence(*scope));
+ if let Some((highest_name, highest_scope)) = highest {
+ if precedence(skill.scope) >= precedence(highest_scope) {
+ // The incoming skill wins ties, preserving the historical
+ // last-writer behavior for equal-precedence roots.
+ } else {
+ if let Some(kept) = by_name.get_mut(&highest_name) {
+ kept.warnings.push(format!(
+ "workflow id '{}' or name '{}' also declared in {:?} scope at {} (ignored)",
+ skill.dir_name,
+ skill.name,
+ skill.scope,
+ skill.location.as_deref().map_or_else(
+ || "<unknown>".to_owned(),
+ |path| path.display().to_string()
+ )
+ ));
+ }
+ continue;
}
- continue;
}
for collision_key in collision_keys {
@@ -43,7 +48,8 @@ pub(super) fn absorb(by_name: &mut HashMap<String, Workflow>, incoming: Vec<Work
loser.scope,
loser.name,
loser.dir_name,
- loser.location
+ loser
+ .location
.as_deref()
.map_or_else(|| "<unknown>".to_owned(), |path| path.display().to_string())
));
diff --git a/crates/openhuman-core/src/skills/ops_discover/scan.rs b/crates/openhuman-core/src/skills/ops_discover/scan.rs
index 61f943a9e0..457274de59 100644
--- a/crates/openhuman-core/src/skills/ops_discover/scan.rs
+++ b/crates/openhuman-core/src/skills/ops_discover/scan.rs
@@ -2,8 +2,8 @@
//! into `Workflow` entries, and the shared multi-root scan engine that both
//! the full discovery surface and the automations-only view share.
-use std::path::{Path, PathBuf};
use std::collections::HashMap;
+use std::path::{Path, PathBuf};
use crate::skills::ops_types::{Workflow, WorkflowScope};
@@ -65,7 +65,10 @@ pub(super) fn discover_filtered(
scope = ?WorkflowScope::Builtin,
"[workflows] discover:branch:builtin"
);
- absorb(&mut discovered, scan_bundled_root(&root, WorkflowScope::Builtin));
+ absorb(
+ &mut discovered,
+ scan_bundled_root(&root, WorkflowScope::Builtin),
+ );
}
}
@@ -108,7 +111,10 @@ pub(super) fn discover_filtered(
scope = ?WorkflowScope::Legacy,
"[workflows] discover:branch:legacy"
);
- absorb(&mut discovered, scan_root(&legacy_root, WorkflowScope::Legacy));
+ absorb(
+ &mut discovered,
+ scan_root(&legacy_root, WorkflowScope::Legacy),
+ );
}
}
@@ -127,7 +133,10 @@ pub(super) fn discover_filtered(
"[profiles] discover:branch:profile-local skills"
);
let before = discovered.len();
- absorb(&mut discovered, scan_root(profile_root, WorkflowScope::Profile));
+ absorb(
+ &mut discovered,
+ scan_root(profile_root, WorkflowScope::Profile),
+ );
tracing::debug!(
names_before = before,
names_after = discovered.len(),