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(platform): move scheduler gate to platform::llm_gate
Steven Enamakele612f458ff6a
diff --git a/crates/openhuman-core/Cargo.toml b/crates/openhuman-core/Cargo.tomlindex a6e1bdedee..aa55900158 100644--- a/crates/openhuman-core/Cargo.toml+++ b/crates/openhuman-core/Cargo.toml@@ -374,7 +374,7 @@ sentry = { version = "0.47.0", default-features = false, optional = true, featururl = "2"tempfile = "3"fs2 = "0.4"-# The scheduler gate's battery/AC probe (`cron::scheduler_gate::signals`),+# The scheduler gate's battery/AC probe (`platform::llm_gate::signals`),# behind the `scheduler-gate` feature. CPU sampling uses `sysinfo` above.starship-battery = { version = "0.12", optional = true }diff --git a/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rsindex ad85d23ff2..661454e109 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs@@ -3,7 +3,7 @@//!//! This is `docs/specs/plan-agents.md` Phase 4. The agent runtime is being made//! generic over its host, so it can no longer reach into-//! [`crate::cron::scheduler_gate`] or [`crate::cost`] directly.+//! [`crate::platform::llm_gate`] or [`crate::cost`] directly.//! It declares [`BudgetGate`] instead, and this module is the single place//! OpenHuman's three metering concerns meet it://!@@ -67,7 +67,7 @@ use tinyagents_harness::host::budget_gate::{use tinyinference_llm::usage::Usage;use crate::config::{Config, DEFAULT_MODEL};-use crate::cron::scheduler_gate;+use crate::platform::llm_gate;use crate::platform::cost;use tinyjuice_bus::types::AgentTokenjuiceCompression;diff --git a/crates/openhuman-core/src/agent/triage/README.md b/crates/openhuman-core/src/agent/triage/README.mdindex ae616fec84..0dfc717880 100644--- a/crates/openhuman-core/src/agent/triage/README.md+++ b/crates/openhuman-core/src/agent/triage/README.md@@ -52,7 +52,7 @@ route, so the initial attempt never depends on a local model being up.`local_ai.runtime_enabled` is set and a `chat_model_id` is configured;otherwise the chain skips straight to `Deferred`.-Only the local arm takes the `cron::scheduler_gate::wait_for_capacity`+Only the local arm takes the `platform::llm_gate::wait_for_capacity`permit (held for the duration of that turn); cloud attempts do not wait onthe gate. Tests use a `_for_test` variant that skips the permit.@@ -108,7 +108,7 @@ Re-exported from [`mod.rs`](./mod.rs):`decision.rs` parses.- [`crates/openhuman-core/src/agent/registry/agents/trigger_reactor/`](../registry/agents/trigger_reactor/): thesingle-step sub-agent `react` decisions dispatch to.-- [`crates/openhuman-core/src/cron/scheduler_gate/README.md`](../../cron/scheduler_gate/README.md): the LLM-permit+- [`crates/openhuman-core/src/platform/llm_gate/README.md`](../../platform/llm_gate/README.md): the LLM-permitgate the local arm waits on.- [Parent module README](../README.md)- [Triggers](../../../../../docs/gitbooks/en/features/integrations/triggers.md)diff --git a/crates/openhuman-core/src/agent/triage/evaluator/chain.rs b/crates/openhuman-core/src/agent/triage/evaluator/chain.rsindex d7bdb5e125..309b8f15bf 100644--- a/crates/openhuman-core/src/agent/triage/evaluator/chain.rs+++ b/crates/openhuman-core/src/agent/triage/evaluator/chain.rs@@ -99,7 +99,7 @@ pub async fn run_triage(}/// Test-only entry point: skip the global LLM permit acquisition so the-/// triage tests don't contend with `scheduler_gate`'s process-wide+/// triage tests don't contend with `llm_gate`'s process-wide/// 1-slot semaphore or get trapped by a stale `Paused` policy left in/// `STATE` by another test's `init_global` call.#[cfg(test)]diff --git a/crates/openhuman-core/src/channels/runtime/session_tests.rs b/crates/openhuman-core/src/channels/runtime/session_tests.rsindex f5c2a1c76a..6aa6d4da36 100644--- a/crates/openhuman-core/src/channels/runtime/session_tests.rs+++ b/crates/openhuman-core/src/channels/runtime/session_tests.rs@@ -6,7 +6,7 @@ use std::sync::Arc;#[tokio::test]async fn independent_local_runtime_does_not_need_an_account_session() {let _guard = crate::inference::inference_test_guard_async().await;- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);run_in_session(CancellationToken::new(), async { Ok(()) }).await.unwrap();@@ -85,7 +85,7 @@ async fn clear_session_invalidates_old_channels_and_opens_a_fresh_generation() {config_path: tmp.path().join("config.toml"),..Default::default()};- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(false);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(false);let old_session = channel_session();crate::security::credentials::ops::clear_session(&DispatchCtx::process_default(), &config).awaitdiff --git a/crates/openhuman-core/src/config/schema/scheduler_gate.rs b/crates/openhuman-core/src/config/schema/scheduler_gate.rsindex 43f126ff4e..84c578c40d 100644--- a/crates/openhuman-core/src/config/schema/scheduler_gate.rs+++ b/crates/openhuman-core/src/config/schema/scheduler_gate.rs@@ -1,6 +1,6 @@//! Scheduler-gate configuration — controls when background AI work runs.//!-//! Consumed by `cron::scheduler_gate`.+//! Consumed by `platform::llm_gate`.use schemars::JsonSchema;use serde::{Deserialize, Serialize};@@ -110,11 +110,11 @@ impl Default for SchedulerGateConfig {// ── Gate decision vocabulary ────────────────────────────────────────────────//// `Policy` and `PauseReason` moved here from the host's-// `cron::scheduler_gate::policy` because the extracted sync loops read them on+// `platform::llm_gate::policy` because the extracted sync loops read them on// every tick to decide whether to back off. They are inert `Copy` enums with no// dependencies. The pure *decision function* that produces a `Policy` from// sampled signals lives in `platform::resource_admission`; the product config-// adapter, hardware sampling and cooperative wait stay in `cron::scheduler_gate`.+// adapter, hardware sampling and cooperative wait stay in `platform::llm_gate`./// Why the gate is currently paused. Carried by [`Policy::Paused`] so/// downstream consumers (UI, logging, observability) can surface adiff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rsindex 61246a9141..f90c4929cc 100644--- a/crates/openhuman-core/src/config/schema/types/config.rs+++ b/crates/openhuman-core/src/config/schema/types/config.rs@@ -211,7 +211,7 @@ pub struct Config {/// Background-AI scheduler gate — throttles embeddings and other/// LLM-bound background work based on power/// state, CPU pressure, and deployment mode. See- /// [`crate::cron::scheduler_gate`].+ /// [`crate::platform::llm_gate`].#[serde(default)]pub scheduler_gate: SchedulerGateConfig,diff --git a/crates/openhuman-core/src/core/runtime/subscribers.rs b/crates/openhuman-core/src/core/runtime/subscribers.rsindex 5265572a3b..f9f07b4387 100644--- a/crates/openhuman-core/src/core/runtime/subscribers.rs+++ b/crates/openhuman-core/src/core/runtime/subscribers.rs@@ -165,7 +165,7 @@ pub(super) fn register_domain_subscribers(// so they observe a real policy on their first iteration (otherwise they// fall back to `Policy::Normal` and miss the initial throttle decision on// battery-powered hosts).- crate::cron::scheduler_gate::init_global(config.scheduler_gate.clone());+ crate::platform::llm_gate::init_global(config.scheduler_gate.clone());// A headless host (Docker / VPS / CI) has no interactive login; it// hands the core a credential through the environment instead. The@@ -188,11 +188,11 @@ pub(super) fn register_domain_subscribers(// 401.if crate::security::credentials::api_key::has_api_key(&config) {log::info!("[auth] api-key credential present at startup — scheduler gate signed in");- crate::cron::scheduler_gate::set_signed_out(false);+ crate::platform::llm_gate::set_signed_out(false);} else {match crate::security::credentials::jwt::get_session_token(&config) {Ok(Some(_)) => {- crate::cron::scheduler_gate::set_signed_out(false);+ crate::platform::llm_gate::set_signed_out(false);}Ok(None) => {log::info!(@@ -201,7 +201,7 @@ pub(super) fn register_domain_subscribers(config.config_path.display(),crate::security::secret_storage::backend_name(),);- crate::cron::scheduler_gate::set_signed_out(true);+ crate::platform::llm_gate::set_signed_out(true);}Err(err) => {log::warn!(@@ -210,7 +210,7 @@ pub(super) fn register_domain_subscribers(config.config_path.display(),crate::security::secret_storage::backend_name(),);- crate::cron::scheduler_gate::set_signed_out(true);+ crate::platform::llm_gate::set_signed_out(true);}}}diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.mdindex 5977bc4eb6..01cfa4d2b5 100644--- a/crates/openhuman-core/src/cron/README.md+++ b/crates/openhuman-core/src/cron/README.md@@ -286,7 +286,7 @@ so two processes sharing one database don't double-advance it.| [`seed.rs`](./seed.rs) | Built-in proactive jobs and pruning of retired rows. || `system_jobs.rs` | `system:<name>` flow rows owned by other domains. || [`tools.rs`](./tools.rs), `tools/` | Agent tools. See [tools/README.md](tools/README.md). |-| `scheduler_gate/` | Host power and CPU policy for background LLM work. Unrelated to the poll loop. See [scheduler_gate/README.md](scheduler_gate/README.md). |+| (moved) | The background-LLM power/CPU gate now lives in [`platform/llm_gate`](../platform/llm_gate/README.md). |## Key types and entry points@@ -379,7 +379,7 @@ Cron publishes, through [`core/bus.rs`](../core/bus.rs), these `DomainEvent` var## Gotchas-- `scheduler_gate` lives here for historical reasons, but the poll loop does not+- the LLM gate (`platform::llm_gate`) is not part of cron; it used to live here, but the poll loop does notconsult it. Its consumers are `modules/memory_host.rs` and[`security/credentials/`](../security/credentials/).- Dispatch is non-blocking: each due job is spawned onto a `JoinSet` bounded bydiff --git a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rsindex 040834f492..a69e23df55 100644--- a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs+++ b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs@@ -145,7 +145,7 @@ async fn inference_gate_reports_signed_out_for_dynamic_agent_ref_only_graph() {//// Built as a struct literal for that reason: `graph()` would reject it,// and going through `graph()` would only prove the rule above twice.- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let tmp = TempDir::new().unwrap();let config = test_config(&tmp);@@ -291,7 +291,7 @@ async fn proposal_omits_inference_status_for_tool_call_only_graph() {/// negative-cache test below (through `cached_probe_inference_readiness`).#[tokio::test]async fn flows_run_fails_cleanly_without_invoking_engine_when_inference_not_ready() {- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let tmp = TempDir::new().unwrap();let config = test_config(&tmp);@@ -357,7 +357,7 @@ async fn flows_run_fails_cleanly_without_invoking_engine_when_inference_not_read#[tokio::test]async fn local_agent_flow_is_ready_without_openhuman_session() {let _inference = crate::inference::inference_test_guard_async().await;- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let tmp = TempDir::new().unwrap();let mut config = test_config(&tmp);config.chat_provider = Some("omlx:test-model".into());@@ -381,7 +381,7 @@ async fn local_agent_flow_is_ready_without_openhuman_session() {#[tokio::test]async fn claude_agent_flow_readiness_does_not_require_an_openhuman_session() {let _inference = crate::inference::inference_test_guard_async().await;- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);// Isolate the caller's session classification from CLI installation/auth// and provider availability. Layer 1 must still reject managed inference// even while the Layer 2 probe has an injected model.@@ -452,7 +452,7 @@ fn harness_readiness_uses_runtime_role_and_node_override() {#[tokio::test]async fn harness_readiness_checks_session_for_execution_provider() {let _inference = crate::inference::inference_test_guard_async().await;- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let _model =crate::inference::provider::factory::test_provider_override::install_model(Arc::new(tinyagents_harness::testkit::ScriptedModel::replies(vec!["OK"]),diff --git a/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs b/crates/openhuman-core/src/flows/ops_inference_gate_tests.rsindex 62d4b3150d..b7444f28c7 100644--- a/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs+++ b/crates/openhuman-core/src/flows/ops_inference_gate_tests.rs@@ -37,7 +37,7 @@ async fn run_builder_gates_does_not_reject_when_signed_out() {// Authoring is never blocked by inference readiness (design correction,// B45): a signed-out session must NOT appear among `run_builder_gates`'// errors for an otherwise-valid agent-node graph.- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let tmp = TempDir::new().unwrap();let config = test_config(&tmp);@@ -64,7 +64,7 @@ async fn proposal_surfaces_signed_out_inference_status() {// The proposal still WARNS about the signed-out state (advisory, never a// rejection) so the UI can render a "sign in" nudge alongside the built// workflow.- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let tmp = TempDir::new().unwrap();let config = test_config(&tmp);diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/runtime_ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops/runtime_ops.rsindex ff3a50e47a..1d14bc232c 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops/runtime_ops.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops/runtime_ops.rs@@ -105,7 +105,7 @@ pub async fn local_ai_vision_prompt(let service = local_ai::global(config);let runtime = crate::inference::local_runtime_config(config);- let Some(_permit) = crate::cron::scheduler_gate::wait_for_capacity().await else {+ let Some(_permit) = crate::platform::llm_gate::wait_for_capacity().await else {return Err("local AI vision inference is paused while signed out".to_string());};let output = servicediff --git a/crates/openhuman-core/src/inference/ops.rs b/crates/openhuman-core/src/inference/ops.rsindex e9ac765320..1a61e9ac5f 100644--- a/crates/openhuman-core/src/inference/ops.rs+++ b/crates/openhuman-core/src/inference/ops.rs@@ -228,7 +228,7 @@ pub async fn inference_analyze_sentiment(User message: {message}");let runtime = crate::inference::local_runtime_config(config);- let Some(_permit) = crate::cron::scheduler_gate::wait_for_capacity().await else {+ let Some(_permit) = crate::platform::llm_gate::wait_for_capacity().await else {return Ok(Outcome::single_log(SentimentResult::neutral(),"local inference paused while signed out",diff --git a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs b/crates/openhuman-core/src/inference/provider/factory/access_gates.rsindex 605fd9319c..f5d7c6fd9c 100644--- a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs+++ b/crates/openhuman-core/src/inference/provider/factory/access_gates.rs@@ -198,7 +198,7 @@ pub(crate) fn verify_backend_session_active(config: &Config) -> anyhow::Result<(return Ok(());}// Fast path: the scheduler gate already knows the session is dead.- if crate::cron::scheduler_gate::is_signed_out() {+ if crate::platform::llm_gate::is_signed_out() {anyhow::bail!("SESSION_EXPIRED: backend session not active — sign in to use custom providers");diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rsindex cfc43e2df0..143f35a947 100644--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_diagnostics_tests.rs@@ -86,7 +86,7 @@ async fn from_string_external_provider_emits_egress_realpath() {#[tokio::test]async fn caller_owned_models_build_without_openhuman_session() {let _guard = crate::inference::inference_test_guard_async().await;- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let dir = tempfile::tempdir().unwrap();let config = Config {config_path: dir.path().join("config.toml"),@@ -131,7 +131,7 @@ async fn caller_owned_models_build_without_openhuman_session() {#[tokio::test]async fn local_aliases_build_without_a_session_and_preserve_model_ids() {let _guard = crate::inference::inference_test_guard_async().await;- let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);+ let _signed_out = crate::platform::llm_gate::SignedOutTestGuard::set(true);let config = Config::default();for (prefix, canonical) in [("OLLAMA", "ollama"),diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rsindex d7b2caeefa..e87e4bcb2f 100644--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs@@ -198,7 +198,7 @@ impl OpenHumanBackendModel {);return Ok(key);}- if crate::cron::scheduler_gate::is_signed_out() {+ if crate::platform::llm_gate::is_signed_out() {anyhow::bail!("SESSION_EXPIRED: backend session not active — sign in to resume LLM work");@@ -541,7 +541,7 @@ fn managed_bearer(/// re-auths exactly as it would on a real backend 401. Deduped via the/// scheduler gate so N parallel managed turns in one tick don't emit N events.fn maybe_publish_local_session_expiry() {- if crate::cron::scheduler_gate::is_signed_out() {+ if crate::platform::llm_gate::is_signed_out() {return;}log::warn!(diff --git a/crates/openhuman-core/src/integrations/task_sources/README.md b/crates/openhuman-core/src/integrations/task_sources/README.mdindex 3244e958a3..020eb9ebbe 100644--- a/crates/openhuman-core/src/integrations/task_sources/README.md+++ b/crates/openhuman-core/src/integrations/task_sources/README.md@@ -143,7 +143,7 @@ SQL cascade). With no backend configured (the desktop default)- `crate::config` (+ `config::rpc`), `Config`, `load_config_with_timeout`; reads the `[task_sources]` block for defaults and the master switch.- `crate::integrations::composio::contract`: `NormalizedTask`, `TaskContainer`, `TaskFetchFilter`, `TaskKind` (contract types re-exported from `tinymemory_api::composio::tasks`). The old `get_provider` / `ProviderContext` / `ComposioProvider::fetch_tasks` registry no longer exists; `mod.rs`'s intra-doc link to `fetch_tasks` is stale.- `crate::agent::triage`: `run_triage`, `apply_decision`, `TriageOutcome`, `TriggerEnvelope`; dispatches the proactive agent turn for `AgentTodoProactive` sources.-- `crate::cron::scheduler_gate`: `wait_for_capacity` capacity semaphore; gates proactive triage turns behind background-AI throttling.+- `crate::platform::llm_gate`: `wait_for_capacity` capacity semaphore; gates proactive triage turns behind background-AI throttling.## Used bydiff --git a/crates/openhuman-core/src/integrations/task_sources/route.rs b/crates/openhuman-core/src/integrations/task_sources/route.rsindex 7a48e960b9..68f9f880ee 100644--- a/crates/openhuman-core/src/integrations/task_sources/route.rs+++ b/crates/openhuman-core/src/integrations/task_sources/route.rs@@ -6,7 +6,7 @@//! `run_triage` → `apply_decision` path Composio webhooks use — so an agent//! can start working immediately; triage's classifier (drop / acknowledge ///! react / escalate) gates noise, and the proactive turn is held behind the-//! `scheduler_gate` capacity semaphore so background AI throttling is+//! `llm_gate` capacity semaphore so background AI throttling is//! respected. [`SourceTarget::TodoOnly`] sources are collected into the ledger//! and go no further.//!@@ -21,7 +21,7 @@ use crate::agent::triage::{};use crate::agent::turn_origin::with_origin;use crate::config::Config;-use crate::cron::scheduler_gate;+use crate::platform::llm_gate;use super::types::{EnrichedTask, SourceTarget, TaskSource};diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rsindex 9b858e33b4..0aacb2a924 100644--- a/crates/openhuman-core/src/memory/import.rs+++ b/crates/openhuman-core/src/memory/import.rs@@ -183,8 +183,8 @@ pub fn status(config: &Config) -> ImportState {/// The scheduler's pause, which includes being signed out.pub(crate) fn scheduler_paused() -> bool {matches!(- crate::cron::scheduler_gate::current_policy(),- crate::cron::scheduler_gate::Policy::Paused { .. }+ crate::platform::llm_gate::current_policy(),+ crate::platform::llm_gate::Policy::Paused { .. })}diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs.rs b/crates/openhuman-core/src/memory/lifecycle/jobs.rsindex d1bd950299..d454a29df9 100644--- a/crates/openhuman-core/src/memory/lifecycle/jobs.rs+++ b/crates/openhuman-core/src/memory/lifecycle/jobs.rs@@ -121,8 +121,8 @@ pub async fn run(config: &Config, selection: Selection) -> MemoryResult<Vec<JobR/// The cron entry point: runs due jobs unless background work is paused.pub async fn run_due(config: &Config) {- if let crate::cron::scheduler_gate::Policy::Paused { reason } =- crate::cron::scheduler_gate::current_policy()+ if let crate::platform::llm_gate::Policy::Paused { reason } =+ crate::platform::llm_gate::current_policy(){tracing::debug!(?reason,diff --git a/crates/openhuman-core/src/platform/llm_gate/README.md b/crates/openhuman-core/src/platform/llm_gate/README.mdindex 71c02f6798..e4f6de6da8 100644--- a/crates/openhuman-core/src/platform/llm_gate/README.md+++ b/crates/openhuman-core/src/platform/llm_gate/README.md@@ -1,4 +1,4 @@-# scheduler_gate+# llm_gateGates background AI work (embeddings, summarisation, triage, local inference) on live host conditions so the process doesn't make the machine visibly lag: especially on battery. It exposes a single process-wide decision point: background workers consult `current_policy()` for a cheap read, or `await wait_for_capacity()` to cooperatively block until the host is ready and hold a slot in a one-permit LLM semaphore. A background sampler refreshes host signals every 30s and recomputes the policy. A separate "signed out" override trumps everything to halt LLM work the moment the app session goes away.@@ -15,11 +15,11 @@ Gates background AI work (embeddings, summarisation, triage, local inference) on| File | Role || --- | --- |-| [`crates/openhuman-core/src/cron/scheduler_gate/mod.rs`](./mod.rs) | Module docstring + re-exports of the public surface. |-| [`crates/openhuman-core/src/cron/scheduler_gate/gate.rs`](./gate.rs) | The process-wide wiring: the `SharedCore`, the signed-out override, the resume `Notify`, the single-slot LLM semaphore, `init_global(SchedulerGateConfig)`/`update_config`/`current_policy`/`wait_for_capacity`, and the per-tokio-runtime test-state scaffolding. |-| [`crates/openhuman-core/src/cron/scheduler_gate/throttle.rs`](./throttle.rs) | The machinery: `GateCore` (config + signals + policy), the 30s `spawn_sampler` task, `wait_for_capacity` over a caller-owned semaphore, and the `LlmPermit` RAII guard. |-| [`crates/openhuman-core/src/cron/scheduler_gate/signals.rs`](./signals.rs) | `sample(&SignalEnv)`: battery (via `starship_battery`, behind the `scheduler-gate` feature), CPU usage (via `sysinfo`, two-refresh delta), and server/container detection. |-| [`crates/openhuman-core/src/cron/scheduler_gate/decide.rs`](./decide.rs) | Config/policy adapter: `decide(signals, cfg) -> Policy` maps `SchedulerGateConfig` to `platform::resource_admission::Limits` and maps `Admission` to `Policy`. The pure decision lives in [`platform/resource_admission`](../../platform/resource_admission/mod.rs). `Policy` / `PauseReason` live beside `SchedulerGateConfig` in `config::schema::scheduler_gate`. Evaluation order: user mode override → server mode → power-aware stand-down → hard CPU ceiling → battery/CPU headroom. |+| [`crates/openhuman-core/src/platform/llm_gate/mod.rs`](./mod.rs) | Module docstring + re-exports of the public surface. |+| [`crates/openhuman-core/src/platform/llm_gate/gate.rs`](./gate.rs) | The process-wide wiring: the `SharedCore`, the signed-out override, the resume `Notify`, the single-slot LLM semaphore, `init_global(SchedulerGateConfig)`/`update_config`/`current_policy`/`wait_for_capacity`, and the per-tokio-runtime test-state scaffolding. |+| [`crates/openhuman-core/src/platform/llm_gate/throttle.rs`](./throttle.rs) | The machinery: `GateCore` (config + signals + policy), the 30s `spawn_sampler` task, `wait_for_capacity` over a caller-owned semaphore, and the `LlmPermit` RAII guard. |+| [`crates/openhuman-core/src/platform/llm_gate/signals.rs`](./signals.rs) | `sample(&SignalEnv)`: battery (via `starship_battery`, behind the `scheduler-gate` feature), CPU usage (via `sysinfo`, two-refresh delta), and server/container detection. |+| [`crates/openhuman-core/src/platform/llm_gate/decide.rs`](./decide.rs) | Config/policy adapter: `decide(signals, cfg) -> Policy` maps `SchedulerGateConfig` to `platform::resource_admission::Limits` and maps `Admission` to `Policy`. The pure decision lives in [`platform/resource_admission`](../resource_admission/mod.rs). `Policy` / `PauseReason` live beside `SchedulerGateConfig` in `config::schema::scheduler_gate`. Evaluation order: user mode override → server mode → power-aware stand-down → hard CPU ceiling → battery/CPU headroom. || `SIGNAL_ENV` in `gate.rs` | The env-override names: `OPENHUMAN_ON_AC_POWER`, `OPENHUMAN_BATTERY_CHARGE`, `OPENHUMAN_DEPLOYMENT` (plus the Kubernetes / `/.dockerenv` heuristics). |## Public surface@@ -56,7 +56,7 @@ No dependency on any other `openhuman` domain or on `crate::core::*`.## Used by-Consumed in-process across the codebase (discoverable via `grep scheduler_gate`):+Consumed in-process across the codebase (discoverable via `grep llm_gate`):- Background workers / pipelines: `autocomplete/core/engine.rs`, `task_sources/route.rs`, [`agent/triage/evaluator.rs`](../../agent/triage/evaluator.rs).- Inference layer: `inference/provider/openhuman_backend.rs`, [`inference/provider/factory.rs`](../../inference/provider/factory.rs), `inference/local/service/{vision_embed.rs,public_infer.rs}`, `inference/voice/postprocess.rs`.diff --git a/crates/openhuman-core/src/search/tools.rs b/crates/openhuman-core/src/search/tools.rsindex 8f52b8ebec..29f74cd123 100644--- a/crates/openhuman-core/src/search/tools.rs+++ b/crates/openhuman-core/src/search/tools.rs@@ -197,7 +197,7 @@ pub(crate) fn backend_unauthorized_message(api_key: bool) -> String {/// token. A rejected API key has no session to expire, so it never signs the/// user out (`API_KEY_REJECTED` semantics).fn on_backend_unauthorized(tool: &str, api_key: bool) {- if api_key || crate::cron::scheduler_gate::is_signed_out() {+ if api_key || crate::platform::llm_gate::is_signed_out() {return;}crate::core::bus::BUS.publish(crate::core::events::DomainEvent::SessionExpired {diff --git a/crates/openhuman-core/src/security/credentials/README.md b/crates/openhuman-core/src/security/credentials/README.mdindex 34517ec988..71be6e0bef 100644--- a/crates/openhuman-core/src/security/credentials/README.md+++ b/crates/openhuman-core/src/security/credentials/README.md@@ -106,7 +106,7 @@ across processes; the local file lock still serializes one host.- `crate::config`: `Config`, config load (`load_config_with_timeout`), user-dir activation (`default_root_openhuman_dir`, `user_openhuman_dir`, `read/write/clear_active_user`, `pre_login_user_dir`), onboarding state.- `crate::security::secret_storage`: `SecretStore` (encrypt/decrypt) and OS keychain `get`/`set`/`delete`/`is_available`.-- `crate::cron::scheduler_gate`: signed-out override flipped on install/removal/expiry.+- `crate::platform::llm_gate`: signed-out override flipped on install/removal/expiry.- `crate::memory::conversations`: purge pre-login threads, bind conversation persistence after activation.- `crate::memory`: bind memory client to the active workspace after activation.- `crate::inference::host_runtime`, `crate::voice::{server,dictation_listener,always_on}`: credential-gated services started/stopped.diff --git a/crates/openhuman-core/src/security/credentials/bus.rs b/crates/openhuman-core/src/security/credentials/bus.rsindex 6e7d43c646..8c5d96c8ba 100644--- a/crates/openhuman-core/src/security/credentials/bus.rs+++ b/crates/openhuman-core/src/security/credentials/bus.rs@@ -25,7 +25,7 @@use crate::core::events::DomainEvent;use crate::core::runtime::DispatchCtx;-use crate::cron::scheduler_gate;+use crate::platform::llm_gate;use async_trait::async_trait;use tinybus::EventHandler;diff --git a/crates/openhuman-core/src/security/credentials/ops/credential.rs b/crates/openhuman-core/src/security/credentials/ops/credential.rsindex 73b3d651cd..0056cad19a 100644--- a/crates/openhuman-core/src/security/credentials/ops/credential.rs+++ b/crates/openhuman-core/src/security/credentials/ops/credential.rs@@ -213,7 +213,7 @@ pub async fn set_credential(} else {spawn_integrations_cache_warm(config);}- crate::cron::scheduler_gate::set_signed_out(false);+ crate::platform::llm_gate::set_signed_out(false);#[cfg(feature = "channels")]crate::channels::session::resume_channel_service();tracing::info!(@@ -344,7 +344,7 @@ pub async fn set_credential(// Open the scheduler gate now that a live credential is in place; workers// sleeping in the paused poll loop resume at their next iteration.- crate::cron::scheduler_gate::set_signed_out(false);+ crate::platform::llm_gate::set_signed_out(false);#[cfg(feature = "channels")]crate::channels::session::resume_channel_service();// An API key wins over a session for every backend request. Keep the@@ -460,7 +460,7 @@ pub async fn clear_credential(logs.push("api key cleared".to_string());}if !crate::security::credentials::session_support::has_backend_credential(config) {- crate::cron::scheduler_gate::set_signed_out(true);+ crate::platform::llm_gate::set_signed_out(true);} else if removed_api_key {// Clearing the preferred API key exposes the surviving session.// Restore the session's process identity immediately.@@ -484,7 +484,7 @@ pub async fn clear_credential(// restore the surviving key's runtime after that teardown has completed.if removed_session && api_key::has_api_key(config) {start_credential_gated_services(ctx, config).await;- crate::cron::scheduler_gate::set_signed_out(false);+ crate::platform::llm_gate::set_signed_out(false);sentry_scope::clear();identity::clear_current_user();logs.push("credential-gated services restarted for api key".to_string());@@ -513,7 +513,7 @@ async fn clear_session_credential(config: &Config,) -> Result<Outcome<bool>, String> {let mut logs = Vec::new();- crate::cron::scheduler_gate::set_signed_out(true);+ crate::platform::llm_gate::set_signed_out(true);#[cfg(feature = "web3")]if let Err(error) = crate::modules::web3_service::close_service(config).await {tracing::warn!(%error, "{LOG_PREFIX} failed to close Web3 service during sign-out");diff --git a/crates/openhuman-core/src/security/credentials/session_support.rs b/crates/openhuman-core/src/security/credentials/session_support.rsindex 0ef5e1f199..c7c3315b57 100644--- a/crates/openhuman-core/src/security/credentials/session_support.rs+++ b/crates/openhuman-core/src/security/credentials/session_support.rs@@ -519,7 +519,7 @@ pub fn has_backend_credential(config: &Config) -> bool {pub fn publish_local_session_expiry(operation: &'static str) {// Dedupe the publish via the scheduler gate so N parallel authed// callers in one tick don't emit N SessionExpired events.- if crate::cron::scheduler_gate::is_signed_out() {+ if crate::platform::llm_gate::is_signed_out() {return;}// An API-key runtime has no session to expire. Its backend calls neverdiff --git a/docs/gitbooks/en/developing/architecture.md b/docs/gitbooks/en/developing/architecture.mdindex 8544ee3637..4e97238e1f 100644--- a/docs/gitbooks/en/developing/architecture.md+++ b/docs/gitbooks/en/developing/architecture.md@@ -210,7 +210,7 @@ Skill discovery uses `SKILL.md` plus optional bundled resources:Script-backed skills run through the shell tool and use the host `node` and `python3` executables on `PATH`. Execution is gated by the `security/` sandbox policy like any other tool.-Recurring work belongs to the `cron` domain (with `scheduler_gate`), not to skills. There is no per-skill cron handler.+Recurring work belongs to the `cron` domain (with `platform::llm_gate`), not to skills. There is no per-skill cron handler.---@@ -324,7 +324,7 @@ Core subsystems run on `tiny*` crates, vendored as git submodules under `vendor/| WebSocket | tokio-tungstenite + rustls | Persistent connections with native TLS || HTTP | reqwest | Async HTTP with rustls + native-TLS support || Encryption | chacha20poly1305 (secret store), aes-gcm + argon2 (`security/encryption/`) | Config-field secrets use ChaCha20-Poly1305 under a keychain-backed master key (`enc2:` prefix); the separate user-facing encryption facility uses AES-256-GCM with Argon2id |-| Scheduling | cron crate + `cron` domain | Standard cron expressions, `scheduler_gate`-gated |+| Scheduling | cron crate + `cron` domain | Standard cron expressions, `llm_gate`-gated || Telegram | `tinychannels` Bot API driver | Transport in vendored `tinychannels`; host keeps bus/approval glue || Realtime | Socket.io (client) | Bidirectional event-based communication || AI | MCP (JSON-RPC 2.0) | Standardized tool protocol for LLM integration |diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.mdindex 0c478fddb4..9d8cf08a3d 100644--- a/docs/module-boundary-inventory.md+++ b/docs/module-boundary-inventory.md@@ -526,7 +526,7 @@ The cron scheduler runtime is `tinyflows_schedule::runtime::Scheduler` (v0.8.15)Deleted from `crates/openhuman-core/src/cron/`: `scheduler/{dispatch,slot,retry}.rs`, the persistence half of `scheduler/run_record.rs`, `policy.rs` and its tests, the core `parse_human_delay`, `validate_delivery`, `check_origin_requirements` and `default_delivery`, and the `DomainEvent::FlowScheduleTick` round trip (`EVENTS_VERSION` 1.11.0). The tests of the moved behaviour (claims, concurrency, single-flight, retry budget, one-shot completion) live in `tinyflows-schedule`.-The host keeps the ports in `scheduler/{host,executor,run_delivery}.rs`: `JobStore` over `CronDocuments` (with operator limits), `JobExecutor` (shell and agent attempts, failure classification, the retries-exhausted report), `RunDelivery` (delivery, completion and health events) and `TriggerSink` (the flow's schedule trigger through `FlowTriggerSubscriber::dispatch_schedule_tick`, and `system:<name>` jobs). `scheduler_gate`, system jobs, seeding and the `cron.*` RPC stay. TinyFlows is a plain library gitlink, so there is no registry record or `module-boundaries.json` entry.+The host keeps the ports in `scheduler/{host,executor,run_delivery}.rs`: `JobStore` over `CronDocuments` (with operator limits), `JobExecutor` (shell and agent attempts, failure classification, the retries-exhausted report), `RunDelivery` (delivery, completion and health events) and `TriggerSink` (the flow's schedule trigger through `FlowTriggerSubscriber::dispatch_schedule_tick`, and `system:<name>` jobs). `platform::llm_gate` (moved out), system jobs, seeding and the `cron.*` RPC stay. TinyFlows is a plain library gitlink, so there is no registry record or `module-boundaries.json` entry.Behaviour notes: a job's policy is read from the job document (an unreadable job refuses Run Now with a credential-free message, `ops::load_job_for_run`); `CronJobCompleted` and the scheduler health signal are published from delivery, before the runtime writes the completion; `CronJobTriggered` is no longer published for `flow` rows.diff --git a/scripts/ci/saas-ambient-baseline.json b/scripts/ci/saas-ambient-baseline.jsonindex 7ef15378e5..d1de8717e3 100644--- a/scripts/ci/saas-ambient-baseline.json+++ b/scripts/ci/saas-ambient-baseline.json@@ -421,14 +421,14 @@},{"rule": "bare-spawn",- "path": "crates/openhuman-core/src/cron/scheduler_gate/throttle.rs",+ "path": "crates/openhuman-core/src/platform/llm_gate/throttle.rs","line": 140,"text": "tokio::spawn(async move {","occurrence": 1},{"rule": "bare-spawn",- "path": "crates/openhuman-core/src/cron/scheduler_gate/throttle.rs",+ "path": "crates/openhuman-core/src/platform/llm_gate/throttle.rs","line": 145,"text": "let signals = match tokio::task::spawn_blocking(move || signals::sample(&env)).await {","occurrence": 1diff --git a/tests/embedded_server_shutdown_e2e.rs b/tests/embedded_server_shutdown_e2e.rsindex a89632c4d9..0da6e26f85 100644--- a/tests/embedded_server_shutdown_e2e.rs+++ b/tests/embedded_server_shutdown_e2e.rs@@ -53,7 +53,7 @@ fn shutdown_token_stops_axum_listener_within_timeout() {}async fn shutdown_token_stops_listener() {- openhuman_core::cron::scheduler_gate::set_signed_out(false);+ openhuman_core::platform::llm_gate::set_signed_out(false);let workspace = tempfile::tempdir().expect("workspace tempdir");// Pin the scheduler-gate policy so the bootstrap's `init_global` snapshot