Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Keep the archive notice test passing after a release folds its changelog entry (#9437)
Garry Tan968aa8f516a3
diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 6976fd3a25..d1d5cdbe65 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -457,6 +457,7 @@ test/transcription-injection.test.ts transcription — command injection (#245)test/trust-write-gate-drift.test.ts (file-level) 1 readFileSynctest/unmanaged-push-every-site-gst2456.serial.test.ts gbrain git commit-push 8 readFileSynctest/upgrade-post-swap-imports.test.ts #6604 upgrade post-swap tail 3 readFileSync+test/upgrade-transcript-archive-notice.test.ts the conversation archive upgrade notice 3 readFileSynctest/upgrade.serial.test.ts detectInstallMethod — package-install classification (in-process) 5 readFileSynctest/upgrade.serial.test.ts runUpgrade target verification (#4366) 8 readFileSynctest/v0_37_fix_wave.serial.test.ts v0.37 Lane A — defaults sweep 8 source-surface-helperdiff --git a/test/upgrade-transcript-archive-notice.test.ts b/test/upgrade-transcript-archive-notice.test.tsindex a2bd280c66..2a25663b3d 100644--- a/test/upgrade-transcript-archive-notice.test.ts+++ b/test/upgrade-transcript-archive-notice.test.ts@@ -4,8 +4,10 @@* per-channel markers (no new sentinel): an existing brain sees it once, with the off command; a shared brain reads* the offer (the on command) and the notice never turns anything on. PGLite.*- * The row is pending until a release dates it, so the test adds it to the loaded table for the duration of the file- * (dated at the newest disclosed release, so the notice id is unchanged) and removes it afterwards.+ * Before a release dates the row, the test adds it to the loaded table for the duration of the file (dated at the+ * newest disclosed release, so the notice id is unchanged) and removes it afterwards; once a release has dated it, the+ * table already holds it and the test adds nothing. The release also folds the changelog fragment into CHANGELOG.md,+ * so the marker is read from whichever of the two holds it.*/import { afterAll, beforeAll, describe, expect, test } from 'bun:test';import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';@@ -26,6 +28,7 @@ const table = BEHAVIOR_CHANGES as Array<{ since: string; id?: string; text: unknconst NO_CHAIN = { GBRAIN_CHAT_FALLBACK_CHAIN: undefined, GBRAIN_CHAT_FALLBACK_ON_REFUSAL: undefined };let engine: PGLiteEngine;+let pushed = false;function upgradedHome(brainKey: string): string {const home = mkdtempSync(join(tmpdir(), 'archive-notice-'));@@ -39,12 +42,17 @@ beforeAll(async () => {engine = new PGLiteEngine();await engine.connect({});await engine.initSchema();- table.push({ since: BEHAVIOR_NOTICE_SINCE, id: ID, text });+ if (!table.some(row => row.id === ID)) {+ table.push({ since: BEHAVIOR_NOTICE_SINCE, id: ID, text });+ pushed = true;+ }});afterAll(async () => {- const at = table.findIndex(row => row.id === ID);- if (at >= 0) table.splice(at, 1);+ if (pushed) {+ const at = table.findIndex(row => row.id === ID);+ if (at >= 0) table.splice(at, 1);+ }await engine.disconnect();});@@ -53,8 +61,13 @@ describe('the conversation archive upgrade notice', () => {expect(text.length).toBeLessThanOrEqual(2000);expect(text).not.toContain('\n');for (const phrase of ['gbrain transcripts archive off', 'conversations', 'gbrain embed --held --dry-run', 'keyless', 'gbrain transcripts archive on']) expect(text).toContain(phrase);- const fragment = readFileSync(join(ROOT, 'changelog.d', 'transcript-archive-default.md'), 'utf8');- expect(fragment).toContain('<!-- behavior-change: ' + ID + ' -->');+ let entry: string;+ try {+ entry = readFileSync(join(ROOT, 'changelog.d', 'transcript-archive-default.md'), 'utf8');+ } catch {+ entry = readFileSync(join(ROOT, 'CHANGELOG.md'), 'utf8');+ }+ expect(entry).toContain('<!-- behavior-change: ' + ID + ' -->');});test('an upgraded brain sees it once, with the off command', async () => {