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
test: reuse shared makeReadMock in new memory tests; trim verbose gate comment (#1826)
[._.]/ Adam Eivyd17c23315128
diff --git a/server/services/memory.test.js b/server/services/memory.test.jsindex 84839ea5e0..6b02b33520 100644--- a/server/services/memory.test.js+++ b/server/services/memory.test.js@@ -119,6 +119,15 @@ describe('memory service', () => {existsSync.mockReturnValue(true);});+ // Shared readJSONFile mock builder: routes memory.json / index.json / embeddings.json+ // reads to the supplied fixtures, falling back to the default for everything else.+ const makeReadMock = (memory, index, embeddings) => (path, def) => {+ if (path.includes('memory.json')) return Promise.resolve(memory ? { ...memory } : def);+ if (path.includes('index.json')) return Promise.resolve(index || def);+ if (path.includes('embeddings.json')) return Promise.resolve(embeddings || def);+ return Promise.resolve(def);+ };+// ===========================================================================// createMemory// ===========================================================================@@ -522,11 +531,7 @@ describe('memory service', () => {// Absent-vs-cleared: clearing content to "" is an intentional edit and must// refresh the (now-empty) summary, not leave the stale one behind (#1826).const mockMemory = { id: 'mem-1', type: 'fact', content: 'old', summary: 'old summary', category: 'other', tags: [], importance: 0.5, relatedMemories: [], status: 'active', sourceAppId: null };- readJSONFile.mockImplementation((path, def) => {- if (path.includes('memory.json')) return Promise.resolve({ ...mockMemory });- if (path.includes('index.json')) return Promise.resolve({ version: 1, lastUpdated: '', count: 1, memories: [{ id: 'mem-1', type: 'fact', category: 'other', tags: [], summary: 'old summary', importance: 0.5, createdAt: '', status: 'active', sourceAppId: null }] });- return Promise.resolve(def);- });+ readJSONFile.mockImplementation(makeReadMock(mockMemory, { version: 1, memories: [{ id: 'mem-1', status: 'active' }] }));const result = await updateMemory('mem-1', { content: '' });@@ -538,11 +543,7 @@ describe('memory service', () => {// The string-typed gate must keep a content-less update out of generateSummary,// which would throw on `undefined.length` (#1826).const mockMemory = { id: 'mem-1', type: 'fact', content: 'old', summary: 'old summary', category: 'other', tags: [], importance: 0.5, relatedMemories: [], status: 'active', sourceAppId: null };- readJSONFile.mockImplementation((path, def) => {- if (path.includes('memory.json')) return Promise.resolve({ ...mockMemory });- if (path.includes('index.json')) return Promise.resolve({ version: 1, lastUpdated: '', count: 1, memories: [{ id: 'mem-1', type: 'fact', category: 'other', tags: [], summary: 'old summary', importance: 0.5, createdAt: '', status: 'active', sourceAppId: null }] });- return Promise.resolve(def);- });+ readJSONFile.mockImplementation(makeReadMock(mockMemory, { version: 1, memories: [{ id: 'mem-1', status: 'active' }] }));const result = await updateMemory('mem-1', { status: 'archived' });@@ -589,11 +590,7 @@ describe('memory service', () => {// document stops matching its old terms — the falsy-gated version skipped// the reindex and left the old text searchable (#1826).const mockMemory = { id: 'mem-1', type: 'fact', content: 'searchable old text', summary: 'old', category: 'other', tags: [], importance: 0.5, relatedMemories: [], status: 'active', sourceAppId: null };- readJSONFile.mockImplementation((path, def) => {- if (path.includes('memory.json')) return Promise.resolve({ ...mockMemory });- if (path.includes('index.json')) return Promise.resolve({ version: 1, lastUpdated: '', count: 1, memories: [{ id: 'mem-1', type: 'fact', category: 'other', tags: [], summary: 'old', importance: 0.5, createdAt: '', status: 'active', sourceAppId: null }] });- return Promise.resolve(def);- });+ readJSONFile.mockImplementation(makeReadMock(mockMemory, { version: 1, memories: [{ id: 'mem-1', status: 'active' }] }));await updateMemory('mem-1', { content: '' });@@ -604,11 +601,7 @@ describe('memory service', () => {it('should not reindex BM25 when neither content nor tags are in the update', async () => {const mockMemory = { id: 'mem-1', type: 'fact', content: 'test', summary: 'test', category: 'other', tags: [], importance: 0.5, relatedMemories: [], status: 'active', sourceAppId: null };- readJSONFile.mockImplementation((path, def) => {- if (path.includes('memory.json')) return Promise.resolve({ ...mockMemory });- if (path.includes('index.json')) return Promise.resolve({ version: 1, lastUpdated: '', count: 1, memories: [{ id: 'mem-1', type: 'fact', category: 'other', tags: [], summary: 'test', importance: 0.5, createdAt: '', status: 'active', sourceAppId: null }] });- return Promise.resolve(def);- });+ readJSONFile.mockImplementation(makeReadMock(mockMemory, { version: 1, memories: [{ id: 'mem-1', status: 'active' }] }));await updateMemory('mem-1', { category: 'engineering' });@@ -664,13 +657,6 @@ describe('memory service', () => {// ===========================================================================describe('deleteMemory', () => {- const makeReadMock = (memory, index, embeddings) => (path, def) => {- if (path.includes('memory.json')) return Promise.resolve(memory ? { ...memory } : def);- if (path.includes('index.json')) return Promise.resolve(index || def);- if (path.includes('embeddings.json')) return Promise.resolve(embeddings || def);- return Promise.resolve(def);- };-it('should soft delete (archive) by default', async () => {const mockMemory = { id: 'mem-1', status: 'active', updatedAt: '' };const mockIndex = { version: 1, lastUpdated: '', count: 1, memories: [{ id: 'mem-1', status: 'active' }] };diff --git a/server/services/memoryDB.js b/server/services/memoryDB.jsindex fbd42f649c..06e23ace63 100644--- a/server/services/memoryDB.js+++ b/server/services/memoryDB.js@@ -285,13 +285,8 @@ export async function updateMemory(id, updates) {}// Update summary if content changed but no explicit summary. Gate on "is a- // string", not truthiness, to mirror the file backend (memory.js): a content- // edit must refresh the summary rather than leave the stale one behind- // (absent-vs-cleared, CLAUDE.md). The typeof check also keeps null/undefined- // out of generateSummary, which would throw on `.length`. (Empty content is- // separately blocked at the API by memoryUpdateSchema's min(1), so in practice- // this only fires for a real non-empty edit — the guard keeps both backends- // consistent and crash-safe regardless of caller.)+ // string" not truthiness, mirroring the file backend (memory.js) and keeping+ // null/undefined out of generateSummary (absent-vs-cleared, CLAUDE.md).if (typeof updates.content === 'string' && !updates.summary) {fields.push(`summary = $${paramIdx++}`);params.push(generateSummary(updates.content));