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: preserve calendar event IDs and isolate recovery test queues (#8837)
[._.]/ Adam Eivy87681b2ab8bd
diff --git a/server/services/dailyReview.js b/server/services/dailyReview.jsindex e52f5b1b7a..8f3db454b8 100644--- a/server/services/dailyReview.js+++ b/server/services/dailyReview.js@@ -10,7 +10,14 @@ const reviewQueue = createKeyCachedQueue();async function loadReview(date) {await ensureDir(REVIEW_DIR);- return readJSONFile(join(REVIEW_DIR, `${date}.json`), null, { strict: true });+ const review = await readJSONFile(join(REVIEW_DIR, `${date}.json`), null, { strict: true });+ if (!review) return null;+ // Provider event IDs are arbitrary strings, including object prototype names.+ review.confirmations = Object.assign(Object.create(null), review.confirmations);+ if (review.pendingOperations) {+ review.pendingOperations = Object.assign(Object.create(null), review.pendingOperations);+ }+ return review;}async function saveReview(date, data) {@@ -20,7 +27,7 @@ async function saveReview(date, data) {export async function getDailyReview(date) {// Recover a durable intent before projecting confirmations or goal progress.const existing = await reviewQueue(date, async () => {- const review = await loadReview(date) || { confirmations: {}, updatedAt: null };+ const review = await loadReview(date) || { confirmations: Object.create(null), updatedAt: null };for (const eventId of Object.keys(review.pendingOperations || {})) {await finishPendingReview(date, review, eventId).catch(error => {// A deleted goal needs an operator correction, not a day-wide outage.@@ -133,10 +140,10 @@ async function finishPendingReview(date, review, eventId) {export function confirmEvent(date, { eventId, happened, goalId, durationMinutes, note }) {return reviewQueue(date, async () => {- const review = await loadReview(date) || { confirmations: {}, updatedAt: null };+ const review = await loadReview(date) || { confirmations: Object.create(null), updatedAt: null };// A new desired state supersedes this event's interrupted intent, including// a deleted goal. Independent events retain their own recoverable intents.- review.pendingOperations ||= {};+ review.pendingOperations ||= Object.create(null);const sourceKey = `calendar-review:${date}:${eventId}`;review.pendingOperations[eventId] = {eventId,diff --git a/server/services/dailyReview.test.js b/server/services/dailyReview.test.jsindex 674f1a3168..e05edded9d 100644--- a/server/services/dailyReview.test.js+++ b/server/services/dailyReview.test.js@@ -26,11 +26,15 @@ vi.mock('./calendarSync.js', () => ({ getEvents: async () => ({ events: [{ id: 'vi.mock('./calendarAccounts.js', () => ({ listAccounts: async () => [] }));vi.mock('./aiProvider.js', () => ({ callProviderAISimple: vi.fn(), parseLLMJSON: vi.fn() }));vi.mock('./meatspaceCalendar.js', () => ({ getActivities: async () => [] }));-vi.mock('./identity.js', async () => {- const goals = await import('./identity/goals.js');- const store = await import('./identity/store.js');- return { ...goals, getGoals: () => store.loadJSON(store.GOALS_FILE, store.DEFAULT_GOALS, { strict: true }) };-});+vi.mock('./identity.js', () => ({+ // Dynamic forwarding matters after resetModules: the real store queue and the+ // manual progress writer must come from the same fresh module instance.+ reconcileCalendarProgress: async (...args) => (await import('./identity/goals.js')).reconcileCalendarProgress(...args),+ getGoals: async () => {+ const store = await import('./identity/store.js');+ return store.loadJSON(store.GOALS_FILE, store.DEFAULT_GOALS, { strict: true });+ }+}));import { PATHS } from '../lib/fileUtils.js';const date = '2026-01-02';@@ -73,6 +77,19 @@ describe('calendar confirmation persistence workflow', () => {expect((await read(reviewPath)).confirmations['event-a'].happened).toBe(false);});+ it('persists provider event IDs that coincide with object prototype properties', async () => {+ for (const eventId of ['__proto__', 'constructor', 'toString']) {+ const confirmation = await review.confirmEvent(date, { ...input, eventId });+ expect((await read(reviewPath)).confirmations[eventId]).toEqual(confirmation.confirmation);+ await review.confirmEvent(date, { ...input, eventId });+ }+ expect((await allProgress()).filter(entry => entry.sourceKey)).toHaveLength(3);+ for (const eventId of ['__proto__', 'constructor', 'toString']) {+ await review.confirmEvent(date, { ...input, eventId, happened: false });+ }+ expect(await allProgress()).toEqual([expect.objectContaining({ id: 'manual' })]);+ });+it('serializes different events, different dates and manual writes against the shared goal store', async () => {await Promise.all([review.confirmEvent(date, input),