Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: pre-landing review fixes
garrytan3b81f1a4d6d9
diff --git a/AGENTS.md b/AGENTS.mdindex 35b5c32a26..1c6c22db79 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -67,7 +67,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.mdindex c1804911d3..fd2f16ede5 100644--- a/INSTALL_FOR_AGENTS.md+++ b/INSTALL_FOR_AGENTS.md@@ -383,7 +383,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/llms-full.txt b/llms-full.txtindex 468bed6c1c..61447602d6 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -1839,7 +1839,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |@@ -3074,7 +3074,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |@@ -4928,7 +4928,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/plugin-variants/gbrain-coding/skills/conventions/brain-first.md b/plugin-variants/gbrain-coding/skills/conventions/brain-first.mdindex f5bee7dd98..62e7593977 100644--- a/plugin-variants/gbrain-coding/skills/conventions/brain-first.md+++ b/plugin-variants/gbrain-coding/skills/conventions/brain-first.md@@ -16,7 +16,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/plugin-variants/gbrain-daily/skills/conventions/brain-first.md b/plugin-variants/gbrain-daily/skills/conventions/brain-first.mdindex f5bee7dd98..62e7593977 100644--- a/plugin-variants/gbrain-daily/skills/conventions/brain-first.md+++ b/plugin-variants/gbrain-daily/skills/conventions/brain-first.md@@ -16,7 +16,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/plugin/skills/conventions/brain-first.md b/plugin/skills/conventions/brain-first.mdindex f5bee7dd98..62e7593977 100644--- a/plugin/skills/conventions/brain-first.md+++ b/plugin/skills/conventions/brain-first.md@@ -16,7 +16,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/skills/RESOLVER.md b/skills/RESOLVER.mdindex 44165cb21c..ec8127c6d1 100644--- a/skills/RESOLVER.md+++ b/skills/RESOLVER.md@@ -24,7 +24,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/skills/conventions/brain-first.md b/skills/conventions/brain-first.mdindex f5bee7dd98..62e7593977 100644--- a/skills/conventions/brain-first.md+++ b/skills/conventions/brain-first.md@@ -16,7 +16,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/skills/skills.lock.json b/skills/skills.lock.jsonindex 0034f5fe6b..4e0caa8f17 100644--- a/skills/skills.lock.json+++ b/skills/skills.lock.json@@ -1,5 +1,5 @@{- "RESOLVER.md": "c0d4ab42e161f3618b98957fd8c12df94cb8dcf1a9e9159cab72398dd473fbaf",+ "RESOLVER.md": "587768c702e0badf5e7d6201cd5902b7313b218e5663ab527e3a8365f5c438ee","_AGENT_README.md": "ab51e36e9a0b53f4d0609294b0556444399147834932d9c1acfdc7aa367c70b8","_brain-filing-rules.json": "4e6ecee2d94867d146583d60bf98dccdd9205bb70793af56fe1397a2b258ae0d","_brain-filing-rules.md": "ff42b331bce542d708f97ff0a73ff0fb5664b46ee9b1862a5478b15dc637487e",@@ -45,7 +45,7 @@"context-audit/SKILL.md": "6d786629d40544ddaab4f4e6e333569d270bcb8b581589dc16fb9f8bcb4f6207","context-audit/routing-eval.jsonl": "fb1832e24cc1b04163a74c5cde72bca53050a66246ca902e1a5f40303f52b5ab","conventions/agent-operator-protocol.md": "1dc2a6a71469b1802cb2e9802c609a61a066a78afae9499e92ed0490221022a4",- "conventions/brain-first.md": "29441dcb16d81d697d4136a09d74cc19b4cf76f5cd274c1e2cc90c3a74e0b4e6",+ "conventions/brain-first.md": "f11d719348f28998bebc5033c25734a064d2d491f6fdc7182628c2bebbee5f55","conventions/brain-routing.md": "f11c3e7c4f98163aa6c68aa7d8f09a7acb7b6a8695f42eb7d92d4ee5787d428a","conventions/calibration.md": "500dc26bd7c8400f50dc4c16fd83f1a588f3e7e68c59050a21fd8a0f69e4d198","conventions/cron-via-minions.md": "badb1cd6cd825d6f1ac0b6b28cc47e5d80facc783a3e59a14146ae901ee0f933",diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 186f0857b3..23a57f48c7 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1427,8 +1427,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.570.0', id: 'get_page_selector_precedence_gbra280', text: 'get_page given several window selectors now reads one window instead of refusing with invalid_params: cursor, then around_chunk_id, then lines, then bytes, and a cursor that cannot read the page or an around_chunk_id no longer on it gives way to the next. body full, include_content and content_only beside a selector are set aside, so the read stays a window and never returns the whole page. The response\'s window_selector names what applied and what was ignored; a call with one selector is unchanged.' },{ since: '0.60.574.0', id: 'embedded_scope_required_gbra283', text: 'Experimental embedded engines (`openEngine` with `embedded_core: true`) only; the CLI, `gbrain serve` and mounts are unchanged. While such an engine is open, an embed, chat, expansion or rerank call that entered no scope now refuses `engine_scope_required` (new code) even when the host configured a process gateway with `configureGateway`; before, that configuration let unscoped calls use the process keys, and the refusal was `engine_scope_missing`, which now only means a provider the engine lacks or a closed engine. Wrap such calls in `withEngineScope(engine, fn)`, or `withLocalScope(fn)` for calls that belong to the process gateway (both from `gbrain/engine-open`); `hybridSearch`, the import paths, minion jobs and `POST /mcp` enter their engine\'s scope themselves. `openEngine` also refuses an unknown settings key, top-level or nested, with `engine_settings_invalid` naming the key, where it used to ignore it. An embedded engine\'s chat usage is no longer on the process usage stack and survives `reconnect()`. See docs/ENGINES.md "Upgrading an embedded host".' },// GBRA-156 (#7491, #7492). `since` is stamped at the merge slot.- { since: '0.60.440.0', id: 'keyword_identifier_probe', text: 'A search or query naming an identifier (`#412`, a 6+ digit run, a code like INV-2026-00417, an email or a URL) together with other words now runs one more keyword statement: the arm\'s own statement, with the same scope, visibility and filters, matching every identifier the query names. Those rows vote like strict keyword rows, so the page holding the identifier is no longer dropped when filler words ("What did the latest weekly digest (#412) say?") keep it from matching every word, and a title holding every identifier leads the title arm\'s any-word retry. The keyword arm\'s any-word retry ranks rare words first for questions of up to 12 words (it was 4). Queries without an identifier keep their keyword rows. `_meta.retrieval.coverage` counts a pending page only when a query word is a whole token of its title or slug (`412` no longer matches `t004120`), counts pending image pages only when an image arm ran, and adds `could_affect.pending_images`; the `projection_pending` notice says text pages are being indexed and that image pages wait for `gbrain projections drain` or a paid re-import, with doctor\'s `text_projection_readiness` as the fix.' },- { since: '0.60.440.0', id: 'keyword_slug_handles', text: 'Keyword search resolves slug handles: a hyphenated token with a letter in it (`dan-example`), bare or quoted on its own, now also matches the pages whose slug ends in exactly that handle (`people/dan-example`), under the same scope, filters and visibility as any keyword match. Those pages lead `match: "keyword"` results and its count, and lead the hybrid keyword arm as rows that vote like strict rows, so `"dan-example" OR "erin-example"` with `--types \'["person"]\'` returns the two person pages instead of nothing. Queries without such a token run as before.' },+ { since: 'TBD', id: 'keyword_identifier_probe', text: 'A search or query naming an identifier (`#412`, a 6+ digit run, a code like INV-2026-00417, an email or a URL) together with other words now runs one more keyword statement: the arm\'s own statement, with the same scope, visibility and filters, matching every identifier the query names. Those rows vote like strict keyword rows, so the page holding the identifier is no longer dropped when filler words ("What did the latest weekly digest (#412) say?") keep it from matching every word, and a title holding every identifier leads the title arm\'s any-word retry. The keyword arm\'s any-word retry ranks rare words first for questions of up to 12 words (it was 4). Queries without an identifier keep their keyword rows. `_meta.retrieval.coverage` counts a pending page only when a query word is a whole token of its title or slug (`412` no longer matches `t004120`), counts pending image pages only when an image arm ran, and adds `could_affect.pending_images`; the `projection_pending` notice says text pages are being indexed and that image pages wait for `gbrain projections drain` or a paid re-import, with doctor\'s `text_projection_readiness` as the fix.' },+ { since: 'TBD', id: 'keyword_slug_handles', text: 'Keyword search resolves slug handles: a hyphenated token with a letter in it (`dan-example`), bare or quoted on its own, now also matches the pages whose slug ends in exactly that handle (`people/dan-example`), under the same scope, filters and visibility as any keyword match. Those pages lead `match: "keyword"` results and its count, and lead the hybrid keyword arm as rows that vote like strict rows, so `"dan-example" OR "erin-example"` with `--types \'["person"]\'` returns the two person pages instead of nothing. Queries without such a token run as before.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/ops/find-pages.ts b/src/core/ops/find-pages.tsindex 9d05ed53f7..e58ae6bc80 100644--- a/src/core/ops/find-pages.ts+++ b/src/core/ops/find-pages.ts@@ -7,7 +7,7 @@* Scope follows `list_pages`: `federatedSearchScope` (an explicit `source_id`,* `'__all__'` included, is checked against the grant and must name a live* source). Every caller sees live pages in unarchived sources; a remote- * caller's `readPolicyOpts` policy goes through `pageReadFilter` (private+ * caller's (or a local `--as <member>` preview's) `readPolicyOpts` policy goes through `pageReadFilter` (private* pages, trust floor, quarantine). Like ranked search, find hides the* `resolveHardExcludes` prefixes unless the pattern targets one; the result* names the prefixes it hid.@@ -73,7 +73,7 @@ const find_pages: Operation = {const requested = typeof p.limit === 'number' ? p.limit : undefined;const cap = ctx.remote === false ? FIND_PAGES_LOCAL_MAX_LIMIT : FIND_PAGES_REMOTE_MAX_LIMIT;const limit = clampSearchLimit(requested, FIND_PAGES_DEFAULT_LIMIT, cap);- const policy = ctx.remote === false ? undefined : await readPolicyOpts(ctx, scope);+ const policy = ctx.remote === false && !ctx.applyRemoteReadPolicy ? undefined : await readPolicyOpts(ctx, scope);const hiddenPrefixes = hiddenPrefixesFor(pattern, resolveHardExcludes());const found = await ctx.engine.findPages({pattern,diff --git a/src/core/ops/stats-by.ts b/src/core/ops/stats-by.tsindex a293e5b722..4469f1b68d 100644--- a/src/core/ops/stats-by.ts+++ b/src/core/ops/stats-by.ts@@ -7,7 +7,7 @@** Scope is the diagnostic ladder `get_stats` already uses (trusted local:* every source; remote: the caller's grant). Counts cover live pages in- * unarchived sources; a remote caller's `readPolicyOpts` policy goes through+ * unarchived sources; a remote caller's (or a local `--as <member>` preview's) `readPolicyOpts` policy goes through* `pageReadFilter` (private pages, trust floor, quarantine), like other* remote reads. Stats do not hide the search hard-exclude prefixes: they* count what is stored.@@ -54,7 +54,7 @@ export async function statsBy(const groupTypes = by.includes('type') && !by.includes('source')? (types: string[]) => { const collapse = collapseFor(types); return types.map((type) => collapse?.get(type)?.group ?? type); }: undefined;- const policy = ctx.remote === false ? undefined : await readPolicyOpts(ctx, scope);+ const policy = ctx.remote === false && !ctx.applyRemoteReadPolicy ? undefined : await readPolicyOpts(ctx, scope);const counts = await ctx.engine.countPagesBy({...scope,since,diff --git a/templates/bootstrap/AGENTS.md.template b/templates/bootstrap/AGENTS.md.templateindex e9bb3347d5..12bf3b2c02 100644--- a/templates/bootstrap/AGENTS.md.template+++ b/templates/bootstrap/AGENTS.md.template@@ -95,7 +95,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/templates/bootstrap/template-repo/AGENTS.md b/templates/bootstrap/template-repo/AGENTS.mdindex c044a96016..4d73f68abe 100644--- a/templates/bootstrap/template-repo/AGENTS.md+++ b/templates/bootstrap/template-repo/AGENTS.md@@ -99,7 +99,7 @@ instead of the CLI (one connection, no per-call startup).| Lookup | CLI | MCP tool ||---|---|---|| Find a page by name or path | `gbrain find <name\|prefix\|glob> [--type T] [--source S]` | `find_pages` |-| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` |+| Count pages by kind or source | `gbrain stats --by source,type [--since 30d] [--collapse-aliases]` | `get_stats` (needs an admin-scope token) || Answer a question, search a topic | `gbrain query "<question>" [--types '["meeting"]'] [--since 30d]` | `query` || Pages with these words | `gbrain search "<words>" [--match keyword] [--source S]` | `search` || Read a known page | `gbrain get <slug>` | `get_page` |diff --git a/test/access-as.serial.test.ts b/test/access-as.serial.test.tsindex fccbc1237d..cd0a2faaa1 100644--- a/test/access-as.serial.test.ts+++ b/test/access-as.serial.test.ts@@ -84,6 +84,24 @@ describe('local --as <member> (repo-less PGLite)', () => {expect(listBob.stdout).not.toContain(ALICE.slug);}, 180_000);+ test('find and grouped stats under --as count only the pages the member reads', async () => {+ const findPlain = await cli(['find', 'notes/*', '--json']);+ expect(findPlain.exitCode).toBe(0);+ expect(findPlain.stdout).toContain(ALICE.slug);+ const findBob = await cli(['find', 'notes/*', '--as', 'bob-example', '--json']);+ expect(findBob.exitCode).toBe(0);+ expect(findBob.stdout).toContain('notes/open-plan');+ expect(findBob.stdout).not.toContain(ALICE.slug);+ const findAlice = await cli(['find', 'notes/*', '--as', 'alice-example', '--json']);+ expect(findAlice.stdout).toContain(ALICE.slug);+ const statsPlain = await cli(['stats', '--by', 'type', '--json']);+ expect(statsPlain.exitCode).toBe(0);+ const statsBob = await cli(['stats', '--by', 'type', '--as', 'bob-example', '--json']);+ expect(statsBob.exitCode).toBe(0);+ expect(JSON.parse(statsPlain.stdout).total_pages).toBe(2);+ expect(JSON.parse(statsBob.stdout).total_pages).toBe(1);+ }, 180_000);+test('an unknown, disabled or ill-formed --as is refused before any work', async () => {for (const [who, reason] of [['nobody-example', 'unknown'], ['carol-example', 'disabled'], ['Not_Valid!', 'ill_formed']] as const) {const r = await cli(['get', 'notes/open-plan', '--as', who, '--json']);