bareloop 0.56.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +75 -214
  4. package/package.json +2 -2
  5. package/src/authorflow.js +71 -136
  6. package/src/authoring.js +5 -124
  7. package/src/authorjob.js +125 -417
  8. package/src/authorreadout.js +105 -355
  9. package/src/authorrun.js +70 -234
  10. package/src/authorscout.js +9 -1
  11. package/src/blockasks.js +12 -17
  12. package/src/bundlerun.js +4 -1
  13. package/src/checkblock.js +297 -75
  14. package/src/checklist.js +1 -1
  15. package/src/checkpick.js +9 -5
  16. package/src/cli.js +3 -3
  17. package/src/declaredclose.js +45 -112
  18. package/src/destpoint.js +1 -1
  19. package/src/draftspend.js +20 -4
  20. package/src/fencepointcall.js +76 -0
  21. package/src/guarddescriptions.js +14 -0
  22. package/src/index.js +3 -43
  23. package/src/interviewrun.js +13 -8
  24. package/src/job.js +20 -1
  25. package/src/jobblock.js +11 -46
  26. package/src/judged.js +13 -1229
  27. package/src/kinds.js +10 -348
  28. package/src/noteask.js +124 -0
  29. package/src/pagedry.js +27 -5
  30. package/src/pagemap.js +7 -29
  31. package/src/pagerules.js +18 -3
  32. package/src/panel/authorroutes.js +15 -4
  33. package/src/panel/authorsession.js +201 -167
  34. package/src/panel/importrun.js +0 -1
  35. package/src/panel/index.html +43 -18
  36. package/src/panel/jobplan.js +54 -19
  37. package/src/panel/server.js +90 -69
  38. package/src/panel/status.js +3 -0
  39. package/src/pickrecord.js +15 -54
  40. package/src/planrun.js +4 -48
  41. package/src/promptregisters.js +7 -17
  42. package/src/providerrows.js +0 -36
  43. package/src/providers.js +4 -25
  44. package/src/questionbox.js +34 -30
  45. package/src/reviewdoor.js +1 -1
  46. package/src/rowresults.js +69 -0
  47. package/src/rubricstep.js +136 -28
  48. package/src/run.js +2 -15
  49. package/src/stagewords.js +24 -0
  50. package/src/userrun.js +14 -111
  51. package/types/authorflow.d.ts +51 -137
  52. package/types/authoring.d.ts +1 -14
  53. package/types/authorjob.d.ts +14 -55
  54. package/types/authorreadout.d.ts +52 -80
  55. package/types/authorrun.d.ts +20 -0
  56. package/types/blockasks.d.ts +5 -11
  57. package/types/checkblock.d.ts +147 -28
  58. package/types/checklist.d.ts +2 -2
  59. package/types/checkpick.d.ts +5 -3
  60. package/types/cli.d.ts +1 -3
  61. package/types/declaredclose.d.ts +5 -33
  62. package/types/draftspend.d.ts +16 -2
  63. package/types/fencepointcall.d.ts +68 -0
  64. package/types/guarddescriptions.d.ts +7 -0
  65. package/types/index.d.ts +2 -4
  66. package/types/job.d.ts +8 -0
  67. package/types/jobblock.d.ts +8 -38
  68. package/types/judged.d.ts +7 -357
  69. package/types/kinds.d.ts +4 -104
  70. package/types/noteask.d.ts +76 -0
  71. package/types/pagedry.d.ts +13 -0
  72. package/types/pagemap.d.ts +2 -5
  73. package/types/pagerules.d.ts +7 -0
  74. package/types/panel/authorsession.d.ts +37 -5
  75. package/types/panel/jobplan.d.ts +15 -3
  76. package/types/panel/server.d.ts +46 -13
  77. package/types/panel/status.d.ts +5 -0
  78. package/types/pickrecord.d.ts +8 -13
  79. package/types/planrun.d.ts +1 -22
  80. package/types/providerrows.d.ts +0 -31
  81. package/types/providers.d.ts +3 -19
  82. package/types/questionbox.d.ts +20 -6
  83. package/types/rowresults.d.ts +23 -0
  84. package/types/rubricstep.d.ts +43 -7
  85. package/types/run.d.ts +1 -20
  86. package/types/stagewords.d.ts +11 -0
  87. package/types/userrun.d.ts +0 -1
  88. package/src/calibrate.js +0 -702
  89. package/src/cardauthor.js +0 -502
  90. package/src/fitcheck.js +0 -168
  91. package/types/calibrate.d.ts +0 -201
  92. package/types/cardauthor.d.ts +0 -358
  93. package/types/fitcheck.d.ts +0 -119
package/src/pagemap.js CHANGED
@@ -199,50 +199,28 @@ export async function runPageMap({
199
199
  export const DROP_IT = 'drop it';
200
200
  /** @param {unknown} text @returns {boolean} */
201
201
  export const isDropIt = (text) => String(text ?? '').trim().replace(/\.$/, '').toLowerCase() === DROP_IT;
202
- /** the answers that accept the code's reading of a rule; anything else the person types is their own reading */
202
+ /** the answers that accept the code's reading of a rule (the Result tab's "(you confirmed)" reads an old typed one) */
203
203
  const AGREE_WORDS = ['agree', 'yes'];
204
204
  /** @param {unknown} text @returns {boolean} */
205
205
  export const isAgree = (text) => AGREE_WORDS.includes(String(text ?? '').trim().replace(/[.!]$/, '').toLowerCase());
206
- /**
207
- * F240: an answer that opens with an agree word IMMEDIATELY followed by a comma or a colon (spaces allowed only after it) and more text
208
- * ("yes, check it as ...", "agree: the outbound flight") is the person's own reading with a courtesy word in front: the word and the
209
- * comma/colon go, the rest stays word for word. No hyphen or dash of any kind and no bare space counts, so "yes-no questions only",
210
- * "agree-ment on price", "yes - departs", "yes departs" and "yesterday, ..." are kept whole. A bare "yes"/"agree" (isAgree) and a text that
211
- * only contains the word later are returned untouched.
212
- * @param {string} text @returns {string}
213
- */
214
- export const stripAgreeLead = (text) => {
215
- const m = String(text ?? '').match(new RegExp(`^(?:${AGREE_WORDS.join('|')})[,:]\\s*(\\S[\\s\\S]*)$`, 'i'));
216
- return m ? m[1].trim() : String(text ?? '');
217
- };
218
-
219
206
  /** @typedef {{line: number, rule: number, source: 'look', question: string, ask: 'reading'|'cant-check'|'check'|'no-check', ruleText: string, reading?: string}} LookAsk
220
207
  * `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only) */
221
208
 
222
209
  /** the words of a reading ask: the ONE spelling, and {@link readingOfQuestion} reads it back (the Result tab's "(you confirmed)") */
223
210
  const READING_HEAD = ' I read it as: ';
224
211
  const READING_ASKED = '. Agree?';
225
- /** the part of a reading ask that tells the CLI's typed words (the panel's question box shows the question without it: src/questionbox.js) */
226
- const READING_ANSWER = ' Answer "agree"';
227
- const READING_TAIL = `${READING_ASKED}${READING_ANSWER}`;
228
- /** @param {number} n @returns {string} the rest of a reading ask after its answer words */
229
- const readingRest = (n) => `, or type your own reading (your answer is added as a new ~ rule on line ${n}).`;
230
- /** @param {number} n @returns {string} the answer words a reading ask ends with (said once, here, and cut in the panel) */
231
- export const readingTail = (n) => `${READING_ANSWER}${readingRest(n)}`;
232
- /** @param {number} n @returns {string} the answer words a can't-check ask ends with (said once, here, and cut in the panel) */
233
- export const cantCheckTail = (n) => ` Answer "${DROP_IT}", or type how to check it (your answer is added as a new ~ rule on line ${n}).`;
234
- /** @param {number} n @param {string} rule @param {string} reading @returns {string} */
235
- export const readingQuestion = (n, rule, reading) => `Your line ${n} says "${rule}".${READING_HEAD}${reading}${READING_TAIL}${readingRest(n)}`;
212
+ /** @param {number} n @param {string} rule @param {string} reading @returns {string} a reading ask: the question only (hamr 2026-11-15: buttons only, so no answer words; a rule is changed by Revise) */
213
+ export const readingQuestion = (n, rule, reading) => `Your line ${n} says "${rule}".${READING_HEAD}${reading}${READING_ASKED}`;
236
214
  /** @param {unknown} q a recorded question @returns {string|null} the reading a reading ask proposed, or null when it was another kind of question */
237
215
  export function readingOfQuestion(q) {
238
216
  const s = String(q ?? '');
239
217
  const a = s.indexOf(READING_HEAD);
240
- const b = s.indexOf(READING_TAIL);
218
+ const b = s.indexOf(READING_ASKED, a + 1);
241
219
  return a >= 0 && b > a ? s.slice(a + READING_HEAD.length, b) : null;
242
220
  }
243
221
 
244
222
  /** @param {number} n @param {string} rule @returns {string} the can't-check ask of a rule the page cannot check */
245
- export const cantCheckQuestion = (n, rule) => `Your line ${n} says "${rule}". I can't check this on the page. Drop it?${cantCheckTail(n)}`;
223
+ export const cantCheckQuestion = (n, rule, where = ' on the page') => `Your line ${n} says "${rule}". I can't check this${where}. Drop it?`;
246
224
 
247
225
  /**
248
226
  * PRD v1.107 Part 5b ("the look reads, code asks"): the early asks CODE forces before any paid drafting, from the look's own result. Every `~` rule is
@@ -304,7 +282,7 @@ const ruleBounds = (r) => (r.op === 'between' ? [r.lo, r.hi] : [r.value]);
304
282
  * its reading as the suggestion (no extra paid call). A secret in a rule is masked.
305
283
  * @param {LookAsk[]} asks @returns {string}
306
284
  */
307
- export function tooManyAsksText(asks) {
308
- const list = asks.map((a) => `line ${a.line} "${a.ruleText}" → ${a.ask === 'no-check' ? "I can't check this" : (a.reading ?? "I can't check this on the page")}`).join('; ');
285
+ export function tooManyAsksText(asks, where = ' on the page') {
286
+ const list = asks.map((a) => `line ${a.line} "${a.ruleText}" → ${a.reading ?? `I can't check this${where}`}`).join('; ');
309
287
  return redactSecrets(`Your job has ${asks.length} rules I can't check or had to guess. Please rewrite it so each one says what to look for. My readings: ${list}.`);
310
288
  }
package/src/pagerules.js CHANGED
@@ -237,6 +237,18 @@ function pageDecimal(lines, signs) {
237
237
  /** the shapes that read a value after a label */
238
238
  const VALUE_SHAPES = ['money', 'time', 'number', 'date'];
239
239
 
240
+ /**
241
+ * The ONE owner of a label's separator: the label as the page writes it. The run's checker reads a value right after the signed label, so a page that
242
+ * writes "Departure time: 10:24 AM." can only be read by the label "Departure time:". When EVERY place the page holds the label has a colon right after
243
+ * it, the label is signed with that colon; one bare place leaves it as the look gave it. A plain count of the page's own text, no pattern.
244
+ * @param {string} text the frozen page text @param {string} label a label as normLabel leaves it @returns {string}
245
+ */
246
+ export function withColon(text, label) {
247
+ if (label.endsWith(':')) return label;
248
+ const n = countExact(text, label);
249
+ return n >= 1 && countExact(text, `${label}:`) === n ? `${label}:` : label;
250
+ }
251
+
240
252
  /** the full month names of each language a date may be signed in (bareguard 0.27 reads these and short forms; one full name on the page proves the language is the page's) */
241
253
  const MONTHS_FULL = /** @type {Record<string, string[]>} */ ({
242
254
  en: ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'],
@@ -353,9 +365,12 @@ export function applyPageRules(text, mapping, jobLines) {
353
365
  const asListed = [];
354
366
  /** U1: labels the page writes after the number */
355
367
  const moved = [];
356
- for (const w0 of words) {
357
- const w = normLabel(w0);
358
- if (!w) continue;
368
+ for (const w00 of words) {
369
+ const base = normLabel(w00);
370
+ if (!base) continue;
371
+ // a label the page always writes with a colon right after it ("Departure time: 10:24 AM.") is signed as the page writes it (run mwgsl7zx)
372
+ const w = withColon(text, base);
373
+ const w0 = w === base ? w00 : w;
359
374
  if (countExact(text, w) < 1) { asListed.push(w0); drop(f, w0, 'not-on-page'); continue; }
360
375
  if (amount) {
361
376
  const { B, A } = beforeAfter(lines, w);
@@ -26,11 +26,11 @@ import { planMatchesClose, listMatchesClose } from '../rubricstep.js';
26
26
  import { ticketNumberOf } from '../ticketshape.js';
27
27
  import { newestUnrunTicket } from '../ticketnext.js';
28
28
  import { readRunList } from '../runlist.js';
29
- import { createSession, validateJobCard, validateReuseCard, jobBoxesChanged, buildReuseSpec, cardFields, nextFreeJobName, startDestinationProblem, resolveFlowCard, ticketBoxProblem, STEP_LABELS } from './authorsession.js';
29
+ import { createSession, ticketRubricInputs, validateJobCard, validateReuseCard, jobBoxesChanged, buildReuseSpec, cardFields, nextFreeJobName, startDestinationProblem, resolveFlowCard, ticketBoxProblem, STEP_LABELS } from './authorsession.js';
30
30
  import { parseInputs } from '../jobblock.js';
31
31
  import { isReusableGreen } from './status.js';
32
32
  import { proveInputFiles, looksLikeRubricInput, webFetchState } from '../source.js';
33
- import { validateJob, flowTypeOf } from '../job.js';
33
+ import { validateJob, flowTypeOf, oldJobWords } from '../job.js';
34
34
  import { ticketAnyway } from './tickets.js';
35
35
  import { cardScheduleOf } from '../cardschedule.js';
36
36
 
@@ -167,13 +167,19 @@ export function createAuthorRoutes(opts) {
167
167
  // the session proves every line itself (`proveRubricInputs`), at $0, before any model call.
168
168
  const rubric = reuse ? reuse.spec?.verdictType === 'soft-green' : card?.checkType === 'rubric';
169
169
  if (reuse) card = { ...card, checkType: rubric ? 'rubric' : 'deterministic' };
170
- const filesJob = rubric && inputs.length > 0 && looksLikeRubricInput(inputs[0].value);
170
+ // hamr 2026-11-14 (piece 6): a job made with PASS/FAIL examples or the old judge is not reused, nor fired by a schedule; old runs are not repaired
171
+ const oldJob = reuse ? oldJobWords(reuse.spec) : null;
172
+ if (oldJob !== null) return Promise.resolve({ ok: /** @type {false} */ (false), status: 400, error: `${oldJob} Nothing spent.` });
171
173
  // piece 8: the card's Flow type and MCP pick, decided at $0 before any session (a reuse keeps the signed spec's own MCP). Nothing is started: the pick reads the check log.
172
174
  /** @type {ReturnType<typeof resolveFlowCard>} */
173
175
  const flow = reuse
174
176
  ? { ok: true, flowType: flowTypeOf(reuse.spec), pick: reuse.spec?.mcp ? { server: reuse.spec.mcp.server, tools: reuse.spec.mcp.tools } : null }
175
177
  : resolveFlowCard(card, { ...(opts.home !== undefined ? { home: opts.home } : {}), ...(opts.mcpHome !== undefined ? { mcpHome: opts.mcpHome } : {}) });
176
178
  if (!flow.ok) return Promise.resolve({ ok: /** @type {false} */ (false), status: 400, error: flow.error });
179
+ // hamr 2026-11-14 (piece 5): a Tickets + rubric job's one input is its ticket line, numbered 1, by the same owner the card, the session and Reuse read
180
+ inputs = ticketRubricInputs(inputs, { rubric, flowType: flow.flowType });
181
+ if (flow.flowType === 'tickets') card = { ...card, flowType: 'tickets' };
182
+ const filesJob = rubric && inputs.length > 0 && looksLikeRubricInput(inputs[0].value);
177
183
  const ticketProblem = ticketBoxProblem(card, flow.flowType);
178
184
  if (ticketProblem !== null) return Promise.resolve({ ok: /** @type {false} */ (false), status: 400, error: ticketProblem });
179
185
  // piece 9 (R7): the card's Schedule row, decided at $0 before any session exists. A scheduled fire is a headless start with no Schedule row, so it never reaches this.
@@ -469,6 +475,11 @@ export function createAuthorRoutes(opts) {
469
475
  }
470
476
  if (sub === 'row-edit') {
471
477
  // hamr 2026-11-13 (N-2): the confirm card's Drop / Add. $0 and instant: a row edit through the live check block, never a model call
478
+ // the FINAL repo card's Drop (hamr 2026-11-15): the signing gates run again, so the answer comes when they have
479
+ if (session.state.phase === 'prepared' && body?.op === 'drop') {
480
+ session.dropStage(body?.key).then((r) => send(r.ok ? 200 : 400, { ...r, state: session.state }), () => send(500, { ok: false, error: 'could not drop that check' }));
481
+ return true;
482
+ }
472
483
  const r = session.rowEdit(body?.op, body?.key);
473
484
  send(r.ok ? 200 : 400, { ...r, state: session.state });
474
485
  return true;
@@ -530,7 +541,7 @@ export function signRun(session, claimedHash, o) {
530
541
  if (session.state.finalPlan) {
531
542
  try {
532
543
  const spec = JSON.parse(readFileSync(session.state.resolvedSpecPath, 'utf8'));
533
- const m = planMatchesClose(session.state.finalPlan.checkItems, spec.closeDecl);
544
+ const m = planMatchesClose(session.state.finalPlan.checkItems, spec.closeDecl, spec.jobLines ?? null);
534
545
  if (!m.ok) return { ok: false, error: m.error };
535
546
  // B2: a close that carries the one check list must agree with it: every built row points at a check the close runs, and every check has a row
536
547
  const lm = listMatchesClose(spec.closeDecl);