fwdloop 0.33.0 → 0.35.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 (87) hide show
  1. package/README.md +14 -0
  2. package/bin/fwdloop +18 -2
  3. package/package.json +1 -1
  4. package/src/action-line.js +100 -0
  5. package/src/action-stop.js +44 -0
  6. package/src/ask.js +9 -2
  7. package/src/auditchecks.js +6 -4
  8. package/src/authoring.js +28 -14
  9. package/src/blockasks.js +3 -2
  10. package/src/blockassemble.js +40 -21
  11. package/src/blockdraft.js +8 -13
  12. package/src/blockpick.js +11 -1
  13. package/src/checkblock.js +102 -58
  14. package/src/checked.js +7 -2
  15. package/src/checklist.js +1 -3
  16. package/src/checklistsign.js +1 -1
  17. package/src/checkpick.js +7 -73
  18. package/src/declaration.js +20 -35
  19. package/src/drafter.js +281 -208
  20. package/src/jobkey.js +2 -3
  21. package/src/noteask.js +62 -0
  22. package/src/pageask.js +24 -69
  23. package/src/pagedry.js +27 -4
  24. package/src/pagemap.js +8 -2
  25. package/src/pagerules.js +19 -3
  26. package/src/panel/author.js +63 -36
  27. package/src/panel/authorcard.js +36 -20
  28. package/src/panel/data.js +5 -1
  29. package/src/panel/index.html +66 -37
  30. package/src/pickrecord.js +42 -54
  31. package/src/planrebuild.js +16 -6
  32. package/src/rowedit.js +35 -5
  33. package/src/rubricstep.js +9 -1
  34. package/src/runner.js +87 -41
  35. package/src/runvalues.js +9 -1
  36. package/src/setup.js +3 -1
  37. package/src/sheetblock.js +17 -7
  38. package/src/sheetbuild.js +148 -0
  39. package/src/sheetchecks.js +3 -2
  40. package/src/sheetfind.js +4 -4
  41. package/src/sheetlook.js +15 -4
  42. package/src/sheetoffer.js +50 -5
  43. package/src/sheetrows.js +18 -2
  44. package/src/signed-text.js +1 -5
  45. package/src/ticket-draft.js +4 -21
  46. package/src/ticketrows.js +100 -0
  47. package/src/whole-job.js +27 -11
  48. package/types/action-line.d.ts +71 -0
  49. package/types/action-stop.d.ts +36 -0
  50. package/types/ask.d.ts +3 -2
  51. package/types/auditchecks.d.ts +2 -1
  52. package/types/authoring.d.ts +8 -3
  53. package/types/blockasks.d.ts +1 -2
  54. package/types/blockassemble.d.ts +20 -3
  55. package/types/blockdraft.d.ts +4 -12
  56. package/types/blockpick.d.ts +5 -0
  57. package/types/checkblock.d.ts +33 -17
  58. package/types/checked.d.ts +2 -0
  59. package/types/checklist.d.ts +3 -5
  60. package/types/checkpick.d.ts +4 -34
  61. package/types/declaration.d.ts +7 -0
  62. package/types/drafter.d.ts +23 -356
  63. package/types/noteask.d.ts +52 -0
  64. package/types/pageask.d.ts +12 -36
  65. package/types/pagedry.d.ts +13 -0
  66. package/types/pagerules.d.ts +7 -0
  67. package/types/panel/author.d.ts +1 -1
  68. package/types/panel/authorcard.d.ts +13 -8
  69. package/types/panel/authorflows.d.ts +4 -4
  70. package/types/panel/data.d.ts +2 -2
  71. package/types/panel/jobgrid.d.ts +1 -1
  72. package/types/pickrecord.d.ts +47 -13
  73. package/types/rowedit.d.ts +16 -1
  74. package/types/rubricstep.d.ts +3 -0
  75. package/types/sheetblock.d.ts +11 -4
  76. package/types/sheetbuild.d.ts +82 -0
  77. package/types/sheetchecks.d.ts +2 -1
  78. package/types/sheetfind.d.ts +2 -2
  79. package/types/sheetoffer.d.ts +26 -1
  80. package/types/sheetrows.d.ts +8 -0
  81. package/types/ticket-draft.d.ts +3 -49
  82. package/types/ticketrows.d.ts +61 -0
  83. package/types/whole-job.d.ts +3 -3
  84. package/src/added-end.js +0 -60
  85. package/src/repairs.js +0 -38
  86. package/types/added-end.d.ts +0 -62
  87. package/types/repairs.d.ts +0 -13
@@ -45,6 +45,7 @@ import { lineRules } from './pagebits.js';
45
45
  import { OFFERED as OFFERED_RULES } from './checkwords.js';
46
46
  import { isColumnChoiceRule } from './sheetoffer.js';
47
47
  import { checkListReds } from './checklistsign.js';
48
+ import { ticketListReds } from './ticketrows.js';
48
49
 
49
50
  /** @typedef {import('./types.js').Arbiter} Arbiter */
50
51
  /** @typedef {import('./types.js').SignedLine} SignedLine */
@@ -159,7 +160,7 @@ function checkMcp(declaration, reds) {
159
160
  /** M12 piece 3 (item 4): the signed label filter, `ticketFilter: {priority?: ['P0'..'P3'], labels?: [names]}`; optional, and only on a job that lists MCP tools.
160
161
  * Pure data: code decides at run (src/ticket-labels.js); the drafter may only suggest it and a human signs it.
161
162
  * @param {Record<string, any>} declaration @param {string[]} reds */
162
- function checkTicketFilter(declaration, reds) {
163
+ export function checkTicketFilter(declaration, reds) {
163
164
  if (!Object.hasOwn(declaration, 'ticketFilter')) return;
164
165
  const f = declaration.ticketFilter;
165
166
  if (!isPlainObject(f) || Object.keys(f).length === 0) {
@@ -186,7 +187,7 @@ function checkTicketFilter(declaration, reds) {
186
187
 
187
188
  /** M12 piece 3 (signed item 7): the ticket fields a schedule may watch, `ticketWatch: ['state'|'labels']`; optional, only on a job that lists MCP tools, typed values only.
188
189
  * The scheduler compares (src/trigger-tickets.js); the drafter may suggest, a human signs. @param {Record<string, any>} declaration @param {string[]} reds */
189
- function checkTicketWatch(declaration, reds) {
190
+ export function checkTicketWatch(declaration, reds) {
190
191
  if (!Object.hasOwn(declaration, 'ticketWatch')) return;
191
192
  const w = declaration.ticketWatch;
192
193
  if (!Array.isArray(w) || w.length === 0) { reds.push(`declaration: "ticketWatch" must be a non-empty list of fields (${WATCHABLE.join(' and ')})`); return; }
@@ -226,7 +227,7 @@ export const SHAPE_KEYS = Object.freeze(['maxWords', 'sections', 'linesPerInvoic
226
227
  export const MACHINE_SHAPE_KEYS = Object.freeze(['wordsPerSection', 'picked']);
227
228
 
228
229
  const SHAPE_TYPE_CHECKS = Object.freeze({
229
- // M10 am16: the checks the person picked, set by code (src/checkpick.js applyPicks), each one a bareguard rule with only that rule's own fields
230
+ // M10 am16: the checks the person picked, set by code (src/blockassemble.js), each one a bareguard rule with only that rule's own fields
230
231
  picked: {
231
232
  expected: 'a non-empty array of checks, each an object with a text rule of bareguard\'s list',
232
233
  check: (v) => Array.isArray(v) && v.length > 0 && v.every((c) => isPlainObject(c) && typeof c.rule === 'string' && OFFERED_RULES.includes(c.rule)),
@@ -560,7 +561,7 @@ function checkShapeBuilds(shape, label, reds, redsBefore) {
560
561
  }
561
562
 
562
563
  /**
563
- * M10 am22 (3): `pickedLines` is the record of the fact lines that carry the person's picks: a list of line numbers. Code writes it (src/checkpick.js applyPicks).
564
+ * M10 am22 (3): `pickedLines` is the record of the fact lines that carry the person's picks: a list of line numbers. Code writes it (src/blockassemble.js).
564
565
  * @param {Record<string, any>} declaration @param {string[]} reds
565
566
  */
566
567
  function checkPickedLines(declaration, reds) {
@@ -571,7 +572,7 @@ function checkPickedLines(declaration, reds) {
571
572
 
572
573
  /**
573
574
  * M10 am22: `close.picked` is the checks the person picked for a fact line, kept beside its fact check and run on the answer's `text`. Code sets it (src/checkpick.js
574
- * applyPicks); here it must be a green step's, a list of bareguard text rules that builds into a check.
575
+ * assembleFromBlock); here it must be a green step's, a list of bareguard text rules that builds into a check.
575
576
  * It is allowed ONLY on a line the signed plan records in `pickedLines` (written by code from the person's picks); a count on any other fact line is refused.
576
577
  * @param {any} step @param {string} label @param {string} effectiveClass @param {string[]} reds @param {Record<string, any>} declaration
577
578
  */
@@ -818,10 +819,10 @@ export function validateDeclaration(declaration, context = {}) {
818
819
  reds.push('declaration: "guardrailClasses" must be an object keyed by line number');
819
820
  }
820
821
 
821
- // --- unjudgeable (REQUIRED; {} is fine) ------------------------------------
822
+ // --- unjudgeable (M17 am4, C8: a new plan carries none; a plan signed before holds it and is read as signed) ---
822
823
  let unjudgeable = {};
823
824
  if (!Object.prototype.hasOwnProperty.call(declaration, 'unjudgeable')) {
824
- reds.push('declaration: "unjudgeable" is required (an object keyed by line number; {} is fine)');
825
+ // nothing to read
825
826
  } else if (Array.isArray(declaration.unjudgeable) && declaration.unjudgeable.length === 0) {
826
827
  // am41 item 1 (F63): an empty list carries no data; it counts as {}. A non-empty list falls to the red below.
827
828
  } else if (isPlainObject(declaration.unjudgeable)) {
@@ -1121,6 +1122,7 @@ export function validateDeclaration(declaration, context = {}) {
1121
1122
 
1122
1123
  // M16 item 2: the checks of a list line are the signed list's; a plan carrying one proves it here, at sign and at run start ($0)
1123
1124
  reds.push(...checkListReds(declaration));
1125
+ reds.push(...ticketListReds(declaration));
1124
1126
 
1125
1127
  // --- ask slots (ported from poc/m1/slots.mjs's checkAskSlots) --------------
1126
1128
  // (a) exactly one hitl step bound to each signed ask line.
@@ -1206,33 +1208,14 @@ export function validateDeclaration(declaration, context = {}) {
1206
1208
  reds.push(`declaration: send at line ${n} (steps[${sendIdx}]) is not granted a catalogue primitive of class "write"`);
1207
1209
  }
1208
1210
 
1209
- // M3 scope item 8 (F42's "Also seen" note): "earlier" is judged by STEP
1210
- // ORDER, never by prose line number — the runner folds over
1211
- // `declaration.steps` in array order (`acceptedAskEmitsThisRun` is
1212
- // populated as steps execute), so a line-number comparison here can
1213
- // disagree with what actually runs. A signed ask whose step sits before
1214
- // the send step in `declaration.steps`, whatever its own prose line
1215
- // number, is "earlier"; one whose step sits at or after the send step
1216
- // never is, even if its line number is smaller.
1217
- const earlierAskLines = askLines.filter((a) => {
1218
- const askIdx = stepInfo.findIndex((st) => st.fromLine === a);
1219
- return askIdx !== -1 && askIdx < sendIdx;
1220
- });
1221
- if (earlierAskLines.length === 0) {
1222
- reds.push(`declaration: send at line ${n} (steps[${sendIdx}]) has no signed ask at an earlier line to read from`);
1223
- } else {
1224
- const earlierAskEmits = earlierAskLines
1225
- .map((a) => stepInfo.find((st) => st.fromLine === a))
1226
- .filter((st) => st !== undefined)
1227
- .map((st) => st.emits);
1228
- const readAskEmits = earlierAskEmits.filter((emits) => emits !== null && sendStep.reads.includes(emits));
1229
- if (readAskEmits.length === 0) {
1230
- reds.push(`declaration: send at line ${n} (steps[${sendIdx}]) does not read the emits of any earlier signed `
1231
- + `ask step (asks at lines ${earlierAskLines.join(', ')})`);
1232
- } else if (readAskEmits.length >= 2) {
1233
- reds.push(`declaration: send at line ${n} (steps[${sendIdx}]) reads the emits of more than one earlier signed `
1234
- + `ask step (${readAskEmits.join(', ')}) — exactly 1 required`);
1235
- }
1211
+ // M13 am11: the action ships everything that came before it: it reads the output of the step right before it (by step order, the order the
1212
+ // runner folds over). An Ask there is the artifact accepted at it; any other step's output is checked at run time against the last accept (or the run stops once).
1213
+ // No Ask is needed before the action. (Was: the send must read exactly one earlier signed ask.)
1214
+ const before = sendIdx > 0 ? stepInfo[sendIdx - 1] : null;
1215
+ if (before === null || before.emits === null) {
1216
+ reds.push(`declaration: send at line ${n} (steps[${sendIdx}]) has no step before it to write out`);
1217
+ } else if (!sendStep.reads.includes(before.emits)) {
1218
+ reds.push(`declaration: send at line ${n} (steps[${sendIdx}]) must read the output of the step before it ("${before.emits}"), got [${sendStep.reads.join(', ')}]`);
1236
1219
  }
1237
1220
  }
1238
1221
 
@@ -1244,7 +1227,9 @@ export function validateDeclaration(declaration, context = {}) {
1244
1227
  // STEP ORDER (a step's position in `declaration.steps`, not its line
1245
1228
  // number) since that is the order the runner actually folds over. No
1246
1229
  // anchor to check against when there is no signed ask at all.
1247
- if (askLines.length > 0) {
1230
+ // M13 am11: with an action (a signed send) a step after the last Ask is allowed: what goes out is compared with the last accept at run time and the run stops once if it changed
1231
+ // (src/runner.js). A job with no action keeps this rule unchanged.
1232
+ if (askLines.length > 0 && sendLines.length === 0) {
1248
1233
  const lastAskLine = Math.max(...askLines);
1249
1234
  const lastAskStepIdx = stepInfo.findIndex((st) => st.fromLine === lastAskLine);
1250
1235
  if (lastAskStepIdx !== -1) {