fwdloop 0.34.0 → 0.35.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/README.md +14 -0
- package/bin/fwdloop +4 -0
- package/package.json +1 -1
- package/src/action-line.js +100 -0
- package/src/action-stop.js +44 -0
- package/src/ask.js +9 -2
- package/src/authoring.js +24 -11
- package/src/checkblock.js +7 -2
- package/src/checked.js +7 -2
- package/src/checklist.js +0 -2
- package/src/declaration.js +11 -28
- package/src/drafter.js +132 -81
- package/src/jobkey.js +2 -3
- package/src/pageask.js +19 -1
- package/src/pagemap.js +8 -2
- package/src/panel/author.js +62 -35
- package/src/panel/authorcard.js +2 -9
- package/src/panel/data.js +5 -1
- package/src/panel/index.html +59 -36
- package/src/runner.js +87 -41
- package/src/runvalues.js +9 -1
- package/src/setup.js +2 -0
- package/src/sheetbuild.js +4 -7
- package/src/sheetlook.js +1 -1
- package/src/signed-text.js +1 -5
- package/src/whole-job.js +27 -11
- package/types/action-line.d.ts +71 -0
- package/types/action-stop.d.ts +36 -0
- package/types/ask.d.ts +3 -2
- package/types/authoring.d.ts +5 -2
- package/types/checkblock.d.ts +1 -0
- package/types/checked.d.ts +2 -0
- package/types/checklist.d.ts +0 -2
- package/types/drafter.d.ts +9 -2
- package/types/pageask.d.ts +12 -1
- package/types/panel/author.d.ts +1 -1
- package/types/panel/data.d.ts +1 -1
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/sheetbuild.d.ts +1 -3
- package/types/whole-job.d.ts +3 -3
- package/src/added-end.js +0 -60
- package/types/added-end.d.ts +0 -62
package/src/panel/authorcard.js
CHANGED
|
@@ -20,7 +20,6 @@ import { isColumnChoiceRule, columnChoiceParts, swapColumnWord } from '../sheeto
|
|
|
20
20
|
import { isWebUrl } from '../pagefetch.js';
|
|
21
21
|
import { checkSendDestination } from '../runner.js';
|
|
22
22
|
import { parseSignedText } from '../signed-text.js';
|
|
23
|
-
import { addEnd, typedLinesOf } from '../added-end.js';
|
|
24
23
|
import { capTooSmallText } from '../draftspend.js';
|
|
25
24
|
import { startableMcpServers, mcpConfigFor } from '../mcp-sources.js';
|
|
26
25
|
import { mcpPickFor } from '../mcp-pick.js';
|
|
@@ -283,7 +282,7 @@ export function runInputRows(v) {
|
|
|
283
282
|
* @returns {string}
|
|
284
283
|
*/
|
|
285
284
|
export function cardToProse(card) {
|
|
286
|
-
const { steps } =
|
|
285
|
+
const { steps } = parseJobBox(card.job); // M13 am11: code adds no line; the send is tentative on the last typed line (the draft decides, src/drafter.js)
|
|
287
286
|
const out = [...jobFileLines(steps, card.askWait), '', ARBITER_HEADING];
|
|
288
287
|
out.push(`guardrail: cap $${capText(Number(card.capUsd))} per run`);
|
|
289
288
|
if (card.destination !== '') out.push(`guardrail: send at line ${steps.length} to file:${card.destination}`);
|
|
@@ -310,9 +309,6 @@ export function cardFromSigned({ lines, arbiter }) {
|
|
|
310
309
|
const asks = new Map((arbiter.asks ?? []).map((a) => [a.line, a]));
|
|
311
310
|
const jobLines = [];
|
|
312
311
|
let firstWait = null;
|
|
313
|
-
// M13 am8: the end is added by code (`cardToProse`), so the card's job leaves out the send line (the last line when it is the send) and an added Ask before it
|
|
314
|
-
const lastSend = (arbiter.sends ?? []).length === 1 && arbiter.sends[0].line === lines.length ? arbiter.sends[0].line : null;
|
|
315
|
-
const typed = new Set(typedLinesOf(lines, arbiter).map((l) => l.n));
|
|
316
312
|
for (const l of lines) {
|
|
317
313
|
const ak = asks.get(l.n);
|
|
318
314
|
if (ak) {
|
|
@@ -320,7 +316,6 @@ export function cardFromSigned({ lines, arbiter }) {
|
|
|
320
316
|
if (w === null) return no();
|
|
321
317
|
firstWait ??= w;
|
|
322
318
|
}
|
|
323
|
-
if (!typed.has(l.n)) continue;
|
|
324
319
|
if (ak) jobLines.push(`Ask ${waitText(ak.ttlMs)}: ${l.text}`);
|
|
325
320
|
else jobLines.push(l.text);
|
|
326
321
|
if (typeof l.guardrail === 'string' && l.guardrail !== '') jobLines.push(`~ ${l.guardrail}`);
|
|
@@ -337,9 +332,7 @@ export function cardFromSigned({ lines, arbiter }) {
|
|
|
337
332
|
const again = parseSignedText(cardToProse(cardFields({ ...card, flowName: 'x' })));
|
|
338
333
|
// M9 am1: the trigger is not a box on the card, and signing an Edit clears it (By hand again), so it is not part of the fidelity check
|
|
339
334
|
const norm = (a) => JSON.stringify({ ...a, trigger: null, asks: (a.asks ?? []).map(({ ttlSigned, ...rest }) => rest) });
|
|
340
|
-
|
|
341
|
-
const sendText = (/** @type {{n: number, text: string}[]} */ ls) => ls.map((l) => (l.n === lastSend ? { ...l, text: '' } : l));
|
|
342
|
-
const sameLines = again.ok && JSON.stringify(sendText(again.lines)) === JSON.stringify(sendText(lines));
|
|
335
|
+
const sameLines = again.ok && JSON.stringify(again.lines) === JSON.stringify(lines);
|
|
343
336
|
if (!sameLines || norm(again.arbiter) !== norm(arbiter)) return no();
|
|
344
337
|
return { ok: true, card };
|
|
345
338
|
}
|
package/src/panel/data.js
CHANGED
|
@@ -45,7 +45,7 @@ import { EVERY_STEP_TEXTS } from '../try-checks.js';
|
|
|
45
45
|
import { LABEL_PICKED, tagOf } from '../checkwords.js';
|
|
46
46
|
import { listLinesOf } from '../checklistsign.js';
|
|
47
47
|
import { auditChecksOf } from '../auditchecks.js';
|
|
48
|
-
import { panelQuestionText } from '../pageask.js';
|
|
48
|
+
import { panelQuestionText, decidedWords } from '../pageask.js';
|
|
49
49
|
import { csvRolesOf, askSheetCard } from '../sheetblock.js';
|
|
50
50
|
import { readSheetChecks } from '../sheet-record.js';
|
|
51
51
|
import {
|
|
@@ -1957,6 +1957,8 @@ export function getDraftBlock(flowDir, runDir) {
|
|
|
1957
1957
|
rows.push(human(r, n, { action: 'card (you)', gap }));
|
|
1958
1958
|
} else if (r.kind === 'note') rows.push(human(r, n, { action: 'note (you)', gap: String(r.text ?? '') }));
|
|
1959
1959
|
// M10 am2 item 4: a question the page look raised and your answer, under the drafting step, in bareloop's words (`you were asked:` / `you said:`)
|
|
1960
|
+
// M17 am8: a button-picked answer reads what was decided (`agreed — ...`), never the question that quotes a replaced rule's old words
|
|
1961
|
+
else if (r.kind === 'human' && decidedWords(r) !== null) rows.push(human(r, n, { action: decidedWords(r), gap: '' }));
|
|
1960
1962
|
else if (r.kind === 'human') rows.push(human(r, n, { action: `you were asked: ${panelQuestionText(r)}`, gap: `you said: ${r.answer}${r.source === 'look' && typeof r.rule === 'string' && r.rule !== '' ? ` ${youTag}` : ''}` }));
|
|
1961
1963
|
// M16 item 5: a Drop or an Add on the card: a human row, $0, no model
|
|
1962
1964
|
else if (r.kind === 'rowedit') rows.push(human(r, n, { action: r.op === 'drop' ? 'you dropped a check' : 'you added a check', gap: String(r.key ?? '') }));
|
|
@@ -2298,6 +2300,7 @@ function resultDoorOf(asks) {
|
|
|
2298
2300
|
const block = asks.blocks.at(-1);
|
|
2299
2301
|
const ask = block?.current;
|
|
2300
2302
|
if (!ask || ask.open !== true) return null;
|
|
2303
|
+
if (ask.kind === 'action-stop') return null; // M13 am11: the stop before the action is answered on the Ask tab (Accept / Not now); the Result tab's Your call has Rerun, which the stop does not take
|
|
2301
2304
|
if (asks.resume && asks.resume.askId === ask.askId && asks.resume.state !== 'broken') return null;
|
|
2302
2305
|
return { askId: ask.askId, draftNo: block.draftNo };
|
|
2303
2306
|
}
|
|
@@ -2536,6 +2539,7 @@ function normalizeArchivedRow(a) {
|
|
|
2536
2539
|
answeredAt: a.answer.answeredAt ?? null,
|
|
2537
2540
|
archived: true,
|
|
2538
2541
|
emits: typeof a.emits === 'string' ? a.emits : null,
|
|
2542
|
+
kind: typeof a.kind === 'string' ? a.kind : null, // M13 am11: 'action-stop' = the stop before the action (Accept / Not now)
|
|
2539
2543
|
evidence: flattenEvidence(a.evidence),
|
|
2540
2544
|
};
|
|
2541
2545
|
}
|
package/src/panel/index.html
CHANGED
|
@@ -226,7 +226,6 @@
|
|
|
226
226
|
.badge.cyan{color:var(--cyan);}
|
|
227
227
|
|
|
228
228
|
.hint{font-size:11px;color:var(--text-faint);margin-top:4px;}
|
|
229
|
-
.hint.jf-added{margin-top:2px;overflow-wrap:anywhere;}
|
|
230
229
|
.hint.money-red{color:var(--red);}
|
|
231
230
|
.btn{padding:8px 14px;min-height:44px;border:1px solid var(--border-strong);background:var(--panel2);color:var(--text);white-space:nowrap;flex:none;position:relative;}
|
|
232
231
|
.btn::before{content:"[ ";color:var(--text-faint);}
|
|
@@ -478,9 +477,6 @@
|
|
|
478
477
|
.audit-group.audit-fold h4.audit-status-header::after{content:none;}
|
|
479
478
|
/* 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
479
|
.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;} }
|
|
484
480
|
.audit-part-toggle{width:100%;text-align:left;display:block;white-space:normal;min-height:44px;padding:8px 10px;}
|
|
485
481
|
.audit-part-toggle::before,.audit-part-toggle::after{content:"";}
|
|
486
482
|
.audit-part-toggle.audit-learn-fold::before{content:"\25B6 ";color:var(--text-faint);}
|
|
@@ -600,6 +596,11 @@
|
|
|
600
596
|
/* M10 am4: the Result tab. borrowed-from: bareloop src/panel/index.html@2959217 :188 :192 :397-408 (the Your-call card's rules are below, am5 item 2) */
|
|
601
597
|
.st-word{font-weight:700;color:var(--text);}
|
|
602
598
|
.step-state{display:inline-flex;align-items:center;gap:2px;font-size:12px;}
|
|
599
|
+
.audit-checks-word{font-size:12px;font-weight:700;color:var(--text);}
|
|
600
|
+
/* hamr ask: a passed group's / the run summary's "passed" word = the checks word; the sign glyph stays green. Placed after the phone rule so it also wins at 390/320 */
|
|
601
|
+
.audit-group h4.audit-status-header > .badge.audit-passed-word{font-size:12px;font-weight:700;color:var(--text);}
|
|
602
|
+
.audit-group h4.audit-status-header > .badge.audit-passed-word .audit-sign-glyph{color:var(--green);}
|
|
603
|
+
.audit-group.audit-fold h4.audit-status-header > .badge.audit-passed-word{font-size:12px;}
|
|
603
604
|
/* PRD v1.107 Part 6: the Result tab. Boxes are the Job tab's own (.job-card, .field, .ro-value, .field-row); text wraps, nothing scrolls the page. */
|
|
604
605
|
#result-body{min-width:0;overflow-wrap:anywhere;}
|
|
605
606
|
.rs-ok{color:var(--green);font-weight:700;}
|
|
@@ -1219,9 +1220,7 @@
|
|
|
1219
1220
|
<div class="jf-gut" id="jf-job-gut" data-testid="jf-job-gut" aria-hidden="true"><div class="jf-gut-in"></div></div>
|
|
1220
1221
|
<textarea class="jf-wrap" id="jf-job" rows="6" data-testid="jf-job" autocomplete="off" spellcheck="false" placeholder="Read my resume ~keep it under 600 words Ask: check it with me Write it out"></textarea>
|
|
1221
1222
|
</div>
|
|
1222
|
-
<div class="hint
|
|
1223
|
-
<div class="hint jf-added" id="jf-added-write" data-testid="jf-added-write" hidden></div>
|
|
1224
|
-
<div class="hint">One step per line. A line starting with <code>~</code> is a guardrail of the step above it. <code>Ask:</code> stops for you; <code>Ask 2h:</code> sets that ask's own wait. fwdloop adds the last check and the write to your Destination.</div>
|
|
1223
|
+
<div class="hint">One step per line. A line starting with <code>~</code> is a guardrail of the step above it. <code>Ask:</code> stops for you; <code>Ask 2h:</code> sets that ask's own wait. Your last line writes the result to the Destination. Leave it out and fwdloop suggests one.</div>
|
|
1225
1224
|
<div class="jf-err" id="jf-err-job" data-testid="jf-err-job"></div>
|
|
1226
1225
|
</div>
|
|
1227
1226
|
<div class="field">
|
|
@@ -3592,7 +3591,16 @@
|
|
|
3592
3591
|
var stateSpan = document.createElement("span");
|
|
3593
3592
|
stateSpan.className = "badge " + auditStateClass(p.state) + " sign-badge";
|
|
3594
3593
|
stateSpan.setAttribute("data-testid", "audit-group-state");
|
|
3595
|
-
|
|
3594
|
+
var signEnd = p.status.indexOf(" ");
|
|
3595
|
+
if(p.state === "done" && p.status.charAt(0) === "[" && signEnd > 0){
|
|
3596
|
+
// hamr ask: the "passed" word is the same as the checks header's word (12px, text color); the [\u2713] sign keeps its green
|
|
3597
|
+
stateSpan.className += " audit-passed-word";
|
|
3598
|
+
var glyph = document.createElement("span");
|
|
3599
|
+
glyph.className = "audit-sign-glyph";
|
|
3600
|
+
glyph.textContent = p.status.slice(0, signEnd);
|
|
3601
|
+
stateSpan.appendChild(glyph);
|
|
3602
|
+
stateSpan.appendChild(document.createTextNode(p.status.slice(signEnd)));
|
|
3603
|
+
} else stateSpan.textContent = p.status;
|
|
3596
3604
|
h4.appendChild(stateSpan);
|
|
3597
3605
|
var dotSpan = document.createElement("span");
|
|
3598
3606
|
dotSpan.className = "audit-fold-dot";
|
|
@@ -4160,26 +4168,31 @@
|
|
|
4160
4168
|
if(rows.some(function(r){ return r.result === "none"; })) return glyphClass("[\u00B7]");
|
|
4161
4169
|
return glyphClass("[\u2713]");
|
|
4162
4170
|
}
|
|
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
4171
|
function auditChecksEl(ac){
|
|
4166
4172
|
var all = (ac.checks || []).concat(ac.always || []);
|
|
4167
4173
|
var nPass = all.filter(function(r){ return r.result === "passed"; }).length;
|
|
4168
4174
|
var nFail = all.filter(function(r){ return r.result === "failed"; }).length;
|
|
4169
|
-
var head = "
|
|
4175
|
+
var head = " \u00B7 " + nPass + " passed" + (nFail ? " \u00B7 " + nFail + " failed" : "") + ((ac.notChecked || []).length ? " \u00B7 " + ac.notChecked.length + " not checked" : "");
|
|
4176
|
+
// hamr ask: the same component as a step fold (div.audit-group.audit-fold + h4.audit-status-header, as the schedule fold is), so it lines up with the step rows by construction
|
|
4170
4177
|
var wrap = document.createElement("div");
|
|
4171
|
-
wrap.className = "audit-
|
|
4178
|
+
wrap.className = "audit-group audit-fold closed";
|
|
4172
4179
|
wrap.setAttribute("data-testid", "audit-checks-group");
|
|
4173
|
-
var btn = document.createElement("
|
|
4174
|
-
btn.
|
|
4175
|
-
btn.
|
|
4176
|
-
btn.setAttribute("aria-expanded", "false");
|
|
4180
|
+
var btn = document.createElement("h4");
|
|
4181
|
+
btn.className = "audit-status-header";
|
|
4182
|
+
btn.setAttribute("role", "button"); btn.setAttribute("tabindex", "0"); btn.setAttribute("aria-expanded", "false");
|
|
4177
4183
|
btn.setAttribute("data-testid", "audit-checks-toggle");
|
|
4178
|
-
|
|
4179
|
-
var
|
|
4180
|
-
|
|
4184
|
+
btn.style.cursor = "pointer";
|
|
4185
|
+
var signCls = auditChecksSignClass(all);
|
|
4186
|
+
var sign = document.createElement("span"), signGlyph = document.createElement("span");
|
|
4187
|
+
sign.setAttribute("data-testid", "audit-checks-state");
|
|
4188
|
+
signGlyph.className = "audit-sign-glyph"; signGlyph.textContent = signCls === "green" ? "[\u2713]" : signCls === "red" ? "[\u2717]" : "[\u00B7]";
|
|
4189
|
+
sign.className = "badge " + signCls + " sign-badge" + (signCls === "green" ? " audit-passed-word" : "");
|
|
4190
|
+
sign.appendChild(signGlyph); btn.appendChild(sign);
|
|
4191
|
+
var nm = document.createElement("span"); nm.className = "audit-fold-name keep"; nm.innerHTML = "<b class=\"audit-checks-word\">checks</b>"; btn.appendChild(nm);
|
|
4192
|
+
var lead = document.createElement("span"); lead.textContent = "\u00b7"; btn.appendChild(lead);
|
|
4193
|
+
var tl = document.createElement("span"); tl.className = "audit-fold-tail wrap"; tl.textContent = head.replace(/^ \u00B7 /, ""); btn.appendChild(tl);
|
|
4181
4194
|
var body = document.createElement("div");
|
|
4182
|
-
body.className = "audit-
|
|
4195
|
+
body.className = "audit-fold-body";
|
|
4183
4196
|
body.hidden = true;
|
|
4184
4197
|
body.setAttribute("data-testid", "audit-checks-body");
|
|
4185
4198
|
var sec = function(title, rows, tid){
|
|
@@ -4191,8 +4204,10 @@
|
|
|
4191
4204
|
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
4205
|
};
|
|
4193
4206
|
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");
|
|
4195
|
-
|
|
4207
|
+
function paint(open){ body.hidden = !open; wrap.classList.toggle("closed", !open); btn.setAttribute("aria-expanded", open ? "true" : "false"); }
|
|
4208
|
+
function toggle(){ var open = body.hidden; auditExpanded["\u0000checks"] = open; paint(open); }
|
|
4209
|
+
btn.addEventListener("click", toggle);
|
|
4210
|
+
btn.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); toggle(); } });
|
|
4196
4211
|
if(auditExpanded["\u0000checks"] === true) paint(true);
|
|
4197
4212
|
wrap.appendChild(btn); wrap.appendChild(body);
|
|
4198
4213
|
return wrap;
|
|
@@ -5298,7 +5313,17 @@
|
|
|
5298
5313
|
var root = document.createElement("div");
|
|
5299
5314
|
root.className = "answer-doors";
|
|
5300
5315
|
root.setAttribute("data-testid", "answer-doors");
|
|
5301
|
-
if(model.kind === "doors"){
|
|
5316
|
+
if(model.kind === "doors" && ask.kind === "action-stop"){
|
|
5317
|
+
// M13 am11 rule 3: the stop before the action: its question is the ask's own line; two buttons, Accept and Not now (the Stop: the run ends stopped, nothing is written). No reason box, no other words.
|
|
5318
|
+
var stopBar = document.createElement("div");
|
|
5319
|
+
stopBar.className = "actions-row";
|
|
5320
|
+
stopBar.setAttribute("data-testid", "action-bar");
|
|
5321
|
+
stopBar.appendChild(makeButton("Accept", "btn-accept", function(){ sendAnswer(root, ask, ctx, "accept"); }));
|
|
5322
|
+
stopBar.appendChild(makeButton("Not now", "btn-not-now", function(){
|
|
5323
|
+
postJSON("/api/stop", { flow: ctx.flow, runId: ctx.runId }).then(function(){ return reloadRun(ctx.flow, ctx.runId); }).catch(function(){ return reloadRun(ctx.flow, ctx.runId); });
|
|
5324
|
+
}));
|
|
5325
|
+
root.appendChild(stopBar);
|
|
5326
|
+
} else if(model.kind === "doors"){
|
|
5302
5327
|
if(model.note){
|
|
5303
5328
|
var note = textDiv("answer-msg refused", model.note);
|
|
5304
5329
|
note.setAttribute("data-testid", "answer-note");
|
|
@@ -5969,6 +5994,8 @@
|
|
|
5969
5994
|
return "line " + a.line + (a.lineText ? ": " + a.lineText : "") + "\n > " + a.answer;
|
|
5970
5995
|
})});
|
|
5971
5996
|
}
|
|
5997
|
+
// M13 am11 rule 1: the job's action, the AI's pick, with Drop (a redraft that makes the line an ordinary one)
|
|
5998
|
+
if(state.action && Number.isInteger(state.action.line)) blocks.push({id: "chat-action", action: state.action});
|
|
5972
5999
|
// 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
6000
|
var list = state.list && Array.isArray(state.list.rows) ? state.list : null;
|
|
5974
6001
|
if(list){
|
|
@@ -6342,18 +6369,7 @@
|
|
|
6342
6369
|
clearBtn.textContent = b.text;
|
|
6343
6370
|
clearBtn.disabled = b.disabled;
|
|
6344
6371
|
}
|
|
6345
|
-
// M13 am8: the end code adds, in grey under the Job box (the server's `addEnd` is the one writer; this only shows it): an Ask unless the last step is already one, then the write.
|
|
6346
|
-
function paintAddedEnd(){
|
|
6347
|
-
var steps = jobEl.value.split("\n").map(function(l){ return l.trim(); }).filter(function(l){ return l !== "" && l.charAt(0) !== "~"; });
|
|
6348
|
-
var on = destEl.value.trim() !== "" && steps.length > 0;
|
|
6349
|
-
var needAsk = on && !/^ask[: ]/i.test(steps[steps.length - 1]);
|
|
6350
|
-
var askEl = byId("jf-added-ask"), writeEl = byId("jf-added-write");
|
|
6351
|
-
askEl.hidden = !needAsk; writeEl.hidden = !on;
|
|
6352
|
-
askEl.textContent = "+ Ask " + (askWaitEl.value.trim() || "1h") + ": check the result";
|
|
6353
|
-
writeEl.textContent = "+ Write to Destination";
|
|
6354
|
-
}
|
|
6355
6372
|
function refreshStartEnabled(){
|
|
6356
|
-
paintAddedEnd();
|
|
6357
6373
|
paintRequired();
|
|
6358
6374
|
startOk = startReady();
|
|
6359
6375
|
syncCardLock();
|
|
@@ -6838,14 +6854,21 @@
|
|
|
6838
6854
|
function planControlHTML(op, key){
|
|
6839
6855
|
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
6856
|
}
|
|
6857
|
+
// M13 am11c: the action row, two cases, never a Drop (to change it, Revise). You picked it (Agree or typed): [you]. The AI's pick, or an old log with no `by`: [agent].
|
|
6858
|
+
function actionRowHtml(a){
|
|
6859
|
+
var n = escapeXml(String(a.line));
|
|
6860
|
+
if(a.by === "you") return '<div class="fold" data-testid="plan-action-row"><span class="mk">\u203A</span> line ' + n + ' writes everything before it' + byTagOf("you") + "</div>";
|
|
6861
|
+
return '<div class="fold" data-testid="plan-action-row"><span class="mk">\u203A</span> line ' + n + ' writes everything before it' + byTagOf("agent") + "</div>";
|
|
6862
|
+
}
|
|
6841
6863
|
// 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
|
|
6842
6864
|
function renderExtras(state){
|
|
6843
6865
|
if(state && (state.phase === "revising" || state.phase === "redrafting")) return;
|
|
6844
6866
|
var v = extrasFor(state);
|
|
6845
6867
|
var html = v ? v.blocks.map(function(b){
|
|
6846
|
-
var inner = b.
|
|
6868
|
+
var inner = b.action ? '<div class="who">fwdloop</div>' + actionRowHtml(b.action)
|
|
6869
|
+
: b.plan ? '<div class="who">fwdloop</div>' + planViewHtml(b.plan, planControlHTML)
|
|
6847
6870
|
: '<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>';
|
|
6871
|
+
return '<div class="msg' + (b.plan || b.action ? ' bot' : '') + '" id="' + b.id + '" data-testid="' + b.id + '">' + inner + '</div>';
|
|
6849
6872
|
}).join("") : "";
|
|
6850
6873
|
if(html !== extrasKey){ extrasKey = html; extrasEl.innerHTML = html; }
|
|
6851
6874
|
}
|
package/src/runner.js
CHANGED
|
@@ -80,6 +80,7 @@ import { readRunInputs, readRunRecord, writeRunStart } from './runfile.js';
|
|
|
80
80
|
import { citedPlaceFactsOf, bindCitedPlaceValues, readPlaceRules, valueInWords, stopWords, placeValuesOfEvents, lastRunPlaceRead, PLACE_EVENT, NO_PLACE_RECORD_WORDS } from './placerule.js';
|
|
81
81
|
import { buildMemo } from './memo.js';
|
|
82
82
|
import { wholeJobAskIndex, wholeJobText } from './whole-job.js';
|
|
83
|
+
import { ACTION_STOP_KIND, decideAction, lastAcceptedSha, stopWaitMs } from './action-stop.js';
|
|
83
84
|
import { fetchPageText, isWebUrl } from './pagefetch.js';
|
|
84
85
|
import { readTicketMcp, configForServer, remoteRefusal, mcpStartOpts, startRefusal, firstLine } from './ticket-mcp.js';
|
|
85
86
|
import { createMCPBridge, discoverServers } from 'bare-agent/mcp';
|
|
@@ -1693,7 +1694,7 @@ async function runAskSlot({
|
|
|
1693
1694
|
// `currentPrior` is the just-redrafted artifact), so this write always
|
|
1694
1695
|
// carries the CURRENT evidence, not a stale first-park copy.
|
|
1695
1696
|
writeFileSync(join(runDir, 'ask.json'), JSON.stringify({
|
|
1696
|
-
askId, question: askSlot?.question ?? step.goal, askedAt, expiresAt, evidence,
|
|
1697
|
+
askId, question: askSlot?.question ?? step.goal, askedAt, expiresAt, evidence, ...(askSlot?.kind ? { kind: askSlot.kind } : {}),
|
|
1697
1698
|
}, null, 2));
|
|
1698
1699
|
// Amendment M4a-1 — SIGNED by hamr 2026-09-27 ("sign m4a1"): a
|
|
1699
1700
|
// PERMANENT copy of this same park, `asks/<askId>.json`, written right
|
|
@@ -1707,7 +1708,7 @@ async function runAskSlot({
|
|
|
1707
1708
|
// is a genuine invariant violation, not a race to recover from — it
|
|
1708
1709
|
// halts the run rather than silently dropping the archive duty.
|
|
1709
1710
|
const archived = writeAskArchive({
|
|
1710
|
-
runDir, askId, question: askSlot?.question ?? step.goal, askedAt, expiresAt, evidence, emits: step.emits,
|
|
1711
|
+
runDir, askId, question: askSlot?.question ?? step.goal, askedAt, expiresAt, evidence, emits: step.emits, ...(askSlot?.kind ? { kind: askSlot.kind } : {}),
|
|
1711
1712
|
});
|
|
1712
1713
|
if (!archived.ok) {
|
|
1713
1714
|
throw new Error(archived.red);
|
|
@@ -1889,6 +1890,8 @@ async function foldFromStep({
|
|
|
1889
1890
|
// `@param {object} opts` this function's block comment never declared)
|
|
1890
1891
|
// is what keeps every OTHER destructured field's inferred type intact.
|
|
1891
1892
|
firstStepGap = /** @type {string|null} */ (null),
|
|
1893
|
+
// M13 am11: set by a resume that took the Accept of the stop before the action at step `i0`: the sha256 the person accepted (what was shown)
|
|
1894
|
+
stopAcceptedSha = /** @type {string|null} */ (null),
|
|
1892
1895
|
// Amendment 7 item 8: a run Resumed after a Stop that cut step `i0` mid-way re-enters it as a NEW try — `numbered` tries already
|
|
1893
1896
|
// wear numbers (the new one is numbered after them), `done` of them closed and count against the step's limit.
|
|
1894
1897
|
resumeTries = { numbered: 0, done: 0 },
|
|
@@ -1926,15 +1929,10 @@ async function foldFromStep({
|
|
|
1926
1929
|
});
|
|
1927
1930
|
}
|
|
1928
1931
|
|
|
1929
|
-
// --- the signed send slot: never through modelStep,
|
|
1930
|
-
//
|
|
1932
|
+
// --- the signed send slot = the job's action (M13 am11): never through modelStep. It ships the output of the step right before it. Before it writes, what goes
|
|
1933
|
+
// out is compared by sha256 with what was accepted at the last Ask IN THIS RUN: the same goes; a change, or no accept this run, stops the run once and asks
|
|
1934
|
+
// (Accept / Not now, the Ask's own park). The same rule for every Destination. ---
|
|
1931
1935
|
if (sendLines.has(step.fromLine)) {
|
|
1932
|
-
if (!runAcceptedThisRun) {
|
|
1933
|
-
return haltRun({
|
|
1934
|
-
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs, signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts,
|
|
1935
|
-
outcome: 'red', red: `send: step "${step.goal}" reached with no accept this run`,
|
|
1936
|
-
});
|
|
1937
|
-
}
|
|
1938
1936
|
const sendSlot = sendLines.get(step.fromLine);
|
|
1939
1937
|
if (!sendSlot) {
|
|
1940
1938
|
return haltRun({
|
|
@@ -1942,43 +1940,86 @@ async function foldFromStep({
|
|
|
1942
1940
|
});
|
|
1943
1941
|
}
|
|
1944
1942
|
const target = `${sendSlot.target.kind}:${sendSlot.target.path}`;
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
// refuse, at signing time, any declaration whose send step doesn't
|
|
1949
|
-
// read the emits of exactly one earlier signed ask (M3 item 8); every
|
|
1950
|
-
// path into this fold goes through `readFlow` first, so `askIdsInReads`
|
|
1951
|
-
// is always exactly 1 here.
|
|
1952
|
-
const [askArtifactId] = (step.reads ?? []).filter((id) => askStepEmits.has(id));
|
|
1953
|
-
if (!acceptedAskEmitsThisRun.has(askArtifactId)) {
|
|
1943
|
+
const before = i > 0 ? steps[i - 1] : null;
|
|
1944
|
+
const outId = before?.emits;
|
|
1945
|
+
if (typeof outId !== 'string') {
|
|
1954
1946
|
return haltRun({
|
|
1955
|
-
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs, signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts,
|
|
1956
|
-
outcome: 'red', red: `send: step "${step.goal}" reads ask artifact "${askArtifactId}" that was not accepted this run`,
|
|
1947
|
+
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs, signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts, outcome: 'red', red: `send: step "${step.goal}" has no step before it to write out`,
|
|
1957
1948
|
});
|
|
1958
1949
|
}
|
|
1959
|
-
// F48 round 4 (redesign): ONLY an `ok:true` read ships — a missing OR
|
|
1960
|
-
//
|
|
1961
|
-
|
|
1962
|
-
// called, so nothing reaches the signed destination. This is the exact
|
|
1963
|
-
// gap the round 3 fix left open: `readArtifact` returning `undefined`
|
|
1964
|
-
// for both shapes let a swapped/deleted artifact reach `sendStep` as
|
|
1965
|
-
// `undefined`, get `?? null`-ed by src/send.js, and ship as a
|
|
1966
|
-
// recorded-green `null` — a silent "success" for content that was
|
|
1967
|
-
// never verified.
|
|
1968
|
-
const contentResult = readArtifactResult(runDir, askArtifactId);
|
|
1950
|
+
// F48 round 4 (redesign): ONLY an `ok:true` read ships — a missing OR refused (symlink swap / outside the run dir / unparseable JSON) artifact halts the
|
|
1951
|
+
// run BY NAME, before `sendStep` is ever called, so nothing reaches the signed destination.
|
|
1952
|
+
const contentResult = readArtifactResult(runDir, outId);
|
|
1969
1953
|
if (!contentResult.ok) {
|
|
1970
1954
|
return haltRun({
|
|
1971
1955
|
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs, signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts,
|
|
1972
1956
|
outcome: 'red',
|
|
1973
1957
|
red: contentResult.missing
|
|
1974
|
-
? `send:
|
|
1975
|
-
: `send:
|
|
1958
|
+
? `send: artifact "${outId}" is missing for step "${step.goal}" — refusing to send`
|
|
1959
|
+
: `send: artifact "${outId}" for step "${step.goal}" — ${contentResult.red} — refusing to send`,
|
|
1976
1960
|
});
|
|
1977
1961
|
}
|
|
1978
|
-
|
|
1962
|
+
let content = contentResult.value;
|
|
1963
|
+
const decided = decideAction({ acceptedSha: lastAcceptedSha(steps, i, acceptedAskEmitsThisRun), outgoing: content });
|
|
1964
|
+
let shaToSend = decided.outgoingSha;
|
|
1965
|
+
if (!decided.go) {
|
|
1966
|
+
if (stopAcceptedSha !== null && i === i0) {
|
|
1967
|
+
shaToSend = stopAcceptedSha; // the person accepted the stop for this very step: sendViaPrimitive re-hashes what is on disk against it
|
|
1968
|
+
stopAcceptedSha = null;
|
|
1969
|
+
} else {
|
|
1970
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1971
|
+
const stop = await runAskSlot({
|
|
1972
|
+
mcpServer,
|
|
1973
|
+
checkList,
|
|
1974
|
+
step,
|
|
1975
|
+
stepIndex: i,
|
|
1976
|
+
askSlot: { question: decided.question, ttlMs: stopWaitMs(steps, i, askLines, sendSlot.waitMs), kind: ACTION_STOP_KIND },
|
|
1977
|
+
priorId: outId,
|
|
1978
|
+
priorStep: before,
|
|
1979
|
+
priorStepNo: i,
|
|
1980
|
+
priorPrevStepId: i > 1 ? (steps[i - 2].emits ?? null) : null,
|
|
1981
|
+
priorArtifact: content,
|
|
1982
|
+
redoCap,
|
|
1983
|
+
effectiveCeilingUsd,
|
|
1984
|
+
capUsd,
|
|
1985
|
+
primitives,
|
|
1986
|
+
businessDate,
|
|
1987
|
+
modelStep,
|
|
1988
|
+
askStep,
|
|
1989
|
+
spent,
|
|
1990
|
+
spendComplete,
|
|
1991
|
+
recordAudit,
|
|
1992
|
+
evidenceUnjudged: runUnjudged,
|
|
1993
|
+
unjudgedCount: runUnjudged.length,
|
|
1994
|
+
redone: 0,
|
|
1995
|
+
runDir,
|
|
1996
|
+
flowDir,
|
|
1997
|
+
runId,
|
|
1998
|
+
flowRoot,
|
|
1999
|
+
flowName,
|
|
2000
|
+
signatureHash,
|
|
2001
|
+
inputsManifest,
|
|
2002
|
+
attemptsLog,
|
|
2003
|
+
artifacts,
|
|
2004
|
+
now,
|
|
2005
|
+
startedAt,
|
|
2006
|
+
runStartedAt,
|
|
2007
|
+
});
|
|
2008
|
+
if (stop.type === 'paused' || stop.type === 'stopped') return stop.result;
|
|
2009
|
+
if (stop.type === 'halted') {
|
|
2010
|
+
return haltRun({
|
|
2011
|
+
flowDir, runDir, runId, capUsd, startedAt: runStartedAt, now, nowMs, signatureHash, spent, priorSpendComplete: spendComplete.value, attempts: attemptsLog, artifacts, outcome: stop.outcome, red: stop.red,
|
|
2012
|
+
...(stop.stop ? { stop: stop.stop } : {}),
|
|
2013
|
+
resumeAt: { stepIndex: i, flowRoot, flowName, inputsManifest, unjudged: runUnjudged, redone: stop.redone },
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
content = stop.artifact;
|
|
2017
|
+
shaToSend = typeof stop.acceptedSha256 === 'string' ? stop.acceptedSha256 : decided.outgoingSha;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
1979
2020
|
const filename = `${flowName}-${runId}-${step.emits}.md`;
|
|
1980
2021
|
// eslint-disable-next-line no-await-in-loop
|
|
1981
|
-
const sendResult = await sendStep(target, filename, content,
|
|
2022
|
+
const sendResult = await sendStep(target, filename, content, shaToSend, { root: flowRoot, runDir });
|
|
1982
2023
|
const sendRow = makeAuditRow({
|
|
1983
2024
|
step, attempt: 1, verdict: sendResult.ok ? 'green' : 'red', gap: sendResult.ok ? null : sendResult.red, usd: 0, spendComplete: true, wallMs: 0, strike: false, at: now(),
|
|
1984
2025
|
...(sendResult.ok && typeof sendResult.sha256 === 'string' ? { sentSha256: sendResult.sha256 } : {}),
|
|
@@ -2704,8 +2745,10 @@ export async function resumeRun({
|
|
|
2704
2745
|
const effectiveCeilingUsd = holdOf(ceilingUsd);
|
|
2705
2746
|
|
|
2706
2747
|
const step = steps[state.stepIndex];
|
|
2707
|
-
|
|
2708
|
-
const
|
|
2748
|
+
// M13 am11: a run parked at the stop before the action (a signed send step): the one thing shown is the output of the step right before it
|
|
2749
|
+
const isStop = sendLines.has(step.fromLine);
|
|
2750
|
+
const askSlot = isStop ? { question: 'stop before the action', ttlMs: 0, kind: ACTION_STOP_KIND } : askLines.get(step.fromLine);
|
|
2751
|
+
const priorId = isStop ? steps[state.stepIndex - 1]?.emits : (step.reads ?? [])[0];
|
|
2709
2752
|
const priorStepIndex = steps.findIndex((s) => s.emits === priorId);
|
|
2710
2753
|
// `priorId` names a step strictly earlier than the parked ask
|
|
2711
2754
|
// (state.stepIndex), so i < state.stepIndex — already proven `ok` by the
|
|
@@ -2781,14 +2824,17 @@ export async function resumeRun({
|
|
|
2781
2824
|
// accepted — write the ask step's own artifact, then fold on to
|
|
2782
2825
|
// whatever comes next (another signed ask parks again; the ordinary
|
|
2783
2826
|
// send/step path completes exactly as `runFlow` would have, in-process).
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2827
|
+
if (!isStop) {
|
|
2828
|
+
writeArtifact(runDir, step.emits, askResult.artifact);
|
|
2829
|
+
artifacts[step.emits] = askResult.artifact;
|
|
2830
|
+
acceptedAskEmitsThisRun.set(step.emits, askResult.acceptedSha256 ?? null);
|
|
2831
|
+
}
|
|
2787
2832
|
|
|
2788
2833
|
const result = await foldFromStep({
|
|
2789
2834
|
mcpServer: declaration.mcp?.server ?? null,
|
|
2790
2835
|
checkList: declaration.checkList,
|
|
2791
|
-
i0: state.stepIndex + 1,
|
|
2836
|
+
i0: isStop ? state.stepIndex : state.stepIndex + 1,
|
|
2837
|
+
...(isStop ? { stopAcceptedSha: typeof askResult.acceptedSha256 === 'string' ? askResult.acceptedSha256 : null } : {}),
|
|
2792
2838
|
steps,
|
|
2793
2839
|
askLines,
|
|
2794
2840
|
sendLines,
|
package/src/runvalues.js
CHANGED
|
@@ -19,6 +19,7 @@ import { join } from 'node:path';
|
|
|
19
19
|
|
|
20
20
|
import { readFileInside, readdirInside } from './flow.js';
|
|
21
21
|
import { TRIGGER_RECORD_FILE } from './trigger-line.js';
|
|
22
|
+
import { DEFAULT_ACTION_WAIT_MS } from './action-stop.js';
|
|
22
23
|
|
|
23
24
|
export const VALUES_FILE_RE = /^signed-values(?:-r(\d+))?\.json$/;
|
|
24
25
|
|
|
@@ -50,6 +51,8 @@ export function flowValues(arbiter) {
|
|
|
50
51
|
const sends = arbiter.sends ?? [];
|
|
51
52
|
const destination = sends.length === 1 && sends[0].target?.kind === 'file' ? String(sends[0].target.path) : null;
|
|
52
53
|
const askWaits = Object.fromEntries((arbiter.asks ?? []).map((a) => [String(a.line), waitText(a.ttlMs)]));
|
|
54
|
+
// M13 am11a 2: a job with an action and no Ask line keeps the card's Ask wait (1h unless changed) under the action's line, signed with the Destination and the Cap in the same two clicks
|
|
55
|
+
if ((arbiter.asks ?? []).length === 0 && sends.length === 1) askWaits[String(sends[0].line)] = waitText(DEFAULT_ACTION_WAIT_MS);
|
|
53
56
|
return { capUsd: arbiter.capUsd, destination, askWaits };
|
|
54
57
|
}
|
|
55
58
|
|
|
@@ -169,7 +172,12 @@ export function applyRunValues(arbiter, flow, flowSignatureHash, picked) {
|
|
|
169
172
|
arbiter: {
|
|
170
173
|
...arbiter,
|
|
171
174
|
capUsd: v.capUsd,
|
|
172
|
-
sends: (arbiter.sends ?? []).map((s) => (
|
|
175
|
+
sends: (arbiter.sends ?? []).map((s) => ({
|
|
176
|
+
...s,
|
|
177
|
+
...(v.destination === null ? {} : { target: { ...s.target, path: v.destination } }),
|
|
178
|
+
// M13 am11a: the stop before the action waits this long when the job has no Ask line
|
|
179
|
+
...((arbiter.asks ?? []).length === 0 && v.askWaits[String(s.line)] !== undefined ? { waitMs: parseWaitMs(v.askWaits[String(s.line)]) } : {}),
|
|
180
|
+
})),
|
|
173
181
|
asks: (arbiter.asks ?? []).map((a) => ({ ...a, ttlMs: parseWaitMs(v.askWaits[String(a.line)]), ttlSigned: true })),
|
|
174
182
|
},
|
|
175
183
|
};
|
package/src/setup.js
CHANGED
|
@@ -72,6 +72,8 @@ function humanRows(sessionDir, rel) {
|
|
|
72
72
|
const answered = readQuestions(join(sessionDir, rel)).questions.filter((q) => q.answer !== null).map((q) => (q.source === 'look' ? {
|
|
73
73
|
kind: 'human', n: q.k, at: q.at ?? null, source: 'look', ask: q.ask, question: q.question, answer: q.answer, line: q.line,
|
|
74
74
|
ruleNo: q.ruleNo, ruleText: q.ruleText, proposal: q.proposal ?? null, rule: q.rule ?? null, ...(q.choice === undefined ? {} : { choice: q.choice }),
|
|
75
|
+
// M17 am8: the decided words ride the row (the signed rule on Agree, the typed text on a new rule, none on Drop it), so the Audit never reads the question
|
|
76
|
+
...(q.choice === 'agree' && typeof q.rule === 'string' ? { words: q.rule } : q.choice === 'rule' ? { words: q.answer } : {}),
|
|
75
77
|
} : {
|
|
76
78
|
// M14 am3: a question the drafter raised and the person answered is the same row, with no look-only fields (so no picked label)
|
|
77
79
|
kind: 'human', n: q.k, at: q.at ?? null, question: q.question, answer: q.answer, line: q.line,
|
package/src/sheetbuild.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// One writer per field: `id`, `claim`, `covers` and `table` (when absent and the line reads one sheet) are assigned here. A rule row's id is `l<line>r<rules>`, an agent row's `l<line>a<k>`; the claim is the id.
|
|
10
10
|
// What this throws away: a suggestion's `id`, `claim`, `text` (and its `covers`: an agent row's is only the rule no rule row holds); a refused suggestion's check (only its reason is kept, on the rules it named).
|
|
11
11
|
// Third outcomes, named: a suggestion that is not an object, names no rule or op bareguard has, a table it cannot read, a column that is no header: refused with that helper's words; a rule that no
|
|
12
|
-
// check holds is Not checked with the last refusal that named it, or the no-pick sentence (`
|
|
12
|
+
// check holds is Not checked with the last refusal that named it, or the no-pick sentence (`NO_VALUE_WHY`).
|
|
13
13
|
import { rubricVocabulary, claimSchema, groundedLiterals } from 'bareguard';
|
|
14
14
|
import { SHEET_RULES, sheetCheckColumns, sheetCheckReds, bareguardChecks } from './sheetchecks.js';
|
|
15
15
|
import { tableChecksFailingOnInput } from './sheetrun.js';
|
|
@@ -24,9 +24,6 @@ const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object'
|
|
|
24
24
|
/** the fields of a suggestion code does not read: it names every check itself */
|
|
25
25
|
export const SUGGESTION_DROPPED = Object.freeze(['id', 'claim', 'text', 'covers']);
|
|
26
26
|
|
|
27
|
-
/** M17 am7 item 2: the words of a rule no check holds and nothing refused: the one no-pick sentence (src/ticketrows.js), not a third copy */
|
|
28
|
-
export const NO_SUGGESTION = NO_VALUE_WHY;
|
|
29
|
-
|
|
30
27
|
/**
|
|
31
28
|
* @param {any} ai a suggestion as the AI sent it @returns {{covers: number[], fields: Record<string, any>}}
|
|
32
29
|
*/
|
|
@@ -102,7 +99,7 @@ export async function buildSheetLine({ line, tables, suggestions }) {
|
|
|
102
99
|
if (isColumnChoiceRule(text)) return { rule: n, text, state: 'column', reason: null, id: null };
|
|
103
100
|
if (held.has(n)) return { rule: n, text, state: 'built', reason: null, id: /** @type {string} */ (held.get(n)) };
|
|
104
101
|
if (coveredByAgent.has(n)) return { rule: n, text, state: 'agent-row', reason: null, id: /** @type {string} */ (coveredByAgent.get(n)) };
|
|
105
|
-
return { rule: n, text, state: 'not-checked', reason: refusedFor.get(n) ??
|
|
102
|
+
return { rule: n, text, state: 'not-checked', reason: refusedFor.get(n) ?? NO_VALUE_WHY, id: null };
|
|
106
103
|
});
|
|
107
104
|
return { rows, ruleRows, agentRows, checks: [...ruleRows, ...agentRows].map((p) => p.check), refused };
|
|
108
105
|
}
|
|
@@ -111,7 +108,7 @@ export async function buildSheetLine({ line, tables, suggestions }) {
|
|
|
111
108
|
* The declaration with every green sheet step's `close.sheet` REWRITTEN by code from what the AI suggested there (`buildSheetLine`). A step with no suggestion is left alone; a step none of whose
|
|
112
109
|
* suggestions can be built loses `close.sheet` (its rules are Not checked with their reasons). Pure over the declaration it is given (a copy is returned).
|
|
113
110
|
* @param {{declaration: any, lines: {n: number, text?: string, rules?: string[], guardrail?: string, rule?: string}[], tables: Record<string, {header: string[], rows: any[]}>}} o
|
|
114
|
-
* @returns {Promise<{declaration: any, notChecked: Record<string, string>, refused: {line: number, helper: string, why: string}[], unbuilt: {line: number, lost: string[]}[]}>} `unbuilt`: the green sheet steps left with no check, each with its rules as Not-checked lines. `notChecked`: `line N: "rule"` -> the refusal that named it (or `
|
|
111
|
+
* @returns {Promise<{declaration: any, notChecked: Record<string, string>, refused: {line: number, helper: string, why: string}[], unbuilt: {line: number, lost: string[]}[]}>} `unbuilt`: the green sheet steps left with no check, each with its rules as Not-checked lines. `notChecked`: `line N: "rule"` -> the refusal that named it (or `NO_VALUE_WHY`), for each rule of a
|
|
115
112
|
* rewritten line that no check holds
|
|
116
113
|
*/
|
|
117
114
|
export async function buildSheetChecks({ declaration, lines, tables }) {
|
|
@@ -145,7 +142,7 @@ export async function buildSheetChecks({ declaration, lines, tables }) {
|
|
|
145
142
|
const line = lines.find((l) => l.n === st.fromLine);
|
|
146
143
|
const rules = line ? rulesOfLine(line).filter((r) => !isColumnChoiceRule(r)) : [];
|
|
147
144
|
if (rules.length === 0) continue;
|
|
148
|
-
unbuilt.push({ line: st.fromLine, lost: rules.map((r) => `line ${st.fromLine}: "${r}" \u2014 ${notChecked[`line ${st.fromLine}: "${r}"`] ??
|
|
145
|
+
unbuilt.push({ line: st.fromLine, lost: rules.map((r) => `line ${st.fromLine}: "${r}" \u2014 ${notChecked[`line ${st.fromLine}: "${r}"`] ?? NO_VALUE_WHY}`) });
|
|
149
146
|
}
|
|
150
147
|
return { declaration: { ...declaration, steps }, notChecked, refused, unbuilt };
|
|
151
148
|
}
|
package/src/sheetlook.js
CHANGED
|
@@ -112,7 +112,7 @@ export function applySheetWords(text, words, jobLines, label) {
|
|
|
112
112
|
if (found.kind === 'tie') { dropped.push({ ...rec, reason: 'column-tie', other: found.columns.map((c) => `"${c}"`).join(', ') }); continue; }
|
|
113
113
|
if (found.kind === 'none') { dropped.push({ ...rec, reason: 'no-fit', other: String(found.rows) }); continue; }
|
|
114
114
|
// the person already named this column in a rule of the line (an answer they gave, or their own words): the word is that column, asked no more
|
|
115
|
-
if (rules.some((r
|
|
115
|
+
if (rules.some((r) => countPhrase(r, found.column) > 0)) { facts.push(fact(found.column)); continue; }
|
|
116
116
|
if (at.rule !== undefined) ruleWords.add(`${at.line}\u0000${w.word.toLowerCase()}`);
|
|
117
117
|
if (at.rule !== undefined && tiedRules.has(`${at.line}\u0000${at.rule}`)) continue;
|
|
118
118
|
// F196: the line's prose word that a tied `~` rule of the line also says is settled by that rule (one word, one question, whichever the look tied the ask to)
|
package/src/signed-text.js
CHANGED
|
@@ -442,11 +442,7 @@ function parseArbiter(arbiterRawLines, lineNumbers, reds, asks) {
|
|
|
442
442
|
reds.push(`arbiter: field "trigger" names the input "${trigger.role}", which is not one of the job's inputs (inputs: [${[...sourceRolesSeen].join(', ')}])`);
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
|
|
446
|
-
if (!asks.some((a) => a.line < s.line)) {
|
|
447
|
-
reds.push(`arbiter: field "sends" send at line ${s.line} has no ask at an earlier line (asks: [${asks.map((a) => a.line).join(', ')}])`);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
445
|
+
// M13 am11: the action (a send) needs no Ask before it; what goes out is checked at run time against the last accept (or stops once)
|
|
450
446
|
|
|
451
447
|
return {
|
|
452
448
|
capUsd,
|