Skip to content

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

fix: keep daily reviews available when a pending goal is missing (#8837)

[._.]/ Adam Eivy2ceb004cd11a
diff --git a/docs/STORAGE.md b/docs/STORAGE.md
index 8c75dfc163..4a93990779 100644
--- a/docs/STORAGE.md
+++ b/docs/STORAGE.md
@@ -122,11 +122,12 @@ A cancelled unowned accepted operation moves to `data/database-maintenance-cance
### Calendar daily-review recovery
Daily reviews remain in the existing `data/calendar/daily-reviews/<date>.json`
-file-primary store. An optional `pendingOperation` records the desired confirmation,
+file-primary store. An optional per-event `pendingOperations` map records each desired confirmation,
its stable date/event `sourceKey`, and prior goal link before goal effects run.
Only a successful goal-store write publishes the confirmation and clears the intent.
An explicit daily-review read or confirmation retry replays pending work locally;
-history stays a read-only projection of completed confirmations. No recovery path
+missing goals remain visible as pending confirmations without blocking the day.
+History stays a read-only projection of completed confirmations. No recovery path
calls an AI or calendar provider.
Goal progress carries the same optional `sourceKey` in the existing identity goal
diff --git a/server/services/dailyReview.js b/server/services/dailyReview.js
index 89f7e2c6d3..e52f5b1b7a 100644
--- a/server/services/dailyReview.js
+++ b/server/services/dailyReview.js
@@ -21,7 +21,13 @@ 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 };
- await finishPendingReview(date, review);
+ 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.
+ // Keep its intent durable and visible; every other failure still rejects.
+ if (error.code !== 'GOAL_NOT_FOUND') throw error;
+ });
+ }
return review;
});
// Get all events for this date across all accounts
@@ -91,6 +97,8 @@ export async function getDailyReview(date) {
date,
events: enrichedEvents,
confirmations: existing.confirmations,
+ pendingConfirmations: Object.fromEntries(Object.keys(existing.pendingOperations || {})
+ .map(eventId => [eventId, { code: 'GOAL_NOT_FOUND' }])),
progressEntries,
lastSyncAt,
summary: {
@@ -105,10 +113,10 @@ export async function getDailyReview(date) {
// The intent is saved before goal effects; only completed effects publish a
// confirmation. Replaying after either write failed uses the same source key.
-async function finishPendingReview(date, review) {
- const pending = review.pendingOperation;
+async function finishPendingReview(date, review, eventId) {
+ const pending = review.pendingOperations?.[eventId];
if (!pending) return null;
- const { eventId, confirmation, sourceKey } = pending;
+ const { confirmation, sourceKey } = pending;
const progressEntry = await reconcileCalendarProgress(sourceKey, {
goalId: confirmation.happened ? confirmation.goalId : null,
date,
@@ -117,7 +125,8 @@ async function finishPendingReview(date, review) {
});
review.confirmations[eventId] = confirmation;
review.updatedAt = confirmation.confirmedAt;
- delete review.pendingOperation;
+ delete review.pendingOperations[eventId];
+ if (!Object.keys(review.pendingOperations).length) delete review.pendingOperations;
await saveReview(date, review);
return progressEntry;
}
@@ -125,14 +134,14 @@ async function finishPendingReview(date, review) {
export function confirmEvent(date, { eventId, happened, goalId, durationMinutes, note }) {
return reviewQueue(date, async () => {
const review = await loadReview(date) || { confirmations: {}, updatedAt: null };
- // A new desired state for the SAME event may supersede an interrupted intent
- // (including a goal that was deleted). Other events must finish theirs first.
- if (review.pendingOperation?.eventId !== eventId) await finishPendingReview(date, review);
+ // A new desired state supersedes this event's interrupted intent, including
+ // a deleted goal. Independent events retain their own recoverable intents.
+ review.pendingOperations ||= {};
const sourceKey = `calendar-review:${date}:${eventId}`;
- review.pendingOperation = {
+ review.pendingOperations[eventId] = {
eventId,
sourceKey,
- priorGoalId: review.pendingOperation?.priorGoalId ?? review.confirmations[eventId]?.goalId ?? null,
+ priorGoalId: review.pendingOperations[eventId]?.priorGoalId ?? review.confirmations[eventId]?.goalId ?? null,
confirmation: {
happened,
goalId: goalId || null,
@@ -143,7 +152,7 @@ export function confirmEvent(date, { eventId, happened, goalId, durationMinutes,
}
};
await saveReview(date, review);
- const progressEntry = await finishPendingReview(date, review);
+ const progressEntry = await finishPendingReview(date, review, eventId);
console.log(`📅 Event ${eventId} ${happened ? 'confirmed' : 'skipped'} for ${date}`);
return { confirmation: review.confirmations[eventId], progressEntry };
});
diff --git a/server/services/dailyReview.test.js b/server/services/dailyReview.test.js
index 4c20dda703..674f1a3168 100644
--- a/server/services/dailyReview.test.js
+++ b/server/services/dailyReview.test.js
@@ -96,7 +96,7 @@ describe('calendar confirmation persistence workflow', () => {
if (pending) {
const interrupted = await read(reviewPath);
expect(interrupted.confirmations).toEqual({});
- expect(interrupted.pendingOperation.sourceKey).toBe(`calendar-review:${date}:event-a`);
+ expect(interrupted.pendingOperations['event-a'].sourceKey).toBe(`calendar-review:${date}:event-a`);
} else {
await expect(readFile(reviewPath)).rejects.toMatchObject({ code: 'ENOENT' });
}
@@ -105,7 +105,7 @@ describe('calendar confirmation persistence workflow', () => {
review = await import('./dailyReview.js');
await review.confirmEvent(date, input);
expect((await allProgress()).filter(entry => entry.sourceKey)).toHaveLength(1);
- expect((await read(reviewPath)).pendingOperation).toBeUndefined();
+ expect((await read(reviewPath)).pendingOperations).toBeUndefined();
});
it('an explicit read completes an interrupted intent without provider calls', async () => {
@@ -127,8 +127,12 @@ describe('calendar confirmation persistence workflow', () => {
.rejects.toMatchObject({ status: 404, code: 'GOAL_NOT_FOUND' });
expect((await read(reviewPath)).confirmations).toEqual({});
expect(await allProgress()).toEqual([expect.objectContaining({ id: 'manual' })]);
+ const pendingReview = await review.getDailyReview(date);
+ expect(pendingReview.pendingConfirmations['event-a']).toEqual({ code: 'GOAL_NOT_FOUND' });
+ await review.confirmEvent(date, { ...input, eventId: 'event-b' });
+ expect((await read(reviewPath)).pendingOperations['event-a']).toBeDefined();
await review.confirmEvent(date, { ...input, happened: false });
- expect((await read(reviewPath)).pendingOperation).toBeUndefined();
+ expect((await read(reviewPath)).pendingOperations).toBeUndefined();
});
it('preserves legacy confirmation fields and never infers ownership from date or free-form notes', async () => {