From ef7e4d4d64c294240542c74d8ad2f99b7ef641f2 Mon Sep 17 00:00:00 2001 From: Agando Date: Fri, 23 Oct 2026 15:55:51 +0200 Subject: fix(newos4): empty-pipeline crash, stacks in reports, frame in digest + dashboard (v4.6.55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: splitPipe() splits on every '|', so `help |`, `| wc -l`, `a || b` produced a stage with no argv and executePipeChain() called parts[0].toLowerCase() on undefined — 989 occurrences, first filed 2026-10-20, unfixable from the report because bug reports dropped the stack that named executePipeChain:3955. Same unguarded read existed in _classify(). - terminal.js: _classify() returns an inert classification for empty argv; executePipeChain() parses each stage once, filters stages with no argv (so the last real stage stays final), warns only when the whole pipeline is empty. Last-stage test now compares against the filtered length. - module-system.js: `bug` diagnostics include the stack (10 frames, 1200 chars); auto-filed reports carry it too — they are the majority of the inbox and were previously message-only. - report.php: per-stack 2 KB cap; fingerprint pinned to message/source/count so adding `stack` cannot break dedupe against reports filed before today. - ingest.php: first_frame() parsed once on ingest, stored as `frame` on each signature. - newos4-triage.py: FRAME| line with the first application frame. - dashboard.php: frame under each Top Errors row. - modules/test/test-pipe-guard.js: ordering tripwire (guard must precede the parts[0] read). Verified: test RED exit=1 -> GREEN exit=0; browser matrix on v4.6.55 (help |, | wc -l, echo hi || echo bye, ls | | wc -l, |) -> 0 new error signatures, "|" warns; auto-filed report now carries stack (RPT-...f3e31124, archived after the probe); frame = modules/core/core-bundle.js:3955:42; maintain OK; skill audit 7/7. --- modules/test/test-pipe-guard.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/test/test-pipe-guard.js (limited to 'modules/test') diff --git a/modules/test/test-pipe-guard.js b/modules/test/test-pipe-guard.js new file mode 100644 index 0000000..0bd7cc9 --- /dev/null +++ b/modules/test/test-pipe-guard.js @@ -0,0 +1,34 @@ +// modules/test/test-pipe-guard.js — run: node modules/test/test-pipe-guard.js +// Fails fast if either guard is removed or if a guard is placed AFTER the parts[0] read. +// Behavioural proof is the browser matrix (plan Task 8); this test is the cheap tripwire. +const fs = require('fs'), path = require('path'); +const src = fs.readFileSync(path.join(__dirname, '../core/terminal.js'), 'utf8'); + +// 1. _parseArgs('') must return [] — that precondition is what made parts[0] undefined. +// The source is a CLASS METHOD, so wrap it in an object literal (a bare `new Function('m(){…}')` +// is a SyntaxError). It touches no `this` (verified), so a detached call is safe. +const m = src.match(/_parseArgs\((\w+)\)\s*\{[\s\S]*?\n\s{12}\}/); +if (!m) { console.error('FAIL: _parseArgs not found — did the method signature or indent change?'); process.exit(1); } +const parseArgs = new Function('return ({' + m[0] + '})._parseArgs;')(); +const empty = parseArgs(''); +const blank = parseArgs(' '); + +// 2. guards must exist AND precede the read they protect (ordering, not just presence) +const ci = src.indexOf('_classify(raw)'); +const cGuard = src.indexOf('if (!parts.length)', ci); +const cRead = src.indexOf('parts[0].toLowerCase()', ci); +const classifyGuarded = ci >= 0 && cGuard > ci && cGuard < cRead; + +const pi = src.indexOf('async executePipeChain('); +const pGuard = src.indexOf('if (!stages.length)', pi); +const pFilter = src.indexOf('.filter(argv => argv.length > 0)', pi); +const pRead = src.indexOf('argv[0].toLowerCase()', pi); +const pipeGuarded = pi >= 0 && pFilter > pi && pGuard > pFilter && pRead > pGuard + && src.indexOf('i < stages.length - 1', pi) > 0; + +const report = { empty, blank, classifyGuarded, pipeGuarded }; +console.log(JSON.stringify(report)); +const ok = Array.isArray(empty) && empty.length === 0 + && Array.isArray(blank) && blank.length === 0 + && classifyGuarded && pipeGuarded; +process.exit(ok ? 0 : 1); -- cgit v1.2.3