bareloop 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@
48
48
  always-scrolling wrapper makes the header genuinely sticky on both
49
49
  breakpoints, and also owns the horizontal scroll for the Path column
50
50
  on narrow (390px) screens instead of leaving it to .pane-body. */
51
- .audit-table-scroll{overflow:auto;max-height:min(60vh,520px);}
51
+ .audit-table-scroll{overflow:auto;max-height:min(60vh,520px);max-width:100%;}
52
52
  /* z-index keeps rows from showing through the solid th background as
53
53
  they scroll under it. */
54
54
  [data-testid="audit-table"] th{position:sticky;top:0;z-index:1;}
@@ -388,11 +388,46 @@
388
388
  .step-card h4{margin:0;font-size:13px;text-transform:none;letter-spacing:0;}
389
389
  .step-meta{font-size:12px;color:var(--text-dim);margin-top:4px;}
390
390
  /* build item C: Audit tab attempt/rounds detail (reused by audit-part-toggle expansion) */
391
- .attempts-list{margin-top:8px;border-top:1px dotted var(--border-strong);padding-top:8px;}
392
- .attempt-row{margin-bottom:6px;}
393
- .attempt-toggle{margin-bottom:4px;}
394
391
  .rounds-list{margin:6px 0 6px 12px;padding-left:8px;border-left:2px solid var(--border-strong);}
395
- .checks-list{margin:6px 0 0 12px;padding:6px 8px;border-left:2px solid var(--border-strong);font-size:12px;color:var(--text-faint);}
392
+ /* PRD v1.119 (signed mock variant F): the Audit check grid, its errors list and the rounds folded per try */
393
+ .glyph-q{color:var(--magenta);} .glyph-nr{color:var(--text-faint);}
394
+ .rounds-fold{margin:4px 0 6px 12px;font-size:12px;}
395
+ .rounds-fold>summary{cursor:pointer;color:var(--text-dim);min-height:28px;overflow-wrap:anywhere;}
396
+ .rounds-fold .rf-body{margin-top:4px;padding-left:8px;border-left:2px solid var(--border-strong);}
397
+ .sub-label{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:0.06em;margin:12px 0 4px;}
398
+ .grid-wrap{overflow:auto;max-width:100%;}
399
+ table.grid{width:100%;min-width:0;}
400
+ table.grid th.q,table.grid td.q{min-width:170px;max-width:340px;white-space:normal;overflow-wrap:anywhere;font-size:12px;}
401
+ table.grid th.t,table.grid td.c{text-align:center;width:64px;min-width:56px;white-space:nowrap;}
402
+ table.grid th.t .hint{display:block;text-transform:none;letter-spacing:0;font-weight:400;margin:0;}
403
+ table.grid td.c{padding:2px;}
404
+ .cell{border:1px solid transparent;background:none;min-width:44px;min-height:32px;color:var(--text-faint);font-size:14px;font-weight:700;}
405
+ .cell.fail{color:var(--red);border-color:var(--border-strong);background:var(--red-bg);}
406
+ .cell.pass{color:var(--green);cursor:default;}
407
+ .cell.notrun{color:var(--text-faint);cursor:default;}
408
+ .cell.unk{color:var(--magenta);cursor:default;}
409
+ .fold-list{margin-top:10px;}
410
+ .fgrid .cell.fail[aria-expanded="true"]{outline:2px solid var(--red);outline-offset:1px;}
411
+ .fx-errors{margin:8px 0 4px;min-width:0;}
412
+ .fx-label{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:0.06em;margin-bottom:2px;}
413
+ .fx-row{min-width:0;}
414
+ .fx-rowhead{display:flex;align-items:baseline;gap:8px;width:100%;min-width:0;min-height:32px;padding:3px 4px;border:0;background:none;color:var(--text);font:inherit;font-size:12px;text-align:left;}
415
+ button.fx-rowhead{cursor:pointer;}
416
+ button.fx-rowhead:hover{background:var(--panel2);}
417
+ button.fx-rowhead:focus-visible,.fx-more:focus-visible,.cell.fail:focus-visible{outline:2px solid var(--red);outline-offset:1px;}
418
+ .fx-caret{flex:none;width:12px;color:var(--text-faint);}
419
+ .fx-try{flex:none;font-weight:700;}
420
+ .fx-chk{flex:none;white-space:nowrap;}
421
+ .fx-first{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-dim);}
422
+ .fx-faint,.fx-count{color:var(--text-faint);}
423
+ .fx-count{flex:none;white-space:nowrap;}
424
+ .fx-row.open>.fx-rowhead{background:var(--red-bg);}
425
+ .fx-body{margin:0 0 6px 20px;border-left:2px solid var(--red);padding:4px 10px;background:var(--red-bg);min-width:0;}
426
+ .fx-sub{font-size:12px;color:var(--text);font-weight:700;margin:6px 0 2px;overflow-wrap:anywhere;}
427
+ .fx-lines{font-size:12px;color:var(--text-dim);}
428
+ .fx-lines div{margin:1px 0;overflow-wrap:anywhere;}
429
+ .fx-judged{overflow-wrap:anywhere;}
430
+ .fx-more{margin-top:4px;min-height:28px;padding:2px 8px;border:1px solid var(--border-strong);background:var(--panel2);color:var(--text);font-size:12px;}
396
431
  /* item 1 (2026-09-26): a round's own model call renders as this table's
397
432
  header ROW (visually distinct from its tool-call rows below it). */
398
433
  tr.round-header-row td{background:var(--panel2);font-weight:700;}
@@ -417,11 +452,6 @@
417
452
  .actor-mark{color:var(--text-faint);font-size:12px;margin-left:6px;white-space:nowrap;}
418
453
  .step-tally{font-size:12px;color:var(--text-dim);overflow-wrap:anywhere;margin:2px 0 6px;}
419
454
  .try-line{margin:10px 0 2px;overflow-wrap:anywhere;font-weight:700;}
420
- .try-check,.try-judged{margin:2px 0 2px 12px;font-size:13px;overflow-wrap:anywhere;}
421
- .try-judged{font-size:12px;color:var(--text-dim);}
422
- .try-reasons{margin:2px 0 4px 12px;font-size:12px;color:var(--text-dim);}
423
- .try-reasons summary{cursor:pointer;}
424
- .try-reasons div{margin:2px 0 2px 8px;overflow-wrap:anywhere;}
425
455
  .step-rounds-note{font-size:12px;color:var(--text-faint);margin:8px 0 2px;overflow-wrap:anywhere;}
426
456
  .rounds-page-info{margin-top:6px;display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
427
457
 
@@ -642,7 +672,9 @@
642
672
  .pv-knote > .hint:empty{display:none;}
643
673
  .pv-key[data-open="0"] .pv-models{display:none;}
644
674
  .pv-mrow{border-top:1px dotted var(--border-strong);min-height:32px;}
645
- .pv-mrow:hover,.pv-mrow:focus-within{background:var(--panel2);}
675
+ .pv-mrow:hover{background:var(--panel2);}
676
+ .pv-mrow:focus-within,.pv-mrow:focus-within:hover{background:var(--rl-accent-bg-strong);box-shadow:inset 0 0 0 2px var(--accent);}
677
+ .pv-mrow:focus{outline:none;}
646
678
  .pv-um{grid-column:1;display:flex;align-items:center;gap:0;min-width:0;}
647
679
  .pv-uh,.pv-m-use{flex:0 0 44px;width:44px;display:flex;align-items:center;justify-content:center;}
648
680
  .pv-m-use{min-height:32px;}
@@ -1153,6 +1185,11 @@
1153
1185
  if(outcome === null || outcome === undefined) return boxIsLive ? "▶" : "?";
1154
1186
  return "✗";
1155
1187
  }
1188
+ // a try that no close ended (the provider dropped it, the person stopped it, it died) has no verdict: "?", the same sign the Audit grid's column wears.
1189
+ // `a.noVerdict` is the server's word for it (src/panel/server.js); every surface that draws a try's glyph reads this one rule.
1190
+ function tryGlyph(a, boxIsLive){
1191
+ return a && typeof a.noVerdict === "string" && a.noVerdict !== "" ? "?" : attemptGlyph(a ? a.outcome : null, boxIsLive);
1192
+ }
1156
1193
  // P3 addition: colour ONLY [✓]/[✗] (the standing wording ruling's own
1157
1194
  // words/glyph vocabulary is unchanged — this wraps the same glyph
1158
1195
  // character in a plain inline colour span for the two result-carrying
@@ -1169,7 +1206,7 @@
1169
1206
  // part-card renderer below, never by this function.
1170
1207
  function attemptsInlineText(attempts, boxIsLive){
1171
1208
  if(!attempts || !attempts.length) return "";
1172
- return attempts.map(function(a){ return "attempt " + a.n + " " + attemptGlyph(a.outcome, boxIsLive); }).join(" · ");
1209
+ return attempts.map(function(a){ return "attempt " + a.n + " " + tryGlyph(a, boxIsLive); }).join(" · ");
1173
1210
  }
1174
1211
  function stepTitleText(idx, s){
1175
1212
  var base = s.noNumber ? s.title : (idx + 1) + ' ' + s.title;
@@ -1229,7 +1266,8 @@
1229
1266
  if(part.kind === "drafting") return glyphSpan(attemptGlyph("green", false)); // [✓]: drafting is done once the run exists
1230
1267
  if(partHasNoVerdict(part)) return null;
1231
1268
  var boxIsLive = box.state === "running";
1232
- if(box.attempts.length > 1) return box.attempts.map(function(a){ return glyphSpan(attemptGlyph(a.outcome, boxIsLive)); }).join("");
1269
+ if(box.attempts.length > 1) return box.attempts.map(function(a){ return glyphSpan(tryGlyph(a, boxIsLive)); }).join("");
1270
+ if(box.attempts.length === 1 && box.attempts[0].noVerdict) return glyphSpan(tryGlyph(box.attempts[0], boxIsLive));
1233
1271
  var outcome = (part.outcome !== null && part.outcome !== undefined) ? part.outcome : (box.attempts[0] ? box.attempts[0].outcome : null);
1234
1272
  return glyphSpan(attemptGlyph(outcome, boxIsLive));
1235
1273
  }
@@ -2976,47 +3014,6 @@
2976
3014
  function stateDotHTML(cls, word, testid){
2977
3015
  return '<span class="step-state" data-testid="' + testid + '"><span class="dot ' + cls + (cls === "amber" ? " pulse" : "") + '"></span><b class="st-word">' + escapeXml(word) + '</b></span>';
2978
3016
  }
2979
- // build item C: Audit tab attempt row -> its rounds (server-built,
2980
- // lazy-fetched on expand via /api/runs/:runid/rounds?part=<i>&attempt=<n>).
2981
- function buildAttemptsList(container, partIndex, attempts, boxIsLive){
2982
- container.innerHTML = "";
2983
- attempts.forEach(function(a){
2984
- var row = document.createElement("div");
2985
- row.className = "attempt-row";
2986
- row.setAttribute("data-testid", "audit-attempt-" + partIndex + "-" + a.n);
2987
- // plain-checks build (2026-09-28): the withdrawn "checks N/M" headline
2988
- // is replaced by attemptChecksLine's plain words (including the
2989
- // opening outer-close grade, which is attempt 1 on this SAME list —
2990
- // src/replay.js's fixLoop.attempts) — "" for a rubric/command close or
2991
- // a still-running attempt with no stages yet.
2992
- var checksText = attemptChecksLine(a);
2993
- var checksList = fullStageList(a).map(stageLineHtml).join("<br>");
2994
- row.innerHTML =
2995
- '<button class="btn small attempt-toggle" type="button" aria-expanded="false">' +
2996
- 'attempt ' + a.n + ' ' + attemptGlyph(a.outcome, boxIsLive) +
2997
- (a.thinking ? ' &middot; ' + escapeXml(a.thinking) : '') +
2998
- (checksText ? ' &middot; ' + checksText : '') +
2999
- '</button>' +
3000
- (checksList ? '<div class="checks-list" data-testid="audit-attempt-checks-' + partIndex + '-' + a.n + '" hidden>' + checksList + '</div>' : '') +
3001
- '<div class="rounds-list" hidden></div>';
3002
- container.appendChild(row);
3003
- var btn = row.querySelector(".attempt-toggle");
3004
- var roundsEl = row.querySelector(".rounds-list");
3005
- var checksEl = row.querySelector(".checks-list");
3006
- var built = false;
3007
- btn.addEventListener("click", function(){
3008
- var expanded = btn.getAttribute("aria-expanded") === "true";
3009
- btn.setAttribute("aria-expanded", expanded ? "false" : "true");
3010
- roundsEl.hidden = expanded;
3011
- if(checksEl) checksEl.hidden = expanded;
3012
- if(!expanded && !built){
3013
- built = true;
3014
- loadRounds(roundsEl, partIndex, a, 0);
3015
- }
3016
- });
3017
- });
3018
- }
3019
-
3020
3017
  // PRD v1.106 Part 5: who did a part's work, in the server's own words (`part.marker`: [model] or [human · ask]); nothing typed here
3021
3018
  function actorMarkHtml(part){
3022
3019
  return part && typeof part.marker === "string" && part.marker !== "" ? ' <span class="actor-mark" data-testid="actor-mark">' + escapeXml(part.marker) + '</span>' : "";
@@ -3029,75 +3026,241 @@
3029
3026
  }).join("");
3030
3027
  return '<div class="audit-table-scroll"><table class="rounds-table" data-testid="door-table"><thead><tr><th>Round</th><th>Try</th><th>Action</th><th>Path</th><th>Decision</th><th>Time</th></tr></thead><tbody>' + rows + "</tbody></table></div>";
3031
3028
  }
3032
- // PRD v1.106 Part 5 C: one try, in the server's words: its line (result glyph, thinking, the first reason and how many more), its numbered checks
3033
- // in the order they ran (each with its result, a count or a folded reasons list, the job line it serves) and the file it judged
3034
- function tryBlockHtml(part, t, boxIsLive, partIndex){
3035
- var attempt = (part.attempts || []).filter(function(a){ return a.n === t.n; })[0] || null;
3036
- var testid = "audit-try-" + partIndex + "-" + t.n;
3037
- if(t.cutOff){
3038
- return '<div class="try-line" data-testid="' + testid + '">try ' + t.n + (t.thinking ? " &middot; " + escapeXml(t.thinking) : "") + " &middot; " + escapeXml(t.words || "") + "</div>";
3039
- }
3040
- var checks = attempt && Array.isArray(attempt.checks) ? attempt.checks : [];
3041
- var firstBad = checks.filter(function(c){ return !c.pass && c.gap; })[0] || null;
3042
- var html = '<div class="try-line" data-testid="' + testid + '">try ' + t.n + " " + glyphSpan(attemptGlyph(t.outcome, boxIsLive)) +
3043
- (t.thinking ? " &middot; " + escapeXml(t.thinking) : "") +
3044
- (firstBad ? " &middot; " + escapeXml(firstBad.gap) + (firstBad.moreText ? " " + escapeXml(firstBad.moreText) : "") : "") + "</div>";
3045
- checks.forEach(function(c){
3046
- var label = c.question || c.name || "unknown";
3047
- html += '<div class="try-check" data-testid="' + testid + '-check-' + c.n + '">' + c.n + " " + glyphSpan(c.pass ? "\u2713" : "\u2717") + " " + escapeXml(label) +
3048
- (c.note ? " (" + escapeXml(c.note) + ")" : "") + (c.from ? " &middot; " + escapeXml(c.from) : "") + "</div>";
3049
- if(!c.pass && c.reasonsLabel){
3050
- html += '<details class="try-reasons" data-testid="' + testid + '-reasons-' + c.n + '"><summary>' + escapeXml(c.reasonsLabel) + "</summary>" +
3051
- c.reasons.map(function(r){ return "<div>" + escapeXml(r) + "</div>"; }).join("") + "</details>";
3052
- }
3029
+ // PRD v1.119 (signed mock design/audit-grid-mock.html variant F): ONE look for a plan step's tries and the fix loop's tries. A grid per part (rows =
3030
+ // the part's checks in DECLARED order with their plain questions, columns = tries), under it an "errors" list (one row per try that failed or has
3031
+ // no verdict), then the rounds folded per try. Every word comes from the server (`part.tries`, `attempt.checks`/`stages`/`reasons`/`noVerdict`,
3032
+ // `declaredStages`, `stageQuestionText`); the page joins checks to declared rows by NAME and types none of them.
3033
+ function gridGlyph(g){
3034
+ if(g === "✓") return '<span class="glyph-green">' + g + '</span>';
3035
+ if(g === "✗") return '<span class="glyph-red">' + g + '</span>';
3036
+ if(g === "?") return '<span class="glyph-q">' + g + '</span>';
3037
+ if(g === "·") return '<span class="glyph-nr">' + g + '</span>';
3038
+ return g;
3039
+ }
3040
+ function gridPlural(n, w){ return n + " " + w + (n === 1 ? "" : "s"); }
3041
+ // a plan step's graded try (`part.tries[i]` + its attempt's checks, run order) as one grid column; a cut-off try ran no check: no verdict
3042
+ function gridStepTryOf(part, t, boxIsLive){
3043
+ var a = (part.attempts || []).filter(function(x){ return x.n === t.n; })[0] || null;
3044
+ var out = {
3045
+ n: t.n, glyph: t.cutOff ? "?" : attemptGlyph(t.outcome, boxIsLive), hint: t.thinking || "", noVerdict: t.cutOff ? (t.words || "") : null,
3046
+ known: false, inflight: false, cells: {}, order: [], judged: a && Array.isArray(a.judged) ? a.judged : [], attempt: a || { n: t.n }, calls: a ? (typeof a.rounds === "number" ? a.rounds : null) : (t.cutOff && part.cutOffTry && typeof part.cutOffTry.rounds === "number" ? part.cutOffTry.rounds : null), opening: false
3047
+ };
3048
+ if(!t.cutOff && a && Array.isArray(a.checks)){
3049
+ out.known = true;
3050
+ a.checks.forEach(function(c){
3051
+ out.cells[c.name] = { name: c.name, question: c.question, status: c.pass ? "pass" : "fail", number: c.pass && c.note ? c.note : null, reasons: c.reasons || [] };
3052
+ out.order.push(c.name);
3053
+ });
3054
+ }
3055
+ return out;
3056
+ }
3057
+ // a fix try: the opening close or one fix iteration; `stages` are the checks that RAN (first-red-wins), `reasons` the failing one's output lines
3058
+ function gridFixTryOf(a, boxIsLive){
3059
+ var noVerdict = typeof a.noVerdict === "string" && a.noVerdict !== "" ? a.noVerdict : null;
3060
+ var out = {
3061
+ n: a.n, glyph: tryGlyph(a, boxIsLive), hint: a.source === "outer-close" ? "opening close" : (a.thinking || ""), noVerdict: noVerdict,
3062
+ known: Array.isArray(a.stages), judged: [], inflight: (a.outcome === null || a.outcome === undefined) && !!boxIsLive, cells: {}, order: [], attempt: a,
3063
+ calls: typeof a.rounds === "number" ? a.rounds : null, opening: a.source === "outer-close"
3064
+ };
3065
+ if(out.known){
3066
+ var failSeen = false;
3067
+ a.stages.forEach(function(s){
3068
+ var ok = s.verdict === "satisfied";
3069
+ var cell = { name: s.name, question: stageQuestionText(s), status: ok ? "pass" : "fail", number: ok ? (stageNumberText(s) || null) : null, reasons: [] };
3070
+ if(!ok && !failSeen){ failSeen = true; cell.reasons = Array.isArray(a.reasons) ? a.reasons : []; }
3071
+ out.cells[s.name] = cell;
3072
+ out.order.push(s.name);
3073
+ });
3074
+ }
3075
+ return out;
3076
+ }
3077
+ // the rows, DECLARED order (the server's `n` is run order): every declared check for the fix loop, only the checks a step's tries ran for a step;
3078
+ // a check the declaration does not name (a step's own exit check) follows, numbered on from the declared ones
3079
+ function gridRowsOf(declared, tries, stepOnly){
3080
+ var used = {};
3081
+ tries.forEach(function(t){ t.order.forEach(function(nm){ used[nm] = true; }); });
3082
+ var rows = [];
3083
+ var listed = {};
3084
+ declared.forEach(function(d, i){
3085
+ if(stepOnly && !used[d.name]) return;
3086
+ rows.push({ n: i + 1, name: d.name, question: stageQuestionText(d) });
3087
+ listed[d.name] = true;
3088
+ });
3089
+ var next = declared.length;
3090
+ tries.forEach(function(t){
3091
+ t.order.forEach(function(nm){
3092
+ if(listed[nm]) return;
3093
+ listed[nm] = true;
3094
+ next += 1;
3095
+ rows.push({ n: next, name: nm, question: stageQuestionText(t.cells[nm]) });
3096
+ });
3097
+ });
3098
+ return rows;
3099
+ }
3100
+ function gridModelOf(part, boxIsLive){
3101
+ var attempts = Array.isArray(part.attempts) ? part.attempts : [];
3102
+ var declared = [];
3103
+ attempts.some(function(a){
3104
+ if(Array.isArray(a.declaredStages) && a.declaredStages.length > 0){ declared = a.declaredStages; return true; }
3105
+ return false;
3053
3106
  });
3054
- (attempt && Array.isArray(attempt.judged) ? attempt.judged : []).forEach(function(j){
3055
- html += '<div class="try-judged" data-testid="' + testid + '-judged">' + escapeXml(j) + "</div>";
3107
+ var graded = part.kind === "step" && Array.isArray(part.tries) && part.tries.length > 0;
3108
+ var tries = graded
3109
+ ? part.tries.map(function(t){ return gridStepTryOf(part, t, boxIsLive); })
3110
+ : attempts.map(function(a){ return gridFixTryOf(a, boxIsLive); });
3111
+ return { tries: tries, rows: gridRowsOf(declared, tries, graded) };
3112
+ }
3113
+ // one cell: pass, fail, not run (first-red-wins stopped the close) or no verdict
3114
+ function gridCellOf(t, row){
3115
+ if(t.noVerdict) return { s: "unk" };
3116
+ var c = t.cells[row.name];
3117
+ if(c) return { s: c.status, number: c.number };
3118
+ if(!t.known) return { s: t.inflight ? "notrun" : "unk" };
3119
+ return { s: "notrun" };
3120
+ }
3121
+ // a try's failing checks with their output lines, in row order (none for a try with no verdict)
3122
+ function gridFailsOf(model, t){
3123
+ if(t.noVerdict) return [];
3124
+ return model.rows.filter(function(r){ var c = t.cells[r.name]; return !!c && c.status === "fail"; }).map(function(r){
3125
+ return { row: r, reasons: t.cells[r.name].reasons || [] };
3056
3126
  });
3057
- return html;
3058
3127
  }
3059
- // PRD v1.106 Part 5 C: a plan step's fold — tools tally, every try with its checks, then ONE Round table for the whole step (20 rows a page)
3060
- function buildStepFold(body, partIndex, part, boxIsLive){
3128
+ // default on load: only the LAST failed try's row is open
3129
+ function gridDefaultOpen(model){
3130
+ var open = {};
3131
+ var last = null;
3132
+ model.tries.forEach(function(t){ if(gridFailsOf(model, t).length > 0) last = t.n; });
3133
+ if(last !== null) open[last] = true;
3134
+ return open;
3135
+ }
3136
+ function gridTableHtml(pid, model){
3137
+ if(model.rows.length === 0) return "";
3138
+ var head = '<tr><th class="q">check</th>' + model.tries.map(function(t){
3139
+ return '<th class="t">try ' + t.n + " " + gridGlyph(t.glyph) + (t.hint ? '<span class="hint">' + escapeXml(t.hint) + "</span>" : "") + "</th>";
3140
+ }).join("") + "</tr>";
3141
+ var body = model.rows.map(function(r){
3142
+ var tds = model.tries.map(function(t){
3143
+ var c = gridCellOf(t, r);
3144
+ if(c.s === "unk") return '<td class="c"><span class="cell unk" title="try ' + t.n + ': no verdict">' + gridGlyph("?") + "</span></td>";
3145
+ if(c.s === "notrun") return '<td class="c"><span class="cell notrun" title="not run (first-red-wins stopped the close)">' + gridGlyph("·") + "</span></td>";
3146
+ if(c.s === "pass") return '<td class="c"><span class="cell pass" title="passed' + (c.number ? ": " + escapeXml(c.number) : "") + '">' + gridGlyph("✓") + "</span></td>";
3147
+ return '<td class="c"><button type="button" class="cell fail" aria-expanded="false" aria-controls="fxerr-' + pid + '" data-fx="' + t.n + ":" + r.n + '" title="try ' + t.n + ", check #" + r.n + ': failed - click to read its errors">' + gridGlyph("✗") + "</button></td>";
3148
+ }).join("");
3149
+ return '<tr><td class="q">' + r.n + " " + escapeXml(r.question) + "</td>" + tds + "</tr>";
3150
+ }).join("");
3151
+ return '<div class="grid-wrap audit-table-scroll"><table class="grid fgrid" data-testid="audit-grid-table"><thead>' + head + "</thead><tbody>" + body + "</tbody></table></div>";
3152
+ }
3153
+ // the errors list: one row per try that failed or has no verdict; `st` = {open: {tryN: true}, more: {"tryN:checkN": true}}
3154
+ function gridErrorsHtml(pid, model, st){
3155
+ var rows = model.tries.map(function(t){
3156
+ if(t.noVerdict){
3157
+ return '<div class="fx-row fx-row-q"><span class="fx-rowhead"><span class="fx-caret"></span><span class="fx-try">try ' + t.n + '</span><span class="fx-chk">' + gridGlyph("?") + '</span><span class="fx-first fx-faint">' + escapeXml(t.noVerdict) + "</span></span></div>";
3158
+ }
3159
+ var fails = gridFailsOf(model, t);
3160
+ if(fails.length === 0) return "";
3161
+ var total = 0;
3162
+ fails.forEach(function(f){ total += f.reasons.length; });
3163
+ var firstLine = fails[0].reasons[0] || fails[0].row.question;
3164
+ var rest = Math.max(0, total - 1);
3165
+ var open = !!st.open[t.n];
3166
+ var head = '<button type="button" class="fx-rowhead" id="fxrow-' + pid + "-" + t.n + '" data-fxrow="' + t.n + '" aria-expanded="' + (open ? "true" : "false") + '"><span class="fx-caret">' + (open ? "▾" : "▸") +
3167
+ '</span><span class="fx-try">try ' + t.n + '</span><span class="fx-chk">#' + fails[0].row.n + " " + gridGlyph("✗") +
3168
+ (fails.length > 1 ? ' <span class="fx-faint">+' + (fails.length - 1) + " more check" + (fails.length > 2 ? "s" : "") + "</span>" : "") +
3169
+ '</span><span class="fx-first" title="' + escapeXml(firstLine) + '">' + escapeXml(firstLine) + "</span>" + (rest ? '<span class="fx-count">(+' + rest + " more)</span>" : "") + "</button>";
3170
+ var body = "";
3171
+ if(open){
3172
+ body = '<div class="fx-body">' + fails.map(function(f){
3173
+ var cap = 8;
3174
+ var ex = !!st.more[t.n + ":" + f.row.n];
3175
+ var shown = ex ? f.reasons : f.reasons.slice(0, cap);
3176
+ return (fails.length > 1 ? '<div class="fx-sub">#' + f.row.n + " " + escapeXml(f.row.question) + "</div>" : "") +
3177
+ '<div class="fx-lines">' + shown.map(function(r){ return "<div>" + escapeXml(r) + "</div>"; }).join("") + "</div>" +
3178
+ (f.reasons.length > cap ? '<button type="button" class="fx-more" data-fxmore="' + t.n + ":" + f.row.n + '">' + (ex ? "show first " + cap + " only" : "+" + (f.reasons.length - cap) + " more lines") + "</button>" : "");
3179
+ }).join("") + "</div>";
3180
+ }
3181
+ return '<div class="fx-row' + (open ? " open" : "") + '">' + head + body + "</div>";
3182
+ }).join("");
3183
+ return rows ? '<div class="fx-label">errors</div>' + rows : "";
3184
+ }
3185
+ // the rounds, folded per try, lazy: each fold fetches its own try's rounds (the per-attempt endpoint) the first time it opens
3186
+ function gridRoundsHtml(model){
3187
+ return '<div class="sub-label">rounds per try</div><div class="fold-list">' + model.tries.map(function(t){
3188
+ var line = '<div class="try-line" style="margin-top:6px">try ' + t.n + " " + gridGlyph(t.glyph) + "</div>";
3189
+ if(t.calls === 0){
3190
+ return line + '<div class="step-rounds-note">' + (t.opening ? "no rounds: the opening close ran before any model call" : "no rounds recorded") + "</div>";
3191
+ }
3192
+ return line + '<details class="rounds-fold" data-fxrounds="' + t.n + '"><summary>try ' + t.n + " rounds" + (t.calls === null ? "" : " (" + gridPlural(t.calls, "call") + ")") +
3193
+ '</summary><div class="rf-body"><div class="hint">loading&hellip;</div></div></details>';
3194
+ }).join("") + "</div>";
3195
+ }
3196
+ // a rubric step's try names the file its check read (the server's `attempt.judged` words): one faint line per try that has one
3197
+ function gridJudgedHtml(model){
3198
+ return model.tries.map(function(t){
3199
+ return (t.judged || []).map(function(j){ return '<div class="hint fx-judged">try ' + t.n + " &middot; " + escapeXml(j) + "</div>"; }).join("");
3200
+ }).join("");
3201
+ }
3202
+ function gridPartHtml(pid, model){
3203
+ return gridTableHtml(pid, model) + '<div class="fx-errors" id="fxerr-' + pid + '" hidden></div>' + gridJudgedHtml(model) + gridRoundsHtml(model);
3204
+ }
3205
+ function renderGridErrors(wrap, pid, model, st){
3206
+ var host = wrap.querySelector(".fx-errors");
3207
+ var html = gridErrorsHtml(pid, model, st);
3208
+ host.hidden = html === "";
3209
+ host.innerHTML = html;
3210
+ Array.prototype.forEach.call(wrap.querySelectorAll("[data-fx]"), function(b){
3211
+ b.setAttribute("aria-expanded", st.open[b.getAttribute("data-fx").split(":")[0]] ? "true" : "false");
3212
+ });
3213
+ }
3214
+ // a step's or the fix loop's body: tally (steps), then the grid, the errors list and the rounds folds
3215
+ function buildGridBody(body, partIndex, part, boxIsLive){
3216
+ var pid = "p" + partIndex;
3217
+ var model = gridModelOf(part, boxIsLive);
3218
+ var st = { open: gridDefaultOpen(model), more: {} };
3219
+ if(part.tally){
3220
+ var tally = document.createElement("div");
3221
+ tally.className = "step-tally";
3222
+ tally.setAttribute("data-testid", "audit-tally-" + partIndex);
3223
+ tally.textContent = part.tally;
3224
+ body.appendChild(tally);
3225
+ }
3061
3226
  var wrap = document.createElement("div");
3062
- wrap.className = "step-fold";
3063
- wrap.setAttribute("data-testid", "audit-step-fold-" + partIndex);
3064
- var html = part.tally ? '<div class="step-tally" data-testid="audit-tally-' + partIndex + '">' + escapeXml(part.tally) + "</div>" : "";
3065
- part.tries.forEach(function(t){ html += tryBlockHtml(part, t, boxIsLive, partIndex); });
3066
- html += '<div class="rounds-list" data-testid="audit-step-rounds-' + partIndex + '"></div>';
3067
- wrap.innerHTML = html;
3227
+ wrap.setAttribute("data-fxpart", pid);
3228
+ wrap.setAttribute("data-testid", "audit-grid-" + partIndex);
3229
+ wrap.innerHTML = gridPartHtml(pid, model);
3068
3230
  body.appendChild(wrap);
3069
- loadStepRows(wrap.querySelector(".rounds-list"), partIndex, 0, false);
3070
- }
3071
- function stepRowHtml(r){
3072
- if(r.kind === "check"){
3073
- return "<tr><td>&mdash;</td><td>" + r.try + "</td><td>check</td><td>" + (r.path ? escapeXml(r.path) : "&mdash;") + "</td><td>" + glyphSpan(r.sign) + " " + escapeXml(r.text) + "</td><td>" + auditTimeCellHtml(r) + "</td></tr>";
3074
- }
3075
- if(r.kind === "model"){
3076
- var pseudo = { kind: "model-call", round: r.round, time: r.time, costUsd: r.costUsd, tokens: r.tokens, durationMs: r.durationMs };
3077
- return '<tr class="round-header-row"><td>' + r.round + "</td><td>" + r.try + "</td><td>" + auditActionCellHtml(pseudo) + "</td><td>" + auditPathCellHtml(pseudo) + "</td><td>" + auditDecisionCellHtml(pseudo) + "</td><td>" + auditTimeCellHtml(pseudo) + "</td></tr>";
3078
- }
3079
- var cls = auditRowClassName(r);
3080
- return "<tr" + (cls ? ' class="' + cls + '"' : "") + "><td>" + auditRoundCellHtml(r) + "</td><td>" + r.try + "</td><td>model &middot; " + auditActionCellHtml(r) + "</td><td>" + auditPathCellHtml(r) + "</td><td>" + auditDecisionCellHtml(r) + "</td><td>" + auditTimeCellHtml(r) + "</td></tr>";
3081
- }
3082
- function loadStepRows(el, partIndex, offset, appendMode){
3083
- if(!appendMode) el.innerHTML = '<div class="hint">loading…</div>';
3084
- getJSON("/api/runs/" + encodeURIComponent(currentRunid) + "/rounds?part=" + encodeURIComponent(partIndex) + "&all=1&offset=" + offset).then(function(data){
3085
- var rowsHtml = data.rows.map(stepRowHtml).join("");
3086
- var shownTo = data.offset + data.rows.length;
3087
- var info = '<div class="hint">showing ' + (data.offset + 1) + "&ndash;" + shownTo + " of " + data.totalRows + "</div>";
3088
- if(appendMode){
3089
- var oldInfo = el.querySelector(".rounds-page-info");
3090
- if(oldInfo) oldInfo.remove();
3091
- el.querySelector(".rounds-table tbody").insertAdjacentHTML("beforeend", rowsHtml);
3092
- } else {
3093
- el.innerHTML = (data.toolLogSaved ? "" : '<div class="hint">tool calls: no log saved</div>') +
3094
- '<div class="audit-table-scroll"><table class="rounds-table" data-testid="rounds-table"><thead><tr><th>Round</th><th>Try</th><th>Action</th><th>Path</th><th>Decision</th><th>Time</th></tr></thead><tbody>' + rowsHtml + "</tbody></table></div>";
3231
+ renderGridErrors(wrap, pid, model, st);
3232
+ var toggle = function(tn, force, focusRow){
3233
+ st.open[tn] = force === undefined ? !st.open[tn] : force;
3234
+ renderGridErrors(wrap, pid, model, st);
3235
+ var el = document.getElementById("fxrow-" + pid + "-" + tn);
3236
+ if(el && focusRow){ el.scrollIntoView({ block: "nearest" }); el.focus(); } else if(el){ el.focus(); }
3237
+ };
3238
+ wrap.addEventListener("click", function(e){
3239
+ var more = e.target.closest("[data-fxmore]");
3240
+ if(more){
3241
+ var key = more.getAttribute("data-fxmore");
3242
+ st.more[key] = !st.more[key];
3243
+ renderGridErrors(wrap, pid, model, st);
3244
+ var again = wrap.querySelector('[data-fxmore="' + key + '"]');
3245
+ if(again) again.focus();
3246
+ return;
3095
3247
  }
3096
- el.insertAdjacentHTML("beforeend", '<div class="rounds-page-info">' + info + (shownTo < data.totalRows ? '<button class="btn small rounds-load-more" type="button">load more</button>' : "") + "</div>");
3097
- var more = el.querySelector(".rounds-load-more");
3098
- if(more) more.addEventListener("click", function(){ loadStepRows(el, partIndex, shownTo, true); });
3099
- }).catch(function(e){
3100
- el.innerHTML = '<div class="hint">failed to load rounds: ' + escapeXml(e.message) + "</div>";
3248
+ var row = e.target.closest("[data-fxrow]");
3249
+ if(row){ toggle(parseInt(row.getAttribute("data-fxrow"), 10), undefined, false); return; }
3250
+ var cell = e.target.closest("[data-fx]");
3251
+ if(cell){
3252
+ var tn = parseInt(cell.getAttribute("data-fx").split(":")[0], 10);
3253
+ toggle(tn, st.open[tn] ? false : true, true);
3254
+ }
3255
+ });
3256
+ Array.prototype.forEach.call(wrap.querySelectorAll("details.rounds-fold"), function(d){
3257
+ var t = model.tries.filter(function(x){ return x.n === parseInt(d.getAttribute("data-fxrounds"), 10); })[0];
3258
+ var built = false;
3259
+ d.addEventListener("toggle", function(){
3260
+ if(!d.open || built) return;
3261
+ built = true;
3262
+ loadRounds(d.querySelector(".rf-body"), partIndex, t.attempt, 0);
3263
+ });
3101
3264
  });
3102
3265
  }
3103
3266
 
@@ -3287,8 +3450,8 @@
3287
3450
  ];
3288
3451
  // plain-checks build (2026-09-28): the part's headline check LINE — its
3289
3452
  // MOST RECENT attempt's own declared-close grading (the opening
3290
- // outer-close grade counts as attempt 1, same list `buildAttemptsList`
3291
- // reads), in the withdrawn headline's place.
3453
+ // outer-close grade counts as attempt 1, same list the grid's
3454
+ // columns read), in the withdrawn headline's place.
3292
3455
  // PRD v1.106 Part 3: a part with one call (plan, scout, replan, a one-attempt step) says the thinking it was sent here; the server worded it
3293
3456
  if(typeof part.thinking === "string" && part.thinking !== "") bits.push(escapeXml(part.thinking));
3294
3457
  var latestAttempt = Array.isArray(part.attempts) && part.attempts.length ? part.attempts[part.attempts.length - 1] : null;
@@ -3317,10 +3480,7 @@
3317
3480
  * wins means a later attempt's own `stages` array can be shorter than the
3318
3481
  * close it belongs to; hamr's live catch on run mulbz0ny, checks-count fix
3319
3482
  * 2026-09-28), falling back to `stages.length` only when no spec resolved.
3320
- * The caller (buildAttemptsList) prefixes "attempt N ✓/✗ · " for the
3321
- * attempt header, and the Run tab card / Audit Grouped header show this
3322
- * SAME text bare (hamr: "same text as its attempt header, minus 'attempt
3323
- * N'").
3483
+ * The Run tab card and the Audit Grouped header show this text.
3324
3484
  * @param {any} attempt @returns {string}
3325
3485
  */
3326
3486
  function attemptChecksLine(attempt){
@@ -3391,52 +3551,6 @@
3391
3551
  if(stage.direction === "lower-is-better" && stage.baselineKind === "seed" && hasBaseline) return stage.value + ", limit " + stage.baseline;
3392
3552
  return hasBaseline ? (stage.value + " (baseline " + stage.baseline + ")") : String(stage.value);
3393
3553
  }
3394
- /**
3395
- * plain-checks build (2026-09-28): the expanded attempt row's FULL declared
3396
- * stage list, in declared order, including stages that never ran (first-
3397
- * red-wins stopped the close early) — hamr's ruling: "one line per DECLARED
3398
- * stage, in order, including stages that never ran". Zips
3399
- * `attempt.declaredStages` (the server's full ordered `{name, question}`
3400
- * list) against `attempt.stages` (the shorter, possibly-partial RAN list)
3401
- * BY NAME: a declared stage with a matching ran entry renders that entry
3402
- * (`ran: true`); one with no match renders a synthetic not-run stub
3403
- * (`ran: false`, `verdict: null`). When no `declaredStages` travelled at
3404
- * all (no spec resolvable), falls back to whatever ran, unpadded — exactly
3405
- * today's behaviour for a rubric/command close or an unresolvable spec.
3406
- * @param {any} attempt @returns {{n: number, ran: boolean, stage: any}[]}
3407
- */
3408
- function fullStageList(attempt){
3409
- var ran = Array.isArray(attempt.stages) ? attempt.stages : [];
3410
- if(!Array.isArray(attempt.declaredStages) || attempt.declaredStages.length === 0){
3411
- return ran.map(function(s, i){ return { n: i + 1, ran: true, stage: s }; });
3412
- }
3413
- var byName = {};
3414
- ran.forEach(function(s){ if(s && typeof s.name === "string") byName[s.name] = s; });
3415
- return attempt.declaredStages.map(function(ds, i){
3416
- var s = ds && Object.prototype.hasOwnProperty.call(byName, ds.name) ? byName[ds.name] : null;
3417
- if(s) return { n: i + 1, ran: true, stage: s };
3418
- return { n: i + 1, ran: false, stage: { name: ds ? ds.name : null, question: ds ? ds.question : null, verdict: null } };
3419
- });
3420
- }
3421
- /**
3422
- * one stage's expand-view line — "#N <question> <mark> <number>", hamr's
3423
- * closed illustration:
3424
- * #1 did it change any file? ✓
3425
- * #2 src/checks.js has 0 type errors? ✗ 4 left, need 0
3426
- * #3 other files didn't get more type errors? · not run
3427
- * A never-run declared stage (`entry.ran === false`) always reads "· not
3428
- * run", no number. A ran stage with no recorded number (a guard, a
3429
- * pass/fail command stage) renders the mark alone.
3430
- * @param {{n: number, ran: boolean, stage: any}} entry @returns {string}
3431
- */
3432
- function stageLineHtml(entry){
3433
- var s = entry.stage;
3434
- var q = escapeXml(stageQuestionText(s));
3435
- if(!entry.ran) return "#" + entry.n + " " + q + " &middot; not run";
3436
- var mark = s.verdict === "satisfied" ? glyphSpan("✓") : (s.verdict ? glyphSpan("✗") : "&ndash;");
3437
- var numberText = stageNumberText(s);
3438
- return "#" + entry.n + " " + q + " " + mark + (numberText ? " " + numberText : "");
3439
- }
3440
3554
  var currentAuditFilter = "all";
3441
3555
  function auditPartMatchesFilter(rowWrap, filter){
3442
3556
  if(filter === "all") return true;
@@ -3562,16 +3676,9 @@
3562
3676
  var doorEl = document.createElement("div");
3563
3677
  doorEl.innerHTML = doorTableHtml(part);
3564
3678
  body.appendChild(doorEl);
3565
- } else if(part.kind === "step" && Array.isArray(part.tries) && part.tries.length > 0){
3566
- buildStepFold(body, idx, part, box.state === "running");
3567
- } else if(attempts.length > 1){
3568
- // parts WITH an attempt sub-loop (a multi-attempt step, or the fix
3569
- // loop) expand to attempt rows first — each attempt expands to its
3570
- // own rounds table on its own click, same as the Run tab used to.
3571
- var attemptsWrap = document.createElement("div");
3572
- attemptsWrap.className = "attempts-list";
3573
- body.appendChild(attemptsWrap);
3574
- buildAttemptsList(attemptsWrap, idx, attempts, box.state === "running");
3679
+ } else if((part.kind === "fix" && attempts.length > 0) || (part.kind === "step" && ((Array.isArray(part.tries) && part.tries.length > 0) || attempts.length > 1))){
3680
+ // PRD v1.119: a plan step's tries and the fix loop's tries are ONE grid look: checks x tries, an errors list, the rounds folded per try
3681
+ buildGridBody(body, idx, part, box.state === "running");
3575
3682
  } else {
3576
3683
  // parts with NO sub-loop (scout, plan, replan, judge, run, or a
3577
3684
  // single-attempt step) expand STRAIGHT to their rounds table.
@@ -4326,7 +4433,7 @@
4326
4433
  // M4d Providers layout F. One parent block per key (.pv-key): its key band (name, API shape select, Base URL box, the legacy tick, tokens,
4327
4434
  // the Refresh button), a folded summary, and its model lines as child rows (.pv-mrow). The key row owns shape, Base URL and the legacy
4328
4435
  // tick, so a model line can never drift from them. Shape and Base URL are always editable; a change of either saves both (judged together).
4329
- var folds = {}; // slot -> true (unfolded) / false (folded): set once, on first paint (a key with a ticked model starts unfolded), then only the person changes it
4436
+ var folds = {}; // slot -> true (unfolded) / false (folded): set once, on first paint (every key starts folded), then only the person changes it
4330
4437
  var typedOpen = {}; // slot -> true while "+ type a model name" is open
4331
4438
  function buildProviderRow(row){
4332
4439
  var key = document.createElement("div");
@@ -4361,6 +4468,7 @@
4361
4468
  function buildModelLine(slot, m){
4362
4469
  var d = document.createElement("div");
4363
4470
  d.className = "pv-mrow";
4471
+ d.tabIndex = -1;
4364
4472
  d.setAttribute("data-model", m.model);
4365
4473
  d.setAttribute("data-testid", "model-line");
4366
4474
  d.innerHTML =
@@ -4472,7 +4580,7 @@
4472
4580
  data.rows.forEach(function(row){
4473
4581
  var key = pvRows.querySelector('.pv-key[data-slot="' + row.slot + '"]');
4474
4582
  if(!key){ key = buildProviderRow(row); pvRows.appendChild(key); }
4475
- if(folds[row.slot] === undefined) folds[row.slot] = row.models.some(function(m){ return m.use === true; });
4583
+ if(folds[row.slot] === undefined) folds[row.slot] = false;
4476
4584
  key.setAttribute("data-open", folds[row.slot] ? "1" : "0");
4477
4585
  var fold = key.querySelector("[data-act=fold]");
4478
4586
  fold.textContent = folds[row.slot] ? "▾" : "▸";