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

address review (codex): only prune .imported artifacts; block on unverifiable records

Adam Eivy90f926779f07
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7bff0e74f9..83aec237cc 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -43,7 +43,7 @@
- Code quality: extracted the duplicated cron-expression validation in `cosJobRoutes.js` (job create/update) into a single `validateCronExpression()` helper, and unified the two slightly-divergent error messages.
- Code quality: replaced inline `8000` / `8` / `4` / `20 * 1024 * 1024` literals in the image-generation routes with named constants (`MAX_PROMPT_LENGTH`, `MAX_LORAS`, `MAX_REFERENCE_IMAGES`, `MAX_IMAGE_UPLOAD_BYTES`); the `referenceImageN` upload field list now derives from `MAX_REFERENCE_IMAGES` so it can't drift.
- Code quality: replaced the local `safeReadJson` reimplementation in `apps.js` with the shared `readJSONFile` helper from `fileUtils.js`, and named the repeated `1500` ms inter-action throttle in `agentActionExecutor.js` as `INTER_ACTION_DELAY_MS`.
-- **Legacy file→Postgres migration artifacts are now cleaned up automatically** — the file→DB migrations (#997, #1014–#1017, plus the split migrations 034–036) each parked their source data aside as a "one-release recovery source" (`data/universes.imported`, `pipeline-issues.imported`, `*.bak-NNN`, per-record `index.json.imported` / `manifest.imported.json`, etc.) but nothing ever removed them, so they accumulated in `./data` (several MB on a long-lived install) even though the authoritative copy now lives in PostgreSQL and the `pg_dump`. A new boot-time prune (`server/scripts/pruneImportedLegacyFiles.js`, registered in the ledger as migration 077) removes those copies once the database is provably authoritative — it deletes a domain's parked files **only** after verifying, by record identity, that every migrated record those files hold is still present in the database (it reads the record ids off the artifacts themselves — directory names and JSON `.id`s, including universe run logs and Writers Room draft versions — and checks those exact ids exist). Identity rather than a row count, so a wipe-and-restore to a *different* record set can't satisfy the check with substitute rows; a database missing any parked id keeps its recovery files and a later boot retries. The artifacts are intentionally still included in rsync backups while they remain on disk — during a blocked prune they're the only recovery source and the `pg_dump` is of the incomplete database, so a snapshot must keep them; once pruned they leave subsequent snapshots naturally. The Writers Room `.md` draft bodies (file-primary by design, not migrated to the database) are always preserved. The prune never runs under the `MEMORY_BACKEND=file` dev/test escape hatch.
+- **Legacy file→Postgres migration artifacts are now cleaned up automatically** — the file→DB migrations (#997, #1014–#1017) each parked their source data aside as a "one-release recovery source" (`data/universes.imported`, `pipeline-issues.imported`, per-record `index.json.imported` / `manifest.imported.json`, etc.) but nothing ever removed them, so they accumulated in `./data` (several MB on a long-lived install) even though the authoritative copy now lives in PostgreSQL and the `pg_dump`. A new boot-time prune (`server/scripts/pruneImportedLegacyFiles.js`, registered in the ledger as migration 077) removes those `.imported` copies once the database is provably authoritative — it deletes a domain's parked files **only** after verifying, by record identity, that every migrated record those files hold is still present in the database (it reads the record ids off the artifacts themselves — directory names and JSON `.id`s, including universe run logs and Writers Room draft versions — and checks those exact ids exist). Identity rather than a row count, so a wipe-and-restore to a *different* record set can't satisfy the check with substitute rows. Anything that can't be verified withholds the prune for that domain (a missing id, an unparseable or id-less parked record, or a still-pending migration), so recovery data is never deleted on a doubt; a later boot retries. The deeper `*.bak-NNN` monolith backups from the earlier file→file split migrations are intentionally left in place for manual cleanup — they can hold records the split skipped and soft-deleted records the live DB no longer has, so they're not safe to auto-verify. Nothing is excluded from rsync backups while it's on disk (during a blocked prune the parked files are the only recovery source and the `pg_dump` is of the incomplete database), and the Writers Room `.md` draft bodies (file-primary by design) are always preserved. The prune never runs under the `MEMORY_BACKEND=file` dev/test escape hatch.
## Fixed
diff --git a/docs/STORAGE.md b/docs/STORAGE.md
index 88c0972511..d9f25984db 100644
--- a/docs/STORAGE.md
+++ b/docs/STORAGE.md
@@ -100,7 +100,7 @@ Defaulting a new Create feature to a fresh `data/*.json` file is the anti-patter
### Legacy migration-source cleanup
-Each file→Postgres migrator parks its source aside (`<domain>.imported`, per-record `index.json.imported` / `manifest.imported.json`, split-migration `*.bak-NNN`) instead of deleting it, as a one-release recovery copy. `server/scripts/pruneImportedLegacyFiles.js` (run at boot from `server/index.js`, after every store's file→DB warm, registered in the ledger by `scripts/migrations/077-prune-imported-legacy-files.js`) removes those copies **only** when it has verified, by **record identity**, that every migrated record those artifacts hold is still present in the database. It reads the record ids straight off the parked artifacts — the `.imported` directory names, or the parsed JSON `.id` (the creative-director export, each writers-room manifest/folder/exercise, the universe `config.runs[]`, each manifest's `drafts[]`) — and checks those exact ids exist via `WHERE id = ANY(...)`. Identity rather than a row count, because a count can be satisfied by unrelated rows after a wipe+restore to a different record set (and the migrators' `imported` count comes from `INSERT … ON CONFLICT DO NOTHING`, so it can undercount). A wiped or partially-restored DB missing **any** parked id keeps its recovery files and a future boot retries. These artifacts are deliberately **not** excluded from rsync backups: while a prune is blocked they are the only recovery source and `pg_dump` is capturing the incomplete DB, so a snapshot must keep them — once pruned from disk they leave subsequent snapshots naturally.
+Each file→Postgres migrator parks its source aside (`<domain>.imported`, per-record `index.json.imported` / `manifest.imported.json`) instead of deleting it, as a one-release recovery copy. `server/scripts/pruneImportedLegacyFiles.js` (run at boot from `server/index.js`, after every store's file→DB warm, registered in the ledger by `scripts/migrations/077-prune-imported-legacy-files.js`) removes the **`.imported`** copies **only** when it has verified, by **record identity**, that every migrated record those artifacts hold is still present in the database. It reads the record ids straight off the parked artifacts — the `.imported` directory names, or the parsed JSON `.id` (the creative-director export, each writers-room manifest/folder/exercise, the universe `config.runs[]`, each manifest's `drafts[]`) — and checks those exact ids exist via `WHERE id = ANY(...)`. Identity rather than a row count, because a count can be satisfied by unrelated rows after a wipe+restore to a different record set (and the migrators' `imported` count comes from `INSERT … ON CONFLICT DO NOTHING`, so it can undercount). Anything that can't be verified withholds the whole domain's prune: a missing id, a present-but-unparseable artifact, an id-less record, or a domain whose migration is still pending (legacy source on disk, no marker). The prune deliberately does **not** touch the deeper `*.bak-NNN` monolith backups (the file→file split migrations 034–036) or the file-split backups (037 history, 059 media-collections): those predate the DB, can hold records the split migrator *skipped*, and carry soft-deleted records the live DB legitimately lacks, so they're neither identity-verifiable nor safe to auto-delete — they're left for manual cleanup. None of these artifacts are excluded from rsync backups: while a prune is blocked they are the only recovery source and `pg_dump` is capturing the incomplete DB, so a snapshot must keep them — once pruned from disk they leave subsequent snapshots naturally.
---
diff --git a/scripts/migrations/077-prune-imported-legacy-files.js b/scripts/migrations/077-prune-imported-legacy-files.js
index 4200b4005f..24c70c5e61 100644
--- a/scripts/migrations/077-prune-imported-legacy-files.js
+++ b/scripts/migrations/077-prune-imported-legacy-files.js
@@ -3,16 +3,17 @@
*
* Every file→DB migrator (universes, pipeline-issues/series, story-builder,
* writers-room, creative-director) renames its source aside — `.imported` /
- * `index.json.imported` / `manifest.imported.json` — and the split migrations
- * (034–036) left `.bak-NNN` copies, kept "as a recovery source for at least one
- * release." Nothing ever removed them, so they linger in ./data (multiple MB on
- * a long-lived install) and ride into every rsync snapshot even though the
- * authoritative copy is now in Postgres + the pg_dump.
+ * `index.json.imported` / `manifest.imported.json` — kept "as a recovery source
+ * for at least one release." Nothing ever removed them, so they linger in ./data
+ * (multiple MB on a long-lived install) even though the authoritative copy is now
+ * in Postgres + the pg_dump. (The deeper `.bak-NNN` monolith backups from the
+ * file→file split migrations 034–036 are intentionally NOT pruned — see the
+ * SCOPE note in pruneImportedLegacyFiles.js.)
*
- * The actual prune reads Postgres row counts (to confirm the DB is authoritative
- * before deleting a recovery copy), but the `scripts/migrations/` runner runs
- * BEFORE the DB pool is up — the same reason migrations 048–053 are boot-time +
- * stub-registered. So the prune runs at boot from
+ * The actual prune verifies record identity in Postgres (every parked record id
+ * still present) before deleting a recovery copy, but the `scripts/migrations/`
+ * runner runs BEFORE the DB pool is up — the same reason migrations 048–053 are
+ * boot-time + stub-registered. So the prune runs at boot from
* `server/scripts/pruneImportedLegacyFiles.js` (after ensureSchema + every
* store's file→DB warm import), marker-gated in `data/legacy-prune.applied.json`,
* with a count-vs-marker guard that withholds deletion when the live row count
diff --git a/server/scripts/pruneImportedLegacyFiles.js b/server/scripts/pruneImportedLegacyFiles.js
index eaf39f48f2..ee131a638e 100644
--- a/server/scripts/pruneImportedLegacyFiles.js
+++ b/server/scripts/pruneImportedLegacyFiles.js
@@ -44,9 +44,11 @@
* A wiped / partially-restored DB that is missing ANY parked id WITHHOLDS the
* whole domain's prune and leaves the completion marker unwritten, so a future
* boot retries once the DB is whole. Two more conditions also withhold: (a) a
- * parked artifact that EXISTS but can't be read/parsed (truncated after a crash,
- * hand-edited) blocks its domain rather than being mistaken for "zero records"
- * and deleted; (b) a domain whose migration is still PENDING — its legacy source
+ * parked artifact that EXISTS but can't be turned into a verifiable id set —
+ * unreadable/truncated, wrong top-level shape, or an id-less record (one the
+ * original migrator may have SKIPPED and parked) — blocks its domain rather than
+ * being mistaken for "zero records" and deleted; (b) a domain whose migration is
+ * still PENDING — its legacy source
* is on disk but no marker was stamped (migration failed or hasn't run) — blocks
* the GLOBAL completion marker, so a later boot (after the source is repaired and
* finally parked) still prunes it instead of skipping forever via the applied
@@ -54,9 +56,19 @@
* server/index.js, so it never runs under the MEMORY_BACKEND=file escape hatch
* (no DB → no prune → recovery files kept).
*
- * File-split backups (037 history.json, 059 media-collections.json) are NOT a
- * Postgres move — their successors live on disk — so they use a successor-exists
- * gate instead of id verification.
+ * SCOPE — only the `.imported` file→DB artifacts are pruned. The `.bak-NNN`
+ * monolith backups (the file→FILE split migrations 034–036) and the file-split
+ * backups (037 history.json, 059 media-collections.json) are deliberately LEFT
+ * for manual cleanup: they are a deeper, separate recovery layer that can hold
+ * records the split migrator SKIPPED (invalid records `makeSplitMigration`
+ * leaves only in the `.bak` file), and they predate the DB so their record set
+ * is a superset of (and not identity-verifiable against) the live DB — e.g.
+ * `universe-builder.json.bak-034` carries 30 universes incl. soft-deleted ones
+ * the DB legitimately won't have, so any id check against the DB would block
+ * forever. Auto-deleting them unverified would risk losing skipped records;
+ * verifying them is impossible. So we don't touch them. The big wins
+ * (`universes.imported`, `pipeline-issues.imported` — multiple MB each) are
+ * still pruned.
*
* Idempotent: `rm({ recursive: true, force: true })` no-ops on already-removed
* paths, and a marker in `data/legacy-prune.applied.json` skips the walk once a
@@ -108,24 +120,44 @@ async function idsFromSubdirs(base, dir) {
.map((e) => e.name);
}
+// Map array elements to their string `.id`, BLOCKING (throw) on any element
+// that lacks one. An unidentifiable record can't be verified against the DB, so
+// treating it as "not there" and pruning anyway could delete the only copy of a
+// record the original migrator skipped — block the domain instead.
+function idsOrBlock(arr, label) {
+ return arr.map((r, i) => {
+ if (!r || typeof r.id !== 'string') {
+ throw new ParkedArtifactUnreadable(`${label}: record ${i} has no string id`);
+ }
+ return r.id;
+ });
+}
+
// `.id` of every element of a top-level JSON array file (the CD export, and the
// writers-room folders.imported.json / exercises.imported.json bare arrays).
-// A present-but-corrupt file throws (blocks the domain); absent → no ids.
+// Present-but-corrupt OR wrong-shape OR any id-less record throws (blocks the
+// domain); absent → no ids.
async function idsFromJsonArray(base, file) {
const arr = await readParkedJson(base, file);
- return Array.isArray(arr) ? arr.map((r) => r?.id).filter((id) => typeof id === 'string') : [];
+ if (arr === null) return [];
+ if (!Array.isArray(arr)) throw new ParkedArtifactUnreadable(`${file}: expected a JSON array`);
+ return idsOrBlock(arr, file);
}
// Universe run ids: the type-level index.json's `config.runs[]`, each `{ id }`.
// (migrateUniversesToDB reads runs from `universes.imported/index.json`.)
async function universeRunIds(base) {
- const typeIndex = await readParkedJson(base, 'universes.imported/index.json');
- const runs = Array.isArray(typeIndex?.config?.runs) ? typeIndex.config.runs : [];
- return runs.map((r) => r?.id).filter((id) => typeof id === 'string');
+ const file = 'universes.imported/index.json';
+ const typeIndex = await readParkedJson(base, file);
+ if (typeIndex === null) return [];
+ const runs = typeIndex?.config?.runs;
+ if (runs == null) return []; // no runs key → no run history was parked
+ if (!Array.isArray(runs)) throw new ParkedArtifactUnreadable(`${file}: config.runs is not an array`);
+ return idsOrBlock(runs, `${file}#config.runs`);
}
// Writers-room work ids + draft-version ids, read from each parked manifest.
-// A present-but-corrupt manifest throws (blocks the domain).
+// A present-but-corrupt manifest, or one with an id-less work / draft, throws.
async function writersRoomManifestIds(base) {
const worksDir = 'writers-room/works';
const subdirs = await readdir(join(base, worksDir), { withFileTypes: true }).catch(() => []);
@@ -133,10 +165,15 @@ async function writersRoomManifestIds(base) {
const draftIds = [];
for (const entry of subdirs) {
if (!entry.isDirectory()) continue;
- const manifest = await readParkedJson(base, join(worksDir, entry.name, 'manifest.imported.json'));
- if (typeof manifest?.id === 'string') workIds.push(manifest.id);
- if (Array.isArray(manifest?.drafts)) {
- for (const d of manifest.drafts) if (typeof d?.id === 'string') draftIds.push(d.id);
+ const file = join(worksDir, entry.name, 'manifest.imported.json');
+ const manifest = await readParkedJson(base, file);
+ if (manifest === null) continue; // no parked manifest in this dir
+ if (typeof manifest.id !== 'string') throw new ParkedArtifactUnreadable(`${file}: work has no string id`);
+ workIds.push(manifest.id);
+ const drafts = manifest.drafts;
+ if (drafts != null) {
+ if (!Array.isArray(drafts)) throw new ParkedArtifactUnreadable(`${file}: drafts is not an array`);
+ draftIds.push(...idsOrBlock(drafts, `${file}#drafts`));
}
}
return { workIds, draftIds };
@@ -190,7 +227,7 @@ const DB_DOMAINS = [
{ table: 'universe_runs', ids: await universeRunIds(base) },
],
pending: (base) => pathExists(join(base, 'universes')),
- artifacts: ['universes.imported', 'universe-builder.json.bak-034'],
+ artifacts: ['universes.imported'],
},
{
label: 'pipeline-issues',
@@ -199,7 +236,7 @@ const DB_DOMAINS = [
{ table: 'pipeline_issues', ids: await idsFromSubdirs(base, 'pipeline-issues.imported') },
],
pending: (base) => pathExists(join(base, 'pipeline-issues')),
- artifacts: ['pipeline-issues.imported', 'pipeline-issues.json.bak-035'],
+ artifacts: ['pipeline-issues.imported'],
},
{
label: 'pipeline-series',
@@ -211,7 +248,7 @@ const DB_DOMAINS = [
{ table: 'pipeline_series', ids: await idsFromSubdirsWithLeaf(base, 'pipeline-series', 'index.json.imported') },
],
pending: pipelineSeriesPending,
- artifacts: ['pipeline-series.json.bak-036'],
+ artifacts: [],
nestedGlobs: [{ baseDir: 'pipeline-series', leaf: 'index.json.imported' }],
},
{
@@ -252,15 +289,6 @@ const DB_DOMAINS = [
},
];
-// File-split backups: data reshaped file→file (NOT moved to Postgres), so they
-// gate on the reshaped successor existing on disk. `backupPrefix` is a prefix:
-// migration 037/059 normally write the bare `.bak-NNN`, but on a re-run
-// collision they append `-<timestamp>`, so match the prefix to catch those too.
-const FILE_SPLIT_BACKUPS = [
- { label: 'history', backupPrefix: 'history.json.bak-037', successor: 'history.jsonl' },
- { label: 'media-collections', backupPrefix: 'media-collections.json.bak-059', successor: 'media-collections' },
-];
-
async function pathExists(p) {
return stat(p).then(() => true, () => false);
}
@@ -313,17 +341,6 @@ async function removeNestedGlob(base, baseDir, leaf) {
return removed;
}
-// Remove every top-level entry of `base` whose name starts with `prefix` (the
-// bare `.bak-NNN` plus any `-<timestamp>` re-run collision variant).
-async function removeByPrefix(base, prefix) {
- const entries = await readdir(base).catch(() => []);
- let removed = 0;
- for (const name of entries) {
- if (name.startsWith(prefix) && await removeUnder(base, name)) removed++;
- }
- return removed;
-}
-
/**
* @param {object} [opts]
* @param {boolean} [opts.force] - re-run even if the marker is current (tests/admin).
@@ -399,17 +416,6 @@ export async function pruneImportedLegacyFiles({ force = false, db, dataDir } =
}
}
- // File-split backups: prune only when the reshaped successor is present on
- // disk (proof the split landed). Absent successor → leave the backup alone.
- for (const item of FILE_SPLIT_BACKUPS) {
- if (!await pathExists(join(base, item.successor))) continue;
- const removed = await removeByPrefix(base, item.backupPrefix);
- if (removed > 0) {
- totals.removed += removed;
- totals.pruned.push(item.label);
- }
- }
-
// Only stamp the completion marker on a clean pass with NO blocked domain —
// a block means a future boot should retry (same logic as repairUniverseTags
// withholding its marker on an incomplete pass).
diff --git a/server/scripts/pruneImportedLegacyFiles.test.js b/server/scripts/pruneImportedLegacyFiles.test.js
index a849de94b8..9acfb2f316 100644
--- a/server/scripts/pruneImportedLegacyFiles.test.js
+++ b/server/scripts/pruneImportedLegacyFiles.test.js
@@ -58,17 +58,37 @@ describe('pruneImportedLegacyFiles', () => {
it('prunes a domain when every parked record id is present in the DB', async () => {
await writeJSON(join(dataDir, 'universes.migrated.json'), { imported: 2, runs: 1 });
await seedUniverses(['u1', 'u2'], ['r1']);
+ // The .bak-034 monolith is a deeper recovery layer and is intentionally NOT
+ // pruned — it must survive the prune.
await writeFile(join(dataDir, 'universe-builder.json.bak-034'), 'legacy', 'utf-8');
const res = await pruneImportedLegacyFiles({ dataDir, db: stubDb({ universes: ['u1', 'u2'], universe_runs: ['r1'] }) });
expect(res.skipped).toBe(false);
expect(await exists(join(dataDir, 'universes.imported'))).toBe(false);
- expect(await exists(join(dataDir, 'universe-builder.json.bak-034'))).toBe(false);
+ expect(await exists(join(dataDir, 'universe-builder.json.bak-034'))).toBe(true); // kept
expect(res.markerWritten).toBe(true);
expect(await exists(join(dataDir, 'legacy-prune.applied.json'))).toBe(true);
});
+ it('does NOT delete the .bak-NNN monolith or file-split backups (deeper recovery layer)', async () => {
+ await writeJSON(join(dataDir, 'pipeline-issues.migrated.json'), { imported: 1 });
+ const imp = join(dataDir, 'pipeline-issues.imported');
+ await mkdir(join(imp, 'iss-1'), { recursive: true });
+ await writeFile(join(dataDir, 'pipeline-issues.json.bak-035'), 'monolith', 'utf-8');
+ await writeFile(join(dataDir, 'history.json.bak-037'), 'x', 'utf-8');
+ await writeFile(join(dataDir, 'history.jsonl'), '', 'utf-8');
+
+ const res = await pruneImportedLegacyFiles({ dataDir, db: stubDb({ pipeline_issues: ['iss-1'] }) });
+
+ // The .imported tree is pruned…
+ expect(await exists(imp)).toBe(false);
+ // …but every .bak backup survives for manual recovery.
+ expect(await exists(join(dataDir, 'pipeline-issues.json.bak-035'))).toBe(true);
+ expect(await exists(join(dataDir, 'history.json.bak-037'))).toBe(true);
+ expect(res.markerWritten).toBe(true);
+ });
+
it('WITHHOLDS prune + marker when a parked universe id is missing (wiped/restored DB)', async () => {
await writeJSON(join(dataDir, 'universes.migrated.json'), { imported: 2, runs: 0 });
await seedUniverses(['u1', 'u2']);
@@ -242,28 +262,28 @@ describe('pruneImportedLegacyFiles', () => {
expect(await exists(join(dataDir, 'creative-director-projects.json.imported'))).toBe(false);
});
- it('prunes a file-split backup only when its successor exists', async () => {
- await writeFile(join(dataDir, 'history.json.bak-037'), 'x', 'utf-8');
- await writeFile(join(dataDir, 'history.jsonl'), '', 'utf-8');
- // media-collections: successor ABSENT → backup kept.
- await writeFile(join(dataDir, 'media-collections.json.bak-059'), 'x', 'utf-8');
+ it('BLOCKS a domain whose parked array has an id-less record (skipped by the original migrator)', async () => {
+ // A record with no string id can't be verified against the DB; treating it
+ // as absent and pruning would lose the only copy of a record the migrator
+ // skipped. Must block the domain.
+ await writeJSON(join(dataDir, 'creative-director-projects.migrated.json'), { imported: 1 });
+ await writeJSON(join(dataDir, 'creative-director-projects.json.imported'), [{ id: 'cd-1' }, { name: 'no-id project' }]);
- const res = await pruneImportedLegacyFiles({ dataDir, db: stubDb({}) });
+ const res = await pruneImportedLegacyFiles({ dataDir, db: stubDb({ creative_director_projects: ['cd-1'] }) });
- expect(await exists(join(dataDir, 'history.json.bak-037'))).toBe(false);
- expect(await exists(join(dataDir, 'media-collections.json.bak-059'))).toBe(true);
- expect(res.markerWritten).toBe(true);
+ expect(res.blocked).toBe(1);
+ expect(res.markerWritten).toBe(false);
+ expect(await exists(join(dataDir, 'creative-director-projects.json.imported'))).toBe(true);
});
- it('prunes timestamped file-split backup variants (re-run collision suffix)', async () => {
- await writeFile(join(dataDir, 'history.json.bak-037'), 'x', 'utf-8');
- await writeFile(join(dataDir, 'history.json.bak-037-1717000000000'), 'x', 'utf-8');
- await writeFile(join(dataDir, 'history.jsonl'), '', 'utf-8');
+ it('BLOCKS a domain whose parked JSON has the wrong top-level shape', async () => {
+ await writeJSON(join(dataDir, 'creative-director-projects.migrated.json'), { imported: 1 });
+ await writeJSON(join(dataDir, 'creative-director-projects.json.imported'), { not: 'an array' });
- await pruneImportedLegacyFiles({ dataDir, db: stubDb({}) });
+ const res = await pruneImportedLegacyFiles({ dataDir, db: stubDb({ creative_director_projects: ['cd-1'] }) });
- expect(await exists(join(dataDir, 'history.json.bak-037'))).toBe(false);
- expect(await exists(join(dataDir, 'history.json.bak-037-1717000000000'))).toBe(false);
+ expect(res.blocked).toBe(1);
+ expect(await exists(join(dataDir, 'creative-director-projects.json.imported'))).toBe(true);
});
it('is marker-gated: a current marker no-ops without touching the DB', async () => {