Skip to content

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

refactor(memory): rename file-backed stores to reflect state KV backend

Steven Enamakel9f79bddbe5cc
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rs
index 72ae15e249..4d00f57d90 100644
--- a/crates/openhuman-core/src/memory/import.rs
+++ b/crates/openhuman-core/src/memory/import.rs
@@ -55,13 +55,13 @@ fn release(workspace_dir: &Path) {
/// The state file, written atomically (staged, synced, renamed): a crash
/// mid-write leaves the previous state, never a torn file that reads back as
/// a fresh start and re-sends everything.
-pub(crate) struct FileCheckpointStore {
+pub(crate) struct StateKvCheckpointStore {
workspace_dir: PathBuf,
}
const STATE: &str = "import_state";
-impl FileCheckpointStore {
+impl StateKvCheckpointStore {
pub(crate) fn new(workspace_dir: &Path) -> Self {
Self {
workspace_dir: workspace_dir.to_path_buf(),
@@ -69,7 +69,7 @@ impl FileCheckpointStore {
}
}
-impl CheckpointStore for FileCheckpointStore {
+impl CheckpointStore for StateKvCheckpointStore {
fn load(&self) -> ImportFile {
super::state_store::load(&self.workspace_dir, STATE)
.unwrap_or_else(|error| {
@@ -96,7 +96,7 @@ impl Pacer for TokioPacer {
}
fn read_file(workspace_dir: &Path) -> ImportFile {
- FileCheckpointStore::new(workspace_dir).load()
+ StateKvCheckpointStore::new(workspace_dir).load()
}
/// Whether the last import ended with its last batch not confirmed listed:
@@ -119,7 +119,7 @@ fn importer(
let mut importer = Importer::new(
config.workspace_dir.clone(),
engine,
- Arc::new(FileCheckpointStore::new(&config.workspace_dir)),
+ Arc::new(StateKvCheckpointStore::new(&config.workspace_dir)),
Arc::new(TokioPacer),
Arc::new(move || consent),
)
@@ -262,7 +262,7 @@ pub(crate) async fn resume_interrupted_with(
if let Ok(engine) = engine {
importer(config, engine, true, None).record_resume_failure(&error.to_string());
} else {
- let store = FileCheckpointStore::new(&config.workspace_dir);
+ let store = StateKvCheckpointStore::new(&config.workspace_dir);
let mut file = store.load();
file.state.phase = ImportPhase::Error;
file.state.error = Some(format!("the import could not resume: {error}"));
diff --git a/crates/openhuman-core/src/memory/import_tests.rs b/crates/openhuman-core/src/memory/import_tests.rs
index 2ad8671a3d..db2ccfadd5 100644
--- a/crates/openhuman-core/src/memory/import_tests.rs
+++ b/crates/openhuman-core/src/memory/import_tests.rs
@@ -4,7 +4,7 @@ use crate::memory::test_fixtures::config_in;
#[test]
fn the_state_round_trips_through_the_store() {
let tmp = tempfile::tempdir().unwrap();
- let store = FileCheckpointStore::new(tmp.path());
+ let store = StateKvCheckpointStore::new(tmp.path());
assert_eq!(
store.load(),
ImportFile::default(),
@@ -34,7 +34,7 @@ fn a_running_state_with_no_live_run_reports_interrupted() {
let config = config_in(&tmp);
let mut file = ImportFile::default();
file.state.phase = ImportPhase::Running;
- FileCheckpointStore::new(&config.workspace_dir)
+ StateKvCheckpointStore::new(&config.workspace_dir)
.save(&file)
.unwrap();
let state = status(&config);
@@ -53,7 +53,7 @@ fn a_credits_pause_blocks_organizing_until_resumed() {
let mut file = ImportFile::default();
file.state.phase = ImportPhase::Error;
file.paused_for_credits = true;
- FileCheckpointStore::new(&config.workspace_dir)
+ StateKvCheckpointStore::new(&config.workspace_dir)
.save(&file)
.unwrap();
assert!(in_progress(&config));
@@ -109,7 +109,7 @@ async fn a_paused_scheduler_leaves_an_interrupted_import_for_later() {
let config = config_in(&tmp);
let mut file = ImportFile::default();
file.state.phase = ImportPhase::Running;
- FileCheckpointStore::new(&config.workspace_dir)
+ StateKvCheckpointStore::new(&config.workspace_dir)
.save(&file)
.unwrap();
let resumed = resume_interrupted_with(
diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host.rs b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
index 06107ad20c..22c7a89fc9 100644
--- a/crates/openhuman-core/src/memory/layout_migration/app_host.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
@@ -9,7 +9,7 @@ use tinymemory_tools::layout_migration as lm;
use tinymemory_tools::layout_migration::{Engines, FlowPlacement, LegacyClaim, Placement};
use super::claim::ClaimKey;
-use super::state::FileStateStore;
+use super::state::StateKvMigrationStore;
use crate::config::{Config, MemoryLayoutMode};
use crate::memory::engine::{self, CORTEXDB_ENGINE};
use crate::memory::error::{MemoryError, MemoryResult};
@@ -18,14 +18,14 @@ use crate::memory::scope::{self, MemoryIdentity};
/// The app's [`lm::LayoutHost`], bound to one account's config.
pub struct AppHost {
config: Config,
- store: FileStateStore,
+ store: StateKvMigrationStore,
}
impl AppHost {
/// The host that migrates `config`'s account.
#[must_use]
pub fn new(config: Config) -> Self {
- let store = FileStateStore::new(&config.workspace_dir);
+ let store = StateKvMigrationStore::new(&config.workspace_dir);
Self { config, store }
}
}
diff --git a/crates/openhuman-core/src/memory/layout_migration/mod.rs b/crates/openhuman-core/src/memory/layout_migration/mod.rs
index 005596e337..0853849f38 100644
--- a/crates/openhuman-core/src/memory/layout_migration/mod.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/mod.rs
@@ -23,7 +23,7 @@ mod test_host;
pub use app_host::AppHost;
pub use service::{retry, scan, start, status, tick, StartParams};
-pub use state::FileStateStore;
+pub use state::StateKvMigrationStore;
pub use tinymemory_tools::layout_migration::{
LayoutHost, MigrationState, MigrationStateStore, MigrationStatus, Outcome, Phase, ScanView,
Trigger,
diff --git a/crates/openhuman-core/src/memory/layout_migration/state.rs b/crates/openhuman-core/src/memory/layout_migration/state.rs
index 6734c7248a..7b25a78100 100644
--- a/crates/openhuman-core/src/memory/layout_migration/state.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/state.rs
@@ -25,11 +25,11 @@ pub fn exists(workspace_dir: &Path) -> bool {
/// The migration state kept in one workspace.
#[derive(Debug, Clone)]
-pub struct FileStateStore {
+pub struct StateKvMigrationStore {
workspace_dir: PathBuf,
}
-impl FileStateStore {
+impl StateKvMigrationStore {
/// The store of `workspace_dir`.
#[must_use]
pub fn new(workspace_dir: &Path) -> Self {
@@ -39,7 +39,7 @@ impl FileStateStore {
}
}
-impl MigrationStateStore for FileStateStore {
+impl MigrationStateStore for StateKvMigrationStore {
fn load(&self) -> Result<MigrationState> {
load(&self.workspace_dir).map_err(|error| Error::State(detail(error)))
}
diff --git a/crates/openhuman-core/src/memory/layout_migration/state_tests.rs b/crates/openhuman-core/src/memory/layout_migration/state_tests.rs
index 74ede5c890..655ac87d85 100644
--- a/crates/openhuman-core/src/memory/layout_migration/state_tests.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/state_tests.rs
@@ -43,13 +43,13 @@ fn a_damaged_legacy_file_is_an_error_not_a_fresh_start() {
assert!(exists(tmp.path()), "a state that cannot be read was begun");
assert!(load(tmp.path()).is_err());
// Through the port the host hands the module, too.
- assert!(FileStateStore::new(tmp.path()).load().is_err());
+ assert!(StateKvMigrationStore::new(tmp.path()).load().is_err());
}
#[test]
fn the_port_saves_where_the_status_reads() {
let tmp = tempfile::tempdir().unwrap();
- let store = FileStateStore::new(tmp.path());
+ let store = StateKvMigrationStore::new(tmp.path());
let state = MigrationState {
phase: Phase::Copying,
copied: 3,
diff --git a/crates/openhuman-core/src/memory/layout_migration/test_host.rs b/crates/openhuman-core/src/memory/layout_migration/test_host.rs
index 01d343c634..367c1425e8 100644
--- a/crates/openhuman-core/src/memory/layout_migration/test_host.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/test_host.rs
@@ -13,7 +13,7 @@ use tinymemory_tools::layout_migration::{
use tinymemory_tools::MemoryLayout;
use super::claim::ClaimKey;
-use super::state::FileStateStore;
+use super::state::StateKvMigrationStore;
use crate::config::Config;
/// Two in-memory engines and the switches a real host keeps, with the real
@@ -29,7 +29,7 @@ pub(crate) struct FakeHost {
pub(crate) free_for: AtomicUsize,
/// Written to the legacy tree as the switch happens (a turn racing it).
pub(crate) racing_write: Mutex<Option<StoreItem>>,
- store: FileStateStore,
+ store: StateKvMigrationStore,
workspace: std::path::PathBuf,
}
@@ -47,7 +47,7 @@ impl FakeHost {
claim: None,
free_for: AtomicUsize::new(usize::MAX),
racing_write: Mutex::new(None),
- store: FileStateStore::new(&config.workspace_dir),
+ store: StateKvMigrationStore::new(&config.workspace_dir),
workspace: config.workspace_dir.clone(),
}
}
diff --git a/scripts/ci/storage-bypass-baseline.json b/scripts/ci/storage-bypass-baseline.json
index 748c17415b..92207edae9 100644
--- a/scripts/ci/storage-bypass-baseline.json
+++ b/scripts/ci/storage-bypass-baseline.json
@@ -342,13 +342,6 @@
"text": "std::fs::write(&workflow_toml_path, workflow_toml)",
"occurrence": 1
},
- {
- "rule": "json-write",
- "path": "crates/openhuman-core/src/skills/ops_discover/api.rs",
- "line": 54,
- "text": "std::fs::write(&readme_path, content)",
- "occurrence": 1
- },
{
"rule": "json-write",
"path": "crates/openhuman-core/src/skills/webhooks/router.rs",
diff --git a/scripts/ci/storage-bypass-extension.json b/scripts/ci/storage-bypass-extension.json
index 64561fdc74..5afd08d0e3 100644
--- a/scripts/ci/storage-bypass-extension.json
+++ b/scripts/ci/storage-bypass-extension.json
@@ -279,16 +279,6 @@
"reason": "Legacy memory layout migration claim/state marker publication; historical source capture and native migration admission remain separate.",
"issue": "https://github.com/tinyhumansai/openhuman/issues/7427"
},
- {
- "rule": "file-store-new",
- "path": "crates/openhuman-core/src/memory/layout_migration/test_host.rs",
- "line": 50,
- "text": "store: FileStateStore::new(&config.workspace_dir),",
- "occurrence": 1,
- "classification": "scratch",
- "reason": "Test-only layout migration host, wired under cfg(test), instantiates the file-state fixture for migration controls; it is not a product storage route.",
- "issue": "https://github.com/tinyhumansai/openhuman/issues/7427"
- },
{
"rule": "writer-helper",
"path": "crates/openhuman-core/src/modules/browser_task_report.rs",