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

address codex review: tolerate null estimate/targetDate in accept schema + tests; file #1422 for parity follow-ups (#898)

Adam Eivydde90fd22971
diff --git a/server/lib/identityValidation.js b/server/lib/identityValidation.js
index 8399601bf7..64bb434902 100644
--- a/server/lib/identityValidation.js
+++ b/server/lib/identityValidation.js
@@ -110,19 +110,21 @@ export const acceptPhasesInputSchema = z.object({
export const decomposeGoalInputSchema = aiProviderInputSchema;
-// Mirrors addTodoInputSchema; estimateMinutes optional (LLM may omit).
+// Mirrors addTodoInputSchema; estimateMinutes optional — tolerate the explicit
+// `null` an LLM commonly emits (the service normalizes it to null anyway).
export const decomposedTaskSchema = z.object({
title: z.string().min(1).max(200),
priority: z.enum(['low', 'medium', 'high']).optional().default('medium'),
- estimateMinutes: z.number().int().min(1).max(14400).optional()
+ estimateMinutes: z.number().int().min(1).max(14400).nullable().optional()
});
export const acceptDecompositionInputSchema = z.object({
milestones: z.array(z.object({
title: z.string().min(1).max(200),
description: z.string().max(2000).optional().default(''),
- // targetDate optional — decomposition works without a goal target date.
- targetDate: validCalendarDate.optional(),
+ // targetDate optional/nullable — decomposition works without a goal target
+ // date, and the LLM may emit an explicit `null` for a dateless milestone.
+ targetDate: validCalendarDate.nullable().optional(),
order: z.number().int().min(0),
tasks: z.array(decomposedTaskSchema).max(20).optional().default([])
})).min(1).max(20)
diff --git a/server/lib/identityValidation.test.js b/server/lib/identityValidation.test.js
index 25376f439a..c9e6997ce8 100644
--- a/server/lib/identityValidation.test.js
+++ b/server/lib/identityValidation.test.js
@@ -13,6 +13,7 @@ import {
addMilestoneInputSchema,
aiProviderInputSchema,
acceptPhasesInputSchema,
+ acceptDecompositionInputSchema,
addProgressEntrySchema,
addTodoInputSchema,
updateTodoInputSchema,
@@ -231,6 +232,37 @@ describe('identityValidation', () => {
});
});
+ describe('acceptDecompositionInputSchema', () => {
+ it('accepts a milestone with nested tasks', () => {
+ const r = acceptDecompositionInputSchema.safeParse({
+ milestones: [{ title: 'M1', targetDate: '2030-01-01', order: 0,
+ tasks: [{ title: 'T1', priority: 'high', estimateMinutes: 60 }] }]
+ });
+ expect(r.success).toBe(true);
+ });
+
+ it('tolerates null targetDate and null estimateMinutes (common LLM output)', () => {
+ const r = acceptDecompositionInputSchema.safeParse({
+ milestones: [{ title: 'M1', targetDate: null, order: 0,
+ tasks: [{ title: 'T1', estimateMinutes: null }] }]
+ });
+ expect(r.success).toBe(true);
+ expect(r.data.milestones[0].tasks[0].priority).toBe('medium');
+ });
+
+ it('defaults tasks to an empty array when omitted', () => {
+ const r = acceptDecompositionInputSchema.safeParse({
+ milestones: [{ title: 'M1', order: 0 }]
+ });
+ expect(r.success).toBe(true);
+ expect(r.data.milestones[0].tasks).toEqual([]);
+ });
+
+ it('rejects an empty milestones array', () => {
+ expect(acceptDecompositionInputSchema.safeParse({ milestones: [] }).success).toBe(false);
+ });
+ });
+
describe('addProgressEntrySchema', () => {
it('accepts a minimal entry', () => {
const r = addProgressEntrySchema.safeParse({ date: '2025-01-15', note: 'practiced scales' });
diff --git a/server/services/identity/goals.test.js b/server/services/identity/goals.test.js
index 4a6c193b51..66c7aff535 100644
--- a/server/services/identity/goals.test.js
+++ b/server/services/identity/goals.test.js
@@ -140,6 +140,16 @@ describe('goal decomposition', () => {
expect(await completeMilestoneTask('goal-1', msId, 'missing')).toBeNull();
});
+ it('acceptGoalDecomposition tolerates null estimateMinutes / targetDate from the LLM', async () => {
+ const goal = await acceptGoalDecomposition('goal-1', [
+ { title: 'Outline', order: 0, targetDate: null, tasks: [
+ { title: 'Beat sheet', priority: 'high', estimateMinutes: null }
+ ] }
+ ]);
+ expect(goal.milestones[0].targetDate).toBeNull();
+ expect(goal.milestones[0].tasks[0].estimateMinutes).toBeNull();
+ });
+
it('getGoals lazily backfills milestone.tasks = [] on legacy milestones', async () => {
h.goalsData.goals[0].milestones = [{ id: 'ms-legacy', title: 'Old', completedAt: null }];
const data = await getGoals();