From 71d78fa055d00ed51a9067c441d562807ea95404 Mon Sep 17 00:00:00 2001 From: Agando Date: Fri, 23 Oct 2026 17:46:41 +0200 Subject: fix(newos4): predictor arithmetic, deployed-source viewer, ls text output (v4.6.57) Acting on the "Request to the newOS4 team" packet (spaces/agando/guides/, re-verified by its author on 4.6.56). Three verified defects fixed: Packet 5 (predictor arithmetic) - module-predictor.js - the persisted field named mape held a SUM while predictor-status divided by the paired count: renamed to errorSum, older payloads read through - errorPct is stored raw; the 500% clamp is now render-only, so a 475x miss stays visible instead of being flattened to the ceiling - predictions are floored at 1 s and marked floored; a floored prediction is consumed but never scored as 100% error (a 0 s prediction is not a prediction) - observations shorter than 1.5 s (aborted/instant runs) are marked unusable and no longer train _findSimilar - one 0.079 s run was rounding the next prediction to 0 s - status prints an unpaired and an unscored count alongside the mean Packet 10 (verification cannot see its own fixes) - module-aiassist.js - view_module now returns the DEPLOYED source, prefixed with file and version, and only falls back to the _mods copy with a "may be stale" banner. The unversioned _mods/.js edit cache used to shadow the deployed file forever, so the viewer showed pre-fix code while the bundle was new. Proven by seeding a stale _mods/PredictorModule.js and calling the tool. Packet 1b (ls exits clean with no output) - module-fs.js - ls rendered only via printClickable(), which writes straight to the DOM, so any capture (AI run_command, diagnostics) saw an empty result and reported "empty directory". It now always prints a text line and keeps the clickable chips when nothing is capturing. Test: modules/test/test-predictor-accuracy.js 34/34 (new cases Q, R, S). --- modules/core/module-aiassist.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'modules/core/module-aiassist.js') diff --git a/modules/core/module-aiassist.js b/modules/core/module-aiassist.js index 83d073a..628e68a 100644 --- a/modules/core/module-aiassist.js +++ b/modules/core/module-aiassist.js @@ -3094,9 +3094,11 @@ buildSystemPrompt() { case 'view_module': { const modName = a.name || ''; const entry = this.terminal.moduleManager.moduleRegistry.find(m => m.name === modName); - const code = this.terminal.fs.readFile(`_mods/${modName}.js`); - if (code) return code; const url = entry ? entry.url : null; + // v4.6.57: deployed source FIRST. The unversioned `_mods/.js` edit cache + // used to shadow it forever, so view_module returned pre-fix code while the + // running bundle was new (packet §10). The cache is only a labelled fallback. + const deployedVer = (typeof localStorage !== 'undefined' && localStorage.getItem('webx11_cache_ver')) || 'dev'; // Try registry URL first if (url) { try { @@ -3104,7 +3106,7 @@ buildSystemPrompt() { if (resp.ok) { const src = await resp.text(); this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, src); - return src; + return '// deployed: ' + url + ' @ ' + deployedVer + '\n' + src; } } catch (e) { /* fall through */ } } @@ -3126,11 +3128,15 @@ buildSystemPrompt() { if (resp.ok) { const src = await resp.text(); this.terminal.fs.writeFile(`_mods/${modName}.orig.js`, src); - return src; + return '// deployed: ' + fetchUrl + ' @ ' + deployedVer + '\n' + src; } } } } catch (e) { /* fall through */ } + const cachedSrc = this.terminal.fs.readFile(`_mods/${modName}.js`); + if (cachedSrc) { + return '// VFS COPY of ' + modName + '.js — may be stale (not the deployed file)\n' + cachedSrc; + } return JSON.stringify({ error: `Cannot find source for ${modName} — not in registry, not in modules-index.json` }); } case 'edit_module': { -- cgit v1.2.3