Skip to content

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

test(memory): assert the backfill counters with distinct non-zero values\n\nReview finding, and correct: the counter test asserted zeros, so it passed just\nas happily if the RPC dropped every number the driver reported or replaced them\nwith zeros — the exact class of bug a mapping test exists to catch. An all-zero\nfixture cannot tell a working passthrough from no passthrough at all.\n\nThe test driver now answers `backfill_connector_trees` with a set outcome, and\nthe values are distinct as well as non-zero (41/17/23/5, more_pending, one\nnote): distinct also catches a transposition, which is invisible when two\nfields are both 0.\n\n`backfilling_trees` is deliberately not `backfilling` — that name is taken by\nthe unrelated `backfill_in_progress` flag, which answers "is a re-embed\nrunning" rather than "what did the connector-tree pass do".\n\nRefs #6012\n

Shanu47a6765af2cc
diff --git a/src/openhuman/memory/binding.rs b/src/openhuman/memory/binding.rs
index 969a7a1d69..fd7353216a 100644
--- a/src/openhuman/memory/binding.rs
+++ b/src/openhuman/memory/binding.rs
@@ -527,6 +527,13 @@ pub(crate) struct FixedDiagnostics {
/// between them — nothing ready, nothing running, backfill unfinished —
/// has to set the two independently.
backfill: bool,
+ /// What [`MemoryMaintenance::backfill_connector_trees`] answers, when a test
+ /// sets it.
+ ///
+ /// Distinct from [`Self::backfill`], which is the unrelated
+ /// `backfill_in_progress` flag — one is "is a re-embed running", the other
+ /// is the connector-tree pass's counters.
+ backfill_trees: crate::openhuman::memory::api::provider::types::BackfillTreesOutcome,
/// What [`MemoryMaintenance::flush_pending`] answers, when a test sets it.
flush: crate::openhuman::memory::api::provider::types::FlushOutcome,
/// What [`MemoryMaintenance::reset_derived_index`] answers, likewise.
diff --git a/src/openhuman/memory/binding_fixed_diagnostics_impl_tests.rs b/src/openhuman/memory/binding_fixed_diagnostics_impl_tests.rs
index 80146a5ffd..d77e81b646 100644
--- a/src/openhuman/memory/binding_fixed_diagnostics_impl_tests.rs
+++ b/src/openhuman/memory/binding_fixed_diagnostics_impl_tests.rs
@@ -22,6 +22,7 @@ impl FixedDiagnostics {
queue,
failure: None,
backfill: false,
+ backfill_trees: Default::default(),
flush: Default::default(),
reset: Default::default(),
retry_calls: std::sync::atomic::AtomicUsize::new(0),
@@ -42,6 +43,18 @@ impl FixedDiagnostics {
self
}
+ /// Answer [`MemoryMaintenance::backfill_connector_trees`] with `outcome`.
+ ///
+ /// Named apart from [`Self::backfilling`], which sets the unrelated
+ /// `backfill_in_progress` flag.
+ pub(crate) fn backfilling_trees(
+ mut self,
+ outcome: crate::openhuman::memory::api::provider::types::BackfillTreesOutcome,
+ ) -> Self {
+ self.backfill_trees = outcome;
+ self
+ }
+
/// Answer [`MemoryMaintenance::flush_pending`] with `outcome`.
pub(crate) fn flushing(
mut self,
@@ -193,6 +206,14 @@ impl MemoryMaintenance for FixedDiagnostics {
Ok(self.flush.clone())
}
+ async fn backfill_connector_trees(
+ &self,
+ _request: crate::openhuman::memory::api::provider::types::BackfillTreesRequest,
+ ) -> Result<crate::openhuman::memory::api::provider::types::BackfillTreesOutcome, MemoryError>
+ {
+ Ok(self.backfill_trees.clone())
+ }
+
async fn reset_derived_index(
&self,
) -> Result<crate::openhuman::memory::api::provider::types::ResetOutcome, MemoryError> {
diff --git a/src/openhuman/memory/read_rpc/admin_tests.rs b/src/openhuman/memory/read_rpc/admin_tests.rs
index 0d82bfe649..ac7d313bef 100644
--- a/src/openhuman/memory/read_rpc/admin_tests.rs
+++ b/src/openhuman/memory/read_rpc/admin_tests.rs
@@ -180,22 +180,33 @@ async fn backfill_connector_trees_refuses_a_driver_that_serves_no_maintenance()
);
}
-/// `executed` reports the **mode**, not the effect.
+/// `executed` reports the **mode**, not the effect — and every counter the
+/// driver reports reaches the caller unchanged.
///
-/// 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.
+/// The counters are deliberately distinct and non-zero. An all-zero fixture
+/// would pass just as happily if this RPC dropped the driver's numbers or
+/// replaced them with zeros, which is the whole class of bug the mapping can
+/// have (review finding). Distinct values also catch a transposition — two
+/// fields swapped is invisible when both are 0.
#[tokio::test]
async fn backfill_connector_trees_reports_the_mode_and_passes_the_counters_through() {
+ use crate::openhuman::memory::api::provider::types::BackfillTreesOutcome;
+
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>,
+ Arc::new(
+ binding::FixedDiagnostics::new(Default::default(), Default::default())
+ .backfilling_trees(BackfillTreesOutcome {
+ scanned: 41,
+ ingested: 17,
+ already_present: 23,
+ skipped: 5,
+ more_pending: true,
+ notes: vec!["skill-gmail: skipped".to_string()],
+ }),
+ ) as Arc<dyn MemoryProvider>,
);
let preview = super::backfill_connector_trees_rpc(&cfg, None, true)
@@ -212,8 +223,20 @@ async fn backfill_connector_trees_reports_the_mode_and_passes_the_counters_throu
real.executed,
"a real pass reports the mode even when it finds nothing left to do"
);
+ assert_eq!(real.scanned, 41, "scanned must come from the driver");
+ assert_eq!(real.ingested, 17, "ingested must come from the driver");
+ assert_eq!(
+ real.already_present, 23,
+ "already_present must come from the driver"
+ );
+ assert_eq!(real.skipped, 5, "skipped must come from the driver");
+ assert!(
+ real.more_pending,
+ "more_pending must survive; a pass that stopped on its limit must not read as complete"
+ );
assert_eq!(
- real.ingested, 0,
- "the driver reported no writes, and the host must not invent any"
+ real.notes,
+ vec!["skill-gmail: skipped".to_string()],
+ "the skip reasons are what tell an operator which accounts were left alone"
);
}