Skip to content

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

chore(cron): adopt tinyflows schedule contract v6

Steven Enamakeld07a33dfe859
diff --git a/crates/openhuman-core/src/cron/README.md b/crates/openhuman-core/src/cron/README.md
index 7f4eaa2678..d9b685c20f 100644
--- a/crates/openhuman-core/src/cron/README.md
+++ b/crates/openhuman-core/src/cron/README.md
@@ -13,7 +13,7 @@ scheduler runtime (poll pass, process-wide run claims, retry with backoff,
completion and rescheduling), the cron job and run store, and the schedule
maths (cron expressions, one-shot instants, intervals, active hours, the
agent-job cadence floor). Core reaches it only through the `tinyflows-bus`
-contract (`tinyflows_bus::schedule`, v3), and keeps what is policy and what is
+contract (`tinyflows_bus::schedule`, v6), and keeps what is policy and what is
pluggable: the callbacks the module runs jobs through, the document port it
persists through, the job-kind handler registry, delivery, the operator limits
and the RPC and tool surface. Core links neither `tinyflows-schedule` nor
@@ -67,14 +67,14 @@ jobs, the turn's message id.
### Run claims
-The module keeps process-wide run claims per `(scope, job id)`; the host uses
-the scope `openhuman` for every scheduler so the poll loop of any agent and
-Run Now refuse to start a job another of them is running. `cron.run` also
-takes a host-side guard (`scheduler::try_acquire_run`) so a second concurrent
-Run Now is rejected at once; a Run Now that loses to a scheduled run is
-refused by the module's `ExecuteJob` ("job is already running"), and the host
-records nothing for it. A claim releases on drop, so a scheduled run and a manual run
-never overlap.
+The module keeps process-wide occurrence claims per scheduler scope and job
+id. Each host scheduler and manual run uses the stable `DocScope` identity, so
+jobs in one document scope cannot overlap while distinct workspaces or agent
+scopes remain independent. Run Now reserves an inert module handle, starts
+the worker, and observes its state until the module confirms admission or a
+terminal result. The owner task keeps that invocation's callback and context
+alive through terminal acknowledgement, even if the RPC or tool caller goes
+away.
### Executing a job
diff --git a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs b/crates/openhuman-core/src/cron/scheduler/dispatcher.rs
index 4e81e3fe16..f7a0dce701 100644
--- a/crates/openhuman-core/src/cron/scheduler/dispatcher.rs
+++ b/crates/openhuman-core/src/cron/scheduler/dispatcher.rs
@@ -156,34 +156,41 @@ async fn own_manual_run(
}
}
} else {
- let proxy = module::proxy(&config).await.map_err(|error| anyhow!(error))?;
- match proxy
- .call::<Option<ManualRunState>>(
- members::WAIT_MANUAL_RUN,
- (WaitManualRun {
- handle: handle.clone(),
- },),
- )
- .await
- {
- Ok(Some(state)) => state,
- // The released contract defines absence as no retained worker
- // in this module generation. It is quiescent, but does not
- // prove admission or success.
- Ok(None) => {
- if let Some(reply_tx) = reply_tx.take() {
- let _ = reply_tx.send(Err(
- "cron manual worker disappeared before a terminal result".to_string(),
- ));
- }
- return Ok(());
- }
+ match module::proxy(&config).await {
Err(error) => {
- tracing::debug!(error = %error.wire_message(), "[cron:scheduler] retrying WaitManualRun");
+ tracing::debug!(%error, "[cron:scheduler] retrying WaitManualRun");
tokio::time::sleep(retry_delay).await;
retry_delay = (retry_delay * 2).min(Duration::from_secs(1));
continue;
}
+ Ok(proxy) => match proxy
+ .call::<Option<ManualRunState>>(
+ members::WAIT_MANUAL_RUN,
+ (WaitManualRun {
+ handle: handle.clone(),
+ },),
+ )
+ .await
+ {
+ Ok(Some(state)) => state,
+ // The released contract defines absence as no retained worker
+ // in this module generation. It is quiescent, but does not
+ // prove admission or success.
+ Ok(None) => {
+ if let Some(reply_tx) = reply_tx.take() {
+ let _ = reply_tx.send(Err(
+ "cron manual worker disappeared before a terminal result".to_string(),
+ ));
+ }
+ return Ok(());
+ }
+ Err(error) => {
+ tracing::debug!(error = %error.wire_message(), "[cron:scheduler] retrying WaitManualRun");
+ tokio::time::sleep(retry_delay).await;
+ retry_delay = (retry_delay * 2).min(Duration::from_secs(1));
+ continue;
+ }
+ },
}
};
diff --git a/crates/openhuman-core/src/modules/registry_contract_tests.rs b/crates/openhuman-core/src/modules/registry_contract_tests.rs
index 45b50be814..90f47ade12 100644
--- a/crates/openhuman-core/src/modules/registry_contract_tests.rs
+++ b/crates/openhuman-core/src/modules/registry_contract_tests.rs
@@ -174,20 +174,20 @@ fn the_flows_record_serves_the_schedule_object() {
assert_ne!(record.object_path, schedule::OBJECT_PATH);
assert_ne!(schedule::INTERFACE, schedule::CALLBACK_INTERFACE);
assert_ne!(schedule::INTERFACE, schedule::DOCUMENT_INTERFACE);
- assert_eq!(schedule::CONTRACT_VERSION, 3, "the host speaks contract v3");
+ assert_eq!(schedule::CONTRACT_VERSION, 6, "the host speaks contract v6");
assert_eq!(component_for("tinyflows"), Some("tinyflows"));
}
-/// The pins are the published v0.8.23 `checksum.toml` (the first release with
-/// schedule contract v3).
+/// The pins are the published v0.8.25 `checksum.toml` (the first release with
+/// schedule contract v6).
#[test]
fn the_flows_record_pins_every_host_of_one_release() {
let record = find("tinyflows").unwrap();
- assert_eq!(record.version, "0.8.23");
+ assert_eq!(record.version, "0.8.25");
assert_eq!(record.assets.len(), 11);
for asset in record.assets {
assert!(
- asset.archive.starts_with("tinyflows-module-0.8.23-"),
+ asset.archive.starts_with("tinyflows-module-0.8.25-"),
"{}",
asset.archive
);
diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.md
index 0a54b1e592..96bb8bd084 100644
--- a/docs/module-boundary-inventory.md
+++ b/docs/module-boundary-inventory.md
@@ -548,6 +548,6 @@ schedule rows included, regardless of `flows`.
### TinyFlows schedule bus cutover (#7397)
-Supersedes the section above for who runs the scheduler. The `tinyflows` module (registry record `records_flows.rs`, contract `tinyflows_bus::schedule` v3) owns the scheduler runtime, claims, retry timing, completion, the cron job and run store (`CronDocuments`) and the schedule maths (`NextRun`, `ValidateSchedule`, `RunsCloserThan`, `NormalizeExpression`, `ParseHumanDelay`, `ValidateDelivery`, `DefaultDelivery`, `CheckOriginRequirements`, `CheckPatch`, `TruncateCronOutput`). Core links only `tinyflows-bus` (serde and chrono): `cargo tree -p openhuman -e normal -i tinyflows-schedule` is empty, and `tinyflows-drivers` is optional behind `flows` for the catalog alone.
+Supersedes the section above for who runs the scheduler. The `tinyflows` module (registry record `records_flows.rs`, contract `tinyflows_bus::schedule` v6) owns the scheduler runtime, claims, retry timing, completion, the cron job and run store (`CronDocuments`) and the schedule maths (`NextRun`, `ValidateSchedule`, `RunsCloserThan`, `NormalizeExpression`, `ParseHumanDelay`, `ValidateDelivery`, `DefaultDelivery`, `CheckOriginRequirements`, `CheckPatch`, `TruncateCronOutput`). Core links only `tinyflows-bus` (serde and chrono): `cargo tree -p openhuman -e normal -i tinyflows-schedule` is empty, and `tinyflows-drivers` is optional behind `flows` for the catalog alone.
The host keeps four adapters in `crates/openhuman-core/src/cron/`: `client.rs` (typed calls and `ScheduleStore` requests), `documents_port.rs` (the scope's document store served to the module), `bus_host.rs` (the `ScheduleHost` callbacks `Execute`, `Failed`, `Deliver`, `ScheduleTrigger`, bound per scope) and `handlers.rs` (the job-kind registry that replaced the hard-coded shell/agent/flow split and absorbed the system-job handlers). Deleted: `claims.rs`, `scheduler/host.rs`, `scheduler/run_record.rs` and the `tinyflows_schedule` re-export facade. Temporary exception: `tinyflows-bus` carries `chrono` (record timestamps), recorded in `scripts/ci/module-boundaries.json`.