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(security): answer policy reads from the agent context first (#7032)
oxoxDev57396bd764be
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rsindex 646ce4a1c9..df843ca633 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs@@ -141,7 +141,7 @@ impl SpawnAsyncSubagentTool {workspace.root.clone()}).or_else(|| {- crate::security::live_policy::current().map(|policy| policy.action_dir.clone())+ crate::security::live_policy::effective().map(|policy| policy.action_dir.clone())});let selector = SubagentSessionSelector {parent_session: parent_session.clone(),diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rsindex 60702d2c6e..e6f4da3e1e 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs@@ -465,7 +465,7 @@ async fn offload_outcome_artifacts(// A worktree-isolated worker offloads into its own checkout; everyone else// uses the live policy's action root, which is the same root a parent's// relative read resolves the returned path against.- let policy = crate::security::live_policy::current();+ let policy = crate::security::live_policy::effective();let Some(action_dir) = options.worktree_action_dir.clone()diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rsindex eb1043edb0..a7d4a0f9b1 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs@@ -127,7 +127,7 @@ pub struct OpenHumanSecurityGate {/// Fallback policy used when no process-global live policy is installed.////// Per-call resolution prefers- /// [`crate::security::live_policy::current`] so an autonomy+ /// [`crate::security::live_policy::effective`] so an autonomy/// change made mid-session is observed on the very next tool call — the/// same live-first / snapshot-fallback discipline `ApprovalGate` uses for/// `auto_approve`. The trait explicitly forbids the runtime caching a@@ -195,10 +195,10 @@ impl OpenHumanSecurityGate {.remove(call_id)}- /// The policy to answer this call against: the live process-global one when+ /// The policy to answer this call against: the agent's or the live one when/// installed, else the constructor snapshot.fn effective_policy(&self) -> Arc<SecurityPolicy> {- crate::security::live_policy::current().unwrap_or_else(|| self.policy.clone())+ crate::security::live_policy::effective().unwrap_or_else(|| self.policy.clone())}/// Finds the registered [`Tool`] named `name`, if any.diff --git a/crates/openhuman-core/src/security/approval/gate_setup.rs b/crates/openhuman-core/src/security/approval/gate_setup.rsindex 0de0391d55..39e994a578 100644--- a/crates/openhuman-core/src/security/approval/gate_setup.rs+++ b/crates/openhuman-core/src/security/approval/gate_setup.rs@@ -87,11 +87,11 @@ impl ApprovalGate {ttl}- /// Whether `tool_name` is on the user's "Always allow" list. Prefers the+ /// Whether `tool_name` is on the user's "Always allow" list. Prefers the agent or/// process-global live policy (so a grant made this session is seen/// immediately) and falls back to the gate's boot-time config snapshot.fn tool_is_auto_approved(&self, tool_name: &str) -> bool {- if let Some(policy) = crate::security::live_policy::current() {+ if let Some(policy) = crate::security::live_policy::effective() {return policy.auto_approve.iter().any(|t| t == tool_name);}self.config@@ -111,7 +111,7 @@ impl ApprovalGate {/// this flag — see the `matches!` guard at the call site below. This method only reports the/// user's setting; it does not know about origin.fn is_auto_approve_all_enabled(&self) -> bool {- if let Some(policy) = crate::security::live_policy::current() {+ if let Some(policy) = crate::security::live_policy::effective() {return policy.auto_approve_all;}self.config.autonomy.auto_approve_alldiff --git a/crates/openhuman-core/src/security/live_policy.rs b/crates/openhuman-core/src/security/live_policy.rsindex 7b0c76d3a8..f2b4d52f49 100644--- a/crates/openhuman-core/src/security/live_policy.rs+++ b/crates/openhuman-core/src/security/live_policy.rs@@ -175,6 +175,21 @@ pub fn current() -> Option<Arc<SecurityPolicy>> {.and_then(|s| s.policy.read().ok().map(|g| Arc::clone(&g)))}+/// The policy a call should be answered against: the ambient agent context's+/// own policy when it carries one, else the process-global [`current`] policy.+pub fn effective() -> Option<Arc<SecurityPolicy>> {+ if let Some(policy) = crate::core::runtime::CoreContext::current_agent_policy() {+ return Some(policy);+ }+ if let Some(agent) = crate::core::runtime::agent_scope::current_agent_id() {+ tracing::trace!(+ agent_id = %agent,+ "[security:live_policy] agent context carries no policy; using the process policy"+ );+ }+ current()+}+/// Reload counter — incremented on every [`reload_from`]. Observability/tests.pub fn generation() -> u64 {STATE