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
fix(memory): let a readonly operator preview the backfill
Shanu1bff5f478a03
diff --git a/src/openhuman/memory/guard/families_part_02.rs b/src/openhuman/memory/guard/families_part_02.rsindex d153d1ce7a..83d952e40f 100644--- a/src/openhuman/memory/guard/families_part_02.rs+++ b/src/openhuman/memory/guard/families_part_02.rs@@ -391,20 +391,38 @@ impl MemoryMaintenance for GuardedMaintenance {self.family()?.consolidate().await}- /// Writes memory-tree rows for documents already stored, so it takes the- /// **write** tier like every other mutating maintenance member. A- /// `readonly` operator may inspect a store; re-filing thousands of its+ /// Tiered by what the call actually does, not by what the member could do.+ ///+ /// Executing writes memory-tree rows for documents already stored, so it+ /// takes the **write** tier like every other mutating maintenance member: a+ /// `readonly` operator may inspect a store, and re-filing thousands of its/// documents is not inspection.+ ///+ /// A **dry run writes nothing** — it counts what a pass would examine — so+ /// it takes the **read** tier, the same trade [`Self::doctor`] makes below.+ /// Gating it behind the write tier would withhold the one safe way to size+ /// the job from precisely the tier that should be sizing rather than+ /// executing, and the preview is what the expensive control exists to be+ /// asked for first (review finding).async fn backfill_connector_trees(&self,request: BackfillTreesRequest,) -> Result<BackfillTreesOutcome, MemoryError> {- self.policy.admit_write(- Capability::Maintenance,- "maintenance.backfill_connector_trees",- NO_NAMESPACE,- false,- )?;+ if request.dry_run {+ self.policy.admit_read(+ Capability::Maintenance,+ "maintenance.backfill_connector_trees",+ NO_NAMESPACE,+ false,+ )?;+ } else {+ self.policy.admit_write(+ Capability::Maintenance,+ "maintenance.backfill_connector_trees",+ NO_NAMESPACE,+ false,+ )?;+ }self.family()?.backfill_connector_trees(request).await}@@ -567,169 +585,3 @@ impl MemoryPeople for GuardedPeople {self.family()?.seed_from_address_book().await}}--// ── Chunks ───────────────────────────────────────────────────────────────────--#[async_trait]-impl MemoryChunks for GuardedChunks {- async fn list_chunks(- &self,- query: &ChunkQuery,- scope: Option<&SourceScope>,- ) -> Result<Vec<Chunk>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.list_chunks",- NO_NAMESPACE,- false,- )?;- // Intersected with the ambient allowlist, never passed through. The- // ambient scope is an upper bound: forwarding the caller's scope- // unchanged would let a source-restricted turn widen itself back out by- // naming a collection the restriction excluded. See- // `GuardPolicy::narrow_scope`.- let effective = self.policy.narrow_scope(scope);- self.family()?.list_chunks(query, effective.as_ref()).await- }-- /// The count that labels a [`Self::list_chunks`] page, and it must be- /// narrowed by exactly the same rule. A total computed against a wider- /// scope than the page it labels leaks the existence of rows the caller may- /// not read — "showing 20 of 4000" tells a source-restricted turn how much- /// it is not being shown.- async fn count_chunks(- &self,- query: &ChunkQuery,- scope: Option<&SourceScope>,- ) -> Result<u64, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.count_chunks",- NO_NAMESPACE,- false,- )?;- let effective = self.policy.narrow_scope(scope);- self.family()?.count_chunks(query, effective.as_ref()).await- }-- /// Same rows as [`Self::list_chunks`] with the stored facts beside them, so- /// the same intersection applies for the same reason.- async fn list_chunk_details(- &self,- query: &ChunkQuery,- scope: Option<&SourceScope>,- ) -> Result<Vec<ChunkListRow>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.list_chunk_details",- NO_NAMESPACE,- false,- )?;- let effective = self.policy.narrow_scope(scope);- self.family()?- .list_chunk_details(query, effective.as_ref())- .await- }-- /// Per-source totals are computed from the chunks the scope admits, not- /// filtered afterwards — so a restricted caller must not learn that a- /// forbidden source exists by seeing its row, nor see a permitted source- /// carrying a count that includes rows it cannot read.- async fn source_totals(- &self,- limit: usize,- scope: Option<&SourceScope>,- ) -> Result<Vec<SourceTotal>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.source_totals",- NO_NAMESPACE,- false,- )?;- let effective = self.policy.narrow_scope(scope);- self.family()?- .source_totals(limit, effective.as_ref())- .await- }-- async fn get_chunk(&self, chunk_id: &str) -> Result<Option<Chunk>, MemoryError> {- self.policy- .admit_read(Capability::Chunks, "chunks.get_chunk", NO_NAMESPACE, false)?;- self.family()?.get_chunk(chunk_id).await- }-- async fn chunk_detail(&self, chunk_id: &str) -> Result<Option<ChunkDetail>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.chunk_detail",- NO_NAMESPACE,- false,- )?;- self.family()?.chunk_detail(chunk_id).await- }-- /// The catalog is not user content, so it takes no namespace and the- /// lightest read check — refusing it under `readonly` would stop an- /// operator finding out what the store can even hold.- async fn storage_kinds(&self) -> Result<Vec<String>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.storage_kinds",- NO_NAMESPACE,- false,- )?;- self.family()?.storage_kinds().await- }-- /// Vectors, not content — but still a read of stored material, so it takes- /// the same tier check rather than being waved through as metadata.- async fn chunk_embeddings(- &self,- chunk_ids: &[String],- model_signature: &str,- ) -> Result<Vec<ChunkEmbedding>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.chunk_embeddings",- NO_NAMESPACE,- false,- )?;- self.family()?- .chunk_embeddings(chunk_ids, model_signature)- .await- }-- /// One chunk's admission verdict, read by chunk id exactly as- /// [`Self::chunk_detail`] is — so it takes that member's check, not- /// [`Self::list_chunks`]'s scope intersection. There is no scope to narrow:- /// the caller already holds the id.- async fn chunk_score(&self, chunk_id: &str) -> Result<Option<ChunkScore>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.chunk_score",- NO_NAMESPACE,- false,- )?;- self.family()?.chunk_score(chunk_id).await- }-- /// Ingest progress for the sources the caller names, one row per query.- ///- /// Unlike [`Self::source_totals`], which enumerates the groups that exist- /// and therefore has to be narrowed to the ambient allowlist, this answers- /// only about prefixes the caller supplied — it discloses no source the- /// caller did not already name — and the contract member carries no- /// [`SourceScope`] for the guard to intersect anything into.- async fn source_ingest_status(- &self,- source_prefixes: &[SourceIngestQuery],- ) -> Result<Vec<SourceIngestStatus>, MemoryError> {- self.policy.admit_read(- Capability::Chunks,- "chunks.source_ingest_status",- NO_NAMESPACE,- false,- )?;- self.family()?.source_ingest_status(source_prefixes).await- }-}diff --git a/src/openhuman/memory/guard/families_part_03.rs b/src/openhuman/memory/guard/families_part_03.rsindex 00bdca2533..b3dee6411d 100644--- a/src/openhuman/memory/guard/families_part_03.rs+++ b/src/openhuman/memory/guard/families_part_03.rs@@ -1,3 +1,4 @@+// ── Chunks ───────────────────────────────────────────────────────────────────// ── Retrieval ────────────────────────────────────────────────────────────────diff --git a/src/openhuman/memory/guard/families_part_04.rs b/src/openhuman/memory/guard/families_part_04.rsindex 3426897526..0e441b008d 100644--- a/src/openhuman/memory/guard/families_part_04.rs+++ b/src/openhuman/memory/guard/families_part_04.rs@@ -152,3 +152,167 @@ impl MemoryAnswer for GuardedAnswer {self.family()?.answer(request).await}}++#[async_trait]+impl MemoryChunks for GuardedChunks {+ async fn list_chunks(+ &self,+ query: &ChunkQuery,+ scope: Option<&SourceScope>,+ ) -> Result<Vec<Chunk>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.list_chunks",+ NO_NAMESPACE,+ false,+ )?;+ // Intersected with the ambient allowlist, never passed through. The+ // ambient scope is an upper bound: forwarding the caller's scope+ // unchanged would let a source-restricted turn widen itself back out by+ // naming a collection the restriction excluded. See+ // `GuardPolicy::narrow_scope`.+ let effective = self.policy.narrow_scope(scope);+ self.family()?.list_chunks(query, effective.as_ref()).await+ }++ /// The count that labels a [`Self::list_chunks`] page, and it must be+ /// narrowed by exactly the same rule. A total computed against a wider+ /// scope than the page it labels leaks the existence of rows the caller may+ /// not read — "showing 20 of 4000" tells a source-restricted turn how much+ /// it is not being shown.+ async fn count_chunks(+ &self,+ query: &ChunkQuery,+ scope: Option<&SourceScope>,+ ) -> Result<u64, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.count_chunks",+ NO_NAMESPACE,+ false,+ )?;+ let effective = self.policy.narrow_scope(scope);+ self.family()?.count_chunks(query, effective.as_ref()).await+ }++ /// Same rows as [`Self::list_chunks`] with the stored facts beside them, so+ /// the same intersection applies for the same reason.+ async fn list_chunk_details(+ &self,+ query: &ChunkQuery,+ scope: Option<&SourceScope>,+ ) -> Result<Vec<ChunkListRow>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.list_chunk_details",+ NO_NAMESPACE,+ false,+ )?;+ let effective = self.policy.narrow_scope(scope);+ self.family()?+ .list_chunk_details(query, effective.as_ref())+ .await+ }++ /// Per-source totals are computed from the chunks the scope admits, not+ /// filtered afterwards — so a restricted caller must not learn that a+ /// forbidden source exists by seeing its row, nor see a permitted source+ /// carrying a count that includes rows it cannot read.+ async fn source_totals(+ &self,+ limit: usize,+ scope: Option<&SourceScope>,+ ) -> Result<Vec<SourceTotal>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.source_totals",+ NO_NAMESPACE,+ false,+ )?;+ let effective = self.policy.narrow_scope(scope);+ self.family()?+ .source_totals(limit, effective.as_ref())+ .await+ }++ async fn get_chunk(&self, chunk_id: &str) -> Result<Option<Chunk>, MemoryError> {+ self.policy+ .admit_read(Capability::Chunks, "chunks.get_chunk", NO_NAMESPACE, false)?;+ self.family()?.get_chunk(chunk_id).await+ }++ async fn chunk_detail(&self, chunk_id: &str) -> Result<Option<ChunkDetail>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.chunk_detail",+ NO_NAMESPACE,+ false,+ )?;+ self.family()?.chunk_detail(chunk_id).await+ }++ /// The catalog is not user content, so it takes no namespace and the+ /// lightest read check — refusing it under `readonly` would stop an+ /// operator finding out what the store can even hold.+ async fn storage_kinds(&self) -> Result<Vec<String>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.storage_kinds",+ NO_NAMESPACE,+ false,+ )?;+ self.family()?.storage_kinds().await+ }++ /// Vectors, not content — but still a read of stored material, so it takes+ /// the same tier check rather than being waved through as metadata.+ async fn chunk_embeddings(+ &self,+ chunk_ids: &[String],+ model_signature: &str,+ ) -> Result<Vec<ChunkEmbedding>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.chunk_embeddings",+ NO_NAMESPACE,+ false,+ )?;+ self.family()?+ .chunk_embeddings(chunk_ids, model_signature)+ .await+ }++ /// One chunk's admission verdict, read by chunk id exactly as+ /// [`Self::chunk_detail`] is — so it takes that member's check, not+ /// [`Self::list_chunks`]'s scope intersection. There is no scope to narrow:+ /// the caller already holds the id.+ async fn chunk_score(&self, chunk_id: &str) -> Result<Option<ChunkScore>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.chunk_score",+ NO_NAMESPACE,+ false,+ )?;+ self.family()?.chunk_score(chunk_id).await+ }++ /// Ingest progress for the sources the caller names, one row per query.+ ///+ /// Unlike [`Self::source_totals`], which enumerates the groups that exist+ /// and therefore has to be narrowed to the ambient allowlist, this answers+ /// only about prefixes the caller supplied — it discloses no source the+ /// caller did not already name — and the contract member carries no+ /// [`SourceScope`] for the guard to intersect anything into.+ async fn source_ingest_status(+ &self,+ source_prefixes: &[SourceIngestQuery],+ ) -> Result<Vec<SourceIngestStatus>, MemoryError> {+ self.policy.admit_read(+ Capability::Chunks,+ "chunks.source_ingest_status",+ NO_NAMESPACE,+ false,+ )?;+ self.family()?.source_ingest_status(source_prefixes).await+ }+}diff --git a/src/openhuman/memory/read_rpc/types.rs b/src/openhuman/memory/read_rpc/types.rsindex 8abdef4453..30ffe18538 100644--- a/src/openhuman/memory/read_rpc/types.rs+++ b/src/openhuman/memory/read_rpc/types.rs@@ -163,7 +163,12 @@ pub struct FlushNowResponse {/// nothing to look at (`scanned == 0`).#[derive(Clone, Debug, Serialize, Deserialize)]pub struct BackfillConnectorTreesResponse {- /// Whether this actually wrote. `false` is the dry-run preview.+ /// Which mode ran: `false` is the dry-run preview, `true` a real pass.+ ///+ /// Deliberately the mode and not "did anything change" — `ingested` already+ /// answers that, and folding the two would make a real pass that found+ /// nothing left to do indistinguishable from a preview, which is the one+ /// distinction this field exists for (review finding).pub executed: bool,/// Documents examined.pub scanned: u64,diff --git a/src/openhuman/memory/schema/schema_schema_part_01.rs b/src/openhuman/memory/schema/schema_schema_part_01.rsindex c6840d3ee1..e140fa0b33 100644--- a/src/openhuman/memory/schema/schema_schema_part_01.rs+++ b/src/openhuman/memory/schema/schema_schema_part_01.rs@@ -514,7 +514,9 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {FieldSchema {name: "executed",ty: TypeSchema::Bool,- comment: "False for a dry-run preview.",+ comment: "Which mode ran: false is the dry-run preview, true a \+ real pass. The mode, not \"did anything change\" — \+ `ingested` answers that.",required: true,},FieldSchema {