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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bareloop",
3
- "version": "0.56.0",
3
+ "version": "0.58.0",
4
4
  "description": "Workflows that earn their own design, with receipts — agent-authored workflows for repeated, long, verifiable jobs that improve across runs under an un-gameable gate.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "bare-agent": "^0.59.0",
31
31
  "barebrowse": "^0.25.0",
32
- "bareguard": "^0.35.0",
32
+ "bareguard": "^0.36.0",
33
33
  "litectx": "^0.41.0"
34
34
  },
35
35
  "devDependencies": {
package/src/authorflow.js CHANGED
@@ -26,7 +26,7 @@
26
26
  // TWO CONSEQUENCES, NAMED RATHER THAN SMOOTHED:
27
27
  //
28
28
  // 1. A LOCKED KIND IS INEXPRESSIBLE IN TOOL MODE. The schema carries one branch
29
- // per LIVE kind, so there is no way to spell `judged-floor` or
29
+ // per LIVE kind, so there is no way to spell
30
30
  // `human-confirms` — which is the `check-passes(name)` move applied one
31
31
  // level up (illegal becomes unsayable, not rejected late). The price is
32
32
  // real: M2's `locked-kind` red is bareloop's DEMAND COUNTER for its own
@@ -77,8 +77,7 @@ import { thinkingCallOptions } from './thinking.js';
77
77
  import { createRequire } from 'node:module';
78
78
  import { realpathSync } from 'node:fs';
79
79
  import { join, relative, isAbsolute } from 'node:path';
80
- import { seedRead as runSeedReadStages, makeSeedTrees, AGGREGATES, SIGNS, MAX_TERMS, MAX_JUDGED_PATHS } from './kinds.js';
81
- import { JUDGE_RULE_IDS } from './judged.js';
80
+ import { seedRead as runSeedReadStages, makeSeedTrees, AGGREGATES, SIGNS, MAX_TERMS } from './kinds.js';
82
81
  import {
83
82
  KIND_CATALOGUE, MAX_STAGES, DIRECTIONS, BASELINES,
84
83
  GENRE_LANGUAGES, RUBRIC_LANG, DECLARABLE_LANGUAGES, TYPES_GENRE_TEMPLATE, classGuards, genreEnv, genreOwnedEnvNames, genreInstruments,
@@ -90,7 +89,8 @@ import { redactSecrets } from './validate.js';
90
89
  import { ledgerRecord } from './checklist.js';
91
90
  import { ROW_EDIT_REVISE, rowEditUserText, rowEditChannel, editsOf } from './rowedit.js';
92
91
  import { REASON, CheckBlock } from './checkblock.js';
93
- import { stepFileContract, inputLabelsOf, stepFileRel, readFrozenInputs, lineRules } from './rubricstep.js';
92
+ import { GUARD_DESCRIPTIONS } from './guarddescriptions.js';
93
+ import { stepFileContract, inputLabelsOf, stepFileRel, readFrozenInputs, lineRules, lineCarriesText, guardNameOfKey } from './rubricstep.js';
94
94
  import { dropRows, dropLine } from './pagedropwords.js';
95
95
  import { renderLookReport } from './inputlook.js';
96
96
  import { checkDeclarationWords, labelListsFor } from './factwords.js';
@@ -130,8 +130,10 @@ export const MAX_QUESTIONS = 3;
130
130
  * word anywhere in it (a test greps this): the machine, not the prompt, bounds the count.
131
131
  */
132
132
  export const QUESTIONS_DESCRIPTION = 'Optional. Add a question only if a refusal in the measured results names a job line that cannot be drafted '
133
- + 'without the person\'s answer (an undefined size, format, destination, or what "done" means). Each question is {line, question}: '
134
- + '"line" is the number of the job line it is about. If the refusals can be fixed without asking, fix them and leave this out. '
133
+ + 'without the person\'s answer (an undefined size, format, destination, or what "done" means). Each question is {line, question} plus the tag that says what the answer does: '
134
+ + '"line" is the number of the job line it is about; "rule" is the number of that line\'s own rule the question is about (the answer then replaces that rule) '
135
+ + 'or "new": true when it is about nothing the line already says (the answer is added as a new rule). Name a rule only if the line really has it, and tag each question with a rule or with new, never with a mix. '
136
+ + 'If the refusals can be fixed without asking, fix them and leave this out. '
135
137
  + 'Never ask about a budget, a cap or a time limit (the person signs those). Still deliver the complete corrected declaration.';
136
138
 
137
139
  /**
@@ -162,13 +164,14 @@ export function linesNamedByReds(reds, declaration, lineNums) {
162
164
  }
163
165
 
164
166
  /**
165
- * The machine's keep-or-drop of the try-3 questions. Kept only when its line is one the previous try's reds named and its
166
- * text is non-blank, at most {@link MAX_QUESTIONS}; every drop comes back with its reason, for the draft's log.
167
- * @param {any} raw @param {number[]} failedLines
168
- * @returns {{kept: {line: number, question: string, rule?: number, source?: string, ask?: 'reading'|'cant-check', reading?: string}[], dropped: {reason: string, raw: any}[]}}
167
+ * The machine's keep-or-drop of the try-3 questions. Kept only when its line is one the previous try's reds named, its text is non-blank, at most {@link MAX_QUESTIONS}, and its TAG is sound
168
+ * (Addendum 2026-11-14 (c) piece 5): the drafter names the `rule` the question is about (a `~` rule number the line really has: the answer REPLACES it) or says `new` (the answer is added as a new rule).
169
+ * A rule the line does not have, a question with neither tag and one with both are dropped; code never guesses which the drafter meant. Every drop comes back with its reason, for the draft's log.
170
+ * @param {any} raw @param {number[]} failedLines @param {{n: number, rules?: string[], rule?: string}[]|null} [jobLines] the person's numbered lines (their rules are what a tag may name)
171
+ * @returns {{kept: {line: number, question: string, rule?: number, new?: true, source?: string, ask?: 'reading'|'cant-check', reading?: string}[], dropped: {reason: string, raw: any}[]}}
169
172
  */
170
- export function normalizeQuestions(raw, failedLines) {
171
- /** @type {{line: number, question: string, rule?: number, source?: string, ask?: 'reading'|'cant-check', reading?: string}[]} */
173
+ export function normalizeQuestions(raw, failedLines, jobLines = null) {
174
+ /** @type {{line: number, question: string, rule?: number, new?: true, source?: string, ask?: 'reading'|'cant-check', reading?: string}[]} */
172
175
  const kept = [];
173
176
  /** @type {{reason: string, raw: any}[]} */
174
177
  const dropped = [];
@@ -178,11 +181,15 @@ export function normalizeQuestions(raw, failedLines) {
178
181
  if (!q || typeof q !== 'object' || !Number.isInteger(q.line)) { dropped.push({ reason: 'no line', raw: q }); continue; }
179
182
  if (!failedLines.includes(q.line)) { dropped.push({ reason: `line ${q.line} is not a line the previous try's checks failed on`, raw: q }); continue; }
180
183
  if (typeof q.question !== 'string' || q.question.trim() === '') { dropped.push({ reason: 'blank question', raw: q }); continue; }
184
+ const named = Number.isInteger(q.rule);
185
+ if (named && q.new === true) { dropped.push({ reason: `line ${q.line}: the question names both a rule and new`, raw: q }); continue; }
186
+ if (!named && q.new !== true) { dropped.push({ reason: `line ${q.line}: the question names neither a rule nor new`, raw: q }); continue; }
187
+ if (named && !(q.rule >= 1 && q.rule <= lineRules((jobLines ?? []).find((/** @type {any} */ l) => l?.n === q.line)).length)) { dropped.push({ reason: `line ${q.line} has no rule ${q.rule}`, raw: q }); continue; }
181
188
  if (kept.length >= MAX_QUESTIONS) { dropped.push({ reason: 'beyond the machine\'s limit', raw: q }); continue; }
182
189
  kept.push({
183
190
  line: q.line, question: redactSecrets(q.question.trim()),
184
191
  // PRD v1.106 Part 5 Q3: a code-forced question (the early look ask) names the `~` rule it is about and says so; a model's question has neither
185
- ...(Number.isInteger(q.rule) ? { rule: q.rule } : {}), ...(typeof q.source === 'string' ? { source: q.source } : {}),
192
+ ...(named ? { rule: q.rule } : { new: /** @type {const} */ (true) }), ...(typeof q.source === 'string' ? { source: q.source } : {}),
186
193
  // PRD v1.107 Part 5b: the kind of a code-forced ask, and (reading asks) the plain words `agree` writes as the `~` rule
187
194
  ...(q.ask === 'reading' || q.ask === 'cant-check' ? { ask: q.ask } : {}), ...(q.ask === 'reading' && typeof q.reading === 'string' ? { reading: redactSecrets(q.reading) } : {}),
188
195
  });
@@ -324,10 +331,10 @@ export const INPUTS_FIELD = Object.freeze({
324
331
  + '(e.g. `spec: docs/spec.md`) — git must track them.',
325
332
  });
326
333
 
327
- /** P7: how to write "The job" (printed under its question by the CLI; the panel's box shows the same in its examples). */
334
+ /** P7: how to write "The job" (printed under its question by the CLI; the panel's box shows the same in its placeholder). */
328
335
  export const JOB_BLOCK_HELP = Object.freeze([
329
336
  'One line per thing the job must do — each plain line gets a number. A line starting with `~` is a rule for the',
330
- 'numbered line above it. For a rubric check, a `~ PASS: ...` and a `~ FAIL: ...` line are your examples.',
337
+ 'numbered line above it (what you want checked, in your own words).',
331
338
  ]);
332
339
 
333
340
  /** Destination's wording when Source resolved to a git repo: the answer IS the
@@ -402,37 +409,14 @@ export const FIELD_LABELS = Object.freeze({
402
409
  * soft-green and hitl extensions below — computed, never hardcoded twice. */
403
410
  const NEXT_FREE_TEXT_KEY = Object.keys(GREEN_QUESTIONS).length + 1;
404
411
 
405
- /** The soft-green quartet's own key for Judge Examples — exported so
406
- * `cardauthor.js` reads the SAME number this module files the answer under,
407
- * rather than a second, hand-typed "6"/"7". */
408
- export const SOFTGREEN_JUDGE_EXAMPLES_KEY = NEXT_FREE_TEXT_KEY;
409
-
410
- /** The Judge Examples question — the signed table's own Holds text, verbatim
411
- * ("one pass, one fail, and why"), not the old worded Q7 ("Give one example
412
- * you'd pass and one you'd fail, and say why."). Exported so `cardauthor.js`'s
413
- * prompt and this module's own `SOFTGREEN_QUESTIONS` render the identical
414
- * string; its label ("Judge examples") lives in `SOFTGREEN_FIELD_LABELS`. */
415
- export const JUDGE_EXAMPLES_QUESTION = 'the PASS: and FAIL: examples the person wrote under their job lines, each with its line number';
416
-
417
- /** {@link FIELD_LABELS} plus Judge Examples' own label, for the soft-green set. */
418
- export const SOFTGREEN_FIELD_LABELS = Object.freeze({
419
- ...FIELD_LABELS,
420
- [SOFTGREEN_JUDGE_EXAMPLES_KEY]: 'Judge examples',
421
- });
412
+ /** {@link FIELD_LABELS} for the soft-green set: the same one label (the judge examples are gone). */
413
+ export const SOFTGREEN_FIELD_LABELS = Object.freeze({ ...FIELD_LABELS });
422
414
 
423
415
  /**
424
- * THE SOFTGREEN SET — the green trio plus Judge Examples. A judged close needs
425
- * exactly this one more thing the green set cannot supply: a real pass/fail
426
- * pair in the person's own words, which module 4 (`cardauthor.js`) compiles
427
- * into the signed rubric card and the frozen calibration set. It rides in
428
- * `answers` and reaches the composer verbatim through the prompt's interview
429
- * block, exactly as every other free-text answer does — this module derives
430
- * nothing from it.
416
+ * THE SOFTGREEN SET — the green set again: a rubric job's whole job is the numbered lines of "The job" (its `~` rules
417
+ * become the check list); the PASS/FAIL judge examples are gone (hamr 2026-11-14).
431
418
  */
432
- export const SOFTGREEN_QUESTIONS = Object.freeze({
433
- ...GREEN_QUESTIONS,
434
- [SOFTGREEN_JUDGE_EXAMPLES_KEY]: JUDGE_EXAMPLES_QUESTION,
435
- });
419
+ export const SOFTGREEN_QUESTIONS = Object.freeze({ ...GREEN_QUESTIONS });
436
420
 
437
421
  /**
438
422
  * THE HITL SET (N4 slice 1, kept in code only — never offered in the form or
@@ -507,10 +491,8 @@ export const CLASS_STATEMENTS = Object.freeze({
507
491
  'soft-green': 'The person declared this job SOFT-GREEN: part of what "done" means here needs JUDGEMENT — reading '
508
492
  + 'the result and deciding whether it is any good — and no command can render it. Compose the mechanical part '
509
493
  + 'first: everything about this repository a command can decide is still a mechanical stage, exactly as it would '
510
- + 'be for a green job. Then put ONE judged-floor stage AFTER them, carrying the few things the person said they '
511
- + 'actually look for and the real files the work lands in (files the job may EDIT, inside the write fence, '
512
- + 'because a finding on a file the run is fenced out of can never be fixed). A judged stage decides only the lines its card names, '
513
- + 'so name each thing they look for as its own line, and leave nothing to be inferred.',
494
+ + 'be for a green job. Compose NO stage for the part that needs judgement: there is no judged stage to put it in '
495
+ + '(the old judge is gone), so leave that part out and say so in your notes; the person judges it at Accept.',
514
496
  // N4 slice 1. The mechanical-first composition law is stated as an ORDER
515
497
  // because first-red-wins makes the order the mechanism: the cheap stages shield
516
498
  // the expensive one, and the person is never the first filter.
@@ -615,27 +597,13 @@ export const ANSWER_QUESTION_FIELD = Object.freeze({
615
597
  * @type {Record<'confirm'|'fix'|'type-goal'|'start-over', string>}
616
598
  */
617
599
  export const CONFIRM_MENU = Object.freeze({
618
- confirm: 'Confirm — sign this plan and goal as shown',
600
+ confirm: 'Confirm — draft the checks for this plan and goal as shown',
619
601
  fix: 'Fix — describe what to change',
620
602
  'type-goal': 'Type the goal sentence yourself',
621
603
  'start-over': 'Start over — rerun the interview from the beginning',
622
604
  });
623
605
 
624
- /**
625
- * PLAIN-ENGLISH lines for the guards `classGuards` can compose, keyed by
626
- * guard NAME — frozen beside {@link CONFIRM_MENU} because both are constants
627
- * the confirm turn shows a person verbatim. One entry per guard that exists
628
- * in `MECHANICAL_GUARDS` (`src/authoring.js`); {@link confirmProtections}
629
- * throws if a guard `classGuards` hands back has no line here, so a battery
630
- * that grows a guard fails loudly instead of showing a blank description.
631
- * @type {Record<string, string>}
632
- */
633
- export const GUARD_DESCRIPTIONS = Object.freeze({
634
- 'changed-from-seed': 'the run must actually change at least one file in scope — a close that reports done '
635
- + 'without touching anything is refused',
636
- 'no-suppressions': 'the run may not silence a checker instead of fixing what it flags (things like @ts-ignore, '
637
- + 'eslint-disable, or # type: ignore) — none of those may appear in the diff',
638
- });
606
+ export { GUARD_DESCRIPTIONS };
639
607
 
640
608
  /**
641
609
  * THE REAL PROTECTIONS a person is shown, and what {@link runConfirmTurn}
@@ -649,11 +617,15 @@ export const GUARD_DESCRIPTIONS = Object.freeze({
649
617
  * close — one source, never a second hand-typed list — rendered through the
650
618
  * frozen line in {@link GUARD_DESCRIPTIONS}, plus the write fence (a real,
651
619
  * signed fence — {@link writeScopeBlock}'s own subject) when one is set.
652
- * @param {{verdictType: string, lang: string, writeScope?: string[]|null, jobLines?: {n: number}[]|null}} o
620
+ * A rubric line's file is listed as carrying text ONLY when the close really puts a text-present check on it ({@link lineCarriesText}, derived from `closeDecl`; one owner): a facts-only line
621
+ * (results and no note) is listed without it, and with no close to read nothing is claimed about text.
622
+ * @param {{verdictType: string, lang: string, writeScope?: string[]|null, jobLines?: {n: number}[]|null, closeDecl?: any}} o
653
623
  * @returns {string[]}
654
624
  */
655
- export function confirmProtections({ verdictType, lang, writeScope = null, jobLines = null }) {
656
- const guards = classGuards({ verdictType, lang });
625
+ export function confirmProtections({ verdictType, lang, writeScope = null, jobLines = null, closeDecl = null }) {
626
+ // (one list, Addendum 2026-11-14 (c) piece 2: a guard the signed list already holds as a `$` row is said THERE, once for the job; an older close with no guard row keeps its line here)
627
+ const rowed = Array.isArray(closeDecl?.list) ? closeDecl.list.filter((/** @type {any} */ r) => r && r.kind === 'guard' && r.state === 'built').map((/** @type {any} */ r) => guardNameOfKey(r.key)) : [];
628
+ const guards = classGuards({ verdictType, lang }).filter((g) => !rowed.includes(g.name));
657
629
  const lines = guards.map((g) => {
658
630
  const desc = GUARD_DESCRIPTIONS[g.name];
659
631
  if (!desc) {
@@ -662,13 +634,16 @@ export function confirmProtections({ verdictType, lang, writeScope = null, jobLi
662
634
  }
663
635
  return `${g.name} — ${desc}`;
664
636
  });
665
- if (Array.isArray(writeScope) && writeScope.length > 0) {
637
+ // (a close whose signed list holds the fence row says it THERE, as a `$` row; only an older close keeps this line)
638
+ if (Array.isArray(writeScope) && writeScope.length > 0 && !(Array.isArray(closeDecl?.list) && closeDecl.list.some((/** @type {any} */ r) => r && r.kind === 'fence'))) {
666
639
  lines.push(`write fence — the run may only change files matching: ${writeScope.join(', ')}`);
667
640
  }
668
641
  // PART 1a: a rubric job on local files always checks, for EVERY numbered line, that the line's file exists, is complete
669
642
  // JSON and has text — a fact of the close's shape (`rubric-step`), not a plan of the model's, so it is listed from code
643
+ // (one list, Addendum 2026-11-14 (c) piece 1: a close whose signed list already holds a line's `$` floor row says it THERE, once; only an older close with no floor row keeps this note)
670
644
  if (lang === RUBRIC_LANG && Array.isArray(jobLines)) {
671
- for (const l of jobLines) lines.push(`line ${l.n} file — ${stepFileRel(l.n)} must exist, be complete JSON, and carry text`);
645
+ const floors = Array.isArray(closeDecl?.list) ? closeDecl.list.filter((/** @type {any} */ r) => r && r.kind === 'floor' && r.state === 'built').map((/** @type {any} */ r) => r.line) : [];
646
+ for (const l of jobLines) if (!floors.includes(l.n)) lines.push(`line ${l.n} file — ${stepFileRel(l.n)} must exist, be complete JSON${lineCarriesText(closeDecl, l.n) ? ', and carry text' : ''}`);
672
647
  }
673
648
  return lines;
674
649
  }
@@ -790,39 +765,6 @@ export const PARAM_SCHEMAS = Object.freeze({
790
765
  extensions: { type: 'array', minItems: 1, items: { type: 'string' } },
791
766
  allowPrefixes: { type: 'array', minItems: 1, items: { type: 'string' } },
792
767
  requireNonEmpty: { const: true },
793
- // SOFTGREEN's two. `rule` is an ENUM off the judge's own rulebook — where only a
794
- // closed set can satisfy a field, the illegal value is made inexpressible rather
795
- // than rejected after the fact (`check-passes(name)`, again) — and `text` is the
796
- // only free string, carrying the signer's words so a red can be explained in them.
797
- card: {
798
- type: 'object',
799
- description: 'the rubric, as enumerated items: one line per thing the person actually looks for, in the order '
800
- + 'they look for them. The rule is SELECTED from the arbiter\'s own rulebook; the text is theirs.',
801
- properties: {
802
- items: {
803
- type: 'array',
804
- minItems: 1,
805
- items: {
806
- type: 'object',
807
- properties: {
808
- rule: { enum: [...JUDGE_RULE_IDS], description: 'which owned rule this line asserts' },
809
- text: { type: 'string', minLength: 1, description: 'what this line means, in the person\'s own words' },
810
- },
811
- required: ['rule', 'text'],
812
- additionalProperties: false,
813
- },
814
- },
815
- },
816
- required: ['items'],
817
- additionalProperties: false,
818
- },
819
- paths: {
820
- type: 'array',
821
- minItems: 1,
822
- maxItems: MAX_JUDGED_PATHS,
823
- items: { type: 'string' },
824
- description: 'the AUTHORITATIVE artifacts to judge, repository-relative, read off the listing. One paid call each.',
825
- },
826
768
  step: { type: 'integer', minimum: 1, description: 'the number of the job line this stage serves; its file is output/steps/<step>.json' },
827
769
  parts: {
828
770
  type: 'array',
@@ -996,26 +938,14 @@ export function declarationSchema(catalogue = KIND_CATALOGUE, { verdictType = nu
996
938
  type: 'object',
997
939
  properties: {
998
940
  line: { type: 'integer', minimum: 1, description: 'the number of a job line no stage checks' },
999
- rule: { type: 'integer', minimum: 1, description: 'optional: the number of ONE ~ rule of that line that nothing checks (the line itself still has a stage)' },
941
+ // a `~` rule is never a repo drafter's to refuse (code decides what keeps it and asks about the rest); only the rubric class keeps the rule number (its rows are code-assembled)
942
+ ...(Array.isArray(kinds) && kinds.includes('rubric-step') ? { rule: { type: 'integer', minimum: 1, description: 'optional: the number of ONE ~ rule of that line that nothing checks (the line itself still has a stage)' } } : {}),
1000
943
  reason: { type: 'string', minLength: 1, description: 'why, in plain words the person can read' },
1001
944
  },
1002
945
  required: ['line', 'reason'],
1003
946
  additionalProperties: false,
1004
947
  },
1005
- description: 'job lines (or single ~ rules of a line) you could not turn into a check, each with a reason in the person\'s words — a note does not cover a line or a rule',
1006
- },
1007
- guardLines: {
1008
- type: 'array',
1009
- items: {
1010
- type: 'object',
1011
- properties: {
1012
- guard: { type: 'string', minLength: 1, description: 'the name of a mandatory guard stage' },
1013
- lines: { type: 'array', minItems: 1, uniqueItems: true, items: { type: 'integer', minimum: 1 }, description: 'the number(s) of the job line(s) that guard already checks' },
1014
- },
1015
- required: ['guard', 'lines'],
1016
- additionalProperties: false,
1017
- },
1018
- description: 'optional: which job lines the always-on guards already cover (a line whose every ask a mandatory guard checks needs no stage of its own)',
948
+ description: 'job lines you could not turn into a check, each with a reason in the person\'s words — a note does not cover a line. A ~ rule is never listed here: code decides what keeps it and asks the person about the rest',
1019
949
  },
1020
950
  ...(ticket ? {
1021
951
  ticketFilter: {
@@ -1033,7 +963,7 @@ export function declarationSchema(catalogue = KIND_CATALOGUE, { verdictType = nu
1033
963
  type: 'array',
1034
964
  items: {
1035
965
  type: 'object',
1036
- properties: { line: { type: 'integer', minimum: 1 }, question: { type: 'string', minLength: 1 } },
966
+ properties: { line: { type: 'integer', minimum: 1 }, question: { type: 'string', minLength: 1 }, rule: { type: 'integer', minimum: 1 }, new: { type: 'boolean' } },
1037
967
  required: ['line', 'question'],
1038
968
  },
1039
969
  description: QUESTIONS_DESCRIPTION,
@@ -1281,7 +1211,7 @@ export function confirmedBlock(confirmed) {
1281
1211
  * names the ONE numbered job line it serves, or the line is refused with a reason; the mandatory guards serve no line.
1282
1212
  * The $0 validator (validateDeclaration, `jobLines`) enforces it and the revise loop feeds a miss back.
1283
1213
  * @param {number} count how many numbered job lines the person wrote
1284
- * @param {string[]} [guardNames] the mandatory guards' names; present = the block also tells how a line they already cover is covered
1214
+ * @param {string[]} [guardNames] the mandatory guards' names; present = the block also tells that a rule needs no stage and no refusal (code decides what keeps a rule)
1285
1215
  */
1286
1216
  export function jobLineTagBlock(count, guardNames = []) {
1287
1217
  return 'EVERY STAGE SERVES ONE JOB LINE\n\n'
@@ -1291,17 +1221,10 @@ export function jobLineTagBlock(count, guardNames = []) {
1291
1221
  + 'words the person can read. Every numbered line needs at least one stage or one refusal — a note in "notes" does '
1292
1222
  + 'NOT cover a line. The mandatory guards serve no job line and carry NO "fromLine".'
1293
1223
  + (guardNames.length
1294
- ? '\n\nA job line whose every ask the always-on checks (the mandatory guards) already do needs no stage of its own and no refusal: '
1295
- + 'name the guard(s) that do it in "guardLines", beside "stages" — for example {"guardLines": [{"guard": "' + guardNames[0] + '", "lines": [N]}]}. '
1296
- + 'Never write a second stage that repeats a guard, and keep "refused" for a line nothing can check.'
1297
- + '\n\nTHE ALWAYS-ON CHECKS ALREADY EXIST in this close, in plain words: ' + guardNames.map((n) => n + ' (' + (GUARD_DESCRIPTIONS[n] ?? n) + ')').join('; ')
1224
+ ? '\n\nTHE ALWAYS-ON CHECKS ALREADY EXIST in this close, in plain words: ' + guardNames.map((n) => n + ' (' + (GUARD_DESCRIPTIONS[n] ?? n) + ')').join('; ')
1298
1225
  + '; and the write fence (changes stay inside the write scope). They are already among the guard stages you were given — keep those exactly as given, and NEVER declare any of them again as a stage of your own — '
1299
- + 'no second files-changed or scope stage, and no stage that adds scope or params to the suppression guard. A job line they already cover '
1300
- + '(for example "Fix the cause in the source code under src/" with the rule "no suppression comments") is linked to them with "guardLines", '
1301
- + 'not given a stage and not refused. Legal example for a two-line job whose line 1 is a test run and whose line 2 is covered by the guards: '
1302
- + '{"stages": [{"name": "suite-green", "kind": "command-exit", "fromLine": [1], "params": {"cmd": "npm", "args": ["test"], "expectExit": 0}}], '
1303
- + '"guardLines": [{"guard": "' + guardNames[0] + '", "lines": [2]}' + (guardNames[1] ? ', {"guard": "' + guardNames[1] + '", "lines": [2]}' : '') + ']} — '
1304
- + 'line 2 has no stage of its own and is not refused.'
1226
+ + 'no second files-changed or scope stage, and no stage that adds scope or params to the suppression guard. A job line whose every ask they already do needs no stage of its own: list it in "refused" with a reason, never a stage that repeats them.'
1227
+ + '\n\nA "~" rule needs no stage and no refusal, and you never list one in "refused". Write a stage only for what a kind in the catalogue really measures; never write one to stand in for a rule nothing can check — code decides which rules the write fence keeps (from the person\'s own words) and asks the person about the rest.'
1305
1228
  : '');
1306
1229
  }
1307
1230
 
@@ -2098,6 +2021,10 @@ export const RUBRIC_CONFIRM_NOTE = 'THIS JOB HAS NO REPOSITORY. Its inputs are t
2098
2021
  + 'The checks of this job are made elsewhere: plan none. Send an empty checks list, an empty notChecked list and an empty questions list, '
2099
2022
  + 'and write ONE sentence saying what the job does, from the numbered job lines.';
2100
2023
 
2024
+ /** What the confirm turn tells the model about a REPO job (model-facing, registered; Addendum 2026-11-15 (d)): the turn plans the goal only, the job's checks are the one list's rows, built by code after the draft. */
2025
+ export const REPO_CONFIRM_NOTE = 'The checks of this job are made elsewhere: plan none. Send an empty checks list, an empty notChecked list and an empty questions list, '
2026
+ + 'and write ONE sentence saying what the job does, from the numbered job lines.';
2027
+
2101
2028
  export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a read-only survey or listing of their '
2102
2029
  + 'own repository, and draft a PLAN for a job\'s definition of done: the checks you plan to compose and one '
2103
2030
  + 'signed goal sentence. You never propose a check the numbered job lines (and the ~ rules written under them) did not ask for '
@@ -2160,6 +2087,7 @@ export function confirmPrompt({ answers, questions, labels = {}, facts = null, l
2160
2087
  // PART 1a: a rubric job on the person's own text files. The model is told what a check CAN be here, so that anything
2161
2088
  // needing judgement lands in `notChecked` instead of being promised as a check
2162
2089
  if (lang === RUBRIC_LANG) lines.push('', RUBRIC_CONFIRM_NOTE);
2090
+ else if (isRepo === true) lines.push('', REPO_CONFIRM_NOTE);
2163
2091
  // R10: the `~` rules code settles from the person's own picks are not yours to plan: a check for them is code's, a gap is code's Not checked row
2164
2092
  // MCP + tickets R5 (F285): a Tickets job's confirm turn is told the ticket is picked per run and a priority/label line is code's, so it never asks the person which ticket
2165
2093
  if (ticket) lines.push('', ticketPerRunFacts());
@@ -2216,7 +2144,7 @@ async function askConfirmPlan({ convo, generate, mode, book, label }) {
2216
2144
  * ask: (step: {kind: string, [k: string]: any}) => Promise<string|null>,
2217
2145
  * onPhase?: (phase: string, data?: any) => void, mode?: 'tool'|'text',
2218
2146
  * worseThanBefore?: string, inputs?: {n: number, label: string, value: string}[]|null,
2219
- * jobLines?: {n: number}[]|null, ticket?: boolean, card?: {checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|'default', key?: string}[], notChecked: string[], notCheckedBy?: Record<string, string>}|null, block?: CheckBlock|null, cardOf?: (() => any)|null}} o retired field (hamr's ruling 2026-09-28):
2147
+ * jobLines?: {n: number}[]|null, ticket?: boolean, card?: {checkItems: {text: string, fromLine: number[], by: 'agent'|'you'|'default', key?: string}[], notChecked: string[], notCheckedBy?: Record<string, string>, closeDecl?: any}|null, block?: CheckBlock|null, cardOf?: (() => any)|null}} o retired field (hamr's ruling 2026-09-28):
2220
2148
  * `worseThanBefore` is never asked any more and defaults to `''` — a
2221
2149
  * caller may still pass a string through (kept for a future, non-ask
2222
2150
  * source of the same constraint), it just never comes from an ask() step.
@@ -2247,8 +2175,8 @@ export async function runConfirmTurn({
2247
2175
  // the live check block of a rubric job and the reader that draws its rows (`() => cardOfClose(...)`): the confirm card's Drop and Add are instant row edits ($0, no AI) through the block, and the card is redrawn from its rows
2248
2176
  block = null, cardOf = null,
2249
2177
  }) {
2250
- /** a rubric job's confirm turn plans the goal only (its checks are the list's) */
2251
- const goalOnly = lang === RUBRIC_LANG;
2178
+ /** a rubric or a repo job's confirm turn plans the goal only (its checks are the list's rows) */
2179
+ const goalOnly = lang === RUBRIC_LANG || isRepo === true;
2252
2180
  /** @typedef {null|'cap-halt'|'pricing-red'|'provider-red'|'artifact-red'|'confirm-abandoned'|'confirm-restart'} ConfirmStop */
2253
2181
  /** @returns {{ok: boolean, stop: ConfirmStop, rounds: number, accepted: null, reds: Red[], cost: any}} */
2254
2182
  const base = () => ({ ok: false, stop: null, rounds: 0, accepted: null, reds: [], cost: book.report() });
@@ -2273,7 +2201,7 @@ export async function runConfirmTurn({
2273
2201
  // the prompt below so the model can check `notChecked` against it, and
2274
2202
  // reused (never recomputed) after the call so the shown, prompted, and
2275
2203
  // recorded protections are always the exact same list.
2276
- const protections = confirmProtections({ verdictType, lang: resolvedLang, writeScope, jobLines });
2204
+ const protections = confirmProtections({ verdictType, lang: resolvedLang, writeScope, jobLines, closeDecl: block !== null ? block.closeView() : (card?.closeDecl ?? null) });
2277
2205
 
2278
2206
  // ── up to 2 paid rounds (ruling 5) ─────────────────────────────────────────
2279
2207
  /** @type {string|null} */
@@ -2358,12 +2286,17 @@ export async function runConfirmTurn({
2358
2286
  // a rubric job's turn keeps nothing but the goal of the model's plan: its checks, gaps and questions are the list's to make, so code discards any it sent
2359
2287
  if (goalOnly) r.plan = { ...r.plan, checks: [], notChecked: [], questions: [] };
2360
2288
  const notChecked = [...(r.plan.notChecked ?? [])];
2361
- for (const row of dropRows(facts?.look?.dropped)) { const text = dropLine(row, jobLines, lineRules); if (!notChecked.includes(text)) notChecked.push(text); }
2289
+ const lookRows = dropRows(facts?.look?.dropped).map((row) => ({ row, text: dropLine(row, jobLines, lineRules) }));
2290
+ for (const { text } of lookRows) if (!notChecked.includes(text)) notChecked.push(text);
2291
+ // ONE row per `~` rule on the CARD (hamr 2026-11-14, run mwgsl7zx): a rule the check list says Not checked is said by its row alone (its reason is the look's sentence, or the person's kept Drop, which wins),
2292
+ // so the look's own line for that rule is not drawn beside it. `accepted.notChecked` below stays the full list the drafter is told.
2293
+ // live run mwi76vh8 (session smwi75mbqjjbs): a drop with no `~` rule (a place fact) is the block's own `!` row too ("boston place"), so its look line is not drawn beside it either
2294
+ const shownNotChecked = () => notChecked.filter((t) => !lookRows.some((l) => l.text === t && block !== null && (l.row.rule !== undefined ? block.saysRule(l.row.line, l.row.rule) : block.rows.some((r) => r.key === `L${l.row.line}.fact.${String(l.row.fact).toLowerCase().replace(/\s+/g, ' ').trim()}`))));
2362
2295
  const checkItems = normalizeChecks(r.plan.checks);
2363
2296
  r.plan = { ...r.plan, checks: checkItems.map((c) => c.text), checkItems };
2364
2297
  // the rows of the check block, drawn by the same readers as the signed card (hamr 2026-11-12: the confirm card showed no row the block had built); shown only, never accepted
2365
2298
  const planFor = (/** @type {any} */ c) => ({
2366
- ...r.plan, ...(c === null ? {} : { checkItems: c.checkItems, checks: c.checkItems.map((/** @type {any} */ x) => x.text) }), protections, notChecked: c === null ? notChecked : [...new Set([...notChecked, ...c.notChecked])], ...(c?.notCheckedBy ? { notCheckedBy: c.notCheckedBy } : {}),
2299
+ ...r.plan, ...(c === null ? {} : { checkItems: c.checkItems, checks: c.checkItems.map((/** @type {any} */ x) => x.text) }), protections, notChecked: [...new Set([...(c === null ? notChecked : shownNotChecked()), ...(c === null ? [] : c.notChecked)])], ...(c?.notCheckedBy ? { notCheckedBy: c.notCheckedBy } : {}),
2367
2300
  signedFacts: (Array.isArray(facts?.look?.facts) ? facts.look.facts : []).map((/** @type {any} */ f) => String(f?.name)),
2368
2301
  ...(block !== null && cardOf !== null ? { suggested: block.suggestedView(), editable: true } : {}),
2369
2302
  });
@@ -2716,6 +2649,8 @@ export async function authorClose({
2716
2649
  block.addLook(Array.isArray(facts?.look?.facts) ? facts.look.facts : [], Array.isArray(facts?.look?.dropped) ? facts.look.dropped : []);
2717
2650
  block.reconcile();
2718
2651
  }
2652
+ // the mandatory guards are job-level `$` rows of the signed list (piece 2): the block that signs knows their names, whoever built it
2653
+ if (block !== null && lang === RUBRIC_LANG) block.setGuards(guards.map((/** @type {any} */ g) => g.name), Array.isArray(writeScope) && writeScope.length ? writeScope : ['output/']);
2719
2654
  /** the row-edit turn replaces the drafter's declaration for a rubric job: the model boundary and the declaration code assembles from the block's rows */
2720
2655
  const rowEdits = block !== null && lang === RUBRIC_LANG;
2721
2656
  const draftGenerate = rowEdits && editGenerate ? editGenerate : generate;
@@ -2741,7 +2676,7 @@ export async function authorClose({
2741
2676
  // the draft gate on one settled declaration: validation, then (PART 1c, rubric) code proves, at $0, that every label is PICKED from the input's own list and every word a fact depends
2742
2677
  // on is really in the source (white-space blind, once is enough). A word that is not found is a red naming the word and the input; the drafter revises like it does for any validation red.
2743
2678
  const checkDraft = (/** @type {any} */ d) => {
2744
- let r = validateDeclaration(d, { catalogue, listing: seedFiles, guards, envOwned: ownedEnvNames, verdictType, writeScope, jobLines, inputLabels: inputLabelsOf(inputs) });
2679
+ let r = validateDeclaration(d, { catalogue, listing: seedFiles, guards, envOwned: ownedEnvNames, verdictType, jobLines, inputLabels: inputLabelsOf(inputs) });
2745
2680
  if (r.ok && lang === RUBRIC_LANG) {
2746
2681
  const words = checkDeclarationWords(r.declaration, inputTexts, facts?.look ?? null);
2747
2682
  if (words.length > 0) r = { ...r, ok: false, reds: [...r.reds, ...words], declaration: null };
@@ -2854,7 +2789,7 @@ export async function authorClose({
2854
2789
  // `questions` is never part of the declaration: stripped before validation, kept only through the machine's filter
2855
2790
  const { questions: rawQuestions, ...rest } = ask.declaration;
2856
2791
  ask.declaration = rest;
2857
- const nq = normalizeQuestions(rawQuestions, /** @type {number[]} */ (questionLines));
2792
+ const nq = normalizeQuestions(rawQuestions, /** @type {number[]} */ (questionLines), jobLines);
2858
2793
  askedQuestions = nq.kept;
2859
2794
  droppedQuestions = nq.dropped;
2860
2795
  }