Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: a bootstrap install and an upgraded registration now carry the brain-first block

garrytand4e7f79e2d4c
diff --git a/test/agent-journey-upgrade.serial.test.ts b/test/agent-journey-upgrade.serial.test.ts
index dcace20357..9a02895d01 100644
--- a/test/agent-journey-upgrade.serial.test.ts
+++ b/test/agent-journey-upgrade.serial.test.ts
@@ -279,14 +279,23 @@ describe('(3) harness configs registered before the upgrade', () => {
return check;
}
+ /** The registration still answers; the only warning is the brain-first block an older install never wrote, and its fix clears it. */
+ async function expectWiredThenBlockFixed(harness: 'claude-code' | 'codex') {
+ const before = harnessCheck(await run(h, ['doctor', '--only', 'harness_wiring', '--json']));
+ expect(before, JSON.stringify(before)).toMatchObject({ status: 'warn', details: { harness, reason: 'wired_running', smoke: 'smoke_passed', instructions: expect.arrayContaining([expect.objectContaining({ harness, state: 'missing' })]) }, fix: { argv: ['gbrain', 'setup', harness, '--instructions-only'] } });
+ const fixed = await run(h, ['setup', harness, '--instructions-only', '--json']);
+ expect(fixed.exitCode, fixed.stderr).toBe(0);
+ const after = harnessCheck(await run(h, ['doctor', '--only', 'harness_wiring', '--json']));
+ expect(after, JSON.stringify(after)).toMatchObject({ status: 'ok', details: { harness, reason: 'wired_running', smoke: 'smoke_passed', instructions: expect.arrayContaining([expect.objectContaining({ harness, state: 'current' })]) } });
+ }
+
test('a pre-surface Claude Code registration (`serve`, no --surface) keeps the full catalog and recalls', async () => {
clear();
const regEnv = { GBRAIN_HOME: h.home, GBRAIN_SKIP_STARTUP_HOOKS: '1' };
writeFileSync(join(h.home, '.claude.json'), JSON.stringify({ mcpServers: { gbrain: { type: 'stdio', command: process.execPath, args: ['--no-env-file', CLI, 'serve'], env: regEnv } } }));
const tools = await registeredRecall(process.execPath, ['--no-env-file', CLI, 'serve'], regEnv);
expect(tools).toContain('search');
- const check = harnessCheck(await run(h, ['doctor', '--only', 'harness_wiring', '--json']));
- expect(check).toMatchObject({ status: 'ok', details: { harness: 'claude-code', reason: 'wired_running', smoke: 'smoke_passed' } });
+ await expectWiredThenBlockFixed('claude-code');
}, 120_000);
test('a Codex config.toml registration keeps working and doctor reports it', async () => {
@@ -298,8 +307,7 @@ describe('(3) harness configs registered before the upgrade', () => {
`env = { GBRAIN_HOME = ${JSON.stringify(h.home)}, GBRAIN_SKIP_STARTUP_HOOKS = "1" }`, '',
].join('\n'));
await registeredRecall(process.execPath, ['--no-env-file', CLI, 'serve', '--surface', 'verbs'], { GBRAIN_HOME: h.home, GBRAIN_SKIP_STARTUP_HOOKS: '1' });
- const check = harnessCheck(await run(h, ['doctor', '--only', 'harness_wiring', '--json']));
- expect(check, JSON.stringify(check)).toMatchObject({ status: 'ok', details: { harness: 'codex', reason: 'wired_running', smoke: 'smoke_passed' } });
+ await expectWiredThenBlockFixed('codex');
}, 120_000);
test('a bare `gbrain serve` registration still answers on a PATH that has gbrain; doctor flags it with the rewire fix', async () => {
diff --git a/test/bootstrap-shared-skills.test.ts b/test/bootstrap-shared-skills.test.ts
index fcd2ae5357..ef6cc3352e 100644
--- a/test/bootstrap-shared-skills.test.ts
+++ b/test/bootstrap-shared-skills.test.ts
@@ -9,6 +9,7 @@ import { installSharedSkillsConnection } from '../src/core/harness/shared-skills
import type { SharedSkillsToolCaller } from '../src/core/shared-skills/adapter.ts';
import { operations } from '../src/core/operations.ts';
import { HARNESS_CLEANUP_PENDING_EXIT_CODE } from '../src/core/exit-codes.ts';
+import { BRAIN_FIRST_BEGIN, BRAIN_FIRST_END } from '../src/core/setup/brain-first.ts';
const roots: string[] = [];
afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
@@ -112,7 +113,10 @@ test('fresh parent follows the catalog with an owned native router and a registr
expect(adapter.native_registration).toBe('installed');
expect(readFileSync(adapter.native_router_path, 'utf8')).toContain('configured MCP connection "gbrain"');
expect(readFileSync(adapter.native_router_path, 'utf8')).toContain('sync_brain_skills');
- expect(readFileSync(join(f.root, 'codex', 'AGENTS.md'), 'utf8')).toBe('Preserve this agent identity.');
+ const agents = readFileSync(join(f.root, 'codex', 'AGENTS.md'), 'utf8');
+ expect(agents.split(BRAIN_FIRST_BEGIN)).toHaveLength(2);
+ expect(agents.slice(0, agents.indexOf(BRAIN_FIRST_BEGIN)).trimEnd()).toBe('Preserve this agent identity.');
+ expect(agents.slice(agents.indexOf(BRAIN_FIRST_END) + BRAIN_FIRST_END.length).trim()).toBe('');
expect(statSync(join(entry.root, 'credentials.json')).mode & 0o777).toBe(0o600);
expect(JSON.stringify(r)).not.toContain(mint.token);
expect(f.output.join('\n')).toContain('native activation remains unverified');