Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(sync): run the delta drift-guard probe on Postgres too (#6712)

garrytande7f3b22a246
diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txt
index a45a100a85..905b406370 100644
--- a/test/postgres-unit-arms.txt
+++ b/test/postgres-unit-arms.txt
@@ -216,6 +216,7 @@ test/sync-legacy-holds.test.ts
test/sync-legacy-retry-actions-6696.test.ts
test/sync-legacy-slug-adoption-6727.test.ts
test/sync-origin-live-wins-6517.test.ts
+test/sync-prescreen-both-delta-6712.test.ts
test/sync-prescreen-drift-6712.test.ts
test/sync-slug-root-mode-6694.test.ts
test/sync-staged-catchup.test.ts
@@ -233,4 +234,3 @@ test/unbound-source-6536.test.ts
test/withdrawal-overlay-concurrency.test.ts
test/withdrawal-publication-file.test.ts
test/writer-status-owner-backends.test.ts
-test/sync-prescreen-both-delta-6712.test.ts
diff --git a/test/sync-prescreen-both-delta-6712.test.ts b/test/sync-prescreen-both-delta-6712.test.ts
index 862742f5e9..cd0fac3243 100644
--- a/test/sync-prescreen-both-delta-6712.test.ts
+++ b/test/sync-prescreen-both-delta-6712.test.ts
@@ -12,7 +12,7 @@
* The first test fails on the base (the page loses the edit and no hold is written). PGLite always; Postgres too when
* DATABASE_URL is set.
*/
-import { expect, test } from 'bun:test';
+import { describe, expect, test } from 'bun:test';
import { execFileSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { mkdirSync, writeFileSync } from 'node:fs';
@@ -44,28 +44,30 @@ async function putPage(engine: BrainEngine, ctx: OperationContext, slug: string,
await waitFor(async () => (await engine.executeRaw<{ state: string }>('SELECT state FROM persistence_requests WHERE request_id=$1::uuid', [requestId]))[0]?.state === 'committed', { timeoutMs: 30_000 });
}
-test('a delta sync holds a committed file edit over a database-only put_page instead of publishing it', () => managedBrain(async ({ engine, ctx, root }) => {
- expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');
- await engine.setConfig('sync.write_through', 'false');
- await putPage(engine, ctx, 'notes/a', 'DBONLYMARKER agent edit.');
- writeFileSync(join(root, 'notes/a.md'), note('notes/a', 'The second committed body.'));
- writeFileSync(join(root, 'notes/b.md'), note('notes/b', 'A file-only edit.'));
- commit(root, 'edit a and b');
- await performManagedSync(engine, OPTS);
- expect(await bodyOf(engine, 'notes/a')).toContain('DBONLYMARKER');
- const hold = await holdOf(engine, 'notes/a.md');
- expect(hold?.code).toBe('file_drift');
- expect(await bodyOf(engine, 'notes/b')).toContain('A file-only edit.');
- expect(await holdOf(engine, 'notes/b.md')).toBeNull();
-}, { setup }), 120_000);
+for (const databaseUrl of process.env.DATABASE_URL ? [undefined, process.env.DATABASE_URL] : [undefined]) describe(`#6712 delta drift guard (${databaseUrl ? 'postgres' : 'pglite'})`, () => {
+ test('a delta sync holds a committed file edit over a database-only put_page instead of publishing it', () => managedBrain(async ({ engine, ctx, root }) => {
+ expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');
+ await engine.setConfig('sync.write_through', 'false');
+ await putPage(engine, ctx, 'notes/a', 'DBONLYMARKER agent edit.');
+ writeFileSync(join(root, 'notes/a.md'), note('notes/a', 'The second committed body.'));
+ writeFileSync(join(root, 'notes/b.md'), note('notes/b', 'A file-only edit.'));
+ commit(root, 'edit a and b');
+ await performManagedSync(engine, OPTS);
+ expect(await bodyOf(engine, 'notes/a')).toContain('DBONLYMARKER');
+ const hold = await holdOf(engine, 'notes/a.md');
+ expect(hold?.code).toBe('file_drift');
+ expect(await bodyOf(engine, 'notes/b')).toContain('A file-only edit.');
+ expect(await holdOf(engine, 'notes/b.md')).toBeNull();
+ }, { setup, databaseUrl }), 120_000);
-test('a page whose revision write-through wrote to its file is not guarded: the committed edit imports', () => managedBrain(async ({ engine, ctx, root }) => {
- expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');
- await putPage(engine, ctx, 'notes/a', 'A write-through edit.');
- commit(root, 'write-through publication');
- writeFileSync(join(root, 'notes/a.md'), note('notes/a', 'A later committed body.'));
- commit(root, 'edit a');
- await performManagedSync(engine, OPTS);
- expect(await bodyOf(engine, 'notes/a')).toContain('A later committed body.');
- expect(await holdOf(engine, 'notes/a.md')).toBeNull();
-}, { setup }), 120_000);
+ test('a page whose revision write-through wrote to its file is not guarded: the committed edit imports', () => managedBrain(async ({ engine, ctx, root }) => {
+ expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');
+ await putPage(engine, ctx, 'notes/a', 'A write-through edit.');
+ commit(root, 'write-through publication');
+ writeFileSync(join(root, 'notes/a.md'), note('notes/a', 'A later committed body.'));
+ commit(root, 'edit a');
+ await performManagedSync(engine, OPTS);
+ expect(await bodyOf(engine, 'notes/a')).toContain('A later committed body.');
+ expect(await holdOf(engine, 'notes/a.md')).toBeNull();
+ }, { setup, databaseUrl }), 120_000);
+});