bareloop 0.56.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +65 -207
  4. package/package.json +2 -2
  5. package/src/authorflow.js +25 -78
  6. package/src/authoring.js +5 -124
  7. package/src/authorjob.js +33 -395
  8. package/src/authorreadout.js +17 -355
  9. package/src/authorrun.js +8 -211
  10. package/src/blockasks.js +2 -2
  11. package/src/bundlerun.js +4 -1
  12. package/src/checkblock.js +76 -50
  13. package/src/checklist.js +1 -1
  14. package/src/checkpick.js +10 -1
  15. package/src/cli.js +3 -3
  16. package/src/declaredclose.js +11 -110
  17. package/src/destpoint.js +1 -1
  18. package/src/index.js +3 -43
  19. package/src/interviewrun.js +13 -8
  20. package/src/job.js +20 -1
  21. package/src/jobblock.js +11 -46
  22. package/src/judged.js +13 -1229
  23. package/src/kinds.js +5 -347
  24. package/src/noteask.js +124 -0
  25. package/src/pagedry.js +27 -5
  26. package/src/pagemap.js +2 -2
  27. package/src/pagerules.js +18 -3
  28. package/src/panel/authorroutes.js +9 -3
  29. package/src/panel/authorsession.js +99 -141
  30. package/src/panel/importrun.js +0 -1
  31. package/src/panel/index.html +6 -6
  32. package/src/panel/jobplan.js +7 -5
  33. package/src/panel/server.js +25 -64
  34. package/src/panel/status.js +3 -0
  35. package/src/pickrecord.js +15 -54
  36. package/src/planrun.js +2 -48
  37. package/src/promptregisters.js +2 -17
  38. package/src/providerrows.js +0 -36
  39. package/src/providers.js +4 -25
  40. package/src/questionbox.js +4 -12
  41. package/src/rubricstep.js +26 -6
  42. package/src/run.js +2 -15
  43. package/src/userrun.js +14 -111
  44. package/types/authorflow.d.ts +9 -58
  45. package/types/authoring.d.ts +1 -14
  46. package/types/authorjob.d.ts +13 -55
  47. package/types/authorreadout.d.ts +8 -80
  48. package/types/blockasks.d.ts +1 -2
  49. package/types/checkblock.d.ts +32 -17
  50. package/types/checklist.d.ts +2 -2
  51. package/types/checkpick.d.ts +5 -0
  52. package/types/cli.d.ts +1 -3
  53. package/types/declaredclose.d.ts +3 -33
  54. package/types/index.d.ts +2 -4
  55. package/types/job.d.ts +8 -0
  56. package/types/jobblock.d.ts +8 -38
  57. package/types/judged.d.ts +7 -357
  58. package/types/kinds.d.ts +3 -104
  59. package/types/noteask.d.ts +76 -0
  60. package/types/pagedry.d.ts +13 -0
  61. package/types/pagerules.d.ts +7 -0
  62. package/types/panel/authorsession.d.ts +35 -4
  63. package/types/panel/jobplan.d.ts +3 -3
  64. package/types/panel/server.d.ts +13 -5
  65. package/types/panel/status.d.ts +5 -0
  66. package/types/pickrecord.d.ts +8 -13
  67. package/types/planrun.d.ts +1 -22
  68. package/types/providerrows.d.ts +0 -31
  69. package/types/providers.d.ts +3 -19
  70. package/types/rubricstep.d.ts +9 -0
  71. package/types/run.d.ts +1 -20
  72. package/types/userrun.d.ts +0 -1
  73. package/src/calibrate.js +0 -702
  74. package/src/cardauthor.js +0 -502
  75. package/src/fitcheck.js +0 -168
  76. package/types/calibrate.d.ts +0 -201
  77. package/types/cardauthor.d.ts +0 -358
  78. package/types/fitcheck.d.ts +0 -119
@@ -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
@@ -328,11 +191,6 @@ export function phaseLine(phase, data = {}) {
328
191
  case 'seed-read': return `· measuring ${data.stages ?? '?'} stage(s) at the seed — each one runs a real toolchain…`;
329
192
  case 'stage': return `· ${data.stage} [${data.kind}] ${data.verdict} — ${ms(data.durationMs)}`;
330
193
  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
194
  // A phase this renderer does not know is PRINTED, not swallowed: the callers
337
195
  // are the library's own seams and a new one appearing unrendered is how a
338
196
  // readout silently stops covering what it reports on.
@@ -413,12 +271,6 @@ const PLAIN_MAX_BULLETS = 8;
413
271
  const RECORD_MAX_REDS = 40;
414
272
  const RECORD_STR_MAX = 600;
415
273
 
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
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
423
275
  * @param {unknown} s @returns {string} */
424
276
  function fullText(s) {
@@ -459,85 +311,16 @@ function rubricShapeSentence(r) {
459
311
  }
460
312
 
461
313
  /**
462
- * The ONE table of plain kinds → sentence builders. A builder gets the red, the
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.
314
+ * The ONE table of plain kinds → sentence builders. A builder gets the red. `unmapped` is the only kind the table does not list.
465
315
  * Order matters: the first matching entry wins.
466
- * @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed, c: string, m: RegExpMatchArray|null) => string}[]}
316
+ * @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed) => string}[]}
467
317
  */
468
318
  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
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
485
320
  { kind: 'rubric-red', when: (r) => r.code.startsWith('rubric-'), say: (r) => fullText(r.detail) },
486
321
  { 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
322
  ];
535
323
 
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
324
  /**
542
325
  * Every plain kind the table can emit — the list the test enumerates against.
543
326
  * @returns {string[]}
@@ -551,18 +334,13 @@ export function plainKinds() {
551
334
  * An unknown code is NEVER dropped: it becomes a generic sentence that still
552
335
  * quotes the code and path, under the kind `unmapped`.
553
336
  * @param {PlainRed[]} reds
554
- * @param {{cases?: any}} [o] the proposed cases, to name a case by its own id
555
337
  * @returns {PlainReason[]}
556
338
  */
557
- export function plainReasons(reds, { cases = null } = {}) {
339
+ export function plainReasons(reds) {
558
340
  return (Array.isArray(reds) ? reds : []).map((red) => {
559
341
  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
342
  const hit = PLAIN_TABLE.find((e) => e.when(r));
565
- if (hit) return { kind: hit.kind, sentence: hit.say(r, caseName, null), red: r };
343
+ if (hit) return { kind: hit.kind, sentence: hit.say(r), red: r };
566
344
  return {
567
345
  kind: 'unmapped',
568
346
  sentence: `The model's proposal failed a check that has no plain wording yet ("${safeText(r.code)}" at ${safeText(r.path)}).`,
@@ -624,34 +402,6 @@ function said1(r) {
624
402
  return isRubricShape(red) ? rubricShapeSentence(red) : safeText(red.detail);
625
403
  }
626
404
 
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
405
  // ── ANY DRAFTING STOP, in plain words (P7 item 6, live session smv2bzdqmp0f8, 2026-10-10) ───────────────────────────
656
406
  // A provider-red used to reach the panel as the bare line "Stopped: provider-red" — a code, no reason. Every stop of the
657
407
  // drafting loop that is not a rubric-proposal or signing refusal (those have their own wording above and below) now says
@@ -677,8 +427,6 @@ export const STOP_HEADS = {
677
427
  'scout-absent': 'Drafting stopped: the first look at your repo or input did not complete.',
678
428
  refused: 'Drafting stopped: something in the job or its inputs is not allowed.',
679
429
  '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
430
  'broken-close': 'Drafting stopped: the final check the model wrote could not run.',
683
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.',
684
432
  'listing-absent': 'Drafting stopped: the list of your files was not available, so the checks could not name any.',
@@ -694,8 +442,6 @@ export const STOP_HEADS = {
694
442
  const STOP_TODO = /** @type {Record<string, string>} */ ({
695
443
  refused: 'change what the message above names, then draft again.',
696
444
  '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
445
  'non-code-source': 'point the job at a code repo, or use a folder or file job instead.',
700
446
  'listing-unreadable': 'check the repo is a readable git repo with at least one commit, then draft again.',
701
447
  'confirm-abandoned': 'start a new draft when you are ready; nothing more was spent.',
@@ -719,11 +465,6 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
719
465
  const detail = (Array.isArray(reds) ? reds : []).find((r) => r?.code === 'look-asks-too-many')?.detail;
720
466
  if (detail) return `${redactSecrets(String(detail))}\nSpent so far: ${spent ?? 'unknown'}.`;
721
467
  }
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
468
  const heads = STOP_HEADS;
728
469
  const redList = Array.isArray(reds) ? reds : [];
729
470
  // F217: the first look at the repo failing (a dropped connection, a timeout) arrives as a `precheck` stop with a
@@ -752,8 +493,7 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
752
493
 
753
494
  // ── THE SIGNING GATES' REFUSAL, in plain words (hamr, 2026-10-09) ──────────────────────────
754
495
  //
755
- // `prepareSigning` (src/authorjob.js) can refuse with a list of reds from four gates. The panel used to say
756
- // `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).
757
497
  // Same principle as the proposal text above ("a user should get a reason that they can understand and do
758
498
  // something about"): one owner, written by code, the structured reds travel beside it in the drafting log.
759
499
  //
@@ -765,10 +505,6 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
765
505
  // gate 1a/1b (the declaration; validateJob + validateCloseDecl): DECLARATION_CODES below, plus seed-unreadable
766
506
  // and listing-unreadable (authorjob.js)
767
507
  // 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
508
  // gate 3 refuses with NO red at all (refusal only: the close already passes at the seed)
773
509
  // An unknown code is never dropped: it becomes a generic sentence that quotes the code.
774
510
 
@@ -776,76 +512,16 @@ export function draftStopText({ stop, reds = null, refusal = null, spend = null,
776
512
  export const DECLARATION_CODES = Object.freeze([
777
513
  'bounds', 'class-absent', 'class-battery-locked', 'class-ceiling', 'cmd-denied', 'duplicate-kind', 'duplicate-name',
778
514
  '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', 'judged-outside-write-scope', 'judged-stage-order',
515
+ 'guard-weakened', 'guards-absent', 'human-stage-not-last', 'human-stage-offered', 'invalid-value', 'job-line-uncovered',
780
516
  'listing-absent', 'listing-conflict', 'locked-kind', 'missing-field', 'missing-required', 'one-population',
781
517
  'path-not-in-listing', 'secret-literal', 'unknown-field', 'unknown-kind',
782
518
  ]);
783
519
 
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
520
  /**
829
521
  * @type {{kind: string, when: (r: PlainRed) => boolean, say: (r: PlainRed) => string[], todo: string}[]}
830
522
  * Order matters; the first match wins. `todo` is the one thing the person can do.
831
523
  */
832
524
  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
525
  // M2: a rubric job's check has no install/build/test commands to blame — its own wording, never the code-job one
850
526
  { kind: 'broken-close-rubric', when: (r) => r.code === 'broken-close' && r.rubricJob === true,
851
527
  say: (r) => [`A check of the close (${safeText(r.path.split('.').pop() ?? '')}) could not run, so nothing it reported could be trusted.`],
@@ -857,23 +533,13 @@ const SIGNING_TABLE = [
857
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' },
858
534
  { kind: 'listing-unreadable', when: (r) => r.code === 'listing-unreadable',
859
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' },
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
536
  // Part 1a: the rubric-step sorting reds are already whole sentences in the person's words (src/rubricstep.js `checkRubricParts`)
864
537
  { kind: 'rubric-part', when: (r) => r.code.startsWith('rubric-'), say: (r) => [fullText(r.detail)], todo: 'draft again, or reword that line' },
865
538
  { 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) && !(r.code === 'invalid-value' && r.path === 'card'),
539
+ { kind: 'declaration', when: (r) => DECLARATION_CODES.includes(r.code),
867
540
  say: (r) => [`The close the model wrote was refused before anything ran ("${safeText(r.code)}" at ${safeText(r.path)}).`], todo: 'draft again' },
868
541
  ];
869
542
 
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
543
  /** the sentence when the gates refuse with no red at all (the close already passes on the untouched repository) */
878
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.';
879
545
 
@@ -882,19 +548,18 @@ const NO_CHECK_SENTENCE = 'This job has no check that can fail: no `~` rule, and
882
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';
883
549
 
884
550
  /**
885
- * Plain sentences for the reds of a refused signing, one or more per red. Card and practice-case reds reuse the
886
- * proposal table; an unknown code is a generic sentence that quotes the code.
887
- * @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
888
553
  * @returns {{kind: string, sentence: string, todo: string, red: PlainRed}[]}
889
554
  */
890
- export function signingReasons(reds, { cases = null } = {}) {
555
+ export function signingReasons(reds) {
891
556
  /** @type {{kind: string, sentence: string, todo: string, red: PlainRed}[]} */
892
557
  const out = [];
893
558
  for (const red of Array.isArray(reds) ? reds : []) {
894
559
  const r = /** @type {PlainRed} */ ({ ...red, code: String(red?.code ?? ''), path: String(red?.path ?? ''), detail: String(red?.detail ?? '') });
895
560
  const hit = SIGNING_TABLE.find((e) => e.when(r));
896
561
  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], { cases });
562
+ const [pr] = plainReasons([r]);
898
563
  if (pr && pr.kind !== 'unmapped') { out.push({ kind: pr.kind, sentence: pr.sentence, todo: 'draft again', red: r }); continue; }
899
564
  out.push({
900
565
  kind: 'unmapped',
@@ -914,12 +579,12 @@ export function signingKinds() {
914
579
 
915
580
  /**
916
581
  * 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, cases?: any, noCheck?: boolean,
582
+ * @param {{reds: PlainRed[], refusal?: {detail?: string}|null, noCheck?: boolean,
918
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
919
584
  * @returns {string}
920
585
  */
921
- export function signingStopText({ reds, refusal = null, cases = null, spend = null, noCheck = false }) {
922
- const reasons = signingReasons(reds, { cases });
586
+ export function signingStopText({ reds, refusal = null, spend = null, noCheck = false }) {
587
+ const reasons = signingReasons(reds);
923
588
  if (reasons.length === 0) {
924
589
  reasons.push({ kind: 'seed-green', sentence: noCheck ? NO_CHECK_SENTENCE : SEED_GREEN_SENTENCE,
925
590
  todo: noCheck ? NO_CHECK_TODO : 'check that the close measures the right thing, or describe a sharper problem',
@@ -931,9 +596,6 @@ export function signingStopText({ reds, refusal = null, cases = null, spend = nu
931
596
  const lines = [`The checks before signing did not all pass, so nothing was signed. Spent so far: ${spent ?? 'unknown'}.`, 'What was wrong:'];
932
597
  for (const s of shown) lines.push(` • ${s}`);
933
598
  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
599
  lines.push(`What to do: ${reasons[0].todo}${reasons[0].todo === 'draft again' && spent ? ` (about ${spent} to reach here)` : ''}.`);
938
600
  return lines.join('\n');
939
601
  }
@@ -941,13 +603,13 @@ export function signingStopText({ reds, refusal = null, cases = null, spend = nu
941
603
  /**
942
604
  * The reds as the drafting log keeps them: every structured field, the plain
943
605
  * sentence beside it, every string secret-scrubbed and bounded, the list capped.
944
- * @param {PlainRed[]} reds @param {{cases?: any, signing?: boolean}} [o] `signing`: the reds are the signing gates', worded by signingReasons
606
+ * @param {PlainRed[]} reds @param {{signing?: boolean}} [o] `signing`: the reds are the signing gates', worded by signingReasons
945
607
  * @returns {Record<string, any>[]}
946
608
  */
947
- export function redsRecord(reds, { cases = null, signing = false } = {}) {
609
+ export function redsRecord(reds, { signing = false } = {}) {
948
610
  /** @param {unknown} s */
949
611
  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, { cases }) : plainReasons(reds, { cases })).slice(0, RECORD_MAX_REDS).map(({ kind, sentence, red }) => {
612
+ return (signing ? signingReasons(reds) : plainReasons(reds)).slice(0, RECORD_MAX_REDS).map(({ kind, sentence, red }) => {
951
613
  /** @type {Record<string, any>} */
952
614
  const out = { kind, plain: sentence };
953
615
  for (const [k, v] of Object.entries(red)) {