From 2dc0b15b4d750b0b475f2dc9a2f254a0da03a5ba Mon Sep 17 00:00:00 2001 From: Harenome Ranaivoarivony-Razanajato Date: Mon, 23 Nov 2026 15:25:09 +0100 Subject: [PATCH] fix(builder): show each recipe error once on Review, and no Ready beside a held Run Prerequisites no longer repeats the recipe's compile errors (the route asks no machine and returns none), and the Run box no longer repeats what the red box lists. The Prerequisites head says Ready or Missing something only beside a Run that the machines alone hold; a Run held for a model key, or absent for recipe errors, already says why. --- app/static/builder/command-builder.js | 16 +++++++++---- .../test_command_builder_providers.py | 24 +++++++++++++++++++ app/ui_tests/test_prerequisites_route.py | 8 +++++++ app/web/builder.py | 4 ++-- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/app/static/builder/command-builder.js b/app/static/builder/command-builder.js index 8a69b81f..720c5443 100644 --- a/app/static/builder/command-builder.js +++ b/app/static/builder/command-builder.js @@ -87,7 +87,13 @@ return saved.length ? saved.map(s => `
${esc(s.name)}${esc(s.recipe.harness)} · ${esc(new Date(s.saved).toLocaleDateString())}${state(s.recipe)}` + `
${button('Load', `data-load="${esc(s.id)}"`)} ${button('Delete', del(s.id))}
`).join('') : '

No saved recipes.

'; } - if (typeof module === 'object' && module.exports) { module.exports = {servedRows, recipeStore, savedList}; return; } + // The Prerequisites head: a status only beside a Run the machines alone hold; a held or absent Run says why itself. + function prereqHead(out, busy, run) { + if (busy) return 'checking…'; + if (!out || !run || run.hasAttribute('data-held')) return ''; + return out.ready ? 'Ready' : 'Missing something: Run waits'; + } + if (typeof module === 'object' && module.exports) { module.exports = {servedRows, recipeStore, savedList, prereqHead}; return; } const root = document.getElementById('nullius-builder'); if (!root) return; const schema = JSON.parse(document.getElementById('nb-schema').textContent); @@ -1020,10 +1026,10 @@ if(blocked)return `
${button('▶ Run on '+esc(where),'id="nb-run" disabled data-held title="'+esc(blocked)+'"','nb-button nb-primary')}

${esc(blocked)} ${button('Model step','data-step="'+S.model+'"','nb-inlinebutton')} · ${button('Settings','data-href="/settings#'+C.needsOf(C.choiceOf(rec))+'"','nb-inlinebutton')}

`; if(C.isStandard(rec)){ const out=runnerOut||{errors:[{message:'Compiling the recipe…'}]}, noun=C.isStandard(rec)?unitsOf(rec).noun:'item'; - return `
${(out.errors||[]).length?out.errors.map(e=>`

${esc(e.message)}

`).join(''):`
${button('▶ Run on '+esc(where),'id="nb-run"','nb-button nb-primary')}
`+(out.confirm?`

No ${esc(noun)} limit: ${esc(out.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.

`:'')}
`; + return `
${(out.errors||[]).length?(runnerOut?[]:out.errors).map(e=>`

${esc(e.message)}

`).join(''):`
${button('▶ Run on '+esc(where),'id="nb-run"','nb-button nb-primary')}
`+(out.confirm?`

No ${esc(noun)} limit: ${esc(out.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.

`:'')}
`; } - const plan=C.runnable(rec); - return `
${plan.errors.length?plan.errors.map(e=>`

${esc(e)}

`).join(''):`
${button('▶ Run on '+esc(where),'id="nb-run"'+(C.validate(rec).errors.length?' disabled data-held':''),'nb-button nb-primary')}
`+(plan.confirm?`

No task limit: ${esc(plan.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.

`:'')}
`; + const plan=C.runnable(rec), listed=C.compile(rec).errors.map(e=>e.message); // the red box's, not said twice + return `
${plan.errors.length?plan.errors.filter(e=>!listed.includes(e)).map(e=>`

${esc(e)}

`).join(''):`
${button('▶ Run on '+esc(where),'id="nb-run"'+(C.validate(rec).errors.length?' disabled data-held':''),'nb-button nb-primary')}
`+(plan.confirm?`

No task limit: ${esc(plan.confirm.replace(/^Run /,'').replace(/\?$/,''))}. Run asks before it starts.

`:'')}
`; }; // Prerequisites: what the recipe needs of each machine it runs on, asked when Review opens and on Check again // (/new-run/prerequisites, nullius/prerequisites.py). Run waits until every row is ready; the run asks again as it starts. @@ -1044,7 +1050,7 @@ const el=$('#nb-prereq'); if(!el)return; const out=prereq.out, mark={ok:'✓',missing:'✕',install:'↓'}; const rows=m=>m.rows.map(x=>`
  • ${esc(x.label)}${x.detail?` ${esc(x.detail)}`:''}${x.state==='missing'&&x.install.length?`${x.install.map(esc).join('
    ')}
    `:''}
  • `).join(''); - const head=prereq.busy?'checking…':out&&out.ready?'Ready':out?'Missing something: Run waits':''; + const head=prereqHead(out,prereq.busy,$('#nb-run')); el.innerHTML=`

    Prerequisites

    ${head}${button('Check again','id="nb-prereq-again"'+(prereq.busy?' disabled':''),'nb-inlinebutton')}
    ` +(out?(out.errors||[]).map(e=>`

    ${esc(e)}

    `).join('')+(out.notes||[]).map(n=>`

    ${esc(n)}

    `).join('') +out.machines.map(m=>`
    ${out.machines.length>1?`${esc(m.label)}`:''}
    `).join(''):''); diff --git a/app/ui_tests/test_command_builder_providers.py b/app/ui_tests/test_command_builder_providers.py index 0c645573..cd3c08bc 100644 --- a/app/ui_tests/test_command_builder_providers.py +++ b/app/ui_tests/test_command_builder_providers.py @@ -77,6 +77,30 @@ def test_validation_knows_the_providers(self): self.assertEqual([e for e in errs('r.provider="openrouter";r.urlEnv="API_URL"') if 'provider/model' in e], []) +class ReviewSaysEachThingOnce(CompilerCase): + """Review lists a recipe's errors once, in its red box, and Prerequisites says Ready or Missing only beside a Run + that the machines alone hold: a Run held for a key or absent for errors says why itself.""" + + def test_the_prerequisites_head_speaks_only_beside_a_run_the_machines_hold(self): + out = self.js('const {prereqHead}=require(' + json.dumps(str(APP / 'static/builder/command-builder.js')) + ');' + 'const run=held=>({hasAttribute:a=>a==="data-held"&&held}),ok={ready:true,machines:[{rows:[]}]},no={ready:false,machines:[{rows:[]}]};' + 'process.stdout.write(JSON.stringify([prereqHead(ok,false,run(false)),prereqHead(no,false,run(false)),prereqHead(ok,false,run(true)),' + 'prereqHead(no,false,run(true)),prereqHead({ready:false,machines:[],errors:[]},false,null),prereqHead(null,true,run(false)),prereqHead(null,false,run(false))]));') + self.assertIn('>Ready<', out[0]) # a key and a valid recipe: as before + self.assertIn('Missing something: Run waits', out[1]) + self.assertEqual(out[2:5], ['', '', '']) # held for a key; no Run, the recipe has errors + self.assertIn('checking', out[5]) + self.assertEqual(out[6], '') + + def test_a_pinned_harbor_recipe_with_errors_leaves_them_to_the_red_box(self): + """The Run box drops what C.compile lists (the red box): a pinned Harbor recipe's errors are all of those.""" + out = self.js('const r=C.create("harbor");' + PIN + 'r.agents=[];r.tasks="-2";' + 'const listed=C.compile(r).errors.map(e=>e.message),plan=C.runnable(r).errors;' + 'process.stdout.write(JSON.stringify([listed.length,plan.length,plan.filter(e=>!listed.includes(e))]));') + self.assertTrue(out[0] and out[1], out) + self.assertEqual(out[2], []) + + class ProviderFromSettings(CompilerCase): """The provider follows the keys set in Settings: a new recipe starts on the first one set (OpenRouter, OpenAI, then a local endpoint, which its diff --git a/app/ui_tests/test_prerequisites_route.py b/app/ui_tests/test_prerequisites_route.py index 20d2e467..22f724a0 100644 --- a/app/ui_tests/test_prerequisites_route.py +++ b/app/ui_tests/test_prerequisites_route.py @@ -59,6 +59,14 @@ def test_a_standard_recipe_on_local_processes_needs_no_docker(self): j = self.post("/new-run/prerequisites", {"recipe": rec}).get_json() self.assertEqual((j["ready"], j["machines"][0]["rows"]), (True, [])) + def test_a_recipe_with_errors_asks_no_machine_and_repeats_none_of_them(self): + """The recipe's own errors are listed once on Review, by the page; Prerequisites asks no machine and says none.""" + rec = {"version": 1, "harness": "standard", "name": "s", "title": "s", "benchmark": "gsm8k", "datasets": ["platinum"], + "others": ["original"], "provider": "openai", "model": "gpt-5-mini", "limit": -3, "where": "local"} + with patch.object(prerequisites, "check_here", lambda *a, **k: self.fail("machine asked")): + j = self.post("/new-run/prerequisites", {"recipe": rec}).get_json() + self.assertEqual((j["machines"], j["ready"], j["errors"]), ([], False, [])) + def test_stella_memory_reaches_review_and_the_local_machine_check(self): rec = {"version": 1, "harness": "standard", "name": "stella", "title": "Stella", "benchmark": "longmemeval", "datasets": ["longmemeval_s"], "others": ["original"], "provider": "openai", "model": "gpt-4o", diff --git a/app/web/builder.py b/app/web/builder.py index 8269e2a3..e1404d5f 100644 --- a/app/web/builder.py +++ b/app/web/builder.py @@ -248,8 +248,8 @@ def new_run_prerequisites(): standard = recipe.get("harness") == standard_recipe.HARNESS if standard: out = standard_recipe.compile(recipe) - if out["errors"]: - return jsonify(machines=[], ready=False, errors=[e["message"] for e in out["errors"]]) + if out["errors"]: # the recipe's own, listed once on Review: no machine is asked + return jsonify(machines=[], ready=False, errors=[]) wheres = [sh["where"] for sh in out["shards"]] needs = (["engine"] if out["docker"] else []) + (list(boat.PROGRAMS) if recipe.get("backend") == "boat" else []) h = out.get("host") or {}