From 5a7230121afc75ad96f1ed32ac90791a98fabce2 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-system.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'modules/core/module-system.js') diff --git a/modules/core/module-system.js b/modules/core/module-system.js index e7f7e5a..b9b62a6 100644 --- a/modules/core/module-system.js +++ b/modules/core/module-system.js @@ -144,13 +144,25 @@ // v4.5.43: errors [n] — alias for logs [n] ERROR this.commands['errors'] = (args) => { const n = parseInt(args[0]) || 20; - const content = this.terminal.fs.readFile('/logs/current.log'); - if (!content) { this.terminal.print('No logs yet', 'info'); return; } - const lines = content.split('\n').filter(l => l && l.includes('[ERROR]')); - const tail = lines.slice(-n); - if (tail.length === 0) { this.terminal.print('✅ No errors found in logs', 'success'); return; } - this.terminal.print(`--- Errors (last ${tail.length}) ---`, 'error'); - tail.forEach(l => this.terminal.print(l, 'error')); + // v4.6.59: read the canonical counter (DebugSupervisor DB + failed tool + // calls) — the same numbers the dashboard and world model publish. The VFS + // log is reported separately because it only receives explicit + // terminal.log('ERROR') calls, so it cannot be the source of truth. + const e = this.terminal.countErrors(); + if (e.total === 0) { + this.terminal.print(`✅ 0 errors — debug DB ${e.debug} · failed tool calls ${e.latency} · log ${e.log}`, 'success'); + } else { + this.terminal.print(`--- ${e.total} ${e.total === 1 ? 'error' : 'errors'} — debug DB ${e.debug} · failed tool calls ${e.latency} ---`, 'error'); + const ds = this.terminal.moduleManager.modules['DebugSupervisorModule']; + const entries = Object.entries((ds && ds._errorDB && ds._errorDB.errors) || {}) + .map(([hash, v]) => Object.assign({ hash: hash }, v)) + .sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0)) + .slice(0, n); + entries.forEach(x => this.terminal.print( + (x.hash || '').slice(0, 8) + ' ×' + (x.count || 1) + ' ' + + ((x.severity || '') + ' ' + (x.message || '')).trim(), 'error')); + } + this.terminal.print(` scope: this browser session · log scan ${e.log} [ERROR] line(s) in /logs/current.log`, 'info'); }; // v4.5.43: doctor — run all health checks, rank issues, show top 3 -- cgit v1.2.3