bareloop 0.55.0 → 0.56.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 (56) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/bareloop.context.md +4 -2
  3. package/package.json +2 -2
  4. package/src/authorflow.js +141 -264
  5. package/src/authoring.js +2 -3
  6. package/src/authorjob.js +117 -88
  7. package/src/authorreadout.js +9 -15
  8. package/src/authorrun.js +13 -4
  9. package/src/behaviour.js +14 -0
  10. package/src/blockasks.js +43 -0
  11. package/src/checkblock.js +772 -0
  12. package/src/checklist.js +128 -0
  13. package/src/checkpick.js +30 -312
  14. package/src/checkwords.js +3 -1
  15. package/src/declaredclose.js +30 -1
  16. package/src/destpoint.js +3 -1
  17. package/src/draftspend.js +46 -0
  18. package/src/facts.js +8 -1
  19. package/src/fitcheck.js +5 -3
  20. package/src/pagemap.js +15 -3
  21. package/src/panel/authorroutes.js +15 -3
  22. package/src/panel/authorsession.js +133 -46
  23. package/src/panel/index.html +194 -22
  24. package/src/panel/jobplan.js +85 -33
  25. package/src/panel/server.js +52 -7
  26. package/src/pickrecord.js +19 -1
  27. package/src/placerule.js +355 -0
  28. package/src/promptregisters.js +11 -0
  29. package/src/questionbox.js +112 -0
  30. package/src/rowedit.js +115 -0
  31. package/src/rubricstep.js +212 -125
  32. package/src/run.js +10 -2
  33. package/src/userrun.js +46 -1
  34. package/types/authorflow.d.ts +32 -139
  35. package/types/authorjob.d.ts +24 -6
  36. package/types/authorreadout.d.ts +4 -10
  37. package/types/behaviour.d.ts +12 -0
  38. package/types/blockasks.d.ts +37 -0
  39. package/types/checkblock.d.ts +361 -0
  40. package/types/checklist.d.ts +134 -0
  41. package/types/checkpick.d.ts +3 -140
  42. package/types/declaredclose.d.ts +4 -0
  43. package/types/destpoint.d.ts +2 -0
  44. package/types/draftspend.d.ts +21 -0
  45. package/types/fitcheck.d.ts +7 -1
  46. package/types/pagemap.d.ts +4 -0
  47. package/types/panel/authorsession.d.ts +13 -2
  48. package/types/panel/jobgrid.d.ts +8 -8
  49. package/types/panel/jobplan.d.ts +48 -10
  50. package/types/panel/server.d.ts +14 -13
  51. package/types/pickrecord.d.ts +12 -0
  52. package/types/placerule.d.ts +194 -0
  53. package/types/questionbox.d.ts +87 -0
  54. package/types/rowedit.d.ts +32 -0
  55. package/types/rubricstep.d.ts +91 -48
  56. package/types/run.d.ts +10 -1
package/src/userrun.js CHANGED
@@ -41,6 +41,8 @@ import { skipWords } from './panel/status.js';
41
41
  import { checkoutPrHead, prHeadIsAncestor, recordPrOnManifest } from './prcheckout.js';
42
42
  import { readShimArm } from './readshim.js';
43
43
  import { closeStagesOf } from './plan.js';
44
+ import { placeFactsOf, readPlaceRules, valueInWords, stopWords, lastPlaceRead, placeValuesOfEvents, bindPlaceValues, NO_PLACE_RECORD_WORDS } from './placerule.js';
45
+ import { readFrozenInputs } from './rubricstep.js';
44
46
  import { resolveCloseTimeoutMs } from './closetimeout.js';
45
47
  import { makeSpine } from './spine.js';
46
48
  // PRD item 33/M2 — the source front door. `readSourceManifest` finds the
@@ -1259,6 +1261,8 @@ async function execute(ctx) {
1259
1261
  // budget — money folds on every path, time does not.
1260
1262
  /** @type {{text: string, fromRunid: string, receivedAt: string}|null} */
1261
1263
  let DOOR_RERUN = null;
1264
+ /** @type {Record<string, string>|null} PLACE RULES: a door rerun's values, taken from the answered run's own record (it re-reads nothing) */
1265
+ let DOOR_PLACE_VALUES = null;
1262
1266
  if (doorSpineFile !== null) {
1263
1267
  if (RULING === null) {
1264
1268
  err('NO DECISION — this run is standing at its review door and no decision was given.');
@@ -1267,6 +1271,20 @@ async function execute(ctx) {
1267
1271
  throw new ExitSignal(2);
1268
1272
  }
1269
1273
  const answeredAt = new Date().toISOString();
1274
+ // PLACE RULES: an accept's re-proof and a rerun (which re-reads nothing: no refreeze at the door) use the values THIS run read, from its own `place-rules`
1275
+ // record (what a resume rebinds); never the signed drafting words, never a new read. No record = refused in plain words. The signed spec is not touched.
1276
+ /** @type {any} */
1277
+ let doorSpec = spec;
1278
+ if (RULING.decision !== 'pause' && placeFactsOf(spec).length > 0) {
1279
+ const doorPlaceValues = placeValuesOfEvents(doorEvents ?? []);
1280
+ if (doorPlaceValues === null) {
1281
+ err(`DOOR REFUSED (${RULING.decision}) — nothing was recorded and nothing was released.`);
1282
+ err(NO_PLACE_RECORD_WORDS);
1283
+ throw new ExitSignal(2);
1284
+ }
1285
+ doorSpec = bindPlaceValues(spec, doorPlaceValues);
1286
+ if (RULING.decision === 'rerun') DOOR_PLACE_VALUES = doorPlaceValues;
1287
+ }
1270
1288
  // PRD item 27/M3 — the door's mechanical re-run needs the same effective
1271
1289
  // ceiling the run itself would use; resolved through the identical
1272
1290
  // function (`resolveCloseTimeoutMs`), never a second guess. Paid only on
@@ -1295,7 +1313,7 @@ async function execute(ctx) {
1295
1313
  // `timedOut: true`, already handled above.
1296
1314
  if (doorCloseTiming.closeTimeoutMs === null) throw new Error('unreachable: resolveCloseTimeoutMs sets closeTimeoutMs whenever timedOut is false');
1297
1315
  const ans = await answerReviewDoor({
1298
- job: spec,
1316
+ job: doorSpec,
1299
1317
  workdir: wd,
1300
1318
  events: doorEvents ?? [],
1301
1319
  decision: RULING.decision,
@@ -1653,6 +1671,12 @@ async function execute(ctx) {
1653
1671
  throw new ExitSignal(2);
1654
1672
  }
1655
1673
 
1674
+ /** @type {Record<string, string>|null} PLACE RULES: the values the run start read for the spec's place-rule facts (key to value), handed to `runJob`; null = none */
1675
+ let placeValues = DOOR_PLACE_VALUES;
1676
+ /** @type {{workflowKey: string, rows: object[]}|null} PLACE RULES: the record the spine keeps of that read; null on a resume (its first leg wrote it) */
1677
+ let placeRead = null;
1678
+ // a RESUME does not re-read: it rebinds the values its own first leg recorded, so the close grades on the words the run started with
1679
+ if (dead) placeValues = placeValuesOfEvents(deadAllEvents);
1656
1680
  // RUN START REFETCH (PART 1c RF22; moved here 2026-10-19, run mvez8s54: the ~18 s barebrowse fetch ran in main() BEFORE this run was
1657
1681
  // listed, so Sign & run showed nothing for 18 s). The run is listed FIRST (row above, with its pid and cap = the monthly claim), THEN
1658
1682
  // fetches: the Run tab reads "fetching the page…" while source.json has no refrozenAt at or after the row. A refusal cannot be a
@@ -1709,6 +1733,25 @@ async function execute(ctx) {
1709
1733
  throw new ExitSignal(2);
1710
1734
  }
1711
1735
  if (fresh.refreshed.length > 0 && typeof fresh.seed === 'string' && fresh.seed) SEED = fresh.seed;
1736
+ // PLACE RULES: every place-rule fact of the signed spec is read, by CODE, from this run's own copy of its input (the copy the refetch above just froze); the values are
1737
+ // bound as those facts' phrases on the run's in-memory copy inside `runJob`, after the approval check, and are never written to the signed spec. Any rule not found
1738
+ // stops the run here, before any provider call.
1739
+ const placeFacts = placeFactsOf(spec);
1740
+ if (placeFacts.length > 0) {
1741
+ const frozen = await readFrozenInputs(join(ctx.into, 'tree'), [...new Set(placeFacts.map((f) => f.source))]);
1742
+ // "last read": the newest earlier run of this workflow's own record, else the drafting words
1743
+ let earlier = {};
1744
+ if (cfgOn) { try { earlier = lastPlaceRead({ rows: readRunList({ home: cfgHome }).rows, job: spec.job, workflowKey: workflowKey(spec), runid }); } catch { /* no earlier record is the drafting words */ } }
1745
+ const read = readPlaceRules(placeFacts.map((fact) => ({ fact, text: frozen.ok ? (frozen.texts[fact.source] ?? null) : null, was: /** @type {Record<string, string>} */ (earlier)[fact.key] ?? valueInWords(fact.place, fact.phrase) })));
1746
+ if (!read.proceed) {
1747
+ const words = stopWords(read.rows);
1748
+ err(`${SELECTOR}: ${words}`);
1749
+ settleRefused(words);
1750
+ throw new ExitSignal(2);
1751
+ }
1752
+ placeValues = read.values;
1753
+ placeRead = { workflowKey: workflowKey(spec), rows: read.rows.map(({ name: _n, ...r }) => r) };
1754
+ }
1712
1755
  }
1713
1756
 
1714
1757
  const git = (/** @type {string[]} */ a) => execFileSync('git', ['-C', wd, ...a], { encoding: 'utf8' }).trim();
@@ -2023,6 +2066,8 @@ async function execute(ctx) {
2023
2066
  try {
2024
2067
  outcome = await runJob(spec, {
2025
2068
  stopFile,
2069
+ ...(placeValues === null ? {} : { placeValues }),
2070
+ ...(placeRead === null ? {} : { placeRead }),
2026
2071
  ...(ticketRecord === null ? {} : { ticketRecord }),
2027
2072
  ...(ticketUnsure === null ? {} : { ticketUnsure }),
2028
2073
  ...(prRecord === null ? {} : { prRecord }),
@@ -519,8 +519,7 @@ export function writeScopeBlock(writeScope: string[]): string;
519
519
  * meaning from `openQuestions` (which means "could not resolve"): the two
520
520
  * never merge.
521
521
  * @param {{checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[],
522
- * answeredQuestions?: string[]}} confirmed
523
- * @param {{numbered?: boolean}} [o] `numbered` (a rubric job on files): each confirmed check carries its `#n`, which a part cites in `covers`
522
+ * answeredQuestions?: string[], goalOnly?: boolean}} confirmed
524
523
  */
525
524
  export function confirmedBlock(confirmed: {
526
525
  checks: string[];
@@ -532,8 +531,7 @@ export function confirmedBlock(confirmed: {
532
531
  openQuestions?: string[];
533
532
  notChecked?: string[];
534
533
  answeredQuestions?: string[];
535
- }, { numbered }?: {
536
- numbered?: boolean;
534
+ goalOnly?: boolean;
537
535
  }): string;
538
536
  /**
539
537
  * P7: the job-line tagging order (model-facing, registered). Rule 1 of the job block: every stage the drafter writes
@@ -567,10 +565,10 @@ export function jobLineTagBlock(count: number, guardNames?: string[]): string;
567
565
  * writeScope?: string[]|null,
568
566
  * jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
569
567
  * confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null,
570
- * labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
568
+ * labelLists?: string[]|null,
571
569
  * }} o
572
570
  */
573
- export function authorPrompt({ answers, questions, facts, listingBlock, lang, verdictType, guards, ownedEnvNames, mode, catalogue: catalogueIn, writeScope, jobLines, inputs, confirmed, labelLists, settled, }: {
571
+ export function authorPrompt({ answers, questions, facts, listingBlock, lang, verdictType, guards, ownedEnvNames, mode, catalogue: catalogueIn, writeScope, jobLines, inputs, confirmed, labelLists, }: {
574
572
  answers: Record<string | number, string>;
575
573
  questions?: Record<string | number, string>;
576
574
  facts: any;
@@ -607,64 +605,6 @@ export function authorPrompt({ answers, questions, facts, listingBlock, lang, ve
607
605
  answeredQuestions?: string[];
608
606
  } | null;
609
607
  labelLists?: string[] | null;
610
- settled?: {
611
- line: number;
612
- rule: number;
613
- text: string;
614
- }[] | null;
615
- }): string;
616
- /**
617
- * 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
618
- * "refused": code puts the picked check, or the Not checked row, on the stage itself.
619
- * @param {{line: number, rule: number, text: string}[]} settled @returns {string}
620
- */
621
- export function settledBlock(settled: {
622
- line: number;
623
- rule: number;
624
- text: string;
625
- }[]): string;
626
- /**
627
- * The composer prompt for a rubric job on local files (Part 1a, docs/product/ITEM33-BUILD.md). There is no repository
628
- * and no survey: the facts are the numbered inputs and the listing is the frozen tree (input/ files, output/). It states
629
- * the step-file contract the worker is also told ({@link stepFileContract}), so the stage and the file cannot drift.
630
- * @param {{answers: Record<string|number, string>, questions?: Record<string|number, string>, facts: any, listingBlock: string,
631
- * verdictType: string, guards: {name: string, kind: string, params: Record<string, any>, fill: string[]}[],
632
- * mode?: 'tool'|'text', catalogue?: Record<string, any>, writeScope?: string[]|null,
633
- * jobLines?: {n: number}[]|null, inputs?: {n: number, label: string, value: string}[]|null, confirmed?: any,
634
- * labelLists?: string[]|null, settled?: {line: number, rule: number, text: string}[]|null,
635
- * }} o
636
- * @returns {string}
637
- */
638
- export function rubricAuthorPrompt({ answers, questions, facts, listingBlock, verdictType, guards, mode, catalogue, writeScope, jobLines, inputs, confirmed, labelLists, settled, }: {
639
- answers: Record<string | number, string>;
640
- questions?: Record<string | number, string>;
641
- facts: any;
642
- listingBlock: string;
643
- verdictType: string;
644
- guards: {
645
- name: string;
646
- kind: string;
647
- params: Record<string, any>;
648
- fill: string[];
649
- }[];
650
- mode?: "tool" | "text";
651
- catalogue?: Record<string, any>;
652
- writeScope?: string[] | null;
653
- jobLines?: {
654
- n: number;
655
- }[] | null;
656
- inputs?: {
657
- n: number;
658
- label: string;
659
- value: string;
660
- }[] | null;
661
- confirmed?: any;
662
- labelLists?: string[] | null;
663
- settled?: {
664
- line: number;
665
- rule: number;
666
- text: string;
667
- }[] | null;
668
608
  }): string;
669
609
  /**
670
610
  * The seed read, as the model sees it: mechanical labels, no editorial. Per-stage
@@ -698,10 +638,10 @@ export function renderSeedReadBlock(rows: any[], { gapCap }?: {
698
638
  * a credential crossed unmasked before this line existed. Applied to the whole
699
639
  * rendered block rather than one field, so a red added to the validator is
700
640
  * scrubbed by construction rather than by remembering.
701
- * @param {{kind: 'validation'|'artifact', reds: (Red|string)[], cap?: number}} o
641
+ * @param {{kind: 'validation'|'artifact'|'edits', reds: (Red|string)[], cap?: number}} o
702
642
  */
703
643
  export function renderRejectBlock({ kind, reds, cap }: {
704
- kind: "validation" | "artifact";
644
+ kind: "validation" | "artifact" | "edits";
705
645
  reds: (Red | string)[];
706
646
  cap?: number;
707
647
  }): string;
@@ -980,10 +920,9 @@ export function confirmTool(box: {
980
920
  * @param {{answers: Record<string|number, string>, questions: Record<string|number, string>,
981
921
  * labels?: Record<string|number, string>, facts?: any, listing?: string|null,
982
922
  * writeScope?: string[]|null, isRepo: boolean, lang: string, worseThanBefore?: string,
983
- * fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean,
984
- * settled?: {line: number, rule: number, text: string}[]|null}} o
923
+ * fixText?: string|null, protections?: string[], inputs?: {n: number, label: string, value: string}[]|null, ticket?: boolean}} o
985
924
  */
986
- export function confirmPrompt({ answers, questions, labels, facts, listing, writeScope, isRepo, lang, worseThanBefore, fixText, protections, inputs, ticket, settled }: {
925
+ export function confirmPrompt({ answers, questions, labels, facts, listing, writeScope, isRepo, lang, worseThanBefore, fixText, protections, inputs, ticket }: {
987
926
  answers: Record<string | number, string>;
988
927
  questions: Record<string | number, string>;
989
928
  labels?: Record<string | number, string>;
@@ -1001,11 +940,6 @@ export function confirmPrompt({ answers, questions, labels, facts, listing, writ
1001
940
  value: string;
1002
941
  }[] | null;
1003
942
  ticket?: boolean;
1004
- settled?: {
1005
- line: number;
1006
- rule: number;
1007
- text: string;
1008
- }[] | null;
1009
943
  }): string;
1010
944
  /**
1011
945
  * THE CONFIRM TURN: the $0 half (worse-than-before for a repo, a language
@@ -1030,7 +964,7 @@ export function confirmPrompt({ answers, questions, labels, facts, listing, writ
1030
964
  * ask: (step: {kind: string, [k: string]: any}) => Promise<string|null>,
1031
965
  * onPhase?: (phase: string, data?: any) => void, mode?: 'tool'|'text',
1032
966
  * worseThanBefore?: string, inputs?: {n: number, label: string, value: string}[]|null,
1033
- * jobLines?: {n: number}[]|null, ticket?: boolean, settled?: {line: number, rule: number, text: string}[]|null}} o retired field (hamr's ruling 2026-09-28):
967
+ * 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):
1034
968
  * `worseThanBefore` is never asked any more and defaults to `''` — a
1035
969
  * caller may still pass a string through (kept for a future, non-ask
1036
970
  * source of the same constraint), it just never comes from an ask() step.
@@ -1041,7 +975,7 @@ export function confirmPrompt({ answers, questions, labels, facts, listing, writ
1041
975
  * worseThanBefore: string, openQuestions: string[], notChecked: string[], answeredQuestions?: string[]}|null,
1042
976
  * reds: Red[], cost: any}>}
1043
977
  */
1044
- export function runConfirmTurn({ verdictType, answers, questions, labels, facts, listing, writeScope, isRepo, lang, generate, book, ask, onPhase, mode, worseThanBefore: presetWorseThanBefore, inputs, jobLines, ticket, settled, }: {
978
+ export function runConfirmTurn({ verdictType, answers, questions, labels, facts, listing, writeScope, isRepo, lang, generate, book, ask, onPhase, mode, worseThanBefore: presetWorseThanBefore, inputs, jobLines, ticket, card, block, cardOf, }: {
1045
979
  verdictType: string;
1046
980
  answers: Record<string | number, string>;
1047
981
  questions: Record<string | number, string>;
@@ -1073,11 +1007,18 @@ export function runConfirmTurn({ verdictType, answers, questions, labels, facts,
1073
1007
  n: number;
1074
1008
  }[] | null;
1075
1009
  ticket?: boolean;
1076
- settled?: {
1077
- line: number;
1078
- rule: number;
1079
- text: string;
1080
- }[] | null;
1010
+ card?: {
1011
+ checkItems: {
1012
+ text: string;
1013
+ fromLine: number[];
1014
+ by: "agent" | "you" | "default";
1015
+ key?: string;
1016
+ }[];
1017
+ notChecked: string[];
1018
+ notCheckedBy?: Record<string, string>;
1019
+ } | null;
1020
+ block?: CheckBlock | null;
1021
+ cardOf?: (() => any) | null;
1081
1022
  }): Promise<{
1082
1023
  ok: boolean;
1083
1024
  stop: null | "cap-halt" | "pricing-red" | "provider-red" | "artifact-red" | "confirm-abandoned" | "confirm-restart";
@@ -1099,25 +1040,6 @@ export function runConfirmTurn({ verdictType, answers, questions, labels, facts,
1099
1040
  reds: Red[];
1100
1041
  cost: any;
1101
1042
  }>;
1102
- /**
1103
- * 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
1104
- * 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
1105
- * try passed already, a red sits on a part the picks built or on no part, or the re-check is still red).
1106
- * @param {{pre: any, v: {ok: boolean, reds: any[]}, jobLines: any[]|null|undefined, redo: (d: any) => any}} o
1107
- * @returns {{pre: any, v: any}|null}
1108
- */
1109
- export function dropAfterLastTry({ pre, v, jobLines, redo }: {
1110
- pre: any;
1111
- v: {
1112
- ok: boolean;
1113
- reds: any[];
1114
- };
1115
- jobLines: any[] | null | undefined;
1116
- redo: (d: any) => any;
1117
- }): {
1118
- pre: any;
1119
- v: any;
1120
- } | null;
1121
1043
  /**
1122
1044
  * THE AUTHORING FLOW.
1123
1045
  *
@@ -1164,10 +1086,10 @@ export function dropAfterLastTry({ pre, v, jobLines, redo }: {
1164
1086
  * priorCalls?: {label: string, costUsd: number|null, unpricedRounds: number}[]|null,
1165
1087
  * priorRaws?: any[]|null,
1166
1088
  * jobLines?: {n: number, text: string}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
1167
- * offerQuestions?: boolean, ticket?: boolean, checkPicks?: {rules: {line: number, rule: number, text: string}[], picks: any[], left: {line: number, rule: number}[]}|null,
1089
+ * offerQuestions?: boolean, ticket?: boolean, block?: CheckBlock|null, editGenerate?: Function|null,
1168
1090
  * confirmed?: {checks: string[], checkItems?: {text: string, fromLine: number[]|null}[], protections: string[], openQuestions?: string[], notChecked?: string[], answeredQuestions?: string[]}|null}} o
1169
1091
  */
1170
- export function authorClose({ workdir, seedRef, lang, verdictType, answers, questions, writeScope, scout, listing, priorCalls, priorRaws, confirmed, jobLines, inputs, generate, seedReadFn, closeCtx, ceilingUsd, onPhase, onCall, maxRevisions, structureRetries, structuredMode, catalogue: catalogueIn, offerQuestions, ticket, checkPicks, }: {
1092
+ export function authorClose({ workdir, seedRef, lang, verdictType, answers, questions, writeScope, scout, listing, priorCalls, priorRaws, confirmed, jobLines, inputs, generate, seedReadFn, closeCtx, ceilingUsd, onPhase, onCall, maxRevisions, structureRetries, structuredMode, catalogue: catalogueIn, offerQuestions, ticket, block, editGenerate, }: {
1171
1093
  workdir: string;
1172
1094
  seedRef: string;
1173
1095
  lang: string;
@@ -1222,18 +1144,8 @@ export function authorClose({ workdir, seedRef, lang, verdictType, answers, ques
1222
1144
  }[] | null;
1223
1145
  offerQuestions?: boolean;
1224
1146
  ticket?: boolean;
1225
- checkPicks?: {
1226
- rules: {
1227
- line: number;
1228
- rule: number;
1229
- text: string;
1230
- }[];
1231
- picks: any[];
1232
- left: {
1233
- line: number;
1234
- rule: number;
1235
- }[];
1236
- } | null;
1147
+ block?: CheckBlock | null;
1148
+ editGenerate?: Function | null;
1237
1149
  confirmed?: {
1238
1150
  checks: string[];
1239
1151
  checkItems?: {
@@ -1799,16 +1711,6 @@ export const PARAM_SCHEMAS: Readonly<{
1799
1711
  };
1800
1712
  description: string;
1801
1713
  };
1802
- covers: {
1803
- type: string;
1804
- minItems: number;
1805
- uniqueItems: boolean;
1806
- items: {
1807
- type: string;
1808
- minimum: number;
1809
- };
1810
- description: string;
1811
- };
1812
1714
  rules: {
1813
1715
  type: string;
1814
1716
  minItems: number;
@@ -1961,18 +1863,6 @@ export const PARAM_SCHEMAS: Readonly<{
1961
1863
  * about KINDS: every part of a job line is counted or checked against a quote, because nothing in this build judges.
1962
1864
  */
1963
1865
  export const RUBRIC_FILES_STATEMENT: string;
1964
- /**
1965
- * 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
1966
- * into checks. The confirm note ({@link RUBRIC_CONFIRM_NOTE}) and the composer brief ({@link REQUIRED_FACTS_BRIEF}) interpolate THIS
1967
- * constant, so the two cannot drift (in smv6k6l8dxkzs the confirm step planned a limit the drafter then could not carry, and the
1968
- * drafter added an airport code the person never wrote). Field-neutral: neither turn needs the other's field names.
1969
- */
1970
- export const RUBRIC_RULES: string;
1971
- /**
1972
- * 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
1973
- * schema; this is the judgement the schema cannot carry: what becomes a fact, where its words come from, and what is Not checked.
1974
- */
1975
- export const REQUIRED_FACTS_BRIEF: string;
1976
1866
  export const CONFIRM_TOOL_NAME: "confirm_plan";
1977
1867
  /** Acknowledgement text the confirm tool's `execute` returns — mirrors
1978
1868
  * {@link DECLARATION_ACK}'s role: an output channel that records and
@@ -1991,12 +1881,14 @@ export const CONFIRM_STRUCTURE_INSTRUCTION: string;
1991
1881
  * {@link CLASS_STATEMENTS} already use, rather than a code matcher over prose.
1992
1882
  */
1993
1883
  /**
1994
- * What the confirm turn tells the model about a rubric job on local text files (model-facing, registered). There is no
1995
- * repository and no judge: a check is a limit a machine counts (words, lines, sections), or a claim a quote from a named
1996
- * input must back. Everything else the person asked for is named in `notChecked`, in their words.
1884
+ * 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
1885
+ * (`src/checklist.js`), made before the draft, never this turn's.
1997
1886
  */
1998
1887
  export const RUBRIC_CONFIRM_NOTE: string;
1999
1888
  export const CONFIRM_SYSTEM: string;
1889
+ /** the confirm turn's system prompt for a rubric job (model-facing, registered): a one-sentence goal, no check of its own */
1890
+ export const CONFIRM_GOAL_SYSTEM: string;
1891
+ export function confirmSystemFor(lang: string): string;
2000
1892
  export type Red = {
2001
1893
  code: string;
2002
1894
  path: string;
@@ -2004,3 +1896,4 @@ export type Red = {
2004
1896
  [k: string]: any;
2005
1897
  };
2006
1898
  import { scrubRaw } from './text.js';
1899
+ import { CheckBlock } from './checkblock.js';
@@ -92,16 +92,16 @@ export function refuseLockedKind(kind: string): Refusal;
92
92
  * authorFn?: Function, authorOpts?: object, writeScope?: string[]|null,
93
93
  * signerFix?: Function|any, proposeFn?: Function, compileOpts?: object,
94
94
  * ask?: ((step: {kind: string, [k: string]: any}) => Promise<string|null>)|null,
95
- * answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
96
- * Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[], picks?: any[]}|null>)|null,
97
- * pickGenerate?: Function|null, carriedPicks?: any[]|null, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
95
+ * answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string, key?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
96
+ * Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[], picks?: any[], choices?: {key: string, choice: string, text?: string}[]}|null>)|null,
97
+ * pickGenerate?: Function|null, ledgerGenerate?: Function|null, editGenerate?: Function|null, carriedPicks?: any[]|null, carriedChoices?: any[]|null, onChoices?: (rec: any[]) => void, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
98
98
  * confirmGenerate?: Function|null, isRepo?: boolean,
99
99
  * langResult?: {kind: string, candidates?: string[], [k: string]: any}|null}} o
100
100
  * @returns {Promise<{ok: boolean, refusal: Refusal|null, verdictType: string|null,
101
101
  * closeDecl: any, seedRef: string|null, authoring: any, judged: any, reds: Red[],
102
- * stop: string|null, cost: any, interview: any, confirmed: any, checkPicks?: any}>}
102
+ * stop: string|null, cost: any, interview: any, confirmed: any, picked?: {line: number, text: string}[], hasBuiltCheck?: boolean, notBuilt?: {line: number, text: string}[]}>}
103
103
  */
104
- export function authorCloseForJob({ answers, repoPath, lang, verdictType, questions, jobLines, inputs, generate, provider, seedRef, scout, listing, ceilingUsd, rates, draftThinking, writeScope, judgeModel, onPhase, onCall, seedFn, scoutFn, listingFn, lookFn, fitFn, fitAsk, onFit, authorFn, authorOpts, pickGenerate, carriedPicks, onPicks, signerFix, proposeFn, compileOpts, ask, confirmGenerate, isRepo, langResult, answerQuestions, }: {
104
+ export function authorCloseForJob({ answers, repoPath, lang, verdictType, questions, jobLines, inputs, generate, provider, seedRef, scout, listing, ceilingUsd, rates, draftThinking, writeScope, judgeModel, onPhase, onCall, seedFn, scoutFn, listingFn, lookFn, fitFn, fitAsk, onFit, authorFn, authorOpts, pickGenerate, ledgerGenerate, editGenerate, carriedPicks, onPicks, carriedChoices, onChoices, signerFix, proposeFn, compileOpts, ask, confirmGenerate, isRepo, langResult, answerQuestions, }: {
105
105
  answers: Record<string | number, any>;
106
106
  repoPath?: string | null;
107
107
  lang: string;
@@ -164,6 +164,7 @@ export function authorCloseForJob({ answers, repoPath, lang, verdictType, questi
164
164
  source?: string;
165
165
  ask?: string;
166
166
  reading?: string;
167
+ key?: string;
167
168
  }[];
168
169
  dropped: {
169
170
  reason: string;
@@ -182,9 +183,18 @@ export function authorCloseForJob({ answers, repoPath, lang, verdictType, questi
182
183
  rule: number;
183
184
  }[];
184
185
  picks?: any[];
186
+ choices?: {
187
+ key: string;
188
+ choice: string;
189
+ text?: string;
190
+ }[];
185
191
  } | null>) | null;
186
192
  pickGenerate?: Function | null;
193
+ ledgerGenerate?: Function | null;
194
+ editGenerate?: Function | null;
187
195
  carriedPicks?: any[] | null;
196
+ carriedChoices?: any[] | null;
197
+ onChoices?: (rec: any[]) => void;
188
198
  onPicks?: (o: {
189
199
  entries: any[];
190
200
  kept: {
@@ -213,7 +223,15 @@ export function authorCloseForJob({ answers, repoPath, lang, verdictType, questi
213
223
  cost: any;
214
224
  interview: any;
215
225
  confirmed: any;
216
- checkPicks?: any;
226
+ picked?: {
227
+ line: number;
228
+ text: string;
229
+ }[];
230
+ hasBuiltCheck?: boolean;
231
+ notBuilt?: {
232
+ line: number;
233
+ text: string;
234
+ }[];
217
235
  }>;
218
236
  /**
219
237
  * Fold an authored close into the OPERATOR's own half of the spec.
@@ -257,12 +257,6 @@ export function draftStopText({ stop, reds, refusal, spend, wholeJob }: {
257
257
  } | null;
258
258
  wholeJob?: boolean;
259
259
  }): string;
260
- /**
261
- * Code's reading of a declared close: a rubric (text-lang) close with no real check, only always-on stages such as
262
- * files-changed, or rubric-step stages holding no part. Decided from the close alone, never by a model.
263
- * @param {any} closeDecl @returns {boolean}
264
- */
265
- export function isNoCheckRubricClose(closeDecl: any): boolean;
266
260
  /**
267
261
  * Plain sentences for the reds of a refused signing, one or more per red. Card and practice-case reds reuse the
268
262
  * proposal table; an unknown code is a generic sentence that quotes the code.
@@ -282,17 +276,17 @@ export function signingReasons(reds: PlainRed[], { cases }?: {
282
276
  export function signingKinds(): string[];
283
277
  /**
284
278
  * THE MESSAGE a person reads when the signing gates refuse. The panel's failed step and the CLI print exactly this.
285
- * @param {{reds: PlainRed[], refusal?: {detail?: string}|null, cases?: any, closeDecl?: any,
286
- * spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o
279
+ * @param {{reds: PlainRed[], refusal?: {detail?: string}|null, cases?: any, noCheck?: boolean,
280
+ * spend?: {knownUsd?: number|null, spendComplete?: boolean|null}|null}} o `noCheck` = the check block has no built check (block.hasBuiltCheck() is false): the stop is the end check's own words
287
281
  * @returns {string}
288
282
  */
289
- export function signingStopText({ reds, refusal, cases, spend, closeDecl }: {
283
+ export function signingStopText({ reds, refusal, cases, spend, noCheck }: {
290
284
  reds: PlainRed[];
291
285
  refusal?: {
292
286
  detail?: string;
293
287
  } | null;
294
288
  cases?: any;
295
- closeDecl?: any;
289
+ noCheck?: boolean;
296
290
  spend?: {
297
291
  knownUsd?: number | null;
298
292
  spendComplete?: boolean | null;
@@ -35,6 +35,18 @@ export function runBehaviour(events: Array<{
35
35
  repeats: number;
36
36
  repeatPct: number | null;
37
37
  };
38
+ /**
39
+ * How many write/edit attempts the gate DENIED (they fell outside the write scope), from gate-audit records alone. One write-class test (action `type`
40
+ * write|edit, as `workerWrites`' reader in src/planrun.js uses), deny-decision only: an allowed write is never counted. Pure.
41
+ * @param {Array<{action?: {type?: string}, decision?: string|null}>} events
42
+ * @returns {number}
43
+ */
44
+ export function writesBlocked(events: Array<{
45
+ action?: {
46
+ type?: string;
47
+ };
48
+ decision?: string | null;
49
+ }>): number;
38
50
  /**
39
51
  * Render a {@link runBehaviour} summary as the agreed printable block
40
52
  * (2–4 short lines). A zero-call run formats plainly ("0 tool calls") rather
@@ -0,0 +1,37 @@
1
+ /** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'cant-check'|'no-check'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>, pairRule?: number}} BlockAsk */
2
+ /**
3
+ * The questions the block has open, in the order the person meets them: the look's readings, then the look's can't-checks, then the pick path's asks (a proposal or a can't-check about a rule the pick path owns) in rule order (a proposal is not counted toward the 3-ask cap).
4
+ * A can't-check about a rule the PICK path owns (`scoped`: src/checkpick.js scopedRules, every `~` rule of a file job) is the pick path's own ask, `no-check`, in fwd's words (a "Line N, guardrail ...: I can't check this" ask
5
+ * whose answer the panel records as a pick, so Revise carries it: am17/am18/am21); any other can't-check is the look's own ask about a page.
6
+ * @param {import('./checkblock.js').CheckBlock} block @param {{line: number, rule: number}[]} [scoped] @returns {BlockAsk[]}
7
+ */
8
+ export function questionsOfBlock(block: import("./checkblock.js").CheckBlock, scoped?: {
9
+ line: number;
10
+ rule: number;
11
+ }[]): BlockAsk[];
12
+ /**
13
+ * The person's choices back into the block, one by one (the choice decides, never the words). A choice the block refuses is returned with its plain reason; the question stays open.
14
+ * @param {import('./checkblock.js').CheckBlock} block @param {{key: string, choice: string, text?: string}[]} choices @returns {{key: string, why: string}[]}
15
+ */
16
+ export function applyChoices(block: import("./checkblock.js").CheckBlock, choices: {
17
+ key: string;
18
+ choice: string;
19
+ text?: string;
20
+ }[]): {
21
+ key: string;
22
+ why: string;
23
+ }[];
24
+ export type BlockAsk = {
25
+ key: string;
26
+ rowKey: string;
27
+ line: number;
28
+ rule: number;
29
+ source: "look";
30
+ ask: "reading" | "cant-check" | "no-check" | "check";
31
+ ruleText: string;
32
+ question: string;
33
+ counted: boolean;
34
+ reading?: string;
35
+ check?: Record<string, any>;
36
+ pairRule?: number;
37
+ };