bareloop 0.56.0 → 0.58.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 +80 -0
- package/README.md +3 -3
- package/bareloop.context.md +75 -214
- package/package.json +2 -2
- package/src/authorflow.js +71 -136
- package/src/authoring.js +5 -124
- package/src/authorjob.js +125 -417
- package/src/authorreadout.js +105 -355
- package/src/authorrun.js +70 -234
- package/src/authorscout.js +9 -1
- package/src/blockasks.js +12 -17
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +297 -75
- package/src/checklist.js +1 -1
- package/src/checkpick.js +9 -5
- package/src/cli.js +3 -3
- package/src/declaredclose.js +45 -112
- package/src/destpoint.js +1 -1
- package/src/draftspend.js +20 -4
- package/src/fencepointcall.js +76 -0
- package/src/guarddescriptions.js +14 -0
- package/src/index.js +3 -43
- package/src/interviewrun.js +13 -8
- package/src/job.js +20 -1
- package/src/jobblock.js +11 -46
- package/src/judged.js +13 -1229
- package/src/kinds.js +10 -348
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +7 -29
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +15 -4
- package/src/panel/authorsession.js +201 -167
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +43 -18
- package/src/panel/jobplan.js +54 -19
- package/src/panel/server.js +90 -69
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +15 -54
- package/src/planrun.js +4 -48
- package/src/promptregisters.js +7 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +34 -30
- package/src/reviewdoor.js +1 -1
- package/src/rowresults.js +69 -0
- package/src/rubricstep.js +136 -28
- package/src/run.js +2 -15
- package/src/stagewords.js +24 -0
- package/src/userrun.js +14 -111
- package/types/authorflow.d.ts +51 -137
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +14 -55
- package/types/authorreadout.d.ts +52 -80
- package/types/authorrun.d.ts +20 -0
- package/types/blockasks.d.ts +5 -11
- package/types/checkblock.d.ts +147 -28
- package/types/checklist.d.ts +2 -2
- package/types/checkpick.d.ts +5 -3
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +5 -33
- package/types/draftspend.d.ts +16 -2
- package/types/fencepointcall.d.ts +68 -0
- package/types/guarddescriptions.d.ts +7 -0
- package/types/index.d.ts +2 -4
- package/types/job.d.ts +8 -0
- package/types/jobblock.d.ts +8 -38
- package/types/judged.d.ts +7 -357
- package/types/kinds.d.ts +4 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagemap.d.ts +2 -5
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +37 -5
- package/types/panel/jobplan.d.ts +15 -3
- package/types/panel/server.d.ts +46 -13
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +8 -13
- package/types/planrun.d.ts +1 -22
- package/types/providerrows.d.ts +0 -31
- package/types/providers.d.ts +3 -19
- package/types/questionbox.d.ts +20 -6
- package/types/rowresults.d.ts +23 -0
- package/types/rubricstep.d.ts +43 -7
- package/types/run.d.ts +1 -20
- package/types/stagewords.d.ts +11 -0
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -168
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -119
package/src/authorreadout.js
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
import { scrubRaw } from './text.js';
|
|
27
27
|
import { panelMoney2 } from './panelmoney.js';
|
|
28
28
|
import { redactSecrets } from './validate.js';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
29
|
+
import { cardOfClose, fenceOfClose, fenceRowText, refusedOf, stepFileRel, lineRules, FENCE_KEY } from './rubricstep.js';
|
|
30
|
+
import { decidedWords } from './draftspend.js';
|
|
31
|
+
import { ticketFilterWords } from './ticketfilter.js';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* @param {{goal?: string|null, closeDecl?: any}} spec the RESOLVED spec — the bytes
|
|
@@ -68,42 +68,6 @@ export function fellBackLines(authoring) {
|
|
|
68
68
|
return [`FELL BACK ${fb.from} broke ${fb.brokenStages?.length ?? 0} check(s) (${stages}) — kept ${fb.to} instead`];
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
/**
|
|
72
|
-
* THE TWO SIGNED JUDGED ARTIFACTS, as a person reads them before signing
|
|
73
|
-
* (softgreen modules 4+5). Absent on a close that judges nothing, which is why
|
|
74
|
-
* this returns an EMPTY list rather than a "no card" line: a green close has no
|
|
75
|
-
* rubric and saying so every run is noise, not information.
|
|
76
|
-
*
|
|
77
|
-
* The CARD is printed in full — it is short, it is the whole standard the judge
|
|
78
|
-
* will hold the work to, and it is the signer's own words. The CASES are printed
|
|
79
|
-
* as a ROSTER (id, verdict, itemized reds) rather than in full: ten real source
|
|
80
|
-
* artifacts is a page of code the terminal cannot usefully show, and what a
|
|
81
|
-
* signer checks at this surface is that both polarities are there and that each
|
|
82
|
-
* red names something they recognise. The artifacts themselves are in the spec
|
|
83
|
-
* file, which is named right above this block.
|
|
84
|
-
* @param {{closeDecl?: any}} spec the RESOLVED spec
|
|
85
|
-
* @returns {string[]}
|
|
86
|
-
*/
|
|
87
|
-
export function rubricLines({ closeDecl }) {
|
|
88
|
-
const judged = judgedStages(closeDecl);
|
|
89
|
-
if (!judged.length) return [];
|
|
90
|
-
/** @type {string[]} */
|
|
91
|
-
const lines = ['rubric card (what the judge will hold the work to — YOUR words, signed)'];
|
|
92
|
-
for (const it of judged[0]?.params?.card?.items ?? []) lines.push(` [${it.rule}] ${it.text}`);
|
|
93
|
-
const cases = closeDecl?.calibration?.cases ?? null;
|
|
94
|
-
if (cases === null) {
|
|
95
|
-
lines.push('calibration NONE STORED — a judged close is not signable without one');
|
|
96
|
-
return lines;
|
|
97
|
-
}
|
|
98
|
-
const pass = cases.filter((/** @type {any} */ c) => c?.expect?.verdict === 'pass').length;
|
|
99
|
-
lines.push(`calibration set (${cases.length} case(s): ${pass} pass, ${cases.length - pass} red)`);
|
|
100
|
-
for (const c of cases) {
|
|
101
|
-
const reds = (c?.expect?.reds ?? []).map((/** @type {any} */ r) => `${r.rule}@${r.fn}`).join(', ');
|
|
102
|
-
lines.push(` ${String(c?.expect?.verdict ?? '?').padEnd(4)} ${c?.id}${reds ? ` → ${reds}` : ''}`);
|
|
103
|
-
}
|
|
104
|
-
return lines;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
71
|
/**
|
|
108
72
|
* THE CONFIRM TURN'S OPEN QUESTIONS (PRD item 33 M3 piece 4, ruling 5's D3
|
|
109
73
|
* addendum) — shown at the SIGNING readout, from `authored.json`'s own
|
|
@@ -145,104 +109,6 @@ export function answeredQuestionLines(confirmed) {
|
|
|
145
109
|
return lines;
|
|
146
110
|
}
|
|
147
111
|
|
|
148
|
-
/** a quote for a human line: one line, cut at `max` with the cut VISIBLE
|
|
149
|
-
* @param {unknown} q @param {number} [max] @returns {string} */
|
|
150
|
-
function shortQuote(q, max = 80) {
|
|
151
|
-
const one = String(q ?? '').replace(/\s+/g, ' ').trim();
|
|
152
|
-
return one.length > max ? `${one.slice(0, max)}…[truncated, ${one.length} chars]` : one;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* ONE plain line saying WHY a graded case reds, read off its own `diag` (F192):
|
|
157
|
-
* the first red's rule, function, `why` and quoted text — and how many more the
|
|
158
|
-
* record holds. A case with no reds says why it has none (no facts: each
|
|
159
|
-
* attempt's axis and cause). Null when the row predates `diag`.
|
|
160
|
-
* @param {any} row a `graded` or `injection.styles` row
|
|
161
|
-
* @returns {string|null}
|
|
162
|
-
*/
|
|
163
|
-
function diagLine(row) {
|
|
164
|
-
const d = row?.diag;
|
|
165
|
-
if (!d) return null;
|
|
166
|
-
const first = d.reds?.[0];
|
|
167
|
-
if (first) {
|
|
168
|
-
const more = d.reds.length > 1 ? ` (+${d.reds.length - 1} more red(s) in signing.json)` : '';
|
|
169
|
-
return ` why: ${first.rule} · ${first.fn} — ${first.why}; quote: ${first.quote === null ? '(none)' : `"${shortQuote(first.quote)}"`}${more}`;
|
|
170
|
-
}
|
|
171
|
-
const failed = (d.attempts ?? []).filter((/** @type {any} */ a) => !a.ok);
|
|
172
|
-
if (failed.length) {
|
|
173
|
-
return ` why: no facts — ${failed.map((/** @type {any} */ a) => `attempt ${a.attempt} [${a.axis}] ${shortQuote(a.detail, 120)}`).join('; ')}`;
|
|
174
|
-
}
|
|
175
|
-
return d.reason ? ` why: ${shortQuote(d.reason, 120)}` : null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* THE CALIBRATION GATE'S OWN READOUT — the one gate that spends money, and the
|
|
180
|
-
* one whose rows a signer has to read case by case.
|
|
181
|
-
*
|
|
182
|
-
* ITEMIZED, never an aggregate percentage: "9/10" tells a person nothing about
|
|
183
|
-
* which line of their own rubric is wrong, and the fix for a miss is a card line
|
|
184
|
-
* or a corrected case (§4.3's ceiling). A CASUALTY prints under its own name and
|
|
185
|
-
* says so, because a dead judge is not a failed set.
|
|
186
|
-
* @param {any} calibration `signing.gates.calibration`
|
|
187
|
-
* @returns {string[]}
|
|
188
|
-
*/
|
|
189
|
-
export function calibrationLines(calibration) {
|
|
190
|
-
if (!calibration) return [' 4 calibration not reached'];
|
|
191
|
-
if (calibration.stop === 'calibration-missing') {
|
|
192
|
-
return [' 4 calibration FAIL — this close judges, and no calibration set is stored with it'];
|
|
193
|
-
}
|
|
194
|
-
if (calibration.stop === 'no-judge') {
|
|
195
|
-
return [' 4 calibration FAIL — no judge seam was wired, so the gate never ran (a wiring gap, never a pass)'];
|
|
196
|
-
}
|
|
197
|
-
const graded = calibration.graded ?? [];
|
|
198
|
-
const styles = calibration.injection?.styles ?? [];
|
|
199
|
-
/** @type {string[]} */
|
|
200
|
-
const lines = [` 4 calibration ${calibration.ok ? 'PASS' : 'FAIL'} — ${graded.filter((/** @type {any} */ g) => g.ok).length}/`
|
|
201
|
-
+ `${graded.length} case(s) graded correctly, ${styles.filter((/** @type {any} */ s) => s.resisted).length}/${styles.length} `
|
|
202
|
-
+ `injection style(s) resisted [judge ${calibration.judgeModel}]`];
|
|
203
|
-
if (calibration.casualty) {
|
|
204
|
-
lines.push(` CASUALTY on ${calibration.casualty.kind} "${calibration.casualty.at}" [${calibration.casualty.axis}] `
|
|
205
|
-
+ '— a broken judge is no evidence about the set');
|
|
206
|
-
const cl = diagLine(calibration.casualty);
|
|
207
|
-
if (cl) lines.push(cl);
|
|
208
|
-
}
|
|
209
|
-
for (const g of graded.filter((/** @type {any} */ x) => !x.ok)) {
|
|
210
|
-
lines.push(` WRONG ${g.id}: ${g.detail}`);
|
|
211
|
-
const l = diagLine(g);
|
|
212
|
-
if (l) lines.push(l);
|
|
213
|
-
}
|
|
214
|
-
for (const s of styles.filter((/** @type {any} */ x) => !x.resisted)) {
|
|
215
|
-
lines.push(` LEAK ${s.style}: ${s.detail}`);
|
|
216
|
-
const l = diagLine(s);
|
|
217
|
-
if (l) lines.push(l);
|
|
218
|
-
}
|
|
219
|
-
lines.push(` certified card ${String(calibration.cardHash ?? 'unknown').slice(0, 12)} cases `
|
|
220
|
-
+ `${String(calibration.casesHash ?? 'unknown').slice(0, 12)} set ${String(calibration.setHash ?? 'unknown').slice(0, 12)}`);
|
|
221
|
-
return lines;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* The calibration gate's real result as one line a person reads next to the step (hamr, 2026-10-09: the panel
|
|
226
|
-
* showed `calibrating ✓` over a gate that graded 8 of 10 and let 2 attack styles leak). PASS IS THE GATE'S OWN:
|
|
227
|
-
* `ok` is `calibration.ok` as `runCalibration` decided it (every case right as a SET of reds, every style
|
|
228
|
-
* resisted), never recomputed here, so there is no second spelling of the floor. The counts are read from the
|
|
229
|
-
* record (`graded[].ok` is `compareExpectation`, which compares reds as sets); the denominators are the live
|
|
230
|
-
* constants (CALIBRATION_SIZE, the battery length), so a gate that stopped part-way reads "x of 10", not "x of x".
|
|
231
|
-
* @param {any} calibration `signing.gates.calibration`
|
|
232
|
-
* @returns {{ok: boolean, note: string}|null} null when the gate was not reached
|
|
233
|
-
*/
|
|
234
|
-
export function calibrationSummary(calibration) {
|
|
235
|
-
if (!calibration || typeof calibration !== 'object') return null;
|
|
236
|
-
const graded = Array.isArray(calibration.graded) ? calibration.graded : [];
|
|
237
|
-
const styles = Array.isArray(calibration.injection?.styles) ? calibration.injection.styles : [];
|
|
238
|
-
const right = graded.filter((/** @type {any} */ g) => g?.ok === true).length;
|
|
239
|
-
const resisted = styles.filter((/** @type {any} */ x) => x?.resisted === true).length;
|
|
240
|
-
return {
|
|
241
|
-
ok: calibration.ok === true,
|
|
242
|
-
note: `${right} of ${CALIBRATION_SIZE} practice cases graded right · ${resisted} of ${INJECTION_LOCATE_BATTERY.length} attack tests resisted`,
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
112
|
/**
|
|
247
113
|
* THE AUTHORING CEILING, parsed from `--budget`. Housed here for the same reason
|
|
248
114
|
* the readout above is: the runner is a script, and a rule no test can reach is a
|
|
@@ -316,6 +182,8 @@ export function phaseLine(phase, data = {}) {
|
|
|
316
182
|
case 'scout-done': return `· scout ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s)`;
|
|
317
183
|
case 'look': return '· looking at your input — a read-only search for the facts the job asks for…';
|
|
318
184
|
case 'look-done': return `· look ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s) can be checked`;
|
|
185
|
+
case 'fence-point': return '· pointing at the files your rules keep as they are…';
|
|
186
|
+
case 'fence-point-done': return data.reason ? `· pointing failed (${data.reason}); those rules are asked about` : `· ${data.kept ?? 0} of ${data.sent ?? 0} pointer(s) proved by code`;
|
|
319
187
|
case 'ledger-suggest': return '· suggesting extra checks from your input…';
|
|
320
188
|
case 'ledger-built': { const rows = Array.isArray(data.rows) ? data.rows : []; const not = rows.filter((/** @type {any} */ r) => r.state === 'not-checked').length; return `· the list of checks: ${rows.length} row(s), ${not} not checked`; }
|
|
321
189
|
case 'draft-ledger-try': return `· ${data.label}: ${data.kept ?? '?'} edit(s) kept, ${(data.refused ?? []).length} refused`;
|
|
@@ -328,11 +196,6 @@ export function phaseLine(phase, data = {}) {
|
|
|
328
196
|
case 'seed-read': return `· measuring ${data.stages ?? '?'} stage(s) at the seed — each one runs a real toolchain…`;
|
|
329
197
|
case 'stage': return `· ${data.stage} [${data.kind}] ${data.verdict} — ${ms(data.durationMs)}`;
|
|
330
198
|
case 'seed-read-done': return `· seed read done (${data.stages ?? '?'} stage(s))`;
|
|
331
|
-
// softgreen modules 4+5: the compile, and the paid gate that grades it
|
|
332
|
-
case 'rubric': return `· compiling the rubric card and ${data.size ?? '?'} calibration cases from your own answers…`;
|
|
333
|
-
case 'rubric-done': return `· rubric ${data.ok ? 'compiled' : `NOT compiled (${data.stop ?? 'unknown'})`} after ${data.attempts ?? '?'} attempt(s)`;
|
|
334
|
-
case 'rubric-scrubbed': return `· MASKED before storing: ${(data.paths ?? []).join(', ')} — the stored bytes differ from what was typed`;
|
|
335
|
-
case 'calibration': return `· calibration gate: ${data.cases ?? '?'} case(s) + ${data.styles ?? '?'} injection style(s), one real judge call each…`;
|
|
336
199
|
// A phase this renderer does not know is PRINTED, not swallowed: the callers
|
|
337
200
|
// are the library's own seams and a new one appearing unrendered is how a
|
|
338
201
|
// readout silently stops covering what it reports on.
|
|
@@ -413,12 +276,6 @@ const PLAIN_MAX_BULLETS = 8;
|
|
|
413
276
|
const RECORD_MAX_REDS = 40;
|
|
414
277
|
const RECORD_STR_MAX = 600;
|
|
415
278
|
|
|
416
|
-
// Each of these two finds its text on the FIRST line that has it, anchored to a line start: a lazy (.*?) that
|
|
417
|
-
// fails runs to the end of its line, and the same pattern retried at every later start on that line fails the
|
|
418
|
-
// same way (the later text is a part of the earlier one's), so retrying them only made the read quadratic.
|
|
419
|
-
const MISSING_REDS_RE = /(?<=^|[\n\r\u2028\u2029])(?:(?!expected red\(s\) the pipe did not raise: )[^\n\r\u2028\u2029])*expected red\(s\) the pipe did not raise: (.*?)(?: — |\. The floor)/;
|
|
420
|
-
const EXTRA_REDS_RE = /(?<=^|[\n\r\u2028\u2029])(?:(?!red\(s\) the pipe raised that nobody signed: )[^\n\r\u2028\u2029])*red\(s\) the pipe raised that nobody signed: (.*?)(?: — |\. The floor)/;
|
|
421
|
-
|
|
422
279
|
/** a code-written sentence that carries the person's own words (a rubric-step sorting red): scrubbed and one line, bounded wide enough to stay whole
|
|
423
280
|
* @param {unknown} s @returns {string} */
|
|
424
281
|
function fullText(s) {
|
|
@@ -459,85 +316,16 @@ function rubricShapeSentence(r) {
|
|
|
459
316
|
}
|
|
460
317
|
|
|
461
318
|
/**
|
|
462
|
-
* The ONE table of plain kinds → sentence builders. A builder gets the red
|
|
463
|
-
* name of the case it lands on (when it lands on one) and the match of the
|
|
464
|
-
* regex that picked it. `unmapped` is the only kind the table does not list.
|
|
319
|
+
* The ONE table of plain kinds → sentence builders. A builder gets the red. `unmapped` is the only kind the table does not list.
|
|
465
320
|
* Order matters: the first matching entry wins.
|
|
466
|
-
* @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed
|
|
321
|
+
* @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed) => string}[]}
|
|
467
322
|
*/
|
|
468
323
|
const PLAIN_TABLE = [
|
|
469
|
-
// ── the rubric card (validateCard, surfaced as code invalid-value at path "card") ──
|
|
470
|
-
{ kind: 'card-not-object', when: (r) => r.code === 'invalid-value' && /^the card must be an object/.test(r.detail),
|
|
471
|
-
say: () => 'The model did not hand back a rubric in the expected shape.' },
|
|
472
|
-
{ kind: 'card-empty', when: (r) => r.code === 'invalid-value' && /^the card must carry a non-empty/.test(r.detail),
|
|
473
|
-
say: () => 'The model\'s rubric has no rules in it.' },
|
|
474
|
-
{ kind: 'card-line-bad', when: (r) => r.code === 'invalid-value' && /^card item \d+: must be an object/.test(r.detail),
|
|
475
|
-
say: (r) => `Rubric line ${cardLineNo(r)} is not a proper line.` },
|
|
476
|
-
{ kind: 'card-line-no-rule', when: (r) => r.code === 'invalid-value' && /^card item \d+: needs a `rule`/.test(r.detail),
|
|
477
|
-
say: (r) => `Rubric line ${cardLineNo(r)} does not pick which rule it uses.` },
|
|
478
|
-
{ kind: 'card-line-unknown-rule', when: (r) => r.code === 'invalid-value' && /^card item \d+: `.*` is not a rule this arbiter implements/.test(r.detail),
|
|
479
|
-
say: (r, _c, _m) => `Rubric line ${cardLineNo(r)} names a rule bareloop does not have (${safeText(/`(.*?)` is not a rule/.exec(r.detail)?.[1] ?? '')}).` },
|
|
480
|
-
{ kind: 'card-line-repeat', when: (r) => r.code === 'invalid-value' && /^card item \d+: `.*` is named twice/.test(r.detail),
|
|
481
|
-
say: (r) => `Rubric line ${cardLineNo(r)} uses a rule that an earlier line already uses.` },
|
|
482
|
-
{ kind: 'card-line-no-text', when: (r) => r.code === 'invalid-value' && /^card item \d+: needs `text`/.test(r.detail),
|
|
483
|
-
say: (r) => `Rubric line ${cardLineNo(r)} has no wording.` },
|
|
484
324
|
// Part 1b live fix B3: the rubric-step reds are whole sentences already (src/rubricstep.js); a shape red on its parameters is worded here
|
|
485
325
|
{ kind: 'rubric-red', when: (r) => r.code.startsWith('rubric-'), say: (r) => fullText(r.detail) },
|
|
486
326
|
{ kind: 'rubric-shape', when: isRubricShape, say: (r) => rubricShapeSentence(r) },
|
|
487
|
-
{ kind: 'proposal-not-object', when: (r) => r.code === 'invalid-value' && r.path === 'proposal',
|
|
488
|
-
say: () => 'The model\'s answer was not a rubric plus practice cases.' },
|
|
489
|
-
// ── the practice-case set as a whole ──
|
|
490
|
-
{ kind: 'set-no-rules', when: (r) => r.code === 'calibration-cardless',
|
|
491
|
-
say: () => 'The rubric has no rules, so the practice cases had nothing to be checked against.' },
|
|
492
|
-
{ kind: 'set-not-list', when: (r) => r.code === 'calibration-size' && !('declared' in r),
|
|
493
|
-
say: () => `The practice cases did not come back as a list of ${CALIBRATION_SIZE}.` },
|
|
494
|
-
{ kind: 'set-size', when: (r) => r.code === 'calibration-size',
|
|
495
|
-
say: (r) => `The model gave ${r.declared} practice case${r.declared === 1 ? '' : 's'}; exactly ${r.required ?? CALIBRATION_SIZE} are needed.` },
|
|
496
|
-
{ kind: 'set-one-sided', when: (r) => r.code === 'calibration-polarity',
|
|
497
|
-
say: (r) => `The practice cases were ${r.passes} pass and ${r.reds} fail; the set needs at least one of each, or it cannot tell a working judge from one that always gives the same answer.` },
|
|
498
|
-
// ── one practice case ──
|
|
499
|
-
{ kind: 'case-not-object', when: (r) => r.code === 'calibration-case' && /^calibration\.cases\[\d+\]$/.test(r.path),
|
|
500
|
-
say: (_r, c) => `${c} is not a proper case.` },
|
|
501
|
-
{ kind: 'case-name-repeat', when: (r) => r.code === 'calibration-case' && /\.id$/.test(r.path) && /declared twice/.test(r.detail),
|
|
502
|
-
say: (_r, c) => `Two practice cases share the name ${c}.` },
|
|
503
|
-
{ kind: 'case-name-bad', when: (r) => r.code === 'calibration-case' && /\.id$/.test(r.path),
|
|
504
|
-
say: (_r, c) => `${c} has no usable name (a short name in lowercase letters, digits and hyphens is needed).` },
|
|
505
|
-
{ kind: 'case-code-repeat', when: (r) => r.code === 'calibration-case' && /\.artifact$/.test(r.path) && /used twice/.test(r.detail),
|
|
506
|
-
say: (_r, c) => `${c} reuses the same sample code as another case.` },
|
|
507
|
-
{ kind: 'case-code-missing', when: (r) => r.code === 'calibration-case' && /\.artifact$/.test(r.path),
|
|
508
|
-
say: (_r, c) => `${c} has no sample code to look at.` },
|
|
509
|
-
{ kind: 'case-impossible-no-doc', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path) && /expects has-doc red on/.test(r.detail),
|
|
510
|
-
say: (r, c) => {
|
|
511
|
-
const fn = safeText(/expects has-doc red on (\S+?),/.exec(r.detail)?.[1] ?? 'a function');
|
|
512
|
-
return `${c} says "fail: no doc comment" on ${fn}, but ${fn} has a doc comment right above it.`;
|
|
513
|
-
} },
|
|
514
|
-
{ kind: 'case-pass-lists-fails', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path) && /^a PASS case expects no reds/.test(r.detail),
|
|
515
|
-
say: (_r, c) => `${c} is marked as a pass but also lists things that fail.` },
|
|
516
|
-
{ kind: 'case-fail-lists-nothing', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path) && /^a RED case names WHICH/.test(r.detail),
|
|
517
|
-
say: (_r, c) => `${c} is marked as a fail but does not say which rule or function fails.` },
|
|
518
|
-
{ kind: 'case-fails-not-list', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path),
|
|
519
|
-
say: (_r, c) => `${c} does not give its expected failures as a list.` },
|
|
520
|
-
{ kind: 'case-no-expected', when: (r) => r.code === 'calibration-case' && /\.expect$/.test(r.path),
|
|
521
|
-
say: (_r, c) => `${c} has no expected result.` },
|
|
522
|
-
{ kind: 'case-verdict-bad', when: (r) => r.code === 'calibration-case' && /\.expect\.verdict$/.test(r.path),
|
|
523
|
-
say: (_r, c) => `${c} expects a result that is neither pass nor fail.` },
|
|
524
|
-
{ kind: 'case-fail-malformed', when: (r) => r.code === 'calibration-case' && /\.reds\[\d+\]$/.test(r.path) && /^an expected red is/.test(r.detail),
|
|
525
|
-
say: (_r, c) => `${c} has an expected failure that is not written as a rule and a function.` },
|
|
526
|
-
{ kind: 'case-fail-repeat', when: (r) => r.code === 'calibration-case' && /\.reds\[\d+\]$/.test(r.path),
|
|
527
|
-
say: (_r, c) => `${c} lists the same failure twice.` },
|
|
528
|
-
{ kind: 'case-fail-rule-foreign', when: (r) => r.code === 'calibration-case' && /\.rule$/.test(r.path) && typeof r.rule === 'string',
|
|
529
|
-
say: (r, c) => `${c} expects a failure from the rule "${safeText(r.rule)}", which this rubric does not use.` },
|
|
530
|
-
{ kind: 'case-fail-rule-missing', when: (r) => r.code === 'calibration-case' && /\.rule$/.test(r.path),
|
|
531
|
-
say: (_r, c) => `${c} has an expected failure with no rule named.` },
|
|
532
|
-
{ kind: 'case-fail-fn-missing', when: (r) => r.code === 'calibration-case' && /\.fn$/.test(r.path),
|
|
533
|
-
say: (_r, c) => `${c} has an expected failure with no function named.` },
|
|
534
327
|
];
|
|
535
328
|
|
|
536
|
-
/** @param {PlainRed} r the 1-based rubric line a card red lands on @returns {number} */
|
|
537
|
-
function cardLineNo(r) {
|
|
538
|
-
return Number(/^card item (\d+):/.exec(r.detail)?.[1] ?? -1) + 1;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
329
|
/**
|
|
542
330
|
* Every plain kind the table can emit — the list the test enumerates against.
|
|
543
331
|
* @returns {string[]}
|
|
@@ -551,18 +339,13 @@ export function plainKinds() {
|
|
|
551
339
|
* An unknown code is NEVER dropped: it becomes a generic sentence that still
|
|
552
340
|
* quotes the code and path, under the kind `unmapped`.
|
|
553
341
|
* @param {PlainRed[]} reds
|
|
554
|
-
* @param {{cases?: any}} [o] the proposed cases, to name a case by its own id
|
|
555
342
|
* @returns {PlainReason[]}
|
|
556
343
|
*/
|
|
557
|
-
export function plainReasons(reds
|
|
344
|
+
export function plainReasons(reds) {
|
|
558
345
|
return (Array.isArray(reds) ? reds : []).map((red) => {
|
|
559
346
|
const r = /** @type {PlainRed} */ ({ ...red, code: String(red?.code ?? ''), path: String(red?.path ?? ''), detail: String(red?.detail ?? '') });
|
|
560
|
-
const idx = /^calibration\.cases\[(\d+)\]/.exec(r.path)?.[1];
|
|
561
|
-
const given = idx !== undefined && Array.isArray(cases) ? cases[Number(idx)]?.id : undefined;
|
|
562
|
-
const caseName = idx === undefined ? 'A case'
|
|
563
|
-
: typeof given === 'string' && given.trim() !== '' ? `Case "${safeText(given)}"` : `Case ${Number(idx) + 1}`;
|
|
564
347
|
const hit = PLAIN_TABLE.find((e) => e.when(r));
|
|
565
|
-
if (hit) return { kind: hit.kind, sentence: hit.say(r
|
|
348
|
+
if (hit) return { kind: hit.kind, sentence: hit.say(r), red: r };
|
|
566
349
|
return {
|
|
567
350
|
kind: 'unmapped',
|
|
568
351
|
sentence: `The model's proposal failed a check that has no plain wording yet ("${safeText(r.code)}" at ${safeText(r.path)}).`,
|
|
@@ -624,34 +407,6 @@ function said1(r) {
|
|
|
624
407
|
return isRubricShape(red) ? rubricShapeSentence(red) : safeText(red.detail);
|
|
625
408
|
}
|
|
626
409
|
|
|
627
|
-
/** the stops this module explains in plain words */
|
|
628
|
-
export const PLAIN_PROPOSAL_STOPS = Object.freeze(['proposal-invalid', 'rubric-invalid']);
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* THE MESSAGE a person reads when the rubric proposal was refused. Both doors
|
|
632
|
-
* (the panel's failed step and the CLI) print exactly this.
|
|
633
|
-
* @param {{stop: string, reds: PlainRed[], cases?: any, spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null,
|
|
634
|
-
* source?: 'proposal'|'signer'}} o
|
|
635
|
-
* @returns {string}
|
|
636
|
-
*/
|
|
637
|
-
export function proposalStopText({ stop, reds, cases = null, spend = null, source = 'proposal' }) {
|
|
638
|
-
const reasons = plainReasons(reds, { cases });
|
|
639
|
-
const unique = [...new Set(reasons.map((x) => x.sentence))];
|
|
640
|
-
const shown = unique.slice(0, PLAIN_MAX_BULLETS);
|
|
641
|
-
const onlyCases = reasons.length > 0 && reasons.every((x) => x.kind.startsWith('case-') || x.kind.startsWith('set-'));
|
|
642
|
-
const spent = spendText(spend);
|
|
643
|
-
const head = stop === 'rubric-invalid'
|
|
644
|
-
? 'The rubric and practice cases failed the last check before signing, so nothing was signed.'
|
|
645
|
-
: `The model's ${onlyCases ? 'practice cases for your rubric' : 'rubric and practice cases'} didn't hold up, so we stopped before grading anything.`;
|
|
646
|
-
const lines = [`${head} Spent so far: ${spent ?? 'unknown'}.`, 'What was wrong:'];
|
|
647
|
-
for (const s of shown) lines.push(` • ${s}`);
|
|
648
|
-
if (unique.length > shown.length) lines.push(` • …and ${unique.length - shown.length} more.`);
|
|
649
|
-
lines.push(source === 'signer' ? 'This one is from the edit made before signing.' : 'This is the model\'s mistake, not yours.');
|
|
650
|
-
lines.push(`What to do: draft again${spent ? ` (about ${spent} to reach here)` : ''}.`);
|
|
651
|
-
lines.push('If it fails the same way twice, make your PASS/FAIL examples more concrete.');
|
|
652
|
-
return lines.join('\n');
|
|
653
|
-
}
|
|
654
|
-
|
|
655
410
|
// ── ANY DRAFTING STOP, in plain words (P7 item 6, live session smv2bzdqmp0f8, 2026-10-10) ───────────────────────────
|
|
656
411
|
// A provider-red used to reach the panel as the bare line "Stopped: provider-red" — a code, no reason. Every stop of the
|
|
657
412
|
// drafting loop that is not a rubric-proposal or signing refusal (those have their own wording above and below) now says
|
|
@@ -677,8 +432,6 @@ export const STOP_HEADS = {
|
|
|
677
432
|
'scout-absent': 'Drafting stopped: the first look at your repo or input did not complete.',
|
|
678
433
|
refused: 'Drafting stopped: something in the job or its inputs is not allowed.',
|
|
679
434
|
'interview-incomplete': 'Drafting stopped: the job form was not complete, so there was nothing to draft from.',
|
|
680
|
-
'calibration-missing': 'Drafting stopped: the practice cases that prove the rubric were missing, so the check could not be trusted.',
|
|
681
|
-
'invalid-set': 'Drafting stopped: the rubric and its practice cases do not fit together, so they could not be graded.',
|
|
682
435
|
'broken-close': 'Drafting stopped: the final check the model wrote could not run.',
|
|
683
436
|
'plan-red': 'Drafting stopped: the plan code built from your checks did not pass its own gate. That is a fault in the build, not in your job.',
|
|
684
437
|
'listing-absent': 'Drafting stopped: the list of your files was not available, so the checks could not name any.',
|
|
@@ -694,8 +447,6 @@ export const STOP_HEADS = {
|
|
|
694
447
|
const STOP_TODO = /** @type {Record<string, string>} */ ({
|
|
695
448
|
refused: 'change what the message above names, then draft again.',
|
|
696
449
|
'interview-incomplete': 'fill in every line of the job form, then draft again.',
|
|
697
|
-
'calibration-missing': 'draft again; if it stops the same way twice, make your PASS/FAIL examples more concrete.',
|
|
698
|
-
'invalid-set': 'draft again; if it stops the same way twice, make your PASS/FAIL examples more concrete.',
|
|
699
450
|
'non-code-source': 'point the job at a code repo, or use a folder or file job instead.',
|
|
700
451
|
'listing-unreadable': 'check the repo is a readable git repo with at least one commit, then draft again.',
|
|
701
452
|
'confirm-abandoned': 'start a new draft when you are ready; nothing more was spent.',
|
|
@@ -719,11 +470,6 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
719
470
|
const detail = (Array.isArray(reds) ? reds : []).find((r) => r?.code === 'look-asks-too-many')?.detail;
|
|
720
471
|
if (detail) return `${redactSecrets(String(detail))}\nSpent so far: ${spent ?? 'unknown'}.`;
|
|
721
472
|
}
|
|
722
|
-
// F243: the fit check - the page does not show everything the job asks for; the not-found list (the code-made red detail) is the whole reason
|
|
723
|
-
if (stop === 'fit-stopped') {
|
|
724
|
-
const detail = (Array.isArray(reds) ? reds : []).find((r) => r?.code === 'fit-stopped')?.detail;
|
|
725
|
-
if (detail) return `Stopped before drafting: the page does not show everything the job asks for: ${redactSecrets(String(detail))}. Change the job or the page and draft again. Spent so far: ${spent ?? 'unknown'}.`;
|
|
726
|
-
}
|
|
727
473
|
const heads = STOP_HEADS;
|
|
728
474
|
const redList = Array.isArray(reds) ? reds : [];
|
|
729
475
|
// F217: the first look at the repo failing (a dropped connection, a timeout) arrives as a `precheck` stop with a
|
|
@@ -752,8 +498,7 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
752
498
|
|
|
753
499
|
// ── THE SIGNING GATES' REFUSAL, in plain words (hamr, 2026-10-09) ──────────────────────────
|
|
754
500
|
//
|
|
755
|
-
// `prepareSigning` (src/authorjob.js) can refuse with a list of reds from
|
|
756
|
-
// `signing gates failed — calibration-miswrite, calibration-miswrite, calibration-miswrite, injection-leak`.
|
|
501
|
+
// `prepareSigning` (src/authorjob.js) can refuse with a list of reds from three gates (the old fourth, the calibration gate, is gone).
|
|
757
502
|
// Same principle as the proposal text above ("a user should get a reason that they can understand and do
|
|
758
503
|
// something about"): one owner, written by code, the structured reds travel beside it in the drafting log.
|
|
759
504
|
//
|
|
@@ -765,10 +510,6 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
765
510
|
// gate 1a/1b (the declaration; validateJob + validateCloseDecl): DECLARATION_CODES below, plus seed-unreadable
|
|
766
511
|
// and listing-unreadable (authorjob.js)
|
|
767
512
|
// gate 2 (precheck): broken-close
|
|
768
|
-
// gate 4 (calibration; calibrate.js + authorjob.js calibrationGate): calibration-missing, no-judge-seam,
|
|
769
|
-
// cap-halt, pricing-red, provider-red, artifact-red (the casualty axes), calibration-miswrite,
|
|
770
|
-
// injection-leak, and the invalid-set reds (invalid-value at `card`, calibration-case / -size / -polarity /
|
|
771
|
-
// -cardless / -orphan) which the proposal table above already words
|
|
772
513
|
// gate 3 refuses with NO red at all (refusal only: the close already passes at the seed)
|
|
773
514
|
// An unknown code is never dropped: it becomes a generic sentence that quotes the code.
|
|
774
515
|
|
|
@@ -776,76 +517,16 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
776
517
|
export const DECLARATION_CODES = Object.freeze([
|
|
777
518
|
'bounds', 'class-absent', 'class-battery-locked', 'class-ceiling', 'cmd-denied', 'duplicate-kind', 'duplicate-name',
|
|
778
519
|
'env-ownership-absent', 'genre-env-missing', 'genre-env-ungrounded', 'genre-owned-env', 'guard-missing',
|
|
779
|
-
'guard-weakened', 'guards-absent', 'human-stage-not-last', 'human-stage-offered', 'invalid-value', 'job-line-uncovered',
|
|
520
|
+
'guard-weakened', 'guards-absent', 'human-stage-not-last', 'human-stage-offered', 'invalid-value', 'job-line-uncovered',
|
|
780
521
|
'listing-absent', 'listing-conflict', 'locked-kind', 'missing-field', 'missing-required', 'one-population',
|
|
781
522
|
'path-not-in-listing', 'secret-literal', 'unknown-field', 'unknown-kind',
|
|
782
523
|
]);
|
|
783
524
|
|
|
784
|
-
/** the rulebook rules in the words of a person: what the rule flags */
|
|
785
|
-
const RULE_FLAGS = Object.freeze({
|
|
786
|
-
'has-doc': 'there is no doc comment',
|
|
787
|
-
'says-what': 'the doc only repeats the function\'s name',
|
|
788
|
-
params: 'a parameter is missing from the doc, or the doc names one that does not exist',
|
|
789
|
-
returns: 'the return value is not documented',
|
|
790
|
-
});
|
|
791
|
-
|
|
792
|
-
/** @param {unknown} rule @returns {string} */
|
|
793
|
-
const ruleFlag = (rule) => (typeof rule === 'string' && Object.hasOwn(RULE_FLAGS, rule)
|
|
794
|
-
? /** @type {Record<string,string>} */ (RULE_FLAGS)[rule] : `the rule "${safeText(rule)}" applies`);
|
|
795
|
-
|
|
796
|
-
/** "says-what · initCache; params · initCache" to [{rule, fn}] @param {string} list */
|
|
797
|
-
const ruleFns = (list) => list.split(';').map((x) => x.trim()).filter(Boolean).map((x) => {
|
|
798
|
-
const [rule, fn] = x.split('·').map((t) => t.trim());
|
|
799
|
-
return { rule, fn: fn ?? '' };
|
|
800
|
-
});
|
|
801
|
-
|
|
802
|
-
/**
|
|
803
|
-
* A calibration-miswrite red as plain sentences: what the practice case expected against what the check found,
|
|
804
|
-
* read off the red's own detail (the compareExpectation pieces calibrate.js writes).
|
|
805
|
-
* @param {PlainRed} r @returns {string[]}
|
|
806
|
-
*/
|
|
807
|
-
function miswriteSentences(r) {
|
|
808
|
-
const who = `Case "${safeText(r.caseId ?? /^case "(.*?)" was graded/.exec(r.detail)?.[1] ?? '')}"`;
|
|
809
|
-
const missing = MISSING_REDS_RE.exec(r.detail)?.[1];
|
|
810
|
-
const extra = EXTRA_REDS_RE.exec(r.detail)?.[1];
|
|
811
|
-
/** @type {string[]} */
|
|
812
|
-
const out = [];
|
|
813
|
-
for (const { rule, fn } of missing ? ruleFns(missing) : []) {
|
|
814
|
-
out.push(`${who}${fn ? ` (${safeText(fn)})` : ''}: the practice case says ${ruleFlag(rule)}, but the check passed it.`);
|
|
815
|
-
}
|
|
816
|
-
for (const { rule, fn } of extra ? ruleFns(extra) : []) {
|
|
817
|
-
out.push(`${who}${fn ? ` (${safeText(fn)})` : ''}: the check says ${ruleFlag(rule)}, but the practice case did not expect that.`);
|
|
818
|
-
}
|
|
819
|
-
if (out.length === 0) {
|
|
820
|
-
const m = /signed "(\w+)", the pipe rendered "(\w+)"/.exec(r.detail);
|
|
821
|
-
out.push(m
|
|
822
|
-
? `${who}: the practice case says ${m[1] === 'red' ? 'fail' : 'pass'}, but the check said ${m[2] === 'red' ? 'fail' : 'pass'}.`
|
|
823
|
-
: `${who}: the practice case and the check disagree.`);
|
|
824
|
-
}
|
|
825
|
-
return out;
|
|
826
|
-
}
|
|
827
|
-
|
|
828
525
|
/**
|
|
829
526
|
* @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed) => string[], todo: string}[]}
|
|
830
527
|
* Order matters; the first match wins. `todo` is the one thing the person can do.
|
|
831
528
|
*/
|
|
832
529
|
const SIGNING_TABLE = [
|
|
833
|
-
{ kind: 'miswrite', when: (r) => r.code === 'calibration-miswrite', say: miswriteSentences, todo: 'draft again' },
|
|
834
|
-
{ kind: 'injection-leak', when: (r) => r.code === 'injection-leak',
|
|
835
|
-
say: (r) => [`A test file tried to trick the judge ("${safeText(r.style ?? '')}"), and what the judge pointed at changed, so the judge could not be shown to resist it.`],
|
|
836
|
-
todo: 'draft again' },
|
|
837
|
-
{ kind: 'calibration-missing', when: (r) => r.code === 'calibration-missing',
|
|
838
|
-
say: () => ['The rubric came without practice cases, so the check was never tried out.'], todo: 'draft again' },
|
|
839
|
-
{ kind: 'no-judge', when: (r) => r.code === 'no-judge-seam',
|
|
840
|
-
say: () => ['No judge model was set up to try out the rubric, so it was never graded.'], todo: 'check the judge model and its key in Settings, then try again' },
|
|
841
|
-
{ kind: 'cap-halt', when: (r) => r.code === 'cap-halt',
|
|
842
|
-
say: () => ['The spending cap ran out while the practice cases were being graded. Nothing says the rubric is wrong.'], todo: 'raise the cap, then draft again' },
|
|
843
|
-
{ kind: 'pricing-red', when: (r) => r.code === 'pricing-red',
|
|
844
|
-
say: () => ['A model call could not be priced, so the cap could not be applied; bareloop stopped rather than spend blind.'], todo: 'set the price for this model in Settings, then try again' },
|
|
845
|
-
{ kind: 'provider-red', when: (r) => r.code === 'provider-red',
|
|
846
|
-
say: () => ['The judge model could not be reached or was cut off while the practice cases were graded. Nothing says the rubric is wrong.'], todo: 'try again in a few minutes' },
|
|
847
|
-
{ kind: 'artifact-red', when: (r) => r.code === 'artifact-red',
|
|
848
|
-
say: () => ['The judge model answered with something bareloop could not read while the practice cases were graded. Nothing says the rubric is wrong.'], todo: 'try again' },
|
|
849
530
|
// M2: a rubric job's check has no install/build/test commands to blame — its own wording, never the code-job one
|
|
850
531
|
{ kind: 'broken-close-rubric', when: (r) => r.code === 'broken-close' && r.rubricJob === true,
|
|
851
532
|
say: (r) => [`A check of the close (${safeText(r.path.split('.').pop() ?? '')}) could not run, so nothing it reported could be trusted.`],
|
|
@@ -857,23 +538,13 @@ const SIGNING_TABLE = [
|
|
|
857
538
|
say: () => ['bareloop could not read the repository\'s starting commit.'], todo: 'check that the source is a git repository with at least one commit' },
|
|
858
539
|
{ kind: 'listing-unreadable', when: (r) => r.code === 'listing-unreadable',
|
|
859
540
|
say: () => ['bareloop could not list the files of the repository\'s starting commit.'], todo: 'check that the source is a git repository with at least one commit' },
|
|
860
|
-
{ kind: 'judged-outside-fence', when: (r) => r.code === 'judged-outside-write-scope',
|
|
861
|
-
say: (r) => [`The rubric check looks at ${listText(r.outside)}, but the job may only edit ${listText(r.fence)} — so the run could never fix what it finds.`],
|
|
862
|
-
todo: 'draft again' },
|
|
863
541
|
// Part 1a: the rubric-step sorting reds are already whole sentences in the person's words (src/rubricstep.js `checkRubricParts`)
|
|
864
542
|
{ kind: 'rubric-part', when: (r) => r.code.startsWith('rubric-'), say: (r) => [fullText(r.detail)], todo: 'draft again, or reword that line' },
|
|
865
543
|
{ kind: 'rubric-shape', when: isRubricShape, say: (r) => [rubricShapeSentence(r)], todo: 'draft again, or reword that line' },
|
|
866
|
-
{ kind: 'declaration', when: (r) => DECLARATION_CODES.includes(r.code)
|
|
544
|
+
{ kind: 'declaration', when: (r) => DECLARATION_CODES.includes(r.code),
|
|
867
545
|
say: (r) => [`The close the model wrote was refused before anything ran ("${safeText(r.code)}" at ${safeText(r.path)}).`], todo: 'draft again' },
|
|
868
546
|
];
|
|
869
547
|
|
|
870
|
-
/** a red's string list as plain text, each entry scrubbed and bounded
|
|
871
|
-
* @param {unknown} v @returns {string} */
|
|
872
|
-
const listText = (v) => {
|
|
873
|
-
const items = (Array.isArray(v) ? v : []).filter((x) => typeof x === 'string' && x !== '').slice(0, 4).map((x) => safeText(x));
|
|
874
|
-
return items.length ? items.join(', ') : 'files outside the edit area';
|
|
875
|
-
};
|
|
876
|
-
|
|
877
548
|
/** the sentence when the gates refuse with no red at all (the close already passes on the untouched repository) */
|
|
878
549
|
const SEED_GREEN_SENTENCE = 'Nothing in the close fails on the repository as it is, so there is nothing for a run to do.';
|
|
879
550
|
|
|
@@ -882,19 +553,18 @@ const NO_CHECK_SENTENCE = 'This job has no check that can fail: no `~` rule, and
|
|
|
882
553
|
const NO_CHECK_TODO = 'add a `~` rule (for example the version, the date, or "under 80 words"), or answer the question with what the output must contain';
|
|
883
554
|
|
|
884
555
|
/**
|
|
885
|
-
* Plain sentences for the reds of a refused signing, one or more per red.
|
|
886
|
-
*
|
|
887
|
-
* @param {PlainRed[]} reds @param {{cases?: any}} [o]
|
|
556
|
+
* Plain sentences for the reds of a refused signing, one or more per red. An unknown code is a generic sentence that quotes the code.
|
|
557
|
+
* @param {PlainRed[]} reds
|
|
888
558
|
* @returns {{kind: string, sentence: string, todo: string, red: PlainRed}[]}
|
|
889
559
|
*/
|
|
890
|
-
export function signingReasons(reds
|
|
560
|
+
export function signingReasons(reds) {
|
|
891
561
|
/** @type {{kind: string, sentence: string, todo: string, red: PlainRed}[]} */
|
|
892
562
|
const out = [];
|
|
893
563
|
for (const red of Array.isArray(reds) ? reds : []) {
|
|
894
564
|
const r = /** @type {PlainRed} */ ({ ...red, code: String(red?.code ?? ''), path: String(red?.path ?? ''), detail: String(red?.detail ?? '') });
|
|
895
565
|
const hit = SIGNING_TABLE.find((e) => e.when(r));
|
|
896
566
|
if (hit) { for (const sentence of hit.say(r)) out.push({ kind: hit.kind, sentence, todo: hit.todo, red: r }); continue; }
|
|
897
|
-
const [pr] = plainReasons([r]
|
|
567
|
+
const [pr] = plainReasons([r]);
|
|
898
568
|
if (pr && pr.kind !== 'unmapped') { out.push({ kind: pr.kind, sentence: pr.sentence, todo: 'draft again', red: r }); continue; }
|
|
899
569
|
out.push({
|
|
900
570
|
kind: 'unmapped',
|
|
@@ -914,12 +584,12 @@ export function signingKinds() {
|
|
|
914
584
|
|
|
915
585
|
/**
|
|
916
586
|
* THE MESSAGE a person reads when the signing gates refuse. The panel's failed step and the CLI print exactly this.
|
|
917
|
-
* @param {{reds: PlainRed[], refusal?: {detail?: string}|null,
|
|
587
|
+
* @param {{reds: PlainRed[], refusal?: {detail?: string}|null, noCheck?: boolean,
|
|
918
588
|
* spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o `noCheck` = the check block has no built check (block.hasBuiltCheck() is false): the stop is the end check's own words
|
|
919
589
|
* @returns {string}
|
|
920
590
|
*/
|
|
921
|
-
export function signingStopText({ reds, refusal = null,
|
|
922
|
-
const reasons = signingReasons(reds
|
|
591
|
+
export function signingStopText({ reds, refusal = null, spend = null, noCheck = false }) {
|
|
592
|
+
const reasons = signingReasons(reds);
|
|
923
593
|
if (reasons.length === 0) {
|
|
924
594
|
reasons.push({ kind: 'seed-green', sentence: noCheck ? NO_CHECK_SENTENCE : SEED_GREEN_SENTENCE,
|
|
925
595
|
todo: noCheck ? NO_CHECK_TODO : 'check that the close measures the right thing, or describe a sharper problem',
|
|
@@ -931,9 +601,6 @@ export function signingStopText({ reds, refusal = null, cases = null, spend = nu
|
|
|
931
601
|
const lines = [`The checks before signing did not all pass, so nothing was signed. Spent so far: ${spent ?? 'unknown'}.`, 'What was wrong:'];
|
|
932
602
|
for (const s of shown) lines.push(` • ${s}`);
|
|
933
603
|
if (unique.length > shown.length) lines.push(` • …and ${unique.length - shown.length} more.`);
|
|
934
|
-
if (reasons.some((x) => x.kind === 'miswrite' || x.kind === 'injection-leak')) {
|
|
935
|
-
lines.push('The practice cases and the check disagree; either one can be the one that is wrong, so this is not necessarily your doing or the model\'s.');
|
|
936
|
-
}
|
|
937
604
|
lines.push(`What to do: ${reasons[0].todo}${reasons[0].todo === 'draft again' && spent ? ` (about ${spent} to reach here)` : ''}.`);
|
|
938
605
|
return lines.join('\n');
|
|
939
606
|
}
|
|
@@ -941,13 +608,13 @@ export function signingStopText({ reds, refusal = null, cases = null, spend = nu
|
|
|
941
608
|
/**
|
|
942
609
|
* The reds as the drafting log keeps them: every structured field, the plain
|
|
943
610
|
* sentence beside it, every string secret-scrubbed and bounded, the list capped.
|
|
944
|
-
* @param {PlainRed[]} reds @param {{
|
|
611
|
+
* @param {PlainRed[]} reds @param {{signing?: boolean}} [o] `signing`: the reds are the signing gates', worded by signingReasons
|
|
945
612
|
* @returns {Record<string, any>[]}
|
|
946
613
|
*/
|
|
947
|
-
export function redsRecord(reds, {
|
|
614
|
+
export function redsRecord(reds, { signing = false } = {}) {
|
|
948
615
|
/** @param {unknown} s */
|
|
949
616
|
const cut = (s) => { const t = redactSecrets(String(s ?? '')); return t.length > RECORD_STR_MAX ? `${t.slice(0, RECORD_STR_MAX)}…` : t; };
|
|
950
|
-
return (signing ? signingReasons(reds
|
|
617
|
+
return (signing ? signingReasons(reds) : plainReasons(reds)).slice(0, RECORD_MAX_REDS).map(({ kind, sentence, red }) => {
|
|
951
618
|
/** @type {Record<string, any>} */
|
|
952
619
|
const out = { kind, plain: sentence };
|
|
953
620
|
for (const [k, v] of Object.entries(red)) {
|
|
@@ -958,3 +625,86 @@ export function redsRecord(reds, { cases = null, signing = false } = {}) {
|
|
|
958
625
|
return out;
|
|
959
626
|
});
|
|
960
627
|
}
|
|
628
|
+
|
|
629
|
+
/** The draft readout's section headings: the ONE list (fwd v0.34.0 `READOUT_HEADS`). `buildReadout` writes them from here and `readoutHeadIndexes` finds them by it, so the panel's bold and the text cannot drift. */
|
|
630
|
+
export const READOUT_HEADS = Object.freeze({
|
|
631
|
+
inputs: 'INPUTS',
|
|
632
|
+
steps: 'STEPS',
|
|
633
|
+
fence: 'WRITE FENCE',
|
|
634
|
+
notChecked: 'REFUSED / NOT CHECKED',
|
|
635
|
+
jobLines: 'JOB LINES',
|
|
636
|
+
answers: 'YOUR ANSWERS',
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
/** The readout's top line prefix: ONE owner for the text `buildReadout` writes and the bold `readoutHeadIndexes` finds. */
|
|
640
|
+
export const READOUT_HEADER_PREFIX = 'DRAFT READOUT \u2014 NOT SIGNED \u2014 job ';
|
|
641
|
+
|
|
642
|
+
/** Zero-based indexes of the header and heading lines in a readout's text (split on "\n"): the panel draws those bold. @param {string} text @returns {number[]} */
|
|
643
|
+
export function readoutHeadIndexes(text) {
|
|
644
|
+
const heads = new Set(Object.values(READOUT_HEADS));
|
|
645
|
+
/** @type {number[]} */
|
|
646
|
+
const idx = [];
|
|
647
|
+
String(text).split('\n').forEach((l, i) => { if (heads.has(/** @type {any} */ (l)) || l.startsWith(READOUT_HEADER_PREFIX)) idx.push(i); });
|
|
648
|
+
return idx;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/** @param {number|null|undefined} ms the signed time cap in words; an absent one reads unbounded, never 0 @returns {string} */
|
|
652
|
+
function capTimeWords(ms) {
|
|
653
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms) || ms <= 0) return 'no time cap set';
|
|
654
|
+
return ms < 60000 ? `${Math.round(ms / 1000)} s` : `${Math.round(ms / 60000)} min`;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The plain-text readout of the draft the person is about to sign (hamr 2026-11-15, copied from fwdloop v0.34.0 `buildReadout`; ASKS, SEND TARGET, flows root and grants are fwd-only and not here).
|
|
659
|
+
* DISPLAY ONLY: built from the signed resolved spec, the draft log and the session's own figures; never signed, never stored, never part of the hash. Pure. The check rows are `cardOfClose`'s (the same reader and tags the card draws),
|
|
660
|
+
* the fence is `fenceRowText`'s, the Not checked rows are `ruleNotCheckedItems`'s plus the `refusedOf` rows it leaves out. The whole text goes through `redactSecrets`.
|
|
661
|
+
* @param {{spec: any, name?: string, modelId?: string|null, rounds: number, costUsd: number|null, spendComplete?: boolean, specHash?: string|null, source?: string, destination?: string,
|
|
662
|
+
* humans?: {question: string, answer: string, line?: number, choice?: string, words?: string}[], ledger?: {key: string, words: string[]}[]|null}} o
|
|
663
|
+
* `costUsd` = the known drafting spend; `spendComplete` false = a provider call was unpriced, so it reads "at least"
|
|
664
|
+
* @returns {string}
|
|
665
|
+
*/
|
|
666
|
+
export function buildReadout({ spec, name, modelId = null, rounds, costUsd, spendComplete = true, specHash = null, source = '', destination = '', humans = [], ledger = null }) {
|
|
667
|
+
const jobLines = Array.isArray(spec?.jobLines) ? spec.jobLines : [];
|
|
668
|
+
const closeDecl = spec?.closeDecl;
|
|
669
|
+
const card = cardOfClose({ closeDecl, jobLines, ledger });
|
|
670
|
+
const out = [];
|
|
671
|
+
out.push(`${READOUT_HEADER_PREFIX}${name ?? spec?.job ?? '?'}`, '');
|
|
672
|
+
const cost = typeof costUsd === 'number' ? (spendComplete === false ? `at least ${panelMoney2(costUsd)} (a provider call is unpriced)` : panelMoney2(costUsd)) : 'unknown';
|
|
673
|
+
out.push(`Drafted by: ${modelId ?? spec?.model ?? '?'} in ${rounds} round(s), cost ${cost}`);
|
|
674
|
+
out.push(`Cap: ${typeof spec?.budgetUsd === 'number' ? panelMoney2(spec.budgetUsd) : 'unknown'} (money) \u00B7 ${capTimeWords(spec?.maxWallMs)} (time)`, '');
|
|
675
|
+
out.push(READOUT_HEADS.inputs);
|
|
676
|
+
if (source) out.push(` source = ${source}`);
|
|
677
|
+
for (const i of Array.isArray(spec?.inputs) ? spec.inputs : []) out.push(` ${i.n}. ${i.label} = ${i.value}`);
|
|
678
|
+
if (destination) out.push(` destination = ${destination}`);
|
|
679
|
+
if (spec?.mcp && typeof spec.mcp === 'object') out.push(` mcp: ${spec.mcp.server} \u00B7 tools: ${(spec.mcp.tools ?? []).join(', ')}`);
|
|
680
|
+
const filter = ticketFilterWords(spec?.ticketFilter);
|
|
681
|
+
if (filter) out.push(` ticket filter: ${filter}`);
|
|
682
|
+
out.push('', READOUT_HEADS.steps);
|
|
683
|
+
const rubricLines = new Set((Array.isArray(closeDecl?.stages) ? closeDecl.stages : []).filter((/** @type {any} */ st) => st?.kind === 'rubric-step' && Number.isInteger(st.params?.step)).map((/** @type {any} */ st) => st.params.step));
|
|
684
|
+
for (const l of jobLines) {
|
|
685
|
+
out.push(` (line ${l.n}) ${l.text}`);
|
|
686
|
+
if (rubricLines.has(l.n)) out.push(` writes: ${stepFileRel(l.n)}`);
|
|
687
|
+
for (const c of card.checkItems.filter((x) => x.fromLine[0] === l.n)) out.push(` check: ${c.text} [${c.by}]`);
|
|
688
|
+
}
|
|
689
|
+
// the job-level rows (the always-on guards, line 0) serve no one line; the fence row is told once under its own head below
|
|
690
|
+
for (const c of card.checkItems.filter((x) => x.fromLine[0] === 0 && x.key !== FENCE_KEY)) out.push(` always: ${c.text} [${c.by}]`);
|
|
691
|
+
const fence = fenceOfClose(closeDecl);
|
|
692
|
+
if (fence) out.push('', READOUT_HEADS.fence, ` ${fenceRowText(fence)}`);
|
|
693
|
+
const refusedRest = refusedOf(closeDecl).filter((r) => !(Number.isInteger(r.rule) || r.fromList));
|
|
694
|
+
if (card.notChecked.length || refusedRest.length) {
|
|
695
|
+
out.push('', READOUT_HEADS.notChecked);
|
|
696
|
+
for (const t of card.notChecked) out.push(` ${t}${card.notCheckedBy[t] ? ` [${card.notCheckedBy[t]}]` : ''}`);
|
|
697
|
+
for (const r of refusedRest) out.push(` line ${r.line}: ${r.reason}`);
|
|
698
|
+
}
|
|
699
|
+
out.push('', READOUT_HEADS.jobLines);
|
|
700
|
+
for (const l of jobLines) {
|
|
701
|
+
out.push(` ${l.n}. ${l.text}`);
|
|
702
|
+
for (const r of lineRules(l)) out.push(` ~ ${r}`);
|
|
703
|
+
}
|
|
704
|
+
if (specHash) out.push('', `Plan hash: ${specHash}`);
|
|
705
|
+
if (humans.length) {
|
|
706
|
+
out.push('', READOUT_HEADS.answers);
|
|
707
|
+
for (const h of humans) out.push(` ${Number.isInteger(h.line) ? `line ${h.line}: ` : ''}${decidedWords(h) ?? `${h.question} \u2014 ${h.answer}`}`);
|
|
708
|
+
}
|
|
709
|
+
return redactSecrets(`${out.join('\n')}\n`);
|
|
710
|
+
}
|