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 (claude): fix silent no-op in universe-tag repair (listIngredients returns {items}, not an array)

[._.]/ Adam Eivyc32069003db5
diff --git a/server/scripts/repairUniverseTags.js b/server/scripts/repairUniverseTags.js
index 9b89a73958..f15510e799 100644
--- a/server/scripts/repairUniverseTags.js
+++ b/server/scripts/repairUniverseTags.js
@@ -33,7 +33,11 @@ import { canonicalTagKey } from '../lib/catalogTypes.js';
import { listUniverses } from '../services/universeBuilder.js';
import * as catalogDB from '../services/catalogDB.js';
-const MARKER_VERSION = 1;
+// v2: v1 shipped a no-op pass (it read `listIngredients()` as a bare array and
+// broke before scanning any row, yet still wrote the v1 marker). Bumping to 2
+// makes installs that already recorded the broken v1 marker re-run the now-fixed
+// repair instead of skipping it forever.
+const MARKER_VERSION = 2;
const MARKER_FILENAME = 'catalog-universe-tags.applied.json';
async function readMarker() {
@@ -85,7 +89,8 @@ export async function repairUniverseTags({ force = false } = {}) {
const PAGE = 200;
let offset = 0;
for (;;) {
- const rows = await catalogDB.listIngredients({ limit: PAGE, offset });
+ // listIngredients returns `{ items, nextOffset }`, NOT a bare array.
+ const { items: rows } = await catalogDB.listIngredients({ limit: PAGE, offset });
if (!Array.isArray(rows) || rows.length === 0) break;
for (const ing of rows) {
totals.scanned++;
diff --git a/server/scripts/repairUniverseTags.test.js b/server/scripts/repairUniverseTags.test.js
index 0825b0685b..441cf46ad2 100644
--- a/server/scripts/repairUniverseTags.test.js
+++ b/server/scripts/repairUniverseTags.test.js
@@ -32,7 +32,12 @@ vi.mock('../services/universeBuilder.js', () => ({
}));
vi.mock('../services/catalogDB.js', () => ({
- listIngredients: vi.fn(async ({ limit, offset }) => dbState.ingredients.slice(offset, offset + limit)),
+ // Mirror the REAL contract: listIngredients returns `{ items, nextOffset }`,
+ // not a bare array. (A bare-array mock is what let the original no-op bug pass.)
+ listIngredients: vi.fn(async ({ limit, offset }) => {
+ const items = dbState.ingredients.slice(offset, offset + limit);
+ return { items, nextOffset: offset + items.length };
+ }),
updateIngredient: vi.fn(async (id, patch, ctx) => {
dbState.updates.push({ id, patch, ctx });
const row = dbState.ingredients.find((r) => r.id === id);
@@ -73,11 +78,11 @@ describe('repairUniverseTags', () => {
// Repair edits are tagged as a system 'sync' source, not a user edit.
expect(dbState.updates[0].ctx.source).toBe('sync');
// Marker written for idempotent skip next boot.
- expect(fsState.written.version).toBe(1);
+ expect(fsState.written.version).toBe(2);
});
it('skips entirely when the marker is already at the current version', async () => {
- fsState.marker = { version: 1, completedAt: '2026-01-01T00:00:00Z' };
+ fsState.marker = { version: 2, completedAt: '2026-01-01T00:00:00Z' };
dbState.ingredients = [{ id: 'cat-chr-1', tags: ['from-universe', 'universe:u-1'] }];
const result = await repairUniverseTags();
@@ -86,6 +91,20 @@ describe('repairUniverseTags', () => {
expect(dbState.updates).toHaveLength(0);
});
+ it('re-runs when the marker is at the older (broken-no-op) version', async () => {
+ // v1 shipped a no-op pass; an install that recorded the v1 marker must
+ // re-run the fixed repair, not skip forever.
+ fsState.marker = { version: 1, completedAt: '2026-01-01T00:00:00Z' };
+ dbState.ingredients = [{ id: 'cat-chr-1', tags: ['from-universe', 'universe:u-1', 'mentor'] }];
+
+ const result = await repairUniverseTags();
+
+ expect(result.skipped).toBe(false);
+ expect(result.stats.rewritten).toBe(1);
+ expect(dbState.ingredients[0].tags).toEqual(['mentor', 'My Cool Universe']);
+ expect(fsState.written.version).toBe(2);
+ });
+
it('re-runs the walk when forced even with a marker present', async () => {
fsState.marker = { version: 1 };
dbState.ingredients = [{ id: 'cat-chr-1', tags: ['from-universe', 'universe:u-1'] }];