fwdloop 0.32.0 → 0.34.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 (114) hide show
  1. package/bin/fwdloop +20 -2
  2. package/package.json +2 -2
  3. package/src/auditchecks.js +55 -0
  4. package/src/authoring.js +53 -12
  5. package/src/blockasks.js +45 -0
  6. package/src/blockassemble.js +159 -0
  7. package/src/blockdraft.js +86 -0
  8. package/src/blocklines.js +30 -0
  9. package/src/blockpick.js +175 -0
  10. package/src/cardlist.js +19 -0
  11. package/src/checkblock.js +843 -0
  12. package/src/checked.js +48 -9
  13. package/src/checklist.js +99 -0
  14. package/src/checklistsign.js +93 -0
  15. package/src/checkpick.js +7 -73
  16. package/src/checkwords.js +20 -1
  17. package/src/cited-record.js +21 -1
  18. package/src/citedcheck.js +162 -7
  19. package/src/closers.js +41 -3
  20. package/src/declaration.js +34 -9
  21. package/src/declaredclose.js +4 -0
  22. package/src/draft-steps.js +3 -1
  23. package/src/drafter.js +311 -206
  24. package/src/factwords.js +112 -0
  25. package/src/inputlook.js +53 -0
  26. package/src/labelscan.js +162 -0
  27. package/src/noteask.js +62 -0
  28. package/src/pageask.js +9 -69
  29. package/src/pagedropwords.js +11 -1
  30. package/src/pagedry.js +27 -4
  31. package/src/pagerules.js +19 -3
  32. package/src/panel/author.js +76 -7
  33. package/src/panel/authorcard.js +43 -17
  34. package/src/panel/data.js +41 -9
  35. package/src/panel/index.html +208 -13
  36. package/src/panel/result.js +4 -3
  37. package/src/panel/server.js +3 -1
  38. package/src/pickrecord.js +70 -54
  39. package/src/placerule.js +398 -0
  40. package/src/planrebuild.js +216 -0
  41. package/src/rowedit.js +148 -0
  42. package/src/rubricstep.js +272 -0
  43. package/src/runfile.js +4 -2
  44. package/src/runner.js +67 -10
  45. package/src/setup.js +11 -5
  46. package/src/sheetblock.js +22 -8
  47. package/src/sheetbuild.js +151 -0
  48. package/src/sheetchecks.js +52 -66
  49. package/src/sheetclaims.js +12 -32
  50. package/src/sheetfind.js +4 -4
  51. package/src/sheetlook.js +14 -3
  52. package/src/sheetoffer.js +74 -57
  53. package/src/sheetrows.js +123 -0
  54. package/src/sheetrun.js +13 -10
  55. package/src/summary-words.js +3 -3
  56. package/src/ticket-draft.js +4 -21
  57. package/src/ticketrows.js +100 -0
  58. package/src/try-checks.js +31 -12
  59. package/src/types.js +1 -0
  60. package/types/auditchecks.d.ts +25 -0
  61. package/types/authoring.d.ts +21 -2
  62. package/types/blockasks.d.ts +36 -0
  63. package/types/blockassemble.d.ts +50 -0
  64. package/types/blockdraft.d.ts +75 -0
  65. package/types/blocklines.d.ts +31 -0
  66. package/types/blockpick.d.ts +46 -0
  67. package/types/cardlist.d.ts +21 -0
  68. package/types/checkblock.d.ts +378 -0
  69. package/types/checked.d.ts +16 -2
  70. package/types/checklist.d.ts +115 -0
  71. package/types/checklistsign.d.ts +27 -0
  72. package/types/checkpick.d.ts +4 -34
  73. package/types/checkwords.d.ts +5 -0
  74. package/types/cited-record.d.ts +9 -0
  75. package/types/citedcheck.d.ts +33 -2
  76. package/types/closers.d.ts +24 -2
  77. package/types/declaration.d.ts +7 -0
  78. package/types/declaredclose.d.ts +2 -0
  79. package/types/drafter.d.ts +29 -715
  80. package/types/factwords.d.ts +38 -0
  81. package/types/inputlook.d.ts +49 -0
  82. package/types/labelscan.d.ts +35 -0
  83. package/types/noteask.d.ts +52 -0
  84. package/types/pageask.d.ts +2 -35
  85. package/types/pagedry.d.ts +13 -0
  86. package/types/pagerules.d.ts +7 -0
  87. package/types/panel/author.d.ts +41 -0
  88. package/types/panel/authorcard.d.ts +14 -9
  89. package/types/panel/authorflows.d.ts +4 -4
  90. package/types/panel/data.d.ts +5 -3
  91. package/types/panel/jobgrid.d.ts +1 -1
  92. package/types/pickrecord.d.ts +69 -13
  93. package/types/placerule.d.ts +208 -0
  94. package/types/planrebuild.d.ts +52 -0
  95. package/types/provider.d.ts +1 -1
  96. package/types/rowedit.d.ts +48 -0
  97. package/types/rubricstep.d.ts +63 -0
  98. package/types/runfile.d.ts +5 -2
  99. package/types/runner.d.ts +45 -1
  100. package/types/sheetblock.d.ts +12 -4
  101. package/types/sheetbuild.d.ts +84 -0
  102. package/types/sheetchecks.d.ts +12 -18
  103. package/types/sheetclaims.d.ts +2 -1
  104. package/types/sheetfind.d.ts +2 -2
  105. package/types/sheetoffer.d.ts +31 -6
  106. package/types/sheetrows.d.ts +81 -0
  107. package/types/sheetrun.d.ts +4 -4
  108. package/types/summary-words.d.ts +2 -1
  109. package/types/ticket-draft.d.ts +3 -49
  110. package/types/ticketrows.d.ts +61 -0
  111. package/types/try-checks.d.ts +4 -2
  112. package/types/types.d.ts +8 -0
  113. package/src/repairs.js +0 -38
  114. package/types/repairs.d.ts +0 -13
@@ -0,0 +1,123 @@
1
+ // M16 am4 (docs/wiki/the-module-ladder.md, "M16 amendment 4" (2)): a sheet line's checks (`close.sheet`) are rows on the plan's list, beside every other check.
2
+ // The AI writes the sheet checks (M10b); code only READS them as rows: this file is the ONE writer of a sheet row, of its tag and of its card text, and of the Drop and Add of one.
3
+ // tag a check whose `covers` names one of the person's `~` rules is `[you]`; a check that covers none (the AI added it) is `[agent]`. (A `[default]` sheet check does not exist: no code adds one.)
4
+ // Drop only an `[agent]` row; the check leaves `close.sheet` and is kept in the picks record (`sheetDropped`) so Add can put it back. A `[you]` row has no Drop.
5
+ // Add puts a dropped check back at the place it had.
6
+ // Words are fwd's existing sheet-check words (src/sheetblock.js `sheetPlainText`); nothing here words a check. What this throws away: the check's fields (id, claim, range ...); a row keeps its line, tag, part and key.
7
+ import { sheetLineBlocks, sheetPlainText } from './sheetblock.js';
8
+ import { closePartsOf } from './checklistsign.js';
9
+ import { isDeepStrictEqual } from 'node:util';
10
+
11
+ const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
12
+
13
+ /** the key of a sheet row: the block's `L<line>.<tail>` shape, tail `sheet.<check id>` @param {number} line @param {string} id */
14
+ export const sheetRowKey = (line, id) => `L${line}.sheet.${id}`;
15
+ /** @param {unknown} key @returns {boolean} the key is a sheet row's */
16
+ export const isSheetKey = (key) => typeof key === 'string' && key.startsWith('L') && key.includes('.sheet.');
17
+
18
+ /**
19
+ * The sheet rows of a declaration, read from its steps' `close.sheet`: the signed rows (for `declaration.checkList`) and the card rows (words, tag, whether a Drop is offered).
20
+ * @param {{declaration: any, lines: any[], csvRoles: string[]}} o
21
+ * @returns {{signed: Record<string, any>[], card: {key: string, line: number, by: 'you'|'agent', state: 'built', text: string, reason: null, drop: boolean}[]}}
22
+ */
23
+ export function sheetRowsOf({ declaration, lines, csvRoles }) {
24
+ /** @type {Record<string, any>[]} */
25
+ const signed = [];
26
+ /** @type {any[]} */
27
+ const card = [];
28
+ const steps = isRec(declaration) && Array.isArray(declaration.steps) ? declaration.steps : [];
29
+ steps.forEach((st, i) => {
30
+ if (!isRec(st) || !isRec(st.close) || st.close.class !== 'green' || !Array.isArray(st.close.sheet) || st.close.sheet.length === 0 || !Number.isInteger(st.fromLine)) return;
31
+ // the parts the earlier steps of this line have, then this step's own (the fact, the picks, the tie) come before its sheet checks (src/checklistsign.js `closePartsOf`)
32
+ const before = steps.slice(0, i).filter((x) => isRec(x) && x.fromLine === st.fromLine).reduce((n, x) => n + closePartsOf(x, true).length, 0);
33
+ const own = closePartsOf({ ...st, close: { ...st.close, sheet: undefined } }).length;
34
+ const block = sheetLineBlocks({ declaration: { steps: [st] }, lines, csvRoles })[0];
35
+ if (!block) return;
36
+ block.checked.forEach((e, j) => {
37
+ const by = /** @type {'you'|'agent'} */ (e.by);
38
+ const key = sheetRowKey(st.fromLine, e.id);
39
+ const nums = Array.isArray(st.close.sheet[j]?.covers) ? st.close.sheet[j].covers.filter((/** @type {unknown} */ x) => Number.isInteger(x) && /** @type {number} */ (x) >= 1 && /** @type {number} */ (x) <= block.guardrails.length) : [];
40
+ signed.push({
41
+ line: st.fromLine, key, from: by === 'you' ? 'rule' : 'agent', by, kind: 'sheet', state: 'built',
42
+ ...(by === 'you' ? { rule: Math.min(...nums) } : {}), part: { line: st.fromLine, part: before + own + j },
43
+ });
44
+ card.push({ key, line: st.fromLine, by, state: 'built', text: sheetPlainText(e.name, e.words, e.coversWords), reason: null, drop: by === 'agent' });
45
+ });
46
+ });
47
+ return { signed, card };
48
+ }
49
+
50
+ /**
51
+ * The plan's card with the sheet rows on it: the sheet rows after the block's rows, a dropped sheet check among the suggestions (Add), as the block's dropped suggestions are.
52
+ * @param {{rows: any[], suggested: any[]}} card the block's card (src/cardlist.js) @param {{card: any[]}} sheet `sheetRowsOf` @param {{key: string, line: number, text: string}[]} [dropped]
53
+ */
54
+ export function withSheetCard(card, sheet, dropped = []) {
55
+ return { ...card, rows: [...card.rows, ...sheet.card], suggested: [...card.suggested, ...dropped.map((d) => ({ key: d.key, line: d.line, text: d.text, dropped: true }))] };
56
+ }
57
+
58
+ /** the dropped sheet checks the picks record keeps: `{key, line, index, check, text}` @returns {any[]} */
59
+ export const droppedSheetOf = (/** @type {any} */ record) => (isRec(record) && Array.isArray(record.sheetDropped) ? record.sheetDropped.filter((d) => isRec(d) && typeof d.key === 'string' && isRec(d.check) && Number.isInteger(d.line)) : []);
60
+
61
+ /** the fields that say what a check is: all but the names code gives it (id, claim) and the rules it covers */
62
+ const checkBody = (/** @type {any} */ c) => { const { id: _i, claim: _c, covers: _v, ...rest } = c; return rest; };
63
+
64
+ /**
65
+ * 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.
66
+ * @param {any} declaration @param {{line: number, check: any}} d a record of `droppedSheetOf` @returns {string|null}
67
+ */
68
+ export function keyOfSameCheck(declaration, d) {
69
+ for (const st of isRec(declaration) && Array.isArray(declaration.steps) ? declaration.steps : []) {
70
+ if (!isRec(st) || st.fromLine !== d.line || !isRec(st.close) || !Array.isArray(st.close.sheet)) continue;
71
+ const hit = st.close.sheet.find((/** @type {any} */ c) => isRec(c) && isDeepStrictEqual(checkBody(c), checkBody(d.check)));
72
+ if (hit) return sheetRowKey(d.line, String(hit.id));
73
+ }
74
+ return null;
75
+ }
76
+
77
+ /**
78
+ * 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`).
79
+ * @param {{declaration: any, lines: any[], csvRoles: string[], op: 'drop'|'add', key: string, dropped: any[]}} o
80
+ * @returns {{ok: true, declaration: any, dropped: any[]}|{ok: false, why: string}}
81
+ */
82
+ export function sheetChoice({ declaration, lines, csvRoles, op, key, dropped }) {
83
+ if (op === 'drop') {
84
+ const row = sheetRowsOf({ declaration, lines, csvRoles }).card.find((r) => r.key === key);
85
+ if (!row) return { ok: false, why: 'there is no such check on the list' };
86
+ if (row.by === 'you') return { ok: false, why: 'that check comes from a rule you wrote; edit the job to change it' };
87
+ let gone = null;
88
+ const steps = declaration.steps.map((/** @type {any} */ st) => {
89
+ if (gone !== null || !isRec(st) || st.fromLine !== row.line || !isRec(st.close) || !Array.isArray(st.close.sheet)) return st;
90
+ const index = st.close.sheet.findIndex((/** @type {any} */ c) => isRec(c) && sheetRowKey(row.line, String(c.id)) === key);
91
+ if (index === -1) return st;
92
+ gone = { key, line: row.line, index, check: st.close.sheet[index], text: row.text };
93
+ const sheet = st.close.sheet.filter((/** @type {unknown} */ _c, /** @type {number} */ k) => k !== index);
94
+ const { sheet: _s, ...close } = st.close;
95
+ return { ...st, close: sheet.length > 0 ? { ...close, sheet } : close };
96
+ });
97
+ if (gone === null) return { ok: false, why: 'there is no such check on the list' };
98
+ return { ok: true, declaration: { ...declaration, steps }, dropped: [...dropped.filter((d) => d.key !== key), gone] };
99
+ }
100
+ const was = dropped.find((d) => d.key === key);
101
+ if (!was) return { ok: false, why: 'only a suggested check can be added' };
102
+ let put = false;
103
+ const steps = declaration.steps.map((/** @type {any} */ st) => {
104
+ if (put || !isRec(st) || st.fromLine !== was.line || !isRec(st.close) || st.close.class !== 'green') return st;
105
+ put = true;
106
+ const sheet = Array.isArray(st.close.sheet) ? [...st.close.sheet] : [];
107
+ sheet.splice(Math.min(was.index, sheet.length), 0, was.check);
108
+ return { ...st, close: { ...st.close, sheet } };
109
+ });
110
+ if (!put) return { ok: false, why: 'only a suggested check can be added' };
111
+ return { ok: true, declaration: { ...declaration, steps }, dropped: dropped.filter((d) => d.key !== key) };
112
+ }
113
+
114
+ /**
115
+ * The list of a declaration with its sheet rows: the block's rows first, then the sheet rows. A declaration with no sheet check keeps the list exactly as it was.
116
+ * @param {{declaration: any, lines: any[], csvRoles: string[]}} o @returns {{declaration: any, sheet: ReturnType<typeof sheetRowsOf>}}
117
+ */
118
+ export function withSheetRows({ declaration, lines, csvRoles }) {
119
+ const { checkList: _old, ...rest } = declaration;
120
+ const base = Array.isArray(declaration.checkList) ? declaration.checkList.filter((/** @type {any} */ r) => !(isRec(r) && r.kind === 'sheet')) : [];
121
+ const sheet = sheetRowsOf({ declaration: rest, lines, csvRoles });
122
+ return { declaration: sheet.signed.length === 0 ? declaration : { ...declaration, checkList: [...base, ...sheet.signed] }, sheet };
123
+ }
package/src/sheetrun.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // `tableSha` (bareguard stops the check; the red names the input), any other stopped check.
7
7
  // Throws away: bareguard's `full` (expected values, evidence) is not kept - the red keeps the gaps, which name rows and counts and never a cell's text.
8
8
  import { basename } from 'node:path';
9
- import { createRubric, checkStep, renderGaps, tableSha } from 'bareguard';
9
+ import { createRubric, checkStep, runTableChecks, renderGaps, tableSha } from 'bareguard';
10
10
  import { parseCsv, sheetTable } from './csv.js';
11
11
  import { readFileInside } from './flow.js';
12
12
  import { readRunInputs } from './runfile.js';
@@ -105,10 +105,10 @@ export async function closeSheet(checks, artifact, sheet) {
105
105
  }
106
106
 
107
107
  /**
108
- * M10b am5: the `table` checks of a draft that already fail on the sheet the draft was made with. A table check judges the sheet itself, so bareguard's `checkStep` (the
109
- * run's own judge, `closeSheet`) can run it before anything is spent: $0, no model call. Only `table` checks run; a cells check judges the step's answer and never runs here.
110
- * Each check is read by its id, so bareguard's own `happened` check never counts; the answer handed over is non-empty, because an EMPTY one stops bareguard at `happened` before any
111
- * table check runs (the check would then read as passing).
108
+ * M10b am5: the `table` checks of a draft that already fail on the sheet the draft was made with. A table check judges the sheet itself, so bareguard's `runTableChecks`
109
+ * (the same evaluation path as the run's `checkStep`) can run it before anything is spent: $0, no model call, no answer needed. Only `table` checks run; a cells check judges
110
+ * the step's answer and never runs here. Each check is its own rubric, read by its id. Only a `red` verdict is a red here: a `stopped` check (bareguard could not read the
111
+ * sheet) or a rubric bareguard refuses is not reported (the draft's own sheet look and sheetCheckReds have said so).
112
112
  * @param {any} declaration the draft @param {Record<string, {header: string[], rows: any[]}>} tables the draft-time table of each CSV input, by role
113
113
  * @returns {Promise<string[]>} one red per failing check, in plan order
114
114
  */
@@ -120,11 +120,14 @@ export async function tableChecksFailingOnInput(declaration, tables) {
120
120
  if (!isRec(c) || c.rule !== 'table' || typeof c.table !== 'string' || !isRec(tables[c.table])) continue;
121
121
  const sha = tableSha(tables[c.table]);
122
122
  if (sha === null) continue; // bareguard cannot read the sheet as a table: the draft's own sheet look has said so
123
- const sheet = { ok: /** @type {const} */ (true), tables: { [c.table]: tables[c.table] }, inputs: [{ name: c.table, sha256: sha }] };
124
- const v = /** @type {any} */ (await closeSheet([c], { done: true }, sheet));
125
- const row = Array.isArray(v.checks) ? v.checks.find((/** @type {any} */ r) => r.id === c.id) : undefined;
126
- if (!row || row.ok) continue;
127
- const what = String(row.result).startsWith(`${c.id}: `) ? String(row.result).slice(c.id.length + 2) : String(row.result);
123
+ let row;
124
+ try {
125
+ const rubric = createRubric({ schema: 1, goal: 'sheet', inputs: [{ name: c.table, sha256: sha }], checkpoints: { sheet: { gating: true, checks: bareguardChecks([c]) } }, maxReds: 3 });
126
+ row = runTableChecks(rubric, 'sheet', { [c.table]: tables[c.table] }).find((r) => r.id === c.id);
127
+ } catch { continue; }
128
+ if (!row || row.verdict !== 'red') continue;
129
+ const gaps = renderGaps(row.gaps);
130
+ const what = gaps.startsWith(`${c.id}: `) ? gaps.slice(c.id.length + 2) : gaps;
128
131
  reds.push(`line ${s.fromLine}: the table check "${sheetCheckName(c)}" already fails on the input "${c.table}" (${what}), so this step could never pass. A table check judges the input sheet itself; to check what the step gives, use a cells check.`);
129
132
  }
130
133
  }
@@ -132,12 +132,12 @@ const splitNext = (rows) => ({ next: rows.map(([l, t]) => `${l} ${t}`).join('\n'
132
132
  /**
133
133
  * ENDED / NEXT of a finished run. Every outcome the history row can hold has a fixed sentence; an unknown one gets an honest fixed fallback
134
134
  * that names the code and guesses nothing. `null` when there is no ending (still running, waiting, or no history row and not died).
135
- * @param {{outcome: string|null, died?: boolean, line: number|null, destination: string|null, canResume: boolean, home?: string, skipReason?: string}} f
135
+ * @param {{outcome: string|null, died?: boolean, line: number|null, destination: string|null, canResume: boolean, home?: string, skipReason?: string, anywayOffered?: boolean}} f
136
136
  * @returns {{reason: string, next: string, rows?: Array<[string, string]>}|null}
137
137
  */
138
138
  export function endedWords(f) {
139
139
  const {
140
- outcome, died = false, line, destination, canResume, home, skipReason,
140
+ outcome, died = false, line, destination, canResume, home, skipReason, anywayOffered = true,
141
141
  } = f;
142
142
  const resumeOrAgain = canResume ? 'Resume from the Chat card.' : RERUN_NEXT;
143
143
  if (died) return { reason: 'It stopped with no ending recorded.', next: 'See the Audit / logs tab for the last thing it did.' };
@@ -146,7 +146,7 @@ export function endedWords(f) {
146
146
  case 'complete':
147
147
  return { reason: 'Goal met.', next: destination ? `The result is in ${tilde(destination, home)}.` : 'The result is in the step cards below.' };
148
148
  case 'skipped':
149
- return { reason: `Skipped: ${typeof skipReason === 'string' && skipReason !== '' ? skipReason : 'the ticket did not match'}. Nothing was spent.`, next: 'Nothing to do. Run it anyway from the ticket list in the Result tab.' };
149
+ return { reason: `Skipped: ${typeof skipReason === 'string' && skipReason !== '' ? skipReason : 'the ticket did not match'}. Nothing was spent.`, next: anywayOffered === false ? 'Nothing to do.' : 'Nothing to do. Run it anyway from the ticket list in the Result tab.' };
150
150
  case 'stopped':
151
151
  return { reason: 'Stopped by you.', next: resumeOrAgain };
152
152
  case 'cap-halt':
@@ -1,6 +1,6 @@
1
1
  // M12 piece 3 (docs/wiki/the-module-ladder.md, "M12 scope (restart)" item 4): what the DRAFTER is told about a ticket role, and what it may suggest.
2
2
  // A ticket role is a signed page input (`source <role> = page:<address>`) whose address is a GitHub issues list: it is never fetched at draft (one ticket is read
3
- // per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read), and MUST add a `ticketFilter` (priority / label names) when a guardrail names a priority or a label; a human
3
+ // per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read), and (M17 am6) suggests the `ticketFilter` / `ticketWatch` as an edit of the list's row-edit turn, never as a top-level field; code proves it (src/ticketrows.js), a human
4
4
  // signs it and code decides at run. The first facts line is F90c's, the line that made the drafter read a ticket role at all (FINDINGS F90c, F92).
5
5
  import { discoverServers } from 'bare-agent/mcp';
6
6
  import { startableMcpServers } from './mcp-sources.js';
@@ -30,8 +30,6 @@ export function ticketFactsLines(role) {
30
30
  `- ${role}: one ticket's text (a signed input, already frozen at run start; read it by listing "${role}" in a step's reads, do not fetch it)`,
31
31
  ` A step that reads "${role}" still lists "read" in its primitives: the ticket is frozen, but reading it is a grant.`,
32
32
  ` Flow type: Tickets. The ticket is already frozen under "${role}" by the job's own tools ("${TICKET_TOOL}" reads it, "${LOOK_TOOL}" looks for new ones); no step needs them. A step lists a tool in "mcpTools" ONLY if that step calls the tool live; leave "mcpTools" out of every other step. The job's server and tool list are set by the program, not by you.`,
33
- ' When a guardrail names a priority or a label (for example "priority P1 only", "only tickets with priority P1 count", "only issues labelled bug"), you MUST add a top-level "ticketFilter": {"priority": [P0 to P3 values], "labels": [label names]} for it; leave it out only when no guardrail names a priority or a label, and such a guardrail stays hitl. A human signs it and code decides at run; never invent a label.',
34
- ' You may SUGGEST a top-level "ticketWatch": ["state", "labels"] (one or both) ONLY for a guardrail that says to run a ticket again when its state or its labels change. Any other thing to watch cannot be put there: leave it out and it stays hitl.',
35
33
  ];
36
34
  }
37
35
 
@@ -47,28 +45,13 @@ export function mcpFactsLines(server, tools) {
47
45
  export const LOOK_TOOL = 'list_issues';
48
46
 
49
47
  /**
50
- * 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
51
- * `ticketFilter` and `ticketWatch`. The job's own `mcp` block and `flowType` are NOT offered: code sets them.
48
+ * 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
49
+ * 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.
52
50
  * @param {{flowType: 'mcp'|'tickets', tools: string[]}} o
53
51
  */
54
52
  export function ticketSchemaParts({ flowType, tools }) {
55
53
  const step = { mcpTools: { type: 'array', items: { type: 'string', enum: tools }, description: 'the MCP tools this step calls LIVE (exact names); omit on every step that calls none' } };
56
- if (flowType !== 'tickets') return { top: {}, step };
57
- return {
58
- top: {
59
- ticketFilter: {
60
- type: 'object',
61
- properties: {
62
- priority: { type: 'array', items: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] }, description: 'priorities a ticket must have; only when a guardrail names them' },
63
- labels: { type: 'array', items: { type: 'string' }, description: 'label names, one of which a ticket must carry; only when a guardrail names them' },
64
- },
65
- additionalProperties: false,
66
- description: 'required when a guardrail names a priority or a label: put those values here; leave it out only when no guardrail names one',
67
- },
68
- ticketWatch: { type: 'array', items: { type: 'string', enum: ['state', 'labels'] }, description: 'optional: suggest only for a guardrail that says to run a ticket again when its state or its labels change' },
69
- },
70
- step,
71
- };
54
+ return { top: {}, step };
72
55
  }
73
56
 
74
57
  /**
@@ -0,0 +1,100 @@
1
+ // M17 am6 (docs/wiki/the-module-ladder.md): a Tickets `~` rule about which tickets to take ("priority P1 only") or what to watch ("run a ticket again when its state changes") is a ROW on the list.
2
+ // Its check is the job's `ticketFilter` or `ticketWatch`. The AI suggests the value as an edit of the row-edit turn (src/rowedit.js); code proves it with the declaration's own readers
3
+ // (src/declaration.js checkTicketFilter / checkTicketWatch) and writes the declaration's field from it, only when a rule of that kind is on the job. This file is the ONE writer of a ticket row,
4
+ // its signed fields, its card words and its proof. A job with no ticket rows (a plan signed before M17) is not examined: its filter and watch run exactly as signed.
5
+ // What this throws away: the filter's and watch's values (they stay in the declaration); a row keeps its line, rule number, tag, state and reason.
6
+ import { checkTicketFilter, checkTicketWatch, isCountGuardrail } from './declaration.js';
7
+
8
+ const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
9
+
10
+ /** @type {readonly ('ticketFilter'|'ticketWatch')[]} */
11
+ export const TICKET_FIELDS = Object.freeze(['ticketFilter', 'ticketWatch']);
12
+ /** 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) */
13
+ export const NO_VALUE_WHY = 'No check was picked for it, so you judge it at the Ask.';
14
+
15
+ /**
16
+ * 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).
17
+ * @param {string} t the rule's words @returns {'ticketFilter'|'ticketWatch'|null}
18
+ */
19
+ export function ticketRuleField(t) {
20
+ if (isCountGuardrail(t)) return null;
21
+ if (/\b(?:state|labels)\b[^;]*\bchange/i.test(t)) return 'ticketWatch';
22
+ if (/\bp[0-3]\b/i.test(t) || /\blabel(?:l?ed|s)?\b/i.test(t)) return 'ticketFilter';
23
+ return null;
24
+ }
25
+
26
+ /**
27
+ * 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.
28
+ * @param {'ticketFilter'|'ticketWatch'} field @param {unknown} value @returns {string[]}
29
+ */
30
+ export function proposalReds(field, value) {
31
+ /** @type {string[]} */
32
+ const reds = [];
33
+ const d = { mcp: {}, [field]: value };
34
+ if (field === 'ticketFilter') checkTicketFilter(d, reds); else checkTicketWatch(d, reds);
35
+ return reds;
36
+ }
37
+
38
+ /** the words a value is drawn with: the readout's own (src/authoring.js) @param {'ticketFilter'|'ticketWatch'} field @param {any} v */
39
+ export function ticketWords(field, v) {
40
+ if (field === 'ticketWatch') return `ticket watch: ${(Array.isArray(v) ? v : []).join(', ')}`;
41
+ const parts = [...(v?.priority?.length ? [`priority ${v.priority.join(', ')}`] : []), ...(v?.labels?.length ? [`labels ${v.labels.join(', ')}`] : [])];
42
+ return `ticket filter: ${parts.join(' · ')}`;
43
+ }
44
+
45
+ /** the key of a ticket row @param {number} line @param {number} rule @param {string} field */
46
+ export const ticketRowKey = (line, rule, field) => `L${line}.ticket.${field}.${rule}`;
47
+
48
+ /**
49
+ * 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).
50
+ * @param {{declaration: any, lines: {n: number, guardrail?: string|null}[]}} o `lines` = the signed lines (a line's `guardrail` is its `; `-joined `~` rules)
51
+ * @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}[]}}
52
+ */
53
+ export function ticketRowsOf({ declaration, lines }) {
54
+ /** @type {Record<string, any>[]} */ const signed = [];
55
+ /** @type {any[]} */ const card = [];
56
+ /** @type {{line: number, rule: string, reason: string}[]} */ const notChecked = [];
57
+ if (!isRec(declaration) || declaration.flowType !== 'tickets') return { signed, card, notChecked };
58
+ for (const l of lines) {
59
+ const rules = typeof l.guardrail === 'string' ? l.guardrail.split('; ').map((s) => s.trim()).filter(Boolean) : [];
60
+ rules.forEach((t, i) => {
61
+ const field = ticketRuleField(t);
62
+ if (field === null) return;
63
+ const key = ticketRowKey(l.n, i + 1, field);
64
+ const has = Object.hasOwn(declaration, field);
65
+ signed.push({ line: l.n, key, from: 'rule', by: 'you', kind: 'ticket', state: has ? 'built' : 'not-checked', rule: i + 1, field, ...(has ? {} : { reason: NO_VALUE_WHY }) });
66
+ card.push({ key, line: l.n, by: 'you', state: has ? 'built' : 'not-checked', text: has ? `"${t}" -> ${ticketWords(field, declaration[field])}` : `"${t}"`, reason: has ? null : NO_VALUE_WHY, drop: false });
67
+ if (!has) notChecked.push({ line: l.n, rule: t, reason: NO_VALUE_WHY });
68
+ });
69
+ }
70
+ return { signed, card, notChecked };
71
+ }
72
+
73
+ /**
74
+ * 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.
75
+ * @param {{declaration: any, lines: any[]}} o @returns {{declaration: any, tickets: ReturnType<typeof ticketRowsOf>}}
76
+ */
77
+ export function withTicketRows({ declaration, lines }) {
78
+ const base = Array.isArray(declaration.checkList) ? declaration.checkList.filter((/** @type {any} */ r) => !(isRec(r) && r.kind === 'ticket')) : undefined;
79
+ const tickets = ticketRowsOf({ declaration, lines });
80
+ if (tickets.signed.length === 0) return { declaration, tickets };
81
+ return { declaration: { ...declaration, checkList: [...(base ?? []), ...tickets.signed] }, tickets };
82
+ }
83
+
84
+ /**
85
+ * 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.
86
+ * @param {any} declaration @returns {string[]}
87
+ */
88
+ export function ticketListReds(declaration) {
89
+ const list = isRec(declaration) && Array.isArray(declaration.checkList) ? declaration.checkList.filter((/** @type {any} */ r) => isRec(r) && r.kind === 'ticket') : [];
90
+ if (list.length === 0) return [];
91
+ /** @type {string[]} */
92
+ const reds = [];
93
+ for (const f of TICKET_FIELDS) {
94
+ const built = list.some((/** @type {any} */ r) => r.field === f && r.state === 'built');
95
+ const has = Object.hasOwn(declaration, f);
96
+ if (built && !has) reds.push(`declaration: checkList: a row says "${f}" is its check, but the plan has no "${f}". Nothing was signed - draft again.`);
97
+ if (has && !built) reds.push(`declaration: "${f}" is not the check of any rule on the list. Nothing was signed - draft again.`);
98
+ }
99
+ return reds;
100
+ }
package/src/try-checks.js CHANGED
@@ -4,8 +4,12 @@
4
4
  import { createHash } from 'node:crypto';
5
5
  import { serializeArtifact } from './ask.js';
6
6
  import { labelled } from './checkwords.js';
7
+ import { sheetRowKey } from './sheetrows.js';
8
+ import { listLinesOf, partByOf } from './checklistsign.js';
7
9
 
8
10
  export const EVERY_STEP = 'every step';
11
+ /** the words of the two checks every step has (#1 and #2 below): the Audit's "Always checked" rows, the plan card's and the Job tab's "Always checked" fold */
12
+ export const EVERY_STEP_TEXTS = Object.freeze(["the output exists and isn't empty", 'the model said done: true']);
9
13
 
10
14
  /** The size words of a byte count: `412 B`, `7.9 KB`, `1.2 MB`. @param {number} n */
11
15
  export function sizeWords(n) {
@@ -42,17 +46,26 @@ export function outputRecord(step, artifact) {
42
46
  /**
43
47
  * #3 and up: the close's own checks. A softgreen close carries each of its checks; a green close is one check over all its cited fields; a close that
44
48
  * judged nothing (`unparseable`, `crash`) is one check that could not run, with that third outcome as its result.
45
- * @param {any} step @param {any} artifact @param {{verdict: string, red?: string|null, checks?: Array<{text:string, ok:boolean, result:string|null}>}} closed
49
+ * @param {any} step @param {any} artifact @param {{verdict: string, red?: string|null, checks?: Array<{text:string, ok:boolean, result:string|null}>}} closed @param {any[]} [checkList] the signed list (M16): a line on it tags its checks
46
50
  */
47
- export function closeRecords(step, artifact, closed) {
48
- const rows = factRecords(step, artifact, closed);
51
+ export function closeRecords(step, artifact, closed, checkList = undefined) {
52
+ // M16 item 5: a check of a list line carries `by`, the row's own (`you` / `agent` / `default`); the Audit draws the tag from it. Any other line keeps the words it has.
53
+ const decl = Array.isArray(checkList) ? { checkList } : undefined;
54
+ const listed = decl !== undefined && listLinesOf(decl).has(step?.fromLine);
55
+ const hasCited = step?.close?.class === 'green' && !!step?.close?.cited;
56
+ const by = (/** @type {number} */ idx, /** @type {'you'|'agent'|'default'} */ fallback) => (listed ? { by: partByOf(decl, step.fromLine, idx) ?? fallback, part: idx } : {});
57
+ const rows = factRecords(step, artifact, closed, listed ? (/** @type {number} */ idx) => partByOf(decl, step.fromLine, idx) : undefined, checkList).map((r) => (listed && hasCited && r.n === 3 ? { ...r, text: String(r.text).replace(/ \[agent\]$/, ''), ...by(0, 'agent') } : r));
49
58
  // M10 am22 (1): the picks on a fact line are rows after the fact rows, each judged on the answer's text
50
59
  const picks = Array.isArray(/** @type {any} */ (closed).pickChecks) ? /** @type {any} */ (closed).pickChecks : [];
51
- return [...rows, ...picks.map((/** @type {any} */ c, i) => ({ n: rows.length + 3 + i, text: labelled(c.text, 'picked'), ok: c.ok, result: c.result, source: lineSource(step) }))];
60
+ const pickRows = picks.map((/** @type {any} */ c, /** @type {number} */ i) => ({ n: rows.length + 3 + i, text: listed ? c.text : labelled(c.text, 'picked'), ok: c.ok, result: c.result, source: lineSource(step), ...by((hasCited ? 1 : 0) + i, 'you') }));
61
+ // M16 R7: the numbers tie of a text line is one more row
62
+ const tie = /** @type {any} */ (closed).numbersCheck;
63
+ const picked = Array.isArray(step?.close?.picked) ? step.close.picked.length : Array.isArray(step?.close?.shape?.picked) ? step.close.shape.picked.length : 0;
64
+ return [...rows, ...pickRows, ...(tie ? [{ n: rows.length + pickRows.length + 3, text: tie.text, ok: tie.ok, result: tie.result, source: lineSource(step), ...by((hasCited ? 1 : 0) + picked, 'default') }] : [])];
52
65
  }
53
66
 
54
- /** @param {any} step @param {any} artifact @param {any} closed */
55
- function factRecords(step, artifact, closed) {
67
+ /** @param {any} step @param {any} artifact @param {any} closed @param {((idx: number) => string|null)} [partBy] set for a list line (M16): its softgreen picks carry the row's `by` instead of a label @param {any[]} [checkList] the signed list: a sheet row on it gives its check's `by` */
68
+ function factRecords(step, artifact, closed, partBy = undefined, checkList = undefined) {
56
69
  const source = lineSource(step);
57
70
  if (closed.verdict === 'unparseable' || closed.verdict === 'crash') {
58
71
  return [{
@@ -61,9 +74,12 @@ function factRecords(step, artifact, closed) {
61
74
  }
62
75
  if (step?.close?.class === 'green' && Array.isArray(step?.close?.sheet) && Array.isArray(closed.checks)) {
63
76
  // M10b piece 2: each signed sheet check is its own row, worded by `sheetCheckSentence`, judged by bareguard
64
- return closed.checks.map((c, i) => ({
65
- n: 3 + i, text: labelled(c.text, 'agent'), ok: c.ok, result: c.result, source,
66
- }));
77
+ // hamr 2026-11-14: a plan whose list has the sheet's rows draws each check with the `by` of its row (`~` = you, `!` = agent); an older plan keeps `[agent]`
78
+ return closed.checks.map((c, i) => {
79
+ const row = Array.isArray(checkList) ? checkList.find((/** @type {any} */ r) => r?.kind === 'sheet' && r.key === sheetRowKey(step.fromLine, String(c.id))) : undefined;
80
+ if (row && (row.by === 'you' || row.by === 'agent')) return { n: 3 + i, text: c.text, ok: c.ok, result: c.result, source, by: row.by, part: row.part.part };
81
+ return { n: 3 + i, text: labelled(c.text, 'agent'), ok: c.ok, result: c.result, source };
82
+ });
67
83
  }
68
84
  if (step?.close?.class === 'green' && step?.close?.cited) {
69
85
  const n = Array.isArray(artifact?.results) ? artifact.results.length : 0;
@@ -78,7 +94,10 @@ function factRecords(step, artifact, closed) {
78
94
  }];
79
95
  }
80
96
  // M10 am22 (4): a softgreen check is the person's when it is one of their picks, the drafter's otherwise; the one-key row is code's own and carries no label
81
- return (closed.checks ?? []).map((c, i) => ({
82
- n: 3 + i, text: /** @type {any} */ (c).id === 'keys' ? c.text : labelled(c.text, /^pick\d+$/.test(String(/** @type {any} */ (c).id)) ? 'picked' : 'agent'), ok: c.ok, result: c.result, source,
83
- }));
97
+ return (closed.checks ?? []).map((c, i) => {
98
+ const id = String(/** @type {any} */ (c).id);
99
+ const pk = /^pick(\d+)$/.exec(id);
100
+ if (partBy !== undefined) return { n: 3 + i, text: c.text, ok: c.ok, result: c.result, source, ...(pk ? { by: partBy(Number(pk[1]) - 1) ?? 'agent', part: Number(pk[1]) - 1 } : {}) };
101
+ return { n: 3 + i, text: id === 'keys' ? c.text : labelled(c.text, pk ? 'picked' : 'agent'), ok: c.ok, result: c.result, source };
102
+ });
84
103
  }
package/src/types.js CHANGED
@@ -253,6 +253,7 @@
253
253
  * @property {string|null} [red]
254
254
  * @property {string[]} [reds]
255
255
  * @property {Array<{id:string, text:string, ok:boolean, result:string|null}>} [checks] a softgreen close: every check it ran (M4d am29 item 2)
256
+ * @property {{text: string, ok: boolean, result: string|null}} [numbersCheck] the numbers tie of a text line (M16 R7): beside the class's own verdict
256
257
  * @property {{part: any, check: any, results?: unknown}} [cited] a cited green close (M10 piece 4): the fact part and the check's own answer, for the run's cited-check record
257
258
  * @property {{inputs: Array<{name:string, sha256:string}>, claims: unknown, checks: Array<{id:string, text:string, ok:boolean, result:string|null}>}} [sheetRecord] a sheet close (M10b piece 2): what the run's sheet-check record keeps
258
259
  */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @param {any} declaration the signed plan @param {any[]} diary the run's `checks` rows (src/diary.js readChecks) @param {{items?: string[], by?: Record<string, string>}|null} notChecked the sign row's Not-checked block
3
+ * @param {{lines?: any[], csvRoles?: string[]}} [sheet] the signed job lines and CSV roles: a plan whose list has sheet rows (M16 am4) shows them here, tagged by where each comes from (hamr 2026-11-14)
4
+ * @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], readNotes: string[], always: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
5
+ * @typedef {{text: string, by: 'you'|'agent'|'default'|null, result: 'passed'|'failed'|'none'|'not-checked'}} AuditCheckRow
6
+ */
7
+ export function auditChecksOf(declaration: any, diary: any[], notChecked: {
8
+ items?: string[];
9
+ by?: Record<string, string>;
10
+ } | null, { lines: jobLines, csvRoles }?: {
11
+ lines?: any[];
12
+ csvRoles?: string[];
13
+ }): {
14
+ checks: AuditCheckRow[];
15
+ notChecked: AuditCheckRow[];
16
+ readNotes: string[];
17
+ always: AuditCheckRow[];
18
+ } | null;
19
+ /** the words of a row no result was recorded for: never "passed" */
20
+ export const AUDIT_NO_RESULT: "no result recorded";
21
+ export type AuditCheckRow = {
22
+ text: string;
23
+ by: "you" | "agent" | "default" | null;
24
+ result: "passed" | "failed" | "none" | "not-checked";
25
+ };
@@ -88,6 +88,21 @@ export function readProseFile(file: any): {
88
88
  * @returns {string|null}
89
89
  */
90
90
  export function draftKeyRefusal(slot: string, env: Record<string, string | undefined>): string | null;
91
+ /**
92
+ * The ONE place a plan folder is claimed: its parent made if needed, then the folder itself, exclusively (an existing path throws EEXIST). `draftToDir` claims the folder of a draft with it and the
93
+ * panel claims the folder of a plan made by a Drop or an Add (src/planrebuild.js).
94
+ * @param {string} dir
95
+ */
96
+ export function claimPlanDir(dir: string): void;
97
+ /**
98
+ * The ONE writer of a plan folder's files: each `name` -> text, in the order given (a draft writes `spec.hash` last, so a folder with one is whole). `opts` is `writeFileSync`'s own
99
+ * (the panel's session files are exclusive, 0600).
100
+ * @param {string} dir @param {Record<string, string>} files @param {{flag?: string, mode?: number}} [opts]
101
+ */
102
+ export function writePlanFiles(dir: string, files: Record<string, string>, opts?: {
103
+ flag?: string;
104
+ mode?: number;
105
+ }): void;
91
106
  /**
92
107
  * Draft into `dir`. $0 refusals (return {ok:false, wrote:false}, nothing on disk): bad key,
93
108
  * unreadable/blank prose, prose that contains the key, missing inputs / bad signed text, dir
@@ -98,7 +113,7 @@ export function draftKeyRefusal(slot: string, env: Record<string, string | undef
98
113
  * Test seam: `provider`/`rates`/`modelId` are injected; without them a live provider is built.
99
114
  * `onResult({ ok })` (M4d am32): called once, after the spend is booked and just before the result files are written (the CLI gives its monthly hold back there).
100
115
  */
101
- export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, checkPicks, carriedPicks, proseRead, flowType, mcpServer, mcpPick, mcpServers, }: {
116
+ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, }: {
102
117
  proseFile: any;
103
118
  dir: any;
104
119
  root: any;
@@ -115,10 +130,14 @@ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThink
115
130
  onResult: any;
116
131
  fetchPage: any;
117
132
  leftRules: any;
133
+ columnAnswers: any;
134
+ carriedColumns: any;
118
135
  checkPicks: any;
119
136
  carriedPicks: any;
137
+ carriedChoices: any;
138
+ carriedSheetDropped: any;
120
139
  proseRead: any;
121
- flowType?: "mcp" | "plain" | "tickets" | undefined;
140
+ flowType?: "tickets" | "mcp" | "plain" | undefined;
122
141
  mcpServer?: string | undefined;
123
142
  mcpPick?: any;
124
143
  mcpServers?: string[] | undefined;
@@ -0,0 +1,36 @@
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>}} 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
+ };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The words a Not-checked row says. A rule the person left, wrote in their own words, or left with no pick keeps fwd's signed table (M10 am16 (5): src/pagedropwords.js), the words the plan card and the
3
+ * Audit already had; any other reason is the block's own (what code could not build and why).
4
+ * @param {string|null|undefined} reason @param {{cantAsked?: boolean}} [row]
5
+ */
6
+ export function notCheckedWords(reason: string | null | undefined, row?: {
7
+ cantAsked?: boolean;
8
+ }): string;
9
+ /** a countable part as the picked check the softgreen close runs: its own fields, the rule named `rule` (the inverse of the block's partOfPick) @param {Record<string, any>} part */
10
+ export function pickedOf(part: Record<string, any>): {
11
+ rule: any;
12
+ };
13
+ /**
14
+ * @param {{declaration: Record<string, any>, block: import('./checkblock.js').CheckBlock, lines: {n: number, guardrail?: string|null}[], lineSet: Set<number>, askLines?: Set<number>}} o
15
+ * `lineSet` = the lines the block was given; `lines` = the signed lines (a guardrail decides the class); `askLines` = the signed Ask lines: each `~` rule on one is a Not-checked line here, never skipped (M17 am5 item 2)
16
+ * @returns {{declaration: Record<string, any>, notChecked: string[], notCheckedBy: Record<string, 'you'|'agent'|'default'>, built: Set<number>}} `built` = the lines that got a check from the block (a red naming one of them is a fault of the build)
17
+ */
18
+ export function assembleFromBlock({ declaration, block, lines, lineSet, askLines }: {
19
+ declaration: Record<string, any>;
20
+ block: import("./checkblock.js").CheckBlock;
21
+ lines: {
22
+ n: number;
23
+ guardrail?: string | null;
24
+ }[];
25
+ lineSet: Set<number>;
26
+ askLines?: Set<number>;
27
+ }): {
28
+ declaration: Record<string, any>;
29
+ notChecked: string[];
30
+ notCheckedBy: Record<string, "you" | "agent" | "default">;
31
+ built: Set<number>;
32
+ };
33
+ /**
34
+ * M17 am5 / P5: a green sheet step the builder (src/sheetbuild.js) reported as holding no built check has nothing to check it: its close becomes `hitl` (the class is decided here, never in the sheet files),
35
+ * the class on its line follows, and its rules are the Not-checked lines the builder gave. A plan signed before M17 is never passed through here.
36
+ * @param {Record<string, any>} declaration @param {{line: number, lost: string[]}[]} unbuilt
37
+ * @returns {{declaration: Record<string, any>, lines: number[], lost: string[]}}
38
+ */
39
+ export function closeUnbuiltSheetSteps(declaration: Record<string, any>, unbuilt: {
40
+ line: number;
41
+ lost: string[];
42
+ }[]): {
43
+ declaration: Record<string, any>;
44
+ lines: number[];
45
+ lost: string[];
46
+ };
47
+ /** M17 am5 item 2 (D3): the reason a `~` rule on a signed Ask line is Not checked, the signed words */
48
+ export const ASK_LINE_REASON: "you judge it at the Ask";
49
+ /** what a row says when its check cannot ride a line that has no guardrail of its own (the class of a line comes from its guardrail) */
50
+ export const NO_GUARDRAIL_WORDS: "This line has no guardrail of yours, so a check on it cannot be signed; you judge it at the Ask.";