Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(pathological): lane B rows run their Postgres arm in CI; the lane guard reads pathologicalArms()

garrytanb7d2ef150103
diff --git a/scripts/check-postgres-lane-coverage.ts b/scripts/check-postgres-lane-coverage.ts
index 86dce68d32..b202107359 100644
--- a/scripts/check-postgres-lane-coverage.ts
+++ b/scripts/check-postgres-lane-coverage.ts
@@ -7,7 +7,7 @@
* the file. This guard fails on every test/ file outside test/e2e/ that has
* such an arm and no Postgres lane:
*
- * - arm: a zero-argument `testBackends()` call, or a `process.env.DATABASE_URL`
+ * - arm: a zero-argument `testBackends()` or `pathologicalArms()` call, or a `process.env.DATABASE_URL`
* read (directly or through a variable that holds it) used as a condition,
* a call or constructor argument, or a `database_url`/`databaseUrl`
* property value. Code inside a `withEnv({ DATABASE_URL: ... })` callback
@@ -105,6 +105,9 @@ function underOwnDatabaseUrl(node: ts.Node): boolean {
return false;
}
+/** Zero-argument calls that return the test's engine arms: `testBackends()` and the pathological harness's `pathologicalArms()`. */
+const ARM_CALLS = new Set(['testBackends', 'pathologicalArms']);
+
/** First line of a Postgres arm in `path`, or null. */
export function postgresArm(path: string): { line: number; what: string } | null {
const sf = ts.createSourceFile(path, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
@@ -113,9 +116,9 @@ export function postgresArm(path: string): { line: number; what: string } | null
const found: Array<{ line: number; what: string }> = [];
const reads: ts.Node[] = [];
const visit = (node: ts.Node): void => {
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'testBackends' && node.arguments.length === 0
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ARM_CALLS.has(node.expression.text) && node.arguments.length === 0
&& !underOwnDatabaseUrl(node)) {
- found.push({ line: line(node), what: 'testBackends()' });
+ found.push({ line: line(node), what: `${node.expression.text}()` });
}
if (isDatabaseUrlRead(node) && !underOwnDatabaseUrl(node)) reads.push(node);
ts.forEachChild(node, visit);
diff --git a/test/pathological/b-10-ontology-rekey-collision.test.ts b/test/pathological/b-10-ontology-rekey-collision.test.ts
index 0d0ac1f306..0eb11ab04c 100644
--- a/test/pathological/b-10-ontology-rekey-collision.test.ts
+++ b/test/pathological/b-10-ontology-rekey-collision.test.ts
@@ -18,12 +18,10 @@
*/
import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
import type { BrainEngine } from '../../src/core/engine.ts';
-import { PGLiteEngine } from '../../src/core/pglite-engine.ts';
import { importFromContent } from '../../src/core/import-file.ts';
import { readFacts } from '../../src/core/persistence/prepared-maintenance.ts';
import { relinkFactHash, submitRelinkGroup } from '../../src/core/facts/relink-publish.ts';
-import { testBackends } from '../helpers/test-backends.ts';
-import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';
+import { openArm, pathologicalArms } from './_gbra60-shim.ts';
const VALID_FROM = '2026-03-01T00:00:00Z';
const observe = (engine: BrainEngine, entitySlug: string, source: string) =>
@@ -32,22 +30,17 @@ const rows = (engine: BrainEngine) => engine.executeRaw<{ id: number; entity_slu
`SELECT id, entity_slug, source_markdown_slug, expired_at FROM facts WHERE source_id = 'default' AND dimension = 'role' ORDER BY id`);
const md = (title: string, type: string) => `---\ntitle: ${title}\ntype: ${type}\n---\n\n# ${title}\n`;
-const backends = testBackends();
+const arms = pathologicalArms();
const engines: Array<{ name: string; engine: BrainEngine; close: () => Promise<void> }> = [];
beforeAll(async () => {
- if (backends.includes('pglite')) {
- const engine = new PGLiteEngine();
- await engine.connect({}); await engine.initSchema();
- engines.push({ name: 'pglite', engine, close: () => engine.disconnect() });
- }
- if (backends.includes('postgres')) {
- const pg = await isolatedPersistencePostgres(process.env.DATABASE_URL!);
- engines.push({ name: 'postgres', engine: pg.engine, close: async () => { await pg.engine.disconnect(); await pg.close(); } });
+ for (const arm of arms) {
+ const { engine, close } = await openArm(arm);
+ engines.push({ name: arm.backend, engine, close });
}
}, 120_000);
afterAll(async () => { for (const e of engines) await e.close(); });
-for (const backend of backends) {
+for (const { backend } of arms) {
const engine = () => engines.find(e => e.name === backend)!.engine;
describe(`B-10 re-keying a fact never collides on the ontology stint index (${backend})`, () => {
beforeEach(async () => {
diff --git a/test/pathological/b-9-enrich-retired-alias.test.ts b/test/pathological/b-9-enrich-retired-alias.test.ts
index 423939cc27..ba45d39d30 100644
--- a/test/pathological/b-9-enrich-retired-alias.test.ts
+++ b/test/pathological/b-9-enrich-retired-alias.test.ts
@@ -14,13 +14,11 @@
*/
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
import type { BrainEngine } from '../../src/core/engine.ts';
-import { PGLiteEngine } from '../../src/core/pglite-engine.ts';
import { importFromContent } from '../../src/core/import-file.ts';
import { enrichEntity } from '../../src/core/enrichment-service.ts';
import { operationsByName } from '../../src/core/operations.ts';
import type { OperationContext } from '../../src/core/operations.ts';
-import { testBackends } from '../helpers/test-backends.ts';
-import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';
+import { openArm, pathologicalArms } from './_gbra60-shim.ts';
const page = (fm: Record<string, unknown>, title: string) =>
`---\n${Object.entries({ title, ...fm }).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join('\n')}\n---\n\n# ${title}\n`;
@@ -43,23 +41,17 @@ const timeline = async (engine: BrainEngine, slug: string) =>
const backlinks = async (engine: BrainEngine, slug: string) =>
(await engine.executeRaw<{ n: number }>(`SELECT count(*)::int AS n FROM links l JOIN pages p ON p.id = l.from_page_id WHERE p.slug = $1`, [slug]))[0]!.n;
-const backends = testBackends();
+const arms = pathologicalArms();
const engines: Array<{ name: string; engine: BrainEngine; close: () => Promise<void> }> = [];
beforeAll(async () => {
- if (backends.includes('pglite')) {
- const engine = new PGLiteEngine();
- await engine.connect({}); await engine.initSchema(); await seed(engine);
- engines.push({ name: 'pglite', engine, close: () => engine.disconnect() });
- }
- if (backends.includes('postgres')) {
- const pg = await isolatedPersistencePostgres(process.env.DATABASE_URL!);
- await seed(pg.engine);
- engines.push({ name: 'postgres', engine: pg.engine, close: async () => { await pg.engine.disconnect(); await pg.close(); } });
+ for (const arm of arms) {
+ const { engine, close } = await openArm(arm); await seed(engine);
+ engines.push({ name: arm.backend, engine, close });
}
}, 120_000);
afterAll(async () => { for (const e of engines) await e.close(); });
-for (const backend of backends) {
+for (const { backend } of arms) {
const engine = () => engines.find(e => e.name === backend)!.engine;
describe(`B-9 enrichment follows a retired page to its canonical page (${backend})`, () => {
test('enriching Alice Example updates the canonical page and leaves the retired one untouched', async () => {
diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txt
index 12e8291655..b2546b8c37 100644
--- a/test/postgres-unit-arms.txt
+++ b/test/postgres-unit-arms.txt
@@ -218,6 +218,9 @@ test/page-prepare-shared-origin-6517.test.ts
test/page-purge-batch-sweep-6884.test.ts
test/page-purge-journal-timeout-6511.test.ts
test/page-state-engine.test.ts
+test/pathological/b-10-ontology-rekey-collision.test.ts
+test/pathological/b-7-facts-pageless-entity.test.ts
+test/pathological/b-9-enrich-retired-alias.test.ts
test/persistence-background-pause.test.ts
test/persistence-bounded-read-session.test.ts
test/persistence-capacity-forecast.test.ts
diff --git a/test/scripts/postgres-lane-coverage.test.ts b/test/scripts/postgres-lane-coverage.test.ts
index 466ba37bb3..2ebd501fda 100644
--- a/test/scripts/postgres-lane-coverage.test.ts
+++ b/test/scripts/postgres-lane-coverage.test.ts
@@ -32,6 +32,7 @@ const PG_ENV = ' env:\n DATABASE_URL: postgres://gbrain_test:gbr
describe('check-postgres-lane-coverage.ts', () => {
test.each([
['a testBackends() loop', "for (const backend of testBackends()) describe(backend, () => {});\n"],
+ ['a pathologicalArms() loop', "for (const arm of pathologicalArms()) describe(arm.backend, () => {});\n"],
['a skipIf on DATABASE_URL', "test.skipIf(!process.env.DATABASE_URL)('postgres arm', () => {});\n"],
['a variable holding DATABASE_URL', "const url = process.env.DATABASE_URL;\ndescribe.skipIf(!url)('postgres arm', () => {});\n"],
['an if-gated connection', "beforeAll(async () => { if (process.env.DATABASE_URL) await isolatedPersistencePostgres(process.env.DATABASE_URL); });\n"],