Elffuss BraidHub

utopia-ia/elffuss-code public

Tests: hold on a loaded machine and on the default graphics backend

- mind_stars.mjs failed 2 to 6 checks without ELFFUSS_CHROME_ARGS (f2ecda5
  made the backend flag optional). Stars, beams and the camera flight live a
  few seconds of frame time, and with the default backend one slow frame
  advances that clock at once: the beam and the flight had ended before the
  fixed waits read them. Each is now read in the same step that causes it,
  and the end of the flight is awaited. (Opening the Mind no longer enables
  the CEO since 13b9856, so no idle cycle runs mid-test either.)
- stopqueue.mjs proceeded after fixed waits; on a loaded machine
  the English section typed before the conversations existed and its message
  went nowhere. It waits for the IDE to be ready instead.
- stop.mjs did not pin Basic mode, so loading the page started loading the
  default local model during the test; it pins it like the other stop tests,
  and uses the bundled browser instead of the installed Chrome.
- ceo_persist.mjs failed on any console error, including the 404 of the
  private engine's probes (web/js/engine is not published with this repo);
  those are ignored, every other console error still fails it.
Changeset144b741f2d623ac24c1dfc1dbf1a4bfe361255b5ed357ffb73a22a5afb9a736f
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00
Parents8b50ce4fd39f

Browse the files at this changeset

4 files changed

modified tests/ceo_persist.mjs +3 −1
@@ -12,7 +12,9 @@
1212 await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
1313 const p = await ctx.newPage();
1414 const errors = [];
15-p.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
15+// El motor propio (web/js/engine) no se publica con este repo: donde no está, sus
16+// sondas dan 404, y eso no es un error de este flujo.
17+p.on('console', m => { if (m.type() === 'error' && !/\/js\/engine\//.test(m.location()?.url || '')) errors.push(m.text()); });
1618 p.on('pageerror', e => errors.push('PAGEERROR: ' + e.message));
1719 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' }); await p.waitForTimeout(1500);
1820
modified tests/mind_stars.mjs +30 −15
@@ -1,5 +1,11 @@
11 // Mente v3: estrellas por perfil (no consolas), historial completo, perfiles
22 // editables, ciudad de fondo + haces de actividad, y tool-calling REAL del CEO.
3+//
4+// Lo que depende del tiempo de la animación (estrellas, haces y vuelo viven
5+// unos segundos de reloj de fotogramas) se mide en el MISMO paso que lo
6+// provoca, no tras una espera fija: con el backend gráfico por defecto (sin
7+// ELFFUSS_CHROME_ARGS) un fotograma lento avanza ese reloj de golpe, y un haz de
8+// 1,4 s o un vuelo de 1,1 s ya habían terminado cuando se miraban.
39 import { chromium } from 'playwright';
410 import { CHROME_ARGS } from './chrome-args.mjs';
511 const OUT = (process.env.SCRATCH || '/tmp/elffuss-test');
@@ -36,15 +42,21 @@
3642 ok('ciudad de fondo construida bajo la Mente', dbg.hasCity, JSON.stringify(dbg));
3743
3844 // estrellas: una línea normal vs una tool-call deben crear estrellas (tamaño/estilo distinto por kind, verificado por código)
39-const before = (await p.evaluate(async () => (await import('/js/mind.js'))._debug())).starCount;
40-await p.evaluate(async () => { const m = await import('/js/mind.js'); m.pushThought('arq', { type: 'open', name: 'Arquitectura' }); m.pushThought('arq', { type: 'token', text: 'Esta es una línea de pensamiento normal que se vuelve estrella.\n' }); });
41-await p.waitForTimeout(200);
42-const afterLine = (await p.evaluate(async () => (await import('/js/mind.js'))._debug())).starCount;
43-ok('una línea de texto crea una estrella', afterLine > before, `${before}→${afterLine}`);
44-await p.evaluate(async (mark) => { const m = await import('/js/mind.js'); m.pushThought('arq', { type: 'tool', text: 'leyendo README.md…', path: 'README.md' }); }, MARK);
45-await p.waitForTimeout(200);
46-const afterTool = (await p.evaluate(async () => (await import('/js/mind.js'))._debug())).starCount;
47-ok('una tool-call crea otra estrella', afterTool > afterLine, `${afterLine}→${afterTool}`);
45+const linea = await p.evaluate(async () => {
46+ const m = await import('/js/mind.js');
47+ const antes = m._debug().starCount;
48+ m.pushThought('arq', { type: 'open', name: 'Arquitectura' });
49+ m.pushThought('arq', { type: 'token', text: 'Esta es una línea de pensamiento normal que se vuelve estrella.\n' });
50+ return { antes, despues: m._debug().starCount };
51+});
52+ok('una línea de texto crea una estrella', linea.despues > linea.antes, `${linea.antes}→${linea.despues}`);
53+const tool = await p.evaluate(async () => {
54+ const m = await import('/js/mind.js');
55+ const antes = m._debug().starCount;
56+ m.pushThought('arq', { type: 'tool', text: 'leyendo README.md…', path: 'README.md' });
57+ return { antes, dbg: m._debug() };
58+});
59+ok('una tool-call crea otra estrella', tool.dbg.starCount > tool.antes, `${tool.antes}→${tool.dbg.starCount}`);
4860
4961 // el historial completo muestra TODO (línea + tool)
5062 const logText = await p.evaluate(() => document.getElementById('mind-log-body').innerText);
@@ -52,8 +64,7 @@
5264 ok('el historial recoge la tool-call', /leyendo README\.md/.test(logText));
5365
5466 // haz de actividad sobre la ciudad (README.md existe en el modelo → beam real)
55-dbg = await p.evaluate(async () => (await import('/js/mind.js'))._debug());
56-ok('la tool-call sobre un fichero real generó un haz + resaltado', dbg.beamCount > 0 && dbg.fileActivityCount > 0, JSON.stringify(dbg));
67+ok('la tool-call sobre un fichero real generó un haz + resaltado', tool.dbg.beamCount > 0 && tool.dbg.fileActivityCount > 0, JSON.stringify(tool.dbg));
5768
5869 // editor de perfiles: renombrar Arquitectura y cambiar color, guardar
5970 await p.click('#mind-config'); await p.waitForTimeout(300);
@@ -99,11 +110,15 @@
99110
100111 // clic en la leyenda → la cámara VUELA a centrarse (posición cambia de verdad)
101112 const posBefore = (await p.evaluate(async () => (await import('/js/mind.js'))._debug())).cameraPos;
102-await p.click('.ml-item[data-id="rend"]'); // perfil lejos de la posición inicial de cámara
103-await p.waitForTimeout(150);
104-const midFly = await p.evaluate(async () => (await import('/js/mind.js'))._debug());
113+// el clic, y en el mismo paso, ¿hay vuelo en marcha?
114+const midFly = await p.evaluate(async () => {
115+ const m = await import('/js/mind.js');
116+ document.querySelector('.ml-item[data-id="rend"]').click(); // perfil lejos de la posición inicial de cámara
117+ return m._debug();
118+});
105119 ok('el clic dispara el vuelo (flying=true a mitad de camino)', midFly.flying);
106-await p.waitForTimeout(1300); // esperar a que termine (dur 1.1s)
120+// que termine (dura 1,1 s de reloj de fotogramas)
121+await p.waitForFunction(async () => !(await import('/js/mind.js'))._debug().flying, null, { timeout: 15000 }).catch(() => {});
107122 const posAfter = (await p.evaluate(async () => (await import('/js/mind.js'))._debug())).cameraPos;
108123 const moved = Math.hypot(posAfter[0] - posBefore[0], posAfter[1] - posBefore[1], posAfter[2] - posBefore[2]);
109124 ok('la cámara realmente se movió al centrarse en el perfil', moved > 5, `desplazamiento ${moved.toFixed(1)}`);
modified tests/stop.mjs +6 −2
@@ -9,8 +9,12 @@
99 const BASE = process.env.BASE || 'http://localhost:8799';
1010 let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
1111
12-const b = await chromium.launch({ channel: 'chrome', headless: true });
13-const p = await (await b.newContext()).newPage();
12+const b = await chromium.launch();
13+const ctx = await b.newContext();
14+// Modo Básico: sin esto, al abrir la página main.js se pone a cargar el modelo
15+// local por defecto (preloadModel) en mitad de la prueba, que no lo necesita.
16+await ctx.addInitScript(() => { try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} });
17+const p = await ctx.newPage();
1418 // Telemetría: se cuentan los informes en vez de dejarlos salir.
1519 let informes = 0;
1620 await p.route('**/proxy/report', route => { informes++; return route.fulfill({ status: 204, body: '' }); });
modified tests/stopqueue.mjs +10 −4
@@ -50,7 +50,11 @@
5050 };
5151 });
5252 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
53-await p.waitForTimeout(1500);
53+// Que el IDE haya abierto de verdad (Monaco y las conversaciones): con una
54+// espera fija, en una máquina cargada se mandaba antes de que existiera la
55+// conversación y el mensaje no iba a ninguna parte.
56+const listo = pg => pg.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 30000 });
57+await listo(p);
5458 await ayudantes();
5559
5660 // 1. Parar mientras espera el cerrojo → el modelo ni se llama
@@ -169,7 +173,8 @@
169173 ok('3 · justo después de parar, IndexedDB ya tiene la cola vacía (el turno aún se está soltando)',
170174 r3.sigueTrabajando && r3.colaGuardada === 0, `cola guardada ${r3.colaGuardada}`);
171175 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
172-await p.waitForTimeout(2500);
176+await listo(p);
177+await p.waitForTimeout(1000);
173178 await ayudantes();
174179 const r3b = await p.evaluate(async (id) => {
175180 const db = await import('/js/db.js');
@@ -336,7 +341,8 @@
336341 // acepta, como haría quien recarga a propósito.
337342 p.once('dialog', d => d.accept().catch(() => {}));
338343 await p.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
339-await p.waitForTimeout(2500);
344+await listo(p);
345+await p.waitForTimeout(1000);
340346 await ayudantes();
341347 const tarjeta6b = await p.evaluate(() => {
342348 const c = [...document.querySelectorAll('.plan-card')].at(-1);
@@ -388,7 +394,7 @@
388394 const pe = await ctxEn.newPage({ viewport: { width: 1300, height: 900 } });
389395 pe.on('pageerror', e => errs.push(e.message.slice(0, 160)));
390396 await pe.goto(BASE + '/?test-opfs', { waitUntil: 'domcontentloaded' });
391- await pe.waitForTimeout(1500);
397+ await listo(pe);
392398 const inicial = await boton(pe);
393399 await pe.evaluate(async () => {
394400 window.__dormir = ms => new Promise(r => setTimeout(r, ms));