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
package/src/index.js CHANGED
@@ -129,10 +129,6 @@ export {
129
129
  // gate that reads a signer's answer (and refuses an empty one), and the seed
130
130
  // exemption ruling 8 states.
131
131
  HUMAN_DECISIONS, SEED_EXEMPT_KINDS, normalizeHumanRuling, resolveHumanRuling,
132
- // SOFTGREEN module 2 — the judged stage's own arbiter-owned bounds. An adopter
133
- // wiring `judgeProvider` needs both numbers to reason about what a judged close
134
- // can cost: one paid call per artifact, at most one retry each.
135
- JUDGE_ATTEMPTS, MAX_JUDGED_PATHS,
136
132
  // SOFTGREEN module 8 — the REVIEW DOOR's vocabulary: the record type a run
137
133
  // writes when it ends at the door, which terminals open one, which classes open
138
134
  // one unasked, and the mechanical-only rule an `accept` re-proves against.
@@ -145,45 +141,9 @@ export {
145
141
  // module 6's registry half, and refuses an expired door under the same 60-day TTL a
146
142
  // hitl checkpoint keeps. It never returns, writes or implies a verdict.
147
143
  export { answerReviewDoor } from './reviewdoor.js';
148
- // SOFTGREEN module 1 — the judged floor's core. The pieces an adopter (and an
149
- // integrating UI) genuinely needs: `resolveJudge` (PRD item 32.1 — WHICH model
150
- // grades a job: the spec's signed `judge` override, else the job's own worker
151
- // model, and no library fall-back; the old pinned-model constant is gone), the rulebook a card SELECTS from,
152
- // the card gate, and the two halves themselves so a calibration harness can
153
- // grade the whole pipe without running a close.
154
- // `defaultJudgeLoop` (src/judged.js) is the one spelling of how this repo drives a
155
- // judge; the runner reaches it through `runPlan`'s `judgeProvider`. It is internal:
156
- // the package root does not export it.
157
- export {
158
- resolveJudge, JUDGE_RULES, JUDGE_RULE_IDS,
159
- runLocate, decide,
160
- // SOFTGREEN module 4 — what a legal SIGNED calibration set is. The SIZE is
161
- // hamr's own ruling and a size change is a spec-level threshold change;
162
- // `expectedOf` is the ONE reduction of a `decide()` result to the shape a case
163
- // stores, so a calibration harness compares one shape rather than two.
164
- CALIBRATION_SIZE, validateCalibrationSet, expectedOf,
165
- } from './judged.js';
166
- // SOFTGREEN module 4 — the COMPILE. Q6 becomes the rubric card and Q7 becomes the
167
- // frozen calibration set, both on the D5 shown-and-fixed path: the LLM proposes
168
- // through `proposeJudgedArtifacts`, an integrating UI shows the proposal, the
169
- // SIGNER's fix goes through `signJudgedArtifacts`, and `foldJudgedArtifacts`
170
- // enumerates both into the closeDecl — where the spec hash covers them, so a card
171
- // line or a case is a re-sign like every other spec edit.
172
- export {
173
- proposeJudgedArtifacts, signJudgedArtifacts, foldJudgedArtifacts,
174
- } from './cardauthor.js';
175
- // SOFTGREEN module 5 — THE CALIBRATION GATE. `runCalibration` grades the whole
176
- // pipe (locate + decide) over the signed ten and the five arbiter-owned injection
177
- // artifacts; `prepareSigning` runs it and refuses on anything short of all of
178
- // them. Exported because an integrating UI has to be able to RUN and RENDER the
179
- // gate — the graded rows are what a signer reads before giving a signature — and
180
- // because the battery is evidence a reader may want to inspect rather than take
181
- // on trust. `INJECTION_LOCATE_BATTERY` and `INJECTION_CARD` are ARBITER-OWNED
182
- // constants: no signer authors them and nothing stores them in a spec.
183
- export {
184
- runCalibration,
185
- INJECTION_LOCATE_BATTERY, CASUALTY_AXES,
186
- } from './calibrate.js';
144
+ // WHICH model a job's judge names (PRD item 32.1: the spec's signed `judge` override, else the job's own worker model; no library fall-back). The old
145
+ // judge's engine (the locate call, the rulebook, `decide`, the calibration shape) is gone (hamr 2026-11-14).
146
+ export { resolveJudge } from './judged.js';
187
147
  // M2 — what a declaration may SAY, and whether one said it legally. The
188
148
  // catalogue and the genre are DATA an integrating UI renders (the kind menu, the
189
149
  // guard batteries it must show the user under D5 and cannot let them remove).
@@ -101,10 +101,10 @@ import {
101
101
  PLAIN_FOLDER_DEFERRED_FIELDS,
102
102
  } from './authorjob.js';
103
103
  import {
104
- INPUTS_FIELD, JOB_BLOCK_HELP, destinationFieldFor, labelsFor, SOFTGREEN_JUDGE_EXAMPLES_KEY,
104
+ INPUTS_FIELD, JOB_BLOCK_HELP, destinationFieldFor, labelsFor,
105
105
  } from './authorflow.js';
106
106
  import {
107
- parseJobBlock, parseInputs, renderJobLines, renderExamples, jobBlockFitsCheck, signedJobLines,
107
+ parseJobBlock, parseInputs, renderJobLines, signedJobLines, REPO_RUBRIC_WORDS,
108
108
  } from './jobblock.js';
109
109
  import { validateJob, validateBaseUrl, PROVIDERS } from './job.js';
110
110
  import { resolveProvider, probeWarningLines, apiKeyProblem } from './providers.js';
@@ -391,6 +391,14 @@ export async function main(argv, deps = {}) {
391
391
  // 'repo'), the same authoritative outcome `prepareSource`'s own walk
392
392
  // produces for it — reported, never fought, below.
393
393
  const IS_REPO = looksLikeRepoSource(SOURCE);
394
+ // hamr 2026-11-14: this door always takes a repo on line 1, and a repo job is Deterministic (a rubric on a repo is for a Tickets job, a panel flow).
395
+ // Refused before a single class question is asked.
396
+ if (VERDICT === 'soft-green' && IS_REPO) {
397
+ say('');
398
+ say(REPO_RUBRIC_WORDS);
399
+ say('Nothing was asked and nothing was written.');
400
+ throw new ExitSignal(1);
401
+ }
394
402
 
395
403
  // ── LANGUAGE, DETECTED — never asked (PRD item 33 M3, ruling 3) ──────────────
396
404
  // $0, no provider: reads the repo's own manifest, nearest wins, walking up to
@@ -577,13 +585,13 @@ export async function main(argv, deps = {}) {
577
585
 
578
586
  // ── 3. the class's own frozen questions, one at a time ───────────────────────
579
587
  // P7: "The job" is ONE multi-line answer — numbered lines with their `~` rules, parsed by `parseJobBlock` (the same
580
- // parser the panel uses) and filed under key 1 as the numbered text the drafter reads. A rubric's second answer
581
- // (the judge examples) is DERIVED from the `~ PASS:`/`~ FAIL:` lines of that block, never asked a second time.
588
+ // parser the panel uses) and filed under key 1 as the numbered text the drafter reads. A `~ PASS:`/`~ FAIL:` line
589
+ // is refused by that parser (2026-11-14); the judge examples are gone.
582
590
  /** @type {Record<string, string>} */
583
591
  const answers = {};
584
592
  /** @type {import('./jobblock.js').JobLine[]} */
585
593
  let JOB_LINES = [];
586
- const ASKED = REQUIRED.filter((n) => !(VERDICT === 'soft-green' && n === SOFTGREEN_JUDGE_EXAMPLES_KEY));
594
+ const ASKED = REQUIRED;
587
595
  let asked = 0;
588
596
  for (const n of ASKED) {
589
597
  asked += 1;
@@ -600,14 +608,11 @@ export async function main(argv, deps = {}) {
600
608
  'that one is required — every question in this class\'s set has to be answered before a close can be authored from it. Again:');
601
609
  const parsed = parseJobBlock(raw);
602
610
  if (!parsed.ok) { say(` ${parsed.error}`); continue; }
603
- const misfit = jobBlockFitsCheck(parsed.lines, VERDICT === 'soft-green');
604
- if (misfit) { say(` ${misfit}`); continue; }
605
611
  JOB_LINES = parsed.lines;
606
612
  answers[n] = renderJobLines(parsed.lines);
607
613
  break;
608
614
  }
609
615
  }
610
- if (VERDICT === 'soft-green') answers[SOFTGREEN_JUDGE_EXAMPLES_KEY] = renderExamples(JOB_LINES);
611
616
 
612
617
  // ── 4. the OPERATOR's half of the spec — the part nothing authors for you ────
613
618
  say('');
package/src/job.js CHANGED
@@ -248,6 +248,25 @@ export function flowTypeOf(spec) {
248
248
  return spec?.mcp ? 'tickets' : 'plain';
249
249
  }
250
250
 
251
+ /** hamr 2026-11-14 (rubric vs deterministic split, piece 6): the words for a job made with PASS/FAIL examples or the old judge, which are gone. Old runs are not repaired. */
252
+ export const OLD_JOB_WORDS = 'This job was made with PASS/FAIL examples or the old judge, which are gone. Draft it fresh.';
253
+
254
+ /**
255
+ * Is this signed spec an OLD job: one that carries a `judged-floor` stage (the old judge) or a job line with a `PASS:` / `FAIL:` rule (the old examples)?
256
+ * ONE reader for every door that takes a signed spec back in (Reuse, a scheduled fire, an exported bundle).
257
+ * @param {Record<string, any>} spec @returns {string|null} the plain refusal, or null when the spec is not an old job
258
+ */
259
+ export function oldJobWords(spec) {
260
+ /** @type {any[]} */
261
+ const stages = Array.isArray(spec?.closeDecl?.stages) ? spec.closeDecl.stages : [];
262
+ if (stages.some((st) => st && st.kind === 'judged-floor')) return OLD_JOB_WORDS;
263
+ /** @type {any[]} */
264
+ const lines = Array.isArray(spec?.jobLines) ? spec.jobLines : [];
265
+ const isExample = (/** @type {unknown} */ r) => typeof r === 'string' && /^(PASS|FAIL):/i.test(r.trim());
266
+ if (lines.some((l) => l && ((Array.isArray(l.rules) && l.rules.some(isExample)) || isExample(l.rule)))) return OLD_JOB_WORDS;
267
+ return null;
268
+ }
269
+
251
270
  /** the shape of an MCP server or tool name in a job (the bridge names a tool `<server>_<tool>`) */
252
271
  const MCP_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
253
272
 
@@ -905,7 +924,7 @@ function validatePlanShape(spec, red, reds) {
905
924
  // class the user picked (PRD v1.57 §2), so the gate cannot check D5 without
906
925
  // it. An unknown or locked class is refused there, on its own axis, beside
907
926
  // the counted `request-red` above.
908
- const cd = validateCloseDecl(spec.closeDecl, { at: 'closeDecl', deferListing: true, verdictType: spec.verdictType, writeScope: spec.writeScope, jobLines: Array.isArray(spec.jobLines) ? spec.jobLines : null, inputLabels: inputLabelsOf(spec.inputs) });
927
+ const cd = validateCloseDecl(spec.closeDecl, { at: 'closeDecl', deferListing: true, verdictType: spec.verdictType, jobLines: Array.isArray(spec.jobLines) ? spec.jobLines : null, inputLabels: inputLabelsOf(spec.inputs) });
909
928
  for (const r of cd.reds) reds.push(r);
910
929
  if (demanded !== undefined && !CLASS_BY_CLOSE.declared.includes(demanded)) {
911
930
  // the same laundering guard as the close-type hierarchy, one level up: a
package/src/jobblock.js CHANGED
@@ -4,18 +4,22 @@
4
4
  //
5
5
  // Both are pure and $0: a malformed block is a named red `{ok: false, error}`, never a throw and never a guess.
6
6
 
7
- /** @typedef {{verdict: 'PASS'|'FAIL', text: string}} JobExample a `~ PASS:` / `~ FAIL:` line (rubric only), kept with its job line */
8
- /** @typedef {{n: number, text: string, rule: string, rules: string[], examples: JobExample[]}} JobLine one numbered job line; `rule` = its `~` lines joined with '; ' ('' when none), `rules` = those same `~` lines one by one (so an example's own '; ' survives) */
7
+ /** @typedef {{n: number, text: string, rule: string, rules: string[]}} JobLine one numbered job line; `rule` = its `~` lines joined with '; ' ('' when none), `rules` = those same `~` lines one by one */
9
8
  /** @typedef {{n: number, label: string, value: string}} JobInput one numbered `label: value` input line */
10
9
 
10
+ /** hamr 2026-11-14: Rubric on a repo is allowed ONLY for a Tickets job; any other repo + rubric start is refused at $0 in these words */
11
+ export const REPO_RUBRIC_WORDS = 'A repo job uses a Deterministic check.';
12
+
11
13
  /** the joiner for consecutive `~` lines (fwd's joinGuardrails) */
12
14
  export const RULE_JOINER = '; ';
13
15
 
16
+ /** hamr 2026-11-14: a `~ PASS:` / `~ FAIL:` line is refused at $0; the check list (`~` rules, Drop and Add) covers what the examples did */
17
+ export const PASS_FAIL_GONE_WORDS = 'PASS/FAIL examples are gone \u2014 write what you want as a ~ rule.';
18
+
14
19
  /**
15
20
  * Parse "The job" box. A plain line is a numbered job line (1, 2, 3...). A line starting `~` has no number and belongs
16
21
  * to the numbered line above; consecutive `~` lines become ONE rule joined with `'; '`. A `~` line starting `PASS:` or
17
- * `FAIL:` is also a judge example (kept with its line number); any other `~` line is a guardrail. Empty lines are
18
- * ignored. A `~` before line 1 is a red.
22
+ * `FAIL:` is a red ({@link PASS_FAIL_GONE_WORDS}). Empty lines are ignored. A `~` before line 1 is a red.
19
23
  * @param {unknown} text the box's raw text
20
24
  * @returns {{ok: true, lines: JobLine[]}|{ok: false, error: string}}
21
25
  */
@@ -35,16 +39,12 @@ export function parseJobBlock(text) {
35
39
  if (lines.length === 0) return { ok: false, error: `The job, line ${row}: a "~" line belongs to the numbered line above it, and there is none yet` };
36
40
  const body = t.slice(1).trim();
37
41
  if (body === '') continue;
42
+ if (/^(PASS|FAIL):/i.test(body)) return { ok: false, error: PASS_FAIL_GONE_WORDS };
38
43
  rule.push(body);
39
- const m = /^(PASS|FAIL):\s*(.*)$/i.exec(body);
40
- if (m) {
41
- if (m[2].trim() === '') return { ok: false, error: `The job, line ${row}: "${m[1].toUpperCase()}:" needs an example after it` };
42
- lines[lines.length - 1].examples.push({ verdict: /** @type {'PASS'|'FAIL'} */ (m[1].toUpperCase()), text: m[2].trim() });
43
- }
44
44
  continue;
45
45
  }
46
46
  flush();
47
- lines.push({ n: lines.length + 1, text: t, rule: '', rules: [], examples: [] });
47
+ lines.push({ n: lines.length + 1, text: t, rule: '', rules: [] });
48
48
  }
49
49
  flush();
50
50
  if (lines.length === 0) return { ok: false, error: 'The job is required' };
@@ -99,16 +99,6 @@ export function jobBoxText(lines) {
99
99
  return lines.map((l) => [l.text, ...l.rules.map((r) => `~ ${r}`)].join('\n')).join('\n');
100
100
  }
101
101
 
102
- /**
103
- * The PASS:/FAIL: examples the person wrote, each kept with its line number (answer 2 of a rubric interview — what the
104
- * calibration compile reads). Empty string when there are none.
105
- * @param {JobLine[]} lines
106
- * @returns {string}
107
- */
108
- export function renderExamples(lines) {
109
- return lines.flatMap((l) => l.examples.map((e) => `line ${l.n} ${e.verdict}: ${e.text}`)).join('\n');
110
- }
111
-
112
102
  /**
113
103
  * The inputs as the drafter is told about them: "the person pointed at these inputs: N label path".
114
104
  * @param {JobInput[]} inputs
@@ -119,32 +109,7 @@ export function renderInputs(inputs) {
119
109
  }
120
110
 
121
111
  /**
122
- * The two cross-checks between a parsed job block and the Check type: a RUBRIC job needs at least one `PASS:` and one
123
- * `FAIL:` example (the calibration compile reads them); a DETERMINISTIC job has no judge, so an example line would be
124
- * silently dropped — a red instead.
125
- * PART 1a (hamr's ruling P1=B, docs/product/ITEM33-BUILD.md "Addendum 2026-10-12"): the examples are required of a rubric
126
- * job ONLY when it holds a judged part. A rubric job on the person's own local files holds none in this build (its
127
- * parts are counted or checked against a quote), so the caller says `judged: false` and a block without examples fits.
128
- * Examples written anyway are never a red there — they simply have no judge to read them yet.
129
- * @param {JobLine[]} lines
130
- * @param {boolean} rubric
131
- * @param {{judged?: boolean}} [o] `judged` (default true): does this job hold a judged part, so that it needs examples?
132
- * @returns {string|null} the plain red, or null when the block fits the Check type
133
- */
134
- export function jobBlockFitsCheck(lines, rubric, { judged = true } = {}) {
135
- const all = lines.flatMap((l) => l.examples.map((e) => ({ n: l.n, ...e })));
136
- if (!rubric) {
137
- return all.length ? `The job, line ${all[0].n}: PASS:/FAIL: examples are for a Rubric check — a Deterministic job has no judge to read them` : null;
138
- }
139
- if (judged && (!all.some((e) => e.verdict === 'PASS') || !all.some((e) => e.verdict === 'FAIL'))) {
140
- return 'The job: a Rubric check needs at least one "~ PASS:" line and one "~ FAIL:" line under a job line';
141
- }
142
- return null;
143
- }
144
-
145
- /**
146
- * The signed `jobLines` field from parsed lines: the person's own words, `{n, text, rule, rules}` (examples stay inside the
147
- * rule text, where the person wrote them). `rules` is the same `~` lines as an array, BESIDE the joined `rule` (never
112
+ * The signed `jobLines` field from parsed lines: the person's own words, `{n, text, rule, rules}`. `rules` is the same `~` lines as an array, BESIDE the joined `rule` (never
148
113
  * replacing it); it is omitted on a line with no `~` line, and an older spec lacks it entirely.
149
114
  * @param {JobLine[]} lines
150
115
  * @returns {{n: number, text: string, rule: string, rules?: string[]}[]}