Skip to content

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

feat(cron): skip flow schedule ticks when flows component is disabled

Steven Enamakel843111c56dc4
diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.md
index 5f4bbb4be1..becc4c7a09 100644
--- a/crates/openhuman-core/src/cron/README.md
+++ b/crates/openhuman-core/src/cron/README.md
@@ -441,3 +441,10 @@ earlier are refused too.
- [Parent module README](../../README.md)
- [Cron and scheduling](../../../../gitbooks/features/native-tools/cron.md)
- [Workflows](../../../../gitbooks/features/workflows.md)
+
+## Relation to `[components].flows`
+
+`flow` schedule rows are fired through `HostTriggers`. When `[components]
+flows = false`, such a tick is answered as skipped (`COMPONENT_DISABLED:flows`,
+no retry, the recurrence advances) while agent, shell and system jobs keep
+running; `cron.enabled = false` still stops the whole scheduler.
diff --git a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
index d6bb3efed7..e3f4283f9d 100644
--- a/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
+++ b/crates/openhuman-core/src/cron/scheduler/run_delivery.rs
@@ -102,6 +102,22 @@ impl TriggerSink for HostTriggers {
.map_or_else(|| flow_id.to_string(), |job| job.id);
return Ok(run_system_job(&job_id, name, run_id).await);
}
+ // `[components] flows = false`: schedule-triggered flows stop
+ // while agent, shell and system jobs keep running. The tick is
+ // answered, not retried, so the row's recurrence moves on.
+ if !flows_component_enabled() {
+ tracing::debug!(
+ target: "flows",
+ %flow_id,
+ %run_id,
+ "[cron] flow schedule trigger skipped: component 'flows' disabled"
+ );
+ return Ok(Attempt {
+ success: true,
+ output: format!("flow schedule tick skipped for flow {flow_id}: COMPONENT_DISABLED:flows"),
+ retryable: false,
+ });
+ }
tracing::info!(
target: "flows",
%flow_id,
@@ -129,6 +145,12 @@ impl TriggerSink for HostTriggers {
}
}
+/// Whether `[components] flows` is on in the ambient context. No context
+/// means nothing narrowed it.
+fn flows_component_enabled() -> bool {
+ crate::core::runtime::CoreContext::current().is_none_or(|ctx| ctx.components().flows)
+}
+
/// A host-owned system job (`system:<name>`): announced on the bus, then its
/// registered handler is awaited and its result is the run's result. Without a
/// handler the job is announce-only and `ok` on dispatch.
diff --git a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
index 7c82ef3e07..b4cfcc8677 100644
--- a/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_dispatch_tests.rs
@@ -418,3 +418,42 @@ async fn a_flow_schedule_job_fires_through_the_trigger_sink() {
.contains("flow schedule tick emitted for flow flow-missing-for-sink"));
assert!(stored.next_run > Utc::now(), "the recurrence moved on");
}
+
+/// `[components] flows = false` stops schedule-triggered flow rows (the tick is
+/// answered as skipped and the recurrence moves on) while the row stays valid.
+#[tokio::test]
+async fn a_flow_schedule_job_is_skipped_when_the_flows_component_is_off() {
+ use crate::core::runtime::{ComponentSet, CoreContext};
+
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp).await;
+ let job = cron::add_flow_schedule_job(
+ &config,
+ "flow-off-for-sink",
+ Schedule::Every {
+ every_ms: 3_600_000,
+ },
+ )
+ .unwrap();
+ force_due(&config, &job.id);
+ let job = cron::get_job(&config, &job.id).unwrap();
+ let job_id = job.id.clone();
+
+ let mut off = ComponentSet::all();
+ off.flows = false;
+ let ctx = CoreContext::for_test_with_components(off);
+ let security = security(&config);
+ let cfg = config.clone();
+ CoreContext::scope(ctx, async move {
+ let mut dispatcher = JobDispatcher::new(&cfg, &security);
+ dispatcher.dispatch(vec![job]).await.unwrap();
+ dispatcher.drain().await;
+ })
+ .await;
+
+ let stored = cron::get_job(&config, &job_id).unwrap();
+ let output = stored.last_output.unwrap_or_default();
+ assert!(output.contains("COMPONENT_DISABLED:flows"), "got: {output}");
+ assert!(!output.contains("tick emitted"));
+ assert!(stored.next_run > Utc::now(), "the recurrence moved on");
+}
diff --git a/crates/openhuman-core/src/cron/schemas.rs b/crates/openhuman-core/src/cron/schemas.rs
index 1620961750..1943f7b6e8 100644
--- a/crates/openhuman-core/src/cron/schemas.rs
+++ b/crates/openhuman-core/src/cron/schemas.rs
@@ -373,7 +373,9 @@ fn handle_add(params: Map<String, Value>) -> ControllerFuture {
.is_none()
.then(tinyflows_schedule::types::DeliveryConfig::default)
.or_else(|| {
- Some(tinyflows_schedule::validation::default_delivery(origin.as_ref()))
+ Some(tinyflows_schedule::validation::default_delivery(
+ origin.as_ref(),
+ ))
})
});
let delivery_cfg = delivery.clone().unwrap_or_default();
diff --git a/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs b/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs
index 23a95660fa..a0053d3797 100644
--- a/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_connection_ref_gate_tests.rs
@@ -357,7 +357,10 @@ async fn mock_opaque_tool_call_upstream_ref_matches_native_and_composio_upstream
],
"edges": []
}));
- let up = |expr: &str| tinyflows::preflight::mock_opaque_tool_call_upstream_ref(expr, &g, "sink").map(str::to_string);
+ let up = |expr: &str| {
+ tinyflows::preflight::mock_opaque_tool_call_upstream_ref(expr, &g, "sink")
+ .map(str::to_string)
+ };
assert_eq!(
up("=nodes.native_up.item.json.url").as_deref(),
Some("native_up")
diff --git a/crates/openhuman-embed/src/cron.rs b/crates/openhuman-embed/src/cron.rs
index 8e3a329c33..5af85f0423 100644
--- a/crates/openhuman-embed/src/cron.rs
+++ b/crates/openhuman-embed/src/cron.rs
@@ -59,8 +59,8 @@ use std::future::Future;
use std::time::SystemTime;
use openhuman_core::config::Config;
-use openhuman_core::cron::JobPolicy;
use openhuman_core::cron::system_jobs::SYSTEM_COMMAND_PREFIX;
+use openhuman_core::cron::JobPolicy;
use {
openhuman_core::cron::CronJob, openhuman_core::cron::CronJobPatch,
openhuman_core::cron::JobType, openhuman_core::cron::Schedule,
diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.md
index 9eafd9e42a..fbdde825a6 100644
--- a/docs/module-boundary-inventory.md
+++ b/docs/module-boundary-inventory.md
@@ -499,3 +499,19 @@ Deleted from `crates/openhuman-core/src/cron/`: `scheduler/{dispatch,slot,retry}
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.
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.
+
+### `[components].flows` toggle (#7564)
+
+`[components] flows = false` (or `OPENHUMAN_COMPONENT_FLOWS=0`) is host-only:
+the flows code stays compiled in. On the next core start it narrows
+`DomainSet::flows` (no flow trigger or run-digest subscribers, no boot
+reconcile), turns the `workflows` tool group off, and answers every `flows.*`
+RPC with `COMPONENT_DISABLED:flows`. `about_app` reports the `flows` and
+`workflow_runs` capability domains as disabled. TinyFlows is a plain library
+gitlink with no registry record, so `modules.list` has no row for it.
+
+Relation to `cron.enabled`: independent switches. With `flows = false` the
+cron scheduler keeps running agent, shell and system jobs, but `flow` schedule
+rows are answered as skipped (`COMPONENT_DISABLED:flows`, not retried) and no
+flow run starts. `cron.enabled = false` stops the whole scheduler, flow
+schedule rows included, regardless of `flows`.