Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Keep the links train green on current master
garrytan35e6110b59db
diff --git a/src/core/schema-migrations/v303-link-transitions-source.ts b/src/core/schema-migrations/v303-link-transitions-source.tsindex de31cce4e8..58455a7e30 100644--- a/src/core/schema-migrations/v303-link-transitions-source.ts+++ b/src/core/schema-migrations/v303-link-transitions-source.ts@@ -70,6 +70,12 @@ export async function swapIdentityIndex(engine: BrainEngine): Promise<void> {}}+async function widenIdentityIndex(engine: BrainEngine): Promise<void> {+ const built = await buildIndexOnline(engine, 303, LINK_TRANSITIONS_IDENTITY_NEXT_INDEX, { notice: migrationNotice });+ if (built === 'building') throw new Error(`${LINK_TRANSITIONS_IDENTITY_NEXT_INDEX.name} is being built by another session; rerun the migration once it finishes`);+ await swapIdentityIndex(engine);+}+export const v303: Migration = {version: 303,name: 'link_transitions_source',@@ -80,10 +86,6 @@ export const v303: Migration = {await runMigrationStatement(engine, 303, POSTGRES_15_GATE);await runMigrationStatement(engine, 303, 'ALTER TABLE link_transitions ADD COLUMN IF NOT EXISTS link_source TEXT');if (await identityIndexHasSource(engine)) return;- const built = await buildIndexOnline(engine, 303, LINK_TRANSITIONS_IDENTITY_NEXT_INDEX, { notice: migrationNotice });- if (built === 'building') {- throw new Error(`Another session is still building ${LINK_TRANSITIONS_IDENTITY_NEXT_INDEX.name}; when it finishes, rerun: gbrain apply-migrations --yes`);- }- await swapIdentityIndex(engine);+ await widenIdentityIndex(engine);},};diff --git a/test/link-dates-per-row-gst2228.test.ts b/test/link-dates-per-row-gst2228.test.tsindex 23eb0c1c5a..f89547494a 100644--- a/test/link-dates-per-row-gst2228.test.ts+++ b/test/link-dates-per-row-gst2228.test.ts@@ -18,6 +18,7 @@ import { join } from 'node:path';import type { BrainEngine } from '../src/core/engine.ts';import type { OperationContext } from '../src/core/ops/contract.ts';import { operationsByName } from '../src/core/operations.ts';+import { pageNotVisibleError } from '../src/core/persistence/page-visibility.ts';import { parseLinksFence, readPageLinksFence, renderLinksFence, type LinksFenceRow } from '../src/core/links-fence.ts';import { durableGitRepo } from './helpers/git-publication.ts';import { managedBrain, settleManagedGitEffects } from './helpers/managed-brain.ts';@@ -157,7 +158,7 @@ for (const backend of testBackends()) {const before = await revision(engine);const missing = await op(remote, 'add_link', { from: ALICE, to: hidden.to, link_type: BETA.type }).then(() => null, (error: { code?: string; message?: string }) => ({ code: error.code, message: error.message }));expect(missing?.code).toBe('page_not_found');- await expect(op(remote, 'add_link', { from: ALICE, to: BETA.to, link_type: BETA.type, context: BETA.context })).rejects.toMatchObject(missing!);+ await expect(op(remote, 'add_link', { from: ALICE, to: BETA.to, link_type: BETA.type, context: BETA.context })).rejects.toMatchObject({ code: missing!.code, message: pageNotVisibleError().message });expect(await revision(engine)).toBe(before);expect(await pageRows(engine)).toEqual([]);await addBeta(ctx);