Elffuss BraidHub

utopia-ia/elffuss-code public

SWE corpus: the five hard tasks get a scripted fix, so the scripted solver resolves 11 of 11

tests/swe_bench.mjs resolved 6 of 11. 1d93eca added
five hard tasks (total-iva, recorta-pie, dias-entre, dos-sitios,
orden-descendente: 151 to 598 lines each) with no `solution`, which the scripted
solver of tests/swe_bench.mjs writes. It wrote an empty file, the truncation
guard of the same commit refused it, and the five always failed. The Lab's
"Reglas" brain uses the same field and had the same gap.

Each hard task now has a `fix`: the exact replacement of its BUG line(s), and
`solution` is derived from it at load time, so it stays the seeded file with
only that change. tests/swe_bench.mjs (scripted) resolves 11/11 again and the
full-size rewrites go through code.write and its guard; each derived solution
passes its task's test and each seeded file still fails it.
Changeset06c5bad3cc8c3d775b673fc7da482bf01ccf7cd0fac0986f4b1639d3255c7a6d
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00
Parents71f77de4f55f

Browse the files at this changeset

1 file changed

modified web/js/swe-tasks.js +24 −0
@@ -373,6 +373,8 @@
373373 'spec/total-iva.md': '# totalCarrito(lineas, descuento, iva)\nDebe aplicar el IVA al final: totalCarrito([{precio:100,unidades:1}],0,0.21) → 121.',
374374 },
375375 task: 'totalCarrito() no aplica el IVA al resultado; arréglalo para que lo aplique después del descuento.',
376+ // cambia SOLO la línea del bug (ver «solution» de las duras, al final)
377+ fix: [[" return conDescuento; // BUG: no aplica el IVA", " return conDescuento * (1 + iva);"]],
376378 test: m => Math.round(m.totalCarrito([{precio:100,unidades:1}],0,0.21)) === 121 && Math.round(m.totalCarrito([{precio:50,unidades:2}],10,0.1)) === 99,
377379 },
378380 {
@@ -566,6 +568,8 @@
566568 task: 'recortaPie() debe añadir «…» al final cuando recorta. recortaTitulo y recortaResumen deben quedarse EXACTAMENTE como están.',
567569 // Lo que mide esta tarea es la DISCRIMINACIÓN entre tres cuerpos idénticos, no
568570 // si el modelo escribe «…» o «...»: las dos son respuestas razonables a la spec.
571+ // cambia SOLO la línea del bug (ver «solution» de las duras, al final)
572+ fix: [[" return s.slice(0, max); // BUG: aquí SÍ hay que poner puntos suspensivos", " return s.slice(0, max) + '…';"]],
569573 test: m => { const r = m.recortaPie('a'.repeat(40));
570574 return r.startsWith('a'.repeat(30)) && /(…|\.\.\.)$/.test(r)
571575 && m.recortaTitulo('a'.repeat(40)) === 'a'.repeat(30)
@@ -792,6 +796,8 @@
792796 'spec/dias-entre.md': '# diasEntre(a, b)\ndiasEntre("2026-01-01","2026-01-03") → 2. No se suma un día extra.',
793797 },
794798 task: 'diasEntre() devuelve un día de más; quita ese +1.',
799+ // cambia SOLO la línea del bug (ver «solution» de las duras, al final)
800+ fix: [["\treturn Math.floor(ms / 86400000) + 1; // BUG: el +1 sobra", "\treturn Math.floor(ms / 86400000);"]],
795801 test: m => m.diasEntre('2026-01-01','2026-01-03') === 2 && m.diasEntre('2026-01-01','2026-01-01') === 0,
796802 },
797803 {
@@ -952,6 +958,8 @@
952958 'spec/dos-sitios.md': '# validaUsuario / validaAlias\nAmbas deben exigir MÁS de 3 caracteres: una cadena de 3 es inválida, una de 4 es válida.',
953959 },
954960 task: 'validaUsuario() y validaAlias() aceptan cadenas de 3 caracteres y no deberían: hay que exigir más de 3 en LAS DOS.',
961+ // cambia SOLO la línea del bug (ver «solution» de las duras, al final)
962+ fix: [[" if (nombre.length < MINIMO) return false; // BUG: debe ser <= para exigir MÁS de 3", " if (nombre.length <= MINIMO) return false;"], [" if (alias.length < MINIMO) return false; // BUG: mismo fallo aquí", " if (alias.length <= MINIMO) return false;"]],
955963 test: m => m.validaUsuario('abc')===false && m.validaUsuario('abcd')===true && m.validaAlias('abc')===false && m.validaAlias('abcd')===true,
956964 },
957965 {
@@ -1559,6 +1567,22 @@
15591567 'spec/orden-descendente.md': '# ordenaPorFecha(filas)\nDe más reciente a más antigua.',
15601568 },
15611569 task: 'ordenaPorFecha() ordena de más antigua a más reciente; debe ser al revés, la más reciente primero.',
1570+ // cambia SOLO la línea del bug (ver «solution» de las duras, al final)
1571+ fix: [[" return filas.slice().sort((a, b) => a.fecha - b.fecha); // BUG: debe ser descendente", " return filas.slice().sort((a, b) => b.fecha - a.fecha);"]],
15621572 test: m => { const r = m.ordenaPorFecha([{fecha:1},{fecha:3},{fecha:2}]); return r[0].fecha===3 && r[2].fecha===1; },
15631573 },
15641574 ];
1575+
1576+// Las DURAS no traen `solution` escrita a mano (son ficheros de cientos de
1577+// líneas): se saca de su `fix`, que cambia solo la línea del bug. Sin ella el
1578+// solucionador de guion (el arnés tests/swe_bench.mjs y el Lab con «Reglas»)
1579+// escribía un contenido vacío y las cinco fallaban siempre; con ella, además,
1580+// prueban que reescribir un fichero entero pasa por code.write.
1581+for (const t of TASKS) {
1582+ if (t.solution != null || !t.fix) continue;
1583+ let src = t.files[t.target];
1584+ if (t.fix.every(([de]) => src.includes(de))) {
1585+ for (const [de, a] of t.fix) src = src.replace(de, a);
1586+ t.solution = src;
1587+ }
1588+}