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
test(memory): cover the backfill RPC and its tier split
Shanuc908e1e0c60c
diff --git a/src/openhuman/memory/guard/families_tests.rs b/src/openhuman/memory/guard/families_tests.rsindex 741614e263..68246fa6a4 100644--- a/src/openhuman/memory/guard/families_tests.rs+++ b/src/openhuman/memory/guard/families_tests.rs@@ -4,7 +4,7 @@use crate::openhuman::memory::api::provider::chunks::ChunkQuery;use crate::openhuman::memory::api::provider::retrieval::{CoverWindowQuery, FastRetrieveQuery};use crate::openhuman::memory::api::provider::types::SourceScope;-use crate::openhuman::memory::api::provider::{MemoryProvider, MemoryTree};+use crate::openhuman::memory::api::provider::{MemoryMaintenance, MemoryProvider, MemoryTree};use crate::openhuman::memory::api::tree::IngestRequest;use crate::openhuman::memory::api::types::MemoryTaint;@@ -671,3 +671,49 @@ async fn summarise_inputs_are_not_redacted_for_an_embedded_driver() {.expect("summarise");assert_eq!(driver.only_call().content.as_deref(), Some(secrety));}++/// openhuman#6012, review finding: a dry run is a read.+///+/// The member is tiered by what the call *does*, not by what it could do. A dry+/// run counts what a pass would examine and writes nothing, so a `readonly`+/// operator must be able to make it — that is the safe way to size an expensive+/// job, and it is the default (`dry_run` omitted means `true`), so gating it+/// behind the write tier would have refused the ordinary request outright.+/// Executing re-files documents and stays refused at that tier.+#[tokio::test]+async fn guard_admits_a_backfill_dry_run_at_readonly_but_refuses_the_executing_pass() {+ use crate::openhuman::memory::api::provider::types::BackfillTreesRequest;++ let dir = std::env::temp_dir();+ let _tier = live_policy::install_scoped(+ std::sync::Arc::new(SecurityPolicy {+ autonomy: AutonomyLevel::ReadOnly,+ ..SecurityPolicy::default()+ }),+ dir.clone(),+ dir,+ );++ let (_driver, guard) = guarded(embedded_policy());+ let maintenance = guard.as_maintenance().expect("maintenance family");++ maintenance+ .backfill_connector_trees(BackfillTreesRequest {+ limit: None,+ dry_run: true,+ })+ .await+ .expect("a dry run writes nothing, so a readonly tier must admit it");++ let err = maintenance+ .backfill_connector_trees(BackfillTreesRequest {+ limit: None,+ dry_run: false,+ })+ .await+ .expect_err("a readonly tier must refuse the executing pass");+ assert!(+ err.to_string().contains("memory guard: "),+ "the refusal must come from the guard, not the driver: {err}"+ );+}diff --git a/src/openhuman/memory/read_rpc/admin_tests.rs b/src/openhuman/memory/read_rpc/admin_tests.rsindex f61b718ec3..0d82bfe649 100644--- a/src/openhuman/memory/read_rpc/admin_tests.rs+++ b/src/openhuman/memory/read_rpc/admin_tests.rs@@ -156,3 +156,64 @@ async fn delete_source_never_logs_the_raw_source_id() {outcome.logs[0]);}++/// openhuman#6012. Same distinction the wipes above turn on: a backfill the+/// driver cannot perform must not read as `scanned: 0` success. A caller seeing+/// that concludes their stored records are already treed and stops looking —+/// which is exactly the wrong conclusion, because "invisible memories" is the+/// symptom this RPC exists to clear.+#[tokio::test]+async fn backfill_connector_trees_refuses_a_driver_that_serves_no_maintenance() {+ let (_tmp, cfg) = test_config();+ install_null_driver(&cfg);++ let err = super::backfill_connector_trees_rpc(&cfg, None, true)+ .await+ .expect_err("a driver with no Maintenance family cannot re-file anything");+ assert!(+ err.contains("does not serve Maintenance"),+ "the refusal must name the family: {err}"+ );+ assert!(+ err.contains(tinymemory_api::null::NULL_DRIVER_ID),+ "and the driver, so an operator can tell which one refused: {err}"+ );+}++/// `executed` reports the **mode**, not the effect.+///+/// A real pass that finds everything already treed still ran, and that is the+/// expected second run — folding it into "did anything change" would make it+/// indistinguishable from a preview. `ingested` is what answers the effect, and+/// the host must pass the driver's number through rather than infer one.+#[tokio::test]+async fn backfill_connector_trees_reports_the_mode_and_passes_the_counters_through() {+ let (_tmp, cfg) = test_config();+ binding::install_for_test(+ &cfg.workspace_dir,+ &cfg.subsystems.memory,+ Arc::new(binding::FixedDiagnostics::new(+ Default::default(),+ Default::default(),+ )) as Arc<dyn MemoryProvider>,+ );++ let preview = super::backfill_connector_trees_rpc(&cfg, None, true)+ .await+ .expect("a dry run is answerable")+ .value;+ assert!(!preview.executed, "a dry run is the preview mode");++ let real = super::backfill_connector_trees_rpc(&cfg, Some(10), false)+ .await+ .expect("an executing pass is answerable")+ .value;+ assert!(+ real.executed,+ "a real pass reports the mode even when it finds nothing left to do"+ );+ assert_eq!(+ real.ingested, 0,+ "the driver reported no writes, and the host must not invent any"+ );+}