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: harden semantic dedup — Jira key log prefix + embed-failure sentinel (#2262)
Adam Eivy77ade871ec73
diff --git a/server/services/autonomousJobs/layeredIntelligenceHandler.js b/server/services/autonomousJobs/layeredIntelligenceHandler.jsindex f763a366c3..e56d44164d 100644--- a/server/services/autonomousJobs/layeredIntelligenceHandler.js+++ b/server/services/autonomousJobs/layeredIntelligenceHandler.js@@ -223,7 +223,10 @@ async function isSemanticDuplicate(app, proposal, existingIssues, now) {const semantic = await checkSemanticDuplicate({ proposal, existingIssues, now })if (!semantic.available || !semantic.duplicate) return falseconst m = semantic.match- const ref = m?.number ? `#${m.number}` : (m?.slug || 'an existing issue')+ // `number` is a forge integer (#-prefixed) or a Jira string key (PROJ-123, no #).+ const ref = m?.number != null+ ? (typeof m.number === 'number' ? `#${m.number}` : String(m.number))+ : (m?.slug || 'an existing issue')const score = typeof m?.score === 'number' ? m.score.toFixed(2) : '?'console.log(`♻️ Layered Intelligence: ${app.name} proposal "${proposal.slug}" is a near-duplicate of ${ref} (score ${score}) — suppressed`)return truediff --git a/server/services/layeredIntelligence.js b/server/services/layeredIntelligence.jsindex 6253976937..aa2655da65 100644--- a/server/services/layeredIntelligence.js+++ b/server/services/layeredIntelligence.js@@ -579,12 +579,16 @@ export async function checkSemanticDuplicate({ proposal, existingIssues = [], no.slice(0, SEMANTIC_DEDUP_MAX_CANDIDATES);if (candidates.length === 0) return unavailable;- const proposalRes = await embed(issueEmbedSeed({ title: proposal.title, body: proposal.body }));+ // A rejected/throwing embed (transient provider blip, malformed response) must+ // degrade to the available:false sentinel — NOT reject through processApp and+ // mark the whole app run 'error'. `.catch(() => null)` mirrors this file's+ // fetchHttpSource / jira-search failure idiom (no non-boundary try/catch).+ const proposalRes = await embed(issueEmbedSeed({ title: proposal.title, body: proposal.body })).catch(() => null);if (!proposalRes?.success || !Array.isArray(proposalRes.embedding)) return unavailable;const embedded = [];for (const c of candidates) {- const res = await embed(issueEmbedSeed({ title: c.title, body: c.body }));+ const res = await embed(issueEmbedSeed({ title: c.title, body: c.body })).catch(() => null);if (res?.success && Array.isArray(res.embedding)) {embedded.push({ slug: c.slug || null, number: c.number ?? null, title: c.title || '', embedding: res.embedding });}diff --git a/server/services/layeredIntelligence.test.js b/server/services/layeredIntelligence.test.jsindex 6146ee62aa..9a096e04c5 100644--- a/server/services/layeredIntelligence.test.js+++ b/server/services/layeredIntelligence.test.js@@ -883,6 +883,13 @@ describe('checkSemanticDuplicate — I/O wrapper', () => {expect(res.duplicate).toBe(false);});+ it('degrades to unavailable (never rejects) when the embedder throws', async () => {+ const embed = vi.fn(async () => { throw new Error('provider down'); });+ const existing = [{ number: 3, title: 'Add widget', body: 'x', state: 'open' }];+ const res = await checkSemanticDuplicate({ proposal, existingIssues: existing, now: NOW, embed });+ expect(res).toEqual({ available: false, duplicate: false, match: null });+ });+it('flags a near-duplicate when a candidate embedding is close enough', async () => {const embed = vi.fn(async () => ok([1, 0, 0])); // proposal + candidate both identical → score 1const existing = [{ number: 3, slug: 'add-widget', title: 'Add widget', body: 'x', state: 'open' }];