bareloop 0.55.0 → 0.57.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 +82 -0
- package/README.md +3 -3
- package/bareloop.context.md +69 -209
- package/package.json +2 -2
- package/src/authorflow.js +164 -340
- package/src/authoring.js +7 -127
- package/src/authorjob.js +139 -472
- package/src/authorreadout.js +24 -368
- package/src/authorrun.js +21 -215
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +798 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +39 -312
- package/src/checkwords.js +3 -1
- package/src/cli.js +3 -3
- package/src/declaredclose.js +38 -108
- package/src/destpoint.js +4 -2
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -1
- 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 +5 -347
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +15 -3
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +24 -6
- package/src/panel/authorsession.js +222 -177
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +198 -26
- package/src/panel/jobplan.js +87 -33
- package/src/panel/server.js +74 -68
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +34 -55
- package/src/placerule.js +355 -0
- package/src/planrun.js +2 -48
- package/src/promptregisters.js +13 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +104 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +234 -127
- package/src/run.js +11 -16
- package/src/userrun.js +60 -112
- package/types/authorflow.d.ts +41 -197
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +35 -59
- package/types/authorreadout.d.ts +10 -88
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +36 -0
- package/types/checkblock.d.ts +376 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +8 -140
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +7 -33
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -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 +3 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagemap.d.ts +4 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +47 -5
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +27 -18
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +20 -13
- package/types/placerule.d.ts +194 -0
- 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 +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +100 -48
- package/types/run.d.ts +9 -19
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -166
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -113
package/src/authorreadout.js
CHANGED
|
@@ -26,9 +26,6 @@
|
|
|
26
26
|
import { scrubRaw } from './text.js';
|
|
27
27
|
import { panelMoney2 } from './panelmoney.js';
|
|
28
28
|
import { redactSecrets } from './validate.js';
|
|
29
|
-
import { judgedStages } from './kinds.js';
|
|
30
|
-
import { CALIBRATION_SIZE } from './judged.js';
|
|
31
|
-
import { INJECTION_LOCATE_BATTERY } from './calibrate.js';
|
|
32
29
|
|
|
33
30
|
/**
|
|
34
31
|
* @param {{goal?: string|null, closeDecl?: any}} spec the RESOLVED spec — the bytes
|
|
@@ -68,42 +65,6 @@ export function fellBackLines(authoring) {
|
|
|
68
65
|
return [`FELL BACK ${fb.from} broke ${fb.brokenStages?.length ?? 0} check(s) (${stages}) — kept ${fb.to} instead`];
|
|
69
66
|
}
|
|
70
67
|
|
|
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
68
|
/**
|
|
108
69
|
* THE CONFIRM TURN'S OPEN QUESTIONS (PRD item 33 M3 piece 4, ruling 5's D3
|
|
109
70
|
* addendum) — shown at the SIGNING readout, from `authored.json`'s own
|
|
@@ -145,104 +106,6 @@ export function answeredQuestionLines(confirmed) {
|
|
|
145
106
|
return lines;
|
|
146
107
|
}
|
|
147
108
|
|
|
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
109
|
/**
|
|
247
110
|
* THE AUTHORING CEILING, parsed from `--budget`. Housed here for the same reason
|
|
248
111
|
* the readout above is: the runner is a script, and a rule no test can reach is a
|
|
@@ -316,6 +179,10 @@ export function phaseLine(phase, data = {}) {
|
|
|
316
179
|
case 'scout-done': return `· scout ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s)`;
|
|
317
180
|
case 'look': return '· looking at your input — a read-only search for the facts the job asks for…';
|
|
318
181
|
case 'look-done': return `· look ${data.state ?? 'unknown'} — ${data.facts ?? 0} fact(s) can be checked`;
|
|
182
|
+
case 'ledger-suggest': return '· suggesting extra checks from your input…';
|
|
183
|
+
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`; }
|
|
184
|
+
case 'draft-ledger-try': return `· ${data.label}: ${data.kept ?? '?'} edit(s) kept, ${(data.refused ?? []).length} refused`;
|
|
185
|
+
case 'draft-ledger': { const rows = Array.isArray(data.rows) ? data.rows : []; const n = (/** @type {string} */ st) => rows.filter((/** @type {any} */ r) => r.state === st).length; return `· the list at the end: ${n('built')} built, ${n('not-checked')} not checked`; }
|
|
319
186
|
case 'listing': return '· listing the files the declaration may name…';
|
|
320
187
|
case 'listing-done': return `· listing ${data.stop ? `STOPPED (${data.stop})` : `${data.files ?? 'unknown'} file(s)`}`;
|
|
321
188
|
case 'author': return '· authoring the close declaration…';
|
|
@@ -324,11 +191,6 @@ export function phaseLine(phase, data = {}) {
|
|
|
324
191
|
case 'seed-read': return `· measuring ${data.stages ?? '?'} stage(s) at the seed — each one runs a real toolchain…`;
|
|
325
192
|
case 'stage': return `· ${data.stage} [${data.kind}] ${data.verdict} — ${ms(data.durationMs)}`;
|
|
326
193
|
case 'seed-read-done': return `· seed read done (${data.stages ?? '?'} stage(s))`;
|
|
327
|
-
// softgreen modules 4+5: the compile, and the paid gate that grades it
|
|
328
|
-
case 'rubric': return `· compiling the rubric card and ${data.size ?? '?'} calibration cases from your own answers…`;
|
|
329
|
-
case 'rubric-done': return `· rubric ${data.ok ? 'compiled' : `NOT compiled (${data.stop ?? 'unknown'})`} after ${data.attempts ?? '?'} attempt(s)`;
|
|
330
|
-
case 'rubric-scrubbed': return `· MASKED before storing: ${(data.paths ?? []).join(', ')} — the stored bytes differ from what was typed`;
|
|
331
|
-
case 'calibration': return `· calibration gate: ${data.cases ?? '?'} case(s) + ${data.styles ?? '?'} injection style(s), one real judge call each…`;
|
|
332
194
|
// A phase this renderer does not know is PRINTED, not swallowed: the callers
|
|
333
195
|
// are the library's own seams and a new one appearing unrendered is how a
|
|
334
196
|
// readout silently stops covering what it reports on.
|
|
@@ -409,12 +271,6 @@ const PLAIN_MAX_BULLETS = 8;
|
|
|
409
271
|
const RECORD_MAX_REDS = 40;
|
|
410
272
|
const RECORD_STR_MAX = 600;
|
|
411
273
|
|
|
412
|
-
// Each of these two finds its text on the FIRST line that has it, anchored to a line start: a lazy (.*?) that
|
|
413
|
-
// fails runs to the end of its line, and the same pattern retried at every later start on that line fails the
|
|
414
|
-
// same way (the later text is a part of the earlier one's), so retrying them only made the read quadratic.
|
|
415
|
-
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)/;
|
|
416
|
-
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)/;
|
|
417
|
-
|
|
418
274
|
/** 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
|
|
419
275
|
* @param {unknown} s @returns {string} */
|
|
420
276
|
function fullText(s) {
|
|
@@ -455,85 +311,16 @@ function rubricShapeSentence(r) {
|
|
|
455
311
|
}
|
|
456
312
|
|
|
457
313
|
/**
|
|
458
|
-
* The ONE table of plain kinds → sentence builders. A builder gets the red
|
|
459
|
-
* name of the case it lands on (when it lands on one) and the match of the
|
|
460
|
-
* regex that picked it. `unmapped` is the only kind the table does not list.
|
|
314
|
+
* The ONE table of plain kinds → sentence builders. A builder gets the red. `unmapped` is the only kind the table does not list.
|
|
461
315
|
* Order matters: the first matching entry wins.
|
|
462
|
-
* @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed
|
|
316
|
+
* @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed) => string}[]}
|
|
463
317
|
*/
|
|
464
318
|
const PLAIN_TABLE = [
|
|
465
|
-
// ── the rubric card (validateCard, surfaced as code invalid-value at path "card") ──
|
|
466
|
-
{ kind: 'card-not-object', when: (r) => r.code === 'invalid-value' && /^the card must be an object/.test(r.detail),
|
|
467
|
-
say: () => 'The model did not hand back a rubric in the expected shape.' },
|
|
468
|
-
{ kind: 'card-empty', when: (r) => r.code === 'invalid-value' && /^the card must carry a non-empty/.test(r.detail),
|
|
469
|
-
say: () => 'The model\'s rubric has no rules in it.' },
|
|
470
|
-
{ kind: 'card-line-bad', when: (r) => r.code === 'invalid-value' && /^card item \d+: must be an object/.test(r.detail),
|
|
471
|
-
say: (r) => `Rubric line ${cardLineNo(r)} is not a proper line.` },
|
|
472
|
-
{ kind: 'card-line-no-rule', when: (r) => r.code === 'invalid-value' && /^card item \d+: needs a `rule`/.test(r.detail),
|
|
473
|
-
say: (r) => `Rubric line ${cardLineNo(r)} does not pick which rule it uses.` },
|
|
474
|
-
{ kind: 'card-line-unknown-rule', when: (r) => r.code === 'invalid-value' && /^card item \d+: `.*` is not a rule this arbiter implements/.test(r.detail),
|
|
475
|
-
say: (r, _c, _m) => `Rubric line ${cardLineNo(r)} names a rule bareloop does not have (${safeText(/`(.*?)` is not a rule/.exec(r.detail)?.[1] ?? '')}).` },
|
|
476
|
-
{ kind: 'card-line-repeat', when: (r) => r.code === 'invalid-value' && /^card item \d+: `.*` is named twice/.test(r.detail),
|
|
477
|
-
say: (r) => `Rubric line ${cardLineNo(r)} uses a rule that an earlier line already uses.` },
|
|
478
|
-
{ kind: 'card-line-no-text', when: (r) => r.code === 'invalid-value' && /^card item \d+: needs `text`/.test(r.detail),
|
|
479
|
-
say: (r) => `Rubric line ${cardLineNo(r)} has no wording.` },
|
|
480
319
|
// 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
|
|
481
320
|
{ kind: 'rubric-red', when: (r) => r.code.startsWith('rubric-'), say: (r) => fullText(r.detail) },
|
|
482
321
|
{ kind: 'rubric-shape', when: isRubricShape, say: (r) => rubricShapeSentence(r) },
|
|
483
|
-
{ kind: 'proposal-not-object', when: (r) => r.code === 'invalid-value' && r.path === 'proposal',
|
|
484
|
-
say: () => 'The model\'s answer was not a rubric plus practice cases.' },
|
|
485
|
-
// ── the practice-case set as a whole ──
|
|
486
|
-
{ kind: 'set-no-rules', when: (r) => r.code === 'calibration-cardless',
|
|
487
|
-
say: () => 'The rubric has no rules, so the practice cases had nothing to be checked against.' },
|
|
488
|
-
{ kind: 'set-not-list', when: (r) => r.code === 'calibration-size' && !('declared' in r),
|
|
489
|
-
say: () => `The practice cases did not come back as a list of ${CALIBRATION_SIZE}.` },
|
|
490
|
-
{ kind: 'set-size', when: (r) => r.code === 'calibration-size',
|
|
491
|
-
say: (r) => `The model gave ${r.declared} practice case${r.declared === 1 ? '' : 's'}; exactly ${r.required ?? CALIBRATION_SIZE} are needed.` },
|
|
492
|
-
{ kind: 'set-one-sided', when: (r) => r.code === 'calibration-polarity',
|
|
493
|
-
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.` },
|
|
494
|
-
// ── one practice case ──
|
|
495
|
-
{ kind: 'case-not-object', when: (r) => r.code === 'calibration-case' && /^calibration\.cases\[\d+\]$/.test(r.path),
|
|
496
|
-
say: (_r, c) => `${c} is not a proper case.` },
|
|
497
|
-
{ kind: 'case-name-repeat', when: (r) => r.code === 'calibration-case' && /\.id$/.test(r.path) && /declared twice/.test(r.detail),
|
|
498
|
-
say: (_r, c) => `Two practice cases share the name ${c}.` },
|
|
499
|
-
{ kind: 'case-name-bad', when: (r) => r.code === 'calibration-case' && /\.id$/.test(r.path),
|
|
500
|
-
say: (_r, c) => `${c} has no usable name (a short name in lowercase letters, digits and hyphens is needed).` },
|
|
501
|
-
{ kind: 'case-code-repeat', when: (r) => r.code === 'calibration-case' && /\.artifact$/.test(r.path) && /used twice/.test(r.detail),
|
|
502
|
-
say: (_r, c) => `${c} reuses the same sample code as another case.` },
|
|
503
|
-
{ kind: 'case-code-missing', when: (r) => r.code === 'calibration-case' && /\.artifact$/.test(r.path),
|
|
504
|
-
say: (_r, c) => `${c} has no sample code to look at.` },
|
|
505
|
-
{ kind: 'case-impossible-no-doc', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path) && /expects has-doc red on/.test(r.detail),
|
|
506
|
-
say: (r, c) => {
|
|
507
|
-
const fn = safeText(/expects has-doc red on (\S+?),/.exec(r.detail)?.[1] ?? 'a function');
|
|
508
|
-
return `${c} says "fail: no doc comment" on ${fn}, but ${fn} has a doc comment right above it.`;
|
|
509
|
-
} },
|
|
510
|
-
{ 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),
|
|
511
|
-
say: (_r, c) => `${c} is marked as a pass but also lists things that fail.` },
|
|
512
|
-
{ kind: 'case-fail-lists-nothing', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path) && /^a RED case names WHICH/.test(r.detail),
|
|
513
|
-
say: (_r, c) => `${c} is marked as a fail but does not say which rule or function fails.` },
|
|
514
|
-
{ kind: 'case-fails-not-list', when: (r) => r.code === 'calibration-case' && /\.expect\.reds$/.test(r.path),
|
|
515
|
-
say: (_r, c) => `${c} does not give its expected failures as a list.` },
|
|
516
|
-
{ kind: 'case-no-expected', when: (r) => r.code === 'calibration-case' && /\.expect$/.test(r.path),
|
|
517
|
-
say: (_r, c) => `${c} has no expected result.` },
|
|
518
|
-
{ kind: 'case-verdict-bad', when: (r) => r.code === 'calibration-case' && /\.expect\.verdict$/.test(r.path),
|
|
519
|
-
say: (_r, c) => `${c} expects a result that is neither pass nor fail.` },
|
|
520
|
-
{ kind: 'case-fail-malformed', when: (r) => r.code === 'calibration-case' && /\.reds\[\d+\]$/.test(r.path) && /^an expected red is/.test(r.detail),
|
|
521
|
-
say: (_r, c) => `${c} has an expected failure that is not written as a rule and a function.` },
|
|
522
|
-
{ kind: 'case-fail-repeat', when: (r) => r.code === 'calibration-case' && /\.reds\[\d+\]$/.test(r.path),
|
|
523
|
-
say: (_r, c) => `${c} lists the same failure twice.` },
|
|
524
|
-
{ kind: 'case-fail-rule-foreign', when: (r) => r.code === 'calibration-case' && /\.rule$/.test(r.path) && typeof r.rule === 'string',
|
|
525
|
-
say: (r, c) => `${c} expects a failure from the rule "${safeText(r.rule)}", which this rubric does not use.` },
|
|
526
|
-
{ kind: 'case-fail-rule-missing', when: (r) => r.code === 'calibration-case' && /\.rule$/.test(r.path),
|
|
527
|
-
say: (_r, c) => `${c} has an expected failure with no rule named.` },
|
|
528
|
-
{ kind: 'case-fail-fn-missing', when: (r) => r.code === 'calibration-case' && /\.fn$/.test(r.path),
|
|
529
|
-
say: (_r, c) => `${c} has an expected failure with no function named.` },
|
|
530
322
|
];
|
|
531
323
|
|
|
532
|
-
/** @param {PlainRed} r the 1-based rubric line a card red lands on @returns {number} */
|
|
533
|
-
function cardLineNo(r) {
|
|
534
|
-
return Number(/^card item (\d+):/.exec(r.detail)?.[1] ?? -1) + 1;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
324
|
/**
|
|
538
325
|
* Every plain kind the table can emit — the list the test enumerates against.
|
|
539
326
|
* @returns {string[]}
|
|
@@ -547,18 +334,13 @@ export function plainKinds() {
|
|
|
547
334
|
* An unknown code is NEVER dropped: it becomes a generic sentence that still
|
|
548
335
|
* quotes the code and path, under the kind `unmapped`.
|
|
549
336
|
* @param {PlainRed[]} reds
|
|
550
|
-
* @param {{cases?: any}} [o] the proposed cases, to name a case by its own id
|
|
551
337
|
* @returns {PlainReason[]}
|
|
552
338
|
*/
|
|
553
|
-
export function plainReasons(reds
|
|
339
|
+
export function plainReasons(reds) {
|
|
554
340
|
return (Array.isArray(reds) ? reds : []).map((red) => {
|
|
555
341
|
const r = /** @type {PlainRed} */ ({ ...red, code: String(red?.code ?? ''), path: String(red?.path ?? ''), detail: String(red?.detail ?? '') });
|
|
556
|
-
const idx = /^calibration\.cases\[(\d+)\]/.exec(r.path)?.[1];
|
|
557
|
-
const given = idx !== undefined && Array.isArray(cases) ? cases[Number(idx)]?.id : undefined;
|
|
558
|
-
const caseName = idx === undefined ? 'A case'
|
|
559
|
-
: typeof given === 'string' && given.trim() !== '' ? `Case "${safeText(given)}"` : `Case ${Number(idx) + 1}`;
|
|
560
342
|
const hit = PLAIN_TABLE.find((e) => e.when(r));
|
|
561
|
-
if (hit) return { kind: hit.kind, sentence: hit.say(r
|
|
343
|
+
if (hit) return { kind: hit.kind, sentence: hit.say(r), red: r };
|
|
562
344
|
return {
|
|
563
345
|
kind: 'unmapped',
|
|
564
346
|
sentence: `The model's proposal failed a check that has no plain wording yet ("${safeText(r.code)}" at ${safeText(r.path)}).`,
|
|
@@ -620,34 +402,6 @@ function said1(r) {
|
|
|
620
402
|
return isRubricShape(red) ? rubricShapeSentence(red) : safeText(red.detail);
|
|
621
403
|
}
|
|
622
404
|
|
|
623
|
-
/** the stops this module explains in plain words */
|
|
624
|
-
export const PLAIN_PROPOSAL_STOPS = Object.freeze(['proposal-invalid', 'rubric-invalid']);
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* THE MESSAGE a person reads when the rubric proposal was refused. Both doors
|
|
628
|
-
* (the panel's failed step and the CLI) print exactly this.
|
|
629
|
-
* @param {{stop: string, reds: PlainRed[], cases?: any, spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null,
|
|
630
|
-
* source?: 'proposal'|'signer'}} o
|
|
631
|
-
* @returns {string}
|
|
632
|
-
*/
|
|
633
|
-
export function proposalStopText({ stop, reds, cases = null, spend = null, source = 'proposal' }) {
|
|
634
|
-
const reasons = plainReasons(reds, { cases });
|
|
635
|
-
const unique = [...new Set(reasons.map((x) => x.sentence))];
|
|
636
|
-
const shown = unique.slice(0, PLAIN_MAX_BULLETS);
|
|
637
|
-
const onlyCases = reasons.length > 0 && reasons.every((x) => x.kind.startsWith('case-') || x.kind.startsWith('set-'));
|
|
638
|
-
const spent = spendText(spend);
|
|
639
|
-
const head = stop === 'rubric-invalid'
|
|
640
|
-
? 'The rubric and practice cases failed the last check before signing, so nothing was signed.'
|
|
641
|
-
: `The model's ${onlyCases ? 'practice cases for your rubric' : 'rubric and practice cases'} didn't hold up, so we stopped before grading anything.`;
|
|
642
|
-
const lines = [`${head} Spent so far: ${spent ?? 'unknown'}.`, 'What was wrong:'];
|
|
643
|
-
for (const s of shown) lines.push(` • ${s}`);
|
|
644
|
-
if (unique.length > shown.length) lines.push(` • …and ${unique.length - shown.length} more.`);
|
|
645
|
-
lines.push(source === 'signer' ? 'This one is from the edit made before signing.' : 'This is the model\'s mistake, not yours.');
|
|
646
|
-
lines.push(`What to do: draft again${spent ? ` (about ${spent} to reach here)` : ''}.`);
|
|
647
|
-
lines.push('If it fails the same way twice, make your PASS/FAIL examples more concrete.');
|
|
648
|
-
return lines.join('\n');
|
|
649
|
-
}
|
|
650
|
-
|
|
651
405
|
// ── ANY DRAFTING STOP, in plain words (P7 item 6, live session smv2bzdqmp0f8, 2026-10-10) ───────────────────────────
|
|
652
406
|
// A provider-red used to reach the panel as the bare line "Stopped: provider-red" — a code, no reason. Every stop of the
|
|
653
407
|
// drafting loop that is not a rubric-proposal or signing refusal (those have their own wording above and below) now says
|
|
@@ -673,9 +427,8 @@ export const STOP_HEADS = {
|
|
|
673
427
|
'scout-absent': 'Drafting stopped: the first look at your repo or input did not complete.',
|
|
674
428
|
refused: 'Drafting stopped: something in the job or its inputs is not allowed.',
|
|
675
429
|
'interview-incomplete': 'Drafting stopped: the job form was not complete, so there was nothing to draft from.',
|
|
676
|
-
'calibration-missing': 'Drafting stopped: the practice cases that prove the rubric were missing, so the check could not be trusted.',
|
|
677
|
-
'invalid-set': 'Drafting stopped: the rubric and its practice cases do not fit together, so they could not be graded.',
|
|
678
430
|
'broken-close': 'Drafting stopped: the final check the model wrote could not run.',
|
|
431
|
+
'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.',
|
|
679
432
|
'listing-absent': 'Drafting stopped: the list of your files was not available, so the checks could not name any.',
|
|
680
433
|
'listing-conflict': 'Drafting stopped: the list of your files was given twice and the two did not agree.',
|
|
681
434
|
'listing-unreadable': 'Drafting stopped: your repo\'s file list could not be read.',
|
|
@@ -689,12 +442,11 @@ export const STOP_HEADS = {
|
|
|
689
442
|
const STOP_TODO = /** @type {Record<string, string>} */ ({
|
|
690
443
|
refused: 'change what the message above names, then draft again.',
|
|
691
444
|
'interview-incomplete': 'fill in every line of the job form, then draft again.',
|
|
692
|
-
'calibration-missing': 'draft again; if it stops the same way twice, make your PASS/FAIL examples more concrete.',
|
|
693
|
-
'invalid-set': 'draft again; if it stops the same way twice, make your PASS/FAIL examples more concrete.',
|
|
694
445
|
'non-code-source': 'point the job at a code repo, or use a folder or file job instead.',
|
|
695
446
|
'listing-unreadable': 'check the repo is a readable git repo with at least one commit, then draft again.',
|
|
696
447
|
'confirm-abandoned': 'start a new draft when you are ready; nothing more was spent.',
|
|
697
448
|
'confirm-restart': 'change the answers you want and start the draft again.',
|
|
449
|
+
'plan-red': 'draft again; if it stops the same way twice, report it (nothing was spent on a close).',
|
|
698
450
|
});
|
|
699
451
|
|
|
700
452
|
/** a stop code this table does not know: still plain words, never the code */
|
|
@@ -713,11 +465,6 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
713
465
|
const detail = (Array.isArray(reds) ? reds : []).find((r) => r?.code === 'look-asks-too-many')?.detail;
|
|
714
466
|
if (detail) return `${redactSecrets(String(detail))}\nSpent so far: ${spent ?? 'unknown'}.`;
|
|
715
467
|
}
|
|
716
|
-
// 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
|
|
717
|
-
if (stop === 'fit-stopped') {
|
|
718
|
-
const detail = (Array.isArray(reds) ? reds : []).find((r) => r?.code === 'fit-stopped')?.detail;
|
|
719
|
-
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'}.`;
|
|
720
|
-
}
|
|
721
468
|
const heads = STOP_HEADS;
|
|
722
469
|
const redList = Array.isArray(reds) ? reds : [];
|
|
723
470
|
// F217: the first look at the repo failing (a dropped connection, a timeout) arrives as a `precheck` stop with a
|
|
@@ -746,8 +493,7 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
746
493
|
|
|
747
494
|
// ── THE SIGNING GATES' REFUSAL, in plain words (hamr, 2026-10-09) ──────────────────────────
|
|
748
495
|
//
|
|
749
|
-
// `prepareSigning` (src/authorjob.js) can refuse with a list of reds from
|
|
750
|
-
// `signing gates failed — calibration-miswrite, calibration-miswrite, calibration-miswrite, injection-leak`.
|
|
496
|
+
// `prepareSigning` (src/authorjob.js) can refuse with a list of reds from three gates (the old fourth, the calibration gate, is gone).
|
|
751
497
|
// Same principle as the proposal text above ("a user should get a reason that they can understand and do
|
|
752
498
|
// something about"): one owner, written by code, the structured reds travel beside it in the drafting log.
|
|
753
499
|
//
|
|
@@ -759,10 +505,6 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
759
505
|
// gate 1a/1b (the declaration; validateJob + validateCloseDecl): DECLARATION_CODES below, plus seed-unreadable
|
|
760
506
|
// and listing-unreadable (authorjob.js)
|
|
761
507
|
// gate 2 (precheck): broken-close
|
|
762
|
-
// gate 4 (calibration; calibrate.js + authorjob.js calibrationGate): calibration-missing, no-judge-seam,
|
|
763
|
-
// cap-halt, pricing-red, provider-red, artifact-red (the casualty axes), calibration-miswrite,
|
|
764
|
-
// injection-leak, and the invalid-set reds (invalid-value at `card`, calibration-case / -size / -polarity /
|
|
765
|
-
// -cardless / -orphan) which the proposal table above already words
|
|
766
508
|
// gate 3 refuses with NO red at all (refusal only: the close already passes at the seed)
|
|
767
509
|
// An unknown code is never dropped: it becomes a generic sentence that quotes the code.
|
|
768
510
|
|
|
@@ -770,76 +512,16 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
|
|
|
770
512
|
export const DECLARATION_CODES = Object.freeze([
|
|
771
513
|
'bounds', 'class-absent', 'class-battery-locked', 'class-ceiling', 'cmd-denied', 'duplicate-kind', 'duplicate-name',
|
|
772
514
|
'env-ownership-absent', 'genre-env-missing', 'genre-env-ungrounded', 'genre-owned-env', 'guard-missing',
|
|
773
|
-
'guard-weakened', 'guards-absent', 'human-stage-not-last', 'human-stage-offered', 'invalid-value', 'job-line-uncovered',
|
|
515
|
+
'guard-weakened', 'guards-absent', 'human-stage-not-last', 'human-stage-offered', 'invalid-value', 'job-line-uncovered',
|
|
774
516
|
'listing-absent', 'listing-conflict', 'locked-kind', 'missing-field', 'missing-required', 'one-population',
|
|
775
517
|
'path-not-in-listing', 'secret-literal', 'unknown-field', 'unknown-kind',
|
|
776
518
|
]);
|
|
777
519
|
|
|
778
|
-
/** the rulebook rules in the words of a person: what the rule flags */
|
|
779
|
-
const RULE_FLAGS = Object.freeze({
|
|
780
|
-
'has-doc': 'there is no doc comment',
|
|
781
|
-
'says-what': 'the doc only repeats the function\'s name',
|
|
782
|
-
params: 'a parameter is missing from the doc, or the doc names one that does not exist',
|
|
783
|
-
returns: 'the return value is not documented',
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
/** @param {unknown} rule @returns {string} */
|
|
787
|
-
const ruleFlag = (rule) => (typeof rule === 'string' && Object.hasOwn(RULE_FLAGS, rule)
|
|
788
|
-
? /** @type {Record<string,string>} */ (RULE_FLAGS)[rule] : `the rule "${safeText(rule)}" applies`);
|
|
789
|
-
|
|
790
|
-
/** "says-what · initCache; params · initCache" to [{rule, fn}] @param {string} list */
|
|
791
|
-
const ruleFns = (list) => list.split(';').map((x) => x.trim()).filter(Boolean).map((x) => {
|
|
792
|
-
const [rule, fn] = x.split('·').map((t) => t.trim());
|
|
793
|
-
return { rule, fn: fn ?? '' };
|
|
794
|
-
});
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
* A calibration-miswrite red as plain sentences: what the practice case expected against what the check found,
|
|
798
|
-
* read off the red's own detail (the compareExpectation pieces calibrate.js writes).
|
|
799
|
-
* @param {PlainRed} r @returns {string[]}
|
|
800
|
-
*/
|
|
801
|
-
function miswriteSentences(r) {
|
|
802
|
-
const who = `Case "${safeText(r.caseId ?? /^case "(.*?)" was graded/.exec(r.detail)?.[1] ?? '')}"`;
|
|
803
|
-
const missing = MISSING_REDS_RE.exec(r.detail)?.[1];
|
|
804
|
-
const extra = EXTRA_REDS_RE.exec(r.detail)?.[1];
|
|
805
|
-
/** @type {string[]} */
|
|
806
|
-
const out = [];
|
|
807
|
-
for (const { rule, fn } of missing ? ruleFns(missing) : []) {
|
|
808
|
-
out.push(`${who}${fn ? ` (${safeText(fn)})` : ''}: the practice case says ${ruleFlag(rule)}, but the check passed it.`);
|
|
809
|
-
}
|
|
810
|
-
for (const { rule, fn } of extra ? ruleFns(extra) : []) {
|
|
811
|
-
out.push(`${who}${fn ? ` (${safeText(fn)})` : ''}: the check says ${ruleFlag(rule)}, but the practice case did not expect that.`);
|
|
812
|
-
}
|
|
813
|
-
if (out.length === 0) {
|
|
814
|
-
const m = /signed "(\w+)", the pipe rendered "(\w+)"/.exec(r.detail);
|
|
815
|
-
out.push(m
|
|
816
|
-
? `${who}: the practice case says ${m[1] === 'red' ? 'fail' : 'pass'}, but the check said ${m[2] === 'red' ? 'fail' : 'pass'}.`
|
|
817
|
-
: `${who}: the practice case and the check disagree.`);
|
|
818
|
-
}
|
|
819
|
-
return out;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
520
|
/**
|
|
823
521
|
* @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed) => string[], todo: string}[]}
|
|
824
522
|
* Order matters; the first match wins. `todo` is the one thing the person can do.
|
|
825
523
|
*/
|
|
826
524
|
const SIGNING_TABLE = [
|
|
827
|
-
{ kind: 'miswrite', when: (r) => r.code === 'calibration-miswrite', say: miswriteSentences, todo: 'draft again' },
|
|
828
|
-
{ kind: 'injection-leak', when: (r) => r.code === 'injection-leak',
|
|
829
|
-
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.`],
|
|
830
|
-
todo: 'draft again' },
|
|
831
|
-
{ kind: 'calibration-missing', when: (r) => r.code === 'calibration-missing',
|
|
832
|
-
say: () => ['The rubric came without practice cases, so the check was never tried out.'], todo: 'draft again' },
|
|
833
|
-
{ kind: 'no-judge', when: (r) => r.code === 'no-judge-seam',
|
|
834
|
-
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' },
|
|
835
|
-
{ kind: 'cap-halt', when: (r) => r.code === 'cap-halt',
|
|
836
|
-
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' },
|
|
837
|
-
{ kind: 'pricing-red', when: (r) => r.code === 'pricing-red',
|
|
838
|
-
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' },
|
|
839
|
-
{ kind: 'provider-red', when: (r) => r.code === 'provider-red',
|
|
840
|
-
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' },
|
|
841
|
-
{ kind: 'artifact-red', when: (r) => r.code === 'artifact-red',
|
|
842
|
-
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' },
|
|
843
525
|
// M2: a rubric job's check has no install/build/test commands to blame — its own wording, never the code-job one
|
|
844
526
|
{ kind: 'broken-close-rubric', when: (r) => r.code === 'broken-close' && r.rubricJob === true,
|
|
845
527
|
say: (r) => [`A check of the close (${safeText(r.path.split('.').pop() ?? '')}) could not run, so nothing it reported could be trusted.`],
|
|
@@ -851,23 +533,13 @@ const SIGNING_TABLE = [
|
|
|
851
533
|
say: () => ['bareloop could not read the repository\'s starting commit.'], todo: 'check that the source is a git repository with at least one commit' },
|
|
852
534
|
{ kind: 'listing-unreadable', when: (r) => r.code === 'listing-unreadable',
|
|
853
535
|
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' },
|
|
854
|
-
{ kind: 'judged-outside-fence', when: (r) => r.code === 'judged-outside-write-scope',
|
|
855
|
-
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.`],
|
|
856
|
-
todo: 'draft again' },
|
|
857
536
|
// Part 1a: the rubric-step sorting reds are already whole sentences in the person's words (src/rubricstep.js `checkRubricParts`)
|
|
858
537
|
{ kind: 'rubric-part', when: (r) => r.code.startsWith('rubric-'), say: (r) => [fullText(r.detail)], todo: 'draft again, or reword that line' },
|
|
859
538
|
{ kind: 'rubric-shape', when: isRubricShape, say: (r) => [rubricShapeSentence(r)], todo: 'draft again, or reword that line' },
|
|
860
|
-
{ kind: 'declaration', when: (r) => DECLARATION_CODES.includes(r.code)
|
|
539
|
+
{ kind: 'declaration', when: (r) => DECLARATION_CODES.includes(r.code),
|
|
861
540
|
say: (r) => [`The close the model wrote was refused before anything ran ("${safeText(r.code)}" at ${safeText(r.path)}).`], todo: 'draft again' },
|
|
862
541
|
];
|
|
863
542
|
|
|
864
|
-
/** a red's string list as plain text, each entry scrubbed and bounded
|
|
865
|
-
* @param {unknown} v @returns {string} */
|
|
866
|
-
const listText = (v) => {
|
|
867
|
-
const items = (Array.isArray(v) ? v : []).filter((x) => typeof x === 'string' && x !== '').slice(0, 4).map((x) => safeText(x));
|
|
868
|
-
return items.length ? items.join(', ') : 'files outside the edit area';
|
|
869
|
-
};
|
|
870
|
-
|
|
871
543
|
/** the sentence when the gates refuse with no red at all (the close already passes on the untouched repository) */
|
|
872
544
|
const SEED_GREEN_SENTENCE = 'Nothing in the close fails on the repository as it is, so there is nothing for a run to do.';
|
|
873
545
|
|
|
@@ -876,30 +548,18 @@ const NO_CHECK_SENTENCE = 'This job has no check that can fail: no `~` rule, and
|
|
|
876
548
|
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';
|
|
877
549
|
|
|
878
550
|
/**
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
* @param {any} closeDecl @returns {boolean}
|
|
882
|
-
*/
|
|
883
|
-
export function isNoCheckRubricClose(closeDecl) {
|
|
884
|
-
if (!closeDecl || closeDecl.lang !== 'text' || !Array.isArray(closeDecl.stages)) return false;
|
|
885
|
-
return !closeDecl.stages.some((/** @type {any} */ st) => st && st.kind !== 'files-changed'
|
|
886
|
-
&& (st.kind !== 'rubric-step' || (Array.isArray(st.params?.parts) && st.params.parts.length > 0)));
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Plain sentences for the reds of a refused signing, one or more per red. Card and practice-case reds reuse the
|
|
891
|
-
* proposal table; an unknown code is a generic sentence that quotes the code.
|
|
892
|
-
* @param {PlainRed[]} reds @param {{cases?: any}} [o]
|
|
551
|
+
* 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.
|
|
552
|
+
* @param {PlainRed[]} reds
|
|
893
553
|
* @returns {{kind: string, sentence: string, todo: string, red: PlainRed}[]}
|
|
894
554
|
*/
|
|
895
|
-
export function signingReasons(reds
|
|
555
|
+
export function signingReasons(reds) {
|
|
896
556
|
/** @type {{kind: string, sentence: string, todo: string, red: PlainRed}[]} */
|
|
897
557
|
const out = [];
|
|
898
558
|
for (const red of Array.isArray(reds) ? reds : []) {
|
|
899
559
|
const r = /** @type {PlainRed} */ ({ ...red, code: String(red?.code ?? ''), path: String(red?.path ?? ''), detail: String(red?.detail ?? '') });
|
|
900
560
|
const hit = SIGNING_TABLE.find((e) => e.when(r));
|
|
901
561
|
if (hit) { for (const sentence of hit.say(r)) out.push({ kind: hit.kind, sentence, todo: hit.todo, red: r }); continue; }
|
|
902
|
-
const [pr] = plainReasons([r]
|
|
562
|
+
const [pr] = plainReasons([r]);
|
|
903
563
|
if (pr && pr.kind !== 'unmapped') { out.push({ kind: pr.kind, sentence: pr.sentence, todo: 'draft again', red: r }); continue; }
|
|
904
564
|
out.push({
|
|
905
565
|
kind: 'unmapped',
|
|
@@ -919,14 +579,13 @@ export function signingKinds() {
|
|
|
919
579
|
|
|
920
580
|
/**
|
|
921
581
|
* THE MESSAGE a person reads when the signing gates refuse. The panel's failed step and the CLI print exactly this.
|
|
922
|
-
* @param {{reds: PlainRed[], refusal?: {detail?: string}|null,
|
|
923
|
-
* spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o
|
|
582
|
+
* @param {{reds: PlainRed[], refusal?: {detail?: string}|null, noCheck?: boolean,
|
|
583
|
+
* 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
|
|
924
584
|
* @returns {string}
|
|
925
585
|
*/
|
|
926
|
-
export function signingStopText({ reds, refusal = null,
|
|
927
|
-
const reasons = signingReasons(reds
|
|
586
|
+
export function signingStopText({ reds, refusal = null, spend = null, noCheck = false }) {
|
|
587
|
+
const reasons = signingReasons(reds);
|
|
928
588
|
if (reasons.length === 0) {
|
|
929
|
-
const noCheck = isNoCheckRubricClose(closeDecl);
|
|
930
589
|
reasons.push({ kind: 'seed-green', sentence: noCheck ? NO_CHECK_SENTENCE : SEED_GREEN_SENTENCE,
|
|
931
590
|
todo: noCheck ? NO_CHECK_TODO : 'check that the close measures the right thing, or describe a sharper problem',
|
|
932
591
|
red: { code: '', path: '', detail: String(refusal?.detail ?? '') } });
|
|
@@ -937,9 +596,6 @@ export function signingStopText({ reds, refusal = null, cases = null, spend = nu
|
|
|
937
596
|
const lines = [`The checks before signing did not all pass, so nothing was signed. Spent so far: ${spent ?? 'unknown'}.`, 'What was wrong:'];
|
|
938
597
|
for (const s of shown) lines.push(` • ${s}`);
|
|
939
598
|
if (unique.length > shown.length) lines.push(` • …and ${unique.length - shown.length} more.`);
|
|
940
|
-
if (reasons.some((x) => x.kind === 'miswrite' || x.kind === 'injection-leak')) {
|
|
941
|
-
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.');
|
|
942
|
-
}
|
|
943
599
|
lines.push(`What to do: ${reasons[0].todo}${reasons[0].todo === 'draft again' && spent ? ` (about ${spent} to reach here)` : ''}.`);
|
|
944
600
|
return lines.join('\n');
|
|
945
601
|
}
|
|
@@ -947,13 +603,13 @@ export function signingStopText({ reds, refusal = null, cases = null, spend = nu
|
|
|
947
603
|
/**
|
|
948
604
|
* The reds as the drafting log keeps them: every structured field, the plain
|
|
949
605
|
* sentence beside it, every string secret-scrubbed and bounded, the list capped.
|
|
950
|
-
* @param {PlainRed[]} reds @param {{
|
|
606
|
+
* @param {PlainRed[]} reds @param {{signing?: boolean}} [o] `signing`: the reds are the signing gates', worded by signingReasons
|
|
951
607
|
* @returns {Record<string, any>[]}
|
|
952
608
|
*/
|
|
953
|
-
export function redsRecord(reds, {
|
|
609
|
+
export function redsRecord(reds, { signing = false } = {}) {
|
|
954
610
|
/** @param {unknown} s */
|
|
955
611
|
const cut = (s) => { const t = redactSecrets(String(s ?? '')); return t.length > RECORD_STR_MAX ? `${t.slice(0, RECORD_STR_MAX)}…` : t; };
|
|
956
|
-
return (signing ? signingReasons(reds
|
|
612
|
+
return (signing ? signingReasons(reds) : plainReasons(reds)).slice(0, RECORD_MAX_REDS).map(({ kind, sentence, red }) => {
|
|
957
613
|
/** @type {Record<string, any>} */
|
|
958
614
|
const out = { kind, plain: sentence };
|
|
959
615
|
for (const [k, v] of Object.entries(red)) {
|