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
refactor(tools): move agent policy engine into tinytools
Steven Enamakel85e789740fc5
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rsindex d8cc248d40..b67fcc57e6 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_build.rs@@ -3,7 +3,7 @@use super::{dedup_visible_tool_specs, visible_tool_specs_for_policy};use crate::agent::context::ContextManager;use crate::agent::session_host::types::{OpenHumanSessionHost, SessionHostBuilder};-use crate::tools::agent_policy::ToolPolicyEngine;+use tinytools::ToolPolicyEngine;use anyhow::Result;use std::sync::Arc;use tinytools::{Tool, ToolSpec};@@ -143,16 +143,16 @@ impl SessionHostBuilder {// swaps synthesised names, and `OpenHumanSessionHost::hide_tools` only seeds a set// that is still empty — see the matching strip there.let discovery_opted_in =- visible_names.remove(crate::tools::implementations::meta::TOOL_SEARCH_NAME);+ visible_names.remove(tinytools::TOOL_SEARCH_NAME);let discovery_enabled = (belt_is_wildcard || discovery_opted_in)&& !self.withheld_tool_names- .contains(crate::tools::implementations::meta::TOOL_SEARCH_NAME);+ .contains(tinytools::TOOL_SEARCH_NAME);// A wildcard belt was seeded from the whole registry, so its durable// `Hidden` members (collapsed `todo_*`) leave here too.// A named belt never listed them.let mut deferred_names = if belt_is_wildcard {- crate::tools::implementations::meta::strip_deferred_from_visible(+ tinytools::strip_deferred_from_visible(&mut visible_names,tools.as_slice(),)@@ -166,7 +166,7 @@ impl SessionHostBuilder {// are left alone on purpose — see the comment above.// Plus the tools this agent's definition defers for itself// (`deferred_tools`); see `meta::deferred_set`.- deferred_names.extend(crate::tools::implementations::meta::deferred_set(+ deferred_names.extend(tinytools::deferred_set(tools.as_slice(),synthesized_tools.as_slice(),&self.deferred_tools,diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rsindex a8a0030c41..83361c2162 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs@@ -72,7 +72,7 @@ mod tool_spec_views_tests;// ── use_skill's advertised spec is scoped to the session ────────────────────-use crate::tools::agent_policy::{+use tinytools::{TaskProfile, TaskRiskLevel, ToolPolicyAction, ToolPolicyDecision, ToolPolicySession,};use tinytools::PermissionLevel;@@ -190,7 +190,7 @@ fn visible_specs_drop_the_pack_tool_when_no_pack_is_reachable() {/// the only route to every withheld tool.#[test]fn a_realistic_withheld_session_keeps_its_packs_advertised() {- use crate::tools::agent_policy::ToolPolicyEngine;+ use tinytools::ToolPolicyEngine;use crate::tools::toolpacks::{append_pack_tools, strip_packed_from_visible};struct Fake(&'static str);diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rsindex 36d273e0f6..c67dd597cc 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs@@ -169,7 +169,7 @@ fn withholding_tool_search_disables_wildcard_discovery() {let config = test_config(&tmp);let host: crate::agent::HostTools = Arc::new(|_| crate::agent::HostTurnTools {withheld: std::collections::HashSet::from([- crate::tools::implementations::meta::TOOL_SEARCH_NAME.to_string(),+ tinytools::TOOL_SEARCH_NAME.to_string(),]),..Default::default()});diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rsindex 6e022bf109..9a39fdbf90 100644--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs@@ -162,7 +162,7 @@ fn wildcard_belt_defers_but_keeps_reachable() {fn named_belt_opts_into_discovery_by_naming_tool_search() {let visible: std::collections::HashSet<String> = ["plain",- crate::tools::implementations::meta::TOOL_SEARCH_NAME,+ tinytools::TOOL_SEARCH_NAME,].into_iter().map(String::from)diff --git a/crates/openhuman-core/src/agent/session_host/builder/mod.rs b/crates/openhuman-core/src/agent/session_host/builder/mod.rsindex 4a76e3cd63..978c22ebe0 100644--- a/crates/openhuman-core/src/agent/session_host/builder/mod.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/mod.rs@@ -26,7 +26,7 @@ pub use host_tools::{HostTools, HostTurnTools, TurnContext};mod builder_tests;use crate::agent::harness::definition::{AgentDefinition, ToolScope};-use crate::tools::agent_policy::ToolPolicySession;+use tinytools::ToolPolicySession;use std::sync::Arc;use tinytools::{Tool, ToolSpec};diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rsindex fd188f55d1..3cc2a9a835 100644--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs@@ -3,7 +3,7 @@//! (which rebuilds the tool policy snapshot on every change).use super::super::types::{OpenHumanSessionHost, SessionHostBuilder};-use crate::tools::agent_policy::ToolPolicyEngine;+use tinytools::ToolPolicyEngine;use std::collections::HashSet;use std::sync::Arc;use tinytools::{Tool, ToolSpec};@@ -121,7 +121,7 @@ impl OpenHumanSessionHost {#[cfg(test)]pub(crate) fn tool_policy_session_for_test(&self,- ) -> &crate::tools::agent_policy::ToolPolicySession {+ ) -> &tinytools::ToolPolicySession {&self.tool_policy_session}@@ -419,7 +419,7 @@ impl OpenHumanSessionHost {);// Durable `Hidden` members leave the wire here; the deferred split// over both sets is the shared recompute below.- let _ = crate::tools::implementations::meta::strip_deferred_from_visible(+ let _ = tinytools::strip_deferred_from_visible(&mut self.visible_tool_names,self.tools.as_slice(),);@@ -437,7 +437,7 @@ impl OpenHumanSessionHost {self.deferred_tool_names.clear();return;}- let mut deferred = crate::tools::implementations::meta::deferred_set(+ let mut deferred = tinytools::deferred_set(self.tools.as_slice(),self.synthesized_tools.as_slice(),&self.requested_deferred_tools,diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex d361c0a040..d82e24fbe9 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -133,7 +133,7 @@ struct OpenHumanTurnToolSurface {/// off so refresh cannot reopen withdrawn authority.auto_include_new_synthesized_tools: bool,synthesized_tool_names: std::collections::HashSet<String>,- tool_policy_session: crate::tools::agent_policy::ToolPolicySession,+ tool_policy_session: tinytools::ToolPolicySession,event_session_id: String,event_channel: String,agent_definition_name: String,@@ -187,7 +187,7 @@ impl OpenHumanTurnPrelude {) -> (Arc<Vec<Box<dyn tinytools::Tool>>>,Arc<Vec<Box<dyn tinytools::Tool>>>,- crate::tools::agent_policy::ToolPolicySession,+ tinytools::ToolPolicySession,String,String,) {diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rsindex 166d6e552f..c32030e4d9 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/permanent.rs@@ -15,7 +15,7 @@ pub(super) fn refresh_visibility(// a `Deferred` synthesised tool leaves the wire and joins the// searchable set, on a belt that opted into discovery.if surface.discovery_enabled {- let deferred = crate::tools::implementations::meta::deferred_set(+ let deferred = tinytools::deferred_set(surface.tools.as_slice(),synthesized,&surface.requested_deferred_tools,diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rsindex 969f39acde..f5e532256e 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tool_surface.rs@@ -9,7 +9,7 @@ impl OpenHumanTurnPrelude {/// this request is prepared.pub(super) fn refresh_delegation_tool_surface(&self) -> anyhow::Result<()> {use crate::agent::harness::definition::AgentDefinitionRegistry;- use crate::tools::agent_policy::ToolPolicyEngine;+ use tinytools::ToolPolicyEngine;use crate::tools::orchestrator_tools::collect_orchestrator_tools;let Some(registry) = AgentDefinitionRegistry::current() else {diff --git a/crates/openhuman-core/src/agent/session_host/turn/context.rs b/crates/openhuman-core/src/agent/session_host/turn/context.rsindex 56a3115019..7e89757609 100644--- a/crates/openhuman-core/src/agent/session_host/turn/context.rs+++ b/crates/openhuman-core/src/agent/session_host/turn/context.rs@@ -2,7 +2,7 @@use super::super::types::OpenHumanSessionHost;use crate::agent::prompts::{tool_call_format_from_dialect, PromptContext, PromptTool};-use crate::tools::agent_policy::render_tool_policy_boundary;+use tinytools::render_tool_policy_boundary;use anyhow::Result;diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rsindex 8cefd68de9..a8e70d3c04 100644--- a/crates/openhuman-core/src/agent/session_host/types.rs+++ b/crates/openhuman-core/src/agent/session_host/types.rs@@ -12,7 +12,7 @@ use crate::agent::progress::AgentProgress;use crate::agent::prompts::SystemPromptBuilder;use crate::agent::tinyagents::TurnModelSource;use crate::agent::tool_policy::ToolPolicy;-use crate::tools::agent_policy::ToolPolicySession;+use tinytools::ToolPolicySession;use std::sync::Arc;use tinytools::{Tool, ToolSpec};use tinytools_agent::dialect::ToolDialect;diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rsindex d4253e84de..2975aaa1ba 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs@@ -16,7 +16,7 @@ use crate::agent::harness::definition::AgentDefinitionRegistry;use crate::agent::hooks::PostTurnHook;use crate::config::Config;use crate::security::policy::SecurityPolicy;-use crate::tools::agent_policy::ToolPolicySession;+use tinytools::ToolPolicySession;use tinytools::Tool;use super::{diff --git a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rsindex 7815f5c6f4..ce340f0b94 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/definition_registry.rs@@ -318,7 +318,7 @@ impl OpenHumanDefinitionRegistry {let mut names = named.clone();if named.iter()- .any(|name| name == crate::tools::implementations::meta::TOOL_SEARCH_NAME)+ .any(|name| name == tinytools::TOOL_SEARCH_NAME){if let Some(deferred) = self.deferred_tools.as_deref() {names.extend(deferred.iter().cloned());diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rsindex e7f85988cc..848f84da8e 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs@@ -84,7 +84,7 @@ use tinyagents_harness::host::security_gate::{GateDecision, ToolCallRequest};use crate::agent::tinyagents::policy_denial::PolicyDenial;use crate::security::approval::{redact_args, summarize_action, ApprovalGate, GateOutcome};use crate::security::policy::{GateDecision as PolicyGateDecision, SecurityPolicy};-use crate::tools::agent_policy::{ToolPolicyAction, ToolPolicySession};+use tinytools::{ToolPolicyAction, ToolPolicySession};use tinybox_bus::CommandClass;use tinytools::{PermissionLevel, Tool};diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_screen_and_policy_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_screen_and_policy_tests.rsindex 03ecaf08d1..202bfa1b0d 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate_screen_and_policy_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate_screen_and_policy_tests.rs@@ -32,7 +32,7 @@ async fn ordinary_text_passes_screening_unchanged() {/// Builds a session whose channel policy yields `action` for `tool_name`.fn policy_session(tool_name: &str, action: ToolPolicyAction) -> Arc<ToolPolicySession> {- use crate::tools::agent_policy::{TaskProfile, TaskRiskLevel, ToolPolicyDecision};+ use tinytools::{TaskProfile, TaskRiskLevel, ToolPolicyDecision};let profile = TaskProfile {agent_id: "lead".to_string(),channel: "telegram".to_string(),diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route.rsindex 7197368372..4ae9f8df87 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route.rs@@ -11,7 +11,7 @@ use tinyagents_harness::error::Result as TaResult;use tinyagents_harness::middleware::Middleware;use tinyinference_llm::tool::ToolCall as TaToolCall;-use crate::tools::agent_policy::ToolPolicySession;+use tinytools::ToolPolicySession;use crate::tools::toolpacks::{self, GroupMode};use tinyagents_harness::tool::packs::USE_SKILL;diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route_tests.rsindex b8f72b177d..9bc4c71e71 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/packed_tool_route_tests.rs@@ -1,7 +1,7 @@use super::*;use std::collections::HashMap;-use crate::tools::agent_policy::ToolPolicyEngine;+use tinytools::ToolPolicyEngine;use tinytools::{PermissionLevel, Tool, ToolResult};/// `skill_registry_search` with a chosen permission level.diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rsindex db92000cf0..08cc3142d4 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs@@ -33,7 +33,7 @@ pub(crate) struct ToolPolicyMiddleware {gate: ToolPolicyGate<OpenHumanRunContext>,/// The session's channel-permission snapshot — enforces the per-channel deny/// + per-call permission-level ceiling the engine ran in `agent_tool_exec`.- session: crate::tools::agent_policy::ToolPolicySession,+ session: tinytools::ToolPolicySession,/// Shared tool sets (same `Arc`s the runner registers) so a call's OpenHuman/// `Tool` can be resolved for its generated-tool runtime context and its/// per-call permission level.@@ -77,7 +77,7 @@ impl ToolCallPolicy<OpenHumanRunContext> for SessionToolPolicy {impl ToolPolicyMiddleware {pub(crate) fn new(policy: Arc<dyn crate::agent::tool_policy::ToolPolicy>,- session: crate::tools::agent_policy::ToolPolicySession,+ session: tinytools::ToolPolicySession,tool_sets: Vec<Arc<Vec<Box<dyn Tool>>>>,session_id: String,channel: String,@@ -242,7 +242,7 @@ impl ToolPolicyMiddleware {let approval_only = desktop_approval_disabled&& matches!(decision.action,- crate::tools::agent_policy::ToolPolicyAction::RequireApproval+ tinytools::ToolPolicyAction::RequireApproval);if decision.is_denied() && !approval_only {return Some(diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rsindex 49c3532a9c..60bad8fba5 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs@@ -9,7 +9,7 @@ use super::*;// the route out of the session's own delegation tools.use crate::agent::orchestration::tools::{ArchetypeDelegationTool, DelegationTarget};-use crate::tools::agent_policy::{+use tinytools::{TaskProfile, TaskRiskLevel, ToolCapability, ToolPolicyAction, ToolPolicyDecision,ToolPolicySession,};@@ -326,7 +326,7 @@ async fn a_session_without_the_delegate_is_not_told_to_call_it() {/// "Registered and callable: yes".#[tokio::test]async fn use_skill_reaches_a_withheld_packed_tool() {- use crate::tools::agent_policy::ToolPolicyEngine;+ use tinytools::ToolPolicyEngine;use crate::tools::toolpacks::strip_packed_from_visible;let mut tools: Vec<Box<dyn tinytools::Tool>> = vec![Box::new(RoutingFakeTool("goal_set"))];@@ -376,7 +376,7 @@ async fn use_skill_reaches_a_withheld_packed_tool() {/// remove, one hop later. The hint must fall back to the owning agent instead.#[tokio::test]async fn a_prompt_hidden_delegate_is_not_offered_as_a_direct_route() {- use crate::tools::agent_policy::ToolPolicyEngine;+ use tinytools::ToolPolicyEngine;use crate::tools::toolpacks::strip_packed_from_visible;let mut tools: Vec<Box<dyn tinytools::Tool>> = vec![diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rsindex 2ef283db3b..8a2a02f1ba 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs@@ -18,7 +18,7 @@ pub(crate) struct ToolPolicyEnforcement {/// The session's channel-permission snapshot — enforces the per-channel/// permission ceiling (deny + per-call permission-level gate) the in-house/// engine ran in `agent_tool_exec`.- pub session: crate::tools::agent_policy::ToolPolicySession,+ pub session: tinytools::ToolPolicySession,pub session_id: String,pub channel: String,pub agent_definition_id: String,diff --git a/crates/openhuman-core/src/agent/turn_origin.rs b/crates/openhuman-core/src/agent/turn_origin.rsindex f6a76d5bd2..24dfa2144c 100644--- a/crates/openhuman-core/src/agent/turn_origin.rs+++ b/crates/openhuman-core/src/agent/turn_origin.rs@@ -1,6 +1,6 @@//! Agent turn origin — the trust/routing label attached to every agent//! `run_turn` invocation. Read by [`crate::security::approval::ApprovalGate`]-//! and [`crate::tools::agent_policy::ToolPolicyEngine`] to make+//! and [`tinytools::ToolPolicyEngine`] to make//! consistent decisions across web, channel, cron, and background entry//! points without relying on the *absence* of other task-locals as a signal.//!diff --git a/crates/openhuman-core/src/config/schema/agent.rs b/crates/openhuman-core/src/config/schema/agent.rsindex 504364a91b..fbbb2f0855 100644--- a/crates/openhuman-core/src/config/schema/agent.rs+++ b/crates/openhuman-core/src/config/schema/agent.rs@@ -206,7 +206,7 @@ pub struct AgentConfig {/// "write", "execute", "dangerous".////// Runtime semantics (see- /// [`crate::tools::agent_policy::engine::ToolPolicyEngine`]):+ /// [`tinytools::engine::ToolPolicyEngine`]):////// * **Empty map** — the policy engine preserves the legacy/// unrestricted surface and returns `PermissionLevel::Dangerous`diff --git a/crates/openhuman-core/src/skills/search.rs b/crates/openhuman-core/src/skills/search.rsindex 83177b315e..4a7c6e2d2e 100644--- a/crates/openhuman-core/src/skills/search.rs+++ b/crates/openhuman-core/src/skills/search.rs@@ -12,7 +12,7 @@//! deciding it should.//!//! Search is the third way: pay for the one skill that matches, and nothing for-//! the rest. It is the same bargain [`crate::tools::implementations::meta::deferred`]+//! the rest. It is the same bargain [`tinytools::deferred`]//! makes for deferred tool schemas, over a different corpus.//!//! # What it returns, and what it does notdiff --git a/crates/openhuman-core/src/tools/agent_policy/README.md b/crates/openhuman-core/src/tools/agent_policy/README.mddeleted file mode 100644index f743e42ce4..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/README.md+++ /dev/null@@ -1,75 +0,0 @@-# agent_policy--Profiles and enforces the tool boundary for a single agent session, keeping the prompt-visible tool set and runtime execution decisions aligned with the channel's configured permission ceiling. Given the active agent, channel, the `channel_permissions` map from `AgentConfig`, the session's tool set, and an optional set of explicitly-visible tool names, it produces a deterministic, immutable `ToolPolicySession` snapshot: per-tool decisions (allow / deny / hide), the allowed/blocked/hidden name sets, and a coarse task risk level. It also renders a compact system-prompt section describing the active boundary. Pure logic: no persistence, no RPC, no bus events.--Not to be confused with `crate::agent::tool_policy` (the generic `ToolPolicy` pre-execution hook trait). That module has its own `ToolPolicyDecision` type; the two are unrelated.--## Responsibilities--- Resolve a channel's `PermissionLevel` ceiling from the `channel -> permission` string map (`permission_for_channel`), with fallbacks.-- Classify every tool against that ceiling and the optional visibility set, producing a `ToolPolicyAction` (Allow / RequireApproval / Deny / HideFromPrompt) per tool.-- Build an immutable `ToolPolicySession` snapshot (profile, capabilities, allowed/blocked/hidden tool-name sets, decision map).-- Derive a coarse `TaskRiskLevel` (Low/Medium/High/Critical) from the allowed permission.-- Render a bounded `## Tool Policy Boundary` system-prompt section listing the active agent/channel/entrypoint, allowed permission, risk, allowed tools, and a restricted-count summary.-- Provide a fail-closed default decision (`Deny`) for unknown or unlisted tool names at runtime.--## Key files--| File | Role |-| --- | --- |-| `crates/openhuman-core/src/tools/agent_policy/mod.rs` | Export-only: module docstring + `mod` decls + `pub use` re-exports of the engine, prompt renderer, and types. |-| `crates/openhuman-core/src/tools/agent_policy/types.rs` | Serde-free domain types: `TaskRiskLevel`, `TaskProfile`, `ToolPolicyAction`, `ToolPolicyDecision`, `ToolCapability`, `ToolPolicySession` (with query helpers). Holds the private `NO_TOOLS_ALLOWED_SENTINEL`. |-| `crates/openhuman-core/src/tools/agent_policy/engine.rs` | `ToolPolicyEngine::build_session` / `build_session_from_refs`: the classification logic; private `permission_for_channel` / `parse_permission_level` helpers. |-| `crates/openhuman-core/src/tools/agent_policy/engine_tests.rs` | Engine tests, attached via `#[path]` from [`engine.rs`](./engine.rs). |-| `crates/openhuman-core/src/tools/agent_policy/prompt.rs` | `render_tool_policy_boundary` + `TOOL_POLICY_BOUNDARY_HEADING`; private UTF-8-safe `truncate_utf8`. |-| `crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs` | Prompt-rendering tests, attached via `#[path]` from [`prompt.rs`](./prompt.rs). |--## Public surface--Re-exported from [`mod.rs`](./mod.rs):--- `ToolPolicyEngine::build_session(agent_id, channel, entrypoint, channel_permissions: &HashMap<String,String>, tools: &[Box<dyn Tool>], visible_tool_names: &HashSet<String>) -> ToolPolicySession`.-- `ToolPolicyEngine::build_session_from_refs(..., tools: &[&dyn Tool], ...)`: same classification over borrowed tools so the harness can classify its durable registry and its synthesized delegate tools together; `build_session` delegates to it.-- `render_tool_policy_boundary(session: &ToolPolicySession, max_bytes: usize) -> Option<String>`: `None` when the session has no restrictions; otherwise a truncated prompt section.-- Types: `TaskProfile`, `TaskRiskLevel`, `ToolCapability`, `ToolPolicyAction`, `ToolPolicyDecision`, `ToolPolicySession`.--`ToolPolicySession` helpers: `is_allowed(name)`, `has_restrictions()`, `restricted_tool_count()`, `visible_tool_names_for_prompt()`, `decision_for(name)` (defaults to `Deny`).--`ToolPolicyDecision` has two predicates that answer different questions:--- `is_denied()`: true for anything other than `Allow`, including `HideFromPrompt`. Right for a direct tool call by name.-- `blocks_execution()`: true for `Deny` / `RequireApproval`, or when `required_permission` exceeds `allowed_permission`. `HideFromPrompt` alone does not block, so withheld packed tools stay reachable through `use_skill`. The permission re-check exists because the classifier tests hidden-ness before the ceiling, so a hidden tool over the ceiling is recorded as `HideFromPrompt` only.--## Dependencies--- `crate::tools`: `PermissionLevel` (ordered, parsed and compared) and the `Tool` trait (`name()`, `permission_level()`). The only in-crate dependency.-- `log` for `[tool-policy]` diagnostics; every call sets `target: "openhuman::tools::agent_policy"` explicitly (the lib crate is named `openhuman`).--## Used by--- `crates/openhuman-core/src/agent/session_host/builder/builder_build.rs`: builds two snapshots with `build_session_from_refs`: the session's `tool_policy_session` (with the role visibility filter) and a `channel_policy_session` without it, used to derive the sub-agent tool ceiling.-- `crates/openhuman-core/src/agent/session_host/builder/mod.rs`: `visible_tool_specs_for_policy` filters prompt-visible specs with `decision_for(name).blocks_execution()`.-- `crates/openhuman-core/src/agent/session_host/runtime/accessors.rs`: `rebuild_tool_policy_session` re-runs `build_session_from_refs` after `hide_tools`.-- `crates/openhuman-core/src/agent/session_host/turn/context.rs`: calls `render_tool_policy_boundary(&session, 2048)` and appends the block to the end of the system prompt.-- `crates/openhuman-core/src/agent/session_host/types.rs`: carries `tool_policy_session` on the session.-- `crates/openhuman-core/src/agent/tinyagents/middleware/tool_policy.rs`: `ToolPolicyMiddleware` is the runtime enforcement point: `is_denied()` for direct calls, `blocks_execution()` for the `use_skill` route. The snapshot reaches it through `ToolPolicyEnforcement` in `agent/tinyagents/turn_policy.rs`.-- `crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs`: `SecurityGate::with_tool_policy` accepts an `Arc<ToolPolicySession>` and maps its actions to gate verdicts.-- `crates/openhuman-core/src/config/schema/agent.rs`: the `channel_permissions` field docs describe the engine's fallback semantics.--## Notes / gotchas--- Legacy escape hatch: an empty `channel_permissions` map yields `PermissionLevel::Dangerous` (fully unrestricted). `AgentConfig::migrate_channel_permissions_if_legacy` seeds the map on first boot, so this branch is only hit before that migration. Once *any* entry exists, channels missing from the map (or with an unparseable value) fall back to `PermissionLevel::ReadOnly`.-- Permission parsing (`parse_permission_level`) is lenient: trims, lowercases, strips `-`/`_`, and accepts aliases (`read`/`readonly`, `exec`/`execute`, `danger`/`dangerous`). Unrecognized tokens fall back to read-only.-- Two independent restriction axes: a tool can be `Deny`ed (exceeds the permission ceiling → `blocked_tool_names`) or `HideFromPrompt` (not in the non-empty `visible_tool_names` set → `hidden_tool_names`). Hidden is tested first, so a tool that is both hidden and over the ceiling lands only in `hidden_tool_names`; `blocks_execution()` carries the ceiling check for that case.-- An empty `visible_tool_names` set means "all visible", not "none visible".-- `ToolPolicyAction::RequireApproval` is handled (routed to `blocked_tool_names`) but the engine never produces it.-- `visible_tool_names_for_prompt()` inserts `NO_TOOLS_ALLOWED_SENTINEL` when restrictions exist but nothing is allowed, so callers can distinguish an empty-but-restricted surface from an unrestricted one.-- `truncate_utf8` keeps `render_tool_policy_boundary` output within `max_bytes` on a char boundary, appending `\n[...truncated]` only when there is room.--## Further reading--- [Parent module (`tools`)](../README.md)-- [Native tools overview](../../../../../gitbooks/features/native-tools/README.md)-- [Agent harness architecture](../../../../../gitbooks/developing/architecture/agent-harness.md)-- [Approval gate](../../../../../gitbooks/features/approval-gate.md)-- [tinyagents submodule](../../../../../vendor/tinyagents/README.md)diff --git a/crates/openhuman-core/src/tools/agent_policy/engine.rs b/crates/openhuman-core/src/tools/agent_policy/engine.rsdeleted file mode 100644index 665178bff3..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/engine.rs+++ /dev/null@@ -1,209 +0,0 @@-use super::{TaskProfile, TaskRiskLevel, ToolCapability, ToolPolicyAction, ToolPolicyDecision};-use std::collections::{BTreeSet, HashMap, HashSet};-use tinytools::{PermissionLevel, Tool};--/// Builds deterministic per-session policy snapshots from the active agent,-/// channel, configured channel permissions, and available tool registry.-pub struct ToolPolicyEngine;--impl ToolPolicyEngine {- /// Resolve the policy profile and per-tool decisions for one agent session.- ///- /// Empty `channel_permissions` preserves the legacy unrestricted tool- /// surface. Once any channel policy exists, unknown channels fall back to- /// read-only.- pub fn build_session(- agent_id: impl Into<String>,- channel: impl Into<String>,- entrypoint: impl Into<String>,- channel_permissions: &HashMap<String, String>,- tools: &[Box<dyn Tool>],- visible_tool_names: &HashSet<String>,- ) -> super::ToolPolicySession {- let tools: Vec<&dyn Tool> = tools.iter().map(|t| t.as_ref()).collect();- Self::build_session_from_refs(- agent_id,- channel,- entrypoint,- channel_permissions,- &tools,- visible_tool_names,- )- }-- /// [`Self::build_session`] over a borrowed tool set that need not be one- /// contiguous slice.- ///- /// A session agent's callable surface is split across two `Arc`s — the- /// durable registry and the freshly-synthesised delegation set (see- /// `OpenHumanSessionHost::synthesized_tools`). Both must be classified, or a delegate tool- /// the model can see and call would carry no policy decision at all and- /// fall through the per-channel permission gate.- pub fn build_session_from_refs(- agent_id: impl Into<String>,- channel: impl Into<String>,- entrypoint: impl Into<String>,- channel_permissions: &HashMap<String, String>,- tools: &[&dyn Tool],- visible_tool_names: &HashSet<String>,- ) -> super::ToolPolicySession {- let channel = channel.into();- let allowed_permission = permission_for_channel(channel_permissions, &channel);- let profile = TaskProfile {- agent_id: agent_id.into(),- channel,- entrypoint: entrypoint.into(),- risk_level: TaskRiskLevel::from_allowed_permission(allowed_permission),- allowed_permission,- };-- let mut allowed_tool_names = BTreeSet::new();- let mut blocked_tool_names = BTreeSet::new();- let mut hidden_tool_names = BTreeSet::new();- let mut capabilities = Vec::with_capacity(tools.len());- let mut decisions = HashMap::with_capacity(tools.len());-- for tool in tools {- let name = tool.name().to_string();- let required_permission = tool.permission_level();- let explicitly_hidden =- !visible_tool_names.is_empty() && !visible_tool_names.contains(&name);- let exceeds_permission = required_permission > allowed_permission;-- let action = if explicitly_hidden {- ToolPolicyAction::HideFromPrompt- } else if exceeds_permission {- ToolPolicyAction::Deny- } else {- ToolPolicyAction::Allow- };- log::trace!(- target: "openhuman::tools::agent_policy",- "[tool-policy] classified tool name={} required={} allowed={} explicitly_hidden={} exceeds_permission={} action={:?}",- name,- required_permission,- allowed_permission,- explicitly_hidden,- exceeds_permission,- action- );-- let capability = ToolCapability {- name: name.clone(),- required_permission,- };-- match action {- ToolPolicyAction::Allow => {- allowed_tool_names.insert(name.clone());- }- ToolPolicyAction::RequireApproval | ToolPolicyAction::Deny => {- blocked_tool_names.insert(name.clone());- }- ToolPolicyAction::HideFromPrompt => {- hidden_tool_names.insert(name.clone());- }- }-- decisions.insert(- name.clone(),- ToolPolicyDecision {- tool_name: name,- action,- required_permission: Some(required_permission),- allowed_permission,- },- );- capabilities.push(capability);- }-- super::ToolPolicySession {- profile,- capabilities,- allowed_tool_names,- blocked_tool_names,- hidden_tool_names,- decisions,- }- }-}--fn permission_for_channel(- channel_permissions: &HashMap<String, String>,- channel: &str,-) -> PermissionLevel {- if channel_permissions.is_empty() {- // Empty map means "operator hasn't configured a per-channel- // policy yet" — keep the legacy unrestricted surface so existing- // installs (and unit fixtures that don't seed the map) keep- // working. The hardening lands at the config layer:- // [`AgentConfig::migrate_channel_permissions_if_legacy`] runs at- // startup on legacy installs and seeds the map with safe- // per-channel defaults so the cap actually engages on the very- // first boot after upgrade. Once any entry exists, unknown- // channels fall back to ReadOnly (the `None` arm below).- log::debug!(- target: "openhuman::tools::agent_policy",- "[tool-policy] channel permissions empty; preserving legacy unrestricted surface channel={} (config migration seeds per-channel defaults on first boot)",- channel- );- return PermissionLevel::Dangerous;- }-- match channel_permissions.get(channel) {- Some(raw) => match parse_permission_level(raw) {- Some(permission) => {- log::debug!(- target: "openhuman::tools::agent_policy",- "[tool-policy] resolved channel permission channel={} raw={} permission={}",- channel,- raw,- permission- );- permission- }- None => {- log::debug!(- target: "openhuman::tools::agent_policy",- "[tool-policy] invalid channel permission; falling back to readonly channel={} raw={}",- channel,- raw- );- PermissionLevel::ReadOnly- }- },- None => {- log::debug!(- target: "openhuman::tools::agent_policy",- "[tool-policy] channel permission missing; falling back to readonly channel={}",- channel- );- PermissionLevel::ReadOnly- }- }-}--fn parse_permission_level(value: &str) -> Option<PermissionLevel> {- let normalized = value.trim().to_ascii_lowercase().replace(['-', '_'], "");- let parsed = match normalized.as_str() {- "none" => Some(PermissionLevel::None),- "readonly" | "read" => Some(PermissionLevel::ReadOnly),- "write" => Some(PermissionLevel::Write),- "execute" | "exec" => Some(PermissionLevel::Execute),- "dangerous" | "danger" => Some(PermissionLevel::Dangerous),- _ => None,- };- if parsed.is_none() {- log::trace!(- target: "openhuman::tools::agent_policy",- "[tool-policy] permission token did not match raw={} normalized={}",- value,- normalized- );- }- parsed-}--#[cfg(test)]-#[path = "engine_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/tools/agent_policy/engine_tests.rs b/crates/openhuman-core/src/tools/agent_policy/engine_tests.rsdeleted file mode 100644index fe0c03a2c4..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/engine_tests.rs+++ /dev/null@@ -1,163 +0,0 @@-use super::*;-use async_trait::async_trait;-use std::collections::{HashMap, HashSet};-use tinytools::{PermissionLevel, Tool, ToolResult};--struct PolicyTestTool {- name: &'static str,- permission: PermissionLevel,-}--#[async_trait]-impl Tool for PolicyTestTool {- fn name(&self) -> &str {- self.name- }-- fn description(&self) -> &str {- self.name- }-- fn parameters_schema(&self) -> serde_json::Value {- serde_json::json!({"type":"object"})- }-- async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {- Ok(ToolResult::success("ok"))- }-- fn permission_level(&self) -> PermissionLevel {- self.permission- }-}--fn tools() -> Vec<Box<dyn Tool>> {- vec![- Box::new(PolicyTestTool {- name: "read_notes",- permission: PermissionLevel::ReadOnly,- }),- Box::new(PolicyTestTool {- name: "write_notes",- permission: PermissionLevel::Write,- }),- Box::new(PolicyTestTool {- name: "run_script",- permission: PermissionLevel::Execute,- }),- ]-}--#[test]-fn permission_from_channel_config_defaults_to_read_only() {- let mut permissions = HashMap::new();- permissions.insert("web".to_string(), "write".to_string());- let session = ToolPolicyEngine::build_session(- "orchestrator",- "unknown-channel",- "chat",- &permissions,- &tools(),- &HashSet::new(),- );-- assert_eq!(- session.profile.allowed_permission,- PermissionLevel::ReadOnly- );- assert!(session.is_allowed("read_notes"));- assert!(!session.is_allowed("write_notes"));-}--#[test]-fn empty_channel_config_preserves_legacy_full_tool_surface() {- // Empty channel_permissions preserves the legacy unrestricted- // tool surface (channel cap returns Dangerous). The real-world- // hardening landed at the config layer: legacy installs are- // migrated via `AgentConfig::migrate_channel_permissions_if_legacy`- // on first boot, which seeds per-channel defaults so the cap- // actually engages. Tests that don't exercise that migration- // path keep their legacy behavior.- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &HashMap::new(),- &tools(),- &HashSet::new(),- );-- assert_eq!(- session.profile.allowed_permission,- PermissionLevel::Dangerous- );- assert!(session.is_allowed("read_notes"));- assert!(session.is_allowed("write_notes"));- assert!(session.is_allowed("run_script"));- assert!(!session.has_restrictions());-}--#[test]-fn filters_tools_above_channel_permission() {- let mut permissions = HashMap::new();- permissions.insert("web".to_string(), "write".to_string());-- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &permissions,- &tools(),- &HashSet::new(),- );-- assert!(session.is_allowed("read_notes"));- assert!(session.is_allowed("write_notes"));- assert!(!session.is_allowed("run_script"));-}--#[test]-fn explicit_visible_names_still_narrow_policy_allowed_tools() {- let mut permissions = HashMap::new();- permissions.insert("cli".to_string(), "execute".to_string());- let visible = HashSet::from(["run_script".to_string()]);-- let session = ToolPolicyEngine::build_session(- "code_executor",- "cli",- "chat",- &permissions,- &tools(),- &visible,- );-- assert!(!session.is_allowed("read_notes"));- assert!(!session.is_allowed("write_notes"));- assert!(session.is_allowed("run_script"));- assert!(session.blocked_tool_names.is_empty());- assert!(session.hidden_tool_names.contains("read_notes"));- assert!(session.hidden_tool_names.contains("write_notes"));- assert!(session.has_restrictions());- assert_eq!(- session.visible_tool_names_for_prompt(),- HashSet::from(["run_script".to_string()])- );-}--#[test]-fn decision_denies_unknown_or_disallowed_tool() {- let mut permissions = HashMap::new();- permissions.insert("web".to_string(), "read_only".to_string());- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &permissions,- &tools(),- &HashSet::new(),- );-- assert!(session.decision_for("write_notes").is_denied());- assert!(session.decision_for("missing_tool").is_denied());- assert!(!session.decision_for("read_notes").is_denied());-}diff --git a/crates/openhuman-core/src/tools/agent_policy/mod.rs b/crates/openhuman-core/src/tools/agent_policy/mod.rsdeleted file mode 100644index cc790420df..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/mod.rs+++ /dev/null@@ -1,15 +0,0 @@-//! Agent tool-policy profiling and enforcement.-//!-//! This domain keeps prompt-visible tools and runtime execution aligned with-//! the session's configured channel permission boundary.--mod engine;-mod prompt;-mod types;--pub use engine::ToolPolicyEngine;-pub use prompt::render_tool_policy_boundary;-pub use types::{- TaskProfile, TaskRiskLevel, ToolCapability, ToolPolicyAction, ToolPolicyDecision,- ToolPolicySession,-};diff --git a/crates/openhuman-core/src/tools/agent_policy/prompt.rs b/crates/openhuman-core/src/tools/agent_policy/prompt.rsdeleted file mode 100644index dbd915fa02..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/prompt.rs+++ /dev/null@@ -1,75 +0,0 @@-use super::ToolPolicySession;-use std::fmt::Write as _;--pub const TOOL_POLICY_BOUNDARY_HEADING: &str = "## Tool Policy Boundary";--/// Render a compact system-prompt section that tells the model which tool-/// boundary is active for this session.-pub fn render_tool_policy_boundary(- session: &ToolPolicySession,- max_bytes: usize,-) -> Option<String> {- if !session.has_restrictions() {- return None;- }-- let mut rendered = String::new();- let _ = writeln!(rendered, "{TOOL_POLICY_BOUNDARY_HEADING}");- let _ = writeln!(rendered, "- Agent: {}", session.profile.agent_id);- let _ = writeln!(rendered, "- Channel: {}", session.profile.channel);- let _ = writeln!(rendered, "- Entry point: {}", session.profile.entrypoint);- let _ = writeln!(- rendered,- "- Allowed permission: {}",- session.profile.allowed_permission- );- let _ = writeln!(rendered, "- Risk: {}", session.profile.risk_level);- // The allowed tools are already on the wire as schemas; listing their- // names again here charged every session for a second copy of the belt.- // The count keeps the boundary legible without the duplication.- if !session.allowed_tool_names.is_empty() {- let _ = writeln!(- rendered,- "- Allowed tools: {} (the tools in your list)",- session.allowed_tool_names.len()- );- }- let restricted_tool_count = session.restricted_tool_count();- if restricted_tool_count > 0 {- let _ = writeln!(- rendered,- "- Restricted tools: {restricted_tool_count} omitted by policy"- );- }-- Some(truncate_utf8(rendered, max_bytes))-}--fn truncate_utf8(mut input: String, max_bytes: usize) -> String {- if input.len() <= max_bytes {- return input;- }- if max_bytes == 0 {- input.clear();- return input;- }-- let marker = "\n[...truncated]";- let target = max_bytes.saturating_sub(marker.len());- let mut end = target;- while end > 0 && !input.is_char_boundary(end) {- end -= 1;- }- input.truncate(end);- if max_bytes >= marker.len() {- input.push_str(marker);- }- while input.len() > max_bytes {- input.pop();- }- input-}--#[cfg(test)]-#[path = "prompt_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs b/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rsdeleted file mode 100644index 040c0f3429..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/prompt_tests.rs+++ /dev/null@@ -1,128 +0,0 @@-use super::*;-use crate::tools::agent_policy::ToolPolicyEngine;-use async_trait::async_trait;-use std::collections::{HashMap, HashSet};-use tinytools::{PermissionLevel, Tool, ToolResult};--struct PromptTestTool {- name: String,- permission: PermissionLevel,-}--#[async_trait]-impl Tool for PromptTestTool {- fn name(&self) -> &str {- &self.name- }-- fn description(&self) -> &str {- &self.name- }-- fn parameters_schema(&self) -> serde_json::Value {- serde_json::json!({"type":"object"})- }-- async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {- Ok(ToolResult::success("ok"))- }-- fn permission_level(&self) -> PermissionLevel {- self.permission- }-}--#[test]-fn render_prompt_boundary_lists_allowed_and_restricted_summary() {- let tools: Vec<Box<dyn Tool>> = vec![- Box::new(PromptTestTool {- name: "read_notes".into(),- permission: PermissionLevel::ReadOnly,- }),- Box::new(PromptTestTool {- name: "write_notes".into(),- permission: PermissionLevel::Write,- }),- ];- let mut permissions = HashMap::new();- permissions.insert("web".to_string(), "read_only".to_string());- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &permissions,- &tools,- &HashSet::new(),- );-- let rendered = render_tool_policy_boundary(&session, 2048).expect("boundary");-- assert!(rendered.contains("## Tool Policy Boundary"));- assert!(rendered.contains("Agent: orchestrator"));- assert!(rendered.contains("Allowed tools: 1 (the tools in your list)"));- assert!(- !rendered.contains("read_notes"),- "names ride on the schemas, not here"- );- assert!(rendered.contains("Restricted tools: 1 omitted by policy"));- assert!(!rendered.contains("write_notes"));-}--#[test]-fn render_prompt_boundary_is_bounded() {- let tools: Vec<Box<dyn Tool>> = (0..80)- .map(|idx| {- Box::new(PromptTestTool {- name: format!("long_tool_name_{idx}_with_extra_context"),- permission: PermissionLevel::Write,- }) as Box<dyn Tool>- })- .collect();- let mut permissions = HashMap::new();- permissions.insert("web".to_string(), "read_only".to_string());- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &permissions,- &tools,- &HashSet::new(),- );-- let rendered = render_tool_policy_boundary(&session, 192).expect("boundary");-- assert!(rendered.len() <= 192);- assert!(rendered.is_char_boundary(rendered.len()));-}--#[test]-fn empty_policy_session_renders_none() {- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &HashMap::new(),- &[],- &HashSet::new(),- );-- assert!(render_tool_policy_boundary(&session, 2048).is_none());-}--#[test]-fn unrestricted_policy_session_renders_none() {- let tools: Vec<Box<dyn Tool>> = vec![Box::new(PromptTestTool {- name: "write_notes".into(),- permission: PermissionLevel::Write,- })];- let session = ToolPolicyEngine::build_session(- "orchestrator",- "web",- "chat",- &HashMap::new(),- &tools,- &HashSet::new(),- );-- assert!(render_tool_policy_boundary(&session, 2048).is_none());-}diff --git a/crates/openhuman-core/src/tools/agent_policy/types.rs b/crates/openhuman-core/src/tools/agent_policy/types.rsdeleted file mode 100644index ca5f13dfb8..0000000000--- a/crates/openhuman-core/src/tools/agent_policy/types.rs+++ /dev/null@@ -1,186 +0,0 @@-use std::collections::{BTreeSet, HashMap, HashSet};-use tinytools::PermissionLevel;--const NO_TOOLS_ALLOWED_SENTINEL: &str = "__openhuman_no_policy_allowed_tools__";--/// Coarse task risk derived from the highest permission level allowed for the-/// session.-#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum TaskRiskLevel {- Low,- Medium,- High,- Critical,-}--impl TaskRiskLevel {- pub fn from_allowed_permission(permission: PermissionLevel) -> Self {- match permission {- PermissionLevel::None | PermissionLevel::ReadOnly => Self::Low,- PermissionLevel::Write => Self::Medium,- PermissionLevel::Execute => Self::High,- PermissionLevel::Dangerous => Self::Critical,- }- }-}--impl std::fmt::Display for TaskRiskLevel {- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {- match self {- Self::Low => write!(f, "low"),- Self::Medium => write!(f, "medium"),- Self::High => write!(f, "high"),- Self::Critical => write!(f, "critical"),- }- }-}--/// Resolved task profile for one agent session.-#[derive(Debug, Clone, PartialEq, Eq)]-pub struct TaskProfile {- pub agent_id: String,- pub channel: String,- pub entrypoint: String,- pub risk_level: TaskRiskLevel,- pub allowed_permission: PermissionLevel,-}--/// Policy action for a tool in the current session.-#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum ToolPolicyAction {- Allow,- RequireApproval,- Deny,- HideFromPrompt,-}--/// Deterministic decision for a specific tool name.-#[derive(Debug, Clone, PartialEq, Eq)]-pub struct ToolPolicyDecision {- pub tool_name: String,- pub action: ToolPolicyAction,- pub required_permission: Option<PermissionLevel>,- pub allowed_permission: PermissionLevel,-}--impl ToolPolicyDecision {- /// Anything that is not a plain `Allow` — **including `HideFromPrompt`**.- ///- /// This is the right question for a *direct* call: a tool the model was- /// never shown has no business being called by name, and refusing it is a- /// deliberate safety property (see `host::security_gate`).- ///- /// It is the wrong question for `use_skill`. See- /// [`Self::blocks_execution`].- pub fn is_denied(&self) -> bool {- !matches!(self.action, ToolPolicyAction::Allow)- }-- /// Whether this tool may not be *executed*, as opposed to merely being kept- /// off the prompt.- ///- /// `HideFromPrompt` is not an execution denial. It is the normal, healthy- /// state of every withheld packed tool — AGENTS.md's disclosure table spells- /// it out: `Withheld` means "Schemas on the wire: no (reached via- /// `load_skill` / `use_skill`)", "Registered and callable: **yes**".- ///- /// Conflating the two is a live bug with teeth: `use_skill` is the only- /// route a withheld tool has, and gating it on [`Self::is_denied`] refused- /// every single one of them — the whole pack mechanism, not an edge case.- /// An unknown tool still lands here, because `decision_for` defaults absent- /// names to `Deny`: a tool this session does not have is genuinely not- /// callable, which is the distinction that keeps owner-only tools out.- pub fn blocks_execution(&self) -> bool {- if matches!(- self.action,- ToolPolicyAction::Deny | ToolPolicyAction::RequireApproval- ) {- return true;- }- // The permission ceiling, re-checked here because the classifier cannot- // have applied it. `build_session_from_refs` tests `explicitly_hidden`- // BEFORE `exceeds_permission`, so a tool that is both hidden *and* over- // the ceiling is recorded as `HideFromPrompt` and its permission verdict- // is never taken. `is_denied()` used to mask that by treating every- // hidden tool as blocked; a predicate that deliberately admits hidden- // tools has to carry the ceiling itself or it hands `use_skill` a- // laundering route into a tool the channel would refuse.- matches!(- self.required_permission,- Some(required) if required > self.allowed_permission- )- }-}--/// Tool metadata used by prompt and policy summaries.-#[derive(Debug, Clone, PartialEq, Eq)]-pub struct ToolCapability {- pub name: String,- pub required_permission: PermissionLevel,-}--/// Immutable policy snapshot attached to an `Agent` session.-#[derive(Debug, Clone, PartialEq, Eq)]-pub struct ToolPolicySession {- pub profile: TaskProfile,- pub capabilities: Vec<ToolCapability>,- pub allowed_tool_names: BTreeSet<String>,- pub blocked_tool_names: BTreeSet<String>,- pub hidden_tool_names: BTreeSet<String>,- pub decisions: HashMap<String, ToolPolicyDecision>,-}--impl ToolPolicySession {- pub fn is_allowed(&self, tool_name: &str) -> bool {- self.allowed_tool_names.contains(tool_name)- }-- pub fn has_restrictions(&self) -> bool {- !self.blocked_tool_names.is_empty() || !self.hidden_tool_names.is_empty()- }-- pub fn restricted_tool_count(&self) -> usize {- self.blocked_tool_names.len() + self.hidden_tool_names.len()- }-- pub fn visible_tool_names_for_prompt(&self) -> HashSet<String> {- if !self.has_restrictions() {- return HashSet::new();- }- let mut names: HashSet<String> = self.allowed_tool_names.iter().cloned().collect();- if names.is_empty() {- names.insert(NO_TOOLS_ALLOWED_SENTINEL.to_string());- }- names- }-- pub fn decision_for(&self, tool_name: &str) -> ToolPolicyDecision {- self.decisions- .get(tool_name)- .cloned()- .unwrap_or_else(|| ToolPolicyDecision {- tool_name: tool_name.to_string(),- action: ToolPolicyAction::Deny,- required_permission: None,- allowed_permission: self.profile.allowed_permission,- })- }-- /// Refuse `names` outright, whatever they were classified as.- ///- /// For a rule applied after classification that narrows what it allowed, so- /// every reader of this snapshot (the gate, a pack listing, the bare-call- /// router) refuses the same tools. A name with no decision is already refused- /// by [`Self::decision_for`] and is left alone.- pub fn deny<'n>(&mut self, names: impl IntoIterator<Item = &'n str>) {- for name in names {- let Some(decision) = self.decisions.get_mut(name) else {- continue;- };- decision.action = ToolPolicyAction::Deny;- self.allowed_tool_names.remove(name);- self.hidden_tool_names.remove(name);- self.blocked_tool_names.insert(name.to_string());- }- }-}diff --git a/crates/openhuman-core/src/tools/impl/meta/deferred.rs b/crates/openhuman-core/src/tools/impl/meta/deferred.rsdeleted file mode 100644index 87f0747496..0000000000--- a/crates/openhuman-core/src/tools/impl/meta/deferred.rs+++ /dev/null@@ -1,113 +0,0 @@-//! The host's half of [`ToolExposure::Deferred`](tinytools::ToolExposure):-//! which registered tools leave the wire, so the harness can advertise-//! `tool_search` in their place.-//!-//! # Why this exists-//!-//! Tool schemas are a fixed cost paid on every request. Measured on the-//! orchestrator with an empty workspace, they were 45,199 bytes against 33,808-//! bytes of system prompt; on a signed-in workspace with Composio connected-//! they reached ~112 KB. Most of that is tools the model reaches for on a-//! handful of turns a week.-//!-//! `Deferred` takes such a tool off the wire without removing the capability.-//! The tinyagents harness owns the other half of that bargain — the intrinsic-//! `tool_search` bridge, the BM25 catalogue, and the pluggable-//! ranker a decision model plugs into (`tool::discover`). This host used to-//! register a `tool_search` of its own, which the harness honoured over its-//! intrinsic; that tool could *find* a deferred tool but the turn allowlist-//! never registered it, so the find was unusable. Now the host only decides-//! what is deferred and hands the harness both sets: the advertised names as-//! the wire surface and the deferred names as still-callable registrations.-//!-//! # Why not the toolpack mechanism-//!-//! Packs answer a different question. A pack is a *group* withheld by a config-//! posture, recovered through `use_skill`, and its membership is compiled in-//! precisely so config cannot move a dangerous tool out of the reviewed-//! surface. That is the right shape for compressing a belt an agent owns.-//!-//! Deferral is per-tool and is a property of the tool: `stock_quote` is rarely-//! needed whoever is running the host. The two compose — a deferred tool inside-//! a withheld pack is simply absent twice — and neither can widen the surface,-//! because both only ever subtract from a set the belt and the security policy-//! already decided.--use std::collections::HashSet;--use tinytools::{Tool, ToolExposure};--/// The name an agent lists in `[tools] named` to opt a hand-written belt into-/// discovery. It is not a registered tool: the harness advertises its own-/// intrinsic `tool_search` whenever a run has a deferred tool, so the name in-/// a belt is a request for that, and the builder strips it from the allowlist.-pub const TOOL_SEARCH_NAME: &str = "tool_search";--/// Remove every [`ToolExposure::Deferred`] and [`ToolExposure::Hidden`] tool-/// from an agent's advertised set, returning the names of the deferred ones so-/// the caller can keep them registered.-///-/// Hidden tools are dropped and **not** returned: they are not searchable-/// either, by definition.-pub fn strip_deferred_from_visible(- visible: &mut HashSet<String>,- tools: &[Box<dyn Tool>],-) -> HashSet<String> {- let mut deferred = HashSet::new();- for tool in tools {- let name = tool.name();- if !visible.contains(name) {- continue;- }- match tool.exposure() {- ToolExposure::Direct => {}- ToolExposure::Deferred => {- visible.remove(name);- deferred.insert(name.to_string());- }- ToolExposure::Hidden => {- visible.remove(name);- }- }- }- deferred-}--/// Every [`ToolExposure::Deferred`] tool in `tools`, by name — the catalogue a-/// belt that opted into discovery can reach whether or not it named them.-pub fn deferred_tool_names(tools: &[Box<dyn Tool>]) -> HashSet<String> {- tools- .iter()- .filter(|tool| tool.exposure() == ToolExposure::Deferred)- .map(|tool| tool.name().to_string())- .collect()-}--/// The deferred set of a belt that opted into discovery: every-/// [`ToolExposure::Deferred`] tool in `durable` and `synthesized`, plus the-/// `Direct` tools its agent definition lists in `deferred_tools`.-///-/// Exposure is a property of the tool and applies to every agent; a-/// definition's `deferred_tools` is the per-agent half. It takes a tool that-/// other belts keep advertised (`file_read` for a coding worker) off this-/// agent's wire only, where it stays registered, searchable through-/// `tool_search`, and callable by its own name. A requested name that is not-/// registered, or is `Hidden`, is ignored: deferral only ever subtracts.-pub fn deferred_set(- durable: &[Box<dyn Tool>],- synthesized: &[Box<dyn Tool>],- requested: &[String],-) -> HashSet<String> {- let mut deferred = deferred_tool_names(durable);- deferred.extend(deferred_tool_names(synthesized));- for tool in durable.iter().chain(synthesized.iter()) {- if tool.exposure() == ToolExposure::Direct && requested.iter().any(|r| r == tool.name()) {- deferred.insert(tool.name().to_string());- }- }- deferred-}--#[cfg(test)]-#[path = "deferred_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/tools/impl/meta/deferred_tests.rs b/crates/openhuman-core/src/tools/impl/meta/deferred_tests.rsdeleted file mode 100644index d5489d8af0..0000000000--- a/crates/openhuman-core/src/tools/impl/meta/deferred_tests.rs+++ /dev/null@@ -1,98 +0,0 @@-use std::collections::HashSet;--use serde_json::json;-use tinytools::{Tool, ToolExposure, ToolResult};--use super::{deferred_set, deferred_tool_names, strip_deferred_from_visible};--struct Fake(&'static str, ToolExposure);--#[async_trait::async_trait]-impl Tool for Fake {- fn name(&self) -> &str {- self.0- }- fn description(&self) -> &str {- "fake"- }- fn parameters_schema(&self) -> serde_json::Value {- json!({"type": "object"})- }- fn exposure(&self) -> ToolExposure {- self.1- }- async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {- Ok(ToolResult::success("ok"))- }-}--fn tools() -> Vec<Box<dyn Tool>> {- vec![- Box::new(Fake("direct", ToolExposure::Direct)),- Box::new(Fake("deferred", ToolExposure::Deferred)),- Box::new(Fake("hidden", ToolExposure::Hidden)),- Box::new(Fake("unlisted_deferred", ToolExposure::Deferred)),- ]-}--#[test]-fn strip_removes_deferred_and_hidden_but_returns_only_deferred() {- let mut visible: HashSet<String> = ["direct", "deferred", "hidden"]- .into_iter()- .map(String::from)- .collect();- let deferred = strip_deferred_from_visible(&mut visible, &tools());- assert_eq!(visible, HashSet::from(["direct".to_string()]));- assert_eq!(deferred, HashSet::from(["deferred".to_string()]));-}--#[test]-fn strip_ignores_tools_the_belt_never_named() {- let mut visible: HashSet<String> = HashSet::from(["direct".to_string()]);- let deferred = strip_deferred_from_visible(&mut visible, &tools());- assert!(deferred.is_empty());- assert_eq!(visible.len(), 1);-}--#[test]-fn deferred_tool_names_lists_every_deferred_registration() {- assert_eq!(- deferred_tool_names(&tools()),- HashSet::from(["deferred".to_string(), "unlisted_deferred".to_string()])- );-}--/// An agent definition's `deferred_tools` adds its `Direct` tools to the-/// deferred set, on top of every `Deferred` registration in both sets. A-/// requested name that is not registered, or is `Hidden`, is ignored: deferral-/// only subtracts, so it can neither invent a tool nor make a hidden one-/// searchable.-#[test]-fn deferred_set_adds_requested_direct_tools_and_nothing_else() {- let durable = tools();- let synthesized: Vec<Box<dyn Tool>> = vec![- Box::new(Fake("synth_direct", ToolExposure::Direct)),- Box::new(Fake("synth_deferred", ToolExposure::Deferred)),- ];- let requested: Vec<String> = ["direct", "synth_direct", "hidden", "not_registered"]- .into_iter()- .map(String::from)- .collect();- let set = deferred_set(&durable, &synthesized, &requested);- let expected: HashSet<String> = [- "direct",- "synth_direct",- "deferred",- "unlisted_deferred",- "synth_deferred",- ]- .into_iter()- .map(String::from)- .collect();- assert_eq!(set, expected);-- // Nothing requested: exactly the exposure-derived set.- let plain = deferred_set(&durable, &synthesized, &[]);- assert!(!plain.contains("direct") && !plain.contains("synth_direct"));- assert!(plain.contains("synth_deferred") && plain.contains("deferred"));-}diff --git a/crates/openhuman-core/src/tools/impl/meta/mod.rs b/crates/openhuman-core/src/tools/impl/meta/mod.rsdeleted file mode 100644index 7d8fe1bd01..0000000000--- a/crates/openhuman-core/src/tools/impl/meta/mod.rs+++ /dev/null@@ -1,14 +0,0 @@-//! Tools *about* the tool surface itself.-//!-//! One member: [`deferred`], the host's half of-//! [`ToolExposure::Deferred`](tinytools::ToolExposure) — which registered tools-//! leave the wire so the harness can advertise its `tool_search` bridge in-//! their place. They sit in their own family rather than under `system/`-//! because it is not a capability the host offers the user — it is the model-//! asking what it is able to do.--pub mod deferred;--pub use deferred::{- deferred_set, deferred_tool_names, strip_deferred_from_visible, TOOL_SEARCH_NAME,-};diff --git a/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rs b/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rsindex 7da1eabee6..6695e34b93 100644--- a/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rs+++ b/crates/openhuman-core/src/tools/ops_tests_default_registry_tests.rs@@ -30,7 +30,7 @@ fn all_tools_registers_the_memory_tool_while_memory_is_on() {// registered tool: a host `tool_search` would shadow it.assert!(!tools.iter()- .any(|tool| { tool.name() == crate::tools::implementations::meta::TOOL_SEARCH_NAME }));+ .any(|tool| { tool.name() == tinytools::TOOL_SEARCH_NAME }));}/// The three `whatsapp_data_*` agent tools are gone, in every build.///diff --git a/crates/openhuman-core/src/tools/registry/denials.rs b/crates/openhuman-core/src/tools/registry/denials.rsdeleted file mode 100644index 32137549cd..0000000000--- a/crates/openhuman-core/src/tools/registry/denials.rs+++ /dev/null@@ -1,78 +0,0 @@-use std::collections::VecDeque;-use std::sync::Mutex;-use std::time::{SystemTime, UNIX_EPOCH};--use super::types::RecentPolicyDenial;--const MAX_DENIALS: usize = 50;-const MAX_REASON_CHARS: usize = 240;--static RECENT_DENIALS: Mutex<VecDeque<RecentPolicyDenial>> = Mutex::new(VecDeque::new());--pub fn record(tool_name: &str, policy: &str, action: &str, reason: &str) {- let tool_name = tool_name.trim();- if tool_name.is_empty() {- return;- }-- let policy = policy.trim();- let action = action.trim();- let reason = truncate_reason(&redact_sensitive(reason.trim()));-- let timestamp_ms = SystemTime::now()- .duration_since(UNIX_EPOCH)- .map(|d| d.as_millis() as i64)- .unwrap_or(0);-- let record = RecentPolicyDenial {- timestamp_ms,- tool_name: tool_name.to_string(),- policy: if policy.is_empty() {- "unknown".to_string()- } else {- policy.to_string()- },- action: if action.is_empty() {- "blocked".to_string()- } else {- action.to_string()- },- reason,- };-- let mut buf = RECENT_DENIALS.lock().unwrap_or_else(|p| p.into_inner());- buf.push_front(record);- while buf.len() > MAX_DENIALS {- buf.pop_back();- }-}--pub fn list(limit: usize) -> Vec<RecentPolicyDenial> {- let limit = limit.min(MAX_DENIALS);- let buf = RECENT_DENIALS.lock().unwrap_or_else(|p| p.into_inner());- buf.iter().take(limit).cloned().collect()-}--fn redact_sensitive(input: &str) -> String {- for marker in ["Bearer ", "sk-", "ghp_", "-----BEGIN"] {- if input.contains(marker) {- return "[redacted: sensitive content]".to_string();- }- }- input.to_string()-}--fn truncate_reason(reason: &str) -> String {- if reason.is_empty() {- return "<empty>".to_string();- }- if reason.chars().count() <= MAX_REASON_CHARS {- return reason.to_string();- }- let truncated: String = reason.chars().take(MAX_REASON_CHARS).collect();- format!("{truncated}…")-}--#[cfg(test)]-#[path = "denials_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/tools/registry/denials_tests.rs b/crates/openhuman-core/src/tools/registry/denials_tests.rsdeleted file mode 100644index eb09229dff..0000000000--- a/crates/openhuman-core/src/tools/registry/denials_tests.rs+++ /dev/null@@ -1,49 +0,0 @@-use super::*;--// These tests intentionally mutate the process-global denial buffer. Keep-// their clear/record/assert sequences atomic with respect to one another;-// the parallel libtest runner can otherwise clear a sibling's freshly-// recorded value between `record` and `list`.-static DENIAL_TEST_LOCK: Mutex<()> = Mutex::new(());--fn clear_denials_for_test() {- let mut buf = RECENT_DENIALS.lock().unwrap_or_else(|p| p.into_inner());- buf.clear();-}--#[test]-fn record_truncates_and_bounds() {- let _guard = DENIAL_TEST_LOCK.lock().unwrap_or_else(|p| p.into_inner());- clear_denials_for_test();- let long = "a".repeat(10_000);- for _ in 0..(MAX_DENIALS + 5) {- record("tool.x", "policy", "denied", &long);- }- let listed = list(999);- assert_eq!(listed.len(), MAX_DENIALS);- assert!(listed[0].reason.len() < 300);- assert_eq!(listed[0].tool_name, "tool.x");-}--#[test]-fn record_ignores_empty_tool() {- let _guard = DENIAL_TEST_LOCK.lock().unwrap_or_else(|p| p.into_inner());- clear_denials_for_test();- record(" ", "policy", "denied", "reason");- // list() should not panic; we can't reliably assert length because tests may run in parallel.- let _ = list(10);-}--#[test]-fn record_redacts_sensitive_reason_fragments() {- let _guard = DENIAL_TEST_LOCK.lock().unwrap_or_else(|p| p.into_inner());- clear_denials_for_test();- record(- "tool.secret",- "policy",- "denied",- "blocked: Bearer abcdefghijklmnopqrstuvwxyz",- );- let listed = list(1);- assert_eq!(listed[0].reason, "[redacted: sensitive content]");-}diff --git a/crates/openhuman-core/src/tools/registry/types.rs b/crates/openhuman-core/src/tools/registry/types.rsdeleted file mode 100644index 445970634f..0000000000--- a/crates/openhuman-core/src/tools/registry/types.rs+++ /dev/null@@ -1,129 +0,0 @@-use serde::Serialize;-use serde_json::Value;--/// Serialized discovery metadata for one OpenHuman tool surface.-#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct ToolRegistryEntry {- /// Stable unique registry id, such as `memory.recall` or `tools.web_search`.- pub tool_id: String,- /// Machine-readable tool name exposed by the source surface.- pub name: String,- /// Human-readable display title.- pub title: String,- /// Short description suitable for agents and dashboards.- pub description: String,- /// Registry entry schema/version marker, currently the core crate version.- pub version: String,- /// Transport used to call the tool.- pub transport: ToolRegistryTransport,- /// Transport-specific route metadata.- pub route: Value,- /// JSON Schema for accepted input parameters.- pub input_schema: Value,- /// JSON Schema for the successful output shape.- pub output_schema: Value,- /// Agent ids allowed to discover/use the tool; `*` means unrestricted in this MVP.- pub allowed_agents: Vec<String>,- /// Search/filter tags derived from the source namespace and tool purpose.- pub tags: Vec<String>,- /// Whether the tool is currently enabled in the static registry.- pub enabled: bool,- /// Current health state for discovery consumers.- pub health: ToolRegistryHealth,-}--/// Transport family used to route a registry entry.-#[derive(Debug, Clone, PartialEq, Eq, Serialize)]-#[serde(rename_all = "snake_case")]-pub enum ToolRegistryTransport {- /// Existing HTTP JSON-RPC controller method.- JsonRpc,- /// Existing stdio Model Context Protocol `tools/call` surface.- McpStdio,-}--/// Health state exposed by the registry.-#[derive(Debug, Clone, PartialEq, Eq, Serialize)]-#[serde(rename_all = "snake_case")]-pub enum ToolRegistryHealth {- /// The tool is statically registered and available for discovery.- Available,- /// Health cannot currently be determined.- Unknown,-}--/// Response payload for `openhuman.tool_registry_list`.-#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct ToolRegistryList {- /// Sorted registry entries.- pub tools: Vec<ToolRegistryEntry>,-}--/// Redacted diagnostics for policy/tool visibility reviews.-#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct ToolPolicyDiagnostics {- pub total_tools: usize,- pub enabled_tools: usize,- pub mcp_stdio_tools: usize,- pub json_rpc_tools: usize,- pub possible_write_surfaces: Vec<String>,- pub policy_surfaces: Vec<String>,- pub posture: ToolPolicyPosture,- pub mcp_allowlists: McpAllowlistDiagnostics,- pub mcp_write_audit: McpWriteAuditHealth,- pub recent_denials: Vec<RecentPolicyDenial>,- pub capability_providers: CapabilityProviderDiagnostics,-}--#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct ToolPolicyPosture {- pub autonomy_level: String,- pub workspace_only: bool,- pub max_actions_per_hour: u32,- pub require_approval_for_medium_risk: bool,- pub block_high_risk_commands: bool,-}--#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct McpAllowlistDiagnostics {- pub enabled: bool,- pub server_count: usize,- pub enabled_server_count: usize,- pub servers: Vec<McpServerAllowlistSummary>,-}--#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct McpServerAllowlistSummary {- pub name: String,- pub enabled: bool,- pub allowed_tools_count: usize,- pub disallowed_tools_count: usize,- pub has_allowlist: bool,- pub has_denylist: bool,-}--#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct McpWriteAuditHealth {- pub enabled: bool,- pub recent_rows: Option<u64>,- pub last_error: Option<String>,-}--#[derive(Debug, Clone, PartialEq, Serialize)]-pub struct RecentPolicyDenial {- pub timestamp_ms: i64,- pub tool_name: String,- pub policy: String,- pub action: String,- pub reason: String,-}--/// Redacted diagnostics for configured external capability providers.-#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]-pub struct CapabilityProviderDiagnostics {- pub total_providers: usize,- pub enabled_providers: usize,- pub trusted_providers: usize,- pub trusted_enabled_providers: usize,- pub registry_errors: Vec<String>,-}diff --git a/crates/openhuman-core/src/tools/toolpacks/ops.rs b/crates/openhuman-core/src/tools/toolpacks/ops.rsindex 0bfa4fb820..2e42a6a17e 100644--- a/crates/openhuman-core/src/tools/toolpacks/ops.rs+++ b/crates/openhuman-core/src/tools/toolpacks/ops.rs@@ -208,7 +208,7 @@ pub fn closed_by_direct_handoff(agent_id: &str, tools: &[&dyn Tool]) -> Vec<&'st/// closed tool becomes `Deny`, so the `use_skill` gate, the pack listing and the/// bare-call router all refuse it from one decision.pub fn close_handed_off_packs(- session: &mut crate::tools::agent_policy::ToolPolicySession,+ session: &mut tinytools::ToolPolicySession,agent_id: &str,tools: &[&dyn Tool],) {diff --git a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rsindex 6d7ba1b7ba..2923575f2d 100644--- a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs+++ b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests_scoping_and_visibility_tests.rs@@ -117,7 +117,7 @@ fn scoping_the_index_only_ever_shrinks_it() {/// call it" predicate built on `is_denied()` therefore eats the whole pack.#[test]fn a_withheld_packed_tool_is_hidden_but_not_denied() {- use crate::tools::agent_policy::{ToolPolicyAction, ToolPolicyEngine};+ use tinytools::{ToolPolicyAction, ToolPolicyEngine};let tools = registry_with_all(&["goal_set", "build_workflow"]);// The real shape: the harness seeds `visible` with everything, then@@ -160,7 +160,7 @@ fn a_withheld_packed_tool_is_hidden_but_not_denied() {/// becomes a laundering route into a tool the channel would refuse.#[test]fn a_hidden_tool_over_the_permission_ceiling_still_blocks_execution() {- use crate::tools::agent_policy::{ToolPolicyAction, ToolPolicyDecision};+ use tinytools::{ToolPolicyAction, ToolPolicyDecision};let over = ToolPolicyDecision {tool_name: "dangerous_packed_tool".to_string(),@@ -433,7 +433,7 @@ fn a_packed_hand_off_leaves_its_owners_pack_open() {#[test]fn a_named_scope_session_closes_the_pack_its_visible_list_never_mentions() {use crate::agent::orchestration::tools::{ArchetypeDelegationTool, DelegationTarget};- use crate::tools::agent_policy::ToolPolicyEngine;+ use tinytools::ToolPolicyEngine;let delegate: Box<dyn tinytools::Tool> = Box::new(ArchetypeDelegationTool {tool_name: "hand_off_to_skill_setup".to_string(),