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: clone DEFAULT_SCHEDULE and registry defaults to prevent mutation (#12060)
Adam Eivyc2d0c3a97505
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex e4c62f500a..758360ac0f 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -548,6 +548,40 @@ describe('taskSchedule', () => {expect(schedule.executions).toBeDefined()})+ it('returns independent schedule instances on consecutive no-file reads without polluting defaults', async () => {+ readJSONFile.mockResolvedValue(null)+ const first = await loadSchedule()+ first.executions['task:security'] = { lastRun: '2026-10-18T00:00:00.000Z', count: 1 }+ first.templates.push({ name: 'polluted' })+ first.tasks['security'].enabled = false++ const second = await loadSchedule()+ expect(second.executions['task:security']).toBeUndefined()+ expect(second.templates).toEqual([])+ expect(second.tasks['security'].enabled).toBe(true)+ expect(DEFAULT_TASK_INTERVALS['security'].enabled).toBe(true)+ })++ it('does not mutate DEFAULT_TASK_INTERVALS during v1 to v2 migration', async () => {+ const originalSecurityPrompt = DEFAULT_TASK_INTERVALS['security'].prompt+ const originalSecurityMeta = DEFAULT_TASK_INTERVALS['security'].taskMetadata++ readJSONFile.mockResolvedValue({+ version: 1,+ selfImprovement: {+ security: {+ prompt: 'custom v1 prompt',+ taskMetadata: { fileIssues: true }+ }+ }+ })++ const migrated = await loadSchedule()+ expect(migrated.tasks['security'].prompt).toBe('custom v1 prompt')+ expect(DEFAULT_TASK_INTERVALS['security'].prompt).toBe(originalSecurityPrompt)+ expect(DEFAULT_TASK_INTERVALS['security'].taskMetadata).toEqual(originalSecurityMeta)+ })+it('installs tasks on demand and keeps model research disabled until configured', async () => {const schedule = await loadSchedule()diff --git a/server/services/taskScheduleStore.js b/server/services/taskScheduleStore.jsindex 434c3a25a1..fa8d5654e2 100644--- a/server/services/taskScheduleStore.js+++ b/server/services/taskScheduleStore.js@@ -58,7 +58,7 @@ function migrateScheduleV1toV2(schedule) {const migrated = {version: 2,lastUpdated: new Date().toISOString(),- tasks: { ...DEFAULT_TASK_INTERVALS },+ tasks: structuredClone(DEFAULT_TASK_INTERVALS),executions: {},templates: schedule.templates || [],onDemandRequests: schedule.onDemandRequests || []@@ -183,7 +183,7 @@ async function readSchedule() {const loaded = await readJSONFile(SCHEDULE_FILE, null, { strict: true });if (!loaded) {- return { schedule: { ...DEFAULT_SCHEDULE }, needsSave: false };+ return { schedule: structuredClone(DEFAULT_SCHEDULE), needsSave: false };}// Auto-migrate v1 → v2