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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: scope canonUsage 404 to ERR_NOT_FOUND, assert listIssues skipped
[._.]/ Adam Eivyb33db683286b
diff --git a/server/services/canonUsage.js b/server/services/canonUsage.jsindex 5e044b2892..eba4689027 100644--- a/server/services/canonUsage.js+++ b/server/services/canonUsage.js@@ -4,7 +4,7 @@// same pattern the comic-page renderer uses to decide which characters to// cite in the diffusion prompt.-import { getUniverse } from './universeBuilder.js';+import { getUniverse, ERR_NOT_FOUND } from './universeBuilder.js';import { listSeries } from './pipeline/series.js';import { listIssues } from './pipeline/issues.js';import {@@ -44,8 +44,13 @@ function corpusForIssue(issue) {*/export async function listLinkedSeriesNames(universeId) {// Validate the universe exists so 404s line up with the heavier endpoint.+ // Only translate the explicit not-found condition to 404; let I/O / parse+ // errors bubble so they don't masquerade as "not found".await getUniverse(universeId).catch((err) => {- throw new ServerError(err.message || 'Universe not found', { status: 404, code: 'UNIVERSE_NOT_FOUND' });+ if (err?.code === ERR_NOT_FOUND) {+ throw new ServerError('Universe not found', { status: 404, code: 'UNIVERSE_NOT_FOUND' });+ }+ throw err;});const allSeries = await listSeries();return allSeriesdiff --git a/server/services/canonUsage.test.js b/server/services/canonUsage.test.jsindex bc3f4acfa9..5f67f5bc7c 100644--- a/server/services/canonUsage.test.js+++ b/server/services/canonUsage.test.js@@ -8,9 +8,10 @@ const mockSeriesList = [];const mockIssuesBySeries = new Map();vi.mock('./universeBuilder.js', () => ({+ ERR_NOT_FOUND: 'NOT_FOUND',getUniverse: vi.fn(async (id) => {const u = mockUniverses.get(id);- if (!u) throw new Error(`Universe not found: ${id}`);+ if (!u) throw Object.assign(new Error(`Universe not found: ${id}`), { code: 'NOT_FOUND' });return u;}),}));@@ -23,6 +24,7 @@ vi.mock('./pipeline/issues.js', () => ({listIssues: vi.fn(async ({ seriesId }) => mockIssuesBySeries.get(seriesId) || []),}));+const { listIssues } = await import('./pipeline/issues.js');const { getUniverseCanonUsage, listLinkedSeriesNames } = await import('./canonUsage.js');beforeEach(() => {@@ -78,15 +80,18 @@ describe('canonUsage — listLinkedSeriesNames', () => {{ id: 'ser-c', name: 'Gamma', universeId: 'uni-other' },);// Seed issues to prove the thin variant skips the prose scan entirely —- // if it accidentally routed through canon-usage these would show up in- // the per-entry tally (which doesn't exist on this return shape).+ // the explicit listIssues assertion below is what locks that in; the+ // seeded data just ensures the assertion would catch a regression.mockIssuesBySeries.set('ser-a', [{ id: 'iss-1', stages: { prose: { output: 'long prose' } } }]);+ listIssues.mockClear();const result = await listLinkedSeriesNames('uni-1');expect(result).toEqual([{ id: 'ser-a', name: 'Alpha' },{ id: 'ser-b', name: 'Beta' },]);+ // The thin endpoint must NOT scan issues — that's the whole point.+ expect(listIssues).not.toHaveBeenCalled();});it('returns an empty array when no series link to the universe', async () => {