From d100ad3c57f4a18dacb2cbc11cfdc5590f20cf08 Mon Sep 17 00:00:00 2001 From: Agando Date: Fri, 23 Oct 2026 18:15:05 +0200 Subject: fix(newos4): one error counter for errors/dashboard/world-model (v4.6.61) Packet 2 (three surfaces, three answers). Measured first: `errors` scanned /logs/current.log for [ERROR] lines, but that file only ever receives explicit terminal.log('ERROR', ...) calls -- exactly one call site in the whole app -- so it read 0. The dashboard added DebugSupervisor._errorDB plus failed tool calls (18), and the world model read the debug DB alone (11). - terminal.countErrors() / countLogErrors(): the single counter, exposed on the one object all three surfaces already hold - `errors` prints the canonical total with its breakdown, the entry list (hash, count, severity, message), and reports the log scan separately as a mirror - dashboard health.errors and health.errorBreakdown derive from it - world model telemetry.recentErrors derives from it, plus errorsBySource - terminal.log('ERROR', ...) now also records into DebugSupervisor, so the log is a human-readable mirror of one store instead of a second store almost nobody wrote Verified live on v4.6.61: with a seeded debug entry + failed tool call, all three report 2; a single log('ERROR') call moves debug 1->2 and the total by exactly 1 (the mirror line is counted once, in the log, and reported separately). --- modules/core/module-world-model.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'modules/core/module-world-model.js') diff --git a/modules/core/module-world-model.js b/modules/core/module-world-model.js index 4e88f59..d48327b 100644 --- a/modules/core/module-world-model.js +++ b/modules/core/module-world-model.js @@ -257,10 +257,15 @@ class WorldModelModule { const sm = this.terminal?.moduleManager?.modules?.['ServerMonitorModule']; const ds = this.terminal?.moduleManager?.modules?.['DebugSupervisorModule']; const latencyDataPoints = sm?._latencyLog ? Object.keys(sm._latencyLog).length : 0; - const recentErrors = ds ? Object.keys(ds._errorDB?.errors || {}).length : 0; + // v4.6.59: same canonical counter as the `errors` command and the dashboard. + // Reading the debug DB alone made the world model disagree with both (packet ยง2). + const errInfo = (this.terminal && typeof this.terminal.countErrors === 'function') + ? this.terminal.countErrors() + : { total: ds ? Object.keys(ds._errorDB?.errors || {}).length : 0, debug: 0, latency: 0, log: 0 }; return { toolLatencyDataPoints: latencyDataPoints, - recentErrors: recentErrors, + recentErrors: errInfo.total, + errorsBySource: { debug: errInfo.debug, toolCalls: errInfo.latency, log: errInfo.log }, }; } catch (e) { console.warn('[WorldModel] Telemetry gather error:', e.message); -- cgit v1.2.3