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(core): add per-agent skill-root isolation and context overlay
Steven Enamakel4804335005d0
diff --git a/crates/openhuman-core/src/core/runtime/context.rs b/crates/openhuman-core/src/core/runtime/context.rsindex 88bbfbb758..65a4192e46 100644--- a/crates/openhuman-core/src/core/runtime/context.rs+++ b/crates/openhuman-core/src/core/runtime/context.rs@@ -86,6 +86,64 @@ pub struct CoreContext {/// the model. Defaults to every group withheld, which is what the/// compiled-in pack table meant before the type existed.tool_groups: crate::tools::toolpacks::ToolGroups,+ /// Whether skill discovery under this context scans the operator's+ /// user-scope roots (`~/.openhuman/skills`, `~/.agents/skills`).+ ///+ /// `true` for every booted context — the desktop, CLI and a plain library+ /// embedder all run as the operator. A per-agent context derived through+ /// [`CoreContext::derive_with`] can turn it off so an embedded agent sees+ /// only the skills its host installed for it, never the operator's.+ user_skill_roots: bool,+}++/// Per-agent overrides layered onto a booted context by+/// [`CoreContext::derive_with`].+///+/// This is the seam a library host uses to run many independently configured+/// agents on one booted core: each agent gets its own `Config` (provider+/// routes, MCP servers, autonomy tier, `action_dir`), its own+/// [`DomainSet`](crate::core::runtime::DomainSet), its own+/// [`ToolGroups`](crate::tools::toolpacks::ToolGroups) and its own skill-root+/// policy, while sharing the host identity, keyring, bus and RPC bearer of the+/// context it derives from.+#[derive(Debug, Clone)]+pub struct ContextOverlay {+ /// The config every handler dispatched under the derived context reads+ /// through `config::ops::load_config_with_timeout()`. Keep `config_path`+ /// equal to the parent's: credentials, auth profiles and the keyring file+ /// backend all resolve against its parent directory.+ pub config: crate::config::Config,+ /// Domain families live for the derived context. Only narrowing the parent+ /// is meaningful: controllers a booted core never registered stay absent+ /// no matter what this says.+ pub domains: crate::core::runtime::DomainSet,+ /// Tool-group disclosure for the derived context.+ pub tool_groups: crate::tools::toolpacks::ToolGroups,+ /// Scan the operator's user-scope skill roots (`true` = today's behaviour).+ pub user_skill_roots: bool,+}++impl ContextOverlay {+ /// An overlay that keeps user-scope skill roots visible.+ pub fn new(+ config: crate::config::Config,+ domains: crate::core::runtime::DomainSet,+ tool_groups: crate::tools::toolpacks::ToolGroups,+ ) -> Self {+ Self {+ config,+ domains,+ tool_groups,+ user_skill_roots: true,+ }+ }++ /// Hide the operator's `~/.openhuman/skills` / `~/.agents/skills` from+ /// skill discovery under the derived context.+ pub fn without_user_skill_roots(mut self) -> Self {+ self.user_skill_roots = false;+ self+ }}/// The complete input to a workspace-scoped memory binding.@@ -282,6 +340,7 @@ impl CoreContext {domains,tool_groups,embedder_config,+ user_skill_roots: true,});// Register the process default context (first build wins). Dispatch@@ -308,6 +367,55 @@ impl CoreContext {self.domains}+ /// Whether skill discovery under this context scans the operator's+ /// user-scope roots. See [`ContextOverlay::user_skill_roots`].+ pub fn user_skill_roots(&self) -> bool {+ self.user_skill_roots+ }++ /// [`user_skill_roots`](Self::user_skill_roots) of the ambient context, or+ /// `true` when nothing is scoped and no default context exists — the+ /// pre-existing behaviour for every non-embedded caller.+ pub fn current_user_skill_roots() -> bool {+ Self::current().is_none_or(|ctx| ctx.user_skill_roots())+ }++ /// A child context sharing this one's host identity, with its own config,+ /// domain set, tool groups and skill-root policy.+ ///+ /// **No boot runs.** No stores are initialised, no registry, gate or live+ /// policy is (re)installed, and the process default context is untouched.+ /// The child is only useful inside [`CoreContext::scope`] (or+ /// `CoreRuntime::invoke_in` / `run_in`), where every reader that goes+ /// through [`CoreContext::current`] — the config loader, the DomainSet+ /// dispatch gate, the tool-group filter, skill discovery — sees the+ /// overlay instead of the parent.+ ///+ /// The workspace binding is anchored to `overlay.config.workspace_dir`, so+ /// an agent with its own workspace subdirectory resolves its own memory+ /// binding lazily, exactly as an embedder-supplied config does at boot.+ pub fn derive_with(&self, overlay: ContextOverlay) -> Arc<CoreContext> {+ log::debug!(+ "[core-context] derive: workspace_dir={} domains={:?} tool_groups={:?} \+ user_skill_roots={}",+ overlay.config.workspace_dir.display(),+ overlay.domains,+ overlay.tool_groups,+ overlay.user_skill_roots+ );+ Arc::new(CoreContext {+ host_kind: self.host_kind,+ workspace_binding: RwLock::new(WorkspaceBinding {+ workspace_dir: Some(overlay.config.workspace_dir.clone()),+ memory_subsystem: overlay.config.subsystems.memory.clone(),+ }),+ domains: overlay.domains,+ tool_groups: overlay.tool_groups,+ embedder_config: Some(overlay.config),+ user_skill_roots: overlay.user_skill_roots,+ })+ }+/// The resolved per-user workspace directory this context is bound to.pub fn workspace_dir(&self) -> Result<std::path::PathBuf, String> {self.workspace_binding@@ -558,6 +666,7 @@ impl CoreContext {domains,tool_groups: Default::default(),embedder_config: None,+ user_skill_roots: true,})}@@ -585,6 +694,7 @@ impl CoreContext {domains,tool_groups: Default::default(),embedder_config: Some(config),+ user_skill_roots: true,})}}