fwdloop 0.35.2 → 0.37.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.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/bin/fwdloop +5 -2
  3. package/package.json +3 -3
  4. package/src/action-stop.js +1 -1
  5. package/src/auditchecks.js +41 -9
  6. package/src/authoring.js +78 -20
  7. package/src/blockasks.js +10 -12
  8. package/src/blockassemble.js +49 -43
  9. package/src/blockdraft.js +4 -2
  10. package/src/blockpick.js +10 -0
  11. package/src/canrun.js +2 -1
  12. package/src/cardlist.js +28 -5
  13. package/src/checkblock.js +610 -64
  14. package/src/checked.js +28 -33
  15. package/src/checklistsign.js +2 -1
  16. package/src/checklook.js +45 -0
  17. package/src/checkrows.js +202 -0
  18. package/src/cited-record.js +2 -2
  19. package/src/citedcheck.js +53 -12
  20. package/src/citedwords.js +7 -4
  21. package/src/closers.js +49 -2
  22. package/src/declaration.js +26 -4
  23. package/src/drafter.js +86 -62
  24. package/src/factwords.js +7 -4
  25. package/src/globprefix.js +26 -0
  26. package/src/model-step.js +22 -4
  27. package/src/pageask.js +6 -4
  28. package/src/pagedropwords.js +3 -11
  29. package/src/pagedry.js +75 -1
  30. package/src/pagefetch.js +11 -6
  31. package/src/pagelook.js +2 -1
  32. package/src/pagerules.js +8 -2
  33. package/src/panel/author.js +20 -8
  34. package/src/panel/authorcard.js +3 -3
  35. package/src/panel/data.js +3 -2
  36. package/src/panel/index.html +176 -41
  37. package/src/panel/result.js +40 -3
  38. package/src/pickrecord.js +14 -0
  39. package/src/planrebuild.js +55 -19
  40. package/src/ratelimit.js +117 -0
  41. package/src/report.js +216 -0
  42. package/src/rowresults.js +111 -0
  43. package/src/rubricstep.js +65 -2
  44. package/src/runner.js +61 -9
  45. package/src/send.js +19 -82
  46. package/src/shapebuild.js +281 -0
  47. package/src/shapelook.js +91 -0
  48. package/src/shapemenu.js +64 -0
  49. package/src/shaperesult.js +104 -0
  50. package/src/shaperows.js +263 -0
  51. package/src/shapewords.js +140 -0
  52. package/src/sheetbuild.js +41 -29
  53. package/src/sheetclaims.js +49 -1
  54. package/src/sheetfind.js +8 -0
  55. package/src/sheetlook.js +11 -1
  56. package/src/sheetrows.js +10 -64
  57. package/src/ticketrows.js +1 -1
  58. package/src/try-checks.js +39 -6
  59. package/src/types.js +1 -0
  60. package/src/whole-job.js +108 -16
  61. package/types/action-stop.d.ts +1 -1
  62. package/types/auditchecks.d.ts +13 -2
  63. package/types/authoring.d.ts +24 -4
  64. package/types/blockasks.d.ts +6 -10
  65. package/types/blockassemble.d.ts +13 -13
  66. package/types/blockdraft.d.ts +3 -2
  67. package/types/blockpick.d.ts +4 -0
  68. package/types/cardlist.d.ts +18 -2
  69. package/types/checkblock.d.ts +278 -28
  70. package/types/checked.d.ts +15 -6
  71. package/types/checklook.d.ts +36 -0
  72. package/types/checkrows.d.ts +119 -0
  73. package/types/citedcheck.d.ts +4 -2
  74. package/types/closers.d.ts +10 -1
  75. package/types/drafter.d.ts +8 -4
  76. package/types/globprefix.d.ts +5 -0
  77. package/types/model-step.d.ts +43 -2
  78. package/types/pageask.d.ts +5 -3
  79. package/types/pagedropwords.d.ts +0 -1
  80. package/types/pagedry.d.ts +27 -0
  81. package/types/pagefetch.d.ts +3 -2
  82. package/types/pagerules.d.ts +4 -0
  83. package/types/panel/result.d.ts +19 -2
  84. package/types/pickrecord.d.ts +10 -0
  85. package/types/ratelimit.d.ts +59 -0
  86. package/types/report.d.ts +46 -0
  87. package/types/rowresults.d.ts +28 -0
  88. package/types/rubricstep.d.ts +21 -0
  89. package/types/runner.d.ts +3 -1
  90. package/types/send.d.ts +13 -12
  91. package/types/shapebuild.d.ts +97 -0
  92. package/types/shapelook.d.ts +76 -0
  93. package/types/shapemenu.d.ts +40 -0
  94. package/types/shaperesult.d.ts +40 -0
  95. package/types/shaperows.d.ts +102 -0
  96. package/types/shapewords.d.ts +43 -0
  97. package/types/sheetbuild.d.ts +31 -13
  98. package/types/sheetclaims.d.ts +16 -0
  99. package/types/sheetfind.d.ts +1 -0
  100. package/types/sheetrows.d.ts +5 -36
  101. package/types/ticketrows.d.ts +1 -1
  102. package/types/try-checks.d.ts +2 -1
  103. package/types/types.d.ts +4 -0
  104. package/types/whole-job.d.ts +69 -3
@@ -612,6 +612,22 @@
612
612
  /* M12 piece 3: the ticket list in the Result tab (mockup docs/product/m12-ticket-results-mock.html, variant E). Its boxes are the panel's own: .audit-group, .filterbar, .chips, .btn.small. */
613
613
  /* M13 piece 6: the job's Result grid (mock docs/product/m13-setup-mock.html Part 3). The table, cells, q-fold and step-sub are the Audit grid's own; these are the bucket fold rows, the stats line and the run column. */
614
614
  #result-body .tg-stats{font-size:13px;margin:0 0 8px;overflow-wrap:anywhere;}
615
+ /* borrowed-from: bareloop src/panel/index.html@v0.61.0 (.sf-*). a shape line with many fields: one folded row per item (signed mock A2); a failed item is open and tinted; nothing scrolls sideways */
616
+ .sf-item{border-bottom:1px dotted var(--border-strong);}
617
+ .sf-item>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;min-height:36px;font-size:12px;padding:0 4px;}
618
+ .sf-item>summary::-webkit-details-marker{display:none;}
619
+ .sf-nm{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
620
+ .sf-ct{flex:0 0 auto;white-space:nowrap;}
621
+ .sf-ar{flex:0 0 auto;color:var(--accent);font-weight:700;}
622
+ .sf-ar::before{content:"\25B8";}
623
+ .sf-item[open]>summary .sf-ar::before{content:"\25BE";}
624
+ .sf-item.bad>summary{background:var(--red-bg);}
625
+ .sf-fl{padding:4px 8px 8px 22px;font-size:12px;}
626
+ .sf-fl>div{display:flex;gap:8px;padding:2px 0;border-bottom:1px dotted var(--border);}
627
+ .sf-fl .k{flex:0 0 84px;color:var(--text-dim);overflow:hidden;text-overflow:ellipsis;}
628
+ .sf-fl .g{flex:0 0 14px;}
629
+ .sf-fl .v{flex:1 1 auto;min-width:0;overflow-wrap:anywhere;}
630
+ .sf-fl .why{color:var(--red);}
615
631
  table.grid.tg td.r,table.grid.tg th.r{position:sticky;left:0;background:var(--panel2);z-index:1;min-width:84px;white-space:nowrap;}
616
632
  table.grid.tg td.c{min-width:84px;}
617
633
  table.grid.tg th{color:var(--accent);font-weight:700;}
@@ -744,6 +760,7 @@
744
760
  .chat-question .q-line{font-size:12px;color:var(--text-faint);margin-top:4px;overflow-wrap:anywhere;}
745
761
  .chat-question .q-text{font-size:13px;margin-top:4px;overflow-wrap:anywhere;white-space:pre-wrap;}
746
762
  .chat-question textarea{display:block;width:100%;max-width:100%;box-sizing:border-box;margin-top:8px;min-height:3.4em;font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);resize:vertical;}
763
+ .chat-question select{display:block;width:100%;max-width:100%;min-width:0;box-sizing:border-box;margin-top:8px;}
747
764
  .chat-question .q-choices{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;}
748
765
  .chat-question .q-choices .btn{flex:1 1 auto;min-width:0;}
749
766
  .chat-question .q-or{display:block;font-size:12px;color:var(--text-faint);margin-top:8px;text-transform:none;letter-spacing:normal;font-weight:normal;}
@@ -768,6 +785,22 @@
768
785
  /* the confirm card's Drop / Add: wraps with its row, a comfortable touch target, no horizontal scroll at phone width */
769
786
  .jp .jp-btn{margin:2px 0 2px 8px;padding:4px 12px;min-height:32px;font-size:inherit;}
770
787
  .jp .fold{overflow-wrap:anywhere;}
788
+ /* borrowed-from: bareloop src/panel/index.html@v0.61.0 (fc56e1f3) .ck-* (the signed check-list look, M19 S6) */
789
+ .jp .ck-g{margin:6px 0 6px 16px;text-indent:0;}
790
+ .jp .ck-h{font-weight:700;font-size:12px;color:var(--text-dim);margin:6px 0 2px;}
791
+ .jp .ck-row{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px;padding-left:12px;text-indent:0;overflow-wrap:anywhere;}
792
+ .jp .ck-row .tagcol{display:inline-block;min-width:82px;}
793
+ .jp .ck-row .kind{display:inline-block;min-width:48px;color:var(--text-faint);}
794
+ .jp .ck-row .ck-t{flex:1 1 220px;min-width:0;}
795
+ .jp .ck-row .ck-right{margin-left:auto;white-space:nowrap;}
796
+ .jp .ck-row .ck-under{flex-basis:100%;padding-left:138px;}
797
+ .jp .ck-why{display:inline;}
798
+ .jp .ck-why>summary::before{content:none;margin:0;}
799
+ .jp .ck-why>summary{font-weight:400;}
800
+ .jp .jl>.lbl{font-weight:700;margin-right:6px;}
801
+ .jp .ck-why summary{display:inline;cursor:pointer;color:var(--text-dim);list-style:none;margin-left:6px;}
802
+ .jp .ck-why summary::-webkit-details-marker{display:none;}
803
+ .jp .ck-why[open]{display:block;}
771
804
  .jp-sug .lbl{display:block;margin-top:6px;font-weight:700;}
772
805
  .jp details.fold{padding-left:0;margin:6px 0;}
773
806
  .jp details>summary{cursor:pointer;list-style:none;font-weight:700;}
@@ -1432,6 +1465,7 @@
1432
1465
  <button class="btn small" type="button" id="chat-q-agree" data-testid="chat-q-agree" hidden>Agree</button>
1433
1466
  <button class="btn small" type="button" id="chat-q-drop" data-testid="chat-q-drop" hidden>Drop it</button>
1434
1467
  </div>
1468
+ <select id="chat-q-column" data-testid="chat-q-column" aria-label="Choose a column" hidden></select>
1435
1469
  <label class="q-or" id="chat-q-or" data-testid="chat-q-or" for="chat-q-answer">Or type a new rule:</label>
1436
1470
  <textarea id="chat-q-answer" data-testid="chat-q-answer" rows="2" autocomplete="off" spellcheck="false" aria-label="Your answer" placeholder="Your answer, on one line"></textarea>
1437
1471
  <div class="hint q-err" id="chat-q-error" data-testid="chat-q-error" role="alert"></div>
@@ -2833,13 +2867,37 @@
2833
2867
  // M15 item 5: the sent file(s), at the top: a link that opens the file, or the server's words (gone / changed) in its place. A run that sent nothing draws nothing.
2834
2868
  function resultFileLinks(data){
2835
2869
  return (data.delivered || []).map(function(d){
2836
- return resultField("Saved", d.words ? '<div class="rs-warn" data-testid="result-file-top-gone">' + escapeXml(d.name) + ' \u2014 ' + escapeXml(d.words) + '</div>'
2870
+ // M15 am3 item 1: a report saved under a new name says why, in the server's own words (`d.note`)
2871
+ var renamed = d.note ? '<div class="hint" data-testid="result-file-top-note">' + escapeXml(d.note) + '</div>' : "";
2872
+ return resultField("Saved", d.words ? '<div class="rs-warn" data-testid="result-file-top-gone">' + escapeXml(d.name) + ' \u2014 ' + escapeXml(d.words) + '</div>' + renamed
2837
2873
  : '<div class="ro-value" data-testid="result-file-top" style="overflow-wrap:anywhere"><a href="/api/runs/' + encodeURIComponent(data.flow) + '/' + encodeURIComponent(data.runId) +
2838
- '/download?i=' + d.i + '&view=1" target="_blank" rel="noopener noreferrer">' + escapeXml(d.name) + '</a></div>');
2874
+ '/download?i=' + d.i + '&view=1" target="_blank" rel="noopener noreferrer">' + escapeXml(d.name) + '</a>' + renamed + '</div>');
2839
2875
  }).join("");
2840
2876
  }
2877
+ // ---- SHAPE JOBS (M19 S8; borrowed-from: bareloop src/panel/index.html@v0.61.0 shapeFoldHtml, shapeResultCard): a shape line's answer is a FOLD (every shape line, any field count): one row per item, opening to its fields, the stats line and the Not checked line. The server decides every mark and word (`line.shape`, src/shaperesult.js); the page only draws. An item's name is plain text.
2878
+ // one row per item `N \u00B7 name \u2713 k of n \u25B8`, a native <details> opening to one line per field; a failed item starts open (signed mock A2)
2879
+ function shapeFoldHtml(m){
2880
+ var n = m.columns.length;
2881
+ return '<div class="sf-list" data-testid="shape-fold">' + m.rows.map(function(r){
2882
+ var bad = r.cells.filter(function(c){ return c.mark === "r"; }).length;
2883
+ return '<details class="sf-item' + (bad ? ' bad' : '') + '" data-testid="shape-item"' + (bad ? ' open' : '') + '><summary><span class="sf-nm" data-testid="shape-name" title="' + escapeXml(r.name) + '">' + escapeXml(r.name) + '</span><span class="sf-ct" data-testid="shape-count">' + gridMarkOf(bad ? "r" : "g") + ' ' + (n - bad) + ' of ' + n + '</span><span class="sf-ar"></span></summary><div class="sf-fl">' +
2884
+ r.cells.map(function(c, j){ return '<div data-testid="shape-field" data-result="' + (c.mark === "r" ? "failed" : "passed") + '"><span class="k">' + escapeXml(m.columns[j].name) + '</span><span class="g">' + gridMarkOf(c.mark) + '</span><span class="v">' + escapeXml(c.text || "") + (c.why ? ' <span class="why">\u00B7 ' + escapeXml(c.why) + '</span>' : '') + '</span></div>'; }).join("") + '</div></details>';
2885
+ }).join("") + '</div>';
2886
+ }
2887
+ function shapeResultCard(line, detail, many){
2888
+ var m = line.shape;
2889
+ var h = '<div class="job-card" data-testid="result-shape"><h4>Result' + (many ? " \u00B7 line " + escapeXml(String(line.n)) : "") + '</h4>';
2890
+ if(!m){
2891
+ h += '<div class="hint" data-testid="result-nofile">' + RESULT_NONE + '</div>';
2892
+ } else {
2893
+ h += '<p class="tg-stats" data-testid="shape-stats"><b>' + escapeXml(String(detail.flow || "")) + '</b> \u00B7 ' + escapeXml(String(detail.runId || "")) + ' \u00B7 <b>' + m.total + '</b> items \u00B7 <b>' + m.passed + '</b> passed \u00B7 <b>' + m.failed + '</b> failed</p>';
2894
+ h += shapeFoldHtml(m);
2895
+ }
2896
+ return h + resultNotChecked("Not checked", line.notChecked, "result-line-notchecked") + '</div>';
2897
+ }
2841
2898
  // `own` = the Result tab read 2+ pages, so this line's box shows its own page
2842
2899
  function resultLineCard(line, own, note){
2900
+ if(line.kind === "shape") return shapeResultCard(line, resultDetail || {}, !!(resultData && (resultData.lines || []).length > 1));
2843
2901
  return '<div class="job-card" data-testid="result-line"><h4>Line ' + escapeXml(String(line.n)) + '</h4>' + resultLineBox(line) +
2844
2902
  (own ? resultPageLink(line.page, note, "result-page-line") : "") +
2845
2903
  (line.kind === "facts" ? resultFactsLine(line) : resultTextLine(line)) + (line.sheet ? resultSheetBlock(line.sheet) : resultChecksList(line)) +
@@ -2995,6 +3053,7 @@
2995
3053
  if((data.delivered || []).length){
2996
3054
  h += '<div class="job-card" data-testid="result-saved"><h4>Saved</h4>' + data.delivered.map(function(d){
2997
3055
  return resultField(d.name, '<div class="ro-value" data-testid="result-path" style="overflow-wrap:anywhere">' + escapeXml(d.path) + '</div>' +
3056
+ (d.note ? '<div class="hint" data-testid="result-file-note">' + escapeXml(d.note) + '</div>' : "") +
2998
3057
  (d.words ? '<div class="rs-warn" data-testid="result-file-gone">' + escapeXml(d.words) + '</div>'
2999
3058
  : '<div class="run-actions" style="margin:6px 0 0;"><a class="btn" style="text-decoration:none;" data-testid="result-download" download href="/api/runs/' + encodeURIComponent(data.flow) + '/' + encodeURIComponent(data.runId) + '/download?i=' + d.i + '">Download ' + escapeXml(d.name) + '</a></div>'));
3000
3059
  }).join("") + '</div>';
@@ -4129,43 +4188,73 @@
4129
4188
  // borrowed-from: bareloop src/panel/index.html@v0.56.0 (3383cce) :3845-3885 (auditCheckRowHtml, auditChecksSignClass, auditChecksEl), drawn in fwdloop's own fold (the learnings fold's header and body shape), appended inside #audit-groups
4130
4189
  // the tag of a row by its kind (M16 item 5, one spelling: src/checkwords.js TAG): `~` rows [you], `!` rows [agent], `$` rows [default]; the plan card and the Audit both draw it
4131
4190
  function tagWordOf(by){ return by === "you" || by === "agent" || by === "default" ? "[" + by + "]" : ""; }
4132
- function byTagOf(by){ return tagWordOf(by) === "" ? "" : ' <span class="by" data-testid="plan-by" data-by="' + by + '">' + tagWordOf(by) + '</span>'; }
4191
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (fc56e1f3) byTagOf (the sign before the tag, section 3.7: `~ [you]`, `! [agent]`, `$ [default]`)
4192
+ function byTagOf(by, form){ return (tagWordOf(by) === "" ? "" : ' <span class="by" data-testid="plan-by" data-by="' + by + '">' + (by === "you" ? "~ " : by === "agent" ? "! " : "$ ") + tagWordOf(by) + '</span>') + (form === "shape" ? ' <span class="by" data-testid="plan-form" data-form="shape">[shape]</span>' : ""); }
4193
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (fc56e1f3) ckTagHtml, ckRowHtml, ckGroupHtml (the signed check-list look): a row is `[tag] kind words ... right`, the tag first in a fixed column,
4194
+ // the kind word second (`truth`, `shape`, `file`), the Drop / Add or the result at the right; a long reason sits behind "why", a failed row's red reason indented under it.
4195
+ function ckTagHtml(by){ return '<span class="by tagcol" data-testid="plan-by"' + (by ? ' data-by="' + escapeXml(by) + '"' : "") + ">" + (by ? "[" + escapeXml(by) + "]" : "") + "</span>"; }
4196
+ function ckRowHtml(o){
4197
+ var why = o.why ? ' <details class="ck-why" data-testid="ck-why"><summary>\u25B8 why</summary><div class="hint">' + escapeXml(o.why) + "</div></details>" : "";
4198
+ return '<div class="ck-row" data-testid="' + (o.testid || "plan-check") + '"' + (o.attrs || "") + (o.title ? ' title="' + escapeXml(o.title) + '"' : "") + ">" + ckTagHtml(o.by) + '<span class="kind" data-testid="ck-kind">' + (o.kind ? escapeXml(o.kind) : "") + '</span><span class="ck-t">' + escapeXml(o.text) + why + "</span>" + (o.right ? '<span class="ck-right">' + o.right + "</span>" : "") + (o.under || "") + "</div>";
4199
+ }
4200
+ function ckGroupHtml(title, rows, testid, tail){
4201
+ return rows.length ? '<div class="ck-g" data-testid="' + testid + '"><div class="ck-h">' + escapeXml(title) + " \u00B7 " + rows.length + (tail ? " \u00B7 " + escapeXml(tail) : "") + "</div>" + rows.join("") + "</div>" : "";
4202
+ }
4133
4203
  // M16 P4c: the plan view of bareloop's card and Job tab, one drawing for both. `plan` = {lines: [{n, text, rules, leads, checks, extra}], suggested, notChecked, notCheckedBy, readNotes, alwaysOn}; the server wrote every string.
4134
4204
  // `ctl` (the card only) draws the Drop / Add button of a row. fwdloop's own rows keep their place in bareloop's structure: a line's lead sentence (src/checked.js) and a sheet line's block draw as a row under their line.
4135
4205
  // borrowed-from: bareloop src/panel/index.html@v0.56.0 (3383cce) :4157-4196 (planViewHtml: the line, its `~` rows, `\u203A check` rows, Suggested, the Not checked / How the page was read / Always checked folds)
4136
- function planCheckRowHtml(name, cls, by, ctlHtml){
4137
- return '<div class="fold" data-testid="plan-check"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(name) + (cls ? " \u00B7 " + escapeXml(cls) : "") + byTagOf(by) + (ctlHtml || "") + "</div>";
4138
- }
4139
4206
  function planFoldHtml(title, items, testid, byOf){
4140
4207
  if(!items || !items.length) return "";
4141
4208
  return '<details class="fold" data-testid="' + testid + '"><summary>' + escapeXml(title) + " \u00B7 " + items.length + "</summary><ul>" +
4142
4209
  items.map(function(x){ return "<li>" + escapeXml(x) + byTagOf(byOf(x)) + "</li>"; }).join("") + "</ul></details>";
4143
4210
  }
4211
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (fc56e1f3) renderJobPlan (the groups of the signed look); fwd's own rows (a line's lead sentence, a sheet line's block, "How the page was read") keep their words inside it
4212
+ function planLegend(){
4213
+ return "Done when every check below passes";
4214
+ }
4144
4215
  function planViewHtml(plan, ctl){
4145
- var hasCheck = (plan.lines || []).some(function(l){ return (l.checks || []).length; });
4146
- var h = '<div class="jp" data-testid="job-plan">' + (hasCheck ? '<div class="jp-legend">Done when every <b>\u203A</b> check passes</div>' : "");
4147
- (plan.lines || []).forEach(function(l){
4216
+ var lines = plan.lines || [];
4217
+ var hasCheck = (plan.alwaysOn || []).length > 0 || lines.some(function(l){ return (l.checks || []).length; });
4218
+ var h = '<div class="jp" data-testid="job-plan">' + (hasCheck ? '<div class="jp-legend">' + planLegend() + "</div>" : "");
4219
+ var checkRow = function(c){
4220
+ var kind = c.kind || (c.shape ? "shape" : "truth");
4221
+ return ckRowHtml({ by: c.by, kind: kind, text: c.name, right: ctl && c.drop && c.key ? ctl("drop", c.key) : "", title: c.cls || "", attrs: c.shape ? ' data-shape="1"' : "" });
4222
+ };
4223
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (ncRow: a dropped rule's Not checked row has an Add back button)
4224
+ var ncRow = function(r){ return ckRowHtml({ by: r.by, text: r.text, why: r.why, testid: "plan-refused", right: ctl && r.addBack ? ctl("add", r.addBack, "Add back") : "" }); };
4225
+ var suggRow = function(x){ return ckRowHtml({ by: "agent", kind: /\.shape\./.test(x.key) ? "shape" : "truth", text: x.text + (x.dropped ? " (you dropped it)" : ""), right: ctl ? ctl("add", x.key) : "", testid: "plan-suggest-row" }); };
4226
+ var nc = plan.ncRows || [];
4227
+ // the rows no one line owns (the two checks every step has, a Not checked note naming no line): in the block of a one-line job, in a block of their own when there are several lines
4228
+ var jobChecks = (plan.alwaysOn || []).map(function(g){ return ckRowHtml({ by: "default", kind: "file", text: g, testid: "plan-always" }); });
4229
+ var jobNc = nc.filter(function(r){ return !r.line || !lines.some(function(l){ return l.n === r.line; }); });
4230
+ var sugg = plan.suggested || [];
4231
+ var oneLine = lines.length === 1;
4232
+ var groups = function(l, own){
4233
+ var checked = (l ? l.checks.map(checkRow) : []).concat(own ? jobChecks : []);
4234
+ var notc = (l ? nc.filter(function(r){ return r.line === l.n; }) : []).concat(own ? jobNc : []).map(ncRow);
4235
+ var sg = sugg.filter(function(x){ return l ? (x.line === l.n || (own && !lines.some(function(y){ return y.n === x.line; }))) : !lines.some(function(y){ return y.n === x.line; }); }).map(suggRow);
4236
+ return ckGroupHtml("CHECKED", checked, "plan-checked") + ckGroupHtml("NOT CHECKED", notc, "plan-notchecked", "you judge these at Accept") + (sg.length ? '<div class="ck-g jp-sug" data-testid="plan-suggested"><div class="ck-h">SUGGESTED \u00B7 add if you want it</div>' + sg.join("") + "</div>" : "");
4237
+ };
4238
+ lines.forEach(function(l){
4148
4239
  h += '<div class="jl" data-testid="plan-line"><span class="num">' + escapeXml(String(l.n)) + "</span>" + escapeXml(l.text);
4149
4240
  (l.rules || []).forEach(function(r){ h += '<div class="sub">~ ' + escapeXml(r) + "</div>"; });
4150
- // fwdloop's own words under the line, plain grey after its `~` rows and before its checks: the line's lead sentence (src/checked.js) and a sheet line's block (hamr 2026-11-14)
4241
+ // fwdloop's own words under the line, plain grey after its `~` rows and before its groups: the line's lead sentence (src/checked.js) and a sheet line's block (hamr 2026-11-14)
4151
4242
  (l.leads || []).concat(l.extra || []).forEach(function(t){ h += '<div class="sub" data-testid="plan-lead">' + escapeXml(t) + "</div>"; });
4152
- (l.checks || []).forEach(function(c){ h += planCheckRowHtml(c.name, c.cls, c.by, ctl && c.drop && c.key ? ctl("drop", c.key) : ""); });
4153
- h += "</div>";
4243
+ h += groups(l, oneLine) + "</div>";
4154
4244
  });
4155
- if((plan.suggested || []).length){
4156
- h += '<div class="jl jp-sug" data-testid="plan-suggested"><span class="num"></span><span class="lbl">Suggested \u00B7 not in your job, not checked unless you add it</span>' + plan.suggested.map(function(x){
4157
- return '<div class="fold" data-testid="plan-suggest-row"><span class="mk">\u203A</span> line ' + escapeXml(String(x.line)) + " \u00B7 " + escapeXml(x.text) + byTagOf("agent") + (x.dropped ? " (you dropped it)" : "") + (ctl ? ctl("add", x.key) : "") + "</div>";
4158
- }).join("") + "</div>";
4245
+ if(!oneLine){
4246
+ var rest = groups(null, true);
4247
+ if(rest) h += '<div class="jl" data-testid="plan-job-level"><span class="num"></span><span class="lbl">Every line</span>' + rest + "</div>";
4159
4248
  }
4160
- var ncBy = plan.notCheckedBy || {};
4161
- h += planFoldHtml("Not checked", plan.notChecked, "plan-notchecked", function(x){ return ncBy[x]; });
4162
4249
  h += planFoldHtml("How the page was read", plan.readNotes, "plan-readnotes", function(){ return ""; });
4163
- h += planFoldHtml("Always checked", plan.alwaysOn, "plan-alwayson", function(){ return "default"; });
4164
4250
  return h + "</div>";
4165
4251
  }
4252
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (fc56e1f3) auditCheckRowHtml: `[tag] kind words ... result`, the result word at the right, a failed row's red reason indented under it; a Not checked row has no result word, only its "why"
4166
4253
  function auditCheckRowHtml(r){
4167
4254
  var res = r.result === "passed" ? ["green", "passed"] : r.result === "failed" ? ["red", "failed"] : r.result === "not-checked" ? ["grey", "not checked"] : ["grey", "no result recorded"];
4168
- return '<div class="audit-check-row" data-testid="audit-check-row" data-result="' + escapeXml(r.result) + '" style="overflow-wrap:anywhere;margin:2px 0">' + escapeXml(r.text) + byTagOf(r.by) + " " + stateDotHTML(res[0], res[1], "audit-check-state") + "</div>";
4255
+ var nc = r.result === "not-checked";
4256
+ return ckRowHtml({ by: r.by, kind: nc ? "" : r.kind, text: r.text, why: nc ? r.why : "", testid: "audit-check-row", attrs: ' data-result="' + escapeXml(r.result) + '"', right: nc ? "" : stateDotHTML(res[0], res[1], "audit-check-state"),
4257
+ under: r.result === "failed" && r.why ? '<div class="hint ck-under" data-testid="audit-check-why">' + escapeXml(r.why) + "</div>" : "" });
4169
4258
  }
4170
4259
  // the fold's one state sign: any row failed = [\u2717]; else any row with no recorded result = [\u00B7]; else [\u2713] ("not checked" rows never move it)
4171
4260
  function auditChecksSignClass(rows){
@@ -4200,15 +4289,24 @@
4200
4289
  body.className = "audit-fold-body";
4201
4290
  body.hidden = true;
4202
4291
  body.setAttribute("data-testid", "audit-checks-body");
4203
- var sec = function(title, rows, tid){
4204
- if(!rows || !rows.length) return "";
4205
- return '<div data-testid="' + tid + '" style="margin:6px 0"><div><b>' + escapeXml(title) + "</b></div>" + rows.map(auditCheckRowHtml).join("") + "</div>";
4206
- };
4292
+ var grp = function(title, rows, tid, tail){ return ckGroupHtml(title, rows.map(auditCheckRowHtml), tid, tail); };
4207
4293
  var readSec = function(notes){
4208
4294
  if(!notes || !notes.length) return "";
4209
4295
  return '<div data-testid="audit-checks-readnotes" style="margin:6px 0"><div><b>How the page was read</b></div>' + notes.map(function(t){ return '<div class="audit-check-row" data-testid="audit-read-note" style="overflow-wrap:anywhere;margin:2px 0">' + escapeXml(t) + "</div>"; }).join("") + "</div>";
4210
4296
  };
4211
- body.innerHTML = '<div class="jp">' + sec("Checks", ac.checks, "audit-checks-checks") + sec("Not checked", ac.notChecked, "audit-checks-notchecked") + readSec(ac.readNotes) + sec("Always checked", ac.always, "audit-checks-always") + "</div>";
4297
+ // borrowed-from: bareloop src/panel/index.html@v0.61.0 (fc56e1f3) auditChecksEl: one block per job line (signed look): `Line N text`, its CHECKED rows, its NOT CHECKED rows; the rows no line owns (the two every step has, a Not checked note naming no line) join the block of a one-line job, else have a block of their own
4298
+ var lineBlocks = ac.lines || [];
4299
+ var blocks = lineBlocks.map(function(l, i, all){
4300
+ var own = all.length === 1;
4301
+ return '<div class="jl" data-testid="audit-line"><span class="lbl">Line ' + escapeXml(String(l.n)) + "</span> " + escapeXml(l.text) +
4302
+ grp("CHECKED", (l.checks || []).concat(own ? (ac.always || []) : []), "audit-checks-checks") + grp("NOT CHECKED", (l.notChecked || []).concat(own ? (ac.jobNotChecked || []) : []), "audit-checks-notchecked", "you judge these at Accept") + "</div>";
4303
+ });
4304
+ if(lineBlocks.length !== 1){
4305
+ var rest = grp("CHECKED", ac.always || [], "audit-checks-always") + grp("NOT CHECKED", ac.jobNotChecked || [], "audit-checks-notchecked", "you judge these at Accept");
4306
+ if(rest) blocks.push('<div class="jl" data-testid="audit-job-level"><span class="lbl">Every line</span>' + rest + "</div>");
4307
+ }
4308
+ // a run read without its per-line data (an older record, a row owned by a line the job text lacks) keeps the flat groups, no row lost
4309
+ body.innerHTML = '<div class="jp">' + (lineBlocks.length ? blocks.join("") : grp("CHECKED", (ac.checks || []).concat(ac.always || []), "audit-checks-checks") + grp("NOT CHECKED", ac.notChecked || [], "audit-checks-notchecked", "you judge these at Accept")) + readSec(ac.readNotes) + "</div>";
4212
4310
  function paint(open){ body.hidden = !open; wrap.classList.toggle("closed", !open); btn.setAttribute("aria-expanded", open ? "true" : "false"); }
4213
4311
  function toggle(){ var open = body.hidden; auditExpanded["\u0000checks"] = open; paint(open); }
4214
4312
  btn.addEventListener("click", toggle);
@@ -4488,12 +4586,16 @@
4488
4586
  tail.innerHTML = "";
4489
4587
  (plan.steps || []).filter(function(st){ return !placed[st.step]; }).forEach(function(st){ tail.appendChild(jobStepFold(st, job)); });
4490
4588
  var nc = plan.notChecked || {};
4491
- // M16 P4c: a plan with a list draws bareloop's three folds (Not checked, How the page was read, Always checked), each line tagged
4589
+ // M19 S6: a plan with a list draws the signed look's rows no line owns in an "Every line" block (a one-line job's sit in its Line 1 block, above), then "How the page was read"
4492
4590
  if(plan.always && nc.recorded){
4493
4591
  var jpFolds = document.createElement("div");
4494
4592
  jpFolds.className = "jp";
4495
- var ncBy = nc.by || {};
4496
- jpFolds.innerHTML = planFoldHtml("Not checked", nc.items, "plan-notchecked", function(x){ return ncBy[x]; }) + planFoldHtml("How the page was read", nc.readNotes, "plan-readnotes", function(){ return ""; }) + planFoldHtml("Always checked", plan.always, "plan-alwayson", function(){ return "default"; });
4593
+ var many = (job.prose || []).length !== 1;
4594
+ var lineNos = (job.prose || []).map(function(x){ return x.line; });
4595
+ var restNc = (nc.rows || []).filter(function(r){ return (many && !r.line) || (r.line && lineNos.indexOf(r.line) < 0); }).map(function(r){ return ckRowHtml({ by: r.by, text: r.text, why: r.why, testid: "plan-refused" }); });
4596
+ var restChecked = many ? (plan.always || []).map(function(g){ return ckRowHtml({ by: "default", kind: "file", text: g, testid: "plan-always" }); }) : [];
4597
+ var rest = ckGroupHtml("CHECKED", restChecked, "plan-checked") + ckGroupHtml("NOT CHECKED", restNc, "plan-notchecked", "you judge these at Accept");
4598
+ jpFolds.innerHTML = (rest ? '<div class="jl" data-testid="plan-job-level"><span class="lbl">Every line</span>' + rest + "</div>" : "") + planFoldHtml("How the page was read", nc.readNotes, "plan-readnotes", function(){ return ""; });
4497
4599
  tail.appendChild(jpFolds);
4498
4600
  return;
4499
4601
  }
@@ -4537,6 +4639,9 @@
4537
4639
  jobEl.innerHTML = "";
4538
4640
  // M4e amendment 37: one wrapper per signed line: the human's words, its `~` rows, then its step(s) folded under it (the plan, never in the same row).
4539
4641
  var placed = {};
4642
+ // am2 item 1: the Job tab's legend, first in the box, only when the plan has a check (bareloop v0.61.0 renderJobPlan's hasCheck); the same string as the card's
4643
+ var jobPlan = job.plan || {};
4644
+ if((jobPlan.always || []).length > 0 || (jobPlan.steps || []).some(function(st){ return (st.listRows || []).length; })) jobEl.appendChild(textDiv("jp-legend", planLegend()));
4540
4645
  if(!job.prose || !job.prose.length){
4541
4646
  jobEl.appendChild(textDiv("hint", "no signed prose lines"));
4542
4647
  } else {
@@ -4555,11 +4660,16 @@
4555
4660
  });
4556
4661
  // M16 P4c: the checks of a list line sit under the job line as `\u203A check` rows with their tags (bareloop's Job tab); the step fold keeps the rest
4557
4662
  // the line's lead sentence and a sheet block draw as plain grey lines first (hamr 2026-11-14), then the rows
4558
- var listRowsHtml = "";
4663
+ var listRowsHtml = "", listChecked = [];
4559
4664
  ((job.plan && job.plan.steps) || []).filter(function(st){ return st.line === l.line; }).forEach(function(st){
4560
4665
  if(job.plan.always && !st.ask) (st.check || []).concat(sheetBlockLines(st.sheet, true)).forEach(function(t){ listRowsHtml += '<div class="sub" data-testid="plan-lead">' + escapeXml(t) + "</div>"; });
4561
- (st.listRows || []).forEach(function(r){ listRowsHtml += planCheckRowHtml(r.text, "", r.by, ""); });
4666
+ (st.listRows || []).forEach(function(r){ listChecked.push(ckRowHtml({ by: r.by, kind: r.kind || "truth", text: r.text })); });
4562
4667
  });
4668
+ var ncAll = (job.plan && job.plan.notChecked && job.plan.notChecked.rows) || [];
4669
+ var oneJobLine = job.prose.length === 1;
4670
+ var ownNc = ncAll.filter(function(r){ return r.line === l.line || (oneJobLine && !r.line); }).map(function(r){ return ckRowHtml({ by: r.by, text: r.text, why: r.why, testid: "plan-refused" }); });
4671
+ var ownChecked = listChecked.concat(oneJobLine && job.plan && job.plan.always ? job.plan.always.map(function(g){ return ckRowHtml({ by: "default", kind: "file", text: g, testid: "plan-always" }); }) : []);
4672
+ if(listChecked.length || ownNc.length || (oneJobLine && job.plan && job.plan.always)) listRowsHtml += ckGroupHtml("CHECKED", ownChecked, "plan-checked") + ckGroupHtml("NOT CHECKED", ownNc, "plan-notchecked", "you judge these at Accept");
4563
4673
  if(listRowsHtml){ var jpRows = document.createElement("div"); jpRows.className = "jp"; jpRows.innerHTML = listRowsHtml; cell.appendChild(jpRows); }
4564
4674
  ((job.plan && job.plan.steps) || []).filter(function(st){ return st.line === l.line; }).forEach(function(st){
4565
4675
  placed[st.step] = true;
@@ -5716,6 +5826,8 @@
5716
5826
  var qChoices = document.getElementById("chat-q-choices");
5717
5827
  var qAgree = document.getElementById("chat-q-agree");
5718
5828
  var qDrop = document.getElementById("chat-q-drop");
5829
+ var qColumn = document.getElementById("chat-q-column");
5830
+ var qOr = document.getElementById("chat-q-or");
5719
5831
  var extrasEl = document.getElementById("chat-extras");
5720
5832
  var newBox = document.getElementById("jf-new");
5721
5833
  var runBox = document.getElementById("jf-run");
@@ -5964,29 +6076,34 @@
5964
6076
  if(!q) return null;
5965
6077
  // M10 am2 item 1 / am5 item 1: a question the page look raised is ONE plain chat message (bareloop's words); the head and line rows stay empty
5966
6078
  if(q.source === "look"){
5967
- return { key: String(state.draftId) + ":" + q.k, k: q.k, head: "", line: "", question: "A question the plan raised (" + q.k + " of " + state.total + "), about job line " + q.line + ": " + (typeof q.shown === "string" ? q.shown : q.question), agree: q.proposes === true, drop: q.drops === true };
6079
+ return { key: String(state.draftId) + ":" + q.k, k: q.k, head: "", line: "", question: "A question the plan raised (" + q.k + " of " + state.total + "), about job line " + q.line + ": " + (typeof q.shown === "string" ? q.shown : q.question), agree: q.proposes === true, drop: q.drops === true, columns: Array.isArray(q.columns) ? q.columns : [] };
5968
6080
  }
5969
6081
  return {
5970
6082
  key: String(state.draftId) + ":" + q.k, k: q.k,
5971
6083
  head: "A question the plan raised (" + q.k + " of " + state.total + ")",
5972
6084
  line: q.lineText ? "About job line " + q.line + ": " + q.lineText : "About job line " + q.line,
5973
- question: q.question, agree: false, drop: false
6085
+ question: q.question, agree: false, drop: false, columns: []
5974
6086
  };
5975
6087
  }
5976
6088
  // pure: the plan view's model for a plan with a list: each job line with its `~` rules, its lead sentence (src/checked.js), the built rows of the list, a sheet line's block; then the suggestions and the three folds
5977
6089
  function planOfState(state, list){
5978
6090
  var nc = state.notChecked || {};
5979
- var plan = {lines: [], suggested: list.suggested || [], notChecked: nc.items || [], notCheckedBy: nc.by && typeof nc.by === "object" ? nc.by : {}, readNotes: nc.readNotes || [], alwaysOn: state.always || []};
6091
+ var plan = {lines: [], suggested: list.suggested || [], notChecked: nc.items || [], notCheckedBy: nc.by && typeof nc.by === "object" ? nc.by : {}, readNotes: nc.readNotes || [], alwaysOn: state.always || [], ncRows: (nc.rows || []).map(function(r){ return Object.assign({}, r); })};
5980
6092
  (state.planLines || []).forEach(function(pl){
5981
6093
  var l = {n: pl.n, text: pl.text, rules: pl.rules || [], leads: [], checks: [], extra: []};
5982
6094
  state.checked.forEach(function(c){
5983
6095
  if(c.line !== pl.n) return;
5984
- if(c.sentences.length) l.leads.push(c.sentences[0]);
6096
+ if(typeof c.lead === "string") l.leads.push(c.lead);
5985
6097
  sheetBlockLines(c.sheet, true).forEach(function(t){ l.extra.push(t); });
5986
6098
  });
5987
- list.rows.filter(function(r){ return r.line === pl.n && r.state === "built"; }).forEach(function(r){ l.checks.push({name: r.text, cls: "", by: r.by, key: r.key, drop: r.drop === true}); });
6099
+ list.rows.filter(function(r){ return r.line === pl.n && r.state === "built"; }).forEach(function(r){ l.checks.push({name: r.text, cls: "", by: r.by, key: r.key, drop: r.drop === true, kind: r.kind}); });
5988
6100
  plan.lines.push(l);
5989
6101
  });
6102
+ // borrowed-from: bareloop src/panel/jobplan.js@v0.61.0 (planFromConfirm: a rule the person dropped, confirm card only: its Not checked row carries the key the Add back button posts)
6103
+ (list.restorable || []).forEach(function(x){
6104
+ var n = plan.ncRows.find(function(r){ return r.addBack === undefined && r.text === x.text && (r.line === x.line || r.line === 0); });
6105
+ if(n) n.addBack = x.key;
6106
+ });
5990
6107
  return plan;
5991
6108
  }
5992
6109
  // pure: what sits beside a green plan: Your answers (only when the plan was drafted with some), Checked (the machine's sentences from the
@@ -6847,6 +6964,15 @@
6847
6964
  qHead.hidden = v.head === ""; qLine.hidden = v.line === ""; // a look question is one plain message: no empty rows
6848
6965
  // M10 am29: every question has the labelled box; a look question also has Agree (only when it proposes something) and Drop it
6849
6966
  qAgree.hidden = !v.agree; qDrop.hidden = !v.drop; qChoices.hidden = !(v.agree || v.drop);
6967
+ // M17 am9 item 2: a column tie is a closed question: ONE choose-one picker (a native select) listing every tied column, the answer button, and Drop it; no box to type your own words, no Agree
6968
+ qColumn.textContent = "";
6969
+ qColumn.hidden = v.columns.length === 0;
6970
+ qOr.hidden = v.columns.length > 0; qAnswer.hidden = v.columns.length > 0;
6971
+ if(v.columns.length){
6972
+ var first = document.createElement("option"); first.value = ""; first.textContent = "Choose a column"; qColumn.appendChild(first);
6973
+ v.columns.forEach(function(c){ var o = document.createElement("option"); o.value = c; o.textContent = c; qColumn.appendChild(o); });
6974
+ }
6975
+ qColumn.value = "";
6850
6976
  qAnswer.value = ""; qError.textContent = "";
6851
6977
  }
6852
6978
  }
@@ -6856,8 +6982,8 @@
6856
6982
  return escapeXml(l.text) + byTagOf(l.by);
6857
6983
  }
6858
6984
  // the Drop / Add button of the plan view (bareloop's control; the click is handled once on the extras box)
6859
- function planControlHTML(op, key){
6860
- return ' <button type="button" class="btn jp-btn" data-testid="plan-' + op + '" data-rowop="' + op + '" data-rowkey="' + escapeXml(key) + '">' + (op === "add" ? "Add" : "Drop") + "</button>";
6985
+ function planControlHTML(op, key, label){
6986
+ return ' <button type="button" class="btn jp-btn" data-testid="plan-' + op + '" data-rowop="' + op + '" data-rowkey="' + escapeXml(key) + '">' + (label || (op === "add" ? "Add" : "Drop")) + "</button>";
6861
6987
  }
6862
6988
  // M13 am11c: the action row, two cases, never a Drop (to change it, Revise). You picked it (Agree or typed): [you]. The AI's pick, or an old log with no `by`: [agent].
6863
6989
  function actionRowHtml(a){
@@ -6920,6 +7046,14 @@
6920
7046
  startOverBtn.disabled = !!st.busy;
6921
7047
  fitCardBoxes();
6922
7048
  }
7049
+ // M17 am9a item 2: while a session is live the job box follows the server's newest card (`card.job`, the job as `applyAnswers` wrote it after an answer: the rule as answered). The page reads it, never
7050
+ // recomputes it, and never touches the box while Revise has it open for typing.
7051
+ function syncJobBoxFromSession(state){
7052
+ var jt = state && state.card && state.card.job;
7053
+ var box = document.getElementById("jf-job");
7054
+ if(!sessionLive || reviseOpen || typeof jt !== "string" || jt === box.value) return;
7055
+ setVal("jf-job", jt); fitCardBoxes();
7056
+ }
6923
7057
  function renderActions(state){
6924
7058
  lastState = state;
6925
7059
  renderQuestion(state);
@@ -6932,6 +7066,7 @@
6932
7066
  var progressChanged = renderProgress(stepsFor(state, {model: drafterModel, starting: startId !== null, signClicked: signClickedOnce}));
6933
7067
  sessionLive = CLIENT_TERMINAL_PHASES.indexOf(state.phase) === -1;
6934
7068
  refreshStartEnabled();
7069
+ syncJobBoxFromSession(state);
6935
7070
  // while the draft is live and the list changed, bring the newest progress line into view.
6936
7071
  // Never moves keyboard focus, and an unchanged poll tick never scrolls.
6937
7072
  if(progressChanged && sessionLive && progressRow.lastElementChild){
@@ -7083,16 +7218,16 @@
7083
7218
  });
7084
7219
  function doAnswer(choice){
7085
7220
  if(qBusy || !sessionId || !lastState || lastState.phase !== "questions-open") return;
7086
- qBusy = true; qSend.disabled = true; qAgree.disabled = true; qDrop.disabled = true; qError.textContent = "";
7221
+ qBusy = true; qSend.disabled = true; qAgree.disabled = true; qDrop.disabled = true; qColumn.disabled = true; qError.textContent = "";
7087
7222
  var id = sessionId;
7088
- var body = choice === "agree" || choice === "drop" ? {k: lastState.openK, choice: choice} : {k: lastState.openK, answer: qAnswer.value, choice: "rule"};
7223
+ var body = choice === "agree" || choice === "drop" ? {k: lastState.openK, choice: choice} : !qColumn.hidden ? {k: lastState.openK, answer: qColumn.value, choice: "column"} : {k: lastState.openK, answer: qAnswer.value, choice: "rule"};
7089
7224
  authorPost("/api/author/" + id + "/answer", body).then(function(r){
7090
- qBusy = false; qSend.disabled = false; qAgree.disabled = false; qDrop.disabled = false;
7225
+ qBusy = false; qSend.disabled = false; qAgree.disabled = false; qDrop.disabled = false; qColumn.disabled = false;
7091
7226
  if(id !== sessionId) return;
7092
7227
  if(!(r.status >= 200 && r.status < 300 && r.body && r.body.ok === true)){ qError.textContent = refusalText(r); return; }
7093
7228
  qAnswer.value = "";
7094
7229
  poll();
7095
- }).catch(function(){ qBusy = false; qSend.disabled = false; qAgree.disabled = false; qDrop.disabled = false; qError.textContent = NETWORK_SAY; });
7230
+ }).catch(function(){ qBusy = false; qSend.disabled = false; qAgree.disabled = false; qDrop.disabled = false; qColumn.disabled = false; qError.textContent = NETWORK_SAY; });
7096
7231
  }
7097
7232
  function doDraft(startedOverFrom){
7098
7233
  clearFieldErrors();
@@ -15,6 +15,7 @@ import { readFileInside } from '../flow.js';
15
15
  import { isCellsPath } from '../closers.js';
16
16
  import { readAcceptedHashesByEmits } from '../ask.js';
17
17
  import { notCheckedLabelOf } from '../checked.js';
18
+ import { REPORT_RENAMED } from '../report.js';
18
19
  import { checkSendDestination, readArtifactResult } from '../runner.js';
19
20
  import { flowTypeOf } from '../declaration.js';
20
21
  import { isAgree, readingOfQuestion } from '../pageask.js';
@@ -24,6 +25,10 @@ import { readChecks } from '../diary.js';
24
25
  import { sheetLineBlocks, csvRolesOf } from '../sheetblock.js';
25
26
  import { readSheetChecks } from '../sheet-record.js';
26
27
  import { tagged } from '../checkwords.js';
28
+ import { shapeResultModel } from '../shaperesult.js';
29
+ import { shapeItemOfPlain } from '../shapewords.js';
30
+ import { SHAPE_TRUTH_WORDS } from '../shaperows.js';
31
+ import { lineRulesOf } from '../whole-job.js';
27
32
 
28
33
  /** the two sentences for a saved file that is no longer what the run wrote (code-owned, one spelling) */
29
34
  export const RESULT_FILE_GONE = 'the saved file is gone';
@@ -178,10 +183,10 @@ export function readDelivered(rec) {
178
183
  }
179
184
 
180
185
  /**
181
- * The files this run's signed sends wrote: for each signed send whose send step ended green in the audit, the file `<flow>-<runId>-<emits>.md`
186
+ * The files this run's signed sends wrote: for each signed send whose send step ended green in the audit, the file `<job>-YYYY-MM-DD[-n].md` (`sentName`, M15 am3; older runs: `<flow>-<runId>-<emits>.md`)
182
187
  * in the signed folder with the sha256 the send recorded for it (M15), or, for a send older than M15, `.json` with the sha256 the human's accept recorded for the ask that
183
188
  * send reads (`readAcceptedHashesByEmits`, the same record the send itself checked). No accepted hash = recorded as null, which reads as "changed", never as ok.
184
- * @returns {{path: string, dir: string|null, name: string, sha256: string|null}[]}
189
+ * @returns {{path: string, dir: string|null, name: string, note: string|null, sha256: string|null}[]}
185
190
  */
186
191
  export function deliveredOf({
187
192
  arbiter, declaration, runDir, root, flow, runId, auditRows,
@@ -197,11 +202,13 @@ export function deliveredOf({
197
202
  if (!step || !sentRow) continue; // eslint-disable-line no-continue
198
203
  // M15 item 4: a send since M15 wrote `<emits>.md` and recorded that file's own sha256 on its green audit row; an older send wrote the JSON, bound to the accept's hash
199
204
  const plain = isStr(sentRow.sentSha256) && sentRow.sentSha256 !== '';
200
- const name = `${flow}-${runId}-${step.emits}.${plain ? 'md' : 'json'}`;
205
+ // M15 am3: a send since am3 recorded the name it wrote (`sentName`, `<job>-YYYY-MM-DD[-n].md`); an older .md send is `<flow>-<runId>-<emits>.md`, an older still the .json. Old files are not renamed.
206
+ const name = plain && isStr(sentRow.sentName) && sentRow.sentName !== '' ? sentRow.sentName : `${flow}-${runId}-${step.emits}.${plain ? 'md' : 'json'}`;
201
207
  const dest = checkSendDestination(`${send.target.kind}:${send.target.path}`, { root, runDir });
202
208
  const [askId] = (step.reads ?? []).filter((id) => askEmits.has(id));
203
209
  out.push({
204
210
  path: join(dest.ok ? dest.dir : send.target.path, name), dir: dest.ok ? dest.dir : null, name,
211
+ note: plain && isStr(sentRow.sentTaken) && sentRow.sentTaken !== '' ? REPORT_RENAMED(sentRow.sentTaken) : null,
205
212
  sha256: plain ? sentRow.sentSha256 : (hashes.ok && askId !== undefined ? (hashes.byEmits.get(askId) ?? null) : null),
206
213
  });
207
214
  }
@@ -232,6 +239,26 @@ function gapOf(text) {
232
239
  return { line: rows[0], more, moreText: more > 0 ? `(+${more} more)` : null };
233
240
  }
234
241
 
242
+ /**
243
+ * borrowed-from: bareloop src/panel/server.js@v0.61.0 (`shapeRedsFromRecords`, the gap-line half), adjusted to fwdloop's books: a run records the close's plain gap lines on its audit and log.json attempt rows (never bareguard's per-row record),
244
+ * and a red run's judged answer is the model output of that attempt in log.json. A shape line's answer for the Result tab: the delivered artifact (the step closed green: no item is red) or, for a red run, the step's last red attempt
245
+ * with the item reds read back from its plain gap lines through `shapeItemOfPlain`. Third outcome: nothing readable is `null` (the page says "no saved result to show").
246
+ * @param {{runDir: string, step: any, line: number, logJson: any}} a @returns {{results: any[], reds: string[]}|null}
247
+ */
248
+ export function shapeAnswerOf({ runDir, step, line, logJson }) {
249
+ const a = readArtifactResult(runDir, step.emits);
250
+ if (a.ok && a.value && typeof a.value === 'object' && Array.isArray(a.value.results)) return { results: a.value.results, reds: [] };
251
+ const last = (Array.isArray(logJson?.attempts) ? logJson.attempts : []).filter((t) => t && t.step === step.emits && t.verdict === 'red').at(-1);
252
+ const out = last?.modelOutput;
253
+ if (!out || typeof out !== 'object' || !Array.isArray(out.results)) return null;
254
+ const reds = String(last.gap ?? '').split('\n').flatMap((l) => {
255
+ const m = /^line (\d+): (item \d+.*)$/s.exec(l);
256
+ const red = m && Number(m[1]) === line ? shapeItemOfPlain(m[2]) : null;
257
+ return red ? [red] : [];
258
+ });
259
+ return { results: out.results, reds: [...new Set(reds)] };
260
+ }
261
+
235
262
  /**
236
263
  * The Result tab's JSON for one run (`GET /api/runs/:flow/:runId/result`).
237
264
  * @param {{flow: string, runId: string, runDir: string, root: string, flowRead: any, arbiter: any, historyRow: any, auditRows: any[], logJson: any, notChecked: string[], readNotes?: string[], setupRows?: any[], door?: {askId: string, draftNo: number}|null}} a
@@ -265,6 +292,15 @@ export function buildResult({
265
292
  }).filter((x) => x !== null);
266
293
  if (written.length > 0) out.answer = written.join('\n\n');
267
294
  }
295
+ // M19 S8 (the signed mock A2): a line whose close holds a list-of-items check (`close.itemShape`) shows its answer as a fold of items; the model is src/shaperesult.js's (bareloop v0.61.0), the marks and words the server's
296
+ const shapeStep = (declaration?.steps ?? []).find((st) => st.fromLine === l.n && st.close && typeof st.close.itemShape === 'object' && st.close.itemShape !== null && Array.isArray(st.close.itemShape.fields));
297
+ if (shapeStep) {
298
+ out.kind = 'shape';
299
+ const got = shapeAnswerOf({ runDir, step: shapeStep, line: l.n, logJson });
300
+ out.shape = got === null ? null : shapeResultModel({ part: shapeStep.close.itemShape, results: got.results, reds: got.reds, rules: lineRulesOf(l) });
301
+ if (!out.notChecked.includes(SHAPE_TRUTH_WORDS)) out.notChecked = [...out.notChecked, SHAPE_TRUTH_WORDS];
302
+ return out;
303
+ }
268
304
  if (c) {
269
305
  out.source = c.source;
270
306
  out.page = urls.get(c.source) ?? null;
@@ -283,6 +319,7 @@ export function buildResult({
283
319
  return {
284
320
  i, path: d.path, name: d.name, bytes: got.buf ? got.buf.length : null, state: got.state,
285
321
  words: got.state === 'gone' ? RESULT_FILE_GONE : (got.state === 'changed' ? RESULT_FILE_CHANGED : null),
322
+ note: d.note,
286
323
  };
287
324
  });
288
325
  // a run that failed delivered nothing: say its own first gap, never rows. A stop, a cap halt, a rerun and an expired ask are not a failure (the same
package/src/pickrecord.js CHANGED
@@ -118,6 +118,20 @@ export function readRowChoices(file) {
118
118
  } catch { return null; }
119
119
  }
120
120
 
121
+ // borrowed-from: bareloop src/pickrecord.js@v0.61.0 (fc56e1f3) (readShapeDropped; read through readFileInside like readSheetDropped; writeRecordPart not taken: fwd's writers are src/authoring.js and src/planrebuild.js)
122
+ /**
123
+ * Shape jobs (clause 4): the shape fields a person dropped from a plan, carried like the sheet's (the block's `shapeDroppedRecord`: `{lineWords, occurrence, name}` or `{lineWords, occurrence, rule}`), so a Revise keeps a Drop of the very same field. A missing or unreadable record is no record.
124
+ * @param {string} file @returns {{lineWords: string, occurrence: number, name?: string, rule?: number}[]|null}
125
+ */
126
+ export function readShapeDropped(file) {
127
+ try {
128
+ const g = readFileInside(path.dirname(file), path.basename(file));
129
+ if (!g.ok) return null;
130
+ const j = JSON.parse(g.text);
131
+ return Array.isArray(j?.shapeDropped) ? j.shapeDropped.filter((/** @type {any} */ d) => d && typeof d.lineWords === 'string' && Number.isInteger(d.occurrence) && (typeof d.name === 'string' || Number.isInteger(d.rule))) : null;
132
+ } catch { return null; }
133
+ }
134
+
121
135
  /**
122
136
  * The sheet checks the person dropped from a plan (hamr 2026-11-14: a Revise keeps a sheet Drop), carried like the page-row choices: the record's `sheetDropped` entries, each `{key, line, index, check, text}`;
123
137
  * the next draft drops a new check with the same id again. Read through readFileInside; a missing or unreadable record is no record.