Skip to content

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

Gate the credits resume on memory billing's free-period check

M3gA-Mindebb755dda82d
diff --git a/crates/openhuman-core/src/memory/import.rs b/crates/openhuman-core/src/memory/import.rs
index a4b83bf63c..3d905e8231 100644
--- a/crates/openhuman-core/src/memory/import.rs
+++ b/crates/openhuman-core/src/memory/import.rs
@@ -329,18 +329,6 @@ pub(crate) type PauseCheck = Arc<dyn Fn() -> bool + Send + Sync>;
/// automatic import, or resuming one paused for credits), may run now.
pub(crate) type BillingCheck = Arc<dyn Fn(&Config) -> bool + Send + Sync>;
-/// The one gate on automatic migration runs. A self-hosted CortexDB bills
-/// nobody, so it always may. On the TinyHuman memory service an automatic
-/// run spends the user's credits, so it may only while the backend's memory
-/// free period is active.
-///
-/// The shared free-period check (`free_period_active()`) replaces the
-/// TinyHuman half once it lands; until then the free period is unknown, and
-/// unknown is not free.
-pub(crate) fn automatic_run_allowed(config: &Config) -> bool {
- config.memory.engine.trim() == super::engine::CORTEXDB_ENGINE
-}
-
/// The scheduler's pause, which includes being signed out.
fn scheduler_paused() -> bool {
matches!(
@@ -353,10 +341,18 @@ fn scheduler_paused() -> bool {
/// the scheduler's pause ([`resume_interrupted_with`]). Called from memory's
/// background job.
pub async fn resume_interrupted(config: &Config) -> bool {
+ // A credits pause resumes on its own only while memory work is free
+ // (`billing::free_period_active`: always on a self-hosted engine, the
+ // backend's free period on the TinyHuman one). The backend is asked only
+ // when such a pause is waiting on it.
+ let file = read_file(&config.workspace_dir);
+ let free = file.state.phase == ImportPhase::Error
+ && file.paused_for_credits
+ && super::billing::free_period_active(config).await;
resume_interrupted_with(
config,
Arc::new(scheduler_paused),
- Arc::new(automatic_run_allowed),
+ Arc::new(move |_: &Config| free),
)
.await
}
diff --git a/crates/openhuman-core/src/memory/import_recovery_tests.rs b/crates/openhuman-core/src/memory/import_recovery_tests.rs
index 748ad7e610..45b018395f 100644
--- a/crates/openhuman-core/src/memory/import_recovery_tests.rs
+++ b/crates/openhuman-core/src/memory/import_recovery_tests.rs
@@ -166,19 +166,6 @@ async fn a_stop_that_is_not_about_credits_is_not_resumed_by_billing() {
assert!(!resume_interrupted_with(&config, always(false), billing(true)).await);
}
-#[test]
-fn only_a_self_hosted_engine_runs_automatically_until_the_free_period_check_lands() {
- let tmp = tempfile::tempdir().unwrap();
- let mut config = config_in(&tmp);
- config.memory.engine = crate::memory::engine::CORTEXDB_ENGINE.to_string();
- assert!(automatic_run_allowed(&config));
- config.memory.engine = crate::memory::engine::TINYHUMANS_ENGINE.to_string();
- assert!(
- !automatic_run_allowed(&config),
- "unknown free period is not free"
- );
-}
-
/// An engine refusal of the "Ideas" document while `$flag` is set, one flag
/// per test so tests running in parallel never toggle each other's.
macro_rules! ideas_refusal {
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index ea7d960aa5..b561e4768e 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -368,7 +368,7 @@ Spec: `docs/specs/memory-v2.md` (host) and `vendor/tinymemory/docs/specs/memory-
| 8.2.5 | Document sources: add, sync, list, remove | RU+RI+WD | `crates/openhuman-core/src/memory/sources/sync_tests.rs`, `crates/openhuman-core/src/memory/sources/composio_tests.rs`, `crates/openhuman-core/src/memory/sources/mod_tests.rs`, `tests/memory_v2_e2e.rs` (`sources_add_sync_list_and_remove`), `app/test/playwright/specs/memory-v2.spec.ts` | ✅ | folder, file, link, github, rss, composio |
| 8.2.6 | Folder-source path picker | RU+VU | `crates/openhuman-app/src/directory_picker.rs`, `app/src/utils/tauriCommands/directoryPicker.test.ts` | ✅ | |
| 8.2.7 | Pack preview (Ask tab) and brain views | RU+RI+WD | `crates/openhuman-core/src/memory/lifecycle/views_tests.rs`, `crates/openhuman-core/src/memory/brain_tests.rs`, `tests/memory_v2_e2e.rs`, `app/test/playwright/specs/memory-v2.spec.ts` | ✅ | No `context.md`; pack never persisted in the transcript |
-| 8.2.8 | One-time import of previous (v1) memory | RU+RI+WD | `crates/openhuman-core/src/memory/import_tests.rs`, `tests/memory_v2_e2e.rs`, `app/test/playwright/specs/memory-v2.spec.ts` (`importing previous memory needs explicit consent`, `a stopped import resumes only after consent`), `app/src/components/memory/MemoryImportBanner.test.tsx` | ✅ | Refused without consent; stops (not skips) on exhausted credits (`exhausted_credits_stop_the_import_instead_of_skipping_everything`) and resumes on its own only once automatic runs are allowed (`an_import_out_of_credits_resumes_only_once_automatic_runs_are_allowed`, `only_a_self_hosted_engine_runs_automatically_until_the_free_period_check_lands`); an unavailable engine is retried in-run (`a_transient_failure_is_retried_within_the_run`) and then resumed by the background job (`an_engine_that_stays_unavailable_is_resumed_by_the_background_job`); refused items are kept and retried (`a_refused_item_is_kept_and_a_retry_stores_it`); state written atomically and a resume keeps its total (`the_import_state_is_written_whole_and_leaves_no_staging_file`, `a_resumed_import_keeps_its_total_instead_of_rescanning`); the background job resumes an import the app quit during (`the_background_job_resumes_an_interrupted_import`), never while paused, including a pause mid-run (`nothing_resumes_while_background_work_is_paused`, `a_pause_that_lands_after_the_check_stops_the_run_at_the_next_batch`); a resume that cannot start is stopped, not retried (`an_automatic_resume_that_cannot_start_is_stopped_not_retried`); Resume button after an error, behind consent (`a stopped import resumes only after consent`) |
+| 8.2.8 | One-time import of previous (v1) memory | RU+RI+WD | `crates/openhuman-core/src/memory/import_tests.rs`, `tests/memory_v2_e2e.rs`, `app/test/playwright/specs/memory-v2.spec.ts` (`importing previous memory needs explicit consent`, `a stopped import resumes only after consent`), `app/src/components/memory/MemoryImportBanner.test.tsx` | ✅ | Refused without consent; stops (not skips) on exhausted credits (`exhausted_credits_stop_the_import_instead_of_skipping_everything`) and resumes on its own only while memory work is free, per `billing::free_period_active` (`an_import_out_of_credits_resumes_only_once_automatic_runs_are_allowed`); an unavailable engine is retried in-run (`a_transient_failure_is_retried_within_the_run`) and then resumed by the background job (`an_engine_that_stays_unavailable_is_resumed_by_the_background_job`); refused items are kept and retried (`a_refused_item_is_kept_and_a_retry_stores_it`); state written atomically and a resume keeps its total (`the_import_state_is_written_whole_and_leaves_no_staging_file`, `a_resumed_import_keeps_its_total_instead_of_rescanning`); the background job resumes an import the app quit during (`the_background_job_resumes_an_interrupted_import`), never while paused, including a pause mid-run (`nothing_resumes_while_background_work_is_paused`, `a_pause_that_lands_after_the_check_stops_the_run_at_the_next_batch`); a resume that cannot start is stopped, not retried (`an_automatic_resume_that_cannot_start_is_stopped_not_retried`); Resume button after an error, behind consent (`a stopped import resumes only after consent`) |
| 8.2.9 | MCP memory tools | RU | `crates/openhuman-core/src/mcp/server/tools/` | ✅ | `memory.recall`, `memory.fetch`, `memory.list`, `memory.learn`, `memory.forget` |
| 8.2.10 | Memory UI chips and legacy redirects | VU+WD | `app/src/components/memory/*.test.tsx`, `app/test/playwright/specs/memory-v2.spec.ts` | ✅ | Engine, Ask, Explorer, Learnings, Conversations, Brain, Background, Settings; `/brain` and `/settings/memory-engine` redirect |