Skip to content

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

fix(cron): align schedule store with dotted collection names

Steven Enamakel95ba8ff20787
diff --git a/crates/openhuman-core/src/cron/documents_port.rs b/crates/openhuman-core/src/cron/documents_port.rs
index 7f4db1b5cd..3d8ea8f058 100644
--- a/crates/openhuman-core/src/cron/documents_port.rs
+++ b/crates/openhuman-core/src/cron/documents_port.rs
@@ -36,11 +36,14 @@ use crate::config::Config;
use crate::modules::tinyflows as module;
/// The collections the schedule store owns.
-const COLLECTIONS: [&str; 4] = [
- "cron_jobs",
- "cron_runs",
- "cron_counters",
+const COLLECTIONS: [&str; 7] = [
+ "cron.jobs",
+ "cron.runs",
+ "cron.admission",
"cron_job_policies",
+ "tsd.counters",
+ "tsd.leases",
+ "tsd.migrations",
];
/// Where one scope's cron documents live: the workspace whose default backend
diff --git a/crates/openhuman-core/src/cron/documents_port_tests.rs b/crates/openhuman-core/src/cron/documents_port_tests.rs
index acebc8f220..4699443cbf 100644
--- a/crates/openhuman-core/src/cron/documents_port_tests.rs
+++ b/crates/openhuman-core/src/cron/documents_port_tests.rs
@@ -38,9 +38,9 @@ async fn a_second_absent_write_comes_back_as_a_conflict_kind() {
let (proxy, _) = port().await;
let absent = serde_json::to_value(tinystoragedrivers::Precondition::Absent).unwrap();
let put =
- json!({"op":"put","collection":"cron_jobs","id":"dup","doc":{"a":1},"precondition":absent});
+ json!({"op":"put","collection":"cron.jobs","id":"dup","doc":{"a":1},"precondition":absent});
// The collection must exist first; the module declares it, the port relays.
- let ensured = ask(&proxy, json!({"op":"ensure","spec":{"name":"cron_jobs"}})).await;
+ let ensured = ask(&proxy, json!({"op":"ensure","spec":{"name":"cron.jobs"}})).await;
assert!(ensured.get("error").is_none(), "{ensured}");
let first = ask(&proxy, put.clone()).await;
assert!(first.get("error").is_none(), "{first}");
@@ -57,7 +57,7 @@ async fn a_collection_outside_the_schedule_port_is_refused() {
json!({"op":"count","collection":"flows","filter":{}}),
json!({"op":"ensure","spec":{"name":"secrets"}}),
json!({"op":"atomic_batch","ops":[
- {"op":"put","collection":"cron_jobs","id":"ok","doc":{},"precondition":none},
+ {"op":"put","collection":"cron.jobs","id":"ok","doc":{},"precondition":none},
{"op":"delete","collection":"approvals","id":"x","precondition":none}
]}),
] {
@@ -74,7 +74,7 @@ async fn an_unknown_operation_is_refused_not_guessed() {
let (proxy, _) = port().await;
let reply = ask(
&proxy,
- json!({"op":"drop_collection","collection":"cron_jobs"}),
+ json!({"op":"drop_collection","collection":"cron.jobs"}),
)
.await;
assert_eq!(reply["error"]["kind"], "invalid_input", "{reply}");
diff --git a/crates/openhuman-core/src/cron/store.rs b/crates/openhuman-core/src/cron/store.rs
index 5bbdabec48..e85b3495de 100644
--- a/crates/openhuman-core/src/cron/store.rs
+++ b/crates/openhuman-core/src/cron/store.rs
@@ -310,7 +310,7 @@ pub fn list_runs(config: &Config, job_id: &str, limit: usize) -> Result<Vec<Cron
/// Moves a job's next run to `at`, which no production path can do directly
/// (a patch reschedules from the schedule, not to a given instant). Writes the
-/// three forms the store keeps of the instant, so the due-job query sees it.
+/// instant the store keeps (`next_run_ms`), so the due-job query sees it.
#[cfg(test)]
pub(crate) fn force_next_run_for_test(
config: &Config,
@@ -323,14 +323,12 @@ pub(crate) fn force_next_run_for_test(
let job_id = job_id.to_string();
crate::storage::block_on_anyhow(async move {
let stored = docs
- .get("cron_jobs", &job_id)
+ .get("cron.jobs", &job_id)
.await?
.ok_or_else(|| anyhow::anyhow!("no job {job_id}"))?;
let mut doc = stored.doc;
- doc["next_run"] = serde_json::json!(at.to_rfc3339());
doc["next_run_ms"] = serde_json::json!(at.timestamp_millis());
- doc["next_run_ns"] = serde_json::json!(at.timestamp_nanos_opt().unwrap_or(i64::MAX));
- docs.put("cron_jobs", &job_id, doc, Precondition::None)
+ docs.put("cron.jobs", &job_id, doc, Precondition::None)
.await?;
Ok(())
})
diff --git a/crates/openhuman-core/src/storage/boot_tests.rs b/crates/openhuman-core/src/storage/boot_tests.rs
index 7c857eb96b..5571508be8 100644
--- a/crates/openhuman-core/src/storage/boot_tests.rs
+++ b/crates/openhuman-core/src/storage/boot_tests.rs
@@ -19,7 +19,12 @@ async fn a_v1_agent_scope_is_moved_before_its_owner_steps_run() {
let backend: Arc<dyn StorageBackend> = Arc::new(MemoryStorage::new());
let old = backend.for_scope(&Scope::new("asha").unwrap()).unwrap();
old.documents()
- .put("harness_run_status", "run-1", json!({"status": "done"}), Precondition::None)
+ .put(
+ "harness_embedding_cache",
+ "legacy-id",
+ json!({"sig": "s", "key": "k", "vector": [1.0]}),
+ Precondition::None,
+ )
.await
.unwrap();
let report = prepare_and_migrate(&backend).await.unwrap();
@@ -28,7 +33,7 @@ async fn a_v1_agent_scope_is_moved_before_its_owner_steps_run() {
let new = backend.for_scope(&Scope::local().agent("asha").unwrap()).unwrap();
assert!(new
.documents()
- .get("harness.run_status", "run-1")
+ .get("harness.embedding_cache", "s/k")
.await
.unwrap()
.is_some());