Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(mcp): keep the source selectors off the starter tool list (#6723)
garrytanb8ec215a3df0
diff --git a/docs/protocol/MEMORY_VERBS_v1.md b/docs/protocol/MEMORY_VERBS_v1.mdindex 650d6701f7..b14e27f480 100644--- a/docs/protocol/MEMORY_VERBS_v1.md+++ b/docs/protocol/MEMORY_VERBS_v1.md@@ -554,6 +554,9 @@ errors: `scope_denied`, `not_found`, `invalid_params`. `prefer_source_id`reorders the walk without narrowing it (thin clients send their.gbrain-source there). When the ambient binding's source has no match, a`source_binding_narrowed` notice names where each name resolved.+The starter MCP tool list does not advertise `source_id`, `prefer_source_id`+or `context_pack`'s `entity_refs` (it keeps the list inside its size budget);+the full surface does, and every surface accepts them.Every card carries `card.entity.source_id`, every `names` row `source_id`,and each suggestion its `source_id`: `(source_id, slug)` is the entity'sdiff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.tsindex 8d4859a726..3df06d63ee 100644--- a/src/core/operation-manifest.generated.ts+++ b/src/core/operation-manifest.generated.ts@@ -133,7 +133,8 @@ export const OPERATION_MANIFEST: OperationMeta[] = [},"source_id": {"type": "string",- "description": "Read only this source. Default: your source first, then every source you can read."+ "description": "Read only this source. Default: your source first, then every source you can read.",+ "fullSurfaceOnly": true},"prefer_source_id": {"type": "string",@@ -5189,7 +5190,8 @@ export const OPERATION_MANIFEST: OperationMeta[] = [},"source_id": {"type": "string",- "description": "Resolve entities in this source only. Default: your source first, then every source you can read."+ "description": "Resolve entities in this source only. Default: your source first, then every source you can read.",+ "fullSurfaceOnly": true},"entity_refs": {"type": "array",@@ -5204,7 +5206,8 @@ export const OPERATION_MANIFEST: OperationMeta[] = [}}},- "description": "Source-qualified entities: [{\"source_id\":\"wiki\",\"slug\":\"people/alice-example\"}]."+ "description": "Source-qualified entities: [{\"source_id\":\"wiki\",\"slug\":\"people/alice-example\"}].",+ "fullSurfaceOnly": true},"prefer_source_id": {"type": "string",diff --git a/src/core/ops/facts.ts b/src/core/ops/facts.tsindex efef652762..5bf936fc2a 100644--- a/src/core/ops/facts.ts+++ b/src/core/ops/facts.ts@@ -704,9 +704,9 @@ const context_pack: Operation = {include_quarantined: { type: 'boolean', description: 'Admin or memory_confirm: quarantined cards.', fullSurfaceOnly: true },counterparty: { type: 'string', description: 'Person or company (name or slug): adds a pulled brief of dated items about them.', fullSurfaceOnly: true },intent: { type: 'string', enum: [...BRIEF_INTENTS], description: 'With counterparty: the task the brief is for.', fullSurfaceOnly: true },- source_id: { type: 'string', description: 'Resolve entities in this source only. Default: your source first, then every source you can read.' },+ source_id: { type: 'string', description: 'Resolve entities in this source only. Default: your source first, then every source you can read.', fullSurfaceOnly: true },entity_refs: { type: 'array', items: { type: 'object', properties: { source_id: { type: 'string' }, slug: { type: 'string' } } },- description: 'Source-qualified entities: [{"source_id":"wiki","slug":"people/alice-example"}].' },+ description: 'Source-qualified entities: [{"source_id":"wiki","slug":"people/alice-example"}].', fullSurfaceOnly: true },prefer_source_id: { type: 'string', description: 'Source to try first (thin clients send .gbrain-source here); never narrows.', fullSurfaceOnly: true },},scope: 'read',diff --git a/src/core/verbs.ts b/src/core/verbs.tsindex f4d509bdb1..6d8ec6af1c 100644--- a/src/core/verbs.ts+++ b/src/core/verbs.ts@@ -221,7 +221,7 @@ const entity: Operation = {params: {name: { type: 'string', description: 'Name, alias or slug.' },names: { type: 'array', items: { type: 'string' }, description: 'Or up to 50 names/codes at once: compact rows.' },- source_id: { type: 'string', description: 'Read only this source. Default: your source first, then every source you can read.' },+ source_id: { type: 'string', description: 'Read only this source. Default: your source first, then every source you can read.', fullSurfaceOnly: true },prefer_source_id: { type: 'string', description: 'Source to try first (thin clients send .gbrain-source here); never narrows.', fullSurfaceOnly: true },},scope: 'read',diff --git a/test/entity-source-federation.test.ts b/test/entity-source-federation.test.tsindex 39389a3653..05ba24251f 100644--- a/test/entity-source-federation.test.ts+++ b/test/entity-source-federation.test.ts@@ -71,6 +71,10 @@ beforeAll(async () => {sourceId: 'wiki', dedupKey: 'commit:zoe0001', loopType: 'commitment_owed_by_me', counterpartySlug: 'people/zoe-example',summary: 'LOOP-SENTINEL send Zoe the draft', evidence: [{ message_id: 'm-1', quote: 'quote' }], detector: 'llm_extract',});+ for (const sourceId of ['default', 'wiki']) await upsertOpenLoop(engine, {+ sourceId, dedupKey: `commit:sam-${sourceId}`, loopType: 'commitment_owed_by_me', counterpartySlug: 'people/sam-example',+ summary: `SAM-LOOP-SENTINEL ${sourceId} send Sam the deck`, evidence: [{ message_id: `m-${sourceId}`, quote: 'quote' }], detector: 'llm_extract',+ });}, 120_000);afterAll(async () => { await engine.disconnect(); });@@ -116,6 +120,13 @@ describe('#6723 federated entity resolution', () => {['default', 'people/sam-example', expect.stringContaining('default-source Sam')],['wiki', 'people/sam-example', expect.stringContaining('wiki-source Sam')],]);+ expect(pack.cards.flatMap((c: any) => c.open_threads).some((t: any) => t.loop_id !== undefined)).toBe(false);+ expect(JSON.stringify(pack)).not.toContain('SAM-LOOP-SENTINEL');+ const local = await call('context_pack', ctx({ remote: false, grant: ['default', 'wiki'] }), { include_private: true,+ entity_refs: [{ source_id: 'default', slug: 'people/sam-example' }, { source_id: 'wiki', slug: 'people/sam-example' }] });+ expect(local.cards.map((c: any) => c.open_threads.filter((t: any) => /SAM-LOOP-SENTINEL/.test(t.text)).map((t: any) => t.text))).toEqual([+ [expect.stringContaining('SAM-LOOP-SENTINEL default')], [expect.stringContaining('SAM-LOOP-SENTINEL wiki')],+ ]);});test('a source outside the grant is never read: unpinned it is a miss, pinned it is scope_denied', async () => {