Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(openclaw): the native startup lane drains gateway stdout with one pump instead of racing reader.read() against a timer
garrytane2e212200b1b
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex 7708e0512f..8791130e0c 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.","author": {"name": "Garry Tan",diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 9e11040df8..aa3912aa9b 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.","author": {"name": "Garry Tan",diff --git a/BOOTSTRAP_FOR_AGENTS.md b/BOOTSTRAP_FOR_AGENTS.mdindex fde69d5981..a6222d2bcb 100644--- a/BOOTSTRAP_FOR_AGENTS.md+++ b/BOOTSTRAP_FOR_AGENTS.md@@ -1,4 +1,4 @@-<!-- gbrain-runbook-stamp: 0.60.168.0 -->+<!-- gbrain-runbook-stamp: 0.60.169.0 --><!-- This stamp must equal the VERSION file at every release; CI enforces it(scripts/check-bootstrap-tag.sh). `gbrain bootstrap status` compares it tothe installed binary and warns on skew. -->diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5ab6f1235d..d56a6dd6b3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,15 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.169.0] - 2026-10-11++**Fixes the OpenClaw native startup lane that failed master three times; no product change.**++### Itemized changes++- `test/openclaw-context-engine-native.serial.test.ts` lost gateway output: it raced `reader.read()` against a one-second timer, and a read the timer beat stayed queued on the reader, so the next chunk the gateway wrote (after a quiet second of plugin loading, `[gateway] ready` itself) resolved that abandoned read and was dropped. The test now drains stdout and stderr with one pump per stream from spawn (`test/helpers/stream-text.ts`) and polls the collected text; `test/stream-text.test.ts` pins both the pump and the losing pattern with a child that is silent for 1.5 s before its ready line. The startup window is unchanged at 60 s.+- The same test's gateway config sets `update.checkOnStart: false` and `models.catalogRefresh.enabled: false`, so the pinned gateway makes no request to `telemetry.openclaw.ai` or `catalog.openclaw.ai` at startup (verified under `strace`: no outbound connect); the test asserts neither notice appears.+## [0.60.168.0] - 2026-10-11**Fix wave 14, part 1: the big-brain memory blowups stop, a renamed page keeps its history, and `gbrain init` tells you who is blocking it instead of hanging.**diff --git a/VERSION b/VERSIONindex d586f56b2f..03ff1a7028 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-0.60.168.0+0.60.169.0diff --git a/openclaw.plugin.json b/openclaw.plugin.jsonindex 9bdb41fe01..f479387e69 100644--- a/openclaw.plugin.json+++ b/openclaw.plugin.json@@ -1,7 +1,7 @@{"id": "gbrain-context-engine","name": "gbrain",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Personal knowledge brain with Postgres + pgvector hybrid search","family": "bundle-plugin","kind": "context-engine",diff --git a/package.json b/package.jsonindex 71432ec2b3..c859096f03 100644--- a/package.json+++ b/package.json@@ -232,7 +232,7 @@"bun": ">=1.4.0"},"license": "MIT",- "version": "0.60.168.0",+ "version": "0.60.169.0","overrides": {"@ai-sdk/provider-utils": "4.0.56","@hono/node-server": "^2.0.5",diff --git a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json b/plugin-variants/gbrain-coding/.claude-plugin/plugin.jsonindex 3e4f86108c..af6be47ed7 100644--- a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json+++ b/plugin-variants/gbrain-coding/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-coding",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json b/plugin-variants/gbrain-coding/.codex-plugin/plugin.jsonindex e814a53aa3..ad173bee00 100644--- a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json+++ b/plugin-variants/gbrain-coding/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-coding",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-coding/README.md b/plugin-variants/gbrain-coding/README.mdindex 571bc20fa9..8028f61a51 100644--- a/plugin-variants/gbrain-coding/README.md+++ b/plugin-variants/gbrain-coding/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.168.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.169.0 --># gbrain-coding (generated persona variant — do not hand-edit)Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant.diff --git a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json b/plugin-variants/gbrain-daily/.claude-plugin/plugin.jsonindex b309714850..d16d938217 100644--- a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json+++ b/plugin-variants/gbrain-daily/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-daily",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json b/plugin-variants/gbrain-daily/.codex-plugin/plugin.jsonindex 65b5052cd0..8320d6faee 100644--- a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json+++ b/plugin-variants/gbrain-daily/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-daily",- "version": "0.60.168.0",+ "version": "0.60.169.0","description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-daily/README.md b/plugin-variants/gbrain-daily/README.mdindex 94ea38b34a..cdd2c3ad21 100644--- a/plugin-variants/gbrain-daily/README.md+++ b/plugin-variants/gbrain-daily/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.168.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.169.0 --># gbrain-daily (generated persona variant — do not hand-edit)Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant.diff --git a/plugin/README.md b/plugin/README.mdindex 3c70e1939f..49f58b2e1b 100644--- a/plugin/README.md+++ b/plugin/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.168.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.169.0 --># gbrain plugin skill tree (generated — do not hand-edit)This tree is the curated skill set for the gbrain Codex and Claude Codediff --git a/templates/bootstrap/template-repo/README.md b/templates/bootstrap/template-repo/README.mdindex 79ee872b66..b2a45e9127 100644--- a/templates/bootstrap/template-repo/README.md+++ b/templates/bootstrap/template-repo/README.md@@ -1,6 +1,6 @@# gbrain agent workspace — template-<!-- gbrain-template-stamp: 0.60.168.0 -->+<!-- gbrain-template-stamp: 0.60.169.0 -->This repository is the **"Use this template"** distribution artifact for a[gbrain](https://github.com/garrytan/gbrain) personal-agent workspace — the samediff --git a/test/helpers/stream-text.ts b/test/helpers/stream-text.tsnew file mode 100644index 0000000000..46c250dcca--- /dev/null+++ b/test/helpers/stream-text.ts@@ -0,0 +1,30 @@+/**+ * Drain a child's stdout/stderr into a string from the moment it is spawned.+ *+ * Racing `reader.read()` against a timer loses output: a read the timer beat+ * is still queued on the reader, so the next chunk the child writes resolves+ * that abandoned read and nobody keeps its bytes. A gateway that is quiet for+ * a second while it loads plugins and then prints `[gateway] ready` in one+ * chunk has that line eaten (test/stream-text.test.ts pins it). One pump per+ * stream, started once, is the only reader; callers poll `text`.+ */+export interface PumpedText {+ readonly text: string;+}++export function pumpText(stream: ReadableStream<Uint8Array>): PumpedText {+ const decoder = new TextDecoder();+ let text = '';+ void (async () => {+ for await (const chunk of stream) text += decoder.decode(chunk, { stream: true });+ text += decoder.decode();+ })().catch(() => {});+ return { get text() { return text; } };+}++/** Polls until `needle` appears in the pumped text or `timeoutMs` passes; returns whether it appeared. */+export async function waitForText(pumped: PumpedText, needle: string, timeoutMs: number, everyMs = 100): Promise<boolean> {+ const deadline = Date.now() + timeoutMs;+ while (!pumped.text.includes(needle) && Date.now() < deadline) await Bun.sleep(everyMs);+ return pumped.text.includes(needle);+}diff --git a/test/openclaw-context-engine-native.serial.test.ts b/test/openclaw-context-engine-native.serial.test.tsindex a17e8733df..6021226105 100644--- a/test/openclaw-context-engine-native.serial.test.ts+++ b/test/openclaw-context-engine-native.serial.test.ts@@ -6,6 +6,7 @@ import { join, resolve } from 'node:path';import postgres from '#postgres'import { PostgresEngine } from '../src/core/postgres-engine.ts';import { assertSafeE2eDatabaseUrl } from './helpers/db-guard.ts';+import { pumpText, waitForText } from './helpers/stream-text.ts';const host = process.env.GBRAIN_TEST_OPENCLAW_BIN;const root = resolve(import.meta.dir, '..');@@ -82,6 +83,10 @@ describe.skipIf(!host)('pinned OpenClaw native context-engine startup', () => {retrieval_reflex: true, retrieval_reflex_window_turns: 1, retrieval_reflex_volunteer: false,}));const manifest = JSON.parse(readFileSync(join(root, 'openclaw.plugin.json'), 'utf8'));+ const modelsConfig = { mode: 'replace', providers: { fixture: {+ baseUrl: `http://127.0.0.1:${address.port}/v1`, api: 'openai-completions', apiKey: 'local-fixture',+ models: [{ id: 'fixture', name: 'Fixture', contextWindow: 32768, maxTokens: 512, reasoning: false, input: ['text'], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }],+ } } };writeFileSync(configPath, JSON.stringify({plugins: {allow: [manifest.id], load: { paths: [root] },@@ -95,11 +100,11 @@ describe.skipIf(!host)('pinned OpenClaw native context-engine startup', () => {},tools: { deny: ['*'] },mcp: { servers: { gbrain: { enabled: false } } },- models: { mode: 'replace', providers: { fixture: {- baseUrl: `http://127.0.0.1:${address.port}/v1`, api: 'openai-completions', apiKey: 'local-fixture',- models: [{ id: 'fixture', name: 'Fixture', contextWindow: 32768, maxTokens: 512, reasoning: false, input: ['text'], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } }],- } } },gateway: { mode: 'local' },+ // No network at startup: the pinned gateway otherwise checks telemetry.openclaw.ai for a newer+ // release and downloads the hosted model catalog from catalog.openclaw.ai on every start.+ update: { checkOnStart: false },+ models: { ...modelsConfig, catalogRefresh: { enabled: false } },}));expect(await run(['--version'])).toContain('2026.9.4');const inspection = JSON.parse(await run(['plugins', 'inspect', manifest.id, '--runtime', '--json']));@@ -148,17 +153,13 @@ describe.skipIf(!host)('pinned OpenClaw native context-engine startup', () => {const config = JSON.parse(readFileSync(configPath, 'utf8'));writeFileSync(configPath, JSON.stringify({ ...config, gateway: { mode: 'local', port: gatewayPort, bind: 'loopback', auth: { mode: 'none' } } }));const gateway = Bun.spawn([host!, 'gateway', 'run'], { env, cwd: otherWorkspace, stdout: 'pipe', stderr: 'pipe' });+ const gatewayLog = pumpText(gateway.stdout);+ const gatewayErrors = pumpText(gateway.stderr);try {- const reader = gateway.stdout.getReader();- let gatewayLog = '';- const readyBy = Date.now() + 60_000;- while (!gatewayLog.includes('[gateway] ready') && Date.now() < readyBy) {- const chunk = await Promise.race([reader.read(), Bun.sleep(1_000).then(() => null)]);- if (chunk?.done) break;- if (chunk?.value) gatewayLog += new TextDecoder().decode(chunk.value);- }- reader.releaseLock();- expect(gatewayLog).toContain('[gateway] ready');+ await waitForText(gatewayLog, '[gateway] ready', 60_000);+ expect({ stdout: gatewayLog.text, stderr: gatewayErrors.text }).toMatchObject({ stdout: expect.stringContaining('[gateway] ready') });+ expect(gatewayLog.text).not.toContain('update available');+ expect(gatewayLog.text).not.toContain('remote model catalog');const compacted = JSON.parse(await run(['sessions', 'compact', 'agent:main:fresh-conversation-one', '--agent', 'main', '--json', '--timeout', '60000']));expect(compacted).toMatchObject({ ok: true, compacted: true });} finally {diff --git a/test/stream-text.test.ts b/test/stream-text.test.tsnew file mode 100644index 0000000000..dbb2b60b6c--- /dev/null+++ b/test/stream-text.test.ts@@ -0,0 +1,37 @@+import { expect, test } from 'bun:test';+import { pumpText, waitForText } from './helpers/stream-text.ts';++// A child that is quiet for longer than a second and then prints the line we wait for in one chunk:+// the pinned OpenClaw gateway does this between loading its plugins and `[gateway] ready`.+const bursty = () => Bun.spawn(['sh', '-c', 'printf "[gateway] starting...\\n"; sleep 1.5; printf "[gateway] ready\\n"; sleep 2'], { stdout: 'pipe', stderr: 'ignore' });++test('pumpText keeps every chunk a child writes after a silence; the ready line is seen', async () => {+ const child = bursty();+ const log = pumpText(child.stdout);+ try {+ expect(await waitForText(log, '[gateway] ready', 10_000)).toBe(true);+ expect(log.text).toBe('[gateway] starting...\n[gateway] ready\n');+ } finally {+ child.kill();+ await child.exited;+ }+}, 20_000);++test('racing reader.read() against a timer loses the chunk that arrives after the silence (the pattern pumpText replaces)', async () => {+ const child = bursty();+ const reader = child.stdout.getReader();+ let log = '';+ const readyBy = Date.now() + 4_000;+ try {+ while (!log.includes('[gateway] ready') && Date.now() < readyBy) {+ const chunk = await Promise.race([reader.read(), Bun.sleep(1_000).then(() => null)]);+ if (chunk?.done) break;+ if (chunk?.value) log += new TextDecoder().decode(chunk.value);+ }+ } finally {+ reader.releaseLock();+ child.kill();+ await child.exited;+ }+ expect(log).toBe('[gateway] starting...\n');+}, 20_000);