The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(goals): remove legacy file-backed goal migration code
Steven Enamakel5b1c82911d65
diff --git a/crates/openhuman-core/src/agent/goals/migration.rs b/crates/openhuman-core/src/agent/goals/migration.rsdeleted file mode 100644index 57b8636657..0000000000--- a/crates/openhuman-core/src/agent/goals/migration.rs+++ /dev/null@@ -1,134 +0,0 @@-//! One-time migration from OpenHuman's retired file-backed thread-goal store-//! into tinyagents' authoritative `graph.goals` namespace.--use std::path::Path;-use std::sync::Arc;--use tinyagents_graph::goals::store::GOALS_NAMESPACE;-use tinyagents_harness::store::Store;--use super::ThreadGoal;-use crate::agent::session_import::ops::open_session_stores;--const LEGACY_GOALS_DIR: &str = "thread_goals";-const LEGACY_GOALS_EXTENSION: &str = "json";--pub(crate) fn goals_store(workspace_dir: &Path) -> Arc<dyn Store> {- Arc::new(open_session_stores(workspace_dir).kv)-}--fn goal_key(thread_id: &str) -> String {- thread_id- .trim()- .as_bytes()- .iter()- .map(|byte| format!("{byte:02x}"))- .collect()-}--fn legacy_goal_path(workspace_dir: &Path, thread_id: &str) -> Result<std::path::PathBuf, String> {- let thread_id = thread_id.trim();- if thread_id.is_empty() {- return Err("invalid thread goal thread_id: empty or whitespace".to_string());- }- Ok(workspace_dir.join(LEGACY_GOALS_DIR).join(format!(- "{}.{LEGACY_GOALS_EXTENSION}",- hex::encode(thread_id.as_bytes())- )))-}--pub(crate) async fn delete_legacy_goal_file(- workspace_dir: &Path,- thread_id: &str,-) -> Result<bool, String> {- let path = legacy_goal_path(workspace_dir, thread_id)?;- match tokio::fs::remove_file(&path).await {- Ok(()) => Ok(true),- Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(false),- Err(error) => Err(format!(- "delete legacy thread goal {}: {error}",- path.display()- )),- }-}--#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]-pub struct GoalMigrationReport {- pub total: usize,- pub copied: usize,- pub skipped: usize,-}--struct LegacyGoalRow {- path: std::path::PathBuf,- goal: ThreadGoal,-}--async fn read_legacy_goals(workspace_dir: &Path) -> Result<Vec<LegacyGoalRow>, String> {- let dir = workspace_dir.join(LEGACY_GOALS_DIR);- let mut entries = match tokio::fs::read_dir(&dir).await {- Ok(entries) => entries,- Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(Vec::new()),- Err(error) => {- return Err(format!(- "read legacy thread goals dir {}: {error}",- dir.display()- ))- }- };- let mut goals = Vec::new();- while let Some(entry) = entries- .next_entry()- .await- .map_err(|error| format!("iterate legacy thread goals dir: {error}"))?- {- let path = entry.path();- if path.extension().and_then(|extension| extension.to_str()) != Some(LEGACY_GOALS_EXTENSION)- {- continue;- }- if let Ok(body) = tokio::fs::read_to_string(&path).await {- if let Ok(goal) = serde_json::from_str::<ThreadGoal>(&body) {- goals.push(LegacyGoalRow { path, goal });- }- }- }- Ok(goals)-}--pub async fn migrate_legacy_goals(workspace_dir: &Path) -> Result<GoalMigrationReport, String> {- let legacy = read_legacy_goals(workspace_dir).await?;- let store = goals_store(workspace_dir);- let mut report = GoalMigrationReport {- total: legacy.len(),- ..Default::default()- };-- for row in legacy {- let key = goal_key(&row.goal.thread_id);- if store- .get(GOALS_NAMESPACE, &key)- .await- .map_err(|error| format!("read tinyagents goal during migration: {error}"))?- .is_some()- {- report.skipped += 1;- } else {- let value = serde_json::to_value(&row.goal)- .map_err(|error| format!("serialize legacy thread goal: {error}"))?;- store- .put(GOALS_NAMESPACE, &key, value)- .await- .map_err(|error| format!("write tinyagents goal during migration: {error}"))?;- report.copied += 1;- }- tokio::fs::remove_file(&row.path)- .await- .map_err(|error| format!("remove migrated goal {}: {error}", row.path.display()))?;- }- Ok(report)-}--#[cfg(test)]-#[path = "migration_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/agent/goals/migration_tests.rs b/crates/openhuman-core/src/agent/goals/migration_tests.rsdeleted file mode 100644index 821f3a2431..0000000000--- a/crates/openhuman-core/src/agent/goals/migration_tests.rs+++ /dev/null@@ -1,43 +0,0 @@-use super::*;-use tinyagents_graph::goals::{store, ThreadGoalStatus};--#[tokio::test]-async fn migrates_legacy_goal_into_tinyagents_store() {- let temp = tempfile::tempdir().unwrap();- let legacy_dir = temp.path().join(LEGACY_GOALS_DIR);- tokio::fs::create_dir_all(&legacy_dir).await.unwrap();- let goal = ThreadGoal {- thread_id: "thread-1".into(),- goal_id: "legacy-id".into(),- objective: "legacy objective".into(),- status: ThreadGoalStatus::Active,- token_budget: Some(100),- tokens_used: 10,- time_used_seconds: 2,- created_at_ms: 1,- updated_at_ms: 2,- continuation_suppressed: false,- };- let path = legacy_goal_path(temp.path(), &goal.thread_id).unwrap();- tokio::fs::write(&path, serde_json::to_vec(&goal).unwrap())- .await- .unwrap();-- let report = migrate_legacy_goals(temp.path()).await.unwrap();- assert_eq!(- report,- GoalMigrationReport {- total: 1,- copied: 1,- skipped: 0- }- );- assert_eq!(- store::get(&goals_store(temp.path()), "thread-1")- .await- .unwrap()- .unwrap(),- goal- );- assert!(!path.exists());-}diff --git a/crates/openhuman-core/src/agent/goals/mod.rs b/crates/openhuman-core/src/agent/goals/mod.rsindex 7333c006d0..5ffe8bee68 100644--- a/crates/openhuman-core/src/agent/goals/mod.rs+++ b/crates/openhuman-core/src/agent/goals/mod.rs@@ -7,7 +7,6 @@//! OpenHuman's `Tool` and `StopHook` traits.pub mod continuation;-pub mod migration;pub mod runtime;pub mod store;pub mod tools;diff --git a/crates/openhuman-core/src/core/runtime/builder.rs b/crates/openhuman-core/src/core/runtime/builder.rsindex 4c12b5fbc2..ec0fba9e13 100644--- a/crates/openhuman-core/src/core/runtime/builder.rs+++ b/crates/openhuman-core/src/core/runtime/builder.rs@@ -658,9 +658,9 @@ impl CoreBuilder {).await?;- // Legacy goal and task-board rows must be copied before- // `build()` exposes in-process RPC or agent turns. Running these from- // `serve()` is too late for embedders that only build and invoke.+ // Retired scheduled jobs must be pruned before `build()` exposes+ // in-process RPC or agent turns. Running this from `serve()` is too+ // late for embedders that only build and invoke.if let Some(cfg) = config.as_ref() {crate::core::runtime::services::run_legacy_migrations(cfg).await;}diff --git a/crates/openhuman-core/src/core/runtime/services.rs b/crates/openhuman-core/src/core/runtime/services.rsindex 9e1dcb67d7..2f0b407878 100644--- a/crates/openhuman-core/src/core/runtime/services.rs+++ b/crates/openhuman-core/src/core/runtime/services.rs@@ -410,8 +410,8 @@ pub async fn start_boot_once_jobs(services: ServiceSet, config: &Config) {}}-/// Migrates legacy goal and task-board state before a built-/// runtime can expose those crate-backed stores to in-process or HTTP callers.+/// Prunes retired scheduled jobs before a built runtime can expose the+/// scheduler to in-process or HTTP callers.pub(crate) async fn run_legacy_migrations(config: &Config) {match crate::cron::seed::prune_retired_jobs(config) {Ok(count) if count > 0 => {@@ -420,17 +420,6 @@ pub(crate) async fn run_legacy_migrations(config: &Config) {Ok(_) => {}Err(e) => log::warn!("[cron] failed to prune retired jobs: {e}"),}-- match crate::agent::goals::migration::migrate_legacy_goals(&config.workspace_dir).await {- Ok(report) if report.total > 0 => log::info!(- "[thread_goals] legacy→crate migration: total={} copied={} skipped={}",- report.total,- report.copied,- report.skipped- ),- Ok(_) => {}- Err(e) => log::warn!("[thread_goals] legacy→crate migration failed: {e}"),- }}/// Auto-connect Socket.IO to the backend when enabled by the service selection.