diff --git a/server.js b/server.js index 26cc682..58bf3bf 100644 --- a/server.js +++ b/server.js @@ -2955,6 +2955,9 @@ setTimeout(() => { console.log(`[startup] recovered task "${task.title}" (${task.id}): in_progress → ${newStatus || 're-armed'}`); } processQueue(); + // Unconditional and on console (not `log`, which LOG_LEVEL filters): tests that seed + // in_progress rows wait for this line, or this pass re-arms them mid-assertion. + console.log('[startup] in_progress recovery complete'); }, 3000); // Watchdog: detect tasks stuck in 'in_progress' with no live worker process. diff --git a/test/global-workspace.test.js b/test/global-workspace.test.js index 9aa4736..3f0daf3 100644 --- a/test/global-workspace.test.js +++ b/test/global-workspace.test.js @@ -137,6 +137,13 @@ const titles = rows => (rows || []).map(r => r.title).sort(); await api('POST', '/api/projects', { name: 'Gamma', workdir: wdC }); // no tasks at all check('three projects registered', [typeof A, typeof B], ['string', 'string']); + // server.js re-arms every in_progress task with no live worker ~3 s after boot. + // A fixture created before that pass is flipped to todo under the assertions, so + // wait for the line the pass prints when it is done — not a fixed sleep. + const recovered = await waitFor(() => srvLog.includes('[startup] in_progress recovery complete'), + { timeoutMs: 30000, intervalMs: 100 }); + if (!recovered) { console.error('startup recovery never finished:\n' + srvLog); stop(); process.exit(1); } + const now = Math.floor(Date.now() / 1000); const mk = (t) => api('POST', '/api/tasks', t); // Scheduled fixtures are created as in_progress / far-future todo on purpose: