bareloop 0.56.0 → 0.58.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 (93) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +3 -3
  3. package/bareloop.context.md +75 -214
  4. package/package.json +2 -2
  5. package/src/authorflow.js +71 -136
  6. package/src/authoring.js +5 -124
  7. package/src/authorjob.js +125 -417
  8. package/src/authorreadout.js +105 -355
  9. package/src/authorrun.js +70 -234
  10. package/src/authorscout.js +9 -1
  11. package/src/blockasks.js +12 -17
  12. package/src/bundlerun.js +4 -1
  13. package/src/checkblock.js +297 -75
  14. package/src/checklist.js +1 -1
  15. package/src/checkpick.js +9 -5
  16. package/src/cli.js +3 -3
  17. package/src/declaredclose.js +45 -112
  18. package/src/destpoint.js +1 -1
  19. package/src/draftspend.js +20 -4
  20. package/src/fencepointcall.js +76 -0
  21. package/src/guarddescriptions.js +14 -0
  22. package/src/index.js +3 -43
  23. package/src/interviewrun.js +13 -8
  24. package/src/job.js +20 -1
  25. package/src/jobblock.js +11 -46
  26. package/src/judged.js +13 -1229
  27. package/src/kinds.js +10 -348
  28. package/src/noteask.js +124 -0
  29. package/src/pagedry.js +27 -5
  30. package/src/pagemap.js +7 -29
  31. package/src/pagerules.js +18 -3
  32. package/src/panel/authorroutes.js +15 -4
  33. package/src/panel/authorsession.js +201 -167
  34. package/src/panel/importrun.js +0 -1
  35. package/src/panel/index.html +43 -18
  36. package/src/panel/jobplan.js +54 -19
  37. package/src/panel/server.js +90 -69
  38. package/src/panel/status.js +3 -0
  39. package/src/pickrecord.js +15 -54
  40. package/src/planrun.js +4 -48
  41. package/src/promptregisters.js +7 -17
  42. package/src/providerrows.js +0 -36
  43. package/src/providers.js +4 -25
  44. package/src/questionbox.js +34 -30
  45. package/src/reviewdoor.js +1 -1
  46. package/src/rowresults.js +69 -0
  47. package/src/rubricstep.js +136 -28
  48. package/src/run.js +2 -15
  49. package/src/stagewords.js +24 -0
  50. package/src/userrun.js +14 -111
  51. package/types/authorflow.d.ts +51 -137
  52. package/types/authoring.d.ts +1 -14
  53. package/types/authorjob.d.ts +14 -55
  54. package/types/authorreadout.d.ts +52 -80
  55. package/types/authorrun.d.ts +20 -0
  56. package/types/blockasks.d.ts +5 -11
  57. package/types/checkblock.d.ts +147 -28
  58. package/types/checklist.d.ts +2 -2
  59. package/types/checkpick.d.ts +5 -3
  60. package/types/cli.d.ts +1 -3
  61. package/types/declaredclose.d.ts +5 -33
  62. package/types/draftspend.d.ts +16 -2
  63. package/types/fencepointcall.d.ts +68 -0
  64. package/types/guarddescriptions.d.ts +7 -0
  65. package/types/index.d.ts +2 -4
  66. package/types/job.d.ts +8 -0
  67. package/types/jobblock.d.ts +8 -38
  68. package/types/judged.d.ts +7 -357
  69. package/types/kinds.d.ts +4 -104
  70. package/types/noteask.d.ts +76 -0
  71. package/types/pagedry.d.ts +13 -0
  72. package/types/pagemap.d.ts +2 -5
  73. package/types/pagerules.d.ts +7 -0
  74. package/types/panel/authorsession.d.ts +37 -5
  75. package/types/panel/jobplan.d.ts +15 -3
  76. package/types/panel/server.d.ts +46 -13
  77. package/types/panel/status.d.ts +5 -0
  78. package/types/pickrecord.d.ts +8 -13
  79. package/types/planrun.d.ts +1 -22
  80. package/types/providerrows.d.ts +0 -31
  81. package/types/providers.d.ts +3 -19
  82. package/types/questionbox.d.ts +20 -6
  83. package/types/rowresults.d.ts +23 -0
  84. package/types/rubricstep.d.ts +43 -7
  85. package/types/run.d.ts +1 -20
  86. package/types/stagewords.d.ts +11 -0
  87. package/types/userrun.d.ts +0 -1
  88. package/src/calibrate.js +0 -702
  89. package/src/cardauthor.js +0 -502
  90. package/src/fitcheck.js +0 -168
  91. package/types/calibrate.d.ts +0 -201
  92. package/types/cardauthor.d.ts +0 -358
  93. package/types/fitcheck.d.ts +0 -119
@@ -0,0 +1,76 @@
1
+ /** What the AI is told: the numbered job lines (text only), the one question, the reply shape and a legal example. @param {{n: number, text: string}[]} lines @returns {string} */
2
+ export function notePrompt(lines: {
3
+ n: number;
4
+ text: string;
5
+ }[]): string;
6
+ /**
7
+ * Code reads the reply: every asked line answered exactly yes or no, else malformed (no repair). An answer for a line not asked is malformed too.
8
+ * @param {unknown} text @param {{n: number}[]} lines @returns {Map<number, 'yes'|'no'>|null}
9
+ */
10
+ export function decideNote(text: unknown, lines: {
11
+ n: number;
12
+ }[]): Map<number, "yes" | "no"> | null;
13
+ /**
14
+ * Run the call: one call, one retry on a malformed reply, a transport failure or a 429. Never throws on a call casualty; every failure is `failed` (the lines stay facts-only).
15
+ * @param {{lines: {n: number, text: string}[], provider?: any, maxTokens?: number, ceilingUsd?: number|null, callTimeoutMs?: number,
16
+ * onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string, raw?: string}) => void,
17
+ * createLoop?: Function, rates?: {in: number, out: number}|null, callOptions?: Record<string, any>, sleep?: (ms: number) => Promise<void>}} o
18
+ * @returns {Promise<{state: 'answered'|'failed', answers: Map<number, 'yes'|'no'>, reason: string|null, calls: {label: string, costUsd: number|null, unpricedRounds: number}[]}>}
19
+ */
20
+ export function runNoteAsk({ lines, provider, maxTokens, ceilingUsd, callTimeoutMs, onCall, createLoop, rates, callOptions, sleep, }: {
21
+ lines: {
22
+ n: number;
23
+ text: string;
24
+ }[];
25
+ provider?: any;
26
+ maxTokens?: number;
27
+ ceilingUsd?: number | null;
28
+ callTimeoutMs?: number;
29
+ onCall?: (call: {
30
+ label: string;
31
+ costUsd: number | null;
32
+ unpricedRounds: number;
33
+ thinkingStatus?: string;
34
+ raw?: string;
35
+ }) => void;
36
+ createLoop?: Function;
37
+ rates?: {
38
+ in: number;
39
+ out: number;
40
+ } | null;
41
+ callOptions?: Record<string, any>;
42
+ sleep?: (ms: number) => Promise<void>;
43
+ }): Promise<{
44
+ state: "answered" | "failed";
45
+ answers: Map<number, "yes" | "no">;
46
+ reason: string | null;
47
+ calls: {
48
+ label: string;
49
+ costUsd: number | null;
50
+ unpricedRounds: number;
51
+ }[];
52
+ }>;
53
+ /**
54
+ * The drafting step: when the block has a facts-only line (and a `noteFn`), make the ONE call, then let code decide through `block.setNotes`. No facts-only line, or no `noteFn`: no call, nothing changes.
55
+ * A failed call leaves the lines facts-only, each with its Not checked row. Returns the calls made (for the drafting book).
56
+ * @param {{block: import('./checkblock.js').CheckBlock, jobLines: {n: number, text: string}[], noteFn: Function|null, ceilingUsd?: number|null, onCall?: Function, onPhase?: (name: string, data: any) => void}} o
57
+ * @returns {Promise<{label: string, costUsd: number|null, unpricedRounds: number}[]>}
58
+ */
59
+ export function askNotes({ block, jobLines, noteFn, ceilingUsd, onCall, onPhase }: {
60
+ block: import("./checkblock.js").CheckBlock;
61
+ jobLines: {
62
+ n: number;
63
+ text: string;
64
+ }[];
65
+ noteFn: Function | null;
66
+ ceilingUsd?: number | null;
67
+ onCall?: Function;
68
+ onPhase?: (name: string, data: any) => void;
69
+ }): Promise<{
70
+ label: string;
71
+ costUsd: number | null;
72
+ unpricedRounds: number;
73
+ }[]>;
74
+ /** the label of the one paid call, as the drafting book sees it */
75
+ export const NOTE_CALL_LABEL: "note-ask";
76
+ export const NOTE_SYSTEM: "You read the numbered lines of a job. You answer only about what each line says; you never invent words.";
@@ -22,6 +22,19 @@ export function dryReadMoney(text: string, facts: KeptFact[]): Promise<{
22
22
  reads: Record<string, number>;
23
23
  results: Record<string, number>;
24
24
  }>;
25
+ /**
26
+ * The page's RESULT LINES: the lines the given money facts read (`moneyResultLines`), each quote once. Empty when no money fact reads a line (the result lines are then unknown).
27
+ * The one owner of "what is a result row" for phrase facts, shared by the dry read below and by the check list's `!` rows (`phraseInNoResult`).
28
+ * @param {string} text @param {KeptFact[]} facts @returns {string[]}
29
+ */
30
+ export function resultQuotes(text: string, facts: KeptFact[]): string[];
31
+ /**
32
+ * Is this phrase in the page but in NONE of its result lines (the `phrase-no-result` case)? Sync, for a `!` row the check list is about to build.
33
+ * True only when result lines exist and no line holds the words (case and spacing aside, a plain substring: it never refuses a phrase the run's presence check could pass).
34
+ * With no result line known nothing is guessed (false).
35
+ * @param {string} text @param {KeptFact[]} moneyFacts the line's money facts @param {string} words @returns {boolean}
36
+ */
37
+ export function phraseInNoResult(text: string, moneyFacts: KeptFact[], words: string): boolean;
25
38
  /**
26
39
  * The same "can it read" for PHRASE facts (hamr ruled 3a, run m10-walk-flights-3: "Rome" was on the page only in "Track prices from Madrid to
27
40
  * Rome" switches, in none of the 18 result lines, so no result could ever say it). A kept phrase fact is read against the page's RESULT LINES =
@@ -128,7 +128,7 @@ export function askableFromLook(look: {
128
128
  * its reading as the suggestion (no extra paid call). A secret in a rule is masked.
129
129
  * @param {LookAsk[]} asks @returns {string}
130
130
  */
131
- export function tooManyAsksText(asks: LookAsk[]): string;
131
+ export function tooManyAsksText(asks: LookAsk[], where?: string): string;
132
132
  /** the label of the one paid call, as the drafting book and the progress line see it */
133
133
  export const MAP_CALL_LABEL: "page-map";
134
134
  /** the shapes the map may name; a `place` is read by code as a phrase */
@@ -140,11 +140,8 @@ export const MAP_UNREADABLE: "The AI's answer about the page was not readable tw
140
140
  export const DROP_IT: "drop it";
141
141
  export function isDropIt(text: unknown): boolean;
142
142
  export function isAgree(text: unknown): boolean;
143
- export function stripAgreeLead(text: string): string;
144
- export function readingTail(n: number): string;
145
- export function cantCheckTail(n: number): string;
146
143
  export function readingQuestion(n: number, rule: string, reading: string): string;
147
- export function cantCheckQuestion(n: number, rule: string): string;
144
+ export function cantCheckQuestion(n: number, rule: string, where?: string): string;
148
145
  /**
149
146
  * `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only)
150
147
  */
@@ -31,6 +31,13 @@ export function numberAtEnd(s: string): string | undefined;
31
31
  * @param {string} s @returns {string|undefined}
32
32
  */
33
33
  export function numberAtEndComma(s: string): string | undefined;
34
+ /**
35
+ * The ONE owner of a label's separator: the label as the page writes it. The run's checker reads a value right after the signed label, so a page that
36
+ * writes "Departure time: 10:24 AM." can only be read by the label "Departure time:". When EVERY place the page holds the label has a colon right after
37
+ * it, the label is signed with that colon; one bare place leaves it as the look gave it. A plain count of the page's own text, no pattern.
38
+ * @param {string} text the frozen page text @param {string} label a label as normLabel leaves it @returns {string}
39
+ */
40
+ export function withColon(text: string, label: string): string;
34
41
  /**
35
42
  * Apply the rules to the AI's map over one saved page. Returns the kept facts and, for everything a rule removed, one `dropped` entry.
36
43
  * The order of the rules is the POC's (apply-v3.mjs): found-on-page, then the rules that read the page. A place is read as a phrase.
@@ -81,6 +81,33 @@ export function jobNameTaken(name: string, opts?: {
81
81
  export function nextFreeJobName(origin: string, runJobs: Iterable<string>, opts?: {
82
82
  jobsDir?: string;
83
83
  }): string;
84
+ /**
85
+ * The card's Inputs as the JOB reads them: the one place that decides which lines are inputs (hamr 2026-11-14, piece 5): the fresh card, the session, the
86
+ * Destination check and Reuse (`buildReuseSpec`) all read THIS, never a copy.
87
+ * @param {any} card
88
+ * @param {{rubric?: boolean, flowType?: 'plain'|'mcp'|'tickets'}} [o]
89
+ * @returns {{ok: true, inputs: import('../jobblock.js').JobInput[]}|{ok: false, error: string}}
90
+ */
91
+ export function cardInputs(card: any, o?: {
92
+ rubric?: boolean;
93
+ flowType?: "plain" | "mcp" | "tickets";
94
+ }): {
95
+ ok: true;
96
+ inputs: import("../jobblock.js").JobInput[];
97
+ } | {
98
+ ok: false;
99
+ error: string;
100
+ };
101
+ /**
102
+ * The renumbering itself, for a caller that holds parsed lines already (`startSession`): a Tickets + rubric job reads the ticket and nothing else (a repo line is
103
+ * not an input of it), so the ticket line stands alone, numbered 1 (a signed spec's inputs must run 1, 2, 3...). Any other job keeps its lines as typed.
104
+ * @param {import('../jobblock.js').JobInput[]} inputs @param {{rubric: boolean, flowType: 'plain'|'mcp'|'tickets'}} o
105
+ * @returns {import('../jobblock.js').JobInput[]}
106
+ */
107
+ export function ticketRubricInputs(inputs: import("../jobblock.js").JobInput[], { rubric, flowType }: {
108
+ rubric: boolean;
109
+ flowType: "plain" | "mcp" | "tickets";
110
+ }): import("../jobblock.js").JobInput[];
84
111
  /**
85
112
  * The repo a card names: Inputs line 1 (P7 — the Source box is gone; the first input IS the repo). `''` when the Inputs
86
113
  * box does not parse (the card validator refuses that before anything uses this).
@@ -215,8 +242,8 @@ export function validateJobCard(card: any, opts?: {
215
242
  * `signPrepare()` are the only ways in.
216
243
  * @param {any} card the validated job card (see {@link validateJobCard})
217
244
  * @param {{env?: Record<string,string|undefined>, sessionsRoot?: string, home?: string, timeoutMs?: number,
218
- * scout?: any, generate?: Function, pickGenerate?: Function|null, ledgerGenerate?: Function|null, editGenerate?: Function|null, carryFrom?: string, carryKind?: string, confirmGenerate?: Function, authorFn?: Function,
219
- * prepareSigningFn?: Function, npmCiFn?: Function, lookFn?: Function|null, fitFn?: Function|null, destFn?: Function|null, fetchUrl?: (url: string) => Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>, draftThinking?: "on"|"off", reuse?: {spec: any, workflowKey: string}, schedule?: import('../trigger.js').Trigger|null, flow?: {flowType: 'plain'|'mcp'|'tickets', pick: {server: string, tools: string[]}|null}}} [deps] `scout`..`prepareSigningFn` are
245
+ * scout?: any, generate?: Function, pickGenerate?: Function|null, ledgerGenerate?: Function|null, fenceGenerate?: Function|null, noteFn?: Function|null, editGenerate?: Function|null, carryFrom?: string, carryKind?: string, confirmGenerate?: Function, authorFn?: Function,
246
+ * prepareSigningFn?: Function, npmCiFn?: Function, lookFn?: Function|null, destFn?: Function|null, newestUnrunTicket?: typeof newestUnrunTicket, readTicketFn?: typeof readTicket, fetchUrl?: (url: string) => Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>, draftThinking?: "on"|"off", reuse?: {spec: any, workflowKey: string}, schedule?: import('../trigger.js').Trigger|null, flow?: {flowType: 'plain'|'mcp'|'tickets', pick: {server: string, tools: string[]}|null}}} [deps] `scout`..`prepareSigningFn` are
220
247
  * TEST SEAMS ONLY — see the note just above where each is read, below. `reuse` (Reuse workflow) is NOT a seam: the
221
248
  * caller (`/api/author/start`) sets it only when the server's own same-job rule held.
222
249
  * @returns {any} the session object
@@ -230,6 +257,8 @@ export function createSession(card: any, deps?: {
230
257
  generate?: Function;
231
258
  pickGenerate?: Function | null;
232
259
  ledgerGenerate?: Function | null;
260
+ fenceGenerate?: Function | null;
261
+ noteFn?: Function | null;
233
262
  editGenerate?: Function | null;
234
263
  carryFrom?: string;
235
264
  carryKind?: string;
@@ -238,8 +267,9 @@ export function createSession(card: any, deps?: {
238
267
  prepareSigningFn?: Function;
239
268
  npmCiFn?: Function;
240
269
  lookFn?: Function | null;
241
- fitFn?: Function | null;
242
270
  destFn?: Function | null;
271
+ newestUnrunTicket?: typeof newestUnrunTicket;
272
+ readTicketFn?: typeof readTicket;
243
273
  fetchUrl?: (url: string) => Promise<{
244
274
  ok: true;
245
275
  text: string;
@@ -282,13 +312,13 @@ export const FILE_JOB_STEP_LABELS: Readonly<Record<string, string>>;
282
312
  */
283
313
  export const PHASE_STEP: Readonly<Record<string, keyof typeof STEP_LABELS>>;
284
314
  /** the line under the plan bubble, in plain words (the bubble itself is drawn by the page's one `renderJobPlan`) */
285
- export const PLAN_FOOTER: "Sign & run to confirm this plan, or Revise to edit the boxes and draft again.";
315
+ export const PLAN_FOOTER: "Draft the plan to see its checks, or Revise to edit the boxes.";
286
316
  /** the form's fields, in card order — what `card.json` stores, verbatim (P5 item 3) */
287
317
  export const CARD_FIELDS: readonly string[];
288
318
  /**
289
319
  * REUSE WORKFLOW, ONE DOOR (RULED 2026-10-15, v1.101; replaces v1.88's five open boxes). Every box on the card is open. What decides
290
320
  * the path is the CARD compared with the origin run's card, never the drafted spec: the JOB boxes are the job text (numbered lines,
291
- * `~` rules, `~ PASS`/`~ FAIL`), the check type and the thinking tick. The RUN boxes (Inputs, Destination, Model, $ cap, Time cap)
321
+ * `~` rules), the check type and the thinking tick. The RUN boxes (Inputs, Destination, Model, $ cap, Time cap)
292
322
  * never decide it. A green origin with no job box changed reuses the signed plan verbatim (no drafting); anything else drafts.
293
323
  */
294
324
  export const JOB_BOXES: readonly string[];
@@ -303,6 +333,8 @@ export type StepLine = {
303
333
  detail: string;
304
334
  };
305
335
  import { planFromConfirm } from './jobplan.js';
336
+ import { newestUnrunTicket } from '../ticketnext.js';
337
+ import { readTicket } from '../ticket.js';
306
338
  import { thinkingRowText } from '../thinking.js';
307
339
  import { nonRepoSourceMessage } from '../source.js';
308
340
  export { thinkingRowText, nonRepoSourceMessage };
@@ -62,10 +62,19 @@ export function planFromConfirm(jobLines: {
62
62
  * (`results`: stage name to passed), never re-derived; a row no verdict was recorded for says so. A Not checked row's result is "not checked" (its reason is in its words).
63
63
  * The write fence is enforced per write by the gate, so its row reads the gate's own record of THIS run (hamr ruling A, 2026-11-13): `blocked` = the write/edit attempts the gate denied
64
64
  * (`held · N writes blocked`), or `null` when the run's gate record is missing (said in plain words, never "held").
65
- * @param {JobPlan} plan @param {string[]} guards @param {Map<string, boolean>|null} results @param {number|null} [blocked]
65
+ * Each row reads ITS OWN recorded result when the close recorded one (`rowRes`, piece 4: `{results: key -> {result, why?}, unclaimed: line -> words}`), else (a close recorded before rows existed) the verdict of its stage.
66
+ * A gap no row owns is its own failed item of its line, in the gap's words.
67
+ * @param {JobPlan} plan @param {string[]} guards @param {Map<string, boolean>|null} results @param {number|null} [blocked] @param {boolean} [closeRan] the results are a CLOSE's (the latest), so a declared stage missing from them was not reached (the close stops at its first red); else a stage no verdict was recorded for reads none
68
+ * @param {{results: Map<string, {result: string, why?: string}>, unclaimed: Map<number, string[]>}|null} [rowRes]
66
69
  * @returns {{checks: AuditRow[], notChecked: AuditRow[], always: AuditRow[]}}
67
70
  */
68
- export function auditChecksOf(plan: JobPlan, guards: string[], results: Map<string, boolean> | null, blocked?: number | null): {
71
+ export function auditChecksOf(plan: JobPlan, guards: string[], results: Map<string, boolean> | null, blocked?: number | null, closeRan?: boolean, rowRes?: {
72
+ results: Map<string, {
73
+ result: string;
74
+ why?: string;
75
+ }>;
76
+ unclaimed: Map<number, string[]>;
77
+ } | null): {
69
78
  checks: AuditRow[];
70
79
  notChecked: AuditRow[];
71
80
  always: AuditRow[];
@@ -75,8 +84,10 @@ export const AUDIT_NO_RESULT: "no result recorded";
75
84
  export type AuditRow = {
76
85
  text: string;
77
86
  by: "agent" | "you" | "default" | null;
78
- result: "passed" | "failed" | "none" | "not-checked" | "held" | "record-missing";
87
+ result: "passed" | "failed" | "none" | "not-reached" | "not-checked" | "held" | "record-missing";
79
88
  word?: string;
89
+ key?: string;
90
+ why?: string;
80
91
  };
81
92
  export type PlanCheck = {
82
93
  name: string;
@@ -84,6 +95,7 @@ export type PlanCheck = {
84
95
  by?: "agent" | "you" | "default" | null;
85
96
  key?: string;
86
97
  stage?: string;
98
+ fence?: true;
87
99
  };
88
100
  export type PlanLine = {
89
101
  n: number;
@@ -345,6 +345,19 @@ export function deliveredOf(records: any[]): {
345
345
  bytes: number | null;
346
346
  sha256: string | null;
347
347
  }[];
348
+ /**
349
+ * The per-row results of the run's FINAL close (Addendum 2026-11-14 (c) piece 4): what its stage entries recorded in `rows` (`{key, result, why?}`) and `unclaimed` (words of a gap no row owns), keyed by
350
+ * the signed list's row key / by job line. A close recorded before rows existed (an older run) yields empty maps: every reader then keeps the stage verdict. Read, never re-derived.
351
+ * @param {any[]} records @param {any} spec
352
+ * @returns {{results: Map<string, {result: string, why?: string}>, unclaimed: Map<number, string[]>}}
353
+ */
354
+ export function rowResultsFromRecords(records: any[], spec: any): {
355
+ results: Map<string, {
356
+ result: string;
357
+ why?: string;
358
+ }>;
359
+ unclaimed: Map<number, string[]>;
360
+ };
348
361
  /**
349
362
  * R8 (piece 10): the ticket grid of the job a run belongs to, or `null` when that job is not a Tickets job (no run of it read a ticket) or the run is unknown. ONE row per run of the job, from
350
363
  * the run list's own entry (`summarizeRow`: status, needs, money, wall, ending words), the ticket from `job-start` ({@link ticketOfStart}), the checks from {@link checksOf} and the steps from
@@ -734,14 +747,7 @@ export function getRunResult(runid: string, opts?: {
734
747
  foldWords: string;
735
748
  scopeLine: string | null;
736
749
  } | null;
737
- checks: {
738
- head: string;
739
- passed: any;
740
- total: any;
741
- allPassed: boolean;
742
- stages: any;
743
- notes: any;
744
- } | null;
750
+ checks: any;
745
751
  work: {
746
752
  branch: string;
747
753
  finalCommit: string;
@@ -920,13 +926,13 @@ export function callsLineOf(records: any[], behaviour: {
920
926
  denied: number;
921
927
  } | null): string;
922
928
  /**
923
- * "16 run · 8 passed · 8 failed (write-flight-facts tries 1-5, then tries 1-3)" — counts of what ran, never a fraction (the "checks N/M"
924
- * headline stays withdrawn). Every `exit-eval` result plus every graded `outer-close` stage; the parenthesis names the steps and try ranges
925
- * that failed, from the same `tries[]` the Audit reads. A run with neither says `not recorded`.
926
- * @param {any[]} records the run's raw spine @param {any[]|null|undefined} parts the enriched parts
929
+ * "3 run · 3 passed · 0 failed" (+ " · N not reached") — counts of what the run's LATEST close ran, never a fraction (the "checks N/M" headline stays withdrawn).
930
+ * Read from {@link checksOf}, the one owner the Audit checks fold and the Result checks box read (live run mwg3pov1): the last staged close, a stage it never reached counts as
931
+ * neither passed nor failed, and a run no close reached falls back to the checks its steps ran. No history of earlier tries. A run with neither says `not recorded`.
932
+ * @param {any[]} records the run's raw spine @param {any} spec the run's signed spec (names the stages the close declares)
927
933
  * @returns {string}
928
934
  */
929
- export function checksLineOf(records: any[], parts: any[] | null | undefined): string;
935
+ export function checksLineOf(records: any[], spec: any): string;
930
936
  /**
931
937
  * The step card's extra line (PRD v1.106 Part 5 G): "5 tries · last try: 1 check passed, 1 failed", with the cut-off try named when there is one
932
938
  * ("4 tries (the 4th cut off before its checks ran) · last try: no checks ran"). Words for what passed and failed, never a fraction. `null`
@@ -975,6 +981,33 @@ export function judgedFileLine(o: {
975
981
  bytes: number | null;
976
982
  sha256: string | null;
977
983
  }): string;
984
+ /**
985
+ * The close's stage names, in declared order — `close[].name` (a hand-authored
986
+ * command close) or `closeDecl.stages[].name` (an authored declaration); the
987
+ * two are mutually exclusive (`validateJob`'s own `close-duplicated` red).
988
+ * `null` when neither carries a named stage (an old/malformed spec) — never a
989
+ * fabricated placeholder.
990
+ * @param {any} spec
991
+ * @returns {string|null}
992
+ */
993
+ export function successFromSpec(spec: any): string | null;
994
+ /**
995
+ * The write fence plus the guard checks a close actually carries — reusing
996
+ * {@link confirmProtections} (`src/authorflow.js`), the SAME function the
997
+ * authoring CLI's confirm turn shows a person, never a second hand-typed list
998
+ * (build spec item 2). Guard names only resolve for a `closeDecl` spec
999
+ * (`classGuards` needs its `lang`+the spec's `verdictType`); an old-shape
1000
+ * `close`-array spec falls back to the write fence alone — its guard stages
1001
+ * (e.g. `no-suppressions`) already show up in {@link successFromSpec}'s own
1002
+ * stage list, and inventing a second detector to relabel them as "guards" here
1003
+ * would be exactly the per-age special-casing the build spec rules out.
1004
+ * `confirmProtections` itself can throw for an unrecognized verdictType/lang
1005
+ * (a spec this panel was never validated against) — caught here so a stale or
1006
+ * hand-edited spec never 500s the Job tab, only shows less than it could.
1007
+ * @param {any} spec
1008
+ * @returns {string|null}
1009
+ */
1010
+ export function guardrailsFromSpec(spec: any): string | null;
978
1011
  /**
979
1012
  * The Signed row of the Job tab: `YYYY-MM-DD HH:MM · <first 6 of specHash>`, the time being the run's FIRST `job-start`
980
1013
  * in local time (hamr, P7). `null` when either part is not on record — never a made-up stamp.
@@ -110,6 +110,11 @@ export const STATUS: Readonly<{
110
110
  word: "skipped";
111
111
  }>;
112
112
  }>;
113
+ /** a close stage the run's LATEST close never reached (it stops at the first red): the [·] sign, grey, never the precheck's old reading. Beside STATUS, not in it: it is a stage's standing, never a run's status */
114
+ export const NOT_REACHED: Readonly<{
115
+ sign: "·";
116
+ word: "not reached";
117
+ }>;
113
118
  /**
114
119
  * PRD v1.106 Part 5 (C, choice 9): the review door's words, ONE table. The door is the only human step bareloop has; there is no "you
115
120
  * cancelled" (cancel is deleted). `decision` is the spine's `door-decision.decision`, or null while nothing has been decided.
@@ -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 session folder's file). A missing or unreadable file is no record (a draft from before R10 has none).
@@ -88,7 +83,7 @@ export type Entry = {
88
83
  lineWords: string;
89
84
  occurrence: number;
90
85
  ruleText: string;
91
- added: string | null;
86
+ added?: string | null;
92
87
  check: Record<string, any> | null;
93
88
  own: boolean;
94
89
  left: boolean;
@@ -183,21 +183,6 @@ export function planPrompt(job: any, scoutBlob: string, reds: any[] | null, maxS
183
183
  * @param {{in: number, out: number}|null} [opts.rates] the customer's own price for the worker's key row (USD per
184
184
  * 1K tokens, `ratesFor`) — handed to the one Loop that drives worker, scout and planner rounds, so they read
185
185
  * `rateSource:'caller'`; null = bare-agent's built-in guess. Not applied to a native (CLI) session, which reports its own cost.
186
- * @param {{in: number, out: number}|null} [opts.judgeRates] the same, for the judge's Loop
187
- * @param {string|null} [opts.judgeModel] softgreen — WHICH model that judge provider drives
188
- * (PRD item 32.1). Resolved by the CALLER (`resolveJudge`, src/judged.js: the spec's signed
189
- * `judge` override, else the job's own worker model), never pinned in this library. It
190
- * travels with `judgeProvider` or the judged stage stops as a wiring gap: a verdict whose
191
- * grader cannot be named is a floor nobody can attribute.
192
- * @param {any} [opts.judgeProvider] softgreen — the provider a JUDGED close stage runs its
193
- * locate call through, built by the CALLER from the RESOLVED judge identity (PRD item
194
- * 32.1: `resolveJudge`, src/judged.js — the spec's signed `judge` override, else the job's
195
- * own worker provider and model), never pinned in this library. Separate
196
- * from `provider`/`providerFor` on purpose: the judge tier is not a step knob and never
197
- * agent-selectable, and the worker's binding is not a legal stand-in for it. Absent is not
198
- * a fall-back — a judged stage with no seam instrument-STOPS as a wiring gap, the same
199
- * answer a native job with no `nativeProvider` gets. A close with no judged stage never
200
- * reads it.
201
186
  * @param {(type: string, data?: object) => object} opts.emit spine emitter (the caller's METERED emit)
202
187
  * @param {() => number} opts.remainingUsd the one wallet: what is left of the signed budget right now
203
188
  * @param {() => boolean} [opts.isUnpriced] has any round come back with a null cost? (F6) — the
@@ -415,7 +400,7 @@ export function planPrompt(job: any, scoutBlob: string, reds: any[] | null, maxS
415
400
  * 'branch-red' | 'cap-halt' | 'wall-halt' | 'stopped' | 'provider-red' | 'interpreter-red' |
416
401
  * 'step-stalled' | 'hitl-pause' | 'hitl-decision-red' | `step-red:<id>`
417
402
  */
418
- export function runPlan(job: any, { workdir, provider, nativeProvider, providerFor, judgeProvider, judgeModel, rates, judgeRates, emit, remainingUsd, isUnpriced, spendComplete, capRuns, strikeLimit, closeTimeoutMs, closeDir, maxStepRounds, layerRoot, readShim, scout, scoutRounds, bridge, now, priorWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, priorSpentUsd, reviewDoor, doorRerun, resumable, stopFile, learnHints }: {
403
+ export function runPlan(job: any, { workdir, provider, nativeProvider, providerFor, rates, emit, remainingUsd, isUnpriced, spendComplete, capRuns, strikeLimit, closeTimeoutMs, closeDir, maxStepRounds, layerRoot, readShim, scout, scoutRounds, bridge, now, priorWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, priorSpentUsd, reviewDoor, doorRerun, resumable, stopFile, learnHints }: {
419
404
  workdir: string;
420
405
  provider: any;
421
406
  nativeProvider?: ((o: {
@@ -428,12 +413,6 @@ export function runPlan(job: any, { workdir, provider, nativeProvider, providerF
428
413
  in: number;
429
414
  out: number;
430
415
  } | null | undefined;
431
- judgeRates?: {
432
- in: number;
433
- out: number;
434
- } | null | undefined;
435
- judgeModel?: string | null | undefined;
436
- judgeProvider?: any;
437
416
  emit: (type: string, data?: object) => object;
438
417
  remainingUsd: () => number;
439
418
  isUnpriced?: (() => boolean) | undefined;
@@ -233,37 +233,6 @@ export function ratesOfLine(line: ModelLine): {
233
233
  inPerM: number;
234
234
  outPerM: number;
235
235
  } | null;
236
- /**
237
- * The row a judge's key and endpoint come from: the worker's own row when the judge shares the worker's API shape, else the judge
238
- * shape's row that ticks the judge's model (else the first row of that shape). `null` when no row is on that shape.
239
- * @param {readonly KeyRow[]} rows
240
- * @param {{ provider: string, model?: string|null }} judge
241
- * @param {string|null|undefined} workerProvider
242
- * @param {KeyRow|null} workerRow
243
- * @returns {KeyRow|null}
244
- */
245
- export function judgeRowFor(rows: readonly KeyRow[], judge: {
246
- provider: string;
247
- model?: string | null;
248
- }, workerProvider: string | null | undefined, workerRow: KeyRow | null): KeyRow | null;
249
- /**
250
- * The price a judge's rounds are booked at. A price belongs to the MODEL's line: when the judge is
251
- * the worker's own provider it calls the worker's endpoint, so a row on that endpoint with a line
252
- * NAMED for the judge's model prices it ({@link ratesFor}); a judge model that is absent or names
253
- * no line there keeps the worker's price (the worker's row, or none = the guess). A different
254
- * provider resolves with no endpoint. The judge's KEY is chosen elsewhere (`judgeRowFor`:
255
- * the worker's own row when the judge shares its provider), so the two can come from different rows.
256
- * @param {{ provider: string, model?: string|null }} judge
257
- * @param {string|null|undefined} workerProvider
258
- * @param {string|null|undefined} workerBaseUrl
259
- * @param {ReturnType<typeof ratesFor>} workerPrice what the worker's own rounds are booked at
260
- * @param {readonly KeyRow[]} rows
261
- * @returns {ReturnType<typeof ratesFor>}
262
- */
263
- export function judgeRatesFor(judge: {
264
- provider: string;
265
- model?: string | null;
266
- }, workerProvider: string | null | undefined, workerBaseUrl: string | null | undefined, workerPrice: ReturnType<typeof ratesFor>, rows: readonly KeyRow[]): ReturnType<typeof ratesFor>;
267
236
  export { SHAPES };
268
237
  /**
269
238
  * A key line whose value is the word `null` is SET and means "no real key": the row exists and
@@ -52,40 +52,24 @@ export function makeProvider(providerName: string, { apiKey, model, baseUrl, leg
52
52
  legacyMaxTokens?: boolean;
53
53
  }): any;
54
54
  /**
55
- * Build the `{provider, providerFor, judgeProvider}` triple both authoring runners need (`src/authorrun.js` and
56
- * `src/panel/authorsession.js` call it) — ONE seam instead of two copies of the same construction. `model` is the
57
- * already-RESOLVED worker model id (the caller picked the Settings line).
58
- *
59
- * THE JUDGE IS NOT PINNED (PRD item 32.2): it is constructed through this same factory from a `judgeProviderName`/`judgeModel`
60
- * pair the CALLER resolved. `judgeApiKey` stays a SEPARATE argument: the judge may be a different provider from the worker,
61
- * and each key is read by the caller from its own row.
55
+ * Build the `{provider, providerFor}` pair both authoring runners need (`src/authorrun.js` and `src/panel/authorsession.js` call it) — ONE seam
56
+ * instead of two copies of the same construction. `model` is the already-RESOLVED worker model id (the caller picked the Settings line).
62
57
  * @param {object} args
63
58
  * @param {string} args.providerName the worker's API shape id
64
59
  * @param {string|undefined} args.apiKey the WORKER's key, read from its row's env name
65
60
  * @param {string} args.model the already-resolved worker model id
66
61
  * @param {string|undefined} [args.baseUrl] the worker row's Base URL
67
62
  * @param {boolean} [args.legacyMaxTokens] the worker row's old max_tokens tick
68
- * @param {string|undefined} args.judgeApiKey the judge's own key
69
- * @param {string} args.judgeModel the resolved judge model id
70
- * @param {string} [args.judgeProviderName] the resolved judge shape; defaults to `providerName`
71
- * @param {string|undefined} [args.judgeBaseUrl] the judge row's endpoint
72
- * @param {boolean} [args.judgeLegacyMaxTokens] the judge row's old max_tokens tick (defaults to the worker's when the judge shares its provider)
73
63
  */
74
- export function buildRunnerProviders({ providerName, apiKey, model, baseUrl, legacyMaxTokens, judgeApiKey, judgeModel, judgeProviderName, judgeBaseUrl, judgeLegacyMaxTokens, }: {
64
+ export function buildRunnerProviders({ providerName, apiKey, model, baseUrl, legacyMaxTokens }: {
75
65
  providerName: string;
76
66
  apiKey: string | undefined;
77
67
  model: string;
78
68
  baseUrl?: string | undefined;
79
69
  legacyMaxTokens?: boolean | undefined;
80
- judgeApiKey: string | undefined;
81
- judgeModel: string;
82
- judgeProviderName?: string | undefined;
83
- judgeBaseUrl?: string | undefined;
84
- judgeLegacyMaxTokens?: boolean | undefined;
85
70
  }): {
86
71
  provider: any;
87
72
  providerFor: (_tier: string) => any;
88
- judgeProvider: any;
89
73
  };
90
74
  /**
91
75
  * $0 reachability check: ONE GET of the provider's models list (`src/modellist.js`, the one owner of
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Which buttons a look question offers. Agree only when it carries a proposal (a reading ask with its reading, a check-pick ask with its check); Drop it only where "drop it" leaves
3
- * one of the person's own `~` rules Not checked (a can't-check ask or a check-pick ask about a rule number).
3
+ * one of the person's own `~` rules Not checked (a reading or check-pick ask about a rule number). A rule with nothing to agree to is not asked at all (src/checkblock.js).
4
4
  * @param {{source?: string, ask?: string, reading?: unknown, check?: unknown, rule?: unknown}} q @returns {{agree: boolean, drop: boolean}}
5
5
  */
6
6
  export function offersOf(q: {
@@ -14,8 +14,8 @@ export function offersOf(q: {
14
14
  drop: boolean;
15
15
  };
16
16
  /**
17
- * A look question as the PANEL shows it: the code's own answer words (`Answer "agree"...` / `Answer "drop it"...`) cut off the end, because the buttons and the box say it.
18
- * Only the known tails are cut, matched exactly as a suffix (never a pattern over the prose); a question that ends in none of them is returned whole.
17
+ * A question as the PANEL shows it: the Destination question's own typed-answer words (`DEST_ANSWER`) cut off the end, because its buttons and box say it. A look question carries no answer words
18
+ * (its buttons say it); it is returned whole. Only the known tail is cut, matched exactly as a suffix (never a pattern over the prose).
19
19
  * @param {{question: string, line?: number, source?: string}} q @returns {string}
20
20
  */
21
21
  export function panelQuestionText(q: {
@@ -23,15 +23,26 @@ export function panelQuestionText(q: {
23
23
  line?: number;
24
24
  source?: string;
25
25
  }): string;
26
+ /**
27
+ * What a try-3 answer DOES, in the words the ask shows (Addendum 2026-11-14 (c) piece 5): `replaces` = the old words of the `~` rule the answer replaces; `adds` = the answer is a new rule of the line.
28
+ * Null when the question says neither (a code-forced look question has its own words). ONE owner: the panel's box, its chat line and the CLI print it.
29
+ * @param {{replaces?: unknown, adds?: unknown, line?: unknown}} step @returns {string|null}
30
+ */
31
+ export function answerEffectWords(step: {
32
+ replaces?: unknown;
33
+ adds?: unknown;
34
+ line?: unknown;
35
+ }): string | null;
26
36
  /**
27
37
  * What the panel's question box shows for one pending ask. Only a question the person answers (`kind: 'answer'`) has a box; every other ask (language, menu, install)
28
38
  * keeps the chat input. `sendChoice` = the choice the box's own Send posts.
29
- * @param {{kind: string, source?: string, index?: number, total?: number, question?: string, line?: number, offers?: {agree: boolean, drop: boolean}, folder?: string, current?: string}} step
39
+ * @param {{kind: string, source?: string, ask?: string, index?: number, total?: number, question?: string, line?: number, offers?: {agree: boolean, drop: boolean}, folder?: string, current?: string, replaces?: string, adds?: boolean}} step
30
40
  * @returns {{head: string, line: string, text: string, choices: {choice: string, label: string}[], orLabel: string|null, sendChoice: string}|null}
31
41
  */
32
42
  export function boxFor(step: {
33
43
  kind: string;
34
44
  source?: string;
45
+ ask?: string;
35
46
  index?: number;
36
47
  total?: number;
37
48
  question?: string;
@@ -42,6 +53,8 @@ export function boxFor(step: {
42
53
  };
43
54
  folder?: string;
44
55
  current?: string;
56
+ replaces?: string;
57
+ adds?: boolean;
45
58
  }): {
46
59
  head: string;
47
60
  line: string;
@@ -55,11 +68,12 @@ export function boxFor(step: {
55
68
  } | null;
56
69
  /**
57
70
  * The door's check of a choice sent for the pending ask. Null = accepted; else the refusal words.
58
- * @param {{kind: string, source?: string, rule?: unknown, offers?: {agree: boolean, drop: boolean}}} step @param {unknown} choice @returns {string|null}
71
+ * @param {{kind: string, source?: string, ask?: string, rule?: unknown, offers?: {agree: boolean, drop: boolean}}} step @param {unknown} choice @returns {string|null}
59
72
  */
60
73
  export function refuseChoice(step: {
61
74
  kind: string;
62
75
  source?: string;
76
+ ask?: string;
63
77
  rule?: unknown;
64
78
  offers?: {
65
79
  agree: boolean;
@@ -82,6 +96,6 @@ export const CHOICE_SAYS: Readonly<{
82
96
  bad: "That answer is not one of the choices. Nothing was saved.";
83
97
  notOffered: "That choice is not offered for this question. Nothing was saved.";
84
98
  outOfDate: "This page is out of date. Reload it and answer again. Nothing was saved.";
85
- noRule: "That question is about the job line, not one of your ~ rules, so there is nothing to drop. Agree, or type your own words. Nothing was saved.";
99
+ noRule: "That question is about the job line, not one of your ~ rules, so there is nothing to drop. Nothing was saved.";
86
100
  blank: "An answer is needed here — there is no skip. Type it in the box and press Send.";
87
101
  }>;