bareloop 0.56.0 → 0.57.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.
- package/CHANGELOG.md +35 -0
- package/README.md +3 -3
- package/bareloop.context.md +65 -207
- package/package.json +2 -2
- package/src/authorflow.js +25 -78
- package/src/authoring.js +5 -124
- package/src/authorjob.js +33 -395
- package/src/authorreadout.js +17 -355
- package/src/authorrun.js +8 -211
- package/src/blockasks.js +2 -2
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +76 -50
- package/src/checklist.js +1 -1
- package/src/checkpick.js +10 -1
- package/src/cli.js +3 -3
- package/src/declaredclose.js +11 -110
- package/src/destpoint.js +1 -1
- package/src/index.js +3 -43
- package/src/interviewrun.js +13 -8
- package/src/job.js +20 -1
- package/src/jobblock.js +11 -46
- package/src/judged.js +13 -1229
- package/src/kinds.js +5 -347
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +2 -2
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +9 -3
- package/src/panel/authorsession.js +99 -141
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +6 -6
- package/src/panel/jobplan.js +7 -5
- package/src/panel/server.js +25 -64
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +15 -54
- package/src/planrun.js +2 -48
- package/src/promptregisters.js +2 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +4 -12
- package/src/rubricstep.js +26 -6
- package/src/run.js +2 -15
- package/src/userrun.js +14 -111
- package/types/authorflow.d.ts +9 -58
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +13 -55
- package/types/authorreadout.d.ts +8 -80
- package/types/blockasks.d.ts +1 -2
- package/types/checkblock.d.ts +32 -17
- package/types/checklist.d.ts +2 -2
- package/types/checkpick.d.ts +5 -0
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +3 -33
- package/types/index.d.ts +2 -4
- package/types/job.d.ts +8 -0
- package/types/jobblock.d.ts +8 -38
- package/types/judged.d.ts +7 -357
- package/types/kinds.d.ts +3 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +35 -4
- package/types/panel/jobplan.d.ts +3 -3
- package/types/panel/server.d.ts +13 -5
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +8 -13
- package/types/planrun.d.ts +1 -22
- package/types/providerrows.d.ts +0 -31
- package/types/providers.d.ts +3 -19
- package/types/rubricstep.d.ts +9 -0
- package/types/run.d.ts +1 -20
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -168
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -119
|
@@ -26,11 +26,11 @@ import { planMatchesClose, listMatchesClose } from '../rubricstep.js';
|
|
|
26
26
|
import { ticketNumberOf } from '../ticketshape.js';
|
|
27
27
|
import { newestUnrunTicket } from '../ticketnext.js';
|
|
28
28
|
import { readRunList } from '../runlist.js';
|
|
29
|
-
import { createSession, validateJobCard, validateReuseCard, jobBoxesChanged, buildReuseSpec, cardFields, nextFreeJobName, startDestinationProblem, resolveFlowCard, ticketBoxProblem, STEP_LABELS } from './authorsession.js';
|
|
29
|
+
import { createSession, ticketRubricInputs, validateJobCard, validateReuseCard, jobBoxesChanged, buildReuseSpec, cardFields, nextFreeJobName, startDestinationProblem, resolveFlowCard, ticketBoxProblem, STEP_LABELS } from './authorsession.js';
|
|
30
30
|
import { parseInputs } from '../jobblock.js';
|
|
31
31
|
import { isReusableGreen } from './status.js';
|
|
32
32
|
import { proveInputFiles, looksLikeRubricInput, webFetchState } from '../source.js';
|
|
33
|
-
import { validateJob, flowTypeOf } from '../job.js';
|
|
33
|
+
import { validateJob, flowTypeOf, oldJobWords } from '../job.js';
|
|
34
34
|
import { ticketAnyway } from './tickets.js';
|
|
35
35
|
import { cardScheduleOf } from '../cardschedule.js';
|
|
36
36
|
|
|
@@ -167,13 +167,19 @@ export function createAuthorRoutes(opts) {
|
|
|
167
167
|
// the session proves every line itself (`proveRubricInputs`), at $0, before any model call.
|
|
168
168
|
const rubric = reuse ? reuse.spec?.verdictType === 'soft-green' : card?.checkType === 'rubric';
|
|
169
169
|
if (reuse) card = { ...card, checkType: rubric ? 'rubric' : 'deterministic' };
|
|
170
|
-
|
|
170
|
+
// hamr 2026-11-14 (piece 6): a job made with PASS/FAIL examples or the old judge is not reused, nor fired by a schedule; old runs are not repaired
|
|
171
|
+
const oldJob = reuse ? oldJobWords(reuse.spec) : null;
|
|
172
|
+
if (oldJob !== null) return Promise.resolve({ ok: /** @type {false} */ (false), status: 400, error: `${oldJob} Nothing spent.` });
|
|
171
173
|
// piece 8: the card's Flow type and MCP pick, decided at $0 before any session (a reuse keeps the signed spec's own MCP). Nothing is started: the pick reads the check log.
|
|
172
174
|
/** @type {ReturnType<typeof resolveFlowCard>} */
|
|
173
175
|
const flow = reuse
|
|
174
176
|
? { ok: true, flowType: flowTypeOf(reuse.spec), pick: reuse.spec?.mcp ? { server: reuse.spec.mcp.server, tools: reuse.spec.mcp.tools } : null }
|
|
175
177
|
: resolveFlowCard(card, { ...(opts.home !== undefined ? { home: opts.home } : {}), ...(opts.mcpHome !== undefined ? { mcpHome: opts.mcpHome } : {}) });
|
|
176
178
|
if (!flow.ok) return Promise.resolve({ ok: /** @type {false} */ (false), status: 400, error: flow.error });
|
|
179
|
+
// hamr 2026-11-14 (piece 5): a Tickets + rubric job's one input is its ticket line, numbered 1, by the same owner the card, the session and Reuse read
|
|
180
|
+
inputs = ticketRubricInputs(inputs, { rubric, flowType: flow.flowType });
|
|
181
|
+
if (flow.flowType === 'tickets') card = { ...card, flowType: 'tickets' };
|
|
182
|
+
const filesJob = rubric && inputs.length > 0 && looksLikeRubricInput(inputs[0].value);
|
|
177
183
|
const ticketProblem = ticketBoxProblem(card, flow.flowType);
|
|
178
184
|
if (ticketProblem !== null) return Promise.resolve({ ok: /** @type {false} */ (false), status: 400, error: ticketProblem });
|
|
179
185
|
// piece 9 (R7): the card's Schedule row, decided at $0 before any session exists. A scheduled fire is a headless start with no Schedule row, so it never reaches this.
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
// `src/panel/server.js`'s POST routes). Nothing here changes what a step
|
|
21
21
|
// means or what an answer does — only where the answer comes from.
|
|
22
22
|
|
|
23
|
-
import { judgePick,
|
|
24
|
-
import { ConfigError } from '../config.js';
|
|
23
|
+
import { judgePick, keyValueOf, modelChoiceFor, ratesOfLine, rowsForHome } from '../providerrows.js';
|
|
25
24
|
import {
|
|
26
25
|
mkdirSync, existsSync, writeFileSync, readdirSync,
|
|
27
26
|
} from 'node:fs';
|
|
@@ -42,34 +41,37 @@ import {
|
|
|
42
41
|
import { prepareSigning } from '../authorjob.js';
|
|
43
42
|
import { checkCloseByteSignature } from '../close-integrity.js';
|
|
44
43
|
import {
|
|
45
|
-
questionsFor, requiredAnswersFor, makeLoopGenerate, confirmSystemFor,
|
|
44
|
+
questionsFor, requiredAnswersFor, makeLoopGenerate, confirmSystemFor,
|
|
46
45
|
} from '../authorflow.js';
|
|
47
46
|
import {
|
|
48
47
|
resolveProvider, buildRunnerProviders, apiKeyProblem,
|
|
49
48
|
} from '../providers.js';
|
|
50
|
-
import { resolveJobJudge
|
|
49
|
+
import { resolveJobJudge } from '../judged.js';
|
|
51
50
|
import { assertThinkingMode, thinkingPlanFor, thinkingRowText, thinkingCallOptions } from '../thinking.js';
|
|
52
|
-
import { closeJudges } from '../kinds.js';
|
|
53
51
|
import { RUBRIC_LANG } from '../authoring.js';
|
|
54
52
|
import { rubricGoal, cardOfClose, signedFactNames } from '../rubricstep.js';
|
|
55
53
|
import { redactSecrets } from '../validate.js';
|
|
56
|
-
import { FLOW_TYPES } from '../job.js';
|
|
54
|
+
import { FLOW_TYPES, flowTypeOf, oldJobWords } from '../job.js';
|
|
57
55
|
import { mcpPickFor, signFlow } from '../mcppick.js';
|
|
58
56
|
import { parseTicketList, ticketNumberOf, TICKET_NUMBER_WORDS } from '../ticketshape.js';
|
|
57
|
+
import { newestUnrunTicket } from '../ticketnext.js';
|
|
58
|
+
import { readTicket } from '../ticket.js';
|
|
59
|
+
import { readRunList } from '../runlist.js';
|
|
60
|
+
import { fetchPageText } from '../pagefetch.js';
|
|
59
61
|
import { isDropIt, isAgree, stripAgreeLead } from '../pagemap.js';
|
|
60
|
-
import { plainWords, SUGGEST_SYSTEM
|
|
62
|
+
import { plainWords, SUGGEST_SYSTEM } from '../checkpick.js';
|
|
61
63
|
import { LEDGER_SYSTEM } from '../checklist.js';
|
|
62
64
|
import { ROW_EDIT_SYSTEM } from '../rowedit.js';
|
|
63
65
|
import { readRecordFile, readRowChoices, writeRecordPart, RECORD_FILE, KEPT_WORDS } from '../pickrecord.js';
|
|
64
66
|
import { MAX_REVISES, draftLabelOf, nextRevisesUsed, sessionsRootOf, writeRevisesUsed } from '../revises.js';
|
|
65
|
-
import { FIT_ABSENT_NOTE } from '../fitcheck.js';
|
|
66
67
|
import { runDestPoint, destQuestionText, yesNoOf } from '../destpoint.js';
|
|
68
|
+
import { runNoteAsk } from '../noteask.js';
|
|
67
69
|
import { tallyCalls } from '../text.js';
|
|
68
70
|
import { appendDraftLog, readDraftLedger } from '../draftspend.js';
|
|
69
|
-
import {
|
|
71
|
+
import { signingStopText, draftStopText, redsRecord, declarationRecord, tryRefusedText } from '../authorreadout.js';
|
|
70
72
|
import { runNpmCi, NPM_CI_LOCKS } from '../npminstall.js';
|
|
71
73
|
import {
|
|
72
|
-
parseJobBlock, parseInputs,
|
|
74
|
+
parseJobBlock, parseInputs, renderJobLines, signedJobLines, jobBoxText, REPO_RUBRIC_WORDS,
|
|
73
75
|
} from '../jobblock.js';
|
|
74
76
|
import { planFromConfirm } from './jobplan.js';
|
|
75
77
|
import { boxFor, offersOf, panelQuestionText, refuseChoice, resolveChoice } from '../questionbox.js';
|
|
@@ -95,7 +97,6 @@ export const STEP_LABELS = Object.freeze({
|
|
|
95
97
|
listing: 'listing files',
|
|
96
98
|
confirm: 'confirming plan',
|
|
97
99
|
draft: 'drafting',
|
|
98
|
-
calibrate: 'calibrating',
|
|
99
100
|
gates: 'checking signing gates',
|
|
100
101
|
hash: 'generating hash',
|
|
101
102
|
signed: 'signed hash',
|
|
@@ -131,17 +132,11 @@ export const PHASE_STEP = Object.freeze({
|
|
|
131
132
|
'scout-done': 'scout',
|
|
132
133
|
look: 'look',
|
|
133
134
|
'look-done': 'look',
|
|
134
|
-
// F243: the fit check's one call is counted in the look's line, like the look
|
|
135
|
-
'fit-check': 'look',
|
|
136
|
-
'fit-check-done': 'look',
|
|
137
135
|
confirm: 'confirm',
|
|
138
136
|
'confirm-turn-done': 'confirm',
|
|
139
137
|
listing: 'listing',
|
|
140
138
|
'listing-done': 'listing',
|
|
141
139
|
author: 'draft',
|
|
142
|
-
rubric: 'calibrate',
|
|
143
|
-
'rubric-done': 'calibrate',
|
|
144
|
-
'rubric-scrubbed': 'calibrate',
|
|
145
140
|
});
|
|
146
141
|
|
|
147
142
|
export { thinkingRowText };
|
|
@@ -238,6 +233,31 @@ export function nextFreeJobName(origin, runJobs, opts = {}) {
|
|
|
238
233
|
/** the form's fields, in card order — what `card.json` stores, verbatim (P5 item 3) */
|
|
239
234
|
export const CARD_FIELDS = Object.freeze(['jobName', 'checkType', 'provider', 'model', 'thinking', 'jobText', 'inputs', 'destination', 'capUsd', 'maxWallMs', 'flowType', 'mcp', 'ticket', 'schedule']);
|
|
240
235
|
|
|
236
|
+
/**
|
|
237
|
+
* 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
|
|
238
|
+
* Destination check and Reuse (`buildReuseSpec`) all read THIS, never a copy.
|
|
239
|
+
* @param {any} card
|
|
240
|
+
* @param {{rubric?: boolean, flowType?: 'plain'|'mcp'|'tickets'}} [o]
|
|
241
|
+
* @returns {{ok: true, inputs: import('../jobblock.js').JobInput[]}|{ok: false, error: string}}
|
|
242
|
+
*/
|
|
243
|
+
export function cardInputs(card, o = {}) {
|
|
244
|
+
const ip = parseInputs(card?.inputs);
|
|
245
|
+
if (!ip.ok) return ip;
|
|
246
|
+
return { ok: true, inputs: ticketRubricInputs(ip.inputs, { rubric: o.rubric ?? card?.checkType === 'rubric', flowType: o.flowType ?? flowOfCard(card).flowType }) };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 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
|
|
251
|
+
* 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.
|
|
252
|
+
* @param {import('../jobblock.js').JobInput[]} inputs @param {{rubric: boolean, flowType: 'plain'|'mcp'|'tickets'}} o
|
|
253
|
+
* @returns {import('../jobblock.js').JobInput[]}
|
|
254
|
+
*/
|
|
255
|
+
export function ticketRubricInputs(inputs, { rubric, flowType }) {
|
|
256
|
+
if (!rubric || flowType !== 'tickets') return inputs;
|
|
257
|
+
const line = inputs.find((i) => parseTicketList(i.value).ok);
|
|
258
|
+
return line ? [{ ...line, n: 1 }] : inputs;
|
|
259
|
+
}
|
|
260
|
+
|
|
241
261
|
/**
|
|
242
262
|
* The repo a card names: Inputs line 1 (P7 — the Source box is gone; the first input IS the repo). `''` when the Inputs
|
|
243
263
|
* box does not parse (the card validator refuses that before anything uses this).
|
|
@@ -245,7 +265,7 @@ export const CARD_FIELDS = Object.freeze(['jobName', 'checkType', 'provider', 'm
|
|
|
245
265
|
* @returns {string}
|
|
246
266
|
*/
|
|
247
267
|
export function cardSource(card) {
|
|
248
|
-
const p =
|
|
268
|
+
const p = cardInputs(card);
|
|
249
269
|
return p.ok ? p.inputs[0].value : '';
|
|
250
270
|
}
|
|
251
271
|
|
|
@@ -264,7 +284,7 @@ export function cardFields(card) {
|
|
|
264
284
|
/**
|
|
265
285
|
* 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
|
|
266
286
|
* 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,
|
|
267
|
-
* `~` rules
|
|
287
|
+
* `~` rules), the check type and the thinking tick. The RUN boxes (Inputs, Destination, Model, $ cap, Time cap)
|
|
268
288
|
* never decide it. A green origin with no job box changed reuses the signed plan verbatim (no drafting); anything else drafts.
|
|
269
289
|
*/
|
|
270
290
|
export const JOB_BOXES = Object.freeze(['jobText', 'checkType', 'thinking', 'flowType', 'mcp']);
|
|
@@ -350,7 +370,7 @@ export function buildReuseSpec(originSpec, card, rows) {
|
|
|
350
370
|
// an ABSOLUTE Destination is a per-run output folder (a plain-files job): it is never part of the signed spec, and the spec's own
|
|
351
371
|
// fence (inside the run's tree) stays as signed. A repo job's Destination is the fence and is relative (an absolute one is refused).
|
|
352
372
|
if (!isAbsoluteDestination(String(card.destination ?? '').trim())) spec.writeScope = String(card.destination ?? '').split(/[,\n]/).map((x) => x.trim()).filter(Boolean);
|
|
353
|
-
const ip =
|
|
373
|
+
const ip = cardInputs(card, { rubric: spec.verdictType === 'soft-green', flowType: flowTypeOf(spec) });
|
|
354
374
|
if (ip.ok) spec.inputs = ip.inputs; else delete spec.inputs;
|
|
355
375
|
spec.budgetUsd = card.capUsd;
|
|
356
376
|
if (typeof card.maxWallMs === 'number' && Number.isFinite(card.maxWallMs) && card.maxWallMs > 0) spec.maxWallMs = card.maxWallMs;
|
|
@@ -406,7 +426,7 @@ export const DESTINATION_HINT = 'Type the folder that holds the files the job sh
|
|
|
406
426
|
* @returns {string|null} the plain refusal, or null when the Destination is fine
|
|
407
427
|
*/
|
|
408
428
|
export function startDestinationProblem(card) {
|
|
409
|
-
const ip =
|
|
429
|
+
const ip = cardInputs(card);
|
|
410
430
|
const source = ip.ok ? (ip.inputs[0]?.value ?? '') : '';
|
|
411
431
|
const destination = typeof card?.destination === 'string' ? card.destination : '';
|
|
412
432
|
const isRepoLike = looksLikeRepoSource(source);
|
|
@@ -455,13 +475,10 @@ export function validateJobCard(card, opts = {}) {
|
|
|
455
475
|
if (card.thinking !== undefined && typeof card.thinking !== 'boolean') return { ok: false, error: 'Thinking on must be on or off' };
|
|
456
476
|
const jb = parseJobBlock(card.jobText);
|
|
457
477
|
if (!jb.ok) return { ok: false, error: jb.error };
|
|
458
|
-
const ib =
|
|
478
|
+
const ib = cardInputs(card);
|
|
459
479
|
if (!ib.ok) return { ok: false, error: ib.error };
|
|
460
|
-
//
|
|
461
|
-
|
|
462
|
-
const rubricFiles = checkType === 'rubric' && looksLikeRubricInput(ib.inputs[0].value);
|
|
463
|
-
const misfit = jobBlockFitsCheck(jb.lines, checkType === 'rubric', { judged: !rubricFiles });
|
|
464
|
-
if (misfit) return { ok: false, error: misfit };
|
|
480
|
+
// hamr 2026-11-14: a repo job is Deterministic. Rubric on a repo is for a Tickets job only (its input is the ticket, below).
|
|
481
|
+
if (checkType === 'rubric' && flowOfCard(card).flowType !== 'tickets' && looksLikeRepoSource(ib.inputs[0].value)) return { ok: false, error: REPO_RUBRIC_WORDS };
|
|
465
482
|
if (typeof destination !== 'string' || destination.trim() === '') return { ok: false, error: 'Destination is required' };
|
|
466
483
|
if (typeof capUsd !== 'number' || !Number.isFinite(capUsd) || capUsd <= 0) {
|
|
467
484
|
return { ok: false, error: '$ cap is required and must be a positive number' };
|
|
@@ -476,8 +493,8 @@ export function validateJobCard(card, opts = {}) {
|
|
|
476
493
|
* `signPrepare()` are the only ways in.
|
|
477
494
|
* @param {any} card the validated job card (see {@link validateJobCard})
|
|
478
495
|
* @param {{env?: Record<string,string|undefined>, sessionsRoot?: string, home?: string, timeoutMs?: number,
|
|
479
|
-
* scout?: any, generate?: Function, pickGenerate?: Function|null, ledgerGenerate?: Function|null, editGenerate?: Function|null, carryFrom?: string, carryKind?: string, confirmGenerate?: Function, authorFn?: Function,
|
|
480
|
-
* prepareSigningFn?: Function, npmCiFn?: Function, lookFn?: Function|null,
|
|
496
|
+
* scout?: any, generate?: Function, pickGenerate?: Function|null, ledgerGenerate?: Function|null, noteFn?: Function|null, editGenerate?: Function|null, carryFrom?: string, carryKind?: string, confirmGenerate?: Function, authorFn?: Function,
|
|
497
|
+
* 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
|
|
481
498
|
* TEST SEAMS ONLY — see the note just above where each is read, below. `reuse` (Reuse workflow) is NOT a seam: the
|
|
482
499
|
* caller (`/api/author/start`) sets it only when the server's own same-job rule held.
|
|
483
500
|
* @returns {any} the session object
|
|
@@ -491,7 +508,7 @@ export function createSession(card, deps = {}) {
|
|
|
491
508
|
// block before a session exists; a reuse card's job text is the origin's and is not drafted from.
|
|
492
509
|
const jobParsed = parseJobBlock(card.jobText);
|
|
493
510
|
const jobLines = jobParsed.ok ? jobParsed.lines : [];
|
|
494
|
-
const inputsParsed =
|
|
511
|
+
const inputsParsed = cardInputs(card, { flowType: deps.flow?.flowType ?? 'plain' });
|
|
495
512
|
const INPUTS = inputsParsed.ok ? inputsParsed.inputs : [];
|
|
496
513
|
/** the repo — Inputs line 1 */
|
|
497
514
|
const SOURCE = INPUTS[0]?.value ?? '';
|
|
@@ -582,7 +599,7 @@ export function createSession(card, deps = {}) {
|
|
|
582
599
|
};
|
|
583
600
|
|
|
584
601
|
/** a rubric job on local files words its copy/read steps for files (set once the card is known) */
|
|
585
|
-
let fileJob = card.checkType === 'rubric' && looksLikeRubricInput(
|
|
602
|
+
let fileJob = card.checkType === 'rubric' && looksLikeRubricInput(INPUTS[0]?.value ?? '');
|
|
586
603
|
/** @param {string} id @param {string} [detail] (absent = keep what the step has) start (or restart) a step; whatever step was running is finished */
|
|
587
604
|
const stepStart = (id, detail) => {
|
|
588
605
|
const labels = fileJob ? { ...STEP_LABELS, ...FILE_JOB_STEP_LABELS } : STEP_LABELS;
|
|
@@ -664,7 +681,7 @@ export function createSession(card, deps = {}) {
|
|
|
664
681
|
if (step.kind === 'language') say('bot', `${step.field?.prompt ?? 'Which language is this job about?'} (${(step.candidates ?? []).join(', ')})`);
|
|
665
682
|
else if (step.kind === 'menu') {
|
|
666
683
|
sayPlan(step.plan ?? {});
|
|
667
|
-
} else if (step.kind === 'answer' && (step.source === '
|
|
684
|
+
} else if (step.kind === 'answer' && (step.source === 'dest-point')) sayOpen(panelQuestionText(/** @type {any} */ (step)));
|
|
668
685
|
else if (step.kind === 'answer') sayOpen(`A question the plan raised (${step.index} of ${step.total})${Number.isInteger(step.line) ? `, about job line ${step.line}` : ''}: ${panelQuestionText(/** @type {any} */ (step))}`);
|
|
669
686
|
else if (step.kind === 'goal') say('bot', 'Type the goal sentence yourself.');
|
|
670
687
|
});
|
|
@@ -683,19 +700,6 @@ export function createSession(card, deps = {}) {
|
|
|
683
700
|
};
|
|
684
701
|
|
|
685
702
|
let lastTryRefused = false;
|
|
686
|
-
// F243: the fit check's result is one drafting-log row (the asks, what was found, what the quote proved); an `absent` check says so in chat
|
|
687
|
-
// (a seam of its own - onPhase never posts a chat message)
|
|
688
|
-
const onFit = (/** @type {any} */ data) => {
|
|
689
|
-
const running = state.steps.findLastIndex((/** @type {any} */ x) => x.status === 'running');
|
|
690
|
-
appendDraftLog(outDir, {
|
|
691
|
-
kind: 'fit-check', no: running === -1 ? Math.max(0, state.steps.length - 1) : running, state: String(data.state ?? 'absent'),
|
|
692
|
-
asks: (Array.isArray(data.asks) ? data.asks : []).map((/** @type {any} */ a) => ({
|
|
693
|
-
line: a.line, ask: redactSecrets(String(a.ask)), found: a.found === true, quote: typeof a.quote === 'string' ? redactSecrets(a.quote) : null, madeUp: a.madeUp === true, ...(a.ignored === 'number' ? { ignored: 'number' } : {}),
|
|
694
|
-
})),
|
|
695
|
-
notFound: (Array.isArray(data.notFound) ? data.notFound : []).map((/** @type {any} */ x) => ({ line: x.line, ask: redactSecrets(String(x.ask)) })), at: new Date().toISOString(),
|
|
696
|
-
});
|
|
697
|
-
if (data.state === 'absent') say('bot', FIT_ABSENT_NOTE);
|
|
698
|
-
};
|
|
699
703
|
const onPhase = (name, data = {}) => {
|
|
700
704
|
// COLLAPSED INTO THE PROGRESS INDICATOR ONLY (build item 3) — this used
|
|
701
705
|
// to also `say('system', `… ${name}`)`, one jargon chat bubble per
|
|
@@ -710,6 +714,7 @@ export function createSession(card, deps = {}) {
|
|
|
710
714
|
// progress line shows it briefly, in code's words
|
|
711
715
|
// PRD v1.131 tick 7: the retention counts of a rubric draft, one line when it ends (counts only, no words)
|
|
712
716
|
// the one check list of a rubric job: each row once when it is built and once at the end, and each try's refusals (kind `ledger` / `ledger-try`)
|
|
717
|
+
if (name === 'note-answered') appendDraftLog(outDir, { kind: 'note-ask', no: Math.max(0, state.steps.length - 1), state: data.state, answers: data.answers, ...(data.reason ? { reason: redactSecrets(String(data.reason)) } : {}), at: new Date().toISOString() });
|
|
713
718
|
if (name === 'ledger-built' && Array.isArray(data.rows)) for (const r of data.rows) appendDraftLog(outDir, { phase: 'built', ...r, kind: 'ledger', no: Math.max(0, state.steps.length - 1), at: new Date().toISOString() });
|
|
714
719
|
if (name === 'draft-ledger-try') appendDraftLog(outDir, { kind: 'ledger-try', no: Math.max(0, state.steps.length - 1), label: data.label, kept: data.kept, refused: data.refused, at: new Date().toISOString() });
|
|
715
720
|
if (name === 'draft-ledger' && Array.isArray(data.rows)) for (const r of data.rows) appendDraftLog(outDir, { phase: 'final', ...r, kind: 'ledger', no: Math.max(0, state.steps.length - 1), at: new Date().toISOString() });
|
|
@@ -851,6 +856,9 @@ export function createSession(card, deps = {}) {
|
|
|
851
856
|
const keyProblem = apiKeyProblem(apiKey);
|
|
852
857
|
if (keyProblem) { refuse(`${draftKeyName} ${keyProblem}. Stopped — nothing spent.`); return; }
|
|
853
858
|
|
|
859
|
+
// hamr 2026-11-14 (piece 6): a job made with PASS/FAIL examples or the old judge is not reused; old runs are not repaired. Before any copy or read.
|
|
860
|
+
const oldJob = deps.reuse ? oldJobWords(deps.reuse.spec) : null;
|
|
861
|
+
if (oldJob !== null) { refuse(`${oldJob} Nothing spent.`); return; }
|
|
854
862
|
const verdictType = card.checkType === 'rubric' ? 'soft-green' : 'green';
|
|
855
863
|
const into = join(outDir, 'source-seed');
|
|
856
864
|
const isRepoLike = looksLikeRepoSource(SOURCE);
|
|
@@ -883,7 +891,20 @@ export function createSession(card, deps = {}) {
|
|
|
883
891
|
/** @type {any} */
|
|
884
892
|
let prep;
|
|
885
893
|
if (RUBRIC_FILES) {
|
|
886
|
-
|
|
894
|
+
// hamr 2026-11-14 (piece 5): a Tickets + rubric job's one input is the ticket. The drafting-time read takes the newest ticket this job has not run
|
|
895
|
+
// (the product's own lookup, `newestUnrunTicket`) and reads it (`readTicket`): there is no ticket-number box. Run start re-reads the same list row.
|
|
896
|
+
const ticketFlow = deps.flow?.flowType === 'tickets' && deps.flow.pick ? deps.flow.pick : null;
|
|
897
|
+
/** @param {string} url @returns {Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>} */
|
|
898
|
+
const readNewestTicket = async (url) => {
|
|
899
|
+
const rows = (() => { try { return readRunList({ home: configHome }).rows; } catch { return []; } })();
|
|
900
|
+
const picked = await (deps.newestUnrunTicket ?? newestUnrunTicket)({ job: card.jobName, rows, inputs: INPUTS, mcp: /** @type {{server: string, tools: string[]}} */ (ticketFlow) });
|
|
901
|
+
if (!picked.ok) return { ok: false, error: picked.say.replace(/\s*Nothing spent\.$/, '') };
|
|
902
|
+
const t = await (deps.readTicketFn ?? readTicket)({ mcp: /** @type {{server: string, tools: string[]}} */ (ticketFlow), listUrl: url, number: picked.number });
|
|
903
|
+
return t.ok ? { ok: true, text: t.ticket.text, url } : { ok: false, error: t.error };
|
|
904
|
+
};
|
|
905
|
+
const pageFetch = deps.fetchUrl ?? fetchPageText;
|
|
906
|
+
const draftFetch = ticketFlow ? (/** @type {string} */ url) => (parseTicketList(url).ok ? readNewestTicket(url) : pageFetch(url)) : deps.fetchUrl;
|
|
907
|
+
const proved = await proveRubricInputs({ inputs: INPUTS, into, destination: card.destination, ...(draftFetch ? { fetchUrl: draftFetch } : {}) });
|
|
887
908
|
prep = proved.ok ? proved.prep : { stop: proved.error, code: proved.code };
|
|
888
909
|
// what each header-only page read came back with (already secret-masked at capture), so the next live failure shows it
|
|
889
910
|
if (!proved.ok && proved.attempts?.length) appendDraftLog(outDir, { kind: 'page-fetch-attempts', no: Math.max(0, state.steps.length - 1), attempts: proved.attempts, at: new Date().toISOString() });
|
|
@@ -1024,53 +1045,13 @@ export function createSession(card, deps = {}) {
|
|
|
1024
1045
|
return;
|
|
1025
1046
|
}
|
|
1026
1047
|
state.phase = 'signing-gates';
|
|
1027
|
-
stepStart('gates', 'gates 1–3 cost $0
|
|
1028
|
-
const judges = closeJudges(spec.closeDecl);
|
|
1029
|
-
const judge = judges ? resolveJobJudge(spec, modelChoice.provider, resolveWorkerModel) : null;
|
|
1030
|
-
let judgeProvider = null;
|
|
1031
|
-
/** @type {import('../providerrows.js').PriceResult} */
|
|
1032
|
-
let judgePrice = null;
|
|
1033
|
-
if (judge) {
|
|
1034
|
-
const judgeRow = judgeRowFor(keyCfg, judge, modelChoice.provider, keyCfg.find((r) => r.envName === modelChoice.envName) ?? null);
|
|
1035
|
-
try {
|
|
1036
|
-
judgePrice = judgeRatesFor(judge, modelChoice.provider, modelChoice.baseUrl, draftPrice, keyCfg);
|
|
1037
|
-
} catch (e) {
|
|
1038
|
-
if (!(e instanceof ConfigError)) throw e;
|
|
1039
|
-
refuse(`${e.message} — refusing before gate 4 spends anything`);
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
const judgeKeyValue = env.JUDGE_API_KEY ?? (judge.provider === modelChoice.provider ? apiKey : keyValueOf(env, judgeRow?.envName));
|
|
1043
|
-
const judgeKeyProblem = judgeKeyValue ? apiKeyProblem(judgeKeyValue) : null;
|
|
1044
|
-
if (!judgeKeyValue || judgeKeyProblem) {
|
|
1045
|
-
refuse(`the judge key is not usable (${judgeKeyProblem ?? 'not set'}) — refusing before gate 4 spends anything`);
|
|
1046
|
-
return;
|
|
1047
|
-
}
|
|
1048
|
-
judgeProvider = buildRunnerProviders({
|
|
1049
|
-
providerName: modelChoice.provider, apiKey, model: MODEL, baseUrl: modelChoice.baseUrl, legacyMaxTokens: modelChoice.legacyMaxTokens,
|
|
1050
|
-
judgeApiKey: judgeKeyValue, judgeModel: judge.model, judgeProviderName: judge.provider,
|
|
1051
|
-
judgeBaseUrl: judge.provider === modelChoice.provider ? modelChoice.baseUrl : (judgeRow?.baseUrl.trim() || undefined),
|
|
1052
|
-
judgeLegacyMaxTokens: judge.provider === modelChoice.provider ? modelChoice.legacyMaxTokens : (judgeRow?.legacyMaxTokens ?? false),
|
|
1053
|
-
}).judgeProvider;
|
|
1054
|
-
}
|
|
1048
|
+
stepStart('gates', 'gates 1–3 cost $0');
|
|
1055
1049
|
const signing = await prepareSigningFn({
|
|
1056
1050
|
spec, workdir: prep.tree, seedRef: seedRef, timeoutMs,
|
|
1057
|
-
shellCapUsd: spec.budgetUsd,
|
|
1058
|
-
judgeLoop: judgeProvider ? (o) => defaultJudgeLoop({ provider: judgeProvider, system: o.system, rates: judgePrice?.rates ?? null, thinking: spec.thinking === true }) : null,
|
|
1059
|
-
judgeModel: judge?.model ?? null,
|
|
1060
|
-
onJudgeCost: (c) => onCall({ label: `${c.label}:${c.id}`, costUsd: c.costUsd, unpricedRounds: c.unpricedRounds }),
|
|
1051
|
+
shellCapUsd: spec.budgetUsd,
|
|
1061
1052
|
});
|
|
1062
1053
|
const signingFile = join(outDir, 'signing.json');
|
|
1063
1054
|
writeFileSync(signingFile, `${JSON.stringify(signing, null, 2)}\n`);
|
|
1064
|
-
// The `calibrating` line is the rubric phase the person watched; its ✓ was set long before the gate graded
|
|
1065
|
-
// anything. Once the gate has a result, the line says THAT, on its own line (hamr, 2026-10-09).
|
|
1066
|
-
const calSum = calibrationSummary(signing.gates?.calibration);
|
|
1067
|
-
const calStep = latestStep(state.steps, 'calibrate');
|
|
1068
|
-
if (calSum && calStep) {
|
|
1069
|
-
calStep.status = calSum.ok ? 'done' : 'failed';
|
|
1070
|
-
calStep.detail = calSum.note;
|
|
1071
|
-
logSteps();
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
1055
|
if (!signing.ok) {
|
|
1075
1056
|
// plain words for the person (src/authorreadout.js, the one owner the CLI prints too); the full reds go into
|
|
1076
1057
|
// the drafting log on the failed step, so the cause survives the session
|
|
@@ -1146,19 +1127,13 @@ export function createSession(card, deps = {}) {
|
|
|
1146
1127
|
|
|
1147
1128
|
/** @type {Record<string, string>} */
|
|
1148
1129
|
const answers = { 1: renderJobLines(jobLines) };
|
|
1149
|
-
if (verdictType === 'soft-green') answers[SOFTGREEN_JUDGE_EXAMPLES_KEY] = renderExamples(jobLines);
|
|
1150
|
-
// a rubric job on files holds no judged part in this build, so the PASS/FAIL examples are not required of it
|
|
1151
1130
|
const required = RUBRIC_FILES ? [1] : requiredAnswersFor(verdictType);
|
|
1152
1131
|
for (const n of required) {
|
|
1153
1132
|
if (!answers[n]) { refuse(`the ${verdictType} check type needs ${required.length} answers and one is missing (key ${n})`); return; }
|
|
1154
1133
|
}
|
|
1155
1134
|
|
|
1156
|
-
const draftJudge = (() => {
|
|
1157
|
-
try { return resolveJobJudge(draft, modelChoice.provider, resolveWorkerModel); } catch { return { provider: modelChoice.provider, model: modelChoice.name }; }
|
|
1158
|
-
})();
|
|
1159
1135
|
const { provider } = buildRunnerProviders({
|
|
1160
1136
|
providerName: modelChoice.provider, apiKey, model: MODEL, baseUrl: modelChoice.baseUrl, legacyMaxTokens: modelChoice.legacyMaxTokens,
|
|
1161
|
-
judgeApiKey: apiKey, judgeModel: MODEL, judgeProviderName: modelChoice.provider, judgeBaseUrl: modelChoice.baseUrl,
|
|
1162
1137
|
});
|
|
1163
1138
|
// TEST SEAMS (see the constructor's own note): a test overrides
|
|
1164
1139
|
// `generate`/`confirmGenerate` directly (bypassing this real, constructed
|
|
@@ -1218,6 +1193,19 @@ export function createSession(card, deps = {}) {
|
|
|
1218
1193
|
// ask path as every other (the chat box + Send); the answer is REQUIRED (a blank one asks again, there is no skip) and is
|
|
1219
1194
|
// added WORD FOR WORD as a `~` rule on the job line it names — never rewritten. The lines are mutated in place, so the
|
|
1220
1195
|
// signed `jobLines`, the answers text and the plan card all read the same words.
|
|
1196
|
+
/** the job text as the draft shows and signs it: the signed lines, the card's box, the answers text and one message (the check list's rebuilt lines, or the lines a try-3 answer added) */
|
|
1197
|
+
const syncJobLines = (/** @type {any[]} */ lines, /** @type {string|null} */ say = null, /** @type {any} */ confirmed = null) => {
|
|
1198
|
+
// ONE owner: the session's own lines take the rebuilt ones in place, so the plan cards (`planMessage(..., jobLines)`) and the signed rows read the same words
|
|
1199
|
+
if (lines !== jobLines) jobLines.splice(0, jobLines.length, ...lines);
|
|
1200
|
+
draft.jobLines = signedJobLines(lines);
|
|
1201
|
+
// the card's job box holds the rules as they now are (an answer replaced the rule it was asked about), so a Revise reopens the boxes with them; `card` is what card.json stores
|
|
1202
|
+
state.card = { ...state.card, jobText: jobBoxText(lines) };
|
|
1203
|
+
card = { ...card, jobText: state.card.jobText };
|
|
1204
|
+
answers[1] = renderJobLines(lines);
|
|
1205
|
+
if (say !== null) state.messages.push({ ...planMessage({ ...(confirmed ?? {}), ...(pickedSoFar.length ? { picked: [...pickedSoFar] } : {}) }, lines), text: say });
|
|
1206
|
+
};
|
|
1207
|
+
/** the answers message of a check-list ask, drawn once the list has rebuilt the lines @type {{say: string, confirmed: any}|null} */
|
|
1208
|
+
let pendingSay = null;
|
|
1221
1209
|
const answerQuestions = async (/** @type {{questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string, ruleText?: string, check?: Record<string, any>}[], dropped: {reason: string, raw: any}[], confirmed: any}} */ o) => {
|
|
1222
1210
|
if (o.dropped.length) appendDraftLog(outDir, { kind: 'questions-dropped', no: Math.max(0, state.steps.length - 1), dropped: o.dropped, at: new Date().toISOString() });
|
|
1223
1211
|
const total = o.questions.length;
|
|
@@ -1255,43 +1243,34 @@ export function createSession(card, deps = {}) {
|
|
|
1255
1243
|
const canDrop = q.source === 'look' && (q.ask === 'cant-check' || q.ask === 'no-check' || q.ask === 'check') && Number.isInteger(q.rule);
|
|
1256
1244
|
if (typeof (/** @type {any} */ (q)).key === 'string') choices.push({ key: /** @type {any} */ (q).key, choice: canDrop && dropsIt ? 'drop' : canAgree && agrees ? 'agree' : 'rule', text });
|
|
1257
1245
|
if (q.source === 'look' && q.ask === 'cant-check' && Number.isInteger(q.rule) && dropsIt) { left.push({ line: q.line, rule: /** @type {number} */ (q.rule) }); continue; }
|
|
1258
|
-
// R10 (fwd am16): a check-pick ask. `agree`
|
|
1259
|
-
// is the person's own words,
|
|
1260
|
-
let agreedPick = false;
|
|
1246
|
+
// R10 (fwd am16): a check-pick ask. `agree` REPLACES the asked rule with the proposal's plain words and picks the check; "drop it" leaves the rule Not checked; anything else
|
|
1247
|
+
// is the person's own words, which replace the asked rule word for word (no check unless the words are the check: they judge it at Accept)
|
|
1261
1248
|
const isPick = q.source === 'look' && (q.ask === 'check' || q.ask === 'no-check') && Number.isInteger(q.rule);
|
|
1262
|
-
|
|
1263
|
-
const pair = isPick && Number.isInteger(/** @type {any} */ (q).pairRule) ? /** @type {number} */ (/** @type {any} */ (q).pairRule) : null;
|
|
1264
|
-
if (isPick && dropsIt) { left.push({ line: q.line, rule: /** @type {number} */ (q.rule) }); if (pair !== null) left.push({ line: q.line, rule: pair }); appendDraftLog(outDir, { kind: 'check-pick', no: Math.max(0, state.steps.length - 1), line: q.line, rule: q.rule, ruleText: redactSecrets(String(q.ruleText ?? '')), proposed: q.reading ?? null, how: 'drop it', at: new Date().toISOString() }); continue; }
|
|
1249
|
+
if (isPick && dropsIt) { left.push({ line: q.line, rule: /** @type {number} */ (q.rule) }); appendDraftLog(outDir, { kind: 'check-pick', no: Math.max(0, state.steps.length - 1), line: q.line, rule: q.rule, ruleText: redactSecrets(String(q.ruleText ?? '')), proposed: q.reading ?? null, how: 'drop it', at: new Date().toISOString() }); continue; }
|
|
1265
1250
|
if (isPick) {
|
|
1266
1251
|
const agreed = q.ask === 'check' && q.check && agrees;
|
|
1267
1252
|
if (agreed) text = plainWords(/** @type {any} */ (q.check));
|
|
1268
|
-
agreedPick = agreed === true;
|
|
1269
1253
|
if (agreed) pickedSoFar.push({ line: q.line, text: plainWords(/** @type {any} */ (q.check)) });
|
|
1270
|
-
picks.push({ line: q.line, rule:
|
|
1254
|
+
picks.push({ line: q.line, rule: /** @type {number} */ (q.rule), check: agreed ? /** @type {any} */ (q.check) : null, ...(agreed ? {} : { own: true }) });
|
|
1271
1255
|
appendDraftLog(outDir, { kind: 'check-pick', no: Math.max(0, state.steps.length - 1), line: q.line, rule: q.rule, ruleText: redactSecrets(String(q.ruleText ?? '')), proposed: q.reading ?? null, how: agreed ? 'agree' : 'own words', ...(agreed ? { picked: q.check } : {}), added: redactSecrets(text), at: new Date().toISOString() });
|
|
1272
1256
|
}
|
|
1257
|
+
// one rule in, one rule out (hamr 2026-11-14): an answer about a rule of the check list REPLACES that rule, and the list is the one owner (the caller rebuilds the job text from it: `onJobLines`).
|
|
1258
|
+
// Only an answer that is not about a list row (a model's own try-3 question) is still added word for word as a new `~` rule on its line.
|
|
1273
1259
|
const line = jobLines.find((l) => l.n === q.line);
|
|
1274
|
-
if (
|
|
1275
|
-
// F318: agreeing to words the line already holds as a ~ rule adds no second line (the pick cites the rule that is there); different words still add one
|
|
1276
|
-
else if (line && !(agreedPick && line.rules.some((/** @type {string} */ t) => sameRuleWords(t, text)))) { line.rule = line.rule ? `${line.rule}; ${text}` : text; line.rules.push(text); }
|
|
1260
|
+
if (q.source !== 'look' && line) { line.rule = line.rule ? `${line.rule}; ${text}` : text; line.rules.push(text); }
|
|
1277
1261
|
}
|
|
1278
|
-
|
|
1279
|
-
//
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
state.messages.push({ ...planMessage({ ...(o.confirmed ?? {}), ...(pickedSoFar.length ? { picked: [...pickedSoFar] } : {}) }, jobLines), text: left.length === total ? 'Noted: those stay Not checked. Drafting.' : 'Your answers are in as ~ rules on those job lines. Drafting again.' });
|
|
1262
|
+
const said = left.length === total ? 'Noted: those stay Not checked. Drafting.' : 'Your answers are in on those job lines. Drafting again.';
|
|
1263
|
+
// a check-list ask (every question carries a list key): the list has not yet replaced the asked rules, so the message waits for the rebuilt lines (`onJobLines`) and is drawn from them
|
|
1264
|
+
if (o.questions.every((q) => typeof (/** @type {any} */ (q)).key === 'string')) pendingSay = { say: said, confirmed: o.confirmed };
|
|
1265
|
+
else syncJobLines(jobLines, said, o.confirmed);
|
|
1283
1266
|
return { jobLines, answers, left, picks, choices };
|
|
1284
1267
|
};
|
|
1285
1268
|
|
|
1286
|
-
//
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
if (String(a).trim()) return String(a);
|
|
1292
|
-
say('bot', 'An answer is needed here — there is no skip. Type it in the box below and press Send.');
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1269
|
+
// 2026-11-14 (b): the note question's own call (src/noteask.js), same provider, model and thinking-off as the destination call; a test that replaces the model boundary never reaches it unless it brings `deps.noteFn`
|
|
1270
|
+
const noteFn = deps.noteFn !== undefined ? deps.noteFn : (deps.generate ? null : (/** @type {any} */ o) => runNoteAsk({
|
|
1271
|
+
...o, provider, ...(draftPrice?.rates ? { rates: draftPrice.rates } : {}),
|
|
1272
|
+
...(Object.keys(thinkingCallOptions(provider, draftThinking)).length ? { callOptions: thinkingCallOptions(provider, draftThinking) } : {}),
|
|
1273
|
+
}));
|
|
1295
1274
|
|
|
1296
1275
|
state.phase = 'drafting';
|
|
1297
1276
|
// no early "drafting" line: the real author phase (PHASE_STEP) starts it, carrying draftDetail (see onPhase)
|
|
@@ -1299,7 +1278,6 @@ export function createSession(card, deps = {}) {
|
|
|
1299
1278
|
// the internal resolved tier model string (MODEL) or the raw provider
|
|
1300
1279
|
// name — the same id the Model field's own dropdown showed.
|
|
1301
1280
|
const authored = await authorCloseForJob({
|
|
1302
|
-
judgeModel: draftJudge.model,
|
|
1303
1281
|
answers, verdictType, repoPath: prep.tree, lang: LANG,
|
|
1304
1282
|
questions: questionsFor(verdictType),
|
|
1305
1283
|
jobLines, inputs: INPUTS,
|
|
@@ -1308,7 +1286,7 @@ export function createSession(card, deps = {}) {
|
|
|
1308
1286
|
rates: draftPrice?.rates ?? null,
|
|
1309
1287
|
draftThinking,
|
|
1310
1288
|
onPhase, onCall,
|
|
1311
|
-
ask, answerQuestions, confirmGenerate, isRepo: !RUBRIC_FILES, langResult, pickGenerate, ledgerGenerate, editGenerate, carriedPicks, carriedChoices,
|
|
1289
|
+
ask, answerQuestions, confirmGenerate, isRepo: !RUBRIC_FILES, langResult, pickGenerate, ledgerGenerate, noteFn, onJobLines: (/** @type {any[]} */ lines) => { const p = pendingSay; pendingSay = null; syncJobLines(lines, p ? p.say : null, p ? p.confirmed : null); }, editGenerate, carriedPicks, carriedChoices,
|
|
1312
1290
|
onChoices: (/** @type {any[]} */ rec) => { try { writeRecordPart(join(outDir, RECORD_FILE), { rowChoices: rec }); } catch { /* a convenience: a disk fault only means the next draft starts without them */ } },
|
|
1313
1291
|
// R10: this draft's record (the picks it kept and the ones just answered) goes to its own folder for the next draft to carry; each kept pick is logged as such
|
|
1314
1292
|
onPicks: (/** @type {{entries: any[], kept: {line: number, rule: number, entry: any}[]}} */ o) => {
|
|
@@ -1321,31 +1299,11 @@ export function createSession(card, deps = {}) {
|
|
|
1321
1299
|
...(deps.scout ? { scout: deps.scout } : {}),
|
|
1322
1300
|
// PART 1c: a test that replaces the model boundary (`generate`) must not reach the real paid look; `deps.lookFn` brings its own
|
|
1323
1301
|
...(deps.lookFn !== undefined ? { lookFn: deps.lookFn } : (deps.generate ? { lookFn: null } : {})),
|
|
1324
|
-
// F243: the fit check asks through the ordinary ask path; like the look, a test that replaces the model boundary never reaches the real paid call
|
|
1325
|
-
fitAsk, onFit,
|
|
1326
|
-
...(deps.fitFn !== undefined ? { fitFn: deps.fitFn } : (deps.generate ? { fitFn: null } : {})),
|
|
1327
1302
|
...(authorFnOverride ? { authorFn: authorFnOverride } : {}),
|
|
1328
1303
|
// R5 (piece 2): a Tickets job's drafter is told about the ticket filter and may propose one (the person signs it)
|
|
1329
1304
|
...(deps.flow?.flowType === 'tickets' ? { authorOpts: { ticket: true } } : {}),
|
|
1330
1305
|
});
|
|
1331
1306
|
|
|
1332
|
-
if (!authored.ok && PLAIN_PROPOSAL_STOPS.includes(String(authored.stop))) {
|
|
1333
|
-
// a refused rubric proposal: the person gets the reason in plain words (src/authorreadout.js, the one owner the
|
|
1334
|
-
// CLI prints too), and the full reds go into the drafting log on the failed step so the cause survives the session
|
|
1335
|
-
const cases = authored.judged?.signed?.cases ?? authored.judged?.proposal?.proposal?.cases ?? null;
|
|
1336
|
-
const reds = authored.reds ?? [];
|
|
1337
|
-
const runningNo = state.steps.findLastIndex((/** @type {any} */ x) => x.status === 'running');
|
|
1338
|
-
appendDraftLog(outDir, {
|
|
1339
|
-
kind: 'step-reds', no: runningNo === -1 ? state.steps.length - 1 : runningNo, stop: authored.stop,
|
|
1340
|
-
reds: redsRecord(reds, { cases }), at: new Date().toISOString(),
|
|
1341
|
-
});
|
|
1342
|
-
refuse(proposalStopText({
|
|
1343
|
-
stop: String(authored.stop), reds, cases,
|
|
1344
|
-
spend: { knownUsd: state.draftSpentUsd, spendComplete: state.draftSpendComplete },
|
|
1345
|
-
source: authored.judged?.source === 'signer' ? 'signer' : 'proposal',
|
|
1346
|
-
}));
|
|
1347
|
-
return;
|
|
1348
|
-
}
|
|
1349
1307
|
if (!authored.ok) {
|
|
1350
1308
|
// ITEM 6 (P7): every drafting stop says WHY in plain words (the reds travel into the drafting log beside it) — the bare
|
|
1351
1309
|
// "Stopped: provider-red" of live session smv2bzdqmp0f8 carried a code and no reason.
|
package/src/panel/importrun.js
CHANGED
package/src/panel/index.html
CHANGED
|
@@ -3024,7 +3024,6 @@
|
|
|
3024
3024
|
'<div class="summary-headline"><span class="dot ' + glyphClass(detail.glyph) + '"></span>' + (detail.status && detail.status.word ? '<b class="st-word" data-testid="summary-status">' + escapeXml(detail.status.word) + '</b> · ' : '') + '<b>' + escapeXml(detail.checkType) + '</b> · ' +
|
|
3025
3025
|
'<span class="num">' + spendText + '</span> · <span class="num">' + wallText + '</span></div>' +
|
|
3026
3026
|
'<div class="summary-row" data-testid="summary-model"><span class="sum-label">model:</span><span class="sum-val">' + escapeXml(modelLine(detail)) + '</span></div>' +
|
|
3027
|
-
(detail.judgeModel ? '<div class="summary-row" data-testid="summary-judge"><span class="sum-label">judge:</span><span class="sum-val">' + escapeXml(detail.judgeModel) + '</span></div>' : '') +
|
|
3028
3027
|
'<div class="summary-row"><span class="sum-label">steps:</span><span class="sum-val">' + stepsText +
|
|
3029
3028
|
(detail.replans ? ' · ' + detail.replans + ' replan' + (detail.replans === 1 ? '' : 's') : '') + '</span></div>' +
|
|
3030
3029
|
'<div class="summary-row"><span class="sum-label">why:</span><span class="sum-val">' + escapeXml(detail.stopReason || (detail.glyph === "✓" ? "run ended clean" : "not recorded")) + '</span></div>' +
|
|
@@ -3845,7 +3844,7 @@
|
|
|
3845
3844
|
}
|
|
3846
3845
|
// one row of the Audit's check list: its words, its tag, its result in the one state sign+word markup (a row with no recorded verdict says so, never "passed")
|
|
3847
3846
|
function auditCheckRowHtml(r){
|
|
3848
|
-
var res = r.result === "held" ? ["green", r.word || "held"] : r.result === "record-missing" ? ["grey", r.word || "the gate's record for this run is missing"] : r.result === "passed" ? ["green", "passed"] : r.result === "failed" ? ["red", "failed"] : r.result === "not-checked" ? ["grey", "not checked"] : ["grey", "no result recorded"];
|
|
3847
|
+
var res = r.result === "held" ? ["green", r.word || "held"] : r.result === "record-missing" ? ["grey", r.word || "the gate's record for this run is missing"] : r.result === "passed" ? ["green", "passed"] : r.result === "failed" ? ["red", "failed"] : r.result === "not-checked" ? ["grey", "not checked"] : r.result === "not-reached" ? ["grey", r.word || "not reached"] : ["grey", "no result recorded"];
|
|
3849
3848
|
return '<div class="audit-check-row" data-testid="audit-check-row" data-result="' + escapeXml(r.result) + '" style="overflow-wrap:anywhere">' + escapeXml(r.text) + byTagOf(r.by) + " " + stateDotHTML(res[0], res[1], "audit-check-state") + "</div>";
|
|
3850
3849
|
}
|
|
3851
3850
|
// the Checks fold's one state sign (code-owned, one place): any row failed = [✗]; else any row with no recorded result / no gate record = [·]; else [✓] ("held" is passed, "not checked" rows never move it)
|
|
@@ -3861,7 +3860,8 @@
|
|
|
3861
3860
|
var all = (ac.checks || []).concat(ac.always || []);
|
|
3862
3861
|
var nPass = all.filter(function(r){ return r.result === "passed" || r.result === "held"; }).length;
|
|
3863
3862
|
var nFail = all.filter(function(r){ return r.result === "failed"; }).length;
|
|
3864
|
-
var
|
|
3863
|
+
var nUnreached = all.filter(function(r){ return r.result === "not-reached"; }).length;
|
|
3864
|
+
var head = "checks · " + nPass + " passed" + (nFail ? " · " + nFail + " failed" : "") + (nUnreached ? " · " + nUnreached + " not reached" : "") + ((ac.notChecked || []).length ? " · " + ac.notChecked.length + " not checked" : "");
|
|
3865
3865
|
var btn = document.createElement("button");
|
|
3866
3866
|
btn.type = "button";
|
|
3867
3867
|
btn.className = "btn audit-part-toggle";
|
|
@@ -4413,7 +4413,7 @@
|
|
|
4413
4413
|
var rows = k.stages.map(function(s){
|
|
4414
4414
|
var num = stageNumberText(s);
|
|
4415
4415
|
return '<div class="rs-check" data-testid="result-check"><span class="rs-q">' + escapeXml(stageQuestionText(s)) + '</span><span class="rs-num hint" data-testid="result-check-num">' +
|
|
4416
|
-
(num ? escapeXml(num) : "") + escapeXml(stageTriedText(s)) + '</span><span class="rs-sign">' + stateDotHTML(s.passed ? "green" : "red", s.status.word, "result-check-state") + '</span></div>';
|
|
4416
|
+
(num ? escapeXml(num) : "") + escapeXml(stageTriedText(s)) + '</span><span class="rs-sign">' + stateDotHTML(s.passed ? "green" : s.notReached ? "grey" : "red", s.status.word, "result-check-state") + '</span></div>';
|
|
4417
4417
|
}).join("");
|
|
4418
4418
|
var notes = k.notes.length ? '<details data-testid="result-close-notes"><summary>the close\'s own notes</summary><div class="ro-value" style="white-space:pre-wrap">' +
|
|
4419
4419
|
k.notes.map(function(n){ return escapeXml(n.text); }).join("\n") + '</div></details>' : "";
|
|
@@ -4498,7 +4498,7 @@
|
|
|
4498
4498
|
if(!k) return "checks: the close did not run any check for this run";
|
|
4499
4499
|
var bits = k.stages.map(function(s){
|
|
4500
4500
|
var num = stageNumberText(s);
|
|
4501
|
-
return s.passed ? escapeXml(stageQuestionText(s)) : gridGlyph("✗") + " " + escapeXml(stageQuestionText(s)) + (num ? " — " + escapeXml(num) : "") + escapeXml(stageTriedText(s));
|
|
4501
|
+
return s.passed ? escapeXml(stageQuestionText(s)) : s.notReached ? gridGlyph("·") + " " + escapeXml(stageQuestionText(s)) + " — " + escapeXml(s.status.word) : gridGlyph("✗") + " " + escapeXml(stageQuestionText(s)) + (num ? " — " + escapeXml(num) : "") + escapeXml(stageTriedText(s));
|
|
4502
4502
|
});
|
|
4503
4503
|
return "checks: " + k.passed + " of " + k.total + " " + (k.allPassed ? gridGlyph("✓") : "") + (bits.length ? " · " : "") + bits.join(" · ");
|
|
4504
4504
|
}
|
|
@@ -6238,7 +6238,7 @@
|
|
|
6238
6238
|
// the empty-box examples (grey placeholders that vanish on typing) change with the Check type radio
|
|
6239
6239
|
var JOB_PLACEHOLDERS = {
|
|
6240
6240
|
deterministic: "Fix the failing date tests in src/date.js\n~ don't edit any test file\nMake npm test pass",
|
|
6241
|
-
rubric: "Write a one-page summary of docs/plan.md\n~
|
|
6241
|
+
rubric: "Write a one-page summary of docs/plan.md\n~ every number is quoted from the file\nKeep it under 300 words",
|
|
6242
6242
|
};
|
|
6243
6243
|
var INPUTS_PLACEHOLDER = "repo: /home/me/myrepo\nspec: docs/spec.md";
|
|
6244
6244
|
function setJobPlaceholders(v){
|