Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(grants): say source_ids narrows only the call that sends it
garrytan128fe293a8e4
diff --git a/docs/mcp/ADMIN.md b/docs/mcp/ADMIN.mdindex b7b121b533..d662fbe1dc 100644--- a/docs/mcp/ADMIN.md+++ b/docs/mcp/ADMIN.md@@ -423,8 +423,9 @@ Fix it with today's commands:- When the chat sits in one source, a source grant cannot separate it: markthe pages nobody else may see `visibility: private` (hidden from everyremote caller while `search.remote_private_pages` stays off).-- Narrow single calls with `source_ids` on search and query (MCP) or- `--source` on the CLI.+- Don't rely on `source_ids`: it narrows only the call that sends it, so+ recall, list_pages or any read without it reads the token's full grant.+ The fix is a member-bound or rescoped token (`gbrain auth rescope …`).Per-member keys (`gbrain access member add <id>`, then`gbrain auth create <name> --member <id>`) arrive with gbrain#7812.diff --git a/src/core/grants/shared-exposure.ts b/src/core/grants/shared-exposure.tsindex e875c689c3..5ae6b06fb9 100644--- a/src/core/grants/shared-exposure.ts+++ b/src/core/grants/shared-exposure.ts@@ -177,8 +177,7 @@ export function remedyText(s: ExposureSubject, census?: ChatCensus | null): stristeps.push(`the chat sits in one source (${census!.chat_sources[0]}), so a source grant cannot separate it`);}steps.push('mark pages nobody else may see visibility: private (hidden from every remote caller while search.remote_private_pages stays off)');- steps.push('narrow single calls with source_ids on search and query (MCP) or --source (CLI)');- return `Fix: ${steps.join('; ')}. Per-member keys (gbrain access member add <id>, then gbrain auth create <name> --member <id>) arrive with gbrain#7812 and are not in this version.`;+ return `Fix: ${steps.join('; ')}. source_ids narrows only the call that sends it, so recall, list_pages or any read without it reads the token's full grant; the fix is ${splitBySource(census) ? 'a member-bound or rescoped token (gbrain auth rescope …)' : 'a member-bound token'}, not per-call narrowing. Per-member keys (gbrain access member add <id>, then gbrain auth create <name> --member <id>) arrive with gbrain#7812 and are not in this version.`;}export function exposureFix(s: ExposureSubject, census?: ChatCensus | null): Action {diff --git a/test/shared-exposure.test.ts b/test/shared-exposure.test.tsindex 3ee49fb0d2..5bd2470364 100644--- a/test/shared-exposure.test.ts+++ b/test/shared-exposure.test.ts@@ -142,10 +142,13 @@ describe('signals and the warning', () => {const one = sharedTokenNotice({ kind: 'oauth_client', id: 'c1' }, { census: within })!;expect(one.why).toContain('the chat sits in one source (default), so a source grant cannot separate it');expect(one.why).not.toContain('auth rescope');+ expect(one.why).toContain('the fix is a member-bound token, not per-call narrowing');+ expect(split.why).toContain('the fix is a member-bound or rescoped token (gbrain auth rescope …), not per-call narrowing');expect(one.fix!.argv).toBeUndefined();for (const n of [split, one]) {expect(n.why).toContain('visibility: private');- expect(n.why).toContain('source_ids on search and query (MCP) or --source (CLI)');+ expect(n.why).toContain('source_ids narrows only the call that sends it, so recall, list_pages or any read without it reads the token\'s full grant');+ expect(n.why).not.toContain('narrow single calls');expect(n.why).toContain('gbrain auth create <name> --member <id>) arrive with gbrain#7812');expect(n.user_message).toBe(n.fix!.user_message);}