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
@@ -37,7 +37,7 @@ export function appendAnswersToJob(job: string, answers: {
37
37
  added: number;
38
38
  };
39
39
  /**
40
- * M10 am21: the submitted job box with ONE `~` line of a job line replaced by the words of an answer (the edited added line the ask was about). Pure.
40
+ * M10 am21, M17 am1: the submitted job box with ONE `~` rule of a job line (a whole `~` line, or one `; ` part of it) replaced by the words of an answer. Pure.
41
41
  * @param {string} job @param {number} line the job line (step) number @param {string} oldText the `~` words to replace (case and spacing aside) @param {string} newText
42
42
  * @returns {{ job: string, replaced: boolean }}
43
43
  */
@@ -46,11 +46,12 @@ export function replaceRuleOnJob(job: string, line: number, oldText: string, new
46
46
  replaced: boolean;
47
47
  };
48
48
  /**
49
- * THE one writer of what a set of answers does to the job box and to the picks (M4e am24, M10 am16 (4), M10 am21): an answer is one more `~` line under its job line
50
- * (`appendAnswersToJob`), EXCEPT the answer to an ask about an edited added line (`pairRule`), which REPLACES that line's words (the old added line never comes back).
51
- * Picks and left rules are numbered as the asks carried them; an edited-line pick is kept under its source's number (`pairRule`), with the edited words as `added`.
52
- * @param {string} job @param {{line: number, rule: string|null, left: boolean, check?: Record<string, any>|null, own?: boolean, ruleNo?: number, ruleText?: string, ask?: string, pairRule?: number}[]} all
53
- * @returns {{job: string, added: number, picks: {line: number, rule: number|undefined, check: Record<string, any>|null, added: string, own?: boolean}[], left: {line: number, rule: number|undefined}[]}}
49
+ * THE one writer of what a set of answers does to the job box and to the picks (M4e am24, M10 am16 (4); M17 am1 (a), one rule in, one rule out): an answer about one of the person's `~` rules
50
+ * (a look ask with a rule number) REPLACES that rule in place, the same line and the same rule number (`replaceRuleOnJob`), and never adds a line beside it. Only an answer that is about no
51
+ * rule (a drafter question, a sheet column ask) is still added word for word as a new `~` line (`appendAnswersToJob`). Picks and left rules are numbered as the asks carried them; a pick carries
52
+ * no `added` words, because its rule's words ARE the answer. A rule-about answer whose rule is no longer on the job line is not applied (the caller sees the count and refuses).
53
+ * @param {string} job @param {{line: number, rule: string|null, left: boolean, check?: Record<string, any>|null, own?: boolean, ruleNo?: number, ruleText?: string, ask?: string, proposal?: string|null}[]} all
54
+ * @returns {{job: string, added: number, picks: {line: number, rule: number|undefined, check: Record<string, any>|null, own?: boolean}[], left: {line: number, rule: number|undefined}[], columns: {line: number, word: string, column: string}[]}}
54
55
  */
55
56
  export function applyAnswers(job: string, all: {
56
57
  line: number;
@@ -61,7 +62,7 @@ export function applyAnswers(job: string, all: {
61
62
  ruleNo?: number;
62
63
  ruleText?: string;
63
64
  ask?: string;
64
- pairRule?: number;
65
+ proposal?: string | null;
65
66
  }[]): {
66
67
  job: string;
67
68
  added: number;
@@ -69,13 +70,17 @@ export function applyAnswers(job: string, all: {
69
70
  line: number;
70
71
  rule: number | undefined;
71
72
  check: Record<string, any> | null;
72
- added: string;
73
73
  own?: boolean;
74
74
  }[];
75
75
  left: {
76
76
  line: number;
77
77
  rule: number | undefined;
78
78
  }[];
79
+ columns: {
80
+ line: number;
81
+ word: string;
82
+ column: string;
83
+ }[];
79
84
  };
80
85
  /**
81
86
  * THE one place a step's `~` lines become its guardrail: several `~` lines under one step are ONE continuous guardrail (hamr ruling 2026-10-09),
@@ -95,7 +95,7 @@ export function createFlowsDoor(opts: {
95
95
  } | {
96
96
  ok: boolean;
97
97
  card: {
98
- flowType?: "mcp" | "plain" | "tickets" | undefined;
98
+ flowType?: "tickets" | "mcp" | "plain" | undefined;
99
99
  mcp?: any;
100
100
  job: string;
101
101
  inputs: string;
@@ -123,7 +123,7 @@ export function createFlowsDoor(opts: {
123
123
  roles: any;
124
124
  pages: Record<string, string>;
125
125
  tickets: string[];
126
- flowType: "mcp" | "plain" | "tickets";
126
+ flowType: "tickets" | "mcp" | "plain";
127
127
  mcp: any;
128
128
  nextRunId: string;
129
129
  lastRunId: string | null;
@@ -188,7 +188,7 @@ export function createFlowsDoor(opts: {
188
188
  } | {
189
189
  ok: boolean;
190
190
  card: {
191
- flowType?: "mcp" | "plain" | "tickets" | undefined;
191
+ flowType?: "tickets" | "mcp" | "plain" | undefined;
192
192
  mcp?: any;
193
193
  job: string;
194
194
  inputs: string;
@@ -216,7 +216,7 @@ export function createFlowsDoor(opts: {
216
216
  roles: any;
217
217
  pages: Record<string, string>;
218
218
  tickets: string[];
219
- flowType: "mcp" | "plain" | "tickets";
219
+ flowType: "tickets" | "mcp" | "plain";
220
220
  mcp: any;
221
221
  nextRunId: string;
222
222
  lastRunId: string | null;
@@ -757,7 +757,7 @@ export function getJobGrid({ root, flow, catalogue, now, }: {
757
757
  name: string;
758
758
  title: string | null;
759
759
  number: number | null;
760
- bucket: "wait" | "skip" | "done" | "stop";
760
+ bucket: "skip" | "done" | "stop" | "wait";
761
761
  glyph: string;
762
762
  at: number;
763
763
  ex: "r" | "n" | "g" | "q";
@@ -787,7 +787,7 @@ export function getJobGrid({ root, flow, catalogue, now, }: {
787
787
  spentUsd: number | null;
788
788
  spentComplete: boolean;
789
789
  };
790
- flowType: "mcp" | "plain" | "tickets" | null;
790
+ flowType: "tickets" | "mcp" | "plain" | null;
791
791
  } | null;
792
792
  /**
793
793
  * `GET /api/runs/:flow/:runId/download?i=<n>` (M10 am4): one saved file, or why not.
@@ -69,7 +69,7 @@ export function buildJobGrid({ runs, anyway, now }: {
69
69
  name: string;
70
70
  title: string | null;
71
71
  number: number | null;
72
- bucket: "wait" | "skip" | "done" | "stop";
72
+ bucket: "skip" | "done" | "stop" | "wait";
73
73
  glyph: string;
74
74
  at: number;
75
75
  ex: "r" | "n" | "g" | "q";
@@ -10,9 +10,9 @@ export function lineKeys(lines: {
10
10
  occurrence: number;
11
11
  }>;
12
12
  /**
13
- * The entries for answers just given, numbered on THIS card (the answer redraft's card: its line and rule numbers are the ones the asks carried).
13
+ * The entries for answers just given, numbered on THIS card (the answer redraft's card: its line and rule numbers are the ones the asks carried; the rule's text is the FINAL rule's words).
14
14
  * @param {{n: number, text: string}[]} lines @param {Rule[]} rules
15
- * @param {{line: number, rule: number, check?: Record<string, any>|null, added?: string|null, own?: boolean}[]} picks @param {{line: number, rule: number}[]} left
15
+ * @param {{line: number, rule: number, check?: Record<string, any>|null, own?: boolean}[]} picks @param {{line: number, rule: number}[]} left
16
16
  * @returns {Entry[]}
17
17
  */
18
18
  export function entriesFromAnswers(lines: {
@@ -22,7 +22,6 @@ export function entriesFromAnswers(lines: {
22
22
  line: number;
23
23
  rule: number;
24
24
  check?: Record<string, any> | null;
25
- added?: string | null;
26
25
  own?: boolean;
27
26
  }[], left: {
28
27
  line: number;
@@ -30,12 +29,11 @@ export function entriesFromAnswers(lines: {
30
29
  }[]): Entry[];
31
30
  /**
32
31
  * Decide, for the card in hand, which stored picks are kept and which guardrails must be asked.
33
- * A pick is KEPT when the job line with its words (same order among equal lines) still has its source guardrail with the exact words and, if the pick wrote a `~` line,
34
- * that line with its exact words too. Otherwise the pick is dropped (never partly kept) and its guardrails are asked: a pair broken on one side is ONE ask, so the
35
- * partner left on the card is folded (neither asked nor given the old check) - except an EDITED added line (M10 am21): that one is asked (`pairRule` = its source's number) and the source is folded. Pure.
32
+ * A pick is KEPT when the job line with its words (same order among equal lines) still has a guardrail with the pick's exact words. One rule in, one rule out (hamr 2026-11-14): an answer REPLACED the
33
+ * rule it was asked about, so the stored words are the final rule's words and there is no second line to pair; a rule whose words changed is simply new and asked. Pure.
36
34
  * @param {Entry[]} entries @param {{n: number, text: string}[]} lines @param {Rule[]} rules every guardrail the call settles
37
- * @returns {{picks: {line: number, rule: number, check: Record<string, any>|null, added?: string, own?: boolean}[], left: {line: number, rule: number}[],
38
- * kept: {line: number, rule: number, entry: Entry}[], askRules: (Rule & {pairRule?: number})[]}}
35
+ * @returns {{picks: {line: number, rule: number, check: Record<string, any>|null, own?: boolean}[], left: {line: number, rule: number}[],
36
+ * kept: {line: number, rule: number, entry: Entry}[], askRules: Rule[]}}
39
37
  */
40
38
  export function matchRecord(entries: Entry[], lines: {
41
39
  n: number;
@@ -45,7 +43,6 @@ export function matchRecord(entries: Entry[], lines: {
45
43
  line: number;
46
44
  rule: number;
47
45
  check: Record<string, any> | null;
48
- added?: string;
49
46
  own?: boolean;
50
47
  }[];
51
48
  left: {
@@ -57,9 +54,7 @@ export function matchRecord(entries: Entry[], lines: {
57
54
  rule: number;
58
55
  entry: Entry;
59
56
  }[];
60
- askRules: (Rule & {
61
- pairRule?: number;
62
- })[];
57
+ askRules: Rule[];
63
58
  };
64
59
  /**
65
60
  * Read a carried record (the folder's file). A missing or unreadable file is no record (a plan from before am17 has none).
@@ -88,6 +83,45 @@ export function readSheetDropped(file: string): {
88
83
  check: Record<string, any>;
89
84
  text: string;
90
85
  }[] | null;
86
+ /**
87
+ * M17 ruling 2: the columns a person agreed for a word of the job's prose (or a word that is not in the rule it was asked about), kept in the same record as the picks and carried like them:
88
+ * tied to the job line's WORDS (and its order among equal lines), never to a number. `columns` entries are `{lineWords, occurrence, word, column}`.
89
+ * @param {string} file @returns {{lineWords: string, occurrence: number, word: string, column: string}[]|null}
90
+ */
91
+ export function readColumns(file: string): {
92
+ lineWords: string;
93
+ occurrence: number;
94
+ word: string;
95
+ column: string;
96
+ }[] | null;
97
+ /** @param {{n: number, text: string}[]} lines @param {{line: number, word: string, column: string}[]} cols @returns {{lineWords: string, occurrence: number, word: string, column: string}[]} the answers as the record keeps them */
98
+ export function columnEntries(lines: {
99
+ n: number;
100
+ text: string;
101
+ }[], cols: {
102
+ line: number;
103
+ word: string;
104
+ column: string;
105
+ }[]): {
106
+ lineWords: string;
107
+ occurrence: number;
108
+ word: string;
109
+ column: string;
110
+ }[];
111
+ /** @param {{lineWords: string, occurrence: number, word: string, column: string}[]} entries @param {{n: number, text: string}[]} lines @returns {{line: number, word: string, column: string}[]} the record's answers whose job line is still on the card (same words, same order) */
112
+ export function columnsOnLines(entries: {
113
+ lineWords: string;
114
+ occurrence: number;
115
+ word: string;
116
+ column: string;
117
+ }[], lines: {
118
+ n: number;
119
+ text: string;
120
+ }[]): {
121
+ line: number;
122
+ word: string;
123
+ column: string;
124
+ }[];
91
125
  /** the record's file, inside a drafting folder only (never a run folder) */
92
126
  export const RECORD_FILE: "picks-record.json";
93
127
  /** the exact words a kept pick is marked with in the draft log, the Audit and the plan card (M10 am17 (6)) */
@@ -98,7 +132,7 @@ export type Entry = {
98
132
  lineWords: string;
99
133
  occurrence: number;
100
134
  ruleText: string;
101
- added: string | null;
135
+ added?: string | null;
102
136
  check: Record<string, any> | null;
103
137
  own: boolean;
104
138
  left: boolean;
@@ -1,3 +1,15 @@
1
+ /**
2
+ * The facts a person-facing turn must not ask about (R5 finding F285): the confirm turn asked "which ticket, and is it P1?" in 5 of 10 live drafts. ONE owner of these words;
3
+ * the confirm prompt and the drafting prompt both carry them, for a Tickets job only.
4
+ * @returns {string}
5
+ */
6
+ export function ticketPerRunFacts(): string;
7
+ /**
8
+ * What the drafter is told when the job reads tickets (appended to the authoring prompt only then; a plain job's prompt is untouched).
9
+ * Adapted from fwd's `ticketFactsLines` (v0.29.0): the same MUST, the same "never invent a label".
10
+ * @returns {string}
11
+ */
12
+ export function ticketFilterBlock(): string;
1
13
  /**
2
14
  * The ONE user message: the person's job lines (their `~` rules numbered), the look, the inputs (bounded).
3
15
  * @param {{jobLines: any[], look: any, texts: Record<string, string>}} o
@@ -9,6 +21,9 @@ export function rowEditUserText({ jobLines, look, texts }: {
9
21
  texts: Record<string, string>;
10
22
  }): string;
11
23
  export const TICKET_FILTER_SCHEMA_WORDS: "REQUIRED when a job line names a priority or a label (leave it out only when none does). The person signs it; code decides at run start. Listing the line under \"refused\" does not filter anything: only this key does";
24
+ /** a legal filter, as the drafter is shown it */
25
+ export const TICKET_FILTER_EXAMPLE: "{\"priority\": [\"P1\"], \"labels\": [\"bug\"]}";
26
+ export const TICKET_READ_FACT: "A step that reads the ticket input still lists \"read\" in its tools: the ticket is already frozen at run start, but reading it is a grant, so a step without \"read\" cannot see it.";
12
27
  /** the tool a row-edit reply is delivered through */
13
28
  export const ROW_EDIT_TOOL: "submit_edits";
14
29
  /** what an acknowledged reply returns (the loop ends the call the moment the tool fires) */
@@ -17,7 +32,7 @@ export const ROW_EDIT_ACK: "edits received";
17
32
  export const ROW_EDIT_SYSTEM: string;
18
33
  /** the fixed sentence that follows the refusals in a revise turn (the turn carries each refusal's own reason and nothing else) */
19
34
  export const ROW_EDIT_REVISE: "Send corrected edits only (an empty \"edits\" list is a good answer).";
20
- export function rowEditChannel(ticket?: boolean): {
35
+ export function rowEditChannel(ticket?: boolean, sheetChecks?: Record<string, any> | null): {
21
36
  name: string;
22
37
  instruction: string;
23
38
  textPath: string;
@@ -52,7 +52,10 @@ export const PART_CLASSES: readonly string[];
52
52
  export const COUNT_CHECKS: Readonly<Record<string, readonly string[]>>;
53
53
  export function boundInWords(b: unknown, said: string): boolean;
54
54
  export const NEGATING_RE: RegExp;
55
+ /** the plain reason a rule's amount is in a currency the page fact does not use; `readLimit` gives it and the check list reads it, one spelling */
56
+ export const WHY_OTHER_CURRENCY: "the amount is in another currency than the page fact";
55
57
  export function defaultCitedText(label: string): string;
58
+ export function defaultNoteText(n: number): string;
56
59
  export type ShapeRed = {
57
60
  code: string;
58
61
  path: string;
@@ -12,7 +12,7 @@ export function sheetFoundWords(check: any, claims: unknown): string | null;
12
12
  * older `close.columns` / `close.cited` check (then every guardrail is Not checked).
13
13
  * @param {{declaration: any, lines: Array<{n: number, rules?: string[], guardrail?: string, rule?: string}>, csvRoles?: string[], record?: any}} o
14
14
  * `record` = the `sheet` section of `line-checks.json` (`{lines: [...]}`), only after a run
15
- * @returns {Array<{line: number, guardrails: string[], checked: Array<{id: string, name: string, words: string, covers: string[], coversWords: string, text: string, ok?: boolean, found?: string}>, notChecked: string[]|'none'}>}
15
+ * @returns {Array<{line: number, codeBuilt: boolean, guardrails: string[], checked: Array<{id: string, name: string, words: string, covers: string[], coversWords: string, by: 'you'|'agent', text: string, ok?: boolean, found?: string}>, notChecked: string[]|'none'}>}
16
16
  */
17
17
  export function sheetLineBlocks({ declaration, lines, csvRoles, record }: {
18
18
  declaration: any;
@@ -26,6 +26,7 @@ export function sheetLineBlocks({ declaration, lines, csvRoles, record }: {
26
26
  record?: any;
27
27
  }): Array<{
28
28
  line: number;
29
+ codeBuilt: boolean;
29
30
  guardrails: string[];
30
31
  checked: Array<{
31
32
  id: string;
@@ -33,6 +34,7 @@ export function sheetLineBlocks({ declaration, lines, csvRoles, record }: {
33
34
  words: string;
34
35
  covers: string[];
35
36
  coversWords: string;
37
+ by: "you" | "agent";
36
38
  text: string;
37
39
  ok?: boolean;
38
40
  found?: string;
@@ -40,16 +42,19 @@ export function sheetLineBlocks({ declaration, lines, csvRoles, record }: {
40
42
  notChecked: string[] | "none";
41
43
  }>;
42
44
  /**
43
- * The guardrail rules of a sheet step that no check covers, as the drafter's Not-checked lines (`line N: "rule" - no sheet check covers it`): the block's own
45
+ * The guardrail rules of a sheet step that no check covers, as the drafter's Not-checked lines (`line N: "rule" - <reason>`): the block's own
44
46
  * `notChecked`, one list for the plan card and the drafter's saved record.
45
- * @param {any} declaration @param {Array<{n: number, rules?: string[], guardrail?: string, rule?: string}>} lines @param {string[]} csvRoles @returns {string[]}
47
+ * M17 am2: `built` (the builder's answer, src/sheetbuild.js) gives the reason a rule is Not checked (the refusal that named it).
48
+ * @param {any} declaration @param {Array<{n: number, rules?: string[], guardrail?: string, rule?: string}>} lines @param {string[]} csvRoles @param {{notChecked: Record<string, string>}} [built] @returns {string[]}
46
49
  */
47
50
  export function uncoveredRules(declaration: any, lines: Array<{
48
51
  n: number;
49
52
  rules?: string[];
50
53
  guardrail?: string;
51
54
  rule?: string;
52
- }>, csvRoles: string[]): string[];
55
+ }>, csvRoles: string[], built?: {
56
+ notChecked: Record<string, string>;
57
+ }): string[];
53
58
  /** @param {any} arbiter @returns {string[]} the roles of the signed sources that are a CSV file (the sheets a check reads) */
54
59
  export function csvRolesOf(arbiter: any): string[];
55
60
  /**
@@ -112,6 +117,8 @@ export const SHEET_OP_NAMES: Readonly<{
112
117
  rowCount: "row count";
113
118
  rowMath: "row math";
114
119
  }>;
120
+ export function isCodeBuiltId(id: unknown): boolean;
121
+ export function sheetByCheck(c: any, rules: string[]): "agent" | "you";
115
122
  export function rulesOfLine(l: any): string[];
116
123
  export function sheetPlainText(name: string, words: string, cw: string): string;
117
124
  export function coversWords(rules: string[]): string;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @param {any} ai a suggestion as the AI sent it @returns {{covers: number[], fields: Record<string, any>}}
3
+ */
4
+ export function toSuggestion(ai: any): {
5
+ covers: number[];
6
+ fields: Record<string, any>;
7
+ };
8
+ /**
9
+ * @typedef {{check: any, covers: number[]}} Placed
10
+ * @typedef {{rule: number, text: string, state: 'built'|'column'|'agent-row'|'not-checked', reason: string|null, id: string|null}} RuleState
11
+ * @param {{line: {n: number, text?: string, rules?: string[], guardrail?: string, rule?: string}, tables: Record<string, {header: string[], rows: any[]}>, suggestions: any[]}} o
12
+ * @returns {Promise<{rows: RuleState[], ruleRows: Placed[], agentRows: Placed[], checks: any[], refused: {helper: string, why: string}[]}>}
13
+ */
14
+ export function buildSheetLine({ line, tables, suggestions }: {
15
+ line: {
16
+ n: number;
17
+ text?: string;
18
+ rules?: string[];
19
+ guardrail?: string;
20
+ rule?: string;
21
+ };
22
+ tables: Record<string, {
23
+ header: string[];
24
+ rows: any[];
25
+ }>;
26
+ suggestions: any[];
27
+ }): Promise<{
28
+ rows: RuleState[];
29
+ ruleRows: Placed[];
30
+ agentRows: Placed[];
31
+ checks: any[];
32
+ refused: {
33
+ helper: string;
34
+ why: string;
35
+ }[];
36
+ }>;
37
+ /**
38
+ * The declaration with every green sheet step's `close.sheet` REWRITTEN by code from what the AI suggested there (`buildSheetLine`). A step with no suggestion is left alone; a step none of whose
39
+ * suggestions can be built loses `close.sheet` (its rules are Not checked with their reasons). Pure over the declaration it is given (a copy is returned).
40
+ * @param {{declaration: any, lines: {n: number, text?: string, rules?: string[], guardrail?: string, rule?: string}[], tables: Record<string, {header: string[], rows: any[]}>}} o
41
+ * @returns {Promise<{declaration: any, notChecked: Record<string, string>, refused: {line: number, helper: string, why: string}[], unbuilt: {line: number, lost: string[]}[]}>} `unbuilt`: the green sheet steps left with no check, each with its rules as Not-checked lines. `notChecked`: `line N: "rule"` -> the refusal that named it (or `NO_VALUE_WHY`), for each rule of a
42
+ * rewritten line that no check holds
43
+ */
44
+ export function buildSheetChecks({ declaration, lines, tables }: {
45
+ declaration: any;
46
+ lines: {
47
+ n: number;
48
+ text?: string;
49
+ rules?: string[];
50
+ guardrail?: string;
51
+ rule?: string;
52
+ }[];
53
+ tables: Record<string, {
54
+ header: string[];
55
+ rows: any[];
56
+ }>;
57
+ }): Promise<{
58
+ declaration: any;
59
+ notChecked: Record<string, string>;
60
+ refused: {
61
+ line: number;
62
+ helper: string;
63
+ why: string;
64
+ }[];
65
+ unbuilt: {
66
+ line: number;
67
+ lost: string[];
68
+ }[];
69
+ }>;
70
+ /** the fields of a suggestion code does not read: it names every check itself */
71
+ export const SUGGESTION_DROPPED: readonly string[];
72
+ export type Placed = {
73
+ check: any;
74
+ covers: number[];
75
+ };
76
+ export type RuleState = {
77
+ rule: number;
78
+ text: string;
79
+ state: "built" | "column" | "agent-row" | "not-checked";
80
+ reason: string | null;
81
+ id: string | null;
82
+ };
@@ -13,7 +13,8 @@ export function sheetCheckSentence(check: any): string;
13
13
  /**
14
14
  * M10b piece 4: a signed check may carry fwdloop's own `covers` (the numbers of the job line's `~` rules the drafter tagged it to; signed, so the person sees it).
15
15
  * bareguard does not know it, so the checks are cleaned HERE, the ONE place, on the way into bareguard (`createRubric` at sign time and at run time).
16
- * @param {any[]} checks @returns {any[]} a copy without `covers`
16
+ * M17 am3: `row` (fwdloop's own typed tag of a check code made an `[agent]` row) is cleaned here too.
17
+ * @param {any[]} checks @returns {any[]} a copy without `covers` and `row`
17
18
  */
18
19
  export function bareguardChecks(checks: any[]): any[];
19
20
  /**
@@ -12,8 +12,8 @@
12
12
  export function findColumn(csvText: string, word: string): FoundHeader | FoundAsk | FoundTie | FoundNone;
13
13
  /** a column fits when a plain number fills at least this share of the rows (F71 (b)) */
14
14
  export const FIT_RATIO: 0.9;
15
- export function columnQuestion(word: string, found: FoundAsk, line: number): string;
16
- export function columnTail(line: number): string;
15
+ export function columnQuestion(word: string, found: FoundAsk, line: number, tied?: boolean): string;
16
+ export function columnTail(line: number, tied?: boolean): string;
17
17
  /**
18
18
  * the word IS a column (nothing to ask)
19
19
  */
@@ -18,8 +18,33 @@ export function sheetOpsBrief(): string[];
18
18
  * The rules the validator enforces on `close.sheet`, as lines for the drafter (every one of them is a refusal at $0 in src/declaration.js / src/sheetchecks.js).
19
19
  * @param {string[]} roles the CSV input roles @returns {string[]}
20
20
  */
21
- export function sheetOfferRules(roles: string[]): string[];
21
+ export function sheetOfferRules(roles: string[], lineNums?: number[]): string[];
22
+ /**
23
+ * M17 am2 item 2: the row-edit reply's `sheetChecks` property: bareguard's `checkSchema` items (src/sheetoffer.js `sheetChecksProp`) plus the job line each suggestion is for. Typed suggestions only; code builds or refuses each.
24
+ * @param {Record<string, {header: string[]}>} tables @param {number[]} [lineNums] the job's sheet lines: `line` can only name one of them @returns {Record<string, any>|null}
25
+ */
26
+ export function sheetSuggestProp(tables: Record<string, {
27
+ header: string[];
28
+ }>, lineNums?: number[]): Record<string, any> | null;
22
29
  /** @param {unknown} rule @returns {boolean} true for the `use the column 'X' for 'Y'` rule an agreed column ask writes ({@link columnRuleWords}) */
23
30
  export function isColumnChoiceRule(rule: unknown): boolean;
31
+ /**
32
+ * M17 ruling 1 (hamr 2026-11-14): the parts of an agreed column rule (`use the column 'Amount' for 'Price'`), read from the words code wrote ({@link columnRuleWords}); null for any other text.
33
+ * @param {unknown} rule @returns {{column: string, word: string}|null}
34
+ */
35
+ export function columnChoiceParts(rule: unknown): {
36
+ column: string;
37
+ word: string;
38
+ } | null;
39
+ /**
40
+ * M17 ruling 1: the rule's own words with the job's word (case aside, whole word) swapped for the agreed column: "Price over 500" + Amount -> "Amount over 500". Null when the word is not in the rule.
41
+ * @param {string} text @param {string} word @param {string} column @returns {string|null}
42
+ */
43
+ export function swapColumnWord(text: string, word: string, column: string): string | null;
24
44
  /** The comparisons of a `where` condition, as bareguard's vocabulary lists them. */
25
45
  export const WHERE_CMPS: readonly any[];
46
+ export function agreedColumnWords(c: {
47
+ line: number;
48
+ word: string;
49
+ column: string;
50
+ }): string;
@@ -36,6 +36,14 @@ export function withSheetCard(card: {
36
36
  rows: any[];
37
37
  suggested: any[];
38
38
  };
39
+ /**
40
+ * M17 am3: the key of the check of the line that IS a dropped one (same typed fields; code names every check, so an id says nothing across drafts), or null. A Revise keeps a Drop only for the very same check.
41
+ * @param {any} declaration @param {{line: number, check: any}} d a record of `droppedSheetOf` @returns {string|null}
42
+ */
43
+ export function keyOfSameCheck(declaration: any, d: {
44
+ line: number;
45
+ check: any;
46
+ }): string | null;
39
47
  /**
40
48
  * The person's Drop or Add on a sheet row, applied to the declaration (a copy). Same words as the block's own refusals (src/checkblock.js `rowChoice`).
41
49
  * @param {{declaration: any, lines: any[], csvRoles: string[], op: 'drop'|'add', key: string, dropped: any[]}} o
@@ -9,61 +9,15 @@ export function ticketFactsLines(role: string): string[];
9
9
  /** the lines for a generic MCP job: the server, its tool names (so the drafter can grant them to steps), and the rule that a step lists a tool only if it calls it live @param {string} server @param {string[]} tools @returns {string[]} */
10
10
  export function mcpFactsLines(server: string, tools: string[]): string[];
11
11
  /**
12
- * The schema parts a job with an MCP adds (M13 piece 4): per-step `mcpTools` (an enum of the job's tool names) for MCP (generic) and Tickets, and for Tickets the top-level
13
- * `ticketFilter` and `ticketWatch`. The job's own `mcp` block and `flowType` are NOT offered: code sets them.
12
+ * The schema parts a job with an MCP adds (M13 piece 4): per-step `mcpTools` (an enum of the job's tool names) for MCP (generic) and Tickets, and no top-level `ticketFilter` or `ticketWatch` (M17 am6: they are checks on the list, suggested in the
13
+ * row-edit turn, src/rowedit.js; a draft that carries one is refused). The job's own `mcp` block and `flowType` are NOT offered: code sets them.
14
14
  * @param {{flowType: 'mcp'|'tickets', tools: string[]}} o
15
15
  */
16
16
  export function ticketSchemaParts({ flowType, tools }: {
17
17
  flowType: "mcp" | "tickets";
18
18
  tools: string[];
19
19
  }): {
20
- top: {
21
- ticketFilter?: undefined;
22
- ticketWatch?: undefined;
23
- };
24
- step: {
25
- mcpTools: {
26
- type: string;
27
- items: {
28
- type: string;
29
- enum: string[];
30
- };
31
- description: string;
32
- };
33
- };
34
- } | {
35
- top: {
36
- ticketFilter: {
37
- type: string;
38
- properties: {
39
- priority: {
40
- type: string;
41
- items: {
42
- type: string;
43
- enum: string[];
44
- };
45
- description: string;
46
- };
47
- labels: {
48
- type: string;
49
- items: {
50
- type: string;
51
- };
52
- description: string;
53
- };
54
- };
55
- additionalProperties: boolean;
56
- description: string;
57
- };
58
- ticketWatch: {
59
- type: string;
60
- items: {
61
- type: string;
62
- enum: string[];
63
- };
64
- description: string;
65
- };
66
- };
20
+ top: {};
67
21
  step: {
68
22
  mcpTools: {
69
23
  type: string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Which signed field a Tickets rule is the check of: `ticketWatch` (a state or labels change), `ticketFilter` (a priority P0 to P3 or a label), or null (a content rule or a count).
3
+ * @param {string} t the rule's words @returns {'ticketFilter'|'ticketWatch'|null}
4
+ */
5
+ export function ticketRuleField(t: string): "ticketFilter" | "ticketWatch" | null;
6
+ /**
7
+ * The reds of a suggested value, by the declaration's own readers (a stand-in declaration with an `mcp` block so only the value is judged). Empty = legal.
8
+ * @param {'ticketFilter'|'ticketWatch'} field @param {unknown} value @returns {string[]}
9
+ */
10
+ export function proposalReds(field: "ticketFilter" | "ticketWatch", value: unknown): string[];
11
+ /** the words a value is drawn with: the readout's own (src/authoring.js) @param {'ticketFilter'|'ticketWatch'} field @param {any} v */
12
+ export function ticketWords(field: "ticketFilter" | "ticketWatch", v: any): string;
13
+ /**
14
+ * The ticket rows of a Tickets declaration: one per `~` rule of a filter or watch kind. Built when the declaration holds that field; else Not checked (the person judges it at the Ask).
15
+ * @param {{declaration: any, lines: {n: number, guardrail?: string|null}[]}} o `lines` = the signed lines (a line's `guardrail` is its `; `-joined `~` rules)
16
+ * @returns {{signed: Record<string, any>[], card: {key: string, line: number, by: 'you', state: string, text: string, reason: string|null, drop: false}[], notChecked: {line: number, rule: string, reason: string}[]}}
17
+ */
18
+ export function ticketRowsOf({ declaration, lines }: {
19
+ declaration: any;
20
+ lines: {
21
+ n: number;
22
+ guardrail?: string | null;
23
+ }[];
24
+ }): {
25
+ signed: Record<string, any>[];
26
+ card: {
27
+ key: string;
28
+ line: number;
29
+ by: "you";
30
+ state: string;
31
+ text: string;
32
+ reason: string | null;
33
+ drop: false;
34
+ }[];
35
+ notChecked: {
36
+ line: number;
37
+ rule: string;
38
+ reason: string;
39
+ }[];
40
+ };
41
+ /**
42
+ * The list of a declaration with its ticket rows after the block's rows. A declaration with none keeps its list exactly as it was.
43
+ * @param {{declaration: any, lines: any[]}} o @returns {{declaration: any, tickets: ReturnType<typeof ticketRowsOf>}}
44
+ */
45
+ export function withTicketRows({ declaration, lines }: {
46
+ declaration: any;
47
+ lines: any[];
48
+ }): {
49
+ declaration: any;
50
+ tickets: ReturnType<typeof ticketRowsOf>;
51
+ };
52
+ /**
53
+ * The proof of a plan whose list has ticket rows (a plan with none is not examined): a built ticket row needs the declaration's field, and a field the declaration holds needs a built row for it.
54
+ * @param {any} declaration @returns {string[]}
55
+ */
56
+ export function ticketListReds(declaration: any): string[];
57
+ /** @type {readonly ('ticketFilter'|'ticketWatch')[]} */
58
+ export const TICKET_FIELDS: readonly ("ticketFilter" | "ticketWatch")[];
59
+ /** the Not-checked reason of a ticket rule no legal value was suggested for (the block's own noPick sentence is used by the caller's words) */
60
+ export const NO_VALUE_WHY: "No check was picked for it, so you judge it at the Ask.";
61
+ export function ticketRowKey(line: number, rule: number, field: string): string;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The index of the Ask that shows the whole job: the Ask the added send reads, only when the plan has the am8 added `write it out`. A job signed before am8
3
- * (its send line is the person's own words) finds -1 and keeps today's behaviour exactly.
2
+ * The index of the Ask that shows the whole job: the Ask right before the action, when the plan has it read EVERY work step before it (what `readEveryStep` writes into a plan
3
+ * drafted from M13 am9 on). A plan signed with that Ask reading one step (a job signed before am9) finds -1 and keeps today's behaviour exactly: a stored plan is never reinterpreted.
4
4
  * @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
5
5
  * @returns {number} -1 = none
6
6
  */
@@ -49,7 +49,7 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }: {
49
49
  };
50
50
  /**
51
51
  * M13 am9 item 4: the plan shows the last Ask as reading every step. Code sets the Ask's `reads` to every work step's emits before it (the nearest one first, so a
52
- * redo still re-runs the step just before the Ask; the rest in job order). Only a plan with the am8 added end; any other plan comes back as it was.
52
+ * redo still re-runs the step just before the Ask; the rest in job order). Only for the Ask right before the action; any other plan comes back as it was.
53
53
  * @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
54
54
  * @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
55
55
  * @returns {S[]}