Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(sync): exclude company cursors from checkpoint_moved; move the serial checkpoint fixture outside the run (#6834)
garrytand63acbf0e25f
diff --git a/src/core/persistence/managed-sync-orphans.ts b/src/core/persistence/managed-sync-orphans.tsindex 419c8c7371..c4f1a73ad0 100644--- a/src/core/persistence/managed-sync-orphans.ts+++ b/src/core/persistence/managed-sync-orphans.ts@@ -80,10 +80,11 @@ interface CursorRow {/*** #6834: the cursor `c` (of source `s`) stands at its checkpoint, which ended refused because `last_commit` moved, and the- * source now records a commit that is neither the cursor's start nor its target. Shared by the classification and the+ * source now records a commit that is neither the cursor's start nor its target. A company-brain cursor records its+ * approval and is never one. Shared by the classification and the* retirement's re-check, so both read the same rule. `$msg` is the moved-checkpoint message parameter.*/-const checkpointMovedSql = (msg: string) => `(c.completed_keys->0->'pending'->'intent'->>'kind'='managed_sync_checkpoint'+const checkpointMovedSql = (msg: string) => `(c.completed_keys->0->'pending'->'intent'->>'kind'='managed_sync_checkpoint' AND c.completed_keys->0->>'companyReceiptId' IS NULLAND (c.completed_keys->0->>'index')::int>=(c.completed_keys->0->>'total')::intAND s.last_commit IS DISTINCT FROM c.completed_keys->0->>'from' AND s.last_commit IS DISTINCT FROM c.completed_keys->0->>'target'AND EXISTS(SELECT 1 FROM persistence_requests m WHERE m.source_id=s.id AND m.request_id=(c.completed_keys->0->'pending'->>'requestId')::uuiddiff --git a/test/persistence-sync-failures.serial.test.ts b/test/persistence-sync-failures.serial.test.tsindex 3bd0d8281c..783b78aa39 100644--- a/test/persistence-sync-failures.serial.test.ts+++ b/test/persistence-sync-failures.serial.test.ts@@ -301,7 +301,9 @@ test('checkpoint, discovery, and freeze failures remain diagnosable without a ficonst f = await fixture(engine, { 'note.md': 'A stable observation before checkpoint.\n' });const options = { sourceId: f.id, noPull: true };expect((await performManagedSync(engine, options, { maxPages: 1, maxMs: 1000 })).status).toBe('partial');- await engine.transaction(tx => withCoordinatedWrite(tx, [f.id], () => tx.executeRaw('UPDATE sources SET last_commit=$2 WHERE id=$1', [f.id, f.head]), TEST_WRITE_ATTRIBUTION));+ // #6834: the checkpoint moves to a commit outside the run (the fixture's empty initial commit); one moved to the run's own target is finished by the next sync.+ const outside = execFileSync('git', ['-C', f.root, 'rev-parse', 'HEAD~1'], { encoding: 'utf8' }).trim();+ await engine.transaction(tx => withCoordinatedWrite(tx, [f.id], () => tx.executeRaw('UPDATE sources SET last_commit=$2 WHERE id=$1', [f.id, outside]), TEST_WRITE_ATTRIBUTION));const blocked = await performManagedSync(engine, options);expect(blocked).toEqual(expect.objectContaining({ status: 'blocked_by_failures', failures: [expect.objectContaining({ path: '<checkpoint>', phase: 'checkpoint', code: 'revision_conflict' })] }));expect(await performManagedSync(engine, options)).toEqual(blocked);