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
chore: files changed crates/openhuman-core/src/flows/tinyflows/caps/tier.rs
Steven Enamakel01714853262f
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/tier.rs b/crates/openhuman-core/src/flows/tinyflows/caps/tier.rsindex aa6f561f37..4c4d26fc94 100644--- a/crates/openhuman-core/src/flows/tinyflows/caps/tier.rs+++ b/crates/openhuman-core/src/flows/tinyflows/caps/tier.rs@@ -70,6 +70,82 @@ pub(crate) fn enforce_node_tier_gate(Ok(decision)}+/// Loads the tier visible to one flow dispatch while keeping the policy's+/// workspace roots, action budget tracker, and other fixed fields from the+/// capability's original policy.+pub(crate) async fn current_tier_policy(+ ctx: &crate::core::runtime::DispatchCtx,+ captured_config: &crate::config::Config,+ baseline: &SecurityPolicy,+) -> Result<SecurityPolicy> {+ let live = match ctx.autonomy_tier_source() {+ crate::core::runtime::AutonomyTierSource::Captured => None,+ crate::core::runtime::AutonomyTierSource::LiveConfig => Some(+ crate::config::ops::reload_config_snapshot_with_timeout(captured_config)+ .await+ .map_err(|error| tier_config_error(&error))?,+ ),+ };+ Ok(tier_policy_from_config(ctx, captured_config, live.as_ref(), baseline))+}++/// Uses an already reloaded live config when the caller needs that same+/// snapshot for another part of its operation (Composio integrations).+pub(crate) fn tier_policy_from_config(+ ctx: &crate::core::runtime::DispatchCtx,+ captured_config: &crate::config::Config,+ live_config: Option<&crate::config::Config>,+ baseline: &SecurityPolicy,+) -> SecurityPolicy {+ let config = match ctx.autonomy_tier_source() {+ crate::core::runtime::AutonomyTierSource::Captured => captured_config,+ crate::core::runtime::AutonomyTierSource::LiveConfig => {+ live_config.unwrap_or(captured_config)+ }+ };+ let mut policy = baseline.clone();+ policy.enabled = config.autonomy.enabled;+ policy.autonomy = config.autonomy.level;+ if let Some(ceiling) = ctx.autonomy_tier_ceiling() {+ policy.enabled = true;+ policy.autonomy = stricter_tier(policy.autonomy, ceiling);+ }+ policy+}++/// Async counterpart used by the host adapters. Config failures are policy+/// failures and carry the harness's permanent-block marker so the run cannot+/// proceed using a stale permissive tier.+pub(crate) async fn enforce_current_node_tier_gate(+ ctx: &crate::core::runtime::DispatchCtx,+ captured_config: &crate::config::Config,+ baseline: &SecurityPolicy,+ class: CommandClass,+ node: &str,+) -> Result<GateDecision> {+ let policy = current_tier_policy(ctx, captured_config, baseline).await?;+ enforce_node_tier_gate(&policy, class, node)+}++fn tier_config_error(error: &str) -> EngineError {+ EngineError::Capability(format!(+ "{POLICY_BLOCKED_MARKER} flows autonomy tier could not be refreshed; refusing the node: {error}"+ ))+}++fn stricter_tier(+ tier: crate::security::AutonomyLevel,+ ceiling: crate::security::AutonomyLevel,+) -> crate::security::AutonomyLevel {+ use crate::security::AutonomyLevel::{Full, ReadOnly, Supervised};++ match (tier, ceiling) {+ (ReadOnly, _) | (_, ReadOnly) => ReadOnly,+ (Supervised, _) | (_, Supervised) => Supervised,+ (Full, Full) => Full,+ }+}+/// Dispatches to the process-global [`ApprovalGate`](crate::security::approval::ApprovalGate),/// escalating a `Prompt`-tier decision into a forced human-in-the-loop round/// trip regardless of the running flow's own `require_approval` toggle.