Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: write fixtures that pinned an old schema version write at head now that writes refuse a behind schema (#6904)

garrytan5e3590129af7
diff --git a/test/e2e/persistence-client-request-id-postgres.test.ts b/test/e2e/persistence-client-request-id-postgres.test.ts
index d7be52a3e9..81d620cafc 100644
--- a/test/e2e/persistence-client-request-id-postgres.test.ts
+++ b/test/e2e/persistence-client-request-id-postgres.test.ts
@@ -12,6 +12,7 @@ import { configureGateway, resetGateway } from '../../src/core/ai/gateway.ts';
import { disposePersistenceConsumer } from '../../src/core/persistence/service.ts';
import { compactWriteReceipts } from '../../src/core/persistence/journal.ts';
import { clientRequestUuid } from '../../src/core/persistence/preconditions.ts';
+import { LATEST_SCHEMA_VERSION } from '../../src/core/schema-migrations/latest.generated.ts';
const RUN = hasDatabase();
const d = RUN ? describe : describe.skip;
@@ -38,6 +39,7 @@ d('client request ids on Postgres', () => {
});
test('a string id journals its UUIDv5, replays, reads by either id, refuses other intent and survives compaction', async () => {
+ await setConfigVersion(LATEST_SCHEMA_VERSION);
const id = `pg-put-notes-${Date.now()}`;
const uuid = clientRequestUuid(id);
const first = await call('put_page', { slug: `notes/${id}`, content: page('Postgres one'), request_id: id });
diff --git a/test/helpers/facts-worker-config-contract.ts b/test/helpers/facts-worker-config-contract.ts
index db572fde4f..0402f5bfd7 100644
--- a/test/helpers/facts-worker-config-contract.ts
+++ b/test/helpers/facts-worker-config-contract.ts
@@ -16,6 +16,7 @@ import { MinionWorker } from '../../src/core/minions/worker.ts';
import type { MinionJobContext } from '../../src/core/minions/types.ts';
import { registerBuiltinHandlers } from '../../src/commands/jobs.ts';
import { withEnv } from './with-env.ts';
+import { LATEST_SCHEMA_VERSION } from '../../src/core/schema-migrations/latest.generated.ts';
const FACT = 'A worker-specific preference is to review plans weekly.';
const BODY = 'A synthetic meeting record describes a weekly planning preference. '.repeat(8);
@@ -38,7 +39,7 @@ export async function exerciseFactsWorkerConfig(engine: BrainEngine): Promise<vo
embeddedTexts.push(...values);
return { embeddings: values.map(() => [1, ...Array(1535).fill(0)]) };
}) as never);
- await engine.setConfig('version', '162');
+ await engine.setConfig('version', String(LATEST_SCHEMA_VERSION));
await engine.executeRaw('INSERT INTO sources(id,name) VALUES($1,$1)', [sourceId]);
await engine.putPage('people/example', { type: 'person', title: 'Example entity', compiled_truth: 'A searchable narrative remains on this registered entity.' }, { sourceId });
await engine.executeRaw("INSERT INTO oauth_clients(client_id,client_secret_hash,client_name,scope,source_id) VALUES('worker-config-client','fixture-hash','example-client','read write',$1)", [sourceId]);
diff --git a/test/helpers/managed-facts-contract.ts b/test/helpers/managed-facts-contract.ts
index 287ec17050..bfbd1c63e4 100644
--- a/test/helpers/managed-facts-contract.ts
+++ b/test/helpers/managed-facts-contract.ts
@@ -22,6 +22,7 @@ import { withEnv } from './with-env.ts';
import { createPersistenceIpcProvider } from '../../src/core/persistence/provider.ts';
import { requestPersistenceOperation, startPersistenceIpcServer, type PersistenceIpcRequest } from '../../src/core/persistence/ipc.ts';
import type { PersistenceEffect } from '../../src/core/persistence/effect-model.ts';
+import { LATEST_SCHEMA_VERSION } from '../../src/core/schema-migrations/latest.generated.ts';
export const factContractCases = ['publication', 'confined', 'revoked', 'narrowed', 'private_target', 'private_hint', 'owner_unavailable', 'source_replaced', 'deferred', 'worker', 'worker_revoked', 'worker_narrowed', 'unparented', 'ipc'] as const;
type Case = typeof factContractCases[number];
@@ -34,7 +35,7 @@ export async function exerciseManagedFacts(engine: BrainEngine, scenario: Case):
await disposePersistenceConsumer(engine);
configureGateway({ embedding_model: 'openai:text-embedding-3-large', embedding_dimensions: 1536, env: { OPENAI_API_KEY: 'test' } });
await engine.executeRaw('UPDATE persistence_brain SET enabled=false WHERE singleton=1');
- await engine.setConfig('version', '162');
+ await engine.setConfig('version', String(LATEST_SCHEMA_VERSION));
await engine.setConfig('facts.default_visibility', 'private');
await engine.executeRaw('INSERT INTO sources(id,name) VALUES($1,$1)', [sourceId]);
const firstSlug = 'people/alice-example', secondSlug = 'companies/acme-example';