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
fix: reject empty persistent-mind summaries and disambiguate forced retries
[._.]/ Adam Eivyc67d3709941f
diff --git a/server/services/persistentMindContext.js b/server/services/persistentMindContext.jsindex d55b304a28..a8629c1721 100644--- a/server/services/persistentMindContext.js+++ b/server/services/persistentMindContext.js@@ -86,9 +86,9 @@ const latestReadyRollup = (rollups, promptVersion) => rollupsconst summaryOutcome = (summarize, input) => Promise.resolve().then(() => summarize(input)).then(- (summary) => typeof summary === 'string'+ (summary) => typeof summary === 'string' && summary.trim()? { ok: true, summary }- : { ok: false, error: 'Persistent mind summarizer returned no summary string' },+ : { ok: false, error: 'Persistent mind summarizer returned no summary text' },(error) => ({ ok: false, error: String(error?.message || error || 'Persistent mind summary failed').slice(0, 500) }));@@ -147,7 +147,13 @@ export async function preparePersistentMindContext({await appendMindEvent({kind: 'mind.summary',mindId,- eventId: `mind-summary-${sha256Text(rollup.id).slice(0, 32)}`,+ // Keyed on the rollup's own createdAt (unique per attempt), not just+ // rollup.id: a forceSummary retry reuses the same rollup id, and the+ // shared ledger dedupes mind events by eventId regardless of age — an+ // id derived from rollup.id alone would make a successful retry's+ // event silently drop, leaving the replayed trajectory stuck showing+ // the earlier failed attempt forever.+ eventId: `mind-summary-${sha256Text(`${rollup.id}:${rollup.provenance.createdAt}`).slice(0, 32)}`,data: {rollupId: rollup.id,status: rollup.status,diff --git a/server/services/persistentMindContext.test.js b/server/services/persistentMindContext.test.jsindex 7ef142d060..a5696cb4e2 100644--- a/server/services/persistentMindContext.test.js+++ b/server/services/persistentMindContext.test.js@@ -108,6 +108,49 @@ describe('persistent mind rollups', () => {expect(rollup).toMatchObject({ status: 'failed', summary: null, error: 'summary provider unavailable' });});+ it('rejects an empty or whitespace-only summary as a failed attempt', async () => {+ mock.history = [event(1), event(2), event(3)];+ const summarize = vi.fn(async () => ' ');++ const context = await preparePersistentMindContext({ recentEventLimit: 1, summarize });+ const [rollup] = await readPersistentMindRollups();++ expect(context.summaryState).toBe('failed');+ expect(rollup).toMatchObject({+ status: 'failed',+ summary: null,+ error: 'Persistent mind summarizer returned no summary text',+ });+ });++ it('gives a forced retry its own trajectory event so a successful retry is not deduped against the earlier failure', async () => {+ mock.history = [event(1), event(2), event(3)];+ const summarize = vi.fn(async () => { throw new Error('summary provider unavailable'); });++ await preparePersistentMindContext({ recentEventLimit: 1, summarize });+ mock.appendMindEvent.mockClear();+ summarize.mockImplementation(async () => 'Recovered after the provider came back.');++ await preparePersistentMindContext({ recentEventLimit: 1, summarize, forceSummary: true });+ const [rollup] = await readPersistentMindRollups();++ expect(rollup).toMatchObject({ status: 'ready', summary: 'Recovered after the provider came back.' });+ expect(mock.appendMindEvent).toHaveBeenCalledWith(expect.objectContaining({+ kind: 'mind.summary',+ data: expect.objectContaining({ status: 'ready' }),+ }));+ const retryEventId = mock.appendMindEvent.mock.calls.find(+ ([call]) => call.kind === 'mind.summary'+ )[0].eventId;+ expect(retryEventId).toBeTruthy();+ // The retry's event id must differ from an id derived from rollup.id alone+ // (which is unchanged across attempts) — otherwise the shared ledger's+ // dedupe would silently drop this event and the replayed trajectory would+ // stay stuck on the earlier failed attempt forever.+ const staleEventId = `mind-summary-${(await import('../lib/fileUtils.js')).sha256Text(rollup.id).slice(0, 32)}`;+ expect(retryEventId).not.toBe(staleEventId);+ });+it('builds cumulative rollups so a bounded cache retains the full summarized life', async () => {mock.history = [event(1), event(2), event(3)];const summarize = vi.fn()