Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: batch tombstone base-hash evictions (#5532)

[._.]/ Adam Eivy5716918bfa47
diff --git a/server/services/creativeCommissions/feedbackStore.js b/server/services/creativeCommissions/feedbackStore.js
index 094de83149..b990282fea 100644
--- a/server/services/creativeCommissions/feedbackStore.js
+++ b/server/services/creativeCommissions/feedbackStore.js
@@ -33,6 +33,7 @@ import {
setSyncBaseHash,
deleteSyncBaseHash,
flushBaseHashes,
+ withBaseHashFlushBatch,
maybeJournalBeforeOverwrite,
} from '../../lib/conflictJournal.js';
import { emitRecordUpdated, emitRecordDeleted, autoSubscribeRecordToAllPeers } from '../sharing/recordEvents.js';
@@ -311,7 +312,9 @@ export async function mergeCommissionFeedbackFromSync(remoteRecords, { source =
/** Hard-remove tombstoned feedback older than the cutoff; evicts each pruned id's base hash. */
export async function pruneTombstonedCommissionFeedback(olderThanMs) {
const result = await feedbackStore().pruneTombstoned(olderThanMs);
- for (const id of result.ids || []) await deleteSyncBaseHash(COMMISSION_FEEDBACK_KIND, id).catch(() => {});
+ await withBaseHashFlushBatch(async () => {
+ for (const id of result.ids || []) await deleteSyncBaseHash(COMMISSION_FEEDBACK_KIND, id).catch(() => {});
+ });
return result;
}
diff --git a/server/services/creativeCommissions/feedbackStore.test.js b/server/services/creativeCommissions/feedbackStore.test.js
index e032c2b8c7..92f57fd472 100644
--- a/server/services/creativeCommissions/feedbackStore.test.js
+++ b/server/services/creativeCommissions/feedbackStore.test.js
@@ -1,4 +1,10 @@
-import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { describe, it, expect, vi, beforeEach, afterAll } from 'vitest';
+import { mkdtempSync, rmSync } from 'fs';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'commission-feedback-test-'));
+const writeCounter = vi.hoisted(() => ({ baseHash: 0 }));
// In-memory collectionStore (same posture as store.test.js) so CRUD + merge are
// exercised without the filesystem or Postgres.
@@ -14,20 +20,22 @@ const makeMemStore = () => ({
verifySchemaVersion: async () => ({ ok: true }),
});
vi.mock('../../lib/collectionStore.js', () => ({ createCollectionStore: () => makeMemStore() }));
-vi.mock('../../lib/fileUtils.js', () => ({ PATHS: { data: '/tmp/portos-test-feedback' } }));
+vi.mock('../../lib/fileUtils.js', async (importOriginal) => {
+ const actual = await importOriginal();
+ return {
+ ...actual,
+ PATHS: { ...actual.PATHS, data: TEST_DATA_ROOT },
+ atomicWrite: async (path, data) => {
+ if (typeof path === 'string' && path.endsWith('sync_base_hashes.json')) writeCounter.baseHash += 1;
+ return actual.atomicWrite(path, data);
+ },
+ };
+});
// Keep federation side-effects inert in this store-level unit test.
const emitRecordUpdated = vi.fn();
const emitRecordDeleted = vi.fn();
const autoSubscribeRecordToAllPeers = vi.fn(() => Promise.resolve());
vi.mock('../sharing/recordEvents.js', () => ({ emitRecordUpdated, emitRecordDeleted, autoSubscribeRecordToAllPeers }));
-vi.mock('../../lib/conflictJournal.js', () => ({
- contentHashForRecord: vi.fn(() => 'hash'),
- setSyncBaseHash: vi.fn(() => Promise.resolve()),
- deleteSyncBaseHash: vi.fn(() => Promise.resolve()),
- flushBaseHashes: vi.fn(() => Promise.resolve()),
- maybeJournalBeforeOverwrite: vi.fn(() => Promise.resolve()),
-}));
-
const {
recordFeedback,
listFeedbackForCommission,
@@ -41,8 +49,17 @@ const {
deleteCommissionFeedback,
backfillInlineFeedback,
} = await import('./feedbackStore.js');
-
-beforeEach(() => { feedbackRecords.clear(); vi.clearAllMocks(); });
+const cj = await import('../../lib/conflictJournal.js');
+
+beforeEach(() => {
+ feedbackRecords.clear();
+ rmSync(join(TEST_DATA_ROOT, 'sharing'), { recursive: true, force: true });
+ rmSync(join(TEST_DATA_ROOT, 'conflict-journal'), { recursive: true, force: true });
+ cj.__resetBaseHashCacheForTests();
+ writeCounter.baseHash = 0;
+ vi.clearAllMocks();
+});
+afterAll(() => rmSync(TEST_DATA_ROOT, { recursive: true, force: true }));
describe('recordFeedback + hydration', () => {
it('writes one federated record per reaction (deterministic id per run) and subscribes peers', async () => {
@@ -141,6 +158,35 @@ describe('federation facades', () => {
expect(feedbackRecords.has('cfeedback-run-A')).toBe(false);
});
+ it('prunes multiple tombstoned reactions with one base-hash write', async () => {
+ const oldOne = {
+ id: 'cfeedback-run-old-1', commissionId: 'c1', runId: 'run-old-1', rating: 'up',
+ note: '', tags: [], at: '2020-01-01T00:00:00.000Z', updatedAt: '2020-01-01T00:00:00.000Z',
+ deleted: true, deletedAt: '2020-01-01T00:00:00.000Z',
+ };
+ const oldTwo = {
+ ...oldOne, id: 'cfeedback-run-old-2', runId: 'run-old-2',
+ at: '2020-01-02T00:00:00.000Z', updatedAt: '2020-01-02T00:00:00.000Z',
+ deletedAt: '2020-01-02T00:00:00.000Z',
+ };
+ const newer = {
+ ...oldOne, id: 'cfeedback-run-new', runId: 'run-new',
+ at: '2099-01-01T00:00:00.000Z', updatedAt: '2099-01-01T00:00:00.000Z',
+ deletedAt: '2099-01-01T00:00:00.000Z',
+ };
+ await mergeCommissionFeedbackFromSync([oldOne, oldTwo, newer]);
+ expect(await cj.getSyncBaseHash('commissionFeedback', oldOne.id)).not.toBeNull();
+ expect(await cj.getSyncBaseHash('commissionFeedback', oldTwo.id)).not.toBeNull();
+
+ writeCounter.baseHash = 0;
+ const result = await pruneTombstonedCommissionFeedback(Date.parse('2030-01-01T00:00:00.000Z'));
+ expect(result).toEqual({ pruned: 2, ids: [oldOne.id, oldTwo.id] });
+ expect(writeCounter.baseHash).toBe(1);
+ expect(await cj.getSyncBaseHash('commissionFeedback', oldOne.id)).toBeNull();
+ expect(await cj.getSyncBaseHash('commissionFeedback', oldTwo.id)).toBeNull();
+ expect(feedbackRecords.has(newer.id)).toBe(true);
+ });
+
it('restores a tombstoned reaction from a snapshot, un-deleting it', async () => {
await recordFeedback({ commissionId: 'c1', runId: 'run-A', rating: 'up', note: 'x' });
await deleteCommissionFeedback('cfeedback-run-A');
diff --git a/server/services/moodBoard/db.js b/server/services/moodBoard/db.js
index 1bc48f78a9..d05d6a6684 100644
--- a/server/services/moodBoard/db.js
+++ b/server/services/moodBoard/db.js
@@ -39,6 +39,7 @@ import {
} from './logic.js';
import {
maybeJournalBeforeOverwrite, setSyncBaseHash, contentHashForRecord, flushBaseHashes, deleteSyncBaseHash,
+ withBaseHashFlushBatch,
} from '../../lib/conflictJournal.js';
// `data` JSONB is the whole record; name/created_at/updated_at mirror into
@@ -214,7 +215,9 @@ export async function pruneTombstonedBoards(olderThanMs) {
RETURNING id`,
[cutoffIso],
);
- for (const r of rows) await deleteSyncBaseHash('moodBoard', r.id);
+ await withBaseHashFlushBatch(async () => {
+ for (const r of rows) await deleteSyncBaseHash('moodBoard', r.id);
+ });
return { pruned: rows.length };
}
diff --git a/server/services/moodBoard/db.test.js b/server/services/moodBoard/db.test.js
index 77d90894cc..1563ea49b4 100644
--- a/server/services/moodBoard/db.test.js
+++ b/server/services/moodBoard/db.test.js
@@ -10,18 +10,27 @@
*/
import { describe, it, expect, afterAll, beforeAll, vi } from 'vitest';
+import { rmSync } from 'fs';
+import { join } from 'path';
import { checkHealth, ensureSchema, query, close } from '../../lib/db.js';
-
-// Stub the conflict-journal so mergeBoardsFromSync exercises its DB persist + LWW
-// decision WITHOUT writing real base-hash / journal files under data/ during the
-// test:db run (the pure LWW decision itself is pinned in logic.test.js).
-vi.mock('../../lib/conflictJournal.js', () => ({
- maybeJournalBeforeOverwrite: vi.fn().mockResolvedValue(undefined),
- setSyncBaseHash: vi.fn().mockResolvedValue(undefined),
- contentHashForRecord: vi.fn(() => 'test-hash'),
- flushBaseHashes: vi.fn().mockResolvedValue(undefined),
- deleteSyncBaseHash: vi.fn().mockResolvedValue(undefined),
-}));
+import { getSyncBaseHash, __resetBaseHashCacheForTests } from '../../lib/conflictJournal.js';
+
+const testState = vi.hoisted(() => ({ dataRoot: null, writeCounter: { baseHash: 0 } }));
+
+vi.mock('../../lib/fileUtils.js', async (importOriginal) => {
+ const actual = await importOriginal();
+ const { mkdtempSync } = await import('node:fs');
+ const { tmpdir } = await import('node:os');
+ testState.dataRoot ??= mkdtempSync(join(tmpdir(), 'mood-board-db-test-'));
+ return {
+ ...actual,
+ PATHS: { ...actual.PATHS, data: testState.dataRoot },
+ atomicWrite: async (path, data) => {
+ if (typeof path === 'string' && path.endsWith('sync_base_hashes.json')) testState.writeCounter.baseHash += 1;
+ return actual.atomicWrite(path, data);
+ },
+ };
+});
let dbReady = false;
let skipReason = '';
@@ -41,6 +50,8 @@ let skipReason = '';
if (!dbReady) console.log(`⏭️ moodBoard/db.test.js skipped: ${skipReason}`);
+afterAll(() => rmSync(testState.dataRoot, { recursive: true, force: true }));
+
describe.skipIf(!dbReady)('mood board DB round-trip', () => {
let db;
const created = [];
@@ -179,12 +190,27 @@ describe.skipIf(!dbReady)('mood board federation (#1564)', () => {
expect((await db.getBoard(board.id)).description).toBe('d');
});
- it('pruneTombstonedBoards hard-removes tombstones older than the cutoff', async () => {
- const id = `mb-fed-prune-${Date.now()}`;
- created.push(id);
- await db.mergeBoardsFromSync([remote(id, { updatedAt: '2026-06-23T00:00:00.000Z', deleted: true, deletedAt: '2026-06-23T00:00:00.000Z' })]);
- const res = await db.pruneTombstonedBoards(Date.parse('2030-01-01T00:00:00.000Z'));
- expect(res.pruned).toBeGreaterThanOrEqual(1);
- expect(await db.getBoard(id, { includeDeleted: true })).toBeNull();
+ it('pruneTombstonedBoards batches base-hash eviction for multiple tombstones', async () => {
+ await query(`DELETE FROM mood_boards WHERE id LIKE $1`, ['mb-fed-prune-%']);
+ const oldId = `mb-fed-prune-old-${Date.now()}`;
+ const oldIdTwo = `mb-fed-prune-old-two-${Date.now()}`;
+ const newId = `mb-fed-prune-new-${Date.now()}`;
+ created.push(oldId, oldIdTwo, newId);
+ await db.mergeBoardsFromSync([
+ remote(oldId, { updatedAt: '2000-01-02T00:00:00.000Z', deleted: true, deletedAt: '2000-01-01T00:00:00.000Z' }),
+ remote(oldIdTwo, { updatedAt: '2000-01-03T00:00:00.000Z', deleted: true, deletedAt: '2000-01-02T00:00:00.000Z' }),
+ remote(newId, { updatedAt: '2099-01-02T00:00:00.000Z', deleted: true, deletedAt: '2099-01-01T00:00:00.000Z' }),
+ ]);
+ expect(await getSyncBaseHash('moodBoard', oldId)).not.toBeNull();
+ expect(await getSyncBaseHash('moodBoard', oldIdTwo)).not.toBeNull();
+
+ testState.writeCounter.baseHash = 0;
+ const res = await db.pruneTombstonedBoards(Date.parse('2025-01-01T00:00:00.000Z'));
+ expect(res).toEqual({ pruned: 2 });
+ expect(testState.writeCounter.baseHash).toBe(1);
+ expect(await getSyncBaseHash('moodBoard', oldId)).toBeNull();
+ expect(await getSyncBaseHash('moodBoard', oldIdTwo)).toBeNull();
+ expect(await db.getBoard(newId, { includeDeleted: true })).not.toBeNull();
+ expect(await db.getBoard(oldId, { includeDeleted: true })).toBeNull();
});
});
diff --git a/server/services/musicVideo/projectsDB.js b/server/services/musicVideo/projectsDB.js
index cd2d38bce9..f865ee23d1 100644
--- a/server/services/musicVideo/projectsDB.js
+++ b/server/services/musicVideo/projectsDB.js
@@ -29,6 +29,7 @@ import {
} from './projectsLogic.js';
import {
maybeJournalBeforeOverwrite, setSyncBaseHash, contentHashForRecord, flushBaseHashes, deleteSyncBaseHash,
+ withBaseHashFlushBatch,
} from '../../lib/conflictJournal.js';
// `data` JSONB is the whole record; status/created_at/updated_at are a queryable
@@ -197,7 +198,9 @@ export async function pruneTombstonedProjects(olderThanMs) {
RETURNING id`,
[cutoffIso],
);
- for (const r of rows) await deleteSyncBaseHash('musicVideoProject', r.id);
+ await withBaseHashFlushBatch(async () => {
+ for (const r of rows) await deleteSyncBaseHash('musicVideoProject', r.id);
+ });
return { pruned: rows.length };
}
diff --git a/server/services/musicVideo/projectsDB.test.js b/server/services/musicVideo/projectsDB.test.js
new file mode 100644
index 0000000000..2ba9f2fd7d
--- /dev/null
+++ b/server/services/musicVideo/projectsDB.test.js
@@ -0,0 +1,100 @@
+/**
+ * PostgreSQL-backed round-trip for the Music Video project store.
+ *
+ * This suite runs only through the dedicated test database config. It keeps the
+ * fixture ids isolated and uses a temporary data root so the prune assertion
+ * can verify the conflict-journal side-store write without touching a live
+ * install's files.
+ */
+
+import { describe, it, expect, vi, afterAll, beforeAll, beforeEach } from 'vitest';
+import { rmSync } from 'fs';
+import { join } from 'path';
+import { checkHealth, ensureSchema, query, close } from '../../lib/db.js';
+import { getSyncBaseHash, __resetBaseHashCacheForTests } from '../../lib/conflictJournal.js';
+
+const testState = vi.hoisted(() => ({ dataRoot: null, writeCounter: { baseHash: 0 } }));
+
+vi.mock('../../lib/fileUtils.js', async (importOriginal) => {
+ const actual = await importOriginal();
+ const { mkdtempSync } = await import('node:fs');
+ const { tmpdir } = await import('node:os');
+ testState.dataRoot ??= mkdtempSync(join(tmpdir(), 'music-video-projects-db-test-'));
+ return {
+ ...actual,
+ PATHS: { ...actual.PATHS, data: testState.dataRoot },
+ atomicWrite: async (path, data) => {
+ if (typeof path === 'string' && path.endsWith('sync_base_hashes.json')) testState.writeCounter.baseHash += 1;
+ return actual.atomicWrite(path, data);
+ },
+ };
+});
+
+let dbReady = false;
+let skipReason = '';
+{
+ const health = await checkHealth().catch((e) => ({ connected: false, error: e?.message }));
+ if (!health.connected) {
+ skipReason = `Postgres not reachable (${health.error || 'no connection'})`;
+ } else {
+ await ensureSchema().catch(() => {});
+ const probe = await query(
+ `SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'music_video_projects') AS ok`,
+ ).catch(() => ({ rows: [{ ok: false }] }));
+ if (probe.rows?.[0]?.ok) dbReady = true;
+ else skipReason = 'music_video_projects table not present';
+ }
+}
+
+if (!dbReady) console.log(`⏭️ musicVideo/projectsDB.test.js skipped: ${skipReason}`);
+
+afterAll(() => rmSync(testState.dataRoot, { recursive: true, force: true }));
+
+const PRUNE_PREFIX = 'mv-issue-5532-prune-';
+const project = (id, deletedAt) => ({
+ id,
+ name: id,
+ status: 'draft',
+ scenes: [],
+ createdAt: deletedAt,
+ updatedAt: deletedAt,
+ deleted: true,
+ deletedAt,
+});
+
+describe.skipIf(!dbReady)('music video projects DB adapter', () => {
+ let db;
+
+ beforeAll(async () => { db = await import('./projectsDB.js'); });
+
+ beforeEach(async () => {
+ await query(`DELETE FROM music_video_projects WHERE id LIKE $1`, [`${PRUNE_PREFIX}%`]);
+ rmSync(join(testState.dataRoot, 'sharing'), { recursive: true, force: true });
+ rmSync(join(testState.dataRoot, 'conflict-journal'), { recursive: true, force: true });
+ __resetBaseHashCacheForTests();
+ testState.writeCounter.baseHash = 0;
+ });
+
+ afterAll(async () => {
+ await query(`DELETE FROM music_video_projects WHERE id LIKE $1`, [`${PRUNE_PREFIX}%`]).catch(() => {});
+ await close();
+ });
+
+ it('pruneTombstonedProjects batches base-hash eviction for multiple tombstones', async () => {
+ const oldOne = project(`${PRUNE_PREFIX}old-1`, '2000-01-01T00:00:00.000Z');
+ const oldTwo = project(`${PRUNE_PREFIX}old-2`, '2000-01-02T00:00:00.000Z');
+ const newer = project(`${PRUNE_PREFIX}new`, '2099-01-01T00:00:00.000Z');
+ await db.mergeProjectsFromSync([oldOne, oldTwo, newer]);
+ expect(await getSyncBaseHash('musicVideoProject', oldOne.id)).not.toBeNull();
+ expect(await getSyncBaseHash('musicVideoProject', oldTwo.id)).not.toBeNull();
+
+ testState.writeCounter.baseHash = 0;
+ const result = await db.pruneTombstonedProjects(Date.parse('2030-01-01T00:00:00.000Z'));
+ expect(result).toEqual({ pruned: 2 });
+ expect(testState.writeCounter.baseHash).toBe(1);
+ expect(await getSyncBaseHash('musicVideoProject', oldOne.id)).toBeNull();
+ expect(await getSyncBaseHash('musicVideoProject', oldTwo.id)).toBeNull();
+ expect(await db.getProject(newer.id, { includeDeleted: true })).not.toBeNull();
+ expect(await db.getProject(oldOne.id, { includeDeleted: true })).toBeNull();
+ });
+});
diff --git a/server/services/musicVideo/projectsFile.js b/server/services/musicVideo/projectsFile.js
index 0efa447cad..279216d085 100644
--- a/server/services/musicVideo/projectsFile.js
+++ b/server/services/musicVideo/projectsFile.js
@@ -26,6 +26,7 @@ import {
} from './projectsLogic.js';
import {
maybeJournalBeforeOverwrite, setSyncBaseHash, contentHashForRecord, flushBaseHashes, deleteSyncBaseHash,
+ withBaseHashFlushBatch,
} from '../../lib/conflictJournal.js';
const PROJECTS_FILE = join(PATHS.data, 'music-video-projects.json');
@@ -155,7 +156,9 @@ export async function pruneTombstonedProjects(olderThanMs) {
}
if (pruned.length === 0) return { pruned: 0 };
await saveAll(survivors);
- for (const id of pruned) await deleteSyncBaseHash('musicVideoProject', id);
+ await withBaseHashFlushBatch(async () => {
+ for (const id of pruned) await deleteSyncBaseHash('musicVideoProject', id);
+ });
return { pruned: pruned.length };
}
diff --git a/server/services/musicVideo/projectsFile.test.js b/server/services/musicVideo/projectsFile.test.js
index 1f09df97bf..3ba5c8dab4 100644
--- a/server/services/musicVideo/projectsFile.test.js
+++ b/server/services/musicVideo/projectsFile.test.js
@@ -12,16 +12,29 @@ import { tmpdir } from 'os';
import { join } from 'path';
const TEST_DATA_ROOT = mkdtempSync(join(tmpdir(), 'mv-projects-file-test-'));
+const writeCounter = vi.hoisted(() => ({ baseHash: 0 }));
vi.mock('../../lib/fileUtils.js', async (importOriginal) => {
const actual = await importOriginal();
- return { ...actual, PATHS: { ...actual.PATHS, data: TEST_DATA_ROOT } };
+ return {
+ ...actual,
+ PATHS: { ...actual.PATHS, data: TEST_DATA_ROOT },
+ atomicWrite: async (path, data) => {
+ if (typeof path === 'string' && path.endsWith('sync_base_hashes.json')) writeCounter.baseHash += 1;
+ return actual.atomicWrite(path, data);
+ },
+ };
});
const file = await import('./projectsFile.js');
+const cj = await import('../../lib/conflictJournal.js');
function reset() {
rmSync(join(TEST_DATA_ROOT, 'music-video-projects.json'), { force: true });
+ rmSync(join(TEST_DATA_ROOT, 'sharing'), { recursive: true, force: true });
+ rmSync(join(TEST_DATA_ROOT, 'conflict-journal'), { recursive: true, force: true });
+ cj.__resetBaseHashCacheForTests();
+ writeCounter.baseHash = 0;
}
beforeEach(reset);
afterAll(() => rmSync(TEST_DATA_ROOT, { recursive: true, force: true }));
@@ -119,20 +132,37 @@ describe('projectsFile federation (#1770)', () => {
expect(await file.getProject(p.id, { includeDeleted: true })).toMatchObject({ deleted: true });
});
- it('pruneTombstonedProjects hard-removes only old-enough tombstones', async () => {
+ it('pruneTombstonedProjects batches base-hash eviction for multiple tombstones', async () => {
const keep = await file.createProject({ name: 'Live' });
- // Insert an already-old tombstone via the sync insert path (insert applies
- // regardless of LWW), so its deletedAt sits far enough in the past to prune.
+ // Insert already-old tombstones via the sync insert path (insert applies
+ // regardless of LWW), so their deletedAt values sit far enough in the past
+ // to prune. The newer tombstone verifies the existing eligibility predicate.
await file.mergeProjectsFromSync([{
- id: 'mv-old-tomb', name: 'Old', status: 'draft', scenes: [],
+ id: 'mv-old-tomb-1', name: 'Old 1', status: 'draft', scenes: [],
createdAt: '2000-01-01T00:00:00Z', updatedAt: '2000-01-02T00:00:00Z',
deleted: true, deletedAt: '2000-01-01T00:00:00Z',
+ }, {
+ id: 'mv-old-tomb-2', name: 'Old 2', status: 'draft', scenes: [],
+ createdAt: '2000-01-02T00:00:00Z', updatedAt: '2000-01-03T00:00:00Z',
+ deleted: true, deletedAt: '2000-01-02T00:00:00Z',
+ }, {
+ id: 'mv-new-tomb', name: 'New', status: 'draft', scenes: [],
+ createdAt: '2099-01-01T00:00:00Z', updatedAt: '2099-01-02T00:00:00Z',
+ deleted: true, deletedAt: '2099-01-01T00:00:00Z',
}]);
+ expect(await cj.getSyncBaseHash('musicVideoProject', 'mv-old-tomb-1')).not.toBeNull();
+ expect(await cj.getSyncBaseHash('musicVideoProject', 'mv-old-tomb-2')).not.toBeNull();
+
+ writeCounter.baseHash = 0;
// A future cutoff prunes the old tombstone; a pre-tombstone cutoff would not.
expect((await file.pruneTombstonedProjects(Date.parse('1990-01-01T00:00:00Z'))).pruned).toBe(0);
+ expect(writeCounter.baseHash).toBe(0);
const res = await file.pruneTombstonedProjects(Date.parse('2010-01-01T00:00:00Z'));
- expect(res.pruned).toBe(1);
- expect(await file.listProjectIds({ includeDeleted: true })).toEqual([keep.id]);
+ expect(res).toEqual({ pruned: 2 });
+ expect(writeCounter.baseHash).toBe(1);
+ expect(await cj.getSyncBaseHash('musicVideoProject', 'mv-old-tomb-1')).toBeNull();
+ expect(await cj.getSyncBaseHash('musicVideoProject', 'mv-old-tomb-2')).toBeNull();
+ expect((await file.listProjectIds({ includeDeleted: true })).sort()).toEqual([keep.id, 'mv-new-tomb'].sort());
});
});
diff --git a/server/vitest.config.db.js b/server/vitest.config.db.js
index d0873e38a8..2adc513a1b 100644
--- a/server/vitest.config.db.js
+++ b/server/vitest.config.db.js
@@ -30,6 +30,7 @@ export const DB_TEST_INCLUDE = [
'services/catalogCanonProjection.test.js',
'services/catalogRefResolver.test.js',
'services/creativeDirector/projectsDB.test.js',
+ 'services/musicVideo/projectsDB.test.js',
'routes/catalog.test.js',
'scripts/run-db-migrations.test.js',
];