Skip to content

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

feat(storage): schedule journal maintenance and cover retention config

Steven Enamakel65b08f04f183
diff --git a/crates/openhuman-core/src/config/schema/storage_tests.rs b/crates/openhuman-core/src/config/schema/storage_tests.rs
index c29661752a..cfad7748a2 100644
--- a/crates/openhuman-core/src/config/schema/storage_tests.rs
+++ b/crates/openhuman-core/src/config/schema/storage_tests.rs
@@ -17,6 +17,7 @@ fn reads_a_url_from_toml() {
fn debug_never_prints_credentials() {
let config = StorageConfig {
url: Some("mongodb://app:[email protected]/openhuman".into()),
+ ..StorageConfig::default()
};
let shown = format!("{config:?}");
assert!(!shown.contains("hunter2"), "{shown}");
@@ -41,3 +42,12 @@ fn redact_drops_query_and_fragment_tokens() {
"mongodb://***@db/x?***"
);
}
+
+#[test]
+fn journal_retention_defaults_to_thirty_days_and_reads_from_toml() {
+ assert_eq!(StorageConfig::default().journal_retention_days, 30);
+ let unset: StorageConfig = toml::from_str("url = \"memory\"").unwrap();
+ assert_eq!(unset.journal_retention_days, 30);
+ let set: StorageConfig = toml::from_str("journal_retention_days = 7").unwrap();
+ assert_eq!(set.journal_retention_days, 7);
+}
diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rs
index 957b9e32bb..b6e29473a6 100644
--- a/crates/openhuman-core/src/core/runtime/services.rs
+++ b/crates/openhuman-core/src/core/runtime/services.rs
@@ -132,6 +132,15 @@ pub(crate) async fn start_selected_services(
crate::storage::blob_sweep::SWEEP_INTERVAL,
),
);
+ // Run-journal sealing backfill, retention and backend maintenance.
+ tasks.track(
+ "journal_maintenance",
+ crate::storage::journal_maintenance::spawn(
+ &crate::core::runtime::DispatchCtx::new(std::sync::Arc::clone(ctx)),
+ crate::storage::journal_maintenance::FIRST_SWEEP_DELAY,
+ crate::storage::journal_maintenance::SWEEP_INTERVAL,
+ ),
+ );
}
// Flow-run boot reconciliation is selected by the flows *domain*, not by
// a background service — runs can be started without cron in the
diff --git a/crates/openhuman-core/src/storage/journal_maintenance.rs b/crates/openhuman-core/src/storage/journal_maintenance.rs
index c5715e4d11..8da34dc67d 100644
--- a/crates/openhuman-core/src/storage/journal_maintenance.rs
+++ b/crates/openhuman-core/src/storage/journal_maintenance.rs
@@ -190,7 +190,7 @@ async fn configured_retention_days(ctx: &crate::core::runtime::DispatchCtx) -> u
Ok(config) => config.storage.journal_retention_days,
Err(error) => {
tracing::debug!(%error, "{LOG} config unavailable; using the default retention");
- crate::config::DEFAULT_JOURNAL_RETENTION_DAYS
+ crate::config::StorageConfig::default().journal_retention_days
}
}
}