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: log and exclude failed records in task-learning backfill instead of silently counting them
[._.]/ Adam Eivy70ddad61a2f8
diff --git a/server/services/taskLearning/lifecycle.js b/server/services/taskLearning/lifecycle.jsindex 98640e3d6a..930b40b84c 100644--- a/server/services/taskLearning/lifecycle.js+++ b/server/services/taskLearning/lifecycle.js@@ -92,6 +92,7 @@ export async function backfillFromHistory() {const agents = await getAgents();let backfilled = 0;+ let failed = 0;for (const agent of agents) {// Same rule as the live listener above, and the reason it is repeated rather// than assumed: the backfill re-reads the ARCHIVE, where every relaunch the@@ -105,11 +106,19 @@ export async function backfillFromHistory() {metadata: agent.metadata};- await recordTaskCompletion(withoutStaleCoordinatorVerdict(agent, task), task).catch(() => {});- backfilled++;+ // Count only records that actually landed, and name the failing agent/task+ // so a partial backfill is diagnosable instead of reporting a full count.+ const recorded = await recordTaskCompletion(withoutStaleCoordinatorVerdict(agent, task), task)+ .then(() => true)+ .catch(err => {+ failed++;+ console.error(`❌ 📚 TaskLearning: Backfill failed to record agent ${agent.id} (task ${agent.taskId}): ${err.message}`);+ return false;+ });+ if (recorded) backfilled++;}}- emitLog('info', `Backfilled ${backfilled} completed tasks into learning system`, { backfilled }, '📚 TaskLearning');+ emitLog(failed ? 'warn' : 'info', `Backfilled ${backfilled} completed tasks into learning system${failed ? ` (${failed} failed)` : ''}`, { backfilled, failed }, '📚 TaskLearning');return backfilled;}diff --git a/server/services/taskLearning/lifecycle.test.js b/server/services/taskLearning/lifecycle.test.jsindex 2992cda4fe..81519d47fd 100644--- a/server/services/taskLearning/lifecycle.test.js+++ b/server/services/taskLearning/lifecycle.test.js@@ -168,3 +168,17 @@ describe('agent:completed listener — a resumed record is a continuation, not aexpect(observeAgentChurn).not.toHaveBeenCalled();});});++describe('backfillFromHistory — failed records are reported, not counted', () => {+ beforeEach(() => vi.clearAllMocks());++ it('logs the failing agent and returns only the records that landed', async () => {+ agentsStore.list = [completed('ok-task', 'ux', true), { ...completed('bad-task', 'ux', true), id: 'agent-bad' }];+ recordTaskCompletion.mockImplementationOnce(async () => {}).mockImplementationOnce(async () => { throw new Error('disk full'); });+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});++ expect(await backfillFromHistory()).toBe(1);+ expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('agent-bad (task bad-task): disk full'));+ errorSpy.mockRestore();+ });+});