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(taskLearning): snapshot cache to prevent mutable reference aliasing; add vi.clearAllMocks() to test suites
Adam Eivy29d73bc90e30
diff --git a/server/services/taskLearning.js b/server/services/taskLearning.jsindex 228cb3e250..d70bb9f113 100644--- a/server/services/taskLearning.js+++ b/server/services/taskLearning.js@@ -83,7 +83,7 @@ export function clearLearningCache() {*/async function loadLearningData() {if (_learningCache && (Date.now() - _learningCacheTime) < LEARNING_CACHE_TTL_MS) {- return _learningCache;+ return structuredClone(_learningCache);}if (!existsSync(DATA_DIR)) {@@ -91,7 +91,7 @@ async function loadLearningData() {}const data = await readJSONFile(LEARNING_FILE, structuredClone(DEFAULT_LEARNING_DATA));- _learningCache = data;+ _learningCache = structuredClone(data);_learningCacheTime = Date.now();return data;}@@ -115,7 +115,7 @@ async function saveLearningData(data) {const tmp = `${LEARNING_FILE}.tmp`;await writeFile(tmp, JSON.stringify(data, null, 2));await rename(tmp, LEARNING_FILE);- _learningCache = data;+ _learningCache = structuredClone(data);_learningCacheTime = Date.now();}diff --git a/server/services/taskLearning.test.js b/server/services/taskLearning.test.jsindex e17c0f7dd7..1ad2cd76ba 100644--- a/server/services/taskLearning.test.js+++ b/server/services/taskLearning.test.js@@ -688,6 +688,7 @@ describe('TaskLearning - recalculateModelTierMetrics', () => {describe('TaskLearning - getTaskTypeConfidence', () => {beforeEach(() => {+ vi.clearAllMocks();clearLearningCache();});@@ -780,6 +781,7 @@ describe('TaskLearning - getTaskTypeConfidence', () => {describe('TaskLearning - getConfidenceLevels', () => {beforeEach(() => {+ vi.clearAllMocks();clearLearningCache();});