Skip to content

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

feat(config): add journal_retention_days to storage config

Steven Enamakela9ef32fbaadb
diff --git a/crates/openhuman-core/src/config/schema/storage.rs b/crates/openhuman-core/src/config/schema/storage.rs
index 6010827325..dce079703e 100644
--- a/crates/openhuman-core/src/config/schema/storage.rs
+++ b/crates/openhuman-core/src/config/schema/storage.rs
@@ -14,6 +14,9 @@
//! # url = "memory" # tests, keeps nothing
//! ```
//!
+//! `journal_retention_days` (default 30, `0` = forever) is how long a finished
+//! run's sealed event journal is kept ([`crate::storage::journal_maintenance`]).
+//!
//! `OPENHUMAN_STORAGE_URL` overrides it (see [`crate::storage`]). This
//! section is bootstrap configuration: it is always read from the file or the
//! environment, never from storage itself.
@@ -21,7 +24,7 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
+#[derive(Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(default)]
pub struct StorageConfig {
/// The storage URL: `memory`, `sqlite:<path>`, `mongodb://…/<db>`,
@@ -29,6 +32,26 @@ pub struct StorageConfig {
/// default, `sqlite:<workspace>/storage`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
+ /// Days a finished run's sealed event journal is kept before the storage
+ /// maintenance sweep deletes it. `0` keeps sealed journals forever.
+ #[serde(default = "default_journal_retention_days")]
+ pub journal_retention_days: u32,
+}
+
+/// Default for [`StorageConfig::journal_retention_days`].
+pub const DEFAULT_JOURNAL_RETENTION_DAYS: u32 = 30;
+
+fn default_journal_retention_days() -> u32 {
+ DEFAULT_JOURNAL_RETENTION_DAYS
+}
+
+impl Default for StorageConfig {
+ fn default() -> Self {
+ Self {
+ url: None,
+ journal_retention_days: DEFAULT_JOURNAL_RETENTION_DAYS,
+ }
+ }
}
impl std::fmt::Debug for StorageConfig {
@@ -36,6 +59,7 @@ impl std::fmt::Debug for StorageConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("StorageConfig")
.field("url", &self.url.as_deref().map(redact_url))
+ .field("journal_retention_days", &self.journal_retention_days)
.finish()
}
}