bareloop 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +69 -209
  4. package/package.json +2 -2
  5. package/src/authorflow.js +164 -340
  6. package/src/authoring.js +7 -127
  7. package/src/authorjob.js +139 -472
  8. package/src/authorreadout.js +24 -368
  9. package/src/authorrun.js +21 -215
  10. package/src/behaviour.js +14 -0
  11. package/src/blockasks.js +43 -0
  12. package/src/bundlerun.js +4 -1
  13. package/src/checkblock.js +798 -0
  14. package/src/checklist.js +128 -0
  15. package/src/checkpick.js +39 -312
  16. package/src/checkwords.js +3 -1
  17. package/src/cli.js +3 -3
  18. package/src/declaredclose.js +38 -108
  19. package/src/destpoint.js +4 -2
  20. package/src/draftspend.js +46 -0
  21. package/src/facts.js +8 -1
  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 +5 -347
  28. package/src/noteask.js +124 -0
  29. package/src/pagedry.js +27 -5
  30. package/src/pagemap.js +15 -3
  31. package/src/pagerules.js +18 -3
  32. package/src/panel/authorroutes.js +24 -6
  33. package/src/panel/authorsession.js +222 -177
  34. package/src/panel/importrun.js +0 -1
  35. package/src/panel/index.html +198 -26
  36. package/src/panel/jobplan.js +87 -33
  37. package/src/panel/server.js +74 -68
  38. package/src/panel/status.js +3 -0
  39. package/src/pickrecord.js +34 -55
  40. package/src/placerule.js +355 -0
  41. package/src/planrun.js +2 -48
  42. package/src/promptregisters.js +13 -17
  43. package/src/providerrows.js +0 -36
  44. package/src/providers.js +4 -25
  45. package/src/questionbox.js +104 -0
  46. package/src/rowedit.js +115 -0
  47. package/src/rubricstep.js +234 -127
  48. package/src/run.js +11 -16
  49. package/src/userrun.js +60 -112
  50. package/types/authorflow.d.ts +41 -197
  51. package/types/authoring.d.ts +1 -14
  52. package/types/authorjob.d.ts +35 -59
  53. package/types/authorreadout.d.ts +10 -88
  54. package/types/behaviour.d.ts +12 -0
  55. package/types/blockasks.d.ts +36 -0
  56. package/types/checkblock.d.ts +376 -0
  57. package/types/checklist.d.ts +134 -0
  58. package/types/checkpick.d.ts +8 -140
  59. package/types/cli.d.ts +1 -3
  60. package/types/declaredclose.d.ts +7 -33
  61. package/types/destpoint.d.ts +2 -0
  62. package/types/draftspend.d.ts +21 -0
  63. package/types/index.d.ts +2 -4
  64. package/types/job.d.ts +8 -0
  65. package/types/jobblock.d.ts +8 -38
  66. package/types/judged.d.ts +7 -357
  67. package/types/kinds.d.ts +3 -104
  68. package/types/noteask.d.ts +76 -0
  69. package/types/pagedry.d.ts +13 -0
  70. package/types/pagemap.d.ts +4 -0
  71. package/types/pagerules.d.ts +7 -0
  72. package/types/panel/authorsession.d.ts +47 -5
  73. package/types/panel/jobgrid.d.ts +8 -8
  74. package/types/panel/jobplan.d.ts +48 -10
  75. package/types/panel/server.d.ts +27 -18
  76. package/types/panel/status.d.ts +5 -0
  77. package/types/pickrecord.d.ts +20 -13
  78. package/types/placerule.d.ts +194 -0
  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 +87 -0
  83. package/types/rowedit.d.ts +32 -0
  84. package/types/rubricstep.d.ts +100 -48
  85. package/types/run.d.ts +9 -19
  86. package/types/userrun.d.ts +0 -1
  87. package/src/calibrate.js +0 -702
  88. package/src/cardauthor.js +0 -502
  89. package/src/fitcheck.js +0 -166
  90. package/types/calibrate.d.ts +0 -201
  91. package/types/cardauthor.d.ts +0 -358
  92. package/types/fitcheck.d.ts +0 -113
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,
@@ -87,10 +86,11 @@ import {
87
86
  import { buildSeedListing, cleanEntry, SURVEY_CAUSES, AUTHOR_CALL_TIMEOUT_MS } from './authorscout.js';
88
87
  import { extractArtifact, priceOf, scrubRaw, tallyCalls, capStop, callCasualty } from './text.js';
89
88
  import { redactSecrets } from './validate.js';
90
- import { applyPicks, dropExtras, fillAndMergeFacts, moveUncheckable, retentionOf, settleRules } from './checkpick.js';
91
- import { stepFileContract, inputLabelsOf, stepFileRel, readFrozenInputs, withFactBindings, settlePersonsWords, withDropNotes, lineRules } from './rubricstep.js';
89
+ import { ledgerRecord } from './checklist.js';
90
+ import { ROW_EDIT_REVISE, rowEditUserText, rowEditChannel, editsOf } from './rowedit.js';
91
+ import { REASON, CheckBlock } from './checkblock.js';
92
+ import { stepFileContract, inputLabelsOf, stepFileRel, readFrozenInputs, lineRules, lineCarriesText } from './rubricstep.js';
92
93
  import { dropRows, dropLine } from './pagedropwords.js';
93
- import { factShapeGuide } from './facts.js';
94
94
  import { renderLookReport } from './inputlook.js';
95
95
  import { checkDeclarationWords, labelListsFor } from './factwords.js';
96
96
  import { ticketFilterReds, ticketFilterBlock, ticketPerRunFacts, TICKET_FILTER_SCHEMA_WORDS } from './ticketfilter.js';
@@ -323,10 +323,10 @@ export const INPUTS_FIELD = Object.freeze({
323
323
  + '(e.g. `spec: docs/spec.md`) — git must track them.',
324
324
  });
325
325
 
326
- /** P7: how to write "The job" (printed under its question by the CLI; the panel's box shows the same in its examples). */
326
+ /** P7: how to write "The job" (printed under its question by the CLI; the panel's box shows the same in its placeholder). */
327
327
  export const JOB_BLOCK_HELP = Object.freeze([
328
328
  'One line per thing the job must do — each plain line gets a number. A line starting with `~` is a rule for the',
329
- 'numbered line above it. For a rubric check, a `~ PASS: ...` and a `~ FAIL: ...` line are your examples.',
329
+ 'numbered line above it (what you want checked, in your own words).',
330
330
  ]);
331
331
 
332
332
  /** Destination's wording when Source resolved to a git repo: the answer IS the
@@ -401,37 +401,14 @@ export const FIELD_LABELS = Object.freeze({
401
401
  * soft-green and hitl extensions below — computed, never hardcoded twice. */
402
402
  const NEXT_FREE_TEXT_KEY = Object.keys(GREEN_QUESTIONS).length + 1;
403
403
 
404
- /** The soft-green quartet's own key for Judge Examples — exported so
405
- * `cardauthor.js` reads the SAME number this module files the answer under,
406
- * rather than a second, hand-typed "6"/"7". */
407
- export const SOFTGREEN_JUDGE_EXAMPLES_KEY = NEXT_FREE_TEXT_KEY;
408
-
409
- /** The Judge Examples question — the signed table's own Holds text, verbatim
410
- * ("one pass, one fail, and why"), not the old worded Q7 ("Give one example
411
- * you'd pass and one you'd fail, and say why."). Exported so `cardauthor.js`'s
412
- * prompt and this module's own `SOFTGREEN_QUESTIONS` render the identical
413
- * string; its label ("Judge examples") lives in `SOFTGREEN_FIELD_LABELS`. */
414
- export const JUDGE_EXAMPLES_QUESTION = 'the PASS: and FAIL: examples the person wrote under their job lines, each with its line number';
415
-
416
- /** {@link FIELD_LABELS} plus Judge Examples' own label, for the soft-green set. */
417
- export const SOFTGREEN_FIELD_LABELS = Object.freeze({
418
- ...FIELD_LABELS,
419
- [SOFTGREEN_JUDGE_EXAMPLES_KEY]: 'Judge examples',
420
- });
404
+ /** {@link FIELD_LABELS} for the soft-green set: the same one label (the judge examples are gone). */
405
+ export const SOFTGREEN_FIELD_LABELS = Object.freeze({ ...FIELD_LABELS });
421
406
 
422
407
  /**
423
- * THE SOFTGREEN SET — the green trio plus Judge Examples. A judged close needs
424
- * exactly this one more thing the green set cannot supply: a real pass/fail
425
- * pair in the person's own words, which module 4 (`cardauthor.js`) compiles
426
- * into the signed rubric card and the frozen calibration set. It rides in
427
- * `answers` and reaches the composer verbatim through the prompt's interview
428
- * block, exactly as every other free-text answer does — this module derives
429
- * nothing from it.
408
+ * THE SOFTGREEN SET — the green set again: a rubric job's whole job is the numbered lines of "The job" (its `~` rules
409
+ * become the check list); the PASS/FAIL judge examples are gone (hamr 2026-11-14).
430
410
  */
431
- export const SOFTGREEN_QUESTIONS = Object.freeze({
432
- ...GREEN_QUESTIONS,
433
- [SOFTGREEN_JUDGE_EXAMPLES_KEY]: JUDGE_EXAMPLES_QUESTION,
434
- });
411
+ export const SOFTGREEN_QUESTIONS = Object.freeze({ ...GREEN_QUESTIONS });
435
412
 
436
413
  /**
437
414
  * THE HITL SET (N4 slice 1, kept in code only — never offered in the form or
@@ -506,10 +483,8 @@ export const CLASS_STATEMENTS = Object.freeze({
506
483
  'soft-green': 'The person declared this job SOFT-GREEN: part of what "done" means here needs JUDGEMENT — reading '
507
484
  + 'the result and deciding whether it is any good — and no command can render it. Compose the mechanical part '
508
485
  + 'first: everything about this repository a command can decide is still a mechanical stage, exactly as it would '
509
- + 'be for a green job. Then put ONE judged-floor stage AFTER them, carrying the few things the person said they '
510
- + 'actually look for and the real files the work lands in (files the job may EDIT, inside the write fence, '
511
- + '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, '
512
- + 'so name each thing they look for as its own line, and leave nothing to be inferred.',
486
+ + 'be for a green job. Compose NO stage for the part that needs judgement: there is no judged stage to put it in '
487
+ + '(the old judge is gone), so leave that part out and say so in your notes; the person judges it at Accept.',
513
488
  // N4 slice 1. The mechanical-first composition law is stated as an ORDER
514
489
  // because first-red-wins makes the order the mechanism: the cheap stages shield
515
490
  // the expensive one, and the person is never the first filter.
@@ -648,10 +623,12 @@ export const GUARD_DESCRIPTIONS = Object.freeze({
648
623
  * close — one source, never a second hand-typed list — rendered through the
649
624
  * frozen line in {@link GUARD_DESCRIPTIONS}, plus the write fence (a real,
650
625
  * signed fence — {@link writeScopeBlock}'s own subject) when one is set.
651
- * @param {{verdictType: string, lang: string, writeScope?: string[]|null, jobLines?: {n: number}[]|null}} o
626
+ * 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
627
+ * (results and no note) is listed without it, and with no close to read nothing is claimed about text.
628
+ * @param {{verdictType: string, lang: string, writeScope?: string[]|null, jobLines?: {n: number}[]|null, closeDecl?: any}} o
652
629
  * @returns {string[]}
653
630
  */
654
- export function confirmProtections({ verdictType, lang, writeScope = null, jobLines = null }) {
631
+ export function confirmProtections({ verdictType, lang, writeScope = null, jobLines = null, closeDecl = null }) {
655
632
  const guards = classGuards({ verdictType, lang });
656
633
  const lines = guards.map((g) => {
657
634
  const desc = GUARD_DESCRIPTIONS[g.name];
@@ -667,7 +644,7 @@ export function confirmProtections({ verdictType, lang, writeScope = null, jobLi
667
644
  // PART 1a: a rubric job on local files always checks, for EVERY numbered line, that the line's file exists, is complete
668
645
  // 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
669
646
  if (lang === RUBRIC_LANG && Array.isArray(jobLines)) {
670
- for (const l of jobLines) lines.push(`line ${l.n} file — ${stepFileRel(l.n)} must exist, be complete JSON, and carry text`);
647
+ for (const l of jobLines) lines.push(`line ${l.n} file — ${stepFileRel(l.n)} must exist, be complete JSON${lineCarriesText(closeDecl, l.n) ? ', and carry text' : ''}`);
671
648
  }
672
649
  return lines;
673
650
  }
@@ -789,39 +766,6 @@ export const PARAM_SCHEMAS = Object.freeze({
789
766
  extensions: { type: 'array', minItems: 1, items: { type: 'string' } },
790
767
  allowPrefixes: { type: 'array', minItems: 1, items: { type: 'string' } },
791
768
  requireNonEmpty: { const: true },
792
- // SOFTGREEN's two. `rule` is an ENUM off the judge's own rulebook — where only a
793
- // closed set can satisfy a field, the illegal value is made inexpressible rather
794
- // than rejected after the fact (`check-passes(name)`, again) — and `text` is the
795
- // only free string, carrying the signer's words so a red can be explained in them.
796
- card: {
797
- type: 'object',
798
- description: 'the rubric, as enumerated items: one line per thing the person actually looks for, in the order '
799
- + 'they look for them. The rule is SELECTED from the arbiter\'s own rulebook; the text is theirs.',
800
- properties: {
801
- items: {
802
- type: 'array',
803
- minItems: 1,
804
- items: {
805
- type: 'object',
806
- properties: {
807
- rule: { enum: [...JUDGE_RULE_IDS], description: 'which owned rule this line asserts' },
808
- text: { type: 'string', minLength: 1, description: 'what this line means, in the person\'s own words' },
809
- },
810
- required: ['rule', 'text'],
811
- additionalProperties: false,
812
- },
813
- },
814
- },
815
- required: ['items'],
816
- additionalProperties: false,
817
- },
818
- paths: {
819
- type: 'array',
820
- minItems: 1,
821
- maxItems: MAX_JUDGED_PATHS,
822
- items: { type: 'string' },
823
- description: 'the AUTHORITATIVE artifacts to judge, repository-relative, read off the listing. One paid call each.',
824
- },
825
769
  step: { type: 'integer', minimum: 1, description: 'the number of the job line this stage serves; its file is output/steps/<step>.json' },
826
770
  parts: {
827
771
  type: 'array',
@@ -836,7 +780,6 @@ export const PARAM_SCHEMAS = Object.freeze({
836
780
  value: { type: 'integer', minimum: 1, description: 'minClaims / maxClaims: the number of claims asked for' },
837
781
  source: { type: 'string', minLength: 1, description: 'cited: the label of the input a quote must come from' },
838
782
  domains: { type: 'array', minItems: 1, items: { type: 'string', minLength: 1 }, description: 'guard only: the web domains the rule is about' },
839
- covers: { type: 'array', minItems: 1, uniqueItems: true, items: { type: 'integer', minimum: 1 }, description: 'the number(s) of the CONFIRMED check(s) this part carries out' },
840
783
  rules: { type: 'array', minItems: 1, uniqueItems: true, items: { type: 'integer', minimum: 1 }, description: 'the number(s) of the job line\'s ~ rules this part carries out (1 = the first ~ rule under the line)' },
841
784
  facts: {
842
785
  type: 'array',
@@ -1240,21 +1183,28 @@ export function writeScopeBlock(writeScope) {
1240
1183
  * meaning from `openQuestions` (which means "could not resolve"): the two
1241
1184
  * never merge.
1242
1185
  * @param {{checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[],
1243
- * answeredQuestions?: string[]}} confirmed
1244
- * @param {{numbered?: boolean}} [o] `numbered` (a rubric job on files): each confirmed check carries its `#n`, which a part cites in `covers`
1186
+ * answeredQuestions?: string[], goalOnly?: boolean}} confirmed
1245
1187
  */
1246
- export function confirmedBlock(confirmed, { numbered = false } = {}) {
1188
+ export function confirmedBlock(confirmed) {
1247
1189
  const checks = confirmed.checks ?? [];
1248
1190
  const protections = confirmed.protections ?? [];
1249
1191
  const openQuestions = confirmed.openQuestions ?? [];
1250
1192
  const notChecked = confirmed.notChecked ?? [];
1251
1193
  const answeredQuestions = confirmed.answeredQuestions ?? [];
1194
+ // a rubric job's confirm turn plans the goal only (its checks are the list's): no check list and no "the person confirmed" text
1195
+ if (confirmed.goalOnly === true) {
1196
+ return 'ALWAYS-ON PROTECTIONS \u2014 already enforced by this run and unchanged by the job; never compose one of these as a check:\n\n'
1197
+ + `${protections.map((p) => ` - ${p}`).join('\n') || ' (none)'}\n`
1198
+ + (notChecked.length ? `\nTHESE WERE ASKED FOR, BUT NOTHING CHECKS THEM (state these in your notes):\n\n${notChecked.map((n) => ` - ${n}`).join('\n')}\n` : '')
1199
+ + (answeredQuestions.length ? `\nQUESTIONS THE PERSON ANSWERED \u2014 binding:\n\n${answeredQuestions.map((a) => ` - ${a}`).join('\n')}\n` : '')
1200
+ + (openQuestions.length ? `\nOPEN QUESTIONS (state these in your notes, never decide them silently):\n\n${openQuestions.map((q) => ` - ${q}`).join('\n')}\n` : '');
1201
+ }
1252
1202
  return 'THE CONFIRMED PLAN — the person already saw and confirmed this in the confirm turn\n\n'
1253
1203
  + 'Compose stages for these checks and no other — a genre never adds a check the goal did not ask for, and '
1254
1204
  + 'neither do you:\n\n'
1255
1205
  + `${(confirmed.checkItems?.length
1256
- ? confirmed.checkItems.map((c, i) => ` - ${numbered ? `#${i + 1} ` : ''}${c.fromLine && c.fromLine.length ? `[line ${c.fromLine.join(', ')}] ` : ''}${c.text}`)
1257
- : checks.map((c, i) => ` - ${numbered ? `#${i + 1} ` : ''}${c}`)).join('\n') || ' (none)'}\n\n`
1206
+ ? confirmed.checkItems.map((c) => ` - ${c.fromLine && c.fromLine.length ? `[line ${c.fromLine.join(', ')}] ` : ''}${c.text}`)
1207
+ : checks.map((c) => ` - ${c}`)).join('\n') || ' (none)'}\n\n`
1258
1208
  + 'These protections are already always-on and unchanged by this plan — never compose one of these as a check:\n\n'
1259
1209
  + `${protections.map((p) => ` - ${p}`).join('\n') || ' (none)'}\n\n`
1260
1210
  + (notChecked.length
@@ -1322,7 +1272,7 @@ export function jobLineTagBlock(count, guardNames = []) {
1322
1272
  * writeScope?: string[]|null,
1323
1273
  * jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
1324
1274
  * confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null,
1325
- * labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
1275
+ * labelLists?: string[]|null,
1326
1276
  * }} o
1327
1277
  */
1328
1278
  export function authorPrompt({
@@ -1337,16 +1287,11 @@ export function authorPrompt({
1337
1287
  confirmed = null,
1338
1288
  // PART 1c: the label lists code made from the frozen inputs (src/labelscan.js `renderLabelList`); a label is picked from them
1339
1289
  labelLists = null,
1340
- // R10: the `~` rules code settles from the person's own picks (src/checkpick.js); ABSENT = byte-identical prompt
1341
- settled = null,
1342
1290
  }) {
1343
1291
  // PART 1a: a rubric job on the person's own local files has no repository, no genre template and no tool to measure with —
1344
1292
  // it gets its own brief (`rubricAuthorPrompt`), which still ends in the same declaration tool and the same guards
1345
1293
  // an absent catalogue is the language's own menu (`catalogueForLang`), so a code job's prompt never lists a rubric-only kind
1346
1294
  const catalogue = catalogueIn ?? catalogueForLang(lang);
1347
- if (lang === RUBRIC_LANG) {
1348
- return rubricAuthorPrompt({ answers, questions, facts, listingBlock, verdictType, guards, mode, catalogue, writeScope, jobLines, inputs, confirmed, labelLists, settled });
1349
- }
1350
1295
  const statement = CLASS_STATEMENTS[String(verdictType)] ?? null;
1351
1296
  if (statement === null) {
1352
1297
  throw new Error(`[authorflow] the authoring prompt needs the verdict class the user picked, and "${verdictType}" `
@@ -1463,180 +1408,6 @@ export const RUBRIC_FILES_STATEMENT = 'The person declared this job SOFT-GREEN a
1463
1408
  + 'Compose ONE rubric-step stage per numbered job line, after the mandatory guard, and name only limits the person actually '
1464
1409
  + 'asked for. A part you cannot express that way is not approximated by a stage that means something else.';
1465
1410
 
1466
- /**
1467
- * THE RUBRIC RULES, in one place (live fix B1): what the confirm step and the drafter are both told about turning the person's words
1468
- * into checks. The confirm note ({@link RUBRIC_CONFIRM_NOTE}) and the composer brief ({@link REQUIRED_FACTS_BRIEF}) interpolate THIS
1469
- * constant, so the two cannot drift (in smv6k6l8dxkzs the confirm step planned a limit the drafter then could not carry, and the
1470
- * drafter added an airport code the person never wrote). Field-neutral: neither turn needs the other's field names.
1471
- */
1472
- export const RUBRIC_RULES = 'THE RULES FOR TURNING THE PERSON\'S WORDS INTO CHECKS (the same for every turn of this job):\n - A limit the person WROTE ("under $450") is a rule that can be checked: plan it as a limit with its number.\n'
1473
- + ' - A number YOU make out of their words ("not a red-eye" becomes a departure time between 06:00 and 21:00) is your proposal, marked '
1474
- + 'as the AI\'s proposal for the person to check; a limit on a time that you propose is a RANGE (between), never one-sided. The input does '
1475
- + 'not have to hold the person\'s word (it holds no "red-eye"): the limit goes on the time the input DOES hold (e.g. the one after "Departure time:"), as a '
1476
- + 'range marked as the AI\'s proposal.\n'
1477
- + ' - Names, labels and units are the INPUT\'s own words, copied exactly as the input writes them. When the input does not use the '
1478
- + 'person\'s word (they wrote SFO, the input says San Francisco International Airport), use the words the input uses; never invent a '
1479
- + 'word the input does not hold, and never add a code (like SFO) that the person did not write and the input does not hold.\n'
1480
- + ' - A label for a line that asks for N results (a count of N) must sit in each result, so the label list must count it N or more times '
1481
- + '(the x-number beside it). A label counted fewer times is on the page once or twice (a sort tab, a switch) and is refused at $0 with its count.\n'
1482
- + ' - The same holds for the words a "must say" (phrase) fact makes each quote say: they must be in the input at least N times for N results. Words counted fewer times (page-header words like "from San Francisco" when each result says "Leaves San Francisco International Airport") are refused at $0 with their count; pick words every result says, or drop the check.';
1483
-
1484
- /**
1485
- * R10: the `~` rules code settles from the person's own picks, as the composer is told them. The drafter writes no check for these and lists nothing for them under
1486
- * "refused": code puts the picked check, or the Not checked row, on the stage itself.
1487
- * @param {{line: number, rule: number, text: string}[]} settled @returns {string}
1488
- */
1489
- export function settledBlock(settled) {
1490
- return 'SETTLED BY CODE - the person picked how these ~ rules are checked\n\n'
1491
- + settled.map((r) => `- line ${r.line}, ~ rule ${r.rule}: "${r.text}"`).join('\n')
1492
- + '\n\nFor these rules code writes the check the person picked, or the Not checked row, itself: write NO part and NO "refused" entry for them. '
1493
- + 'You never write a word, section, line, list-item or phrase count part (maxWords, minWords, maxLines, listItems, sections, sectionOrder, sectionWords, mustCarry, blockLines, nonEmpty) for any rule: only code does.';
1494
- }
1495
-
1496
- /**
1497
- * REQUIRED FACTS, as the composer is told them (PART 1b, PRD item 33 RF1–RF17). The shape of the fact part is in the catalogue and the
1498
- * schema; this is the judgement the schema cannot carry: what becomes a fact, where its words come from, and what is Not checked.
1499
- */
1500
- export const REQUIRED_FACTS_BRIEF = 'REQUIRED FACTS — what a line that finds, lists or looks something up leaves behind\n\n'
1501
- + 'For such a line write ONE part of class "fact". The worker\'s file for that line holds only results, each with ONE quote copied '
1502
- + 'from the input and the value of every fact as the quote writes it — no free text. Code checks every value against its quote.\n'
1503
- + ' - The facts come from the job line itself AND from its ~ rules: "SFO to LAX" is a from fact and a to fact even with no ~ line. '
1504
- + 'One fact per thing the person asked for. Give every fact a shape. A rule (op, value, or between lo and hi) only where the person '
1505
- + 'asked for a limit.\n'
1506
- + ' - THE LOOK above is what a read of the inputs found: write the facts from it. Copy every label (anchor), unit and phrase EXACTLY '
1507
- + 'as the look gives it (the look\'s phrase facts become phrase facts with the same words), and say in "notes" when you used the input\'s '
1508
- + 'words instead of the person\'s. A label (anchor) is PICKED from the labels the look found in the input, never typed; one that is not '
1509
- + 'among them is refused at $0. What the look could not find is not checked: list it under "refused" in the person\'s words.\n'
1510
- + ' - A money fact names at least one of "unit" (the words the input writes after the amount) or "currency" (a sign: $, € or £), and may name both. Each is one value or a list: '
1511
- + 'at most 3 currencies and 10 units, none repeated, a unit at most 100 characters. A code like EUR is a unit (it is read after the number), never a currency. '
1512
- + 'Copy the forms the look gives for the fact, in its order (the first is the main one); a form the look does not give is refused at $0.\n'
1513
- + ' - A word the look lists under NOT CHECKED or LEFT OUT is never used in a fact - not as a label, a closing label, a unit or a currency - and is refused at $0 with the reason if you do. '
1514
- + 'A fact or ~ rule listed under NOT CHECKED is not turned into a check: code lists it under Not checked for the person, so you do not write it into "refused" yourself.\n'
1515
- + ' - A date fact whose look line gives a "lang" is signed with that lang, and a number or money fact whose look line gives a "decimal" is signed with that decimal; copy it exactly (a fact that does not is refused at $0, nothing spent). "lang" goes on a date only and "decimal" on a number or money only. '
1516
- + 'For such a fact the worker writes the value in one canonical form (a date as YYYY-MM-DD, an amount with a point before the decimals), not as the quote writes it. A fact the look lists under NOT CHECKED for its month names or its decimal comma is not signed.\n'
1517
- + ' - When one result holds several values of one kind (leaves / arrives, subtotal / total) give the fact an anchor, the label that sits right before the value you mean.\n'
1518
- + ' - Set aiProposal true on a fact whose number you made out of their words.\n'
1519
- + RUBRIC_RULES + '\n'
1520
- + ' - How MANY results were asked for is a count ("3 releases": count {min: 3, max: 3}). WHICH ones ("the last", "the newest") and '
1521
- + 'anything else you cannot express as a shape and a rule ("the cheapest", "the best", "a good pick") is NOT CHECKED: list it in "refused" as {"line": N, "rule": the number of that ~ rule, "reason": the '
1522
- + 'person\'s own words}. EVERY ~ rule of a line must be carried out by a part (list its number in the part\'s "rules", 1 = the first ~ '
1523
- + 'rule under the line) or be listed in "refused"; a rule that is neither is refused at $0.\n'
1524
- + ' - A line that WRITES (a summary, a report) needs no part for a word, section, line, list-item or phrase count: code adds the checks the person picked for it. Code ties its numbers to the facts of the lines '
1525
- + 'before it; you do not add that.\n'
1526
- + ' - A look fact that says "carries ~ rule N" is how the look carried that rule: put N in the fact part\'s "rules" and do not also list rule N in "refused".\n'
1527
- + ' - A line has ONE fact part. A look fact that carries a ~ rule goes INSIDE the line\'s one fact part (add its rule number to that part\'s "rules" and its fact to "facts"), never as a fact part of its own: two fact parts on one line are refused at $0. '
1528
- + 'A count of words, bullets or list items the person picked is a pick, not a "count" on the fact part; "count" is only how many results were asked for.\n'
1529
- + ' - A ~ rule that you carry out as a fact (a limit on a time, a price, a date: "not a red-eye" is a time fact with a between rule) is carried by the '
1530
- + 'fact part: list its number in that part\'s "rules". It is NOT also a part of its own: on a line that lists facts, a part of class judged or none '
1531
- + 'is refused. A rule you cannot express as a shape and a rule goes in "refused", never into a part.\n'
1532
- + ' - "covers" and "rules" are fields of the PART, written once on it as a list of numbers. A fact never has a "covers" or a "rules" field.\n'
1533
- + ' - ONE stage per job line, holding ALL of that line\'s facts (and its other parts). Two stages for one line are refused: put a '
1534
- + '~ rule\'s fact (a "not a red-eye" time) on the same stage as the line\'s other facts.\n'
1535
- + ' - WHICH SHAPE TAKES WHICH FIELDS (a field a shape does not take is refused):\n'
1536
- + factShapeGuide();
1537
-
1538
- /**
1539
- * The composer prompt for a rubric job on local files (Part 1a, docs/product/ITEM33-BUILD.md). There is no repository
1540
- * and no survey: the facts are the numbered inputs and the listing is the frozen tree (input/ files, output/). It states
1541
- * the step-file contract the worker is also told ({@link stepFileContract}), so the stage and the file cannot drift.
1542
- * @param {{answers: Record<string|number, string>, questions?: Record<string|number, string>, facts: any, listingBlock: string,
1543
- * verdictType: string, guards: {name: string, kind: string, params: Record<string, any>, fill: string[]}[],
1544
- * mode?: 'tool'|'text', catalogue?: Record<string, any>, writeScope?: string[]|null,
1545
- * jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null, confirmed?: any,
1546
- * labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
1547
- * }} o
1548
- * @returns {string}
1549
- */
1550
- export function rubricAuthorPrompt({
1551
- answers, questions = GREEN_QUESTIONS, facts, listingBlock, verdictType, guards,
1552
- mode = 'tool', catalogue = KIND_CATALOGUE, writeScope = null, jobLines = null, inputs = null, confirmed = null, labelLists = null, settled = null,
1553
- }) {
1554
- const interview = Object.entries(questions)
1555
- .map(([n, q]) => `Q${n}. ${q}\nA${n}. ${answers?.[n] ?? '(no answer given)'}`)
1556
- .join('\n\n');
1557
- const role = `You are composing the close for one job.
1558
-
1559
- The close is what decides whether a run of this job came back DONE. It runs after the work is
1560
- finished, it is the only truth, and nothing else can overrule it. It is a list of STAGES. Each
1561
- stage names a kind from the catalogue below and fills that kind's parameters. Stages run in the
1562
- order you declare them.
1563
-
1564
- Two sources fed you this brief and neither of them is you:
1565
- - the person who wants the job done answered an interview, below, in their own words. They are
1566
- not a software engineer and did not name commands, thresholds or patterns;
1567
- - the person's own text files, frozen into the job. There is no code repository: the files sit
1568
- under input/ and the run writes only under output/.`;
1569
- const guardJson = guards.map((g) => ({
1570
- name: g.name,
1571
- kind: g.kind,
1572
- params: { ...g.params, ...Object.fromEntries(g.fill.map((f) => [f, FILL_MARKER])) },
1573
- }));
1574
- const output = mode === 'tool'
1575
- ? `HOW TO ANSWER
1576
-
1577
- Call the ${DECLARATION_TOOL_NAME} tool exactly once. Its arguments ARE the declaration: an ordered
1578
- "stages" array, plus "notes" for anything you could not express, and "refused" for a job line no stage can check.
1579
- Do not write the declaration as text.
1580
-
1581
- Stage names are unique. Every parameter name comes from the catalogue and no other. No parameter is
1582
- left as a placeholder. You never write a number the person did not ask for.`
1583
- : `HOW TO ANSWER
1584
-
1585
- A single JSON object and nothing else: an ordered "stages" array, plus "notes" for anything you
1586
- could not express, and "refused" for a job line no stage can check.
1587
-
1588
- Stage names are unique. Every parameter name comes from the catalogue and no other. No parameter is
1589
- left as a placeholder. You never write a number the person did not ask for.`;
1590
- return [
1591
- role,
1592
- `WHAT THE PERSON DECLARED "DONE" TO MEAN — their answer, not yours\n\n${RUBRIC_FILES_STATEMENT}`,
1593
- `THE INTERVIEW — the person's own words\n\n${interview}`
1594
- + (inputs && inputs.length ? `\n\n${renderInputs(inputs)}` : ''),
1595
- ...(jobLines && jobLines.length ? [jobLineTagBlock(jobLines.length)] : []),
1596
- ...(writeScope && writeScope.length ? [writeScopeBlock(writeScope)] : []),
1597
- ...(confirmed ? [confirmedBlock(confirmed, { numbered: true }),
1598
- 'EVERY CONFIRMED CHECK IS COMPOSED OR MOVED, NEVER DROPPED\n\nThe person saw the numbered checks above. On each countable or fact part that carries one of them out, list its number in the PART\'s "covers" (once on the part, never on a fact inside it). '
1599
- + 'A confirmed check that no part covers is not silently left out: it is moved to Not checked before signing, and the person is told. '
1600
- + 'To count "N things listed", use minClaims / maxClaims (it counts the claims listed under an input); anything else you cannot count is not composed.'] : []),
1601
- REQUIRED_FACTS_BRIEF,
1602
- ...(Array.isArray(settled) && settled.length ? [settledBlock(settled)] : []),
1603
- `THE STEP FILES — what the worker leaves behind for each job line\n\n${stepFileContract()}\n\n`
1604
- + 'The rubric-step stage for job line N reads exactly that file, output/steps/N.json. It names the inputs (by label) the '
1605
- + 'step must cite from, and the limits on its "text".',
1606
- `THE FILES — the inputs the person pointed at, frozen into the job\n\n${JSON.stringify(withoutLook(facts), null, 2)}`
1607
- + (listingBlock ? `\n\n${listingBlock}` : ''),
1608
- ...(Array.isArray(labelLists) && labelLists.length ? [labelLists.join('\n\n')] : []),
1609
- ...(facts && facts.look ? [renderLookReport(facts.look)] : []),
1610
- rubricCatalogueBlock(catalogue, { verdictType }),
1611
- 'MANDATORY GUARDS — already placed and already parameterised\n\n'
1612
- + 'This kind of job carries a stage the person did not ask for. It is fixed and you may not change, drop, rename, or '
1613
- + `re-kind it. The ONLY thing you fill in is each "${FILL_MARKER}" slot, from the interview:\n\n${JSON.stringify(guardJson, null, 2)}\n\n`
1614
- + 'Place it first: it is cheap, and the first red ends the judgement.',
1615
- output,
1616
- ].join('\n\n---\n\n');
1617
- }
1618
-
1619
- /** the facts object without the look's report (that is its own block, written by code) @param {any} facts */
1620
- function withoutLook(facts) {
1621
- if (!facts || typeof facts !== 'object' || !('look' in facts)) return facts;
1622
- const { look: _look, ...rest } = facts;
1623
- return rest;
1624
- }
1625
-
1626
- /**
1627
- * The kind rows of the catalogue, without the command-output parser text a rubric job never needs.
1628
- * @param {Record<string, any>} catalogue @param {{verdictType?: string|null}} [o]
1629
- */
1630
- function rubricCatalogueBlock(catalogue, { verdictType = null } = {}) {
1631
- const menu = classMenu(verdictType, catalogue);
1632
- const rows = Object.entries(catalogue).filter(([name, spec]) => menu.includes(name) && !spec.locked).map(([name, spec]) => `- ${name}\n ${spec.shape}\n required: ${spec.required.join(', ')}`
1633
- + `${spec.optional.length ? ` optional: ${spec.optional.join(', ')}` : ''}\n asserts: ${spec.asserts}`);
1634
- return `THE KIND CATALOGUE — these are the only kinds that exist.
1635
- You parameterise kinds. You never write a script, a shell fragment, or a new kind.
1636
-
1637
- ${rows.join('\n\n')}`;
1638
- }
1639
-
1640
1411
  // ── 3. THE MEASURED BLOCKS ───────────────────────────────────────────────────
1641
1412
 
1642
1413
  /** F6, at the rendering boundary: an absent number is unknown, never 0. */
@@ -1693,12 +1464,14 @@ export function renderSeedReadBlock(rows, { gapCap = REVISE_GAP_CAP } = {}) {
1693
1464
  * a credential crossed unmasked before this line existed. Applied to the whole
1694
1465
  * rendered block rather than one field, so a red added to the validator is
1695
1466
  * scrubbed by construction rather than by remembering.
1696
- * @param {{kind: 'validation'|'artifact', reds: (Red|string)[], cap?: number}} o
1467
+ * @param {{kind: 'validation'|'artifact'|'edits', reds: (Red|string)[], cap?: number}} o
1697
1468
  */
1698
1469
  export function renderRejectBlock({ kind, reds, cap = REVISE_RED_CAP }) {
1699
1470
  const head = kind === 'validation'
1700
1471
  ? 'MEASURED VALIDATION — your declaration was rejected by the validator before any stage could run:'
1701
- : 'MEASURED PARSE — your reply could not be read as one declaration:';
1472
+ : kind === 'edits'
1473
+ ? 'MEASURED EDITS — some of your edits were refused; each refusal is its own and your other edits stand:'
1474
+ : 'MEASURED PARSE — your reply could not be read as one declaration:';
1702
1475
  const rendered = (reds ?? []).map((r) => (typeof r === 'string' ? r : `${r.code} at ${r.path || '(root)'}: ${r.detail}${typeof r.hint === 'string' ? ` ${r.hint}` : ''}`));
1703
1476
  const shown = rendered.slice(0, cap);
1704
1477
  const tail = rendered.length > shown.length
@@ -2261,21 +2034,12 @@ const confirmChannel = () => ({
2261
2034
  * {@link CLASS_STATEMENTS} already use, rather than a code matcher over prose.
2262
2035
  */
2263
2036
  /**
2264
- * What the confirm turn tells the model about a rubric job on local text files (model-facing, registered). There is no
2265
- * repository and no judge: a check is a limit a machine counts (words, lines, sections), or a claim a quote from a named
2266
- * input must back. Everything else the person asked for is named in `notChecked`, in their words.
2037
+ * What the confirm turn tells the model about a rubric job on local text files (model-facing, registered). The turn plans the goal only: the checks of the job are the one list's
2038
+ * (`src/checklist.js`), made before the draft, never this turn's.
2267
2039
  */
2268
- export const RUBRIC_CONFIRM_NOTE = 'THIS JOB HAS NO REPOSITORY. Its inputs are the person\'s own text files, and each numbered job line leaves ONE '
2269
- + 'file the run writes (output/steps/<line>.json: a "text" and, per input, quoted claims — or, for a line that finds, lists or '
2270
- + 'looks something up, only filled facts, each quoted from the input). In this build only three kinds of check exist: a COUNTED '
2271
- + 'limit on that text (words, lines, sections, words per section); a claim that must be backed by a quote copied from a named input; '
2272
- + 'and a REQUIRED FACT, something a line finds (a price, a date, a time, a name, a phrase) with a limit only if the person gave one '
2273
- + '— plan one fact check for each thing the line asks to find, including those named in the line itself ("SFO to LAX"). Plan a check '
2274
- + 'only for what the person asked for in those terms; '
2275
- + 'anything that needs reading the text to judge it (tone, quality, accuracy), any superlative ("the cheapest", "the best") and any '
2276
- + 'choice of WHICH ones ("the last", "the newest") goes in `notChecked`, in the person\'s own words; how MANY results were asked for is '
2277
- + 'a count and can be checked.\n'
2278
- + RUBRIC_RULES;
2040
+ export const RUBRIC_CONFIRM_NOTE = 'THIS JOB HAS NO REPOSITORY. Its inputs are the person\'s own text files, and each numbered job line leaves ONE file the run writes. '
2041
+ + 'The checks of this job are made elsewhere: plan none. Send an empty checks list, an empty notChecked list and an empty questions list, '
2042
+ + 'and write ONE sentence saying what the job does, from the numbered job lines.';
2279
2043
 
2280
2044
  export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a read-only survey or listing of their '
2281
2045
  + 'own repository, and draft a PLAN for a job\'s definition of done: the checks you plan to compose and one '
@@ -2296,6 +2060,14 @@ export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a rea
2296
2060
  + 'where an answer is genuinely missing — never to double-check something already answered. You cannot read '
2297
2061
  + 'anything and you cannot run anything: everything you know is in the message you are given.';
2298
2062
 
2063
+ /** the confirm turn's system prompt for a rubric job (model-facing, registered): a one-sentence goal, no check of its own */
2064
+ export const CONFIRM_GOAL_SYSTEM = 'You read what a NON-ENGINEER answered, plus the numbered job lines and the inputs they pointed at, and write a one-sentence goal for the job. '
2065
+ + 'You never propose a check, a gap or a question: the checks of this job are made elsewhere. '
2066
+ + 'You cannot read anything and you cannot run anything: everything you know is in the message you are given.';
2067
+
2068
+ /** the confirm turn's system prompt for a job of this language: a rubric job's is the goal-only one @param {string} lang @returns {string} */
2069
+ export const confirmSystemFor = (lang) => (lang === RUBRIC_LANG ? CONFIRM_GOAL_SYSTEM : CONFIRM_SYSTEM);
2070
+
2299
2071
  /**
2300
2072
  * The confirm turn's per-round prompt (model-facing, registered). Shows the
2301
2073
  * person's own answers with their labels (the signed table's Field/Holds
@@ -2314,10 +2086,9 @@ export const CONFIRM_SYSTEM = 'You read what a NON-ENGINEER answered, plus a rea
2314
2086
  * @param {{answers: Record<string|number, string>, questions: Record<string|number, string>,
2315
2087
  * labels?: Record<string|number, string>, facts?: any, listing?: string|null,
2316
2088
  * writeScope?: string[]|null, isRepo: boolean, lang: string, worseThanBefore?: string,
2317
- * fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean,
2318
- * settled?: {line: number, rule: number, text: string}[]|null}} o
2089
+ * fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean}} o
2319
2090
  */
2320
- export function confirmPrompt({ answers, questions, labels = {}, facts = null, listing = null, writeScope = null, isRepo, lang, worseThanBefore = '', fixText = null, protections = [], inputs = null, ticket = false, settled = null }) {
2091
+ export function confirmPrompt({ answers, questions, labels = {}, facts = null, listing = null, writeScope = null, isRepo, lang, worseThanBefore = '', fixText = null, protections = [], inputs = null, ticket = false }) {
2321
2092
  const lines = ['THE PERSON\'S OWN ANSWERS (a non-engineer; read exactly what they wrote, invent nothing beyond it):'];
2322
2093
  for (const k of Object.keys(questions)) {
2323
2094
  const label = labels[k] ? ` (${labels[k]})` : '';
@@ -2333,7 +2104,6 @@ export function confirmPrompt({ answers, questions, labels = {}, facts = null, l
2333
2104
  // needing judgement lands in `notChecked` instead of being promised as a check
2334
2105
  if (lang === RUBRIC_LANG) lines.push('', RUBRIC_CONFIRM_NOTE);
2335
2106
  // 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
2336
- if (Array.isArray(settled) && settled.length) lines.push('', `SETTLED BY CODE - the person picked how these ~ rules are checked; plan no check for them and list none under notChecked:\n${settled.map((/** @type {any} */ r) => ` - line ${r.line}: "${r.text}"`).join('\n')}`);
2337
2107
  // 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
2338
2108
  if (ticket) lines.push('', ticketPerRunFacts());
2339
2109
  if (writeScope) lines.push(`WRITE SCOPE (the fence — the run may write only here): ${writeScope.join(', ')}`);
@@ -2389,7 +2159,7 @@ async function askConfirmPlan({ convo, generate, mode, book, label }) {
2389
2159
  * ask: (step: {kind: string, [k: string]: any}) => Promise<string|null>,
2390
2160
  * onPhase?: (phase: string, data?: any) => void, mode?: 'tool'|'text',
2391
2161
  * worseThanBefore?: string, inputs?: {n: number, label: string, value: string}[]|null,
2392
- * jobLines?: {n: number}[]|null, ticket?: boolean, settled?: {line: number, rule: number, text: string}[]|null}} o retired field (hamr's ruling 2026-09-28):
2162
+ * 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):
2393
2163
  * `worseThanBefore` is never asked any more and defaults to `''` — a
2394
2164
  * caller may still pass a string through (kept for a future, non-ask
2395
2165
  * source of the same constraint), it just never comes from an ask() step.
@@ -2415,9 +2185,13 @@ export async function runConfirmTurn({
2415
2185
  jobLines = null,
2416
2186
  // MCP + tickets R5 (F285): the job reads tickets; absent = the confirm prompt is byte-identical
2417
2187
  ticket = false,
2418
- // R10: the `~` rules settled by the person's picks (src/checkpick.js); ABSENT = the confirm prompt is byte-identical
2419
- settled = null,
2188
+ // a rubric job's check rows as the card readers read them (`cardOfClose` over `block.closeView()`): the card draws them, nothing else. SHOWN only: the accepted plan below never carries them
2189
+ card = null,
2190
+ // 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
2191
+ block = null, cardOf = null,
2420
2192
  }) {
2193
+ /** a rubric job's confirm turn plans the goal only (its checks are the list's) */
2194
+ const goalOnly = lang === RUBRIC_LANG;
2421
2195
  /** @typedef {null|'cap-halt'|'pricing-red'|'provider-red'|'artifact-red'|'confirm-abandoned'|'confirm-restart'} ConfirmStop */
2422
2196
  /** @returns {{ok: boolean, stop: ConfirmStop, rounds: number, accepted: null, reds: Red[], cost: any}} */
2423
2197
  const base = () => ({ ok: false, stop: null, rounds: 0, accepted: null, reds: [], cost: book.report() });
@@ -2442,7 +2216,7 @@ export async function runConfirmTurn({
2442
2216
  // the prompt below so the model can check `notChecked` against it, and
2443
2217
  // reused (never recomputed) after the call so the shown, prompted, and
2444
2218
  // recorded protections are always the exact same list.
2445
- const protections = confirmProtections({ verdictType, lang: resolvedLang, writeScope, jobLines });
2219
+ const protections = confirmProtections({ verdictType, lang: resolvedLang, writeScope, jobLines, closeDecl: block !== null ? block.closeView() : null });
2446
2220
 
2447
2221
  // ── up to 2 paid rounds (ruling 5) ─────────────────────────────────────────
2448
2222
  /** @type {string|null} */
@@ -2487,14 +2261,14 @@ export async function runConfirmTurn({
2487
2261
  let convo = [{
2488
2262
  role: 'user',
2489
2263
  content: confirmPrompt({
2490
- answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, protections, inputs, ticket, settled,
2264
+ answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, protections, inputs, ticket,
2491
2265
  }),
2492
2266
  }];
2493
2267
 
2494
2268
  for (let round = 1; round <= 2; round += 1) {
2495
2269
  if (fixText) {
2496
2270
  convo = [...convo, { role: 'user', content: confirmPrompt({
2497
- answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, fixText, protections, inputs, ticket, settled,
2271
+ answers, questions, labels, facts, listing, writeScope, isRepo, lang: resolvedLang, worseThanBefore, fixText, protections, inputs, ticket,
2498
2272
  }) }];
2499
2273
  }
2500
2274
  onPhase('confirm-round', { round });
@@ -2524,13 +2298,30 @@ export async function runConfirmTurn({
2524
2298
  // model's own honest gap list, carried through unchanged.
2525
2299
  // NO SILENT DROP (idea A core, spec 4.5): what the page rules removed is said HERE too, in the same words as the signed plan, before
2526
2300
  // drafting is paid for. The words come from the one table (src/pagedropwords.js).
2301
+ // 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
2302
+ if (goalOnly) r.plan = { ...r.plan, checks: [], notChecked: [], questions: [] };
2527
2303
  const notChecked = [...(r.plan.notChecked ?? [])];
2528
- for (const row of dropRows(facts?.look?.dropped)) { const text = dropLine(row, jobLines, lineRules); if (!notChecked.includes(text)) notChecked.push(text); }
2304
+ const lookRows = dropRows(facts?.look?.dropped).map((row) => ({ row, text: dropLine(row, jobLines, lineRules) }));
2305
+ for (const { text } of lookRows) if (!notChecked.includes(text)) notChecked.push(text);
2306
+ // 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),
2307
+ // 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.
2308
+ const shownNotChecked = () => notChecked.filter((t) => !lookRows.some((l) => l.text === t && l.row.rule !== undefined && block !== null && block.saysRule(l.row.line, l.row.rule)));
2529
2309
  const checkItems = normalizeChecks(r.plan.checks);
2530
2310
  r.plan = { ...r.plan, checks: checkItems.map((c) => c.text), checkItems };
2531
- const plan = { ...r.plan, protections, notChecked, signedFacts: (Array.isArray(facts?.look?.facts) ? facts.look.facts : []).map((/** @type {any} */ f) => String(f?.name)) };
2311
+ // 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
2312
+ const planFor = (/** @type {any} */ c) => ({
2313
+ ...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 } : {}),
2314
+ signedFacts: (Array.isArray(facts?.look?.facts) ? facts.look.facts : []).map((/** @type {any} */ f) => String(f?.name)),
2315
+ ...(block !== null && cardOf !== null ? { suggested: block.suggestedView(), editable: true } : {}),
2316
+ });
2317
+ const plan = planFor(card);
2532
2318
  onPhase('confirm-done', { round, plan });
2533
- const picked = await ask({ kind: 'menu', field: CONFIRM_MENU, plan });
2319
+ // Drop and Add on the confirm card: a row edit through the block (the choice decides), reconciled, then the card is drawn again from the rows. $0: no model call is made here
2320
+ const edit = block !== null && cardOf !== null ? (/** @type {'drop'|'add'} */ op, /** @type {string} */ key) => {
2321
+ const res = block.rowChoice(key, op);
2322
+ return res.ok ? { ok: true, plan: planFor(cardOf()), choices: block.choicesRecord() } : res;
2323
+ } : null;
2324
+ const picked = await ask({ kind: 'menu', field: CONFIRM_MENU, plan, ...(edit ? { edit } : {}) });
2534
2325
  if (picked === null) return abandon(round);
2535
2326
  if (picked === 'start-over') return { ...base(), stop: /** @type {ConfirmStop} */ ('confirm-restart'), rounds: round, cost: book.report() };
2536
2327
 
@@ -2541,7 +2332,7 @@ export async function runConfirmTurn({
2541
2332
  ok: true, stop: null, rounds: round,
2542
2333
  accepted: {
2543
2334
  goal: String(r.plan.goal ?? ''), checks: [...(r.plan.checks ?? [])], checkItems: [...(r.plan.checkItems ?? [])], protections: [...protections],
2544
- lang: resolvedLang, worseThanBefore,
2335
+ lang: resolvedLang, worseThanBefore, ...(goalOnly ? { goalOnly: true } : {}),
2545
2336
  // every question forced above was answered in order, so what's left
2546
2337
  // unresolved is honestly empty — computed FROM questionsFromPlan
2547
2338
  // rather than a hardcoded `[]`, so this stays true if the forcing
@@ -2562,7 +2353,7 @@ export async function runConfirmTurn({
2562
2353
  ok: true, stop: null, rounds: round,
2563
2354
  accepted: {
2564
2355
  goal: redactSecrets(String(typed).trim()), checks: [...(r.plan.checks ?? [])], checkItems: [...(r.plan.checkItems ?? [])], protections: [...protections],
2565
- lang: resolvedLang, worseThanBefore,
2356
+ lang: resolvedLang, worseThanBefore, ...(goalOnly ? { goalOnly: true } : {}),
2566
2357
  openQuestions: questionsFromPlan(r.plan).slice(answeredQuestions.length),
2567
2358
  notChecked: [...notChecked], answeredQuestions,
2568
2359
  },
@@ -2584,7 +2375,7 @@ export async function runConfirmTurn({
2584
2375
  ok: true, stop: null, rounds: round,
2585
2376
  accepted: {
2586
2377
  goal: String(r.plan.goal ?? ''), checks: [...(r.plan.checks ?? [])], checkItems: [...(r.plan.checkItems ?? [])], protections: [...protections],
2587
- lang: resolvedLang, worseThanBefore, openQuestions: [...questionsFromPlan(r.plan), redactedFix], notChecked: [...notChecked],
2378
+ lang: resolvedLang, worseThanBefore, ...(goalOnly ? { goalOnly: true } : {}), openQuestions: [...questionsFromPlan(r.plan), redactedFix], notChecked: [...notChecked],
2588
2379
  },
2589
2380
  reds: [], cost: book.report(),
2590
2381
  };
@@ -2597,22 +2388,6 @@ export async function runConfirmTurn({
2597
2388
  throw new Error('[authorflow] runConfirmTurn fell through its 2-round cap without returning');
2598
2389
  }
2599
2390
 
2600
- /**
2601
- * PRD v1.131 tick 4 (rubric jobs, the LAST try only; the caller gates both): the last try failed the gate, so the AI's own broken parts are dropped to Not checked (`dropExtras`) and the plan
2602
- * is bound and checked ONCE more with the same gate (`redo`). Returns the new settled declaration and its result when that passes; `null` = nothing dropped, the plan is refused as today (the
2603
- * try passed already, a red sits on a part the picks built or on no part, or the re-check is still red).
2604
- * @param {{pre: any, v: {ok: boolean, reds: any[]}, jobLines: any[]|null|undefined, redo: (d: any) => any}} o
2605
- * @returns {{pre: any, v: any}|null}
2606
- */
2607
- export function dropAfterLastTry({ pre, v, jobLines, redo }) {
2608
- if (v.ok) return null;
2609
- const out = dropExtras(pre, v.reds, jobLines);
2610
- if ('refused' in out) return null;
2611
- const next = withFactBindings(out.declaration);
2612
- const again = redo(next);
2613
- return again.ok ? { pre: next, v: again } : null;
2614
- }
2615
-
2616
2391
  /**
2617
2392
  * THE AUTHORING FLOW.
2618
2393
  *
@@ -2659,7 +2434,7 @@ export function dropAfterLastTry({ pre, v, jobLines, redo }) {
2659
2434
  * priorCalls?: {label: string, costUsd: number|null, unpricedRounds: number}[]|null,
2660
2435
  * priorRaws?: any[]|null,
2661
2436
  * jobLines?: {n: number, text: string}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
2662
- * offerQuestions?: boolean, ticket?: boolean, checkPicks?: {rules: {line: number, rule: number, text: string}[], picks: any[], left: {line: number, rule: number}[]}|null,
2437
+ * offerQuestions?: boolean, ticket?: boolean, block?: CheckBlock|null, editGenerate?: Function|null,
2663
2438
  * confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null}} o
2664
2439
  */
2665
2440
  export async function authorClose({
@@ -2704,8 +2479,10 @@ export async function authorClose({
2704
2479
  // MCP + tickets piece 2 (R5): the job reads tickets, so the drafter is told about the ticket filter, the schema offers the optional `ticketFilter` property and a proposal is
2705
2480
  // checked by the one reader (src/ticketfilter.js). ABSENT = every other job: prompt, schema and validation byte-identical.
2706
2481
  ticket = false,
2707
- // R10 (fwd am16): the person's check picks for the `~` rules code settled, `{rules, picks, left, jobLines}`. ABSENT = every other caller: the declaration is validated as drafted.
2708
- checkPicks = null,
2482
+ // the rubric job's CheckBlock (src/checkblock.js), built before the first try: the AI sends row edits, code builds every check and assembles the declaration from the rows. ABSENT = every other caller.
2483
+ block = null,
2484
+ // the row-edit turn's own model boundary (ROW_EDIT_SYSTEM); a test that replaces `generate` need not bring one
2485
+ editGenerate = null,
2709
2486
  }) {
2710
2487
  // PART 1a: the menu this close may draw from — a rubric job on local files sees its own two kinds, a code job never sees
2711
2488
  // the rubric-only ones (`catalogueForLang`). Everything below (prompt, schema, validator, env) reads THIS one catalogue.
@@ -2879,29 +2656,45 @@ export async function authorClose({
2879
2656
  const frozen = await readFrozenInputs(workdir, inputs.map((i) => i.label));
2880
2657
  if (frozen.ok) { inputTexts = frozen.texts; labelLists = labelListsFor(frozen.texts, facts?.look ?? null); }
2881
2658
  }
2882
- // R10: the picks settled against the lines as they stand now (the answers are already `~` rules on them); the draft carries exactly these checks and these Not checked rows
2883
- const settledPicks = checkPicks ? settleRules(checkPicks.rules, checkPicks.picks, checkPicks.left, jobLines ?? []) : null;
2884
- // a rubric job only: what no rule can check goes under Not checked before the picks are applied (every other kind of job keeps its reds)
2885
- // then (rubric only) a one-input job's missing source is filled and a line's several fact parts are merged into one when that is safe, after the picks' count strip
2886
- const picked = (/** @type {any} */ d) => fillAndMergeFacts(applyPicks(moveUncheckable(d, jobLines ?? [], lang === RUBRIC_LANG), settledPicks), inputLabelsOf(inputs), lang === RUBRIC_LANG);
2887
- const prompt = authorPrompt({
2888
- answers, questions, facts, listingBlock: /** @type {string} */ (seeds.block),
2889
- lang, verdictType, guards, ownedEnvNames, mode: structuredMode, catalogue, writeScope, confirmed, jobLines, inputs,
2890
- labelLists, ...(checkPicks ? { settled: checkPicks.rules } : {}),
2891
- }) + (ticket ? `\n\n${ticketFilterBlock()}` : '');
2659
+ // every rubric job drafts through the check block (src/authorjob.js builds it, with the person's answers applied); a caller that brings none (a direct authorClose call) gets the block of the look alone, nobody to ask
2660
+ if (block === null && lang === RUBRIC_LANG && inputTexts !== null && Array.isArray(jobLines)) {
2661
+ block = new CheckBlock({ texts: inputTexts, labels: (inputs ?? []).map((/** @type {any} */ i) => i.label), asks: false });
2662
+ block.fromJob(jobLines);
2663
+ block.addLook(Array.isArray(facts?.look?.facts) ? facts.look.facts : [], Array.isArray(facts?.look?.dropped) ? facts.look.dropped : []);
2664
+ block.reconcile();
2665
+ }
2666
+ /** 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 */
2667
+ const rowEdits = block !== null && lang === RUBRIC_LANG;
2668
+ const draftGenerate = rowEdits && editGenerate ? editGenerate : generate;
2669
+ /** the declaration of a rubric job, assembled by code from the rows: the mandatory guards, then the block's stages (hamr 2026-11-12, ruling 6), the rule rows no check carries as `refused`, the picks code recorded */
2670
+ const assemble = () => {
2671
+ const c = /** @type {CheckBlock} */ (block).reconcile();
2672
+ /** @type {{line: number, rule?: number, reason: string}[]} */
2673
+ const refused = /** @type {CheckBlock} */ (block).rows.filter((r) => r.kind === 'rule' && r.state !== 'built').map((r) => ({ line: r.line, rule: r.rule, reason: String(r.reason ?? 'not checked') }));
2674
+ // a job line no check could be built for (no stage) is refused as a line, in code's plain words, so the draft gate sees it covered and the end check (hasBuiltCheck) can say "no check" in its own words
2675
+ for (const l of jobLines ?? []) if (!c.stages.some((/** @type {any} */ st) => Array.isArray(st.fromLine) && st.fromLine.includes(l.n))) refused.push({ line: l.n, reason: REASON.noRule });
2676
+ const picks = /** @type {CheckBlock} */ (block).picksOf(c);
2677
+ // a guard's one fill slot (`allowPrefixes`) is the signed write fence, the very value the old drafter was told to copy: for a rubric job the run writes only under output/
2678
+ const fence = Array.isArray(writeScope) && writeScope.length ? [...writeScope] : ['output/'];
2679
+ return { stages: [...guards.map((/** @type {any} */ g) => ({ name: g.name, kind: g.kind, params: { ...g.params, ...Object.fromEntries((g.fill ?? []).map((/** @type {string} */ f) => [f, fence])) } })), ...c.stages], ...(refused.length ? { refused } : {}), ...(picks.length ? { picks } : {}) };
2680
+ };
2681
+ const prompt = rowEdits
2682
+ ? rowEditUserText({ jobLines: jobLines ?? [], look: facts?.look ?? null, texts: inputTexts ?? {} }) + (ticket ? `\n\n${ticketFilterBlock()}` : '')
2683
+ : authorPrompt({
2684
+ answers, questions, facts, listingBlock: /** @type {string} */ (seeds.block),
2685
+ lang, verdictType, guards, ownedEnvNames, mode: structuredMode, catalogue, writeScope, confirmed, jobLines, inputs,
2686
+ labelLists,
2687
+ }) + (ticket ? `\n\n${ticketFilterBlock()}` : '');
2892
2688
  // 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
2893
2689
  // 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.
2894
2690
  const checkDraft = (/** @type {any} */ d) => {
2895
- let r = validateDeclaration(d, { catalogue, listing: seedFiles, guards, envOwned: ownedEnvNames, verdictType, writeScope, jobLines, inputLabels: inputLabelsOf(inputs) });
2691
+ let r = validateDeclaration(d, { catalogue, listing: seedFiles, guards, envOwned: ownedEnvNames, verdictType, jobLines, inputLabels: inputLabelsOf(inputs) });
2896
2692
  if (r.ok && lang === RUBRIC_LANG) {
2897
2693
  const words = checkDeclarationWords(r.declaration, inputTexts, facts?.look ?? null);
2898
2694
  if (words.length > 0) r = { ...r, ok: false, reds: [...r.reds, ...words], declaration: null };
2899
2695
  }
2900
2696
  return r;
2901
2697
  };
2902
- // PRD v1.131 tick 7: per try (by call label), the retention counts of a rubric draft; the one that stands is reported once at the end
2903
- /** @type {Map<string, ReturnType<typeof retentionOf>>} */
2904
- const retentions = new Map();
2905
2698
  /** @type {any[]} */
2906
2699
  let messages = [{ role: 'user', content: prompt }];
2907
2700
  /** the drafter's PROPOSED ticket filter of the accepted iteration (a Tickets job only); the person signs it, the spec carries it, the close never does @type {any} */
@@ -2989,7 +2782,10 @@ export async function authorClose({
2989
2782
  // P7 item 5: a mechanism, never a wish. Only the last try of the full ladder carries the property, and only when the
2990
2783
  // two before it both failed (validation or the seed read; `questionLines` is set at the end of the second one, below).
2991
2784
  const askOpen = questionLines !== null && i === revisionCap;
2992
- const ask = await askDeclaration({ messages, generate, mode: structuredMode, retries: retryCap, label, book, catalogue: catalogueIn, kinds: Object.keys(catalogue), verdictType, questions: askOpen, ticket });
2785
+ const ask = rowEdits
2786
+ ? { ...(await askStructured({ messages, generate: draftGenerate, mode: structuredMode, retries: retryCap, label, book, channel: rowEditChannel(ticket) })), declaration: null }
2787
+ : await askDeclaration({ messages, generate, mode: structuredMode, retries: retryCap, label, book, catalogue: catalogueIn, kinds: Object.keys(catalogue), verdictType, questions: askOpen, ticket });
2788
+ if (rowEdits) ask.declaration = ask.artifact;
2993
2789
  messages = ask.convo;
2994
2790
  // `ticketFilter` is never part of the declaration (the close): taken out before validation, checked by its own reader below, and kept beside the declaration
2995
2791
  /** @type {any} */
@@ -3088,16 +2884,26 @@ export async function authorClose({
3088
2884
  }
3089
2885
  previous = { d: ask.declaration, f: proposedFilter ?? null };
3090
2886
 
3091
- // PART 1b: code puts the number tie on every prose step that follows a fact step, before anything is validated or signed
3092
- const settled = withFactBindings(withDropNotes(settlePersonsWords(picked(ask.declaration), jobLines), facts?.look?.dropped, jobLines));
3093
- let pre = settled;
2887
+ // a rubric job: ONE reply of row edits, each judged alone by the block; the declaration is assembled from the rows (a refused edit costs the others nothing)
2888
+ let pre = ask.declaration;
2889
+ /** @type {any[]} */
2890
+ let refusedEdits = [];
2891
+ if (rowEdits) {
2892
+ const rec = /** @type {CheckBlock} */ (block).applyDelta({ label, edits: editsOf(ask.declaration) });
2893
+ refusedEdits = rec.edits.filter((/** @type {any} */ e) => e.accepted !== true);
2894
+ pre = assemble();
2895
+ iter.edits = rec.edits.map((/** @type {any} */ e) => ({ op: e?.op, accepted: e.accepted === true, ...(e.accepted === true ? {} : { refusedBecause: e.refusedBecause }) }));
2896
+ onPhase('draft-ledger-try', { label, kept: rec.edits.length - refusedEdits.length, refused: refusedEdits.map((/** @type {any} */ e) => ({ op: String(e?.op), reason: String(e.refusedBecause) })) });
2897
+ }
3094
2898
  let v = checkDraft(pre);
3095
- // PRD v1.131 tick 4: only after the LAST try of a rubric draft failed, the AI's own broken parts are dropped to Not checked and the plan is checked ONCE more; else the plan is refused as today
3096
- if (!v.ok && lang === RUBRIC_LANG && i === revisionCap) {
3097
- const dropped = dropAfterLastTry({ pre, v, jobLines, redo: checkDraft });
3098
- if (dropped) { pre = dropped.pre; v = dropped.v; }
2899
+ // a gate red on the code-built declaration is OUR bug (hamr 2026-11-12, ruling 3): the plan stops in plain words, the AI is never asked to fix it
2900
+ if (rowEdits && !v.ok) {
2901
+ fatal = [{ code: 'plan-red', path: 'closeDecl', detail: `The plan code built from your checks did not pass its own gate (${v.reds.slice(0, 2).map((/** @type {Red} */ r) => `${r.code} at ${r.path || '(root)'}: ${r.detail}`).join('; ')}). That is a fault in the build, not in your job: nothing was spent on a close.` }];
2902
+ stop = 'plan-red';
2903
+ iter.validation = { ok: false, reds: v.reds.map(scrubRed), scoped: v.scoped };
2904
+ lastValidation = { ok: false, reds: v.reds.map(scrubRed) };
2905
+ break;
3099
2906
  }
3100
- if (lang === RUBRIC_LANG) retentions.set(label, retentionOf(ask.declaration, pre, jobLines));
3101
2907
  // MCP + tickets piece 2: a proposed ticket filter is read by the ONE reader (src/ticketfilter.js); its reds carry a legal example and go back to the drafter like any red
3102
2908
  if (v.ok && ticket && proposedFilter !== undefined) {
3103
2909
  const fr = ticketFilterReds(proposedFilter);
@@ -3118,6 +2924,7 @@ export async function authorClose({
3118
2924
 
3119
2925
  /** @type {string} */
3120
2926
  let measured;
2927
+ let seedFailed = false;
3121
2928
  if (!v.ok) {
3122
2929
  // a validation red IS a measurement of the declaration, so it rides the
3123
2930
  // same channel and counts as a revision (addendum 5)
@@ -3156,6 +2963,7 @@ export async function authorClose({
3156
2963
  measuredIterations.push({ label, declaration: injected.declaration, seedRead: rows, droppedEnv: injected.dropped });
3157
2964
  const sf = seedReadFailure(rows, injected.declaration, guards.map((/** @type {any} */ g) => g.name), (jobLines ?? []).map((l) => l.n));
3158
2965
  tryFails[i] = sf.failed ? { lines: sf.lines } : null;
2966
+ seedFailed = sf.failed;
3159
2967
  if (sf.failed) {
3160
2968
  const guardNames = guards.map((/** @type {any} */ g) => g.name);
3161
2969
  const stoppedNames = [...new Set(rows.filter((/** @type {any} */ r) => !guardNames.includes(r?.stage) && r?.verdict === 'instrument-stop').map((/** @type {any} */ r) => String(r.stage)))];
@@ -3168,6 +2976,8 @@ export async function authorClose({
3168
2976
  }
3169
2977
  }
3170
2978
 
2979
+ // hamr 2026-11-12 (ruling 3): a rubric job revises only when the last reply had refused edits OR the seed read failed; else the plan stands
2980
+ if (rowEdits && v.ok && refusedEdits.length === 0 && !seedFailed) { stop = 'settled'; break; }
3171
2981
  if (i === revisionCap) { stop = 'max-revisions'; break; }
3172
2982
 
3173
2983
  // P7 item 5: the NEXT try is the last of a full ladder, and this one AND the first both FAILED — either failed validation
@@ -3178,6 +2988,16 @@ export async function authorClose({
3178
2988
  questionLines = second && second.lines.length ? second.lines : null;
3179
2989
  }
3180
2990
 
2991
+ if (rowEdits) {
2992
+ // the revise turn carries each refused edit's own reason, and the seed read when it failed, and nothing else
2993
+ const blocks = [];
2994
+ if (refusedEdits.length) blocks.push(renderRejectBlock({ kind: 'edits', reds: refusedEdits.map((/** @type {any} */ e) => `edit ${String(e?.op)}: ${String(e.refusedBecause)}`) }));
2995
+ blocks.push(v.ok ? (seedFailed ? measured : '') : measured);
2996
+ const editTurn = `${blocks.filter(Boolean).join('\n\n')}\n\n${ROW_EDIT_REVISE}`;
2997
+ iter.reviseTurn = { bytes: Buffer.byteLength(editTurn) };
2998
+ messages = [...messages, { role: 'assistant', content: ask.raw.trim() || '(the reply carried no text)' }, { role: 'user', content: editTurn }];
2999
+ continue;
3000
+ }
3181
3001
  const turn = buildReviseTurn(measured);
3182
3002
  // A TRIPWIRE, not behaviour: it can only fire once something else is
3183
3003
  // already broken, so it is the one guard in this module the mutation
@@ -3210,7 +3030,7 @@ export async function authorClose({
3210
3030
  // it by reading only `declaration`/`seedRead`/`finalFrom`.
3211
3031
  /** @type {{from: string, to: string, brokenStages: string[]}|null} */
3212
3032
  let fellBack = null;
3213
- if (measuredIterations.length) {
3033
+ if (measuredIterations.length && !rowEdits) {
3214
3034
  const last = measuredIterations[measuredIterations.length - 1];
3215
3035
  if (!isSoundMeasurement(last.seedRead)) {
3216
3036
  for (let k = measuredIterations.length - 2; k >= 0; k -= 1) {
@@ -3231,9 +3051,11 @@ export async function authorClose({
3231
3051
  }
3232
3052
  }
3233
3053
 
3234
- // PRD v1.131 tick 7: ONE retention record when a rubric draft ends (accepted or stopped), counts only; the panel writes it into the drafting log
3235
- const standing = fellBack ? retentions.get(fellBack.to) : [...retentions.values()].at(-1);
3236
- if (standing) onPhase('draft-retention', { lines: standing });
3054
+ // PRD v1.131 tick 7: ONE retention record when a rubric draft ends (accepted or stopped), counts only; the panel writes it into the drafting log. Read from the block's rows.
3055
+ if (rowEdits) {
3056
+ onPhase('draft-retention', { lines: /** @type {CheckBlock} */ (block).retention() });
3057
+ onPhase('draft-ledger', { rows: ledgerRecord(/** @type {any} */ (block).rows) });
3058
+ }
3237
3059
 
3238
3060
  const reds = fatal.length ? fatal : (lastValidation && !lastValidation.ok ? lastValidation.reds : []);
3239
3061
  return {
@@ -3267,6 +3089,8 @@ export async function authorClose({
3267
3089
  stop,
3268
3090
  // P7 item 5: what the person is asked (empty on every other stop)
3269
3091
  questions: stop === 'questions-open' ? askedQuestions : [],
3092
+ // the one check list's final rows against the declaration that stands (the signed close carries them as `closeDecl.list`); null = no list
3093
+ ledger: rowEdits && accepted !== null ? /** @type {CheckBlock} */ (block).signedRows() : null,
3270
3094
  revisions: Math.max(0, iterations.length - 1),
3271
3095
  };
3272
3096
  }