fwdloop 0.32.0 → 0.34.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 (114) hide show
  1. package/bin/fwdloop +20 -2
  2. package/package.json +2 -2
  3. package/src/auditchecks.js +55 -0
  4. package/src/authoring.js +53 -12
  5. package/src/blockasks.js +45 -0
  6. package/src/blockassemble.js +159 -0
  7. package/src/blockdraft.js +86 -0
  8. package/src/blocklines.js +30 -0
  9. package/src/blockpick.js +175 -0
  10. package/src/cardlist.js +19 -0
  11. package/src/checkblock.js +843 -0
  12. package/src/checked.js +48 -9
  13. package/src/checklist.js +99 -0
  14. package/src/checklistsign.js +93 -0
  15. package/src/checkpick.js +7 -73
  16. package/src/checkwords.js +20 -1
  17. package/src/cited-record.js +21 -1
  18. package/src/citedcheck.js +162 -7
  19. package/src/closers.js +41 -3
  20. package/src/declaration.js +34 -9
  21. package/src/declaredclose.js +4 -0
  22. package/src/draft-steps.js +3 -1
  23. package/src/drafter.js +311 -206
  24. package/src/factwords.js +112 -0
  25. package/src/inputlook.js +53 -0
  26. package/src/labelscan.js +162 -0
  27. package/src/noteask.js +62 -0
  28. package/src/pageask.js +9 -69
  29. package/src/pagedropwords.js +11 -1
  30. package/src/pagedry.js +27 -4
  31. package/src/pagerules.js +19 -3
  32. package/src/panel/author.js +76 -7
  33. package/src/panel/authorcard.js +43 -17
  34. package/src/panel/data.js +41 -9
  35. package/src/panel/index.html +208 -13
  36. package/src/panel/result.js +4 -3
  37. package/src/panel/server.js +3 -1
  38. package/src/pickrecord.js +70 -54
  39. package/src/placerule.js +398 -0
  40. package/src/planrebuild.js +216 -0
  41. package/src/rowedit.js +148 -0
  42. package/src/rubricstep.js +272 -0
  43. package/src/runfile.js +4 -2
  44. package/src/runner.js +67 -10
  45. package/src/setup.js +11 -5
  46. package/src/sheetblock.js +22 -8
  47. package/src/sheetbuild.js +151 -0
  48. package/src/sheetchecks.js +52 -66
  49. package/src/sheetclaims.js +12 -32
  50. package/src/sheetfind.js +4 -4
  51. package/src/sheetlook.js +14 -3
  52. package/src/sheetoffer.js +74 -57
  53. package/src/sheetrows.js +123 -0
  54. package/src/sheetrun.js +13 -10
  55. package/src/summary-words.js +3 -3
  56. package/src/ticket-draft.js +4 -21
  57. package/src/ticketrows.js +100 -0
  58. package/src/try-checks.js +31 -12
  59. package/src/types.js +1 -0
  60. package/types/auditchecks.d.ts +25 -0
  61. package/types/authoring.d.ts +21 -2
  62. package/types/blockasks.d.ts +36 -0
  63. package/types/blockassemble.d.ts +50 -0
  64. package/types/blockdraft.d.ts +75 -0
  65. package/types/blocklines.d.ts +31 -0
  66. package/types/blockpick.d.ts +46 -0
  67. package/types/cardlist.d.ts +21 -0
  68. package/types/checkblock.d.ts +378 -0
  69. package/types/checked.d.ts +16 -2
  70. package/types/checklist.d.ts +115 -0
  71. package/types/checklistsign.d.ts +27 -0
  72. package/types/checkpick.d.ts +4 -34
  73. package/types/checkwords.d.ts +5 -0
  74. package/types/cited-record.d.ts +9 -0
  75. package/types/citedcheck.d.ts +33 -2
  76. package/types/closers.d.ts +24 -2
  77. package/types/declaration.d.ts +7 -0
  78. package/types/declaredclose.d.ts +2 -0
  79. package/types/drafter.d.ts +29 -715
  80. package/types/factwords.d.ts +38 -0
  81. package/types/inputlook.d.ts +49 -0
  82. package/types/labelscan.d.ts +35 -0
  83. package/types/noteask.d.ts +52 -0
  84. package/types/pageask.d.ts +2 -35
  85. package/types/pagedry.d.ts +13 -0
  86. package/types/pagerules.d.ts +7 -0
  87. package/types/panel/author.d.ts +41 -0
  88. package/types/panel/authorcard.d.ts +14 -9
  89. package/types/panel/authorflows.d.ts +4 -4
  90. package/types/panel/data.d.ts +5 -3
  91. package/types/panel/jobgrid.d.ts +1 -1
  92. package/types/pickrecord.d.ts +69 -13
  93. package/types/placerule.d.ts +208 -0
  94. package/types/planrebuild.d.ts +52 -0
  95. package/types/provider.d.ts +1 -1
  96. package/types/rowedit.d.ts +48 -0
  97. package/types/rubricstep.d.ts +63 -0
  98. package/types/runfile.d.ts +5 -2
  99. package/types/runner.d.ts +45 -1
  100. package/types/sheetblock.d.ts +12 -4
  101. package/types/sheetbuild.d.ts +84 -0
  102. package/types/sheetchecks.d.ts +12 -18
  103. package/types/sheetclaims.d.ts +2 -1
  104. package/types/sheetfind.d.ts +2 -2
  105. package/types/sheetoffer.d.ts +31 -6
  106. package/types/sheetrows.d.ts +81 -0
  107. package/types/sheetrun.d.ts +4 -4
  108. package/types/summary-words.d.ts +2 -1
  109. package/types/ticket-draft.d.ts +3 -49
  110. package/types/ticketrows.d.ts +61 -0
  111. package/types/try-checks.d.ts +4 -2
  112. package/types/types.d.ts +8 -0
  113. package/src/repairs.js +0 -38
  114. package/types/repairs.d.ts +0 -13
@@ -478,6 +478,9 @@
478
478
  .audit-group.audit-fold h4.audit-status-header::after{content:none;}
479
479
  /* M8 item 6: bareloop's learnings box, copied (borrowed-from: bareloop src/panel/index.html@v0.47.1 417e80c, the learnings arrow only): a framed row, the header a full-width button with the arrow, chip and words inline; the arrow is the same ▶ / ▼ the other Audit folds draw (h4.audit-status-header::before), faint, a smaller gap on a phone */
480
480
  .audit-part{border:1px solid var(--border);margin-bottom:6px;background:var(--panel2);}
481
+ /* borrowed-from: bareloop src/panel/index.html@v0.56.0 (3383cce) :181-182 */
482
+ .audit-caret{flex:none;color:var(--text-faint);margin-right:.6em;}
483
+ @media (max-width: 640px){ .audit-caret{margin-right:.2em;} }
481
484
  .audit-part-toggle{width:100%;text-align:left;display:block;white-space:normal;min-height:44px;padding:8px 10px;}
482
485
  .audit-part-toggle::before,.audit-part-toggle::after{content:"";}
483
486
  .audit-part-toggle.audit-learn-fold::before{content:"\25B6 ";color:var(--text-faint);}
@@ -747,6 +750,30 @@
747
750
  .chat-question .q-err{color:var(--red);}
748
751
  .chat-extras{display:flex;flex-direction:column;gap:10px;margin-bottom:10px;}
749
752
  .chat-extras:empty{display:none;}
753
+ /* M16 item 5: a row of the older blocks wears the tag of its kind */
754
+ .chat-extras .by{color:var(--text-faint);font-size:12px;}
755
+ /* M16 P4c: the plan view of bareloop's card and Job tab (borrowed-from: bareloop src/panel/index.html@v0.56.0 (3383cce) :680-701): job lines numbered, `~` rows under, checks and folds; only the marker is blue */
756
+ .jp{white-space:normal;font-size:13px;}
757
+ .jp-legend{font-size:12px;color:var(--text-faint);margin:0 0 8px;}
758
+ .jp-legend b,.jp .mk{color:var(--plan);font-weight:700;}
759
+ /* a wrapped job line hangs: its text lines up after the number, not under it (the signed mock's gutter shape) */
760
+ .jp .jl{margin-bottom:8px;overflow-wrap:anywhere;padding-left:30px;text-indent:-30px;}
761
+ .jp .jl .sub,.jp .jl .fold{padding-left:0;text-indent:0;}
762
+ .jp .num{display:inline-block;text-indent:0;width:22px;text-align:right;color:var(--text-faint);margin-right:8px;}
763
+ .jp .sub{color:var(--text-dim);padding-left:30px;}
764
+ .jp .fold{padding-left:30px;color:var(--text);}
765
+ /* who added a check: the drafter's [agent] or the person's own [you picked] in the dim of a ~ row */
766
+ .jp .by{color:var(--text-dim);white-space:nowrap;}
767
+ /* the confirm card's Drop / Add: wraps with its row, a comfortable touch target, no horizontal scroll at phone width */
768
+ .jp .jp-btn{margin:2px 0 2px 8px;padding:4px 12px;min-height:32px;font-size:inherit;}
769
+ .jp .fold{overflow-wrap:anywhere;}
770
+ .jp-sug .lbl{display:block;margin-top:6px;font-weight:700;}
771
+ .jp details.fold{padding-left:0;margin:6px 0;}
772
+ .jp details>summary{cursor:pointer;list-style:none;font-weight:700;}
773
+ .jp details>summary::-webkit-details-marker{display:none;}
774
+ .jp details>summary::before{content:"\203A";color:var(--plan);font-weight:700;margin-right:6px;}
775
+ .jp details[open]>summary::before{content:"\2304";}
776
+ .jp details ul{margin:4px 0 0;padding-left:26px;color:var(--text-dim);}
750
777
  .msg.bot .who::before{content:"$ ";}
751
778
  .msg .who{font-size:11px;color:var(--text-faint);margin-bottom:3px;text-transform:none;font-weight:400;}
752
779
  /* the card's free-text boxes wrap (textarea): grow a few rows (fitBox), then scroll inside */
@@ -2691,15 +2718,20 @@
2691
2718
  // M10b am2: what a job line that reads a sheet shows, drawn from the server's ONE block ({guardrails, checked: [{text, ...}], notChecked: [..] | "none"}): its
2692
2719
  // guardrails, "Checked:" with one line per sheet check (name, plain words, covers), then "Not checked:" with the guardrails no check covers, or "none".
2693
2720
  // Pure: the Chat plan card and the Job tab step rows both draw these strings; the server wrote every one of them.
2694
- function sheetBlockLines(sheet){
2721
+ // M16 am4: with `onList` the checks are drawn as rows of the list (tags, Drop) by the caller, so this draws the rest
2722
+ function sheetBlockLines(sheet, onList){
2695
2723
  if(!sheet) return [];
2724
+ // M17 am4 (C7): a plan whose sheet checks code built shows the list only: its rows and its one Not checked list, never this block beside them
2725
+ if(onList && sheet.codeBuilt === true) return [];
2696
2726
  var out = [];
2697
2727
  if((sheet.guardrails || []).length){
2698
2728
  out.push("Guardrails:");
2699
2729
  sheet.guardrails.forEach(function(g){ out.push("- " + g); });
2700
2730
  }
2701
- out.push("Checked:");
2702
- (sheet.checked || []).forEach(function(c){ out.push("- " + c.text); });
2731
+ if(!onList){
2732
+ out.push("Checked:");
2733
+ (sheet.checked || []).forEach(function(c){ out.push("- " + c.text); });
2734
+ }
2703
2735
  if(sheet.notChecked === "none" || !(sheet.notChecked || []).length) out.push("Not checked: none");
2704
2736
  else { out.push("Not checked:"); sheet.notChecked.forEach(function(g){ out.push("- " + g); }); }
2705
2737
  return out;
@@ -3699,7 +3731,7 @@
3699
3731
  };
3700
3732
  if(out.known){
3701
3733
  t.checks.forEach(function(c){
3702
- var cell = { name: String(c.n), n: c.n, question: c.text, source: c.source, status: c.ok ? "pass" : "fail", number: c.ok && c.result ? c.result : null };
3734
+ var cell = { name: String(c.n), n: c.n, question: c.text + (c.by ? " " + tagWordOf(c.by) : ""), source: c.source, status: c.ok ? "pass" : "fail", number: c.ok && c.result ? c.result : null };
3703
3735
  if(!c.ok && !out.red){
3704
3736
  var lines = gridGapLines(t.gap);
3705
3737
  out.red = { lines: lines.length ? lines : [c.text] };
@@ -4080,6 +4112,91 @@
4080
4112
  wrap.appendChild(head); wrap.appendChild(list);
4081
4113
  box.appendChild(wrap);
4082
4114
  }
4115
+ // M16 item 5 (hamr ruling A, 2026-11-13): the card's own sections - Checks, Not checked, Always checked - each row with its tag and, after the run, its recorded result (server: `auditChecks`).
4116
+ // 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
4117
+ // 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
4118
+ function tagWordOf(by){ return by === "you" || by === "agent" || by === "default" ? "[" + by + "]" : ""; }
4119
+ function byTagOf(by){ return tagWordOf(by) === "" ? "" : ' <span class="by" data-testid="plan-by" data-by="' + by + '">' + tagWordOf(by) + '</span>'; }
4120
+ // 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.
4121
+ // `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.
4122
+ // 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)
4123
+ function planCheckRowHtml(name, cls, by, ctlHtml){
4124
+ 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>";
4125
+ }
4126
+ function planFoldHtml(title, items, testid, byOf){
4127
+ if(!items || !items.length) return "";
4128
+ return '<details class="fold" data-testid="' + testid + '"><summary>' + escapeXml(title) + " \u00B7 " + items.length + "</summary><ul>" +
4129
+ items.map(function(x){ return "<li>" + escapeXml(x) + byTagOf(byOf(x)) + "</li>"; }).join("") + "</ul></details>";
4130
+ }
4131
+ function planViewHtml(plan, ctl){
4132
+ var hasCheck = (plan.lines || []).some(function(l){ return (l.checks || []).length; });
4133
+ var h = '<div class="jp" data-testid="job-plan">' + (hasCheck ? '<div class="jp-legend">Done when every <b>\u203A</b> check passes</div>' : "");
4134
+ (plan.lines || []).forEach(function(l){
4135
+ h += '<div class="jl" data-testid="plan-line"><span class="num">' + escapeXml(String(l.n)) + "</span>" + escapeXml(l.text);
4136
+ (l.rules || []).forEach(function(r){ h += '<div class="sub">~ ' + escapeXml(r) + "</div>"; });
4137
+ // 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)
4138
+ (l.leads || []).concat(l.extra || []).forEach(function(t){ h += '<div class="sub" data-testid="plan-lead">' + escapeXml(t) + "</div>"; });
4139
+ (l.checks || []).forEach(function(c){ h += planCheckRowHtml(c.name, c.cls, c.by, ctl && c.drop && c.key ? ctl("drop", c.key) : ""); });
4140
+ h += "</div>";
4141
+ });
4142
+ if((plan.suggested || []).length){
4143
+ 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){
4144
+ 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>";
4145
+ }).join("") + "</div>";
4146
+ }
4147
+ var ncBy = plan.notCheckedBy || {};
4148
+ h += planFoldHtml("Not checked", plan.notChecked, "plan-notchecked", function(x){ return ncBy[x]; });
4149
+ h += planFoldHtml("How the page was read", plan.readNotes, "plan-readnotes", function(){ return ""; });
4150
+ h += planFoldHtml("Always checked", plan.alwaysOn, "plan-alwayson", function(){ return "default"; });
4151
+ return h + "</div>";
4152
+ }
4153
+ function auditCheckRowHtml(r){
4154
+ var res = r.result === "passed" ? ["green", "passed"] : r.result === "failed" ? ["red", "failed"] : r.result === "not-checked" ? ["grey", "not checked"] : ["grey", "no result recorded"];
4155
+ 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>";
4156
+ }
4157
+ // 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)
4158
+ function auditChecksSignClass(rows){
4159
+ if(rows.some(function(r){ return r.result === "failed"; })) return glyphClass("[\u2717]");
4160
+ if(rows.some(function(r){ return r.result === "none"; })) return glyphClass("[\u00B7]");
4161
+ return glyphClass("[\u2713]");
4162
+ }
4163
+ // borrowed-from: bareloop src/panel/index.html@v0.56.0 (3383cce) :1358 (auditCaret)
4164
+ function auditCaret(open){ return '<span class="audit-caret">' + (open ? "\u25BC" : "\u25B6") + '</span>'; }
4165
+ function auditChecksEl(ac){
4166
+ var all = (ac.checks || []).concat(ac.always || []);
4167
+ var nPass = all.filter(function(r){ return r.result === "passed"; }).length;
4168
+ var nFail = all.filter(function(r){ return r.result === "failed"; }).length;
4169
+ var head = "checks \u00B7 " + nPass + " passed" + (nFail ? " \u00B7 " + nFail + " failed" : "") + ((ac.notChecked || []).length ? " \u00B7 " + ac.notChecked.length + " not checked" : "");
4170
+ var wrap = document.createElement("div");
4171
+ wrap.className = "audit-part";
4172
+ wrap.setAttribute("data-testid", "audit-checks-group");
4173
+ var btn = document.createElement("button");
4174
+ btn.type = "button";
4175
+ btn.className = "btn audit-part-toggle";
4176
+ btn.setAttribute("aria-expanded", "false");
4177
+ btn.setAttribute("data-testid", "audit-checks-toggle");
4178
+ // P4c: bareloop's header: the caret span, the state sign, the words (re-drawn on each toggle)
4179
+ var headHtml = function(open){ return auditCaret(open) + stateDotHTML(auditChecksSignClass(all), "", "audit-checks-state") + escapeXml(head); };
4180
+ btn.innerHTML = headHtml(false);
4181
+ var body = document.createElement("div");
4182
+ body.className = "audit-part-body";
4183
+ body.hidden = true;
4184
+ body.setAttribute("data-testid", "audit-checks-body");
4185
+ var sec = function(title, rows, tid){
4186
+ if(!rows || !rows.length) return "";
4187
+ return '<div data-testid="' + tid + '" style="margin:6px 0"><div><b>' + escapeXml(title) + "</b></div>" + rows.map(auditCheckRowHtml).join("") + "</div>";
4188
+ };
4189
+ var readSec = function(notes){
4190
+ if(!notes || !notes.length) return "";
4191
+ 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>";
4192
+ };
4193
+ 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>";
4194
+ function paint(open){ body.hidden = !open; btn.setAttribute("aria-expanded", open ? "true" : "false"); btn.innerHTML = headHtml(open); }
4195
+ btn.addEventListener("click", function(){ var open = body.hidden; auditExpanded["\u0000checks"] = open; paint(open); });
4196
+ if(auditExpanded["\u0000checks"] === true) paint(true);
4197
+ wrap.appendChild(btn); wrap.appendChild(body);
4198
+ return wrap;
4199
+ }
4083
4200
  function renderAuditGroups(result){
4084
4201
  var runKey = currentFlow + "/" + currentRunId;
4085
4202
  if(auditExpandedRun !== runKey){ auditExpanded = {}; auditExpandedRun = runKey; }
@@ -4129,6 +4246,9 @@
4129
4246
  container.appendChild(nrow);
4130
4247
  anyVisible = true;
4131
4248
  }
4249
+ // hamr ruling A (2026-11-13): the card's own sections, one of the Audit's groups, after the schedule and the Needs-you line and before the step groups (bareloop v0.56.0 renderAuditGroups order)
4250
+ var ac = result.auditChecks;
4251
+ if(ac && ((ac.checks || []).length || (ac.notChecked || []).length || (ac.always || []).length)) container.appendChild(auditChecksEl(ac));
4132
4252
  var groups = (draftG ? [draftG] : []).concat(result.empty ? [] : (result.groups || []));
4133
4253
  groups.forEach(function(g){
4134
4254
  var rows = (g.rows || []).filter(auditRowMatchesFilter);
@@ -4329,11 +4449,15 @@
4329
4449
  fold.appendChild(textDiv("plan-row", "reads: " + ((st.reads || []).length ? st.reads.join(", ") : "nothing")));
4330
4450
  fold.appendChild(textDiv("plan-row", "makes: " + (st.makes || "unknown")));
4331
4451
  fold.appendChild(textDiv("plan-row", "may do: " + ((st.mayDo || []).length ? st.mayDo.join(", ") : "nothing (pure stop)")));
4332
- // M10 am11: each check sentence is its own row
4333
- if(st.ask || !(st.check || []).length) fold.appendChild(textDiv("plan-row", "check: " + (st.ask ? "ASK · waits " + plainWait(st.waitMs) : "")));
4334
- else st.check.forEach(function(s){ fold.appendChild(textDiv("plan-row", "check: " + s)); });
4335
- // M10b am2: a step that reads a sheet shows its line's block under the check sentence
4336
- sheetBlockLines(st.sheet).forEach(function(t){ fold.appendChild(textDiv("plan-row", t)); });
4452
+ if(st.ask) fold.appendChild(textDiv("plan-row", "check: ASK · waits " + plainWait(st.waitMs)));
4453
+ // P4c: a plan with a list shows the lead sentence and the sheet block under its job line, not in the fold
4454
+ else if(!(job.plan && job.plan.always)){
4455
+ // M10 am11: each check sentence is its own row
4456
+ if(!(st.check || []).length) fold.appendChild(textDiv("plan-row", "check: "));
4457
+ else st.check.forEach(function(s){ fold.appendChild(textDiv("plan-row", "check: " + s)); });
4458
+ // M10b am2: a step that reads a sheet shows its line's block under the check sentence
4459
+ sheetBlockLines(st.sheet).forEach(function(t){ fold.appendChild(textDiv("plan-row", t)); });
4460
+ }
4337
4461
  return fold;
4338
4462
  }
4339
4463
  // The tail: any step that came from no listed line, then the folded Not-checked summary (its label comes from the payload, src/checked.js; always shown).
@@ -4344,6 +4468,15 @@
4344
4468
  tail.innerHTML = "";
4345
4469
  (plan.steps || []).filter(function(st){ return !placed[st.step]; }).forEach(function(st){ tail.appendChild(jobStepFold(st, job)); });
4346
4470
  var nc = plan.notChecked || {};
4471
+ // M16 P4c: a plan with a list draws bareloop's three folds (Not checked, How the page was read, Always checked), each line tagged
4472
+ if(plan.always && nc.recorded){
4473
+ var jpFolds = document.createElement("div");
4474
+ jpFolds.className = "jp";
4475
+ var ncBy = nc.by || {};
4476
+ 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"; });
4477
+ tail.appendChild(jpFolds);
4478
+ return;
4479
+ }
4347
4480
  var fold = document.createElement("details");
4348
4481
  fold.className = "plan-fold plan-notchecked";
4349
4482
  var sum = document.createElement("summary");
@@ -4400,6 +4533,14 @@
4400
4533
  (job.sends || []).filter(function(sd){ return sd.line === l.line; }).forEach(function(sd){
4401
4534
  cell.appendChild(textDiv("ro-value sub", "~ writes out to " + (sd.target || "unknown")));
4402
4535
  });
4536
+ // 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
4537
+ // the line's lead sentence and a sheet block draw as plain grey lines first (hamr 2026-11-14), then the rows
4538
+ var listRowsHtml = "";
4539
+ ((job.plan && job.plan.steps) || []).filter(function(st){ return st.line === l.line; }).forEach(function(st){
4540
+ 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>"; });
4541
+ (st.listRows || []).forEach(function(r){ listRowsHtml += planCheckRowHtml(r.text, "", r.by, ""); });
4542
+ });
4543
+ if(listRowsHtml){ var jpRows = document.createElement("div"); jpRows.className = "jp"; jpRows.innerHTML = listRowsHtml; cell.appendChild(jpRows); }
4403
4544
  ((job.plan && job.plan.steps) || []).filter(function(st){ return st.line === l.line; }).forEach(function(st){
4404
4545
  placed[st.step] = true;
4405
4546
  cell.appendChild(jobStepFold(st, job));
@@ -5802,6 +5943,22 @@
5802
5943
  question: q.question, agree: false, drop: false
5803
5944
  };
5804
5945
  }
5946
+ // 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
5947
+ function planOfState(state, list){
5948
+ var nc = state.notChecked || {};
5949
+ var plan = {lines: [], suggested: list.suggested || [], notChecked: nc.items || [], notCheckedBy: nc.by && typeof nc.by === "object" ? nc.by : {}, readNotes: nc.readNotes || [], alwaysOn: state.always || []};
5950
+ (state.planLines || []).forEach(function(pl){
5951
+ var l = {n: pl.n, text: pl.text, rules: pl.rules || [], leads: [], checks: [], extra: []};
5952
+ state.checked.forEach(function(c){
5953
+ if(c.line !== pl.n) return;
5954
+ if(c.sentences.length) l.leads.push(c.sentences[0]);
5955
+ sheetBlockLines(c.sheet, true).forEach(function(t){ l.extra.push(t); });
5956
+ });
5957
+ 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}); });
5958
+ plan.lines.push(l);
5959
+ });
5960
+ return plan;
5961
+ }
5805
5962
  // pure: what sits beside a green plan: Your answers (only when the plan was drafted with some), Checked (the machine's sentences from the
5806
5963
  // typed checks) and Not checked (the drafter's own list, ALWAYS with its label), or null when there is no plan to show
5807
5964
  function extrasFor(state){
@@ -5812,6 +5969,12 @@
5812
5969
  return "line " + a.line + (a.lineText ? ": " + a.lineText : "") + "\n > " + a.answer;
5813
5970
  })});
5814
5971
  }
5972
+ // M16 P4c: a plan with a list draws bareloop's plan view (lines, checks with their tags, Suggested, the folds) in one bubble, from the card the draft saved (server: state.list, planLines, always)
5973
+ var list = state.list && Array.isArray(state.list.rows) ? state.list : null;
5974
+ if(list){
5975
+ blocks.push({id: "chat-plan", plan: planOfState(state, list)});
5976
+ return {blocks: blocks};
5977
+ }
5815
5978
  // M10 am11: each check sentence is its own line (the step's label leads its first; the rest sit under it)
5816
5979
  var checkedLines = [];
5817
5980
  state.checked.forEach(function(c){
@@ -5819,11 +5982,12 @@
5819
5982
  checkedLines.push(i === 0 ? (c.line !== null && c.line !== undefined ? "line " + c.line : "step " + c.step) + ": " + s : " " + s);
5820
5983
  });
5821
5984
  // M10b am2: a line that reads a sheet: its guardrails, Checked (name, words, covers), Not checked
5822
- sheetBlockLines(c.sheet).forEach(function(t){ checkedLines.push(" " + t); });
5985
+ sheetBlockLines(c.sheet, false).forEach(function(t){ checkedLines.push(" " + t); });
5823
5986
  });
5824
5987
  blocks.push({id: "chat-checked", head: "Checked", sub: "built by the machine from the plan's checks", lines: checkedLines});
5825
5988
  var nc = state.notChecked || {};
5826
- blocks.push({id: "chat-notchecked", head: nc.label || "", sub: "", lines: (nc.items && nc.items.length) ? nc.items.map(function(x){ return "- " + x; }) : ["The drafter listed nothing."]});
5989
+ var ncBy = nc.by && typeof nc.by === "object" ? nc.by : {};
5990
+ blocks.push({id: "chat-notchecked", head: nc.label || "", sub: "", lines: (nc.items && nc.items.length) ? nc.items.map(function(x){ return ncBy[x] ? {text: "- " + x, by: ncBy[x], op: "", key: ""} : "- " + x; }) : ["The drafter listed nothing."]});
5827
5991
  // M10 am11: code's notes about written forms it did not use are their own list, after Not checked (none = no block)
5828
5992
  if(nc.readNotes && nc.readNotes.length) blocks.push({id: "chat-readnotes", head: "How the page was read", sub: "", lines: nc.readNotes.map(function(x){ return "- " + x; })});
5829
5993
  return {blocks: blocks};
@@ -6665,13 +6829,23 @@
6665
6829
  qAnswer.value = ""; qError.textContent = "";
6666
6830
  }
6667
6831
  }
6832
+ // one line of a block: plain text, or a row with its tag
6833
+ function extraLineHTML(l){
6834
+ if(typeof l === "string") return escapeXml(l);
6835
+ return escapeXml(l.text) + byTagOf(l.by);
6836
+ }
6837
+ // the Drop / Add button of the plan view (bareloop's control; the click is handled once on the extras box)
6838
+ function planControlHTML(op, key){
6839
+ return ' <button type="button" class="btn jp-btn" data-testid="plan-' + op + '" data-rowop="' + op + '" data-rowkey="' + escapeXml(key) + '">' + (op === "add" ? "Add" : "Drop") + "</button>";
6840
+ }
6668
6841
  // Your answers / Checked / Not checked; a plan being drafted again leaves them on show (like the plan), anything else without a green plan clears them
6669
6842
  function renderExtras(state){
6670
6843
  if(state && (state.phase === "revising" || state.phase === "redrafting")) return;
6671
6844
  var v = extrasFor(state);
6672
6845
  var html = v ? v.blocks.map(function(b){
6673
- return '<div class="msg" id="' + b.id + '" data-testid="' + b.id + '"><b class="readout-head">' + escapeXml(b.head) + '</b>' +
6674
- (b.sub ? ' <span class="hint">(' + escapeXml(b.sub) + ')</span>' : '') + (b.lines.length ? '\n' + b.lines.map(escapeXml).join("\n") : '') + '</div>';
6846
+ var inner = b.plan ? '<div class="who">fwdloop</div>' + planViewHtml(b.plan, planControlHTML)
6847
+ : '<b class="readout-head">' + escapeXml(b.head) + '</b>' + (b.sub ? ' <span class="hint">(' + escapeXml(b.sub) + ')</span>' : '') + (b.lines.length ? '\n' + b.lines.map(extraLineHTML).join("\n") : '');
6848
+ return '<div class="msg' + (b.plan ? ' bot' : '') + '" id="' + b.id + '" data-testid="' + b.id + '">' + inner + '</div>';
6675
6849
  }).join("") : "";
6676
6850
  if(html !== extrasKey){ extrasKey = html; extrasEl.innerHTML = html; }
6677
6851
  }
@@ -6858,6 +7032,27 @@
6858
7032
 
6859
7033
  // Send (amendments 24/25): the answer to the question now open. A blank answer is refused by the server in plain words and the question stays open.
6860
7034
  // M10 am29: a choice button posts its own choice and nothing else; the box's button posts the box's words as a new rule (choice "rule"), never read as agree or drop it
7035
+ // Drop / Add (M16 item 5): $0, no AI call. The server writes a new plan; a sign click on the old one is cleared (its hash is not the plan's now)
7036
+ var rowBusy = false;
7037
+ function doRowEdit(btn){
7038
+ if(rowBusy || !sessionId || !lastState || lastState.phase !== "green") return;
7039
+ rowBusy = true;
7040
+ var id = sessionId;
7041
+ var all = extrasEl.querySelectorAll("button[data-rowop]");
7042
+ for(var i = 0; i < all.length; i++) all[i].disabled = true;
7043
+ authorPost("/api/author/" + id + "/row-edit", {op: btn.getAttribute("data-rowop"), key: btn.getAttribute("data-rowkey")}).then(function(r){
7044
+ rowBusy = false;
7045
+ if(id !== sessionId) return;
7046
+ if(!(r.status >= 200 && r.status < 300 && r.body && r.body.ok === true)){ chatActionFailed(refusalText(r)); for(var j = 0; j < all.length; j++) all[j].disabled = false; return; }
7047
+ chatActionOk();
7048
+ signInfo = null; signClickedOnce = false;
7049
+ poll();
7050
+ }).catch(function(){ rowBusy = false; for(var j = 0; j < all.length; j++) all[j].disabled = false; chatActionFailed(NETWORK_SAY); });
7051
+ }
7052
+ extrasEl.addEventListener("click", function(ev){
7053
+ var t = ev.target && ev.target.closest ? ev.target.closest("button[data-rowop]") : null;
7054
+ if(t && extrasEl.contains(t)) doRowEdit(t);
7055
+ });
6861
7056
  function doAnswer(choice){
6862
7057
  if(qBusy || !sessionId || !lastState || lastState.phase !== "questions-open") return;
6863
7058
  qBusy = true; qSend.disabled = true; qAgree.disabled = true; qDrop.disabled = true; qError.textContent = "";
@@ -14,7 +14,7 @@ import { basename, join } from 'node:path';
14
14
  import { readFileInside } from '../flow.js';
15
15
  import { isCellsPath } from '../closers.js';
16
16
  import { readAcceptedHashesByEmits } from '../ask.js';
17
- import { NOT_CHECKED_LABEL } from '../checked.js';
17
+ import { notCheckedLabelOf } from '../checked.js';
18
18
  import { checkSendDestination, readArtifactResult } from '../runner.js';
19
19
  import { flowTypeOf } from '../declaration.js';
20
20
  import { isAgree, readingOfQuestion } from '../pageask.js';
@@ -23,6 +23,7 @@ import { readLineSection, LINE_CHECKS_FILE } from '../line-checks.js';
23
23
  import { readChecks } from '../diary.js';
24
24
  import { sheetLineBlocks, csvRolesOf } from '../sheetblock.js';
25
25
  import { readSheetChecks } from '../sheet-record.js';
26
+ import { tagged } from '../checkwords.js';
26
27
 
27
28
  /** the two sentences for a saved file that is no longer what the run wrote (code-owned, one spelling) */
28
29
  export const RESULT_FILE_GONE = 'the saved file is gone';
@@ -218,7 +219,7 @@ function checksOfLine(stepsOfLine, diary) {
218
219
  for (const st of stepsOfLine) {
219
220
  const rows = diary.filter((r) => r && r.step === st.emits && isInt(r.try) && Array.isArray(r.checks));
220
221
  const newest = rows.reduce((m, r) => (m === null || r.try >= m.try ? r : m), null);
221
- for (const c of newest ? newest.checks : []) if (c && isStr(c.text) && typeof c.ok === 'boolean') out.push({ ok: c.ok, text: c.text, result: isStr(c.result) ? c.result : null });
222
+ for (const c of newest ? newest.checks : []) if (c && isStr(c.text) && typeof c.ok === 'boolean') out.push({ ok: c.ok, text: c.by === 'you' || c.by === 'agent' || c.by === 'default' ? tagged(c.text, c.by) : c.text, result: isStr(c.result) ? c.result : null }); // hamr 2026-11-14: a check the plan's list built carries the tag of its row
222
223
  }
223
224
  return out;
224
225
  }
@@ -293,7 +294,7 @@ export function buildResult({
293
294
  }
294
295
  const pages = [...new Set(urls.values())];
295
296
  return {
296
- flow, runId, lines, pages, pageNote: pages.length ? RESULT_PAGE_MAY_CHANGE : null, notCheckedLabel: NOT_CHECKED_LABEL.charAt(0).toUpperCase() + NOT_CHECKED_LABEL.slice(1), notChecked, readNotes, delivered, gap,
297
+ flow, runId, lines, pages, pageNote: pages.length ? RESULT_PAGE_MAY_CHANGE : null, notCheckedLabel: ((l) => l.charAt(0).toUpperCase() + l.slice(1))(notCheckedLabelOf(declaration)), notChecked, readNotes, delivered, gap,
297
298
  door: door === null ? null : { head: RESULT_DOOR_HEAD, ask: RESULT_DOOR_ASK, askId: door.askId, draftNo: door.draftNo },
298
299
  };
299
300
  }
@@ -343,7 +343,7 @@ function resumeRoute(res, body, root, resumer) {
343
343
  }
344
344
 
345
345
  /**
346
- * `POST /api/author/{draft,run,trigger-prepare,trigger,resume-prepare,resume,<id>/sign-prepare,<id>/sign,<id>/revise,<id>/answer,<id>/abandon,start/<id>/clear}` — run after the same gates as every other POST.
346
+ * `POST /api/author/{draft,run,trigger-prepare,trigger,resume-prepare,resume,<id>/sign-prepare,<id>/sign,<id>/revise,<id>/answer,<id>/row-edit,<id>/abandon,start/<id>/clear}` — run after the same gates as every other POST.
347
347
  * Anything else under `/api/author/` is a 404 by name.
348
348
  * @param {any} res @param {string} url @param {any} body @param {ReturnType<typeof createAuthor>} author
349
349
  */
@@ -363,6 +363,8 @@ function authorPost(res, url, body, author) {
363
363
  if (sg) { send(author.sign(sg[1], body)); return; }
364
364
  const rv = /^\/api\/author\/([^/]+)\/revise$/.exec(url);
365
365
  if (rv) { send(author.revise(rv[1], body)); return; }
366
+ const re = /^\/api\/author\/([^/]+)\/row-edit$/.exec(url);
367
+ if (re) { send(author.rowEdit(re[1], body)); return; }
366
368
  const an = /^\/api\/author\/([^/]+)\/answer$/.exec(url);
367
369
  if (an) { send(author.answer(an[1], body)); return; }
368
370
  const sc = /^\/api\/author\/start\/([^/]+)\/clear$/.exec(url);
package/src/pickrecord.js CHANGED
@@ -1,3 +1,4 @@
1
+ // borrowed-from: bareloop src/pickrecord.js@v0.57.0 (c18df406)
1
2
  // M10 am17 + am18: the ONE record of check picks, carried from plan to plan. A pick is tied to its job line's WORDS (plus its order among lines with the same words)
2
3
  // and to its guardrail's exact words, never to a line or rule number: both are recomputed on the new card. This file is the only writer of a record's entries
3
4
  // (`entriesFromAnswers`) and the only reader that decides keep-or-ask (`matchRecord`); the logic is the one F146 / F146b proved (poc/m10-am17/keep-picks-am18.mjs).
@@ -10,7 +11,7 @@ export const RECORD_FILE = 'picks-record.json';
10
11
  /** the exact words a kept pick is marked with in the draft log, the Audit and the plan card (M10 am17 (6)) */
11
12
  export const KEPT_WORDS = 'kept from last draft';
12
13
 
13
- /** @typedef {{lineWords: string, occurrence: number, ruleText: string, added: string|null, check: Record<string, any>|null, own: boolean, left: boolean}} Entry */
14
+ /** @typedef {{lineWords: string, occurrence: number, ruleText: string, added?: string|null, check: Record<string, any>|null, own: boolean, left: boolean}} Entry */
14
15
  /** @typedef {{line: number, rule: number, text: string}} Rule */
15
16
 
16
17
  const norm = (/** @type {unknown} */ t) => String(t).toLowerCase().replace(/\s+/g, ' ').trim();
@@ -34,9 +35,9 @@ export function lineKeys(lines) {
34
35
  }
35
36
 
36
37
  /**
37
- * The entries for answers just given, numbered on THIS card (the answer redraft's card: its line and rule numbers are the ones the asks carried).
38
+ * The entries for answers just given, numbered on THIS card (the answer redraft's card: its line and rule numbers are the ones the asks carried; the rule's text is the FINAL rule's words).
38
39
  * @param {{n: number, text: string}[]} lines @param {Rule[]} rules
39
- * @param {{line: number, rule: number, check?: Record<string, any>|null, added?: string|null, own?: boolean}[]} picks @param {{line: number, rule: number}[]} left
40
+ * @param {{line: number, rule: number, check?: Record<string, any>|null, own?: boolean}[]} picks @param {{line: number, rule: number}[]} left
40
41
  * @returns {Entry[]}
41
42
  */
42
43
  export function entriesFromAnswers(lines, rules, picks, left) {
@@ -51,82 +52,43 @@ export function entriesFromAnswers(lines, rules, picks, left) {
51
52
  const out = [];
52
53
  for (const p of picks) {
53
54
  const b = base(p.line, p.rule);
54
- if (b) out.push({ ...b, added: typeof p.added === 'string' ? p.added : null, check: p.check ?? null, own: p.own === true, left: false });
55
+ if (b) out.push({ ...b, check: p.check ?? null, own: p.own === true, left: false });
55
56
  }
56
57
  for (const l of left) {
57
58
  const b = base(l.line, l.rule);
58
- if (b) out.push({ ...b, added: null, check: null, own: false, left: true });
59
+ if (b) out.push({ ...b, check: null, own: false, left: true });
59
60
  }
60
61
  return out;
61
62
  }
62
63
 
63
64
  /**
64
65
  * Decide, for the card in hand, which stored picks are kept and which guardrails must be asked.
65
- * A pick is KEPT when the job line with its words (same order among equal lines) still has its source guardrail with the exact words and, if the pick wrote a `~` line,
66
- * that line with its exact words too. Otherwise the pick is dropped (never partly kept) and its guardrails are asked: a pair broken on one side is ONE ask, so the
67
- * partner left on the card is folded (neither asked nor given the old check) - except an EDITED added line (M10 am21): that one is asked (`pairRule` = its source's number) and the source is folded. Pure.
66
+ * A pick is KEPT when the job line with its words (same order among equal lines) still has a guardrail with the pick's exact words. One rule in, one rule out (hamr 2026-11-14): an answer REPLACED the
67
+ * rule it was asked about, so the stored words are the final rule's words and there is no second line to pair; a rule whose words changed is simply new and asked. Pure.
68
68
  * @param {Entry[]} entries @param {{n: number, text: string}[]} lines @param {Rule[]} rules every guardrail the call settles
69
- * @returns {{picks: {line: number, rule: number, check: Record<string, any>|null, added?: string, own?: boolean}[], left: {line: number, rule: number}[],
70
- * kept: {line: number, rule: number, entry: Entry}[], askRules: (Rule & {pairRule?: number})[]}}
69
+ * @returns {{picks: {line: number, rule: number, check: Record<string, any>|null, own?: boolean}[], left: {line: number, rule: number}[],
70
+ * kept: {line: number, rule: number, entry: Entry}[], askRules: Rule[]}}
71
71
  */
72
72
  export function matchRecord(entries, lines, rules) {
73
73
  const byKey = new Map([...lineKeys(lines)].map(([n, k]) => [`${k.lineWords}#${k.occurrence}`, n]));
74
74
  /** @type {Set<string>} */
75
75
  const claimed = new Set();
76
- /** @type {Set<string>} */
77
- const folded = new Set();
78
- /** @type {Map<string, number>} an edited added line (by id) -> the rule number of the source it was paired with (M10 am21) */
79
- const edited = new Map();
80
- const free = (/** @type {number} */ n, /** @type {string} */ text) => rules.find((r) => r.line === n && !claimed.has(id(r)) && !folded.has(id(r)) && norm(r.text) === norm(text));
81
76
  const kept = [];
82
- /** @type {{e: Entry, n: number|undefined}[]} */
83
- const broken = [];
84
77
  for (const e of Array.isArray(entries) ? entries : []) {
85
78
  const n = byKey.get(`${e.lineWords}#${e.occurrence}`);
86
- const src = n === undefined ? undefined : free(n, e.ruleText);
87
- if (src) claimed.add(id(src)); // held while the partner is looked for, so a pair never takes one rule twice
88
- const add = n === undefined || !src || e.added === null ? undefined : free(n, e.added);
89
- if (n !== undefined && src && (e.added === null || add)) {
90
- if (add) claimed.add(id(add));
91
- kept.push({ line: n, rule: src.rule, entry: e });
92
- } else {
93
- if (src) claimed.delete(id(src));
94
- broken.push({ e, n });
95
- }
96
- }
97
- // a pair broken on one side is ONE pick, so ONE ask: the partner that is left folds into it (it keeps no old check and is not asked on its own)
98
- for (const { e, n } of broken) {
99
- if (e.added === null) continue;
100
- if (n === undefined) {
101
- // the line's own words changed: it is a new line, all its guardrails are asked; its old `~` line with its source still there rides the source's ask
102
- for (const l of lines) {
103
- const s = free(l.n, e.ruleText);
104
- const a = s ? rules.find((r) => r.line === l.n && r !== s && !claimed.has(id(r)) && !folded.has(id(r)) && norm(r.text) === norm(e.added ?? '')) : undefined;
105
- if (a) { folded.add(id(a)); break; }
106
- }
107
- continue;
108
- }
109
- const src = free(n, e.ruleText);
110
- const add = free(n, e.added);
111
- if (src && !add) {
112
- // the added line was edited (or deleted): the unclaimed rule right after the source on that line is it. M10 am21: the ONE ask is about THAT line's words
113
- // (it carries the source's number as `pairRule`, the rule its pick is kept under); the source rides it and is not asked on its own
114
- const p = rules.find((r) => r.line === n && r.rule > src.rule && !claimed.has(id(r)) && !folded.has(id(r)));
115
- if (p) { folded.add(id(src)); edited.set(id(p), src.rule); }
116
- } else if (add && !src) {
117
- // the source was edited: the unclaimed rule right before the added line is it; the old added line rides that ask
118
- const p = [...rules].reverse().find((r) => r.line === n && r.rule < add.rule && !claimed.has(id(r)) && !folded.has(id(r)));
119
- if (p) folded.add(id(add));
120
- }
79
+ const src = n === undefined ? undefined : rules.find((r) => r.line === n && !claimed.has(id(r)) && norm(r.text) === norm(e.ruleText));
80
+ if (!src) continue;
81
+ claimed.add(id(src));
82
+ kept.push({ line: /** @type {number} */ (n), rule: src.rule, entry: e });
121
83
  }
122
84
  const picks = [];
123
85
  const left = [];
124
86
  for (const k of kept) {
125
87
  const e = k.entry;
126
88
  if (e.left) left.push({ line: k.line, rule: k.rule });
127
- else picks.push({ line: k.line, rule: k.rule, check: e.check, ...(e.added === null ? {} : { added: e.added }), ...(e.own ? { own: true } : {}) });
89
+ else picks.push({ line: k.line, rule: k.rule, check: e.check, ...(e.own ? { own: true } : {}) });
128
90
  }
129
- return { picks, left, kept, askRules: rules.filter((r) => !claimed.has(id(r)) && !folded.has(id(r))).map((r) => (edited.has(id(r)) ? { ...r, pairRule: edited.get(id(r)) } : r)) };
91
+ return { picks, left, kept, askRules: rules.filter((r) => !claimed.has(id(r))) };
130
92
  }
131
93
 
132
94
  /**
@@ -142,5 +104,59 @@ export function readRecordFile(file) {
142
104
  } catch { return null; }
143
105
  }
144
106
 
107
+ // borrowed-from: bareloop src/pickrecord.js@v0.56.0 (3383cce) (readRowChoices; read through readFileInside; writeRecordPart not taken, see the M16 p1 report)
108
+ /**
109
+ * The Drop/Add choices a draft's person made on the confirm card (hamr 2026-11-13, N-2), carried the same way as the picks: tied to the line's words and the row's own name, never to a number.
110
+ * @param {string} file @returns {{lineWords: string, occurrence: number, tail: string, choice: string}[]|null}
111
+ */
112
+ export function readRowChoices(file) {
113
+ try {
114
+ const g = readFileInside(path.dirname(file), path.basename(file));
115
+ if (!g.ok) return null;
116
+ const j = JSON.parse(g.text);
117
+ return Array.isArray(j?.rowChoices) ? j.rowChoices.filter((/** @type {any} */ e) => e && typeof e.lineWords === 'string' && Number.isInteger(e.occurrence) && typeof e.tail === 'string' && (e.choice === 'drop' || e.choice === 'add')) : null;
118
+ } catch { return null; }
119
+ }
120
+
121
+ /**
122
+ * 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
+ * the next draft drops a new check with the same id again. Read through readFileInside; a missing or unreadable record is no record.
124
+ * @param {string} file @returns {{key: string, line: number, index: number, check: Record<string, any>, text: string}[]|null}
125
+ */
126
+ export function readSheetDropped(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?.sheetDropped) ? j.sheetDropped.filter((/** @type {any} */ d) => d && typeof d.key === 'string' && Number.isInteger(d.line) && d.check && typeof d.check === 'object' && !Array.isArray(d.check)) : null;
132
+ } catch { return null; }
133
+ }
134
+
135
+ /**
136
+ * M17 ruling 2: the columns a person agreed for a word of the job's prose (or a word that is not in the rule it was asked about), kept in the same record as the picks and carried like them:
137
+ * tied to the job line's WORDS (and its order among equal lines), never to a number. `columns` entries are `{lineWords, occurrence, word, column}`.
138
+ * @param {string} file @returns {{lineWords: string, occurrence: number, word: string, column: string}[]|null}
139
+ */
140
+ export function readColumns(file) {
141
+ try {
142
+ const g = readFileInside(path.dirname(file), path.basename(file));
143
+ if (!g.ok) return null;
144
+ const j = JSON.parse(g.text);
145
+ return Array.isArray(j?.columns) ? j.columns.filter((/** @type {any} */ e) => e && typeof e.lineWords === 'string' && Number.isInteger(e.occurrence) && typeof e.word === 'string' && typeof e.column === 'string') : null;
146
+ } catch { return null; }
147
+ }
148
+
149
+ /** @param {{n: number, text: string}[]} lines @param {{line: number, word: string, column: string}[]} cols @returns {{lineWords: string, occurrence: number, word: string, column: string}[]} the answers as the record keeps them */
150
+ export function columnEntries(lines, cols) {
151
+ const keys = lineKeys(lines);
152
+ return cols.flatMap((c) => { const k = keys.get(c.line); return k === undefined ? [] : [{ ...k, word: c.word, column: c.column }]; });
153
+ }
154
+
155
+ /** @param {{lineWords: string, occurrence: number, word: string, column: string}[]} entries @param {{n: number, text: string}[]} lines @returns {{line: number, word: string, column: string}[]} the record's answers whose job line is still on the card (same words, same order) */
156
+ export function columnsOnLines(entries, lines) {
157
+ const byKey = new Map([...lineKeys(lines)].map(([n, k]) => [`${k.lineWords}#${k.occurrence}`, n]));
158
+ return entries.flatMap((e) => { const n = byKey.get(`${e.lineWords}#${e.occurrence}`); return n === undefined ? [] : [{ line: n, word: e.word, column: e.column }]; });
159
+ }
160
+
145
161
  /** where a plan folder keeps its record @param {string} planDir */
146
162
  export const recordPath = (planDir) => path.join(planDir, RECORD_FILE);