bareloop 0.55.0 → 0.56.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.
- package/CHANGELOG.md +47 -0
- package/bareloop.context.md +4 -2
- package/package.json +2 -2
- package/src/authorflow.js +141 -264
- package/src/authoring.js +2 -3
- package/src/authorjob.js +117 -88
- package/src/authorreadout.js +9 -15
- package/src/authorrun.js +13 -4
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/checkblock.js +772 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +30 -312
- package/src/checkwords.js +3 -1
- package/src/declaredclose.js +30 -1
- package/src/destpoint.js +3 -1
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- package/src/fitcheck.js +5 -3
- package/src/pagemap.js +15 -3
- package/src/panel/authorroutes.js +15 -3
- package/src/panel/authorsession.js +133 -46
- package/src/panel/index.html +194 -22
- package/src/panel/jobplan.js +85 -33
- package/src/panel/server.js +52 -7
- package/src/pickrecord.js +19 -1
- package/src/placerule.js +355 -0
- package/src/promptregisters.js +11 -0
- package/src/questionbox.js +112 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +212 -125
- package/src/run.js +10 -2
- package/src/userrun.js +46 -1
- package/types/authorflow.d.ts +32 -139
- package/types/authorjob.d.ts +24 -6
- package/types/authorreadout.d.ts +4 -10
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +37 -0
- package/types/checkblock.d.ts +361 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +3 -140
- package/types/declaredclose.d.ts +4 -0
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- package/types/fitcheck.d.ts +7 -1
- package/types/pagemap.d.ts +4 -0
- package/types/panel/authorsession.d.ts +13 -2
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +14 -13
- package/types/pickrecord.d.ts +12 -0
- package/types/placerule.d.ts +194 -0
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +91 -48
- package/types/run.d.ts +10 -1
package/src/panel/index.html
CHANGED
|
@@ -648,6 +648,17 @@
|
|
|
648
648
|
.msg.system{color:var(--text-faint);border-left:3px dotted var(--text-faint);font-size:12px;}
|
|
649
649
|
.msg .who{font-size:11px;color:var(--text-faint);margin-bottom:3px;text-transform:none;font-weight:400;}
|
|
650
650
|
.chat-input-row{margin-top:10px;border-top:1px dotted var(--border-strong);padding-top:10px;}
|
|
651
|
+
/* hamr 2026-11-12 (as fwdloop M10 am29): a question the drafting raised gets its own box; it takes the chat input's place while it is open */
|
|
652
|
+
.chat-question{border:1px solid var(--border);border-left:3px solid var(--amber);background:var(--panel2);padding:8px 10px;margin-top:10px;max-width:100%;box-sizing:border-box;}
|
|
653
|
+
.chat-question .q-head{font-size:11px;color:var(--text-faint);}
|
|
654
|
+
.chat-question .q-line{font-size:12px;color:var(--text-faint);margin-top:4px;overflow-wrap:anywhere;}
|
|
655
|
+
.chat-question .q-text{font-size:13px;margin-top:4px;overflow-wrap:anywhere;white-space:pre-wrap;}
|
|
656
|
+
.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;}
|
|
657
|
+
.chat-question .q-choices{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;}
|
|
658
|
+
.chat-question .q-choices .btn{flex:1 1 auto;min-width:0;white-space:normal;overflow-wrap:anywhere;height:auto;min-height:44px;}
|
|
659
|
+
.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;}
|
|
660
|
+
.chat-question .q-or + textarea{margin-top:4px;}
|
|
661
|
+
.chat-question .q-err{color:var(--red);}
|
|
651
662
|
.chat-input-row input{width:100%;box-sizing:border-box;}
|
|
652
663
|
/* the ask box wraps long text (textarea, hamr 2026-10-05): grows a few rows (fitBox), then scrolls inside; Enter sends, Shift+Enter is a newline */
|
|
653
664
|
textarea[data-testid="chat-msg"]{width:100%;box-sizing:border-box;font:inherit;color:var(--text);resize:vertical;overflow-y:auto;max-height:200px;}
|
|
@@ -677,9 +688,13 @@
|
|
|
677
688
|
.jp .sub{color:var(--text-dim);padding-left:30px;}
|
|
678
689
|
.jp .fold{padding-left:30px;color:var(--text);}
|
|
679
690
|
/* who added a check: the drafter's [agent] or the person's own [you picked] (fwdloop's `[added]` marker, in the dim of a ~ row) */
|
|
680
|
-
.jp .by,.draft-checks-row .by{color:var(--text-dim);white-space:nowrap;}
|
|
691
|
+
.jp .by,.draft-checks-row .by,.job-card .by{color:var(--text-dim);white-space:nowrap;}
|
|
692
|
+
/* the confirm card's Drop / Add: wraps with its row, a comfortable touch target, no horizontal scroll at phone width */
|
|
693
|
+
.jp .jp-btn{margin:2px 0 2px 8px;padding:4px 12px;min-height:32px;font-size:inherit;}
|
|
694
|
+
.jp .fold{overflow-wrap:anywhere;}
|
|
695
|
+
.jp-sug .lbl{display:block;margin-top:6px;font-weight:700;}
|
|
681
696
|
.jp details.fold{padding-left:0;margin:6px 0;}
|
|
682
|
-
.jp details>summary{cursor:pointer;list-style:none;}
|
|
697
|
+
.jp details>summary{cursor:pointer;list-style:none;font-weight:700;}
|
|
683
698
|
.jp details>summary::-webkit-details-marker{display:none;}
|
|
684
699
|
.jp details>summary::before{content:"\203A";color:var(--plan);font-weight:700;margin-right:6px;}
|
|
685
700
|
.jp details[open]>summary::before{content:"\2304";}
|
|
@@ -1027,6 +1042,21 @@
|
|
|
1027
1042
|
before a person reads it. -->
|
|
1028
1043
|
<div class="hint" id="chat-action-error" data-testid="chat-action-error"></div>
|
|
1029
1044
|
|
|
1045
|
+
<!-- hamr 2026-11-12 (as fwdloop M10 am29): a question the drafting raised, one at a time. No Skip. Static markup: the poll only rewrites the texts when the question changes, never the typed answer -->
|
|
1046
|
+
<div class="chat-question" id="chat-question" data-testid="chat-question" hidden>
|
|
1047
|
+
<div class="q-head" id="chat-q-head" data-testid="chat-q-head"></div>
|
|
1048
|
+
<div class="q-line" id="chat-q-line" data-testid="chat-q-line"></div>
|
|
1049
|
+
<div class="q-text" id="chat-q-text" data-testid="chat-q-text"></div>
|
|
1050
|
+
<div class="q-choices" id="chat-q-choices" data-testid="chat-q-choices" hidden>
|
|
1051
|
+
<button class="btn small" type="button" id="chat-q-c1" hidden></button>
|
|
1052
|
+
<button class="btn small" type="button" id="chat-q-c2" hidden></button>
|
|
1053
|
+
</div>
|
|
1054
|
+
<label class="q-or" id="chat-q-or" data-testid="chat-q-or" for="chat-q-answer">Type your answer:</label>
|
|
1055
|
+
<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>
|
|
1056
|
+
<div class="hint q-err" id="chat-q-error" data-testid="chat-q-error" role="alert"></div>
|
|
1057
|
+
<button class="btn primary wide" type="button" id="chat-q-send" data-testid="chat-q-send">Send</button>
|
|
1058
|
+
</div>
|
|
1059
|
+
|
|
1030
1060
|
<div class="chat-input-row">
|
|
1031
1061
|
<label for="chat-msg" style="display:none">Message</label>
|
|
1032
1062
|
<textarea id="chat-msg" rows="2" placeholder="Answer here when the draft asks you a question…" data-testid="chat-msg"></textarea>
|
|
@@ -3625,10 +3655,10 @@
|
|
|
3625
3655
|
var rows = "";
|
|
3626
3656
|
// fwd am14 item 6: a revise or a Start over says so, first, in the server's own words (`revise 1`, `revise 2`, `start over`); a first draft has no such row
|
|
3627
3657
|
if(part.draftLabel) rows += '<tr class="draft-kind-row" data-testid="drafting-kind"><td colspan="5"><b>' + escapeXml(part.draftLabel) + "</b></td></tr>";
|
|
3628
|
-
// the checks
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3658
|
+
// the checks themselves are the Audit's own "Checks" section now (`auditChecks`, one list with each row's result), not a second list here
|
|
3659
|
+
// F-b: a suggested check code could not build is told here in one plain sentence, never on the card
|
|
3660
|
+
(part.draftNotBuilt || []).forEach(function(c){
|
|
3661
|
+
rows += '<tr class="draft-checks-row" data-testid="drafting-notbuilt"><td colspan="5" style="overflow-wrap:anywhere">line ' + escapeXml(String(c.line)) + " \u00B7 " + escapeXml(c.text) + "</td></tr>";
|
|
3632
3662
|
});
|
|
3633
3663
|
(part.draftSteps || []).forEach(function(st){
|
|
3634
3664
|
var wall = st.wallMs === null || st.wallMs === undefined ? "–" : duration(st.wallMs);
|
|
@@ -3813,6 +3843,51 @@
|
|
|
3813
3843
|
}
|
|
3814
3844
|
});
|
|
3815
3845
|
}
|
|
3846
|
+
// one row of the Audit's check list: its words, its tag, its result in the one state sign+word markup (a row with no recorded verdict says so, never "passed")
|
|
3847
|
+
function auditCheckRowHtml(r){
|
|
3848
|
+
var res = r.result === "held" ? ["green", r.word || "held"] : r.result === "record-missing" ? ["grey", r.word || "the gate's record for this run is missing"] : r.result === "passed" ? ["green", "passed"] : r.result === "failed" ? ["red", "failed"] : r.result === "not-checked" ? ["grey", "not checked"] : ["grey", "no result recorded"];
|
|
3849
|
+
return '<div class="audit-check-row" data-testid="audit-check-row" data-result="' + escapeXml(r.result) + '" style="overflow-wrap:anywhere">' + escapeXml(r.text) + byTagOf(r.by) + " " + stateDotHTML(res[0], res[1], "audit-check-state") + "</div>";
|
|
3850
|
+
}
|
|
3851
|
+
// the Checks fold's one state sign (code-owned, one place): any row failed = [✗]; else any row with no recorded result / no gate record = [·]; else [✓] ("held" is passed, "not checked" rows never move it)
|
|
3852
|
+
function auditChecksSignClass(rows){
|
|
3853
|
+
if(rows.some(function(r){ return r.result === "failed"; })) return glyphClass("\u2717");
|
|
3854
|
+
if(rows.some(function(r){ return r.result === "none" || r.result === "record-missing"; })) return glyphClass("\u00B7");
|
|
3855
|
+
return glyphClass("\u2713");
|
|
3856
|
+
}
|
|
3857
|
+
function auditChecksEl(ac){
|
|
3858
|
+
var wrap = document.createElement("div");
|
|
3859
|
+
wrap.className = "audit-part";
|
|
3860
|
+
wrap.setAttribute("data-testid", "audit-checks-group");
|
|
3861
|
+
var all = (ac.checks || []).concat(ac.always || []);
|
|
3862
|
+
var nPass = all.filter(function(r){ return r.result === "passed" || r.result === "held"; }).length;
|
|
3863
|
+
var nFail = all.filter(function(r){ return r.result === "failed"; }).length;
|
|
3864
|
+
var head = "Checks · " + nPass + " passed" + (nFail ? " · " + nFail + " failed" : "") + ((ac.notChecked || []).length ? " · " + ac.notChecked.length + " not checked" : "");
|
|
3865
|
+
var btn = document.createElement("button");
|
|
3866
|
+
btn.type = "button";
|
|
3867
|
+
btn.className = "btn audit-part-toggle";
|
|
3868
|
+
btn.setAttribute("aria-expanded", "false");
|
|
3869
|
+
btn.setAttribute("data-testid", "audit-checks-toggle");
|
|
3870
|
+
var headHtml = function(open){ return auditCaret(open) + stateDotHTML(auditChecksSignClass(all), "", "audit-checks-state") + head; };
|
|
3871
|
+
btn.innerHTML = headHtml(false);
|
|
3872
|
+
var body = document.createElement("div");
|
|
3873
|
+
body.className = "audit-part-body";
|
|
3874
|
+
body.hidden = true;
|
|
3875
|
+
body.setAttribute("data-testid", "audit-checks-body");
|
|
3876
|
+
var sec = function(title, rows, tid){
|
|
3877
|
+
if(!rows || !rows.length) return "";
|
|
3878
|
+
return '<div data-testid="' + tid + '" style="margin:6px 0"><div><b>' + escapeXml(title) + "</b></div>" + rows.map(auditCheckRowHtml).join("") + "</div>";
|
|
3879
|
+
};
|
|
3880
|
+
body.innerHTML = '<div class="jp">' + sec("Checks", ac.checks, "audit-checks-checks") + sec("Not checked", ac.notChecked, "audit-checks-notchecked") + sec("Always checked", ac.always, "audit-checks-always") + "</div>";
|
|
3881
|
+
btn.addEventListener("click", function(){
|
|
3882
|
+
var open = btn.getAttribute("aria-expanded") === "true";
|
|
3883
|
+
btn.setAttribute("aria-expanded", open ? "false" : "true");
|
|
3884
|
+
body.hidden = open;
|
|
3885
|
+
btn.innerHTML = headHtml(!open);
|
|
3886
|
+
});
|
|
3887
|
+
wrap.appendChild(btn);
|
|
3888
|
+
wrap.appendChild(body);
|
|
3889
|
+
return wrap;
|
|
3890
|
+
}
|
|
3816
3891
|
function renderAuditGroups(detail){
|
|
3817
3892
|
var container = document.getElementById("audit-groups");
|
|
3818
3893
|
container.innerHTML = "";
|
|
@@ -3871,6 +3946,11 @@
|
|
|
3871
3946
|
needsEl.textContent = detail.needsAudit;
|
|
3872
3947
|
container.appendChild(needsEl);
|
|
3873
3948
|
}
|
|
3949
|
+
// 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`)
|
|
3950
|
+
var ac = detail.auditChecks;
|
|
3951
|
+
if(ac && ((ac.checks || []).length || (ac.notChecked || []).length || (ac.always || []).length)){
|
|
3952
|
+
container.appendChild(auditChecksEl(ac));
|
|
3953
|
+
}
|
|
3874
3954
|
// P5-R: a resumed run is ONE run — its legs are told apart by a divider line (code-owned text from the server)
|
|
3875
3955
|
var dividers = Array.isArray(detail.legDividers) ? detail.legDividers : [];
|
|
3876
3956
|
boxes.forEach(function(box, idx){
|
|
@@ -4072,12 +4152,17 @@
|
|
|
4072
4152
|
// ---- the ONE job plan drawing (P7): used by the chat's plan bubble AND the Job tab. `plan` is the server's model
|
|
4073
4153
|
// (src/panel/jobplan.js): numbered lines with their rule, the checks under the line each serves (folded), the AI's own
|
|
4074
4154
|
// "Not checked", the always-on guards. Only the marker is blue (--plan). Returns HTML (every text is escaped).
|
|
4075
|
-
|
|
4076
|
-
|
|
4155
|
+
// the tag of a row by its kind (F-c, code-owned): `~` rows [you], `!` rows [agent], `$` rows [default]; one spelling for the confirm card, the signed card, the Job tab and the Result tab
|
|
4156
|
+
function byTagOf(by){ return by === "you" ? ' <span class="by" data-testid="plan-by" data-by="you">[you]</span>' : by === "agent" ? ' <span class="by" data-testid="plan-by" data-by="agent">[agent]</span>' : by === "default" ? ' <span class="by" data-testid="plan-by" data-by="default">[default]</span>' : ""; }
|
|
4157
|
+
function renderJobPlan(plan, ctl){
|
|
4158
|
+
// the legend promises \u203A checks, so it shows only when the plan has one to show (the goal-only confirm card has none yet)
|
|
4159
|
+
var hasCheck = (plan.loose || []).length > 0 || (plan.lines || []).some(function(l){ return (l.checks || []).length || (l.picked || []).length || (l.always || []).length; });
|
|
4160
|
+
var h = '<div class="jp" data-testid="job-plan">' + (plan.older ? '<div class="older" data-testid="plan-older">older job \u2014 numbered lines were not saved</div>' : "") + (hasCheck ? '<div class="jp-legend">Done when every <b>\u203A</b> check passes</div>' : "") +
|
|
4077
4161
|
(plan.goal && !plan.older ? '<div class="jp-sum" data-testid="plan-goal"><span class="lbl">AI\'s summary</span>' + escapeXml(plan.goal) + "</div>" : "");
|
|
4078
|
-
var byTag =
|
|
4162
|
+
var byTag = byTagOf;
|
|
4163
|
+
// `ctl` (the confirm card only): draws a Drop button after an [agent] check that has a row key; a [you] or [default] row has none
|
|
4079
4164
|
var checkLine = function(c){
|
|
4080
|
-
return '<div class="fold" data-testid="plan-check"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(c.name) + (c.cls ? " \u00B7 " + escapeXml(c.cls) : "") + byTag(c.by) + "</div>";
|
|
4165
|
+
return '<div class="fold" data-testid="plan-check"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(c.name) + (c.cls ? " \u00B7 " + escapeXml(c.cls) : "") + byTag(c.by) + (ctl && c.by === "agent" && c.key ? ctl("drop", c.key) : "") + "</div>";
|
|
4081
4166
|
};
|
|
4082
4167
|
(plan.lines || []).forEach(function(l){
|
|
4083
4168
|
h += '<div class="jl" data-testid="plan-line"><span class="num">' + escapeXml(String(l.n)) + "</span>" + escapeXml(l.text);
|
|
@@ -4085,21 +4170,27 @@
|
|
|
4085
4170
|
(l.rules && l.rules.length ? l.rules : (l.rule ? [l.rule] : [])).forEach(function(r){ h += '<div class="sub">~ ' + escapeXml(r) + "</div>"; });
|
|
4086
4171
|
(l.picked || []).forEach(function(p){ h += '<div class="fold" data-testid="plan-picked"><span class="mk">\u203A</span> check \u00B7 ' + escapeXml(p) + byTag("you") + "</div>"; });
|
|
4087
4172
|
(l.checks || []).forEach(function(c){ h += checkLine(c); });
|
|
4088
|
-
(l.always || []).forEach(function(g){ h += '<div class="fold" data-testid="plan-always"><span class="mk">\u203A</span> check \u00B7 always-on: ' + escapeXml(g) + "</div>"; });
|
|
4089
|
-
(l.refused || []).forEach(function(r){ h += '<div class="fold" data-testid="plan-refused"><span class="mk">\u203A</span> not checked \u00B7 ' + escapeXml(r) + "</div>"; });
|
|
4173
|
+
(l.always || []).forEach(function(g){ h += '<div class="fold" data-testid="plan-always"><span class="mk">\u203A</span> check \u00B7 always-on: ' + escapeXml(g) + byTag("default") + "</div>"; });
|
|
4174
|
+
(l.refused || []).forEach(function(r){ h += '<div class="fold" data-testid="plan-refused"><span class="mk">\u203A</span> not checked \u00B7 ' + escapeXml(r) + byTag((plan.notCheckedBy || {})[r]) + "</div>"; });
|
|
4090
4175
|
h += "</div>";
|
|
4091
4176
|
});
|
|
4092
4177
|
if((plan.loose || []).length){
|
|
4093
4178
|
h += '<div class="jl"><span class="num"></span>other checks' + plan.loose.map(checkLine).join("") + "</div>";
|
|
4094
4179
|
}
|
|
4095
|
-
|
|
4180
|
+
// N-1: checks the agent suggests that are NOT in the job. Code has already proved each builds; none is checked unless the person adds it
|
|
4181
|
+
if((plan.suggested || []).length){
|
|
4182
|
+
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){
|
|
4183
|
+
return '<div class="fold" data-testid="plan-suggest-row"><span class="mk">\u203A</span> line ' + escapeXml(String(x.line)) + " \u00B7 " + escapeXml(x.text) + byTag("agent") + (x.dropped ? " (you dropped it)" : "") + (ctl ? ctl("add", x.key) : "") + "</div>";
|
|
4184
|
+
}).join("") + "</div>";
|
|
4185
|
+
}
|
|
4186
|
+
var fold = function(title, items, testid, by){
|
|
4096
4187
|
if(!items || !items.length) return "";
|
|
4097
4188
|
return '<details class="fold" data-testid="' + testid + '"><summary>' + escapeXml(title) + " \u00B7 " + items.length + "</summary><ul>" +
|
|
4098
|
-
items.map(function(x){ return "<li>" + escapeXml(x) + "</li>"; }).join("") + "</ul></details>";
|
|
4189
|
+
items.map(function(x){ return "<li>" + escapeXml(x) + byTag(by ? by : (plan.notCheckedBy || {})[x]) + "</li>"; }).join("") + "</ul></details>";
|
|
4099
4190
|
};
|
|
4100
|
-
h += fold("Not checked
|
|
4191
|
+
h += fold("Not checked", plan.notChecked, "plan-notchecked");
|
|
4101
4192
|
h += fold("How the page was read", plan.readNotes, "plan-readnotes");
|
|
4102
|
-
h += fold("Always checked", plan.alwaysOn, "plan-alwayson");
|
|
4193
|
+
h += fold("Always checked", plan.alwaysOn, "plan-alwayson", "default");
|
|
4103
4194
|
if(plan.ticketFilter) h += '<div class="fold" data-testid="plan-ticketfilter"><span class="mk">\u203A</span> ticket filter \u00B7 ' + escapeXml(plan.ticketFilter) + "</div>";
|
|
4104
4195
|
return h + "</div>";
|
|
4105
4196
|
}
|
|
@@ -4263,10 +4354,10 @@
|
|
|
4263
4354
|
return h;
|
|
4264
4355
|
}
|
|
4265
4356
|
// a list, one row per item (the Job tab lists the same items one per row)
|
|
4266
|
-
function resultNotChecked(label, items, testid){
|
|
4357
|
+
function resultNotChecked(label, items, testid, by){
|
|
4267
4358
|
if(!items || !items.length) return "";
|
|
4268
4359
|
return resultField(label, '<div class="ro-value" data-testid="' + testid + '"><ul style="margin:0;padding-left:18px">' +
|
|
4269
|
-
items.map(function(t){ return '<li>' + escapeXml(t) + '</li>'; }).join("") + '</ul></div>');
|
|
4360
|
+
items.map(function(t){ return '<li>' + escapeXml(t) + (by && typeof byTagOf === "function" ? byTagOf(by[t]) : "") + '</li>'; }).join("") + '</ul></div>');
|
|
4270
4361
|
}
|
|
4271
4362
|
// the web page a result was read from: a link (http/https only, new tab) and the server's words that the page may have moved on
|
|
4272
4363
|
function resultPageLink(url, note, testid){
|
|
@@ -4279,7 +4370,7 @@
|
|
|
4279
4370
|
return '<div class="job-card" data-testid="result-line"><h4>Line ' + escapeXml(String(line.n)) + '</h4>' + resultLineBox(line) +
|
|
4280
4371
|
(own ? resultPageLink(line.page, note, "result-page-line") : "") +
|
|
4281
4372
|
(line.kind === "facts" ? resultFactsLine(line) : resultTextLine(line)) +
|
|
4282
|
-
resultNotChecked("Not checked", line.notChecked, "result-line-notchecked") + '</div>';
|
|
4373
|
+
resultNotChecked("Not checked", line.notChecked, "result-line-notchecked", line.notCheckedBy) + '</div>';
|
|
4283
4374
|
}
|
|
4284
4375
|
// ---- the generic Result tab (R7b item 4): every ended non-rubric run. The server sends the facts and the words (`kind: "generic"`); the page only draws.
|
|
4285
4376
|
// The check words and numbers are the Run/Audit tabs' own owners (stageQuestionText, stageNumberText); the state word is the status table's (the server sends it).
|
|
@@ -4576,7 +4667,7 @@
|
|
|
4576
4667
|
h += '<div class="rs-warn" data-testid="result-gap">The check said: ' + escapeXml(data.gap.line) + (data.gap.moreText ? ' ' + escapeXml(data.gap.moreText) : "") + '</div>';
|
|
4577
4668
|
}
|
|
4578
4669
|
if((data.notChecked || []).length){
|
|
4579
|
-
h += '<div class="job-card"><h4>Not checked</h4>' + resultNotChecked("Not checked
|
|
4670
|
+
h += '<div class="job-card"><h4>Not checked</h4>' + resultNotChecked("Not checked", data.notChecked, "result-notchecked", data.notCheckedBy) + '</div>';
|
|
4580
4671
|
}
|
|
4581
4672
|
if((data.readNotes || []).length){
|
|
4582
4673
|
h += '<div class="job-card"><h4>How the page was read</h4>' + resultNotChecked("How the page was read \u00b7 " + data.readNotes.length, data.readNotes, "result-readnotes") + '</div>';
|
|
@@ -5367,6 +5458,18 @@
|
|
|
5367
5458
|
var mainBtn = document.getElementById("chat-main-btn");
|
|
5368
5459
|
var mainHint = document.getElementById("chat-main-hint");
|
|
5369
5460
|
var reopenBtn = document.getElementById("chat-reopen-btn");
|
|
5461
|
+
var qBox = document.getElementById("chat-question");
|
|
5462
|
+
var qHead = document.getElementById("chat-q-head");
|
|
5463
|
+
var qLine = document.getElementById("chat-q-line");
|
|
5464
|
+
var qText = document.getElementById("chat-q-text");
|
|
5465
|
+
var qChoices = document.getElementById("chat-q-choices");
|
|
5466
|
+
var qC1 = document.getElementById("chat-q-c1");
|
|
5467
|
+
var qC2 = document.getElementById("chat-q-c2");
|
|
5468
|
+
var qOr = document.getElementById("chat-q-or");
|
|
5469
|
+
var qAnswer = document.getElementById("chat-q-answer");
|
|
5470
|
+
var qError = document.getElementById("chat-q-error");
|
|
5471
|
+
var qSend = document.getElementById("chat-q-send");
|
|
5472
|
+
var qKey = null, qBusy = false, qSendChoice = "rule";
|
|
5370
5473
|
var revisesLeftEl = document.getElementById("chat-left-count");
|
|
5371
5474
|
// R10 (fwd am17/am20): the id of the draft the next Start drafting follows; the server hands its check picks on (words-keyed), so a pick already made is not asked again
|
|
5372
5475
|
var carryFromId = null;
|
|
@@ -5649,6 +5752,7 @@
|
|
|
5649
5752
|
card.hidden = false;
|
|
5650
5753
|
originLine.hidden = true;
|
|
5651
5754
|
exitResumeMode();
|
|
5755
|
+
renderQuestionBox(null);
|
|
5652
5756
|
thread.innerHTML = ""; lastMsgSig = null;
|
|
5653
5757
|
errEl.textContent = "";
|
|
5654
5758
|
actionErrEl.textContent = "";
|
|
@@ -5963,11 +6067,16 @@
|
|
|
5963
6067
|
}
|
|
5964
6068
|
// the thread is redrawn only when its messages changed: a 2 s poll tick must not close a fold the person just opened
|
|
5965
6069
|
var lastMsgSig = null;
|
|
6070
|
+
// the confirm card's Drop / Add button (N-2): a typed row edit, instant and $0; the click is handled once on the thread
|
|
6071
|
+
function planControlHTML(op, key){
|
|
6072
|
+
return ' <button type="button" class="btn jp-btn" data-testid="plan-' + op + '" data-rowop="' + op + '" data-rowkey="' + escapeXml(key) + '">' + (op === "add" ? "Add" : "Drop") + "</button>";
|
|
6073
|
+
}
|
|
5966
6074
|
function renderMessages(state){
|
|
5967
6075
|
var sig = JSON.stringify(state.messages);
|
|
5968
6076
|
if(sig === lastMsgSig) return;
|
|
5969
6077
|
lastMsgSig = sig;
|
|
5970
|
-
|
|
6078
|
+
// a question still open is drawn in its own box, not here
|
|
6079
|
+
thread.innerHTML = state.messages.filter(function(m){ return m.askOpen !== true; }).map(function(m){
|
|
5971
6080
|
var cls = m.role === "you" ? "you" : (m.role === "system" ? "system" : "bot");
|
|
5972
6081
|
var who = chatWhoLabel(m.role);
|
|
5973
6082
|
var whoHtml = who ? ('<div class="who">' + escapeXml(who) + '</div>') : "";
|
|
@@ -5976,7 +6085,7 @@
|
|
|
5976
6085
|
var qs = (m.plan.questions || []).length
|
|
5977
6086
|
? '<div class="jp-qs" data-testid="plan-questions"><span class="lbl">AI\'s open questions</span><ul>' +
|
|
5978
6087
|
m.plan.questions.map(function(q){ return "<li>" + escapeXml(q) + "</li>"; }).join("") + "</ul><b>Revise if you need to.</b></div>" : "";
|
|
5979
|
-
return '<div class="msg ' + cls + '" data-testid="plan-bubble">' + whoHtml + renderJobPlan(m.plan) + qs + '<div class="jp-goal">' + escapeXml(m.text) + "</div></div>";
|
|
6088
|
+
return '<div class="msg ' + cls + '" data-testid="plan-bubble">' + whoHtml + renderJobPlan(m.plan, m.plan.editable === true ? planControlHTML : null) + qs + '<div class="jp-goal">' + escapeXml(m.text) + "</div></div>";
|
|
5980
6089
|
}
|
|
5981
6090
|
return '<div class="msg ' + cls + '">' + whoHtml + escapeXml(m.text) + '</div>';
|
|
5982
6091
|
}).join("");
|
|
@@ -6173,6 +6282,33 @@
|
|
|
6173
6282
|
var box = document.getElementById("jf-dest");
|
|
6174
6283
|
if(box && box.value !== d){ box.value = d; fitCardBoxes(); }
|
|
6175
6284
|
}
|
|
6285
|
+
// hamr 2026-11-12 (as fwdloop M10 am29): the question box. It shows while the session has a question with a `box` (the server's words, src/questionbox.js) and takes the chat input's
|
|
6286
|
+
// place; the texts are rewritten only when the question changes, so a poll tick never wipes what the person is typing. A state with no box (an ask of another kind) keeps the chat input.
|
|
6287
|
+
function renderQuestionBox(state){
|
|
6288
|
+
var ask = state && state.pendingAsk;
|
|
6289
|
+
var b = ask && ask.box ? ask.box : null;
|
|
6290
|
+
qBox.hidden = b === null;
|
|
6291
|
+
document.querySelector(".chat-input-row").hidden = b !== null;
|
|
6292
|
+
mainBtn.hidden = b !== null; mainHint.hidden = b !== null;
|
|
6293
|
+
if(b === null){ qKey = null; return; }
|
|
6294
|
+
var key = String(sessionId) + ":" + String(ask.index) + ":" + String(ask.source) + ":" + b.text;
|
|
6295
|
+
if(key !== qKey){
|
|
6296
|
+
qKey = key;
|
|
6297
|
+
qSendChoice = b.sendChoice || "rule";
|
|
6298
|
+
qHead.textContent = b.head; qLine.textContent = b.line; qText.textContent = b.text;
|
|
6299
|
+
qHead.hidden = b.head === ""; qLine.hidden = b.line === "";
|
|
6300
|
+
var cs = b.choices || [];
|
|
6301
|
+
[qC1, qC2].forEach(function(btn, i){
|
|
6302
|
+
var c = cs[i];
|
|
6303
|
+
btn.hidden = !c;
|
|
6304
|
+
if(c){ btn.textContent = c.label; btn.setAttribute("data-choice", c.choice); btn.setAttribute("data-testid", "chat-q-" + c.choice); }
|
|
6305
|
+
});
|
|
6306
|
+
qChoices.hidden = cs.length === 0;
|
|
6307
|
+
qOr.hidden = b.orLabel === null; qAnswer.hidden = b.orLabel === null; qSend.hidden = b.orLabel === null;
|
|
6308
|
+
if(b.orLabel !== null) qOr.textContent = b.orLabel;
|
|
6309
|
+
qAnswer.value = ""; qError.textContent = "";
|
|
6310
|
+
}
|
|
6311
|
+
}
|
|
6176
6312
|
function renderActions(state){
|
|
6177
6313
|
lastState = state;
|
|
6178
6314
|
syncDestinationFromSession(state);
|
|
@@ -6180,6 +6316,7 @@
|
|
|
6180
6316
|
// refused START (its own handler writes it) — echoing state.error here made the same refusal appear twice
|
|
6181
6317
|
errEl.textContent = "";
|
|
6182
6318
|
var progressChanged = renderProgress(state);
|
|
6319
|
+
renderQuestionBox(state);
|
|
6183
6320
|
// build item 4 — re-enable Start only once the session has settled
|
|
6184
6321
|
// into a terminal phase (a fresh Start becomes possible again).
|
|
6185
6322
|
sessionLive = CLIENT_TERMINAL_PHASES.indexOf(state.phase) === -1;
|
|
@@ -6486,6 +6623,41 @@
|
|
|
6486
6623
|
}).catch(function(){ chatActionFailed("network error — could not reach the panel server, nothing was sent"); });
|
|
6487
6624
|
}
|
|
6488
6625
|
|
|
6626
|
+
// the box's own Send and choice buttons: a choice button posts its choice and nothing else; the box's Send posts the box's words (as a new rule where the question has choices)
|
|
6627
|
+
function doQuestion(choice){
|
|
6628
|
+
if(qBusy || !sessionId || !lastState || !lastState.pendingAsk || !lastState.pendingAsk.box) return;
|
|
6629
|
+
qBusy = true; qSend.disabled = true; qC1.disabled = true; qC2.disabled = true; qError.textContent = "";
|
|
6630
|
+
var id = sessionId;
|
|
6631
|
+
// a choice button posts its choice and nothing else; the box's Send posts the box's words with the choice the box carries (a new rule), never read as agree or drop it
|
|
6632
|
+
var body = choice === qSendChoice ? {text: qAnswer.value, choice: choice} : {choice: choice};
|
|
6633
|
+
authorPost("/api/author/" + id + "/send", body).then(function(r){
|
|
6634
|
+
qBusy = false; qSend.disabled = false; qC1.disabled = false; qC2.disabled = false;
|
|
6635
|
+
if(id !== sessionId) return;
|
|
6636
|
+
var o = chatPostOutcome(r);
|
|
6637
|
+
if(!o.ok){ qError.textContent = o.error; return; }
|
|
6638
|
+
qAnswer.value = "";
|
|
6639
|
+
poll();
|
|
6640
|
+
}).catch(function(){ qBusy = false; qSend.disabled = false; qC1.disabled = false; qC2.disabled = false; qError.textContent = "network error \u2014 could not reach the panel server, your answer was NOT sent"; });
|
|
6641
|
+
}
|
|
6642
|
+
qSend.addEventListener("click", function(){ doQuestion(qSendChoice); });
|
|
6643
|
+
qC1.addEventListener("click", function(){ doQuestion(qC1.getAttribute("data-choice")); });
|
|
6644
|
+
qC2.addEventListener("click", function(){ doQuestion(qC2.getAttribute("data-choice")); });
|
|
6645
|
+
qAnswer.addEventListener("keydown", function(e){ if(e.key === "Enter" && !e.shiftKey){ e.preventDefault(); doQuestion(qSendChoice); } });
|
|
6646
|
+
|
|
6647
|
+
// Drop / Add on the confirm card: one delegated click; the server edits the row through the check block (no model call) and the card is drawn again from the rows
|
|
6648
|
+
thread.addEventListener("click", function(ev){
|
|
6649
|
+
var b = ev.target && ev.target.closest ? ev.target.closest("[data-rowop]") : null;
|
|
6650
|
+
if(!b || !sessionId) return;
|
|
6651
|
+
b.disabled = true;
|
|
6652
|
+
var id = sessionId;
|
|
6653
|
+
authorPost("/api/author/" + id + "/row-edit", {op: b.getAttribute("data-rowop"), key: b.getAttribute("data-rowkey")}).then(function(r){
|
|
6654
|
+
if(id !== sessionId) return;
|
|
6655
|
+
var o = chatPostOutcome(r);
|
|
6656
|
+
if(o.ok) chatActionOk(); else { b.disabled = false; chatActionFailed(o.error); }
|
|
6657
|
+
poll();
|
|
6658
|
+
}).catch(function(){ b.disabled = false; chatActionFailed("network error \u2014 could not reach the panel server, nothing was changed"); });
|
|
6659
|
+
});
|
|
6660
|
+
|
|
6489
6661
|
function doSend(){
|
|
6490
6662
|
if(!sessionId) return;
|
|
6491
6663
|
var text = msgInput.value;
|
package/src/panel/jobplan.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
//
|
|
5
5
|
// { lines: [{n, text, rule, rules: [string...], checks: [{name, cls}], refused: [reason...]}],
|
|
6
6
|
// loose: [{name, cls}], checks that name no job line (an older caller, or a model slip)
|
|
7
|
-
// notChecked: [text...], "
|
|
7
|
+
// notChecked: [text...], "Not checked" — what nothing checks
|
|
8
|
+
// notCheckedBy: {text: 'you'|'agent'|'default'}, the tag of a Not checked row, by its row's kind (a refused line under a job line is keyed by its text too)
|
|
8
9
|
// alwaysOn: [text...], the mandatory guards / protections, which serve no job line
|
|
9
10
|
// older: boolean } an older job: the numbered lines were not saved
|
|
10
11
|
//
|
|
@@ -12,13 +13,16 @@
|
|
|
12
13
|
// stage kinds exist only after drafting). Pure; no file IO.
|
|
13
14
|
import { ticketFilterWords } from '../ticketfilter.js';
|
|
14
15
|
import { KIND_CATALOGUE } from '../authoring.js';
|
|
16
|
+
import { WEEK_ONLY_WORDS } from '../checklist.js';
|
|
15
17
|
import { splitReadNotes } from '../pagedropwords.js';
|
|
16
|
-
import { checksOfClose, signedFactNames, proseNotChecked, lineRules, confirmedGoalOf } from '../rubricstep.js';
|
|
18
|
+
import { checksOfClose, signedFactNames, proseNotChecked, lineRules, confirmedGoalOf, refusedOf, listRowName, ruleNotCheckedItems } from '../rubricstep.js';
|
|
17
19
|
|
|
18
20
|
/** `by` = who added the check: the drafter (`agent`) or the person's own pick (`you`); absent = code's own (an always-on guard, a number tie) or not known */
|
|
19
|
-
/**
|
|
21
|
+
/** `stage` = the signed close stage the row belongs to (its recorded verdict is the row's result in the Audit) */
|
|
22
|
+
/** @typedef {{text: string, by: 'agent'|'you'|'default'|null, result: 'passed'|'failed'|'none'|'not-checked'|'held'|'record-missing', word?: string}} AuditRow */
|
|
23
|
+
/** @typedef {{name: string, cls: 'machine check'|'judge'|null, by?: 'agent'|'you'|'default'|null, key?: string, stage?: string}} PlanCheck */
|
|
20
24
|
/** @typedef {{n: number, text: string, rule: string, rules: string[], checks: PlanCheck[], refused: string[], always?: string[], picked?: string[]}} PlanLine */
|
|
21
|
-
/** @typedef {{lines: PlanLine[], loose: PlanCheck[], notChecked: string[], readNotes: string[], alwaysOn: string[], older: boolean, goal?: string, ticketFilter?: string}} JobPlan */
|
|
25
|
+
/** @typedef {{lines: PlanLine[], loose: PlanCheck[], notChecked: string[], readNotes: string[], alwaysOn: string[], older: boolean, goal?: string, ticketFilter?: string, notCheckedBy?: Record<string, 'you'|'agent'|'default'>, suggested?: {key: string, line: number, text: string}[], editable?: boolean}} JobPlan */
|
|
22
26
|
|
|
23
27
|
/** the ticket filter's code-owned words as a plan part, or nothing (R5) @param {any} f @returns {{ticketFilter?: string}} */
|
|
24
28
|
function filterPart(f) {
|
|
@@ -39,26 +43,18 @@ export function checkClassOfKind(kind) {
|
|
|
39
43
|
return spec.verdictClass === 'green' ? 'machine check' : 'judge';
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
/**
|
|
43
|
-
* The `~` rules of one job line, each on its own (the page draws one `~` row per rule): the line's own `rules` array when it
|
|
44
|
-
* has one (a rule may itself contain "; "), else the joined `rule` split on "; " (an older line that saved only the join).
|
|
45
|
-
* @param {any} l @returns {string[]}
|
|
46
|
-
*/
|
|
47
|
-
export function rulesOfLine(l) {
|
|
48
|
-
if (Array.isArray(l?.rules)) return l.rules.filter((/** @type {unknown} */ r) => typeof r === 'string' && r);
|
|
49
|
-
return typeof l?.rule === 'string' && l.rule ? l.rule.split('; ').filter(Boolean) : [];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
46
|
/**
|
|
53
47
|
* The plan of a SIGNED spec. With `jobLines`, each stage lands under EACH line its `fromLine` array names (a stage with none is
|
|
54
48
|
* a mandatory guard: "Always checked"), `closeDecl.refused` reasons land under their line, and `closeDecl.notes` are the
|
|
55
49
|
* drafter's own "not checked" words. Without `jobLines` (a spec that predates the job block) the signed goal sentence is
|
|
56
50
|
* line 1 and every stage name is a check under it — `older: true`.
|
|
51
|
+
* `ledger` = the draft log's final check-list rows (`readDraftLedger`), the words a Not checked row is named by; absent (no draft log) a row is named from its key.
|
|
57
52
|
* @param {any} spec
|
|
53
|
+
* @param {{key: string, words: string[]}[]|null} [ledger]
|
|
58
54
|
* @returns {JobPlan}
|
|
59
55
|
*/
|
|
60
|
-
export function planFromSpec(spec) {
|
|
61
|
-
/** @type {{name: string, cls: 'machine check'|'judge'|null, fromLine: number[]|null, by?: 'agent'|'you'|null}[]} */
|
|
56
|
+
export function planFromSpec(spec, ledger = null) {
|
|
57
|
+
/** @type {{name: string, cls: 'machine check'|'judge'|null, fromLine: number[]|null, by?: 'agent'|'you'|'default'|null, stage?: string}[]} */
|
|
62
58
|
let stages = [];
|
|
63
59
|
if (spec && Array.isArray(spec.closeDecl?.stages)) {
|
|
64
60
|
stages = spec.closeDecl.stages.filter((/** @type {any} */ s) => s && typeof s.name === 'string' && s.name)
|
|
@@ -66,8 +62,8 @@ export function planFromSpec(spec) {
|
|
|
66
62
|
const fromLine = Array.isArray(s.fromLine) && s.fromLine.length ? s.fromLine.filter(Number.isInteger) : null;
|
|
67
63
|
// PART 1b: a rubric-step stage is shown as the checks it RUNS — one code-worded row per fact, per count, per limit — read by
|
|
68
64
|
// the same reader (`checksOfClose`) the confirm card and the sign-time invariant use, so the Job tab cannot differ from them
|
|
69
|
-
const rows = s.kind === 'rubric-step' ? checksOfClose({ stages: [s], picks: spec.closeDecl.picks }) : [];
|
|
70
|
-
return rows.length > 0 ? rows.map((r) => ({ name: r.text, cls: /** @type {'machine check'} */ ('machine check'), fromLine, by: r.by })) : [{ name: s.name, cls: checkClassOfKind(s.kind), fromLine, by: /** @type {'agent'} */ ('agent') }];
|
|
65
|
+
const rows = s.kind === 'rubric-step' ? checksOfClose({ stages: [s], picks: spec.closeDecl.picks, list: spec.closeDecl.list }) : [];
|
|
66
|
+
return rows.length > 0 ? rows.map((r) => ({ name: r.text, cls: /** @type {'machine check'} */ ('machine check'), fromLine, by: r.by, stage: s.name })) : [{ name: s.name, cls: checkClassOfKind(s.kind), fromLine, by: /** @type {'agent'} */ ('agent'), stage: s.name }];
|
|
71
67
|
});
|
|
72
68
|
} else if (spec && Array.isArray(spec.close)) {
|
|
73
69
|
stages = spec.close.filter((/** @type {any} */ s) => s && typeof s.name === 'string' && s.name)
|
|
@@ -91,41 +87,53 @@ export function planFromSpec(spec) {
|
|
|
91
87
|
};
|
|
92
88
|
}
|
|
93
89
|
/** @type {PlanLine[]} */
|
|
94
|
-
const lines = jl.map((/** @type {any} */ l) => ({ n: l.n, text: l.text, rule: typeof l.rule === 'string' ? l.rule : '', rules:
|
|
90
|
+
const lines = jl.map((/** @type {any} */ l) => ({ n: l.n, text: l.text, rule: typeof l.rule === 'string' ? l.rule : '', rules: lineRules(l), checks: [], refused: [] }));
|
|
95
91
|
/** @type {PlanCheck[]} */
|
|
96
92
|
const loose = [];
|
|
97
93
|
/** @type {string[]} */
|
|
98
94
|
const alwaysOn = [];
|
|
95
|
+
/** Not checked rows tagged by their row's kind (F-c): `[you]` a rule the person wrote, `[agent]` the agent's, `[default]` code's @type {Record<string, 'you'|'agent'|'default'>} */
|
|
96
|
+
const refusedBy = {};
|
|
99
97
|
for (const s of stages) {
|
|
100
98
|
if (s.fromLine === null) { alwaysOn.push(s.name); continue; }
|
|
101
99
|
// a check that serves several job lines is shown under EACH line it serves (no new element: the same check line, repeated)
|
|
102
100
|
const served = lines.filter((l) => /** @type {number[]} */ (s.fromLine).includes(l.n));
|
|
103
|
-
for (const line of served) line.checks.push({ name: s.name, cls: s.cls, ...(s.by ? { by: s.by } : {}) });
|
|
104
|
-
if (served.length === 0) loose.push({ name: s.name, cls: s.cls, ...(s.by ? { by: s.by } : {}) });
|
|
101
|
+
for (const line of served) line.checks.push({ name: s.name, cls: s.cls, ...(s.by ? { by: s.by } : {}), ...(s.stage ? { stage: s.stage } : {}) });
|
|
102
|
+
if (served.length === 0) loose.push({ name: s.name, cls: s.cls, ...(s.by ? { by: s.by } : {}), ...(s.stage ? { stage: s.stage } : {}) });
|
|
105
103
|
}
|
|
106
104
|
// an always-on guard that the drafter said covers a job line is shown under that line too ("› check · always-on: <guard>")
|
|
107
105
|
for (const g of Array.isArray(spec?.closeDecl?.guardLines) ? spec.closeDecl.guardLines : []) {
|
|
108
106
|
if (!g || typeof g.guard !== 'string' || !Array.isArray(g.lines)) continue;
|
|
109
107
|
for (const line of lines.filter((l) => g.lines.includes(l.n))) (line.always ??= []).push(g.guard);
|
|
110
108
|
}
|
|
111
|
-
const
|
|
112
|
-
for (const r of refused) {
|
|
109
|
+
for (const r of refusedOf(spec?.closeDecl)) {
|
|
113
110
|
const line = lines.find((l) => l.n === r?.line);
|
|
114
|
-
// a refusal of ONE ~ rule (PART 1b, RF16) names the rule in the person's words, so the row reads as that rule's Not checked
|
|
115
|
-
const ruleText = line && Number.isInteger(r.rule) ? lineRules(spec.jobLines.find((/** @type {any} */ l) => l?.n === r.line))[r.rule - 1] : null;
|
|
116
|
-
|
|
111
|
+
// a refusal of ONE ~ rule (PART 1b, RF16) names the rule in the person's words, so the row reads as that rule's Not checked; a list row of another kind names its fact when it has one
|
|
112
|
+
const ruleText = line && Number.isInteger(r.rule) ? lineRules(spec.jobLines.find((/** @type {any} */ l) => l?.n === r.line))[Number(r.rule) - 1] : (r.label ?? null);
|
|
113
|
+
// a list row that is not a fact or a rule (a phrase, a count) is named by its words: the draft log's, else the text after the key's kind prefix
|
|
114
|
+
const named = line && !ruleText && r.fromList && r.key ? listRowName(r.kind, r.key, ledger?.find((x) => x.key === r.key)?.words) : null;
|
|
115
|
+
const text = ruleText ? `"${ruleText}" — ${r.reason}` : (named ? `${named} — ${r.reason}` : r.reason);
|
|
116
|
+
if (line) { line.refused.push(text); if (r.by) refusedBy[text] = r.by; }
|
|
117
|
+
}
|
|
118
|
+
// a row the list dropped because it names a version or a date from the input is told, with its reason (the signed card preview, A11); other dropped rows are not drawn
|
|
119
|
+
for (const r of Array.isArray(spec?.closeDecl?.list) ? spec.closeDecl.list : []) {
|
|
120
|
+
if (!r || r.state !== 'dropped' || r.reason !== WEEK_ONLY_WORDS || typeof r.key !== 'string' || r.kind === 'rule') continue;
|
|
121
|
+
const line = lines.find((l) => l.n === r.line);
|
|
122
|
+
if (line) line.refused.push(`${listRowName(r.kind, r.key, ledger?.find((x) => x.key === r.key)?.words)} — ${r.reason}`);
|
|
117
123
|
}
|
|
124
|
+
const notCheckedBy = { ...refusedBy };
|
|
125
|
+
for (const i of ruleNotCheckedItems(spec?.closeDecl, spec?.jobLines, ledger)) if (i.by) notCheckedBy[i.text] = i.by;
|
|
118
126
|
// the model's signed goal sentence rides along: the page draws it as the "AI's summary" row (an older job shows it as line 1 instead)
|
|
119
127
|
// (a rubric job's signed goal is the whole worker brief: only the sentence the person confirmed is the summary)
|
|
120
128
|
const summary = typeof spec?.goal === 'string' && spec.goal ? confirmedGoalOf(spec.goal) : null;
|
|
121
|
-
return { lines, loose, notChecked: notes, readNotes, alwaysOn, older: false, ...(summary ? { goal: summary } : {}), ...filterPart(spec?.ticketFilter) };
|
|
129
|
+
return { lines, loose, notChecked: notes, readNotes, alwaysOn, older: false, ...(Object.keys(notCheckedBy).length ? { notCheckedBy } : {}), ...(summary ? { goal: summary } : {}), ...filterPart(spec?.ticketFilter) };
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
/**
|
|
125
133
|
* The plan of the confirm turn, before anything is drafted: the person's own job lines, the model's checks under the
|
|
126
134
|
* line each names, its own "not checked" words, and the real protections (code-owned) as "Always checked".
|
|
127
135
|
* @param {{n: number, text: string, rule: string, rules?: string[]}[]|null|undefined} jobLines
|
|
128
|
-
* @param {{checkItems?: {text: string, fromLine: number[]|null, by?: 'agent'|'you'|null}[], checks?: string[], notChecked?: string[], protections?: string[], signedFacts?: string[], ticketFilter?: any, picked?: {line: number, text: string}[]}} plan
|
|
136
|
+
* @param {{checkItems?: {text: string, fromLine: number[]|null, by?: 'agent'|'you'|'default'|null, key?: string}[], checks?: string[], notChecked?: string[], protections?: string[], signedFacts?: string[], ticketFilter?: any, picked?: {line: number, text: string}[], notCheckedBy?: Record<string, 'you'|'agent'|'default'>, suggested?: {key: string, line: number, text: string}[], editable?: boolean}} plan
|
|
129
137
|
* `signedFacts` = the names of the facts the look signs (so an S1 copy of a signed fact reads as a note, not Not checked)
|
|
130
138
|
* @returns {JobPlan}
|
|
131
139
|
*/
|
|
@@ -135,16 +143,17 @@ export function planFromConfirm(jobLines, plan) {
|
|
|
135
143
|
: (Array.isArray(plan?.checks) ? plan.checks.map((c) => ({ text: String(c), fromLine: null })) : []);
|
|
136
144
|
const jl = Array.isArray(jobLines) ? jobLines : [];
|
|
137
145
|
/** @type {PlanLine[]} */
|
|
138
|
-
const lines = jl.map((l) => ({ n: l.n, text: l.text, rule: l.rule, rules:
|
|
146
|
+
const lines = jl.map((l) => ({ n: l.n, text: l.text, rule: l.rule, rules: lineRules(l), checks: [], refused: [] }));
|
|
139
147
|
/** @type {PlanCheck[]} */
|
|
140
148
|
const loose = [];
|
|
141
149
|
// the person's picks are drawn once, from `plan.picked` (their words, with `kept from last draft`) as `[you picked]` check rows: a close row for the same pick is not a second row
|
|
142
150
|
const hasPicked = Array.isArray(plan?.picked) && plan.picked.length > 0;
|
|
143
|
-
for (const c of items.filter((x) => !(hasPicked && /** @type {any} */ (x).by === 'you'))) {
|
|
144
|
-
const by = /** @type {any} */ (c).by === null ? {} : { by: /** @type {'agent'|'you'} */ (/** @type {any} */ (c).by ?? 'agent') };
|
|
151
|
+
for (const c of items.filter((x) => !(hasPicked && /** @type {any} */ (x).by === 'you' && !(/** @type {any} */ (x).key)))) {
|
|
152
|
+
const by = /** @type {any} */ (c).by === null ? {} : { by: /** @type {'agent'|'you'|'default'} */ (/** @type {any} */ (c).by ?? 'agent') };
|
|
145
153
|
const served = lines.filter((l) => Array.isArray(c.fromLine) && c.fromLine.includes(l.n));
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
const key = typeof (/** @type {any} */ (c).key) === 'string' ? { key: /** @type {any} */ (c).key } : {};
|
|
155
|
+
for (const line of served) line.checks.push({ name: c.text, cls: null, ...by, ...key });
|
|
156
|
+
if (served.length === 0) loose.push({ name: c.text, cls: null, ...by, ...key });
|
|
148
157
|
}
|
|
149
158
|
const { notChecked, readNotes } = splitReadNotes(plan?.notChecked, plan?.signedFacts);
|
|
150
159
|
// R10 (fwd am16 (6)): the checks the person picked, each under its line, in the one table's plain words (`kept from last draft` rides in `text` when a Revise kept it)
|
|
@@ -154,5 +163,48 @@ export function planFromConfirm(jobLines, plan) {
|
|
|
154
163
|
}
|
|
155
164
|
return {
|
|
156
165
|
lines, loose, notChecked, readNotes, alwaysOn: [...(plan?.protections ?? [])], older: false, ...filterPart(plan?.ticketFilter),
|
|
166
|
+
...(plan?.notCheckedBy && typeof plan.notCheckedBy === 'object' && Object.keys(plan.notCheckedBy).length ? { notCheckedBy: plan.notCheckedBy } : {}),
|
|
167
|
+
...(Array.isArray(plan?.suggested) && plan.suggested.length ? { suggested: plan.suggested } : {}),
|
|
168
|
+
...(plan?.editable === true ? { editable: true } : {}),
|
|
157
169
|
};
|
|
158
170
|
}
|
|
171
|
+
|
|
172
|
+
/** the words of a row the run recorded no verdict for: never "passed" */
|
|
173
|
+
export const AUDIT_NO_RESULT = 'no result recorded';
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The Audit's check list (hamr ruling A, 2026-11-13): the SAME sections as the card, read from the SAME model (`plan` = {@link planFromSpec}'s, plus `guards` = the
|
|
177
|
+
* code-owned protections the confirm card shows), each row with its tag and, after the run, its result. A check's result is the recorded verdict of its own signed stage
|
|
178
|
+
* (`results`: stage name to passed), never re-derived; a row no verdict was recorded for says so. A Not checked row's result is "not checked" (its reason is in its words).
|
|
179
|
+
* The write fence is enforced per write by the gate, so its row reads the gate's own record of THIS run (hamr ruling A, 2026-11-13): `blocked` = the write/edit attempts the gate denied
|
|
180
|
+
* (`held · N writes blocked`), or `null` when the run's gate record is missing (said in plain words, never "held").
|
|
181
|
+
* @param {JobPlan} plan @param {string[]} guards @param {Map<string, boolean>|null} results @param {number|null} [blocked]
|
|
182
|
+
* @returns {{checks: AuditRow[], notChecked: AuditRow[], always: AuditRow[]}}
|
|
183
|
+
*/
|
|
184
|
+
export function auditChecksOf(plan, guards, results, blocked = null) {
|
|
185
|
+
/** @param {string|undefined|null} stage @returns {'passed'|'failed'|'none'} */
|
|
186
|
+
const verdict = (stage) => (!stage || !results || !results.has(stage) ? 'none' : (results.get(stage) ? 'passed' : 'failed'));
|
|
187
|
+
/** @type {AuditRow[]} */
|
|
188
|
+
const checks = [];
|
|
189
|
+
for (const l of plan.lines) for (const c of l.checks) checks.push({ text: `line ${l.n} · ${c.name}`, by: c.by ?? null, result: verdict(c.stage) });
|
|
190
|
+
for (const c of plan.loose) checks.push({ text: `other · ${c.name}`, by: c.by ?? null, result: verdict(c.stage) });
|
|
191
|
+
/** @type {AuditRow[]} */
|
|
192
|
+
const notChecked = [];
|
|
193
|
+
const by = plan.notCheckedBy ?? {};
|
|
194
|
+
for (const l of plan.lines) for (const r of l.refused) notChecked.push({ text: `line ${l.n} · ${r}`, by: by[r] ?? null, result: 'not-checked' });
|
|
195
|
+
for (const r of plan.notChecked) notChecked.push({ text: r, by: by[r] ?? null, result: 'not-checked' });
|
|
196
|
+
const names = guards.length > 0 ? guards : plan.alwaysOn;
|
|
197
|
+
const always = names.map((g) => {
|
|
198
|
+
const head = g.split(' — ')[0];
|
|
199
|
+
const file = /^line (\d+) file$/.exec(head);
|
|
200
|
+
// the write fence is held by the gate (the row reads the gate's own record, above), never another stage's verdict
|
|
201
|
+
const stage = file ? `line-${file[1]}` : (head === 'write fence' ? null : head);
|
|
202
|
+
if (head === 'write fence') {
|
|
203
|
+
return blocked === null
|
|
204
|
+
? { text: g, by: /** @type {'default'} */ ('default'), result: /** @type {'record-missing'} */ ('record-missing'), word: "the gate's record for this run is missing" }
|
|
205
|
+
: { text: g, by: /** @type {'default'} */ ('default'), result: /** @type {'held'} */ ('held'), word: `held · ${blocked} ${blocked === 1 ? 'write' : 'writes'} blocked` };
|
|
206
|
+
}
|
|
207
|
+
return { text: g, by: /** @type {'default'} */ ('default'), result: verdict(stage) };
|
|
208
|
+
});
|
|
209
|
+
return { checks, notChecked, always };
|
|
210
|
+
}
|