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
review: catalog Ask snippet walks registry snippetFallbackKeys; direct hybridSearchIngredients DB test
[._.]/ Adam Eivy0b9625b51abf
diff --git a/server/services/askService.js b/server/services/askService.jsindex 4c58707c57..bf92214186 100644--- a/server/services/askService.js+++ b/server/services/askService.js@@ -133,8 +133,14 @@ async function retrieveCatalog(question) {});return hits.map(({ ingredient: ing, rrfScore }) => {const t = getCatalogType(ing.type);- const primary = t?.primaryContentKey ? ing.payload?.[t.primaryContentKey] : null;- const snippetText = primary || ing.payload?.summary || ing.payload?.description || ing.name;+ // Walk the type's registry snippet keys (primaryContentKey first, then its+ // snippetFallbackKeys in order) so a match whose useful text lives in a+ // secondary field (personality / role / significance / notes) still gets a+ // meaningful snippet instead of falling through to name-only.+ const payload = ing.payload || {};+ const snippetKeys = [t?.primaryContentKey, ...(t?.snippetFallbackKeys || [])].filter(Boolean);+ const firstNonEmpty = snippetKeys.map((k) => payload[k]).find((v) => typeof v === 'string' && v.trim());+ const snippetText = firstNonEmpty || ing.name;return {kind: 'catalog',id: `catalog:${ing.type}:${ing.id}`,diff --git a/server/services/askService.test.js b/server/services/askService.test.jsindex fb254eca6d..0db1850a99 100644--- a/server/services/askService.test.js+++ b/server/services/askService.test.js@@ -103,11 +103,14 @@ describe('gatherSources', () => {catalogDB.hybridSearchIngredients.mockResolvedValue([{ ingredient: { id: 'cat-chr-1', type: 'character', name: 'Ada', tags: ['mentor'], payload: { physicalDescription: 'sharp eyes' } }, rrfScore: 0.9 },{ ingredient: { id: 'cat-idea-2', type: 'idea', name: 'Heist', tags: [], payload: { summary: 'a clockwork heist' } }, rrfScore: 0.6 },+ // Character whose only text is in a SECONDARY field (personality) — the+ // snippet should fall through the registry snippetFallbackKeys, not name.+ { ingredient: { id: 'cat-chr-3', type: 'character', name: 'Grim', tags: [], payload: { personality: 'brooding and loyal' } }, rrfScore: 0.5 },]);const sources = await askService.gatherSources('who is in my story');const catalog = sources.filter((s) => s.kind === 'catalog');- expect(catalog).toHaveLength(2);+ expect(catalog).toHaveLength(3);const ada = catalog.find((s) => s.id === 'catalog:character:cat-chr-1');expect(ada).toBeTruthy();expect(ada.title).toBe('Ada');@@ -115,6 +118,8 @@ describe('gatherSources', () => {expect(ada.href).toBe('/catalog/character/cat-chr-1');const idea = catalog.find((s) => s.id === 'catalog:idea:cat-idea-2');expect(idea.snippet).toBe('a clockwork heist'); // idea primaryContentKey = summary+ const grim = catalog.find((s) => s.id === 'catalog:character:cat-chr-3');+ expect(grim.snippet).toBe('brooding and loyal'); // fell through to personality, not name});it('still answers when the catalog retriever throws (isolated by allSettled)', async () => {diff --git a/server/services/catalogDB.test.js b/server/services/catalogDB.test.jsindex 9a3cb0ed6e..efe3716716 100644--- a/server/services/catalogDB.test.js+++ b/server/services/catalogDB.test.js@@ -275,4 +275,28 @@ describe.skipIf(!dbReady)('catalogDB (Postgres CRUD round-trip)', () => {expect(seqs[key]).toMatch(/^\d+$/);}});++ it('hybridSearchIngredients finds an ingredient by FTS, filters by type, and shapes RRF results', async () => {+ if (!requireDb('hybrid search')) return;+ const nonce = `zorblax${Date.now()}`; // unique token so FTS matches only our row+ const ing = await catalogDB.createIngredient({+ type: 'character', name: `Captain ${nonce}`,+ payload: { physicalDescription: `a weathered ${nonce} smuggler` },+ });+ createdIngredientIds.add(ing.id);++ // FTS-only path (no embedding) — the unique token matches exactly one row.+ const hits = await catalogDB.hybridSearchIngredients(nonce, null, { limit: 5 });+ const found = hits.find((h) => h.ingredient.id === ing.id);+ expect(found).toBeTruthy();+ expect(found.rrfScore).toBeGreaterThan(0);+ expect(found.searchMethod).toBe('fts'); // no embedding supplied → fts-only++ // type filter excludes the character row when searching a different type.+ const placeHits = await catalogDB.hybridSearchIngredients(nonce, null, { type: 'place', limit: 5 });+ expect(placeHits.some((h) => h.ingredient.id === ing.id)).toBe(false);++ // Empty query + no embedding → no signal → empty result (no throw).+ expect(await catalogDB.hybridSearchIngredients('', null, { limit: 5 })).toEqual([]);+ });});