Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
The compiled admin smoke makes a fresh bootstrap token each run
garrytan53ddf157a0a0
diff --git a/scripts/native/compiled-admin-smoke.ts b/scripts/native/compiled-admin-smoke.tsindex 7488c7a902..aead0593bb 100644--- a/scripts/native/compiled-admin-smoke.ts+++ b/scripts/native/compiled-admin-smoke.ts@@ -11,6 +11,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { createServer } from 'node:net';+import { randomBytes } from 'node:crypto';const arg = process.argv.indexOf('--binary');if (arg < 0 || !process.argv[arg + 1]) { console.error('usage: compiled-admin-smoke.ts --binary <compiled gbrain>'); process.exit(2); }@@ -24,6 +25,7 @@ const home = mkdtempSync(join(tmpdir(), 'gbrain-admin-smoke-'));mkdirSync(join(home, '.gbrain', 'brain.pglite'), { recursive: true });mkdirSync(join(home, 'tmp'));writeFileSync(join(home, '.gbrain', 'config.json'), `${JSON.stringify({ engine: 'pglite', database_path: join(home, '.gbrain', 'brain.pglite'), embedding_dimensions: 1536 })}\n`);+const bootstrapToken = randomBytes(24).toString('hex');const env: Record<string, string> = {PATH: process.env.PATH ?? '/usr/bin:/bin',HOME: home, USERPROFILE: home, GBRAIN_HOME: home,@@ -31,9 +33,9 @@ const env: Record<string, string> = {TMPDIR: join(home, 'tmp'), TMP: join(home, 'tmp'), TEMP: join(home, 'tmp'),LANG: 'C.UTF-8', LC_ALL: 'C',GBRAIN_NO_BANNER: '1', GBRAIN_SKIP_STARTUP_HOOKS: '1', GBRAIN_BACKUP_CHECK: '0', GBRAIN_SWEEP: '0',- GBRAIN_ADMIN_BOOTSTRAP_TOKEN: 'admin-smoke-bootstrap-token-aaaaaaaaaaaa',+ GBRAIN_ADMIN_BOOTSTRAP_TOKEN: bootstrapToken,};-// Never spread process.env: an inherited GBRAIN_DATABASE_URL or DATABASE_URL outranks config.json, and this server opens /admin with a public token.+// Never spread process.env: an inherited GBRAIN_DATABASE_URL or DATABASE_URL outranks config.json, and this server opens /admin with a per-run token.for (const name of ['SystemRoot', 'WINDIR', 'ComSpec']) if (process.env[name]) env[name] = process.env[name]!;const server = Bun.spawn([binary, 'serve', '--http', '--port', String(port), '--bind', '127.0.0.1'], { cwd: home, env, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe' });let output = '';diff --git a/test/release-workflow.test.ts b/test/release-workflow.test.tsindex 6c1da52045..0c168a7f11 100644--- a/test/release-workflow.test.ts+++ b/test/release-workflow.test.ts@@ -47,6 +47,13 @@ describe('release.yml ↔ binary-self-update asset contract', () => {expect(native).toContain('bun scripts/native/compiled-admin-smoke.ts --binary bin/gbrain-native-validation');});+ test('the compiled admin smoke makes a fresh bootstrap token each run instead of committing one', () => {+ const smoke = readFileSync(join(ROOT, 'scripts/native/compiled-admin-smoke.ts'), 'utf8');+ expect(smoke).not.toMatch(/GBRAIN_ADMIN_BOOTSTRAP_TOKEN:\s*['"`]/);+ expect(smoke).toMatch(/const bootstrapToken = randomBytes\(\d+\)\.toString\('hex'\);/);+ expect(smoke).toContain('GBRAIN_ADMIN_BOOTSTRAP_TOKEN: bootstrapToken,');+ });+test('workflow build matrix produces exactly the assets the updater requests', () => {const artifacts = [...WORKFLOW.matchAll(/artifact:\s*(\S+)/g)].map((m) => m[1]).sort();expect(artifacts).toEqual([...EXPECTED_ASSETS].sort());