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
package/src/added-end.js DELETED
@@ -1,60 +0,0 @@
1
- // M13 am8: the end of a job is added by code, never typed. ONE writer of the added lines (`addEnd`), ONE reader that finds them again in a plan (`addedLinesOf`).
2
- // Given the card's parsed job steps and its Destination: no Destination -> nothing added; the last line not an Ask -> `ask <wait>: check the result with me`
3
- // then `write it out`; the last line an Ask -> only `write it out`. The send is always the added `write it out`. The wait is the card's Ask wait (the
4
- // caller's `jobFileLines` writes it out, as it does for any ask line with no wait of its own).
5
- // Throws away: nothing. Third outcomes: an empty job adds nothing (the card refuses an empty job before this runs).
6
-
7
- export const ADDED_ASK_QUESTION = 'check the result with me';
8
- export const ADDED_WRITE = 'write it out';
9
-
10
- /**
11
- * @param {{ n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[]} steps `parseJobBox` steps
12
- * @param {string} destination the card's Destination ('' = none)
13
- * @returns {{ steps: { n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[], added: number[] }} the steps with the end added, and the numbers of the added lines
14
- */
15
- export function addEnd(steps, destination) {
16
- if (destination === '' || steps.length === 0) return { steps, added: [] };
17
- const out = [...steps];
18
- /** @type {number[]} */
19
- const added = [];
20
- if (out[out.length - 1].ask === null) {
21
- const n = out.length + 1;
22
- out.push({ n, text: `ask: ${ADDED_ASK_QUESTION}`, ask: { wait: null, question: ADDED_ASK_QUESTION }, guardrails: [] });
23
- added.push(n);
24
- }
25
- const n = out.length + 1;
26
- out.push({ n, text: ADDED_WRITE, ask: null, guardrails: [] });
27
- added.push(n);
28
- return { steps: out, added };
29
- }
30
-
31
- /**
32
- * The added lines of a plan, found again from its signed lines and arbiter: the send line when it reads `write it out`, and the Ask just before it
33
- * when that reads `check the result with me`. A job signed before M13 am8 (its send line is the person's own words) finds none.
34
- * @param {{ n: number, text: string }[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
35
- * @returns {Set<number>}
36
- */
37
- export function addedLinesOf(lines, arbiter) {
38
- const found = new Set();
39
- const send = (arbiter?.sends ?? [])[0];
40
- if (!send) return found;
41
- const textOf = (/** @type {number} */ n) => lines.find((l) => l.n === n)?.text;
42
- if (textOf(send.line) !== ADDED_WRITE) return found;
43
- found.add(send.line);
44
- if (textOf(send.line - 1) === ADDED_ASK_QUESTION && (arbiter.asks ?? []).some((a) => a.line === send.line - 1)) found.add(send.line - 1);
45
- return found;
46
- }
47
-
48
- /**
49
- * The lines a person typed, found again from a signed job: the signed lines without the send line (the last line when it is the send; today's `write it out`, or
50
- * the person's own words in a job signed before am8) and without an added Ask before it. ONE reader for the Edit card (`cardFromSigned`) and the job identity (`jobKeyOfSigned`).
51
- * @template {{ n: number, text: string }} L
52
- * @param {L[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
53
- * @returns {L[]}
54
- */
55
- export function typedLinesOf(lines, arbiter) {
56
- const sends = arbiter?.sends ?? [];
57
- const lastSend = sends.length === 1 && sends[0].line === lines.length ? sends[0].line : null;
58
- const added = addedLinesOf(lines, arbiter);
59
- return lines.filter((l) => l.n !== lastSend && !added.has(l.n));
60
- }
package/src/repairs.js DELETED
@@ -1,38 +0,0 @@
1
- // M10 am27 (2): code repairs of the two mechanical plan mistakes F169 found in 13 of 20 F168 drafts. Each repair is returned as a line of text and logged on the draft
2
- // entry (`repaired`), so it is visible. Neither repair grants a primitive, changes a class, or writes a check.
3
- // (1) a green step whose `close.cited.source` is a declared source role the step does not read: the role is added to its `reads`.
4
- // (2) an `unjudgeable` entry for a line whose guardrailClasses says green: the entry is dropped and the line stays green.
5
- // Throws away: the `unjudgeable` reason text of a dropped entry (kept only inside the `repaired` line).
6
- /**
7
- * @param {any} declaration the drafter's declaration (not changed) @param {{sources?: {role?: string, kind?: string}[]}} arbiter
8
- * @returns {{declaration: any, repaired: string[]}}
9
- */
10
- export function repairDeclaration(declaration, arbiter) {
11
- const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
12
- if (!isRec(declaration)) return { declaration, repaired: [] };
13
- /** @type {string[]} */
14
- const repaired = [];
15
- const roles = new Set((arbiter?.sources ?? []).filter((s) => typeof s?.role === 'string').map((s) => /** @type {string} */ (s.role)));
16
- let out = declaration;
17
- if (Array.isArray(declaration.steps)) {
18
- out = {
19
- ...out,
20
- steps: declaration.steps.map((/** @type {any} */ st, /** @type {number} */ i) => {
21
- const src = isRec(st) && isRec(st.close) && st.close.class === 'green' && isRec(st.close.cited) ? st.close.cited.source : undefined;
22
- if (typeof src !== 'string' || !roles.has(src) || !Array.isArray(st.reads) || st.reads.includes(src)) return st;
23
- repaired.push(`steps[${i}].reads: added "${src}" (its cited check reads it)`);
24
- return { ...st, reads: [...st.reads, src] };
25
- }),
26
- };
27
- }
28
- if (isRec(declaration.unjudgeable) && isRec(declaration.guardrailClasses)) {
29
- const un = { ...declaration.unjudgeable };
30
- for (const key of Object.keys(un)) {
31
- if (declaration.guardrailClasses[key] !== 'green') continue;
32
- repaired.push(`unjudgeable: dropped the entry for line ${key} (its class is green; reason was: ${String(un[key]).slice(0, 160)})`);
33
- delete un[key];
34
- }
35
- out = { ...out, unjudgeable: un };
36
- }
37
- return { declaration: repaired.length ? out : declaration, repaired };
38
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * @param {{ n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[]} steps `parseJobBox` steps
3
- * @param {string} destination the card's Destination ('' = none)
4
- * @returns {{ steps: { n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[], added: number[] }} the steps with the end added, and the numbers of the added lines
5
- */
6
- export function addEnd(steps: {
7
- n: number;
8
- text: string;
9
- ask: null | {
10
- wait: string | null;
11
- question: string;
12
- };
13
- guardrails: string[];
14
- }[], destination: string): {
15
- steps: {
16
- n: number;
17
- text: string;
18
- ask: null | {
19
- wait: string | null;
20
- question: string;
21
- };
22
- guardrails: string[];
23
- }[];
24
- added: number[];
25
- };
26
- /**
27
- * The added lines of a plan, found again from its signed lines and arbiter: the send line when it reads `write it out`, and the Ask just before it
28
- * when that reads `check the result with me`. A job signed before M13 am8 (its send line is the person's own words) finds none.
29
- * @param {{ n: number, text: string }[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
30
- * @returns {Set<number>}
31
- */
32
- export function addedLinesOf(lines: {
33
- n: number;
34
- text: string;
35
- }[], arbiter: {
36
- sends?: {
37
- line: number;
38
- }[];
39
- asks?: {
40
- line: number;
41
- }[];
42
- }): Set<number>;
43
- /**
44
- * The lines a person typed, found again from a signed job: the signed lines without the send line (the last line when it is the send; today's `write it out`, or
45
- * the person's own words in a job signed before am8) and without an added Ask before it. ONE reader for the Edit card (`cardFromSigned`) and the job identity (`jobKeyOfSigned`).
46
- * @template {{ n: number, text: string }} L
47
- * @param {L[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
48
- * @returns {L[]}
49
- */
50
- export function typedLinesOf<L extends {
51
- n: number;
52
- text: string;
53
- }>(lines: L[], arbiter: {
54
- sends?: {
55
- line: number;
56
- }[];
57
- asks?: {
58
- line: number;
59
- }[];
60
- }): L[];
61
- export const ADDED_ASK_QUESTION: "check the result with me";
62
- export const ADDED_WRITE: "write it out";
@@ -1,13 +0,0 @@
1
- /**
2
- * @param {any} declaration the drafter's declaration (not changed) @param {{sources?: {role?: string, kind?: string}[]}} arbiter
3
- * @returns {{declaration: any, repaired: string[]}}
4
- */
5
- export function repairDeclaration(declaration: any, arbiter: {
6
- sources?: {
7
- role?: string;
8
- kind?: string;
9
- }[];
10
- }): {
11
- declaration: any;
12
- repaired: string[];
13
- };