Skip to content

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

docs(cron): update README to reflect flow jobs, scheduler split, and new modules

Steven Enamakel1a004e0f357b
diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.md
index 85b97eeebd..634ef189e6 100644
--- a/crates/openhuman-core/src/cron/README.md
+++ b/crates/openhuman-core/src/cron/README.md
@@ -1,32 +1,51 @@
# Cron
-Scheduled-job runtime. Owns cron-expression and human-delay parsing, the persistent job + run store, the polling scheduler that fires due jobs (`shell` and `agent` types), and the delivery layer that publishes events into the agent / channel pipelines. Does NOT own the actual agent execution (`agent::triage`) or shell sandboxing (`security::SecurityPolicy`).
+Scheduled-job runtime. Owns cron-expression and human-delay parsing, the persistent job + run store, the polling scheduler that fires due jobs (`shell`, `agent`, and `flow` types), and the delivery layer that publishes events into the agent / channel pipelines. Does NOT own shell sandboxing (`security::SecurityPolicy`) or flow trigger dispatch (`flows::bus::FlowTriggerSubscriber`).
## Public surface
-- `pub struct CronJob` / `pub struct CronJobPatch` / `pub struct CronRun` / `pub enum JobType` / `pub enum Schedule` / `pub enum SessionTarget` / `pub struct DeliveryConfig` — `types.rs:1-100` — durable job + run model.
-- `pub fn add_once` / `pub fn add_once_at` / `pub fn parse_human_delay` / `pub fn pause_job` / `pub fn resume_job` / `pub fn update_cron_job` — `ops.rs` (re-exported `mod.rs:12`).
-- `pub fn schedule_cron_expression` / `pub fn next_run_for_schedule` / `pub fn normalize_expression` / `pub fn validate_schedule` / `pub fn validate_agent_schedule` / `pub fn runs_closer_than` / `pub const MIN_AGENT_JOB_INTERVAL` — `schedule.rs` (re-exported `mod.rs`).
-- `pub fn add_job` / `pub fn add_agent_job` / `pub fn add_agent_job_with_definition` / `pub fn add_shell_job` / `pub fn due_jobs` / `pub fn get_job` / `pub fn list_jobs` / `pub fn list_runs` / `pub fn record_last_run` / `pub fn record_run` / `pub fn remove_job` / `pub fn reschedule_after_run` / `pub fn update_job` — `store.rs` (re-exported `mod.rs:22-26`).
-- `pub mod scheduler` (`pub async fn run(config: Config)`) — `scheduler.rs:19` — main poll loop.
+- `pub struct CronJob` / `pub struct CronJobPatch` / `pub struct CronRun` / `pub enum JobType` / `pub enum Schedule` / `pub enum SessionTarget` / `pub struct DeliveryConfig` — `types.rs` — durable job + run model.
+- `pub fn add_once` / `pub fn add_once_at` / `pub fn parse_human_delay` / `pub fn pause_job` / `pub fn resume_job` / `pub fn update_cron_job` — `ops.rs` (also re-exported as `pub use ops as rpc`).
+- `pub fn schedule_cron_expression` / `pub fn next_run_for_schedule` / `pub fn normalize_expression` / `pub fn validate_schedule` / `pub fn validate_agent_schedule` / `pub fn runs_closer_than` / `pub const MIN_AGENT_JOB_INTERVAL` — `schedule.rs`.
+- `pub fn add_job` / `pub fn add_agent_job` / `pub fn add_agent_job_with_definition` / `pub fn add_shell_job` / `pub fn add_flow_schedule_job` / `pub fn find_flow_schedule_job` / `pub fn due_jobs` / `pub fn get_job` / `pub fn list_jobs` / `pub fn list_runs` / `pub fn record_last_run` / `pub fn record_run` / `pub fn remove_job` / `pub fn reschedule_after_run` / `pub fn update_job` — `store.rs` (split into `store_part_01.rs` / `store_part_02.rs` via `include!`).
+- `pub mod scheduler` (`pub async fn run(config: Config)`) — `scheduler.rs`, split into `scheduler_part_01.rs` (poll loop, `run`), `scheduler_part_02.rs` (per-job-type execution, `run_agent_job`), `scheduler_part_03.rs` (`deliver_if_configured`) via `include!`.
+- `pub mod scheduler_gate` — host-condition gating (battery / AC / thermal) for whether a due job may run now; see its own [README](scheduler_gate/README.md).
- `pub mod seed` — `seed.rs` — install built-in jobs on first launch.
- `pub mod bus` — `bus.rs` — `CronDeliverySubscriber` for the event bus.
-- RPC `cron.{add, list, update, remove, run, runs}` — `schemas.rs` (re-exported via `all_cron_controller_schemas` / `all_cron_registered_controllers`).
+- `pub mod tools` — `tools.rs` + `tools/` — agent-facing tools: `CronAddTool`, `CronListTool`, `CronUpdateTool`, `CronRemoveTool`, `CronRunTool`, `CronRunsTool`, and the collapsed `CronTool` / `CRON_TOOL_NAME` (see `tools/collapsed.rs` for why all six stay registered as hidden schemas behind the one advertised tool).
+- RPC namespace `cron`: `add`, `list`, `update`, `remove`, `run`, `runs` — `schemas.rs` (re-exported via `all_cron_controller_schemas` / `all_cron_registered_controllers`).
+
+## Job types
+
+- **`shell`** — runs a command under `SecurityPolicy::from_config`.
+- **`agent`** — the scheduler builds an `Agent` directly and runs a turn (see below); it does not go through `agent::triage`.
+- **`flow`** — a `flows::Flow` schedule-trigger binding created by `flows::ops::flows_set_enabled` via `add_flow_schedule_job`. Its `command` column carries the bound flow's id; on fire the scheduler publishes `DomainEvent::FlowScheduleTick { flow_id }` instead of running anything itself. `flows::bus::FlowTriggerSubscriber` does the actual dispatch. Never created via the `cron_add` agent tool.
+
+### Agent jobs
+
+`scheduler_part_02.rs::run_agent_job` builds the `Agent` for a job: `Agent::from_config` by default, `Agent::from_config_for_agent` when `job.agent_id` names a registered definition, or `Agent::from_config_for_agent_with_profile` when a profile applies — the same profile-aware path `agent::profiles` and the interactive dispatcher use, so a cron run inherits the same tool/permission shape as an interactive session with that agent. A per-job `model` override is applied to a cloned `Config` before building. The built agent then runs the prefixed prompt (`[cron:<id> <name>] <prompt>`) as a normal turn; failures are classified (session-expired, insufficient-credits, security-policy) to decide whether the run is retried.
+
+## Event bus
+
+Cron publishes through `core/bus.rs` using variants declared in `core/events.rs`: `DomainEvent::CronJobTriggered`, `CronJobCompleted`, `CronDeliveryRequested`, `ProactiveMessageRequested` (shared with the proactive-message pipeline), and `FlowScheduleTick`.
## Calls into
-- `crates/openhuman-core/src/agent/` — `agent` job type runs through `agent::triage::TriggerEnvelope::from_cron` + `apply_decision`.
+- `crates/openhuman-core/src/agent/` — `Agent::from_config[_for_agent[_with_profile]]` for agent jobs; `agent::harness::definition::AgentDefinitionRegistry` to resolve `agent_id` overrides; `agent::profiles` for profile-aware construction.
- `crates/openhuman-core/src/security/` — `SecurityPolicy::from_config` sandboxes shell jobs.
-- `crates/openhuman-core/src/config/` — `Config` provides poll interval, workspace dir, autonomy policy.
+- `crates/openhuman-core/src/config/` — `Config` provides poll interval, workspace dir, autonomy policy, and per-job model overrides.
+- `crates/openhuman-core/src/inference/` — `provider::create_chat_model_with_model_id` resolves workload-hint model specs on agent-definition overrides.
- `crates/openhuman-core/src/platform/health/` — `health::bus::register_health_subscriber` on startup.
-- `crates/openhuman-core/src/channels/` — `bus.rs` can fan delivery events into channels.
-- `crates/openhuman-core/src/core/event_bus/` — `init_global`, `publish_global(DomainEvent::Cron(*))`.
+- `crates/openhuman-core/src/channels/` — `bus.rs` fans delivery events into channels; `channels::proactive` handles `ProactiveMessageRequested`.
+- `crates/openhuman-core/src/flows/` — `flows::bus::FlowTriggerSubscriber` consumes `FlowScheduleTick`.
+- `crates/openhuman-core/src/core/bus.rs` / `core/events.rs` — the process-wide event bus and `DomainEvent` variants cron publishes.
## Called by
-- `crates/openhuman-core/src/tools/impl/system/schedule.rs` — `schedule` tool exposes cron operations to agents.
+- `crates/openhuman-core/src/tools/impl/system/schedule.rs` — `schedule` tool exposes one-shot cron scheduling to agents.
- `crates/openhuman-core/src/core/all.rs` — controller registry wires `all_cron_*`.
-- Channel and agent runtimes consume `Cron` events via the bus.
+- `crates/openhuman-core/src/flows/ops.rs` — `flows_set_enabled` creates/removes flow schedule jobs via `add_flow_schedule_job`.
+- Channel and agent runtimes consume `Cron*` and `ProactiveMessageRequested` events via the bus.
## Delivery modes
@@ -70,6 +89,6 @@ that evidence on each run instead (#6158).
## Tests
-- Unit: `ops_tests.rs`, `scheduler_tests.rs`, `store_tests.rs`.
-- Schema/parsing coverage lives inside `schedule.rs` and `schemas.rs` `#[cfg(test)] mod tests` blocks.
-- Delivery validation: `cron::tools::add::tests` (announce-mode `allowed_users` checks).
+- Unit: `ops_tests.rs`, `scheduler_tests_part_01_tests.rs` .. `_04_tests.rs`, `store_tests.rs` + `store_tests_part_01_tests.rs`, `schedule_tests.rs`, `types_tests.rs`, `seed_tests.rs`, `bus_tests.rs`.
+- Schema/parsing coverage lives inside `schemas_tests.rs`.
+- Tool coverage: `cron::tools::{add,list,remove,run,runs,update}::tests` and `collapsed_tests.rs` (announce-mode `allowed_users` checks, action dispatch, permission resolution).