fwdloop 0.20.0 → 0.21.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.
@@ -396,6 +396,7 @@
396
396
  .filterbar .chips{gap:4px;margin-bottom:4px;}
397
397
  .chip.fchip{padding:3px 7px;min-height:28px;min-width:28px;font-size:12px;text-align:center;}
398
398
  .chip.fchip::before,.chip.fchip::after{content:"";}
399
+ /* M11 am20 item 4: the ◷ glyph is drawn smaller than ✓ and ✗ at the same font-size (a fallback font); this chip alone is scaled up to match. */
399
400
  .row-blocked{background:var(--red-bg);}
400
401
 
401
402
  /* hamr review #5/#6: Audit tab grouped-by-step sections. */
@@ -453,6 +454,24 @@
453
454
  }
454
455
  .audit-group.audit-fold table{margin-top:8px;}
455
456
  .audit-group.audit-fold table[hidden]{display:none !important;}
457
+ /* M4d am29 (design lab C): the step fold's body - tally, a line per try with its checks, then the Round table. The marker ends the header. */
458
+ .audit-fold-body[hidden]{display:none !important;}
459
+ .audit-fold-body{margin-top:8px;font-size:12px;min-width:0;max-width:100%;}
460
+ .audit-fold-who{flex:none;margin-left:auto;font-weight:700;font-size:11px;white-space:nowrap;}
461
+ .audit-fold-who.model{color:var(--cyan);} .audit-fold-who.human{color:var(--magenta,#9854f1);}
462
+ .audit-tally{color:var(--text-dim);margin:2px 0 4px;}
463
+ .audit-try{margin:4px 0 2px;overflow-wrap:anywhere;}
464
+ .audit-checks{margin:2px 0 6px 14px;}
465
+ .audit-chk{overflow-wrap:anywhere;}
466
+ .audit-chk > span{margin-right:6px;}
467
+ .audit-chk .src,.audit-judged{color:var(--text-faint);}
468
+ .audit-fold-label{color:var(--text-faint);text-transform:uppercase;font-size:10px;letter-spacing:.05em;margin-top:8px;}
469
+ .audit-fold-body table.rounds-table{width:100%;border-collapse:collapse;margin-top:4px;}
470
+ .audit-fold-body table.rounds-table th{position:sticky;top:0;z-index:1;}
471
+ .audit-fold-body table.rounds-table tr.trysep td{border-top:1px solid var(--border-strong);}
472
+ .rounds-pager{color:var(--text-faint);font-size:11px;margin-top:4px;display:flex;gap:10px;align-items:center;flex-wrap:wrap;}
473
+ .step-card .step-head .who{font-weight:700;font-size:11px;}
474
+ .step-card .step-head .who.model{color:var(--cyan);} .step-card .step-head .who.human{color:var(--magenta,#9854f1);}
456
475
  /* hamr's 2026-09-27 review: the group header's own state word (g.state,
457
476
  rendered as a <span class="badge STATE">) and its per-try marks
458
477
  (<span class="mark STATE">) reuse the SAME color vocabulary the runs
@@ -703,6 +722,12 @@
703
722
  }
704
723
  td.am-detail .am-d{margin:0 0 3px;}
705
724
  td.am-detail .am-d b{color:var(--text);font-weight:600;}
725
+ /* the Round table keeps its real table layout on a phone and scrolls inside its own box (.audit-table-scroll), never the page */
726
+ .audit-group table.rounds-table{display:table;width:max-content;min-width:100%;max-width:none;}
727
+ .audit-group table.rounds-table thead{position:static;width:auto;height:auto;overflow:visible;clip:auto;white-space:normal;}
728
+ .audit-group table.rounds-table tbody{display:table-row-group;}
729
+ .audit-group table.rounds-table tr{display:table-row;padding:0;overflow:visible;}
730
+ .audit-group table.rounds-table td{display:table-cell;padding:4px 6px;white-space:normal;overflow-wrap:anywhere;border-right:1px dotted var(--border);}
706
731
  }
707
732
 
708
733
  /* M4d piece 4: the Settings view (a sibling of #main-view, opened from the header). Layout borrowed from bareloop:
@@ -1141,11 +1166,12 @@
1141
1166
  </section>
1142
1167
 
1143
1168
  <section id="panel-runs" class="tabpanel" role="tabpanel" aria-labelledby="tab-runs" hidden>
1144
- <!-- M11: ONE list. Running now, Needs you and Scheduled are not filtered; the filters below act on Jobs and quiet jobs only. -->
1169
+ <!-- M11: ONE list. Running now and Needs you are never filtered and sit above the grey line; Scheduled (the search also finds it, am17; the ◷ chip shows only it, am19) sits BELOW the search box and chips, above Jobs (am20). -->
1145
1170
  <div id="rl-top" data-testid="rl-top"></div>
1146
1171
  <div class="rl-dash"></div>
1147
- <div class="rl-faint" data-testid="rl-filter-note">filters below act on Jobs and quiet jobs only</div>
1172
+ <div class="rl-faint" data-testid="rl-filter-note">search also finds Scheduled; ◷ shows only Scheduled</div>
1148
1173
  <div id="runs-filterbar-anchor"></div>
1174
+ <div id="rl-sched" data-testid="rl-sched"></div>
1149
1175
  <div id="wf-list" data-testid="wf-list"></div>
1150
1176
  </section>
1151
1177
 
@@ -1244,7 +1270,11 @@
1244
1270
  <div class="job-card" id="job-card" hidden data-testid="job-card-readonly">
1245
1271
  <h4 id="details-title">Job card — signed</h4>
1246
1272
  <div class="hint" id="details-jobfrom" data-testid="details-jobfrom"></div>
1247
- <div class="field"><label>Model</label><div class="ro-value" id="details-model">—</div></div>
1273
+ <!-- M4d am28: Model and Thinking side by side on one row (.field-row, the paired-field row bareloop's Job tab uses for its caps) -->
1274
+ <div class="field-row">
1275
+ <div class="field"><label>Model</label><div class="ro-value" id="details-model">—</div></div>
1276
+ <div class="field" id="details-thinking-field"><label>Thinking</label><div class="ro-value" id="details-thinking" data-testid="details-thinking">—</div></div>
1277
+ </div>
1248
1278
  <!-- M9 am6: how this run began, then the workflow's schedule now; both are words built on the server (src/summary-words.js) -->
1249
1279
  <div class="field"><label>Started</label><div class="ro-value" id="details-started" data-testid="details-started">—</div></div>
1250
1280
  <div class="field"><label>Schedule</label><div class="ro-value" id="details-schedule" data-testid="details-schedule">—</div></div>
@@ -1691,6 +1721,7 @@
1691
1721
  // book-derived list, never guessed from `primitives` by exclusion.
1692
1722
  toolsTotal: s.toolsTotal || null, toolsWhy: s.toolsWhy || null, ungranted: s.ungranted || [],
1693
1723
  stoppedReason: s.stoppedReason || null,
1724
+ who: s.who || null, newLine: typeof s.newLine === "string" ? s.newLine : "\u2014", lastAnswerAt: s.lastAnswerAt || null,
1694
1725
  state: s.groupState || "pending", // the server's one decider (deriveStepGroupState); no group = no row yet = not started
1695
1726
  };
1696
1727
  });
@@ -1867,14 +1898,14 @@
1867
1898
  }
1868
1899
 
1869
1900
  // ---- M11: ONE runs list (docs/wiki/the-module-ladder.md "M11 scope", amendments 1 and 2; docs/product/m11-runs-list-mock.html, the right box).
1870
- // Top to bottom: Running now, Needs you, Scheduled (never filtered), a dashed line and the filters (they act on Jobs and quiet jobs only), Jobs, the
1901
+ // Top to bottom: Running now, Needs you (never filtered), a dashed line, the search box and chips, Scheduled (am20: the search narrows it), Jobs, the
1871
1902
  // quiet fold. The page works out NOTHING: `live`, the Needs-you tag (`needs`), the job order and quiet split (`jobs`), the Scheduled cards and the two
1872
1903
  // limits all come from GET /api/runs (src/panel/data.js). `rlModel` is pure (payload in, cards out); the rl*Html functions only draw it.
1873
1904
  var rlData = { rows: [], jobs: [], scheduled: [], limits: { quietDays: 0, olderRuns: 0 } };
1874
1905
  // manual fold memory, keyed by flow ("__quiet" is the quiet fold): a per-viewer convenience, reset on reload. A manual click wins over an automatic open.
1875
1906
  var rlOpen = {};
1876
1907
  // the last markup written into each box: an identical repaint (every poll) writes nothing, so focus, scroll and a half-read card survive it
1877
- var rlLast = { top: null, jobs: null };
1908
+ var rlLast = { top: null, sched: null, jobs: null };
1878
1909
  // The ONE writer of `rlData`: the whole /api/runs payload, as the server sent it.
1879
1910
  function setRunsData(r){
1880
1911
  rlData = { rows: r.rows || [], jobs: r.jobs || [], scheduled: r.scheduled || [], limits: r.limits || rlData.limits };
@@ -1939,13 +1970,28 @@
1939
1970
  if(typeof s.runId !== "string" || s.runId === "") return '<div class="rl-card" data-testid="rl-sched-' + escapeXml(s.flow) + '">' + body + '</div>';
1940
1971
  return '<button class="rl-card" type="button" data-rl-jump="' + escapeXml(s.flow + "|" + s.runId) + '" data-testid="rl-sched-' + escapeXml(s.flow) + '">' + body + '</button>';
1941
1972
  }
1942
- function rlTopHtml(m){
1973
+ // M11 am17: the ONE search box narrows the Scheduled cards by job name (matchesSearch in nameOnly mode: a run number or a date word is skipped, so it narrows only Jobs).
1974
+ // The result and time chips never touch Scheduled. With the `scheduled` chip pressed and nothing matching, the list says so; otherwise an empty Scheduled draws nothing, header included.
1975
+ // M11 am20: Running now and Needs you only (never filtered); they sit above the search box. Scheduled is drawn by rlSchedHtml, below it.
1976
+ function rlTopHtml(m, filters){
1943
1977
  var h = "";
1944
1978
  if(m.running.length) h += rlSectHtml("Running now", m.running.length) + m.running.map(function(r){ return rlJumpCardHtml(r, false); }).join("");
1945
1979
  if(m.needs.length) h += rlSectHtml("Needs you", m.needs.length) + m.needs.map(function(r){ return rlJumpCardHtml(r, true); }).join("");
1946
- if(m.scheduled.length) h += rlSectHtml("Scheduled", m.scheduled.length) + m.scheduled.map(rlScheduledCardHtml).join("");
1947
1980
  return h;
1948
1981
  }
1982
+ // the Scheduled cards the search leaves (the ONE place that narrows them); the count line and rlSchedHtml both read it
1983
+ function rlSchedShown(scheduled, q){
1984
+ return (scheduled || []).filter(function(s){ return matchesSearch(s.flow, null, q, null, true); });
1985
+ }
1986
+ function rlSchedCountText(n){
1987
+ return "showing " + n + " scheduled job" + (n === 1 ? "" : "s");
1988
+ }
1989
+ function rlSchedHtml(m, filters){
1990
+ var shown = rlSchedShown(m.scheduled, filters && filters.search ? filters.search : "");
1991
+ if(shown.length) return rlSectHtml("Scheduled", shown.length) + shown.map(rlScheduledCardHtml).join("");
1992
+ if(filters && filters.scheduled === true) return '<div class="rl-hint">no scheduled job matches</div>';
1993
+ return "";
1994
+ }
1949
1995
  // a run card inside a job: `[sign] run-N date · model` / `word — why · $cost · wall`
1950
1996
  function rlRunCardHtml(r, selected, hit){
1951
1997
  var why = (r.word === "passed" && r.glyph === "[✓]" && !r.line) ? "goal met" : r.line;
@@ -2021,10 +2067,13 @@
2021
2067
  var groups = filterWorkflows(groupRunsByFlow(rlData.rows), filters, Date.now());
2022
2068
  var m = rlModel(rlData, groups, filters, rlData.limits, { flow: currentFlow, runId: currentRunId }, rlOpen);
2023
2069
  var topEl = document.getElementById("rl-top");
2070
+ var schedEl = document.getElementById("rl-sched");
2024
2071
  var listEl = document.getElementById("wf-list");
2025
- var top = rlTopHtml(m);
2026
- var jobs = rlJobsHtml(m);
2072
+ var top = rlTopHtml(m, filters);
2073
+ var sched = rlSchedHtml(m, filters);
2074
+ var jobs = filters.scheduled === true ? "" : rlJobsHtml(m); // M11 am17: the scheduled chip hides Jobs and the quiet fold
2027
2075
  if(top !== rlLast.top){ rlLast.top = top; withFocusPreserved(topEl, function(){ topEl.innerHTML = top; }); }
2076
+ if(sched !== rlLast.sched){ rlLast.sched = sched; withFocusPreserved(schedEl, function(){ schedEl.innerHTML = sched; }); }
2028
2077
  if(jobs !== rlLast.jobs){ rlLast.jobs = jobs; withFocusPreserved(listEl, function(){ listEl.innerHTML = jobs; }); }
2029
2078
  tickSince();
2030
2079
  }
@@ -2097,6 +2146,7 @@
2097
2146
  '<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="time" data-filter-value="7d" title="last 7 days" data-testid="chip-' + scope + '-time-7d">7d</button>' +
2098
2147
  '<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="time" data-filter-value="30d" title="last 30 days" data-testid="chip-' + scope + '-time-30d">30d</button>' +
2099
2148
  '<button class="chip fchip" type="button" aria-pressed="true" data-filter-group="time" data-filter-value="all" title="all time" data-testid="chip-' + scope + '-time-all">all</button>' +
2149
+ (noSigns ? '' : '<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="view" data-filter-value="scheduled" title="scheduled jobs only" aria-label="scheduled jobs only" data-testid="chip-' + scope + '-scheduled">◷</button>') +
2100
2150
  '<button class="chip fchip" type="button" id="' + scope + '-filter-clear" data-testid="' + scope + '-filter-clear">clear</button>' +
2101
2151
  '</div>' +
2102
2152
  '<div class="hint" id="' + scope + '-filter-count" data-testid="' + scope + '-filter-count"></div>' +
@@ -2111,7 +2161,7 @@
2111
2161
  // shape (src/panel/data.js's listRuns). M11 am5: the search splits at spaces and EVERY word must match, case-insensitive. A word shaped run-N is
2112
2162
  // that run exactly; a word shaped MM/DD, MM-DD or YYYY-MM-DD (a real day) is the run's LOCAL start day (`when`, the time the card shows; MM/DD = any year);
2113
2163
  // any other word (a part date like 10/1 too) is a substring of the flow name or the runId.
2114
- function matchesSearch(flow, runId, query, when){
2164
+ function matchesSearch(flow, runId, query, when, nameOnly){
2115
2165
  var words = String(query || "").toLowerCase().replace(/[()]/g, "").split(/\s+/).filter(function(w){ return w; });
2116
2166
  if(!words.length) return true;
2117
2167
  var f = String(flow || "").toLowerCase();
@@ -2119,15 +2169,16 @@
2119
2169
  var d = when ? new Date(when) : null;
2120
2170
  var ok = d && !isNaN(d.getTime());
2121
2171
  return words.every(function(w){
2122
- if(/^run-\d+$/.test(w)) return r === w;
2172
+ if(/^run-\d+$/.test(w)) return nameOnly ? true : r === w;
2123
2173
  var day = /^(?:(\d{4})-)?(\d\d)[-\/](\d\d)$/.exec(w);
2124
2174
  if(day && (day[1] ? w.charAt(4) === "-" && w.charAt(7) === "-" : w.charAt(2) === "/" || w.charAt(2) === "-")){
2125
2175
  var mo = Number(day[2]), da = Number(day[3]);
2126
2176
  if(mo >= 1 && mo <= 12 && da >= 1 && da <= 31){
2177
+ if(nameOnly) return true;
2127
2178
  return !!ok && d.getMonth() + 1 === mo && d.getDate() === da && (!day[1] || d.getFullYear() === Number(day[1]));
2128
2179
  }
2129
2180
  }
2130
- return f.indexOf(w) !== -1 || r.indexOf(w) !== -1;
2181
+ return f.indexOf(w) !== -1 || (!nameOnly && r.indexOf(w) !== -1);
2131
2182
  });
2132
2183
  }
2133
2184
  function filterRuns(runs, filters, nowMs){
@@ -2158,7 +2209,7 @@
2158
2209
  function createFilterBar(opts){
2159
2210
  var scope = opts.scope;
2160
2211
  var storageKey = opts.storageKey;
2161
- var state = { results: [], time: "all", search: "" };
2212
+ var state = { results: [], time: "all", search: "", scheduled: false };
2162
2213
  var allItems = [];
2163
2214
 
2164
2215
  function load(){
@@ -2171,6 +2222,7 @@
2171
2222
  results: Array.isArray(parsed.results) ? parsed.results : [],
2172
2223
  time: typeof parsed.time === "string" ? parsed.time : "all",
2173
2224
  search: typeof parsed.search === "string" ? parsed.search : "",
2225
+ scheduled: parsed.scheduled === true,
2174
2226
  };
2175
2227
  }
2176
2228
  }
@@ -2183,7 +2235,7 @@
2183
2235
  document.querySelectorAll('.filterbar[data-scope="' + scope + '"] .chip[data-filter-group]').forEach(function(chip){
2184
2236
  var group = chip.getAttribute("data-filter-group");
2185
2237
  var value = chip.getAttribute("data-filter-value");
2186
- var active = group === "time" ? state.time === value : state.results.indexOf(value) !== -1;
2238
+ var active = group === "time" ? state.time === value : group === "view" ? state.scheduled : state.results.indexOf(value) !== -1;
2187
2239
  chip.setAttribute("aria-pressed", active ? "true" : "false");
2188
2240
  });
2189
2241
  var searchEl = document.getElementById(scope + "-filter-search");
@@ -2193,7 +2245,7 @@
2193
2245
  var filtered = opts.filterFn(allItems, state, Date.now());
2194
2246
  opts.applyFn(filtered);
2195
2247
  var countEl = document.getElementById(scope + "-filter-count");
2196
- if(countEl) countEl.textContent = "showing " + filtered.length + " of " + allItems.length + " " + (opts.noun || "runs");
2248
+ if(countEl) countEl.textContent = (opts.countFn && opts.countFn(state)) || ("showing " + filtered.length + " of " + allItems.length + " " + (opts.noun || "runs"));
2197
2249
  }
2198
2250
  document.querySelectorAll('.filterbar[data-scope="' + scope + '"] .chip[data-filter-group]').forEach(function(chip){
2199
2251
  chip.addEventListener("click", function(){
@@ -2201,6 +2253,8 @@
2201
2253
  var value = chip.getAttribute("data-filter-value");
2202
2254
  if(group === "time"){
2203
2255
  state.time = value; // single-select within time
2256
+ } else if(group === "view"){
2257
+ state.scheduled = !state.scheduled; // M11 am17: the scheduled chip, the one writer of state.scheduled
2204
2258
  } else {
2205
2259
  var idx = state.results.indexOf(value);
2206
2260
  if(idx === -1) state.results.push(value); else state.results.splice(idx, 1);
@@ -2213,7 +2267,7 @@
2213
2267
  var clearBtn = document.getElementById(scope + "-filter-clear");
2214
2268
  if(clearBtn){
2215
2269
  clearBtn.addEventListener("click", function(){
2216
- state = { results: [], time: "all", search: "" };
2270
+ state = { results: [], time: "all", search: "", scheduled: false };
2217
2271
  paint();
2218
2272
  save();
2219
2273
  apply();
@@ -2237,8 +2291,18 @@
2237
2291
  };
2238
2292
  }
2239
2293
 
2240
- // ONE filter bar, mounted between the unfiltered sections and Jobs (M11). It acts on Jobs and quiet jobs only: `runsFilterFn` keeps a job when ANY of its runs match.
2294
+ // ONE filter bar, mounted below the unfiltered sections (Running now, Needs you); Scheduled and Jobs sit below it (M11 am20). The search narrows Scheduled; the chips act on Jobs and quiet jobs only: `runsFilterFn` keeps a job when ANY of its runs match.
2241
2295
  document.getElementById("runs-filterbar-anchor").innerHTML = filterBarHTML("runs");
2296
+ // M11 am21: ◷'s ink is as tall as ✓'s, whatever font draws it. Canvas measureText of each chip's own font (works in a hidden tab) at 100px; ◷ gets the size that makes its ink match ✓'s.
2297
+ function fitChips(){
2298
+ var cv = document.createElement("canvas").getContext("2d");
2299
+ var ink = function(e){ var cs = getComputedStyle(e); cv.font = cs.fontWeight + " 100px " + cs.fontFamily; var m = cv.measureText(e.textContent); return m.actualBoundingBoxAscent + m.actualBoundingBoxDescent; };
2300
+ var ok = document.querySelector('[data-testid="chip-runs-res-pass"]'), sc = document.querySelector('[data-testid="chip-runs-scheduled"]');
2301
+ if(!ok || !sc || !ink(sc)) return;
2302
+ sc.style.fontSize = (parseFloat(getComputedStyle(ok).fontSize) * ink(ok) / ink(sc)) + "px";
2303
+ }
2304
+ window.fwdloopFitChips = fitChips;
2305
+ fitChips();
2242
2306
 
2243
2307
  function runsFilterFn(items, filters, nowMs){
2244
2308
  return filterWorkflows(groupRunsByFlow(items), filters, nowMs);
@@ -2251,9 +2315,10 @@
2251
2315
  storageKey: "fwdloop-panel-runs-filters",
2252
2316
  filterFn: runsFilterFn,
2253
2317
  applyFn: runsApplyFn,
2318
+ countFn: function(st){ return st.scheduled === true ? rlSchedCountText(rlSchedShown(rlData.scheduled, st.search).length) : null; }, // M11 am20: ◷ pressed, the line counts scheduled jobs
2254
2319
  });
2255
2320
  function currentRunsFilters(){
2256
- return runsFilterBar ? runsFilterBar.getState() : { results: [], time: "all", search: "" };
2321
+ return runsFilterBar ? runsFilterBar.getState() : { results: [], time: "all", search: "", scheduled: false };
2257
2322
  }
2258
2323
 
2259
2324
  // item 4: phone-only "scroll the run view into view" on row select, and
@@ -2353,14 +2418,18 @@
2353
2418
  // read straight off detail.steps/detail.spendSummary, never re-derived
2354
2419
  // from a second, separately-fetched copy of the audit rows.
2355
2420
  var modelText = detail.model || (detail.modelWhy || "no model call recorded yet");
2421
+ // M9 am21/am22: the run's time follows its cost on the top line, after a middle dot like the cost's: the same number as the `took ...` line (one source, detail.wallMs); a finished run without one says so, never 0; a run still going or waiting shows none.
2422
+ var headTime = !runFinished(detail) ? "" : (typeof detail.wallMs === "number" ? duration(detail.wallMs) : "time not recorded");
2356
2423
  var closeText = closeClassSummaryText(detail.steps) || (detail.stepsWhy || "no steps recorded");
2357
2424
  box.innerHTML =
2358
- '<div class="summary-headline"><span class="' + dotClass(detail.glyph, detail.pulse) + '"></span>' + signHtml(detail.word, detail.line, detail.label) + ' &middot; <span class="num">' + escapeXml(spendText) + '</span></div>' +
2425
+ '<div class="summary-headline"><span class="' + dotClass(detail.glyph, detail.pulse) + '"></span>' + signHtml(detail.word, detail.line, detail.label) + ' &middot; <span class="num">' + escapeXml(spendText) + '</span>' + (headTime ? ' &middot; ' + escapeXml(headTime) : '') + '</div>' +
2359
2426
  '<div class="summary-row" data-testid="summary-model"><span class="sum-label">model:</span><span class="sum-val">' + escapeXml(modelText) + '</span></div>' +
2360
2427
  '<div class="summary-row"><span class="sum-label">steps:</span><span class="sum-val">' + stepsText + '</span></div>' +
2361
2428
  '<div class="summary-row" data-testid="summary-why"><span class="sum-label">why:</span><span class="sum-val">' + escapeXml(detail.stopReason || detail.stopReasonWhy || "not recorded") + '</span></div>' +
2362
2429
  '<div class="summary-row" data-testid="summary-close"><span class="sum-label">close:</span><span class="sum-val">' + escapeXml(closeText) + '</span></div>' +
2363
- '<div class="summary-row" data-testid="summary-spend"><span class="sum-label">spend:</span><span class="sum-val">' + spendSummaryText(detail.spendSummary) + '</span></div>';
2430
+ '<div class="summary-row" data-testid="summary-spend"><span class="sum-label">spend:</span><span class="sum-val">' + spendSummaryText(detail.spendSummary) + '</span></div>' +
2431
+ '<div class="summary-row" data-testid="summary-calls"><span class="sum-label">calls:</span><span class="sum-val">' + escapeXml((detail.runLines && detail.runLines.calls) || "\u2014") + '</span></div>' +
2432
+ '<div class="summary-row" data-testid="summary-checks"><span class="sum-label">checks:</span><span class="sum-val">' + escapeXml((detail.runLines && detail.runLines.checks) || "\u2014") + '</span></div>';
2364
2433
 
2365
2434
  renderRunActions(detail);
2366
2435
  // amendment 7 item 2: the Draft is the first box of the Map (an arrow runs on to step 1); the steps keep their own numbers
@@ -2381,6 +2450,8 @@
2381
2450
  // unknown" row.
2382
2451
  if(box.attempts.length) card.appendChild(buildStepActionsLineEl(box, idx));
2383
2452
  else card.appendChild(textLineEl("hint", "not attempted yet", "step-card-actions-" + idx));
2453
+ // M4d am29 item 6: the one new line, the server's words (`—` with no record); a human step's answer time is formatted here, in the viewer's clock
2454
+ card.appendChild(textLineEl("step-meta", box.newLine + (box.who === "human" && box.lastAnswerAt ? " \u00b7 " + (new Date(box.lastAnswerAt).toLocaleTimeString()) : ""), "step-card-new-" + idx));
2384
2455
  // Amendment M4a-3 (hamr's request): "tools: read 3 · write 1" (this
2385
2456
  // step's own tool tally, `summarizeStepTools`) plus "allowed: read,
2386
2457
  // write" (the signed grant, unchanged from the old "granted:" line) —
@@ -2515,6 +2586,14 @@
2515
2586
  closeBadge.className = "badge cyan";
2516
2587
  closeBadge.textContent = closeClassLabel(box.closeClass);
2517
2588
  head.appendChild(closeBadge);
2589
+ // M4d am29 item 6: the same marker as the Audit header; only a step with a record has one
2590
+ if(box.who){
2591
+ var who = document.createElement("span");
2592
+ who.className = "who " + box.who;
2593
+ who.setAttribute("data-testid", "step-card-who-" + idx);
2594
+ who.textContent = foldWhoWords(box.who);
2595
+ head.appendChild(who);
2596
+ }
2518
2597
  return head;
2519
2598
  }
2520
2599
  // The actions line: "<time> · <cost> · [N tokens ·] try N <marks>" — every
@@ -2605,7 +2684,7 @@
2605
2684
  // hamr's 2026-09-27 review item (b): a jump from the Run tab must land
2606
2685
  // on an OPEN group even if a human had folded it — never scroll to a
2607
2686
  // collapsed section with nothing visible in it.
2608
- var table = row.querySelector("table");
2687
+ var table = row.querySelector("table, .audit-fold-body");
2609
2688
  var header = row.querySelector("h4");
2610
2689
  if(table && table.hidden){
2611
2690
  table.hidden = false;
@@ -2648,6 +2727,8 @@
2648
2727
  if(!Array.isArray(r.raw) || r.raw.length === 0) return "";
2649
2728
  return r.raw.map(function(t){ return "<div class=\"audit-raw\">" + escapeXml(String(t)) + "</div>"; }).join("");
2650
2729
  }
2730
+ // M4d am26: ` · thinking off` after a model try's verdict, the server's words (`r.thinkingPhrase`); nothing for a row that has none
2731
+ function auditThinkingHtml(r){ return typeof r.thinkingPhrase === "string" && r.thinkingPhrase.length > 0 ? " \u00b7 " + escapeXml(r.thinkingPhrase) : ""; }
2651
2732
  function buildAuditRowEl(r, includeStep){
2652
2733
  var tr = document.createElement("tr");
2653
2734
  var glyph = verdictGlyph(r.verdict, r.class);
@@ -2666,7 +2747,7 @@
2666
2747
  "<td data-label=\"Action\">" + escapeXml(actionText) + "</td>" +
2667
2748
  "<td data-label=\"Gap\">" + escapeXml(isRejectRow ? "" : auditGapText(r)) + auditRawHtml(r) + "</td>" +
2668
2749
  "<td data-label=\"Cost\">" + escapeXml(auditCostCellText(r)) + "</td>" +
2669
- "<td data-label=\"Verdict\"><span class=\"badge " + badgeClass + "\">" + escapeXml(word) + "</span></td>" +
2750
+ "<td data-label=\"Verdict\"><span class=\"badge " + badgeClass + "\">" + escapeXml(word) + "</span>" + auditThinkingHtml(r) + "</td>" +
2670
2751
  "<td data-label=\"Close\">" + escapeXml(auditCloseText(r)) + "</td>" +
2671
2752
  "<td data-label=\"Time\">" + auditTimeCellHtml(r) + "</td>" +
2672
2753
  // phone-only one-line cells (CSS shows these and hides the rest below 640px; hidden on desktop)
@@ -2764,6 +2845,7 @@
2764
2845
  if(g.draft) return draftLineText(g.summary);
2765
2846
  var line = [p.status, p.name, p.cost].join(" " + p.dot + " ");
2766
2847
  if(p.tries) line += " \u00b7 try " + p.tries.n + " " + p.tries.marks.join("");
2848
+ if(g.fold) line += " " + foldWhoWords(g.fold.who);
2767
2849
  return line;
2768
2850
  }
2769
2851
  // hamr's 2026-09-27 review: the header's status word gets the SAME color
@@ -2841,12 +2923,106 @@
2841
2923
  });
2842
2924
  }
2843
2925
  h4.appendChild(tail);
2926
+ // M4d am29 item 4: the header ends with who acted on the step; only a step with a fold (a run with records) has it
2927
+ if(g.fold){
2928
+ var who = document.createElement("span");
2929
+ who.className = "audit-fold-who " + g.fold.who;
2930
+ who.setAttribute("data-testid", "audit-group-who");
2931
+ who.textContent = foldWhoWords(g.fold.who);
2932
+ h4.appendChild(who);
2933
+ }
2844
2934
  return h4;
2845
2935
  }
2846
2936
  // Grouped view: one section per step, server order preserved (first-seen
2847
2937
  // order of `r.step` across this run's own rows — never re-sorted).
2848
2938
  // review item #1: COLLAPSED by default — a map/step-card click
2849
2939
  // (`openAuditGroup`) is the only thing that force-expands one.
2940
+ // M4d am29 (items 4-6): the step fold's words, all from the server's `fold` (src/audit-fold.js); this page only draws them.
2941
+ function foldWhoWords(who){ return who === "human" ? "[human \u00b7 ask]" : "[model]"; }
2942
+ function foldSize(n){ return n < 1024 ? n + " B" : (n < 1048576 ? (n / 1024).toFixed(1) + " KB" : (n / 1048576).toFixed(1) + " MB"); }
2943
+ function foldEl(tag, cls, text, testId){
2944
+ var e = document.createElement(tag);
2945
+ if(cls) e.className = cls;
2946
+ if(text !== null && text !== undefined) e.textContent = text;
2947
+ if(testId) e.setAttribute("data-testid", testId);
2948
+ return e;
2949
+ }
2950
+ function foldTryEl(t, human){
2951
+ var wrap = document.createElement("div");
2952
+ var line = foldEl("div", "audit-try", null, "audit-try-line");
2953
+ line.appendChild(document.createTextNode("try " + t.n + " "));
2954
+ line.appendChild(foldEl("span", "mark " + auditMarkClass(t.mark), t.mark));
2955
+ var rest = human
2956
+ ? [t.answer, t.about ? "about " + t.about : null]
2957
+ : [t.thinking, t.gap];
2958
+ rest.forEach(function(x){ if(x) line.appendChild(document.createTextNode(" \u00b7 " + x)); });
2959
+ wrap.appendChild(line);
2960
+ if(!human && t.checks && t.checks.length){
2961
+ var box = foldEl("div", "audit-checks", null, "audit-checks");
2962
+ t.checks.forEach(function(c){
2963
+ var row = foldEl("div", "audit-chk", null, "audit-check");
2964
+ row.appendChild(foldEl("span", "mark " + (c.ok ? "green" : "red"), c.ok ? "\u2713" : "\u2717"));
2965
+ row.appendChild(foldEl("span", null, "#" + c.n + " " + c.text + (c.result ? " (" + c.result + ")" : "")));
2966
+ row.appendChild(foldEl("span", "src", "\u00b7 from " + c.source));
2967
+ box.appendChild(row);
2968
+ });
2969
+ if(t.output){
2970
+ var sha = String(t.output.sha256);
2971
+ box.appendChild(foldEl("div", "audit-judged", "output judged: " + t.output.file + " \u00b7 " + foldSize(t.output.bytes) + " \u00b7 sha256 " + sha.slice(0, 4) + "\u2026" + sha.slice(-2), "audit-judged"));
2972
+ }
2973
+ wrap.appendChild(box);
2974
+ }
2975
+ return wrap;
2976
+ }
2977
+ var ROUNDS_PAGE = 20;
2978
+ function foldRowEl(r, prevTry){
2979
+ var tr = document.createElement("tr");
2980
+ if(prevTry !== null && r.try !== prevTry) tr.className = "trysep";
2981
+ [r.round === null || r.round === undefined ? "\u2014" : String(r.round), r.try === null || r.try === undefined ? "\u2014" : String(r.try), r.action, r.path || "\u2014", r.decision, auditShortTime(r)].forEach(function(t){
2982
+ tr.appendChild(foldEl("td", null, t));
2983
+ });
2984
+ return tr;
2985
+ }
2986
+ // the Round table, 20 rows at a time (bareloop's "showing A\u2013B of N" + load more), table scrolling inside its own box
2987
+ function foldRoundsEl(g){
2988
+ var rows = g.fold.rows || [];
2989
+ var wrap = document.createElement("div");
2990
+ wrap.appendChild(foldEl("div", "audit-fold-label", "rounds"));
2991
+ var scroll = foldEl("div", "audit-table-scroll");
2992
+ var table = document.createElement("table");
2993
+ table.className = "rounds-table";
2994
+ table.setAttribute("data-testid", "rounds-table-" + g.step);
2995
+ table.innerHTML = "<thead><tr><th>Round</th><th>Try</th><th>Action</th><th>Path</th><th>Decision</th><th>Time</th></tr></thead><tbody></tbody>";
2996
+ var tbody = table.querySelector("tbody");
2997
+ scroll.appendChild(table);
2998
+ wrap.appendChild(scroll);
2999
+ var pager = foldEl("div", "rounds-pager", null, "rounds-pager");
3000
+ wrap.appendChild(pager);
3001
+ var shown = 0;
3002
+ function more(){
3003
+ var to = Math.min(rows.length, shown + ROUNDS_PAGE);
3004
+ for(var i = shown; i < to; i += 1) tbody.appendChild(foldRowEl(rows[i], i === 0 ? null : rows[i - 1].try));
3005
+ shown = to;
3006
+ pager.innerHTML = "";
3007
+ pager.appendChild(foldEl("span", null, rows.length === 0 ? "no rows" : "showing 1\u2013" + shown + " of " + rows.length));
3008
+ if(shown < rows.length){
3009
+ var b = foldEl("button", "btn small", "load more", "rounds-load-more");
3010
+ b.type = "button";
3011
+ b.addEventListener("click", function(ev){ ev.stopPropagation(); more(); });
3012
+ pager.appendChild(b);
3013
+ }
3014
+ }
3015
+ more();
3016
+ return wrap;
3017
+ }
3018
+ function buildFoldBodyEl(g){
3019
+ var f = g.fold, human = f.who === "human";
3020
+ var body = foldEl("div", "audit-fold-body", null, "audit-fold-body-" + g.step);
3021
+ if(f.tally) body.appendChild(foldEl("div", "audit-tally", f.tally, "audit-tally"));
3022
+ (f.tries || []).forEach(function(t){ body.appendChild(foldTryEl(t, human)); });
3023
+ body.appendChild(foldRoundsEl(g));
3024
+ return body;
3025
+ }
2850
3026
  var auditExpanded = {}; // step -> true/false once a human toggled it; reset when the run changes
2851
3027
  var auditExpandedRun = null;
2852
3028
  function renderAuditGroups(result){
@@ -2868,10 +3044,12 @@
2868
3044
  sh.className = "audit-status-header";
2869
3045
  sh.setAttribute("role", "button"); sh.setAttribute("tabindex", "0"); sh.setAttribute("aria-expanded", "false");
2870
3046
  sh.style.cursor = "pointer";
2871
- var sname = document.createElement("span"); sname.className = "audit-fold-name keep"; sname.textContent = "schedule"; sh.appendChild(sname);
3047
+ // M9 am23: sign + word (one badge, as a step header's), then `schedule`, then ` · ` and the parts. The word is the server's (`sc.word`, from SIGN_WORDS); no table here.
2872
3048
  var ssign = document.createElement("span");
2873
3049
  ssign.className = "badge sign-badge " + (sc.sign === "[\u25B6]" ? "amber" : sc.sign === "[\u2717]" ? "red" : "grey");
2874
- ssign.setAttribute("data-testid", "audit-schedule-sign"); ssign.textContent = sc.sign; sh.appendChild(ssign);
3050
+ ssign.setAttribute("data-testid", "audit-schedule-sign"); ssign.textContent = sc.word ? sc.sign + " " + sc.word : sc.sign; sh.appendChild(ssign);
3051
+ var sname = document.createElement("span"); sname.className = "audit-fold-name keep"; sname.textContent = "schedule"; sh.appendChild(sname);
3052
+ var slead = document.createElement("span"); slead.setAttribute("data-testid", "audit-schedule-lead"); slead.textContent = "\u00b7"; sh.appendChild(slead); // plain span: a phone keeps this dot (the signed header has it)
2875
3053
  var stail = document.createElement("span"); stail.className = "audit-fold-tail wrap"; stail.setAttribute("data-testid", "audit-schedule-head"); stail.textContent = sc.head; sh.appendChild(stail);
2876
3054
  var sl = document.createElement("table");
2877
3055
  sl.setAttribute("data-testid", "audit-table-schedule"); sl.hidden = true;
@@ -2930,12 +3108,20 @@
2930
3108
  header.style.cursor = "pointer";
2931
3109
  wrap.appendChild(header);
2932
3110
  if(noRecord){ container.appendChild(wrap); return; } // nothing to open: the header already says "no draft record"
2933
- var table = document.createElement("table");
2934
- table.hidden = !isOpen;
2935
- table.innerHTML = "<thead><tr><th>Attempt</th><th>Action</th><th>Gap</th><th>Cost</th><th>Verdict</th><th>Close</th><th>Time</th></tr></thead><tbody></tbody>";
2936
- var tbody = table.querySelector("tbody");
2937
- rows.forEach(function(r){ tbody.appendChild(buildAuditRowEl(r, false)); });
2938
- table.setAttribute("data-testid", "audit-table-grouped-" + g.step);
3111
+ // M4d am29: a step with a fold draws it (design lab C); a step without one (an older run, the Draft, the run's own group) keeps its table as before
3112
+ var table, tbody;
3113
+ if(g.fold){
3114
+ table = buildFoldBodyEl(g);
3115
+ table.hidden = !isOpen;
3116
+ rows = []; // a fold has no per-try table row to open with the group (`syncSingleRow` below leaves it alone)
3117
+ } else {
3118
+ table = document.createElement("table");
3119
+ table.hidden = !isOpen;
3120
+ table.innerHTML = "<thead><tr><th>Attempt</th><th>Action</th><th>Gap</th><th>Cost</th><th>Verdict</th><th>Close</th><th>Time</th></tr></thead><tbody></tbody>";
3121
+ tbody = table.querySelector("tbody");
3122
+ rows.forEach(function(r){ tbody.appendChild(buildAuditRowEl(r, false)); });
3123
+ table.setAttribute("data-testid", "audit-table-grouped-" + g.step);
3124
+ }
2939
3125
  wrap.appendChild(table);
2940
3126
  // M4c-fix amendment 2 (j): a step with exactly one try opens that try's detail with the group, closes with it
2941
3127
  // (the same `.open` tap-detail the row's own tap toggles; only the phone layout shows it).
@@ -3161,6 +3347,7 @@
3161
3347
  document.getElementById("details-model").textContent = job.model
3162
3348
  ? ("model used: " + job.model + " (from this run's rows)")
3163
3349
  : (job.modelWhy || "no model call recorded yet");
3350
+ document.getElementById("details-thinking").textContent = typeof job.thinkingRule === "string" ? job.thinkingRule : "—";
3164
3351
  document.getElementById("details-started").textContent = job.started || "—";
3165
3352
  document.getElementById("details-schedule").textContent = job.schedule || "none";
3166
3353
  // M4e amendment 6 item 5 + amendment 7 item 4: "$<cap> per run · 1h wait · redo up to <n>"; several asks: "waits 1h, 30m", each through plainWait.
@@ -3310,8 +3497,12 @@
3310
3497
  var openRunLive = true; // is the open run still changing? (true until its detail says otherwise)
3311
3498
  var wasHidden = false;
3312
3499
  // One writer of `openRunLive`: every paint of the open run's detail goes through here.
3500
+ // M9 am21: the ONE decider of a finished run ([✓] [✗] [■]); the open-run poll and the summary line's time both ask it.
3501
+ function runFinished(d){
3502
+ return !!d && (d.glyph === "[\u2713]" || d.glyph === "[\u2717]" || d.glyph === "[\u25A0]");
3503
+ }
3313
3504
  function paintRun(d){
3314
- openRunLive = !(d && (d.glyph === "[\u2713]" || d.glyph === "[\u2717]" || d.glyph === "[\u25A0]"));
3505
+ openRunLive = !runFinished(d);
3315
3506
  var next = sig(d);
3316
3507
  if(next !== null && next === lastSig.detail) return;
3317
3508
  lastSig.detail = next;
package/src/primitives.js CHANGED
@@ -32,6 +32,8 @@ import { primitiveFor, loadCatalogue } from './catalogue.js';
32
32
  import { readDocxText } from './docx.js';
33
33
  import { parseCsv } from './csv.js';
34
34
  import { makeCtxTools } from './ctx-tools.js';
35
+ import { diaryPaths } from './diary.js';
36
+ import { readdirInside } from './flow.js';
35
37
 
36
38
  // bare-agent >=0.47.0: `noFollowSymlinks: true` makes shell_read/write/edit/
37
39
  // grep throw `err.code === 'ELOOP'` when the path's FINAL component is a
@@ -172,6 +174,9 @@ function sandboxedReadTool(gate, runDir, inputsByRole) {
172
174
  };
173
175
  }
174
176
 
177
+ /** bare-agent's shell_grep default cap (DEFAULT_GREP_MAX_MATCHES, not exported) — mirrored for the entry-by-entry grep. */
178
+ const GREP_DEFAULT_MAX_MATCHES = 200;
179
+
175
180
  function sandboxedGrepTool(gate, runDir, inputsByRole) {
176
181
  const real = shellTool('shell_grep');
177
182
  const textRoles = Object.keys(inputsByRole).filter((r) => rolePrimitiveFor(inputsByRole[r]) === 'read');
@@ -181,7 +186,31 @@ function sandboxedGrepTool(gate, runDir, inputsByRole) {
181
186
  parameters: roleParameters(real, textRoles),
182
187
  execute: async (args) => {
183
188
  const resolvedPath = await resolveRoleOrPath(gate, 'grep', 'grep', runDir, args, inputsByRole, textRoles);
184
- return real.execute({ ...args, path: resolvedPath });
189
+ // M4d am29 item 3: the gate only denies the diaries by name, and bare-agent's grep stops at its cap with no exclude option. A folder that holds a diary
190
+ // (the run folder itself) is therefore grepped entry by entry, diaries left out BEFORE the cap, each entry through the same gate.
191
+ const diaries = new Set(diaryPaths(runDir).map((p) => path.resolve(p)));
192
+ const dir = path.resolve(resolvedPath);
193
+ let found;
194
+ if (dir === path.resolve(runDir)) {
195
+ const cap = args.maxMatches || GREP_DEFAULT_MAX_MATCHES;
196
+ const hits = [];
197
+ let fileCount = 0;
198
+ for (const name of readdirInside(runDir, '').sort()) {
199
+ const entry = path.join(dir, name);
200
+ if (diaries.has(entry) || hits.length >= cap) continue;
201
+ // not recursive: top-level files only; readdirInside lists a directory's entries and nothing for a file
202
+ if (args.recursive === false && readdirInside(runDir, name).length) continue;
203
+ const gated = await resolveAndGate(gate, 'grep', 'grep', runDir, entry);
204
+ const part = await real.execute({ ...args, path: gated, maxMatches: cap - hits.length });
205
+ hits.push(...(part?.hits ?? []));
206
+ fileCount += part?.fileCount ?? 0;
207
+ }
208
+ found = { hits, truncated: hits.length >= cap, fileCount };
209
+ } else {
210
+ found = await real.execute({ ...args, path: resolvedPath });
211
+ }
212
+ // safety net for any other path shape: a diary hit never reaches the model
213
+ return found && Array.isArray(found.hits) ? { ...found, hits: found.hits.filter((h) => !diaries.has(path.resolve(String(h?.file)))) } : found;
185
214
  },
186
215
  };
187
216
  }
@@ -320,11 +349,23 @@ export function resolvePrimitives(catalogue, grantedVerbs, ctx) {
320
349
  // and a red naming bareguard's own message, so the caller refuses the run.
321
350
  let gate;
322
351
  try {
323
- gate = new Gate({ fs: { readScope, writeScope: [outDir] } });
352
+ // M4d am29 item 3: the diaries are denied to the model by name (bareloop's `fs.deny` of its audit sidecar path)
353
+ gate = new Gate({ fs: { readScope, writeScope: [outDir], deny: diaryPaths(runDir) } });
324
354
  } catch (err) {
325
355
  return { tools: {}, reds: [`primitives: bareguard refused the step's file scope — ${err.message}`] };
326
356
  }
327
357
 
358
+ // M4d am29 item 1: what the gate last decided and how many times it was asked, so a tool call's diary row can say `allow`, the deny and its rule,
359
+ // or `no check` (a call that never reached the gate: readDocx, addressCells, a litectx verb with no path). Every tool below carries it as `gateSeen`.
360
+ const gateSeen = { n: 0, last: /** @type {{outcome:string, rule:string|null}|null} */ (null) };
361
+ const askGate = gate.check.bind(gate);
362
+ gate.check = async (action) => {
363
+ const decision = await askGate(action);
364
+ gateSeen.n += 1;
365
+ gateSeen.last = { outcome: decision.outcome, rule: decision.rule ?? null };
366
+ return decision;
367
+ };
368
+
328
369
  const tools = {};
329
370
  const reds = [];
330
371
  // Built on demand, once: nothing is opened or created here (the store is opened per call, inside a tool).
@@ -379,5 +420,6 @@ export function resolvePrimitives(catalogue, grantedVerbs, ctx) {
379
420
  }
380
421
  }
381
422
 
423
+ for (const verb of Object.keys(tools)) tools[verb] = { ...tools[verb], gateSeen };
382
424
  return { tools, reds };
383
425
  }