Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(recall): the facts arms widen across the transport-computed federated set like the page-search arm (#5231 follow-up)

garrytan07b1ba9aa5ff
diff --git a/src/core/ops/facts.ts b/src/core/ops/facts.ts
index 5ad05bd2a4..e22a32a605 100644
--- a/src/core/ops/facts.ts
+++ b/src/core/ops/facts.ts
@@ -231,7 +231,7 @@ const recall: Operation = {
// Federated grants (cathedral-6): the fact arms honor the SAME scope
// ladder as every other read-side op — federated array > scalar >
- // default — via sourceScopeOpts, never a hand-rolled filter. The engine
+ // default — via federatedSearchScope, never a hand-rolled filter. The engine
// fact APIs are scalar-source, so a federated grant fans out per granted
// source and merges newest-first; a single-source caller takes exactly
// the pre-v1 single-query path. A trusted-local `__all__` ({}) has no
@@ -240,7 +240,9 @@ const recall: Operation = {
let scope: ReturnType<typeof sourceScopeOpts>;
try {
sourceIdParam = parseSourceIdParam(p.source_id, 'recall');
- scope = sourceIdParam === undefined ? sourceScopeOpts(ctx) : federatedSearchScope(ctx, sourceIdParam);
+ // The facts arms widen an unqualified no-grant caller across the transport-computed
+ // federated set, exactly like the page-search arm below and every sibling read op.
+ scope = federatedSearchScope(ctx, sourceIdParam);
await assertExplicitSourceLive(ctx, sourceIdParam);
} catch (error) {
if (!(error instanceof OperationError) || p.source_id === undefined || p.source_id === null) throw error;
diff --git a/test/recall-federated-search-scope.test.ts b/test/recall-federated-search-scope.test.ts
index aac7312f5a..bfcb654d03 100644
--- a/test/recall-federated-search-scope.test.ts
+++ b/test/recall-federated-search-scope.test.ts
@@ -133,3 +133,24 @@ describe("recall's page-search arm honors the federated set (#3242 parity)", ()
expect(slugs).toEqual(['notes/home']);
});
});
+
+describe("recall's fact arms honor the federated set too", () => {
+ const factTexts = (res: any): string[] => (res?.facts ?? []).map((f: any) => f.fact);
+ beforeAll(async () => {
+ for (const [fact, source_id] of [['zebra fact in default', 'default'], ['zebra fact in wiki', 'wiki'], ['zebra fact in privsrc', 'privsrc']]) {
+ await engine.insertFact({ fact, kind: 'fact', entity_slug: `zebra-${source_id}`, source: 'test', visibility: 'world' }, { source_id });
+ }
+ });
+
+ test('a no-grant remote caller recalls facts from a federated peer source, never a non-federated one', async () => {
+ const facts = factTexts(await recall().handler(remoteNoGrant(), { since: '1 day ago' }));
+ expect(facts).toContain('zebra fact in default');
+ expect(facts).toContain('zebra fact in wiki');
+ expect(facts).not.toContain('zebra fact in privsrc');
+ });
+
+ test('without a transport-computed set the fact arms stay on the scalar source', async () => {
+ const facts = factTexts(await recall().handler(ctxOf({ remote: true, sourceId: 'default' }), { since: '1 day ago' }));
+ expect(facts).toEqual(['zebra fact in default']);
+ });
+});