Skip to content

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

refactor(security): simplify live policy evaluation

Steven Enamakel2d52da01068c
diff --git a/crates/openhuman-core/src/security/live_policy.rs b/crates/openhuman-core/src/security/live_policy.rs
index f2b4d52f49..75a993a2e3 100644
--- a/crates/openhuman-core/src/security/live_policy.rs
+++ b/crates/openhuman-core/src/security/live_policy.rs
@@ -177,8 +177,16 @@ pub fn current() -> Option<Arc<SecurityPolicy>> {
/// 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.
+///
+/// Reads the calling task's ambient context; a caller that holds its own
+/// context uses [`effective_in`].
pub fn effective() -> Option<Arc<SecurityPolicy>> {
- if let Some(policy) = crate::core::runtime::CoreContext::current_agent_policy() {
+ effective_in(&crate::core::runtime::DispatchCtx::ambient())
+}
+
+/// [`effective`] for the agent `ctx` runs for.
+pub fn effective_in(ctx: &crate::core::runtime::DispatchCtx) -> Option<Arc<SecurityPolicy>> {
+ if let Some(policy) = ctx.agent_policy() {
return Some(policy);
}
if let Some(agent) = crate::core::runtime::agent_scope::current_agent_id() {