bareloop 0.55.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 +82 -0
- package/README.md +3 -3
- package/bareloop.context.md +69 -209
- package/package.json +2 -2
- package/src/authorflow.js +164 -340
- package/src/authoring.js +7 -127
- package/src/authorjob.js +139 -472
- package/src/authorreadout.js +24 -368
- package/src/authorrun.js +21 -215
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +798 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +39 -312
- package/src/checkwords.js +3 -1
- package/src/cli.js +3 -3
- package/src/declaredclose.js +38 -108
- package/src/destpoint.js +4 -2
- package/src/draftspend.js +46 -0
- package/src/facts.js +8 -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 +15 -3
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +24 -6
- package/src/panel/authorsession.js +222 -177
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +198 -26
- package/src/panel/jobplan.js +87 -33
- package/src/panel/server.js +74 -68
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +34 -55
- package/src/placerule.js +355 -0
- package/src/planrun.js +2 -48
- package/src/promptregisters.js +13 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +104 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +234 -127
- package/src/run.js +11 -16
- package/src/userrun.js +60 -112
- package/types/authorflow.d.ts +41 -197
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +35 -59
- package/types/authorreadout.d.ts +10 -88
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +36 -0
- package/types/checkblock.d.ts +376 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +8 -140
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +7 -33
- package/types/destpoint.d.ts +2 -0
- package/types/draftspend.d.ts +21 -0
- 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/pagemap.d.ts +4 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +47 -5
- package/types/panel/jobgrid.d.ts +8 -8
- package/types/panel/jobplan.d.ts +48 -10
- package/types/panel/server.d.ts +27 -18
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +20 -13
- package/types/placerule.d.ts +194 -0
- package/types/planrun.d.ts +1 -22
- package/types/providerrows.d.ts +0 -31
- package/types/providers.d.ts +3 -19
- package/types/questionbox.d.ts +87 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +100 -48
- package/types/run.d.ts +9 -19
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -166
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -113
package/src/declaredclose.js
CHANGED
|
@@ -68,14 +68,11 @@
|
|
|
68
68
|
// once instead of once-per-invocation, but `runPlan` has a dozen return paths and
|
|
69
69
|
// a leaked worktree outlives the process that made it.
|
|
70
70
|
|
|
71
|
-
import { runStage, makeSeedTrees, STOP_FAULTS, EXIT_RED
|
|
71
|
+
import { runStage, makeSeedTrees, STOP_FAULTS, EXIT_RED } from './kinds.js';
|
|
72
72
|
import {
|
|
73
73
|
validateDeclaration, classGuards, genreOwnedEnvNames, ungroundedGenreEnv, DECLARABLE_LANGUAGES, TYPES_GENRE, catalogueForLang, KIND_CATALOGUE, TEXT_GENRE, genreForLang,
|
|
74
74
|
VERDICT_CLASSES, LIVE_CLASSES, NEVER_OFFERED_KINDS,
|
|
75
75
|
} from './authoring.js';
|
|
76
|
-
// the calibration set's own gate lives beside the rulebook it is graded against
|
|
77
|
-
// (src/judged.js) — one opinion about what a judged floor's signed artifacts are
|
|
78
|
-
import { validateCalibrationSet } from './judged.js';
|
|
79
76
|
import { stageGap } from './ralph.js';
|
|
80
77
|
import { isObj, isNonEmptyString } from './validate.js';
|
|
81
78
|
|
|
@@ -102,14 +99,15 @@ export const DECLARED_GENRES = Object.freeze([TYPES_GENRE.name, TEXT_GENRE]);
|
|
|
102
99
|
* constrained to the names the genre OWNS, so it can never become an environment
|
|
103
100
|
* channel of its own.
|
|
104
101
|
*/
|
|
105
|
-
export const CLOSE_DECL_FIELDS = Object.freeze(['genre', 'lang', 'stages', 'notes', 'refused', 'guardLines', 'picks', '
|
|
102
|
+
export const CLOSE_DECL_FIELDS = Object.freeze(['genre', 'lang', 'stages', 'notes', 'refused', 'guardLines', 'picks', 'list', 'genreEnv']);
|
|
106
103
|
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
/** the fields of a row of the one check list that the signed close carries (`closeDecl.list`); the row's own words are never signed */
|
|
105
|
+
export const SIGNED_ROW_FIELDS = Object.freeze(['line', 'key', 'from', 'by', 'kind', 'state', 'rule', 'part', 'reason', 'facts']);
|
|
106
|
+
/** the states a signed row may end in */
|
|
107
|
+
export const SIGNED_STATES = Object.freeze(['built', 'not-checked', 'dropped']);
|
|
108
|
+
const SIGNED_FROM = Object.freeze(['rule', 'pick', 'look', 'agent', 'default']);
|
|
109
|
+
const SIGNED_BY = Object.freeze(['you', 'agent', 'default']);
|
|
110
|
+
const SIGNED_KINDS = Object.freeze(['rule', 'fact', 'cited', 'count', 'phrase', 'numbers', 'note', 'floor']);
|
|
113
111
|
|
|
114
112
|
/**
|
|
115
113
|
* The prefix M1 puts on EVERY gap line of a declared stage (its `ctx.gapKeep`).
|
|
@@ -176,8 +174,7 @@ export const HUMAN_CHECKPOINTS = Object.freeze([HITL_PAUSE]);
|
|
|
176
174
|
*
|
|
177
175
|
* `hard` is by CONSTRUCTION: every mechanical kind is a command whose measurement
|
|
178
176
|
* is the truth. `hitl` joined it at N4 slice 1, and `soft` at softgreen module 3
|
|
179
|
-
* — each only because its kind is genuinely LIVE (`human-confirms
|
|
180
|
-
* `judged-floor`): the widening and the kind go in one commit, or this table
|
|
177
|
+
* — each only because its kind is genuinely LIVE (`human-confirms`): the widening and the kind go in one commit, or this table
|
|
181
178
|
* admits a class the executor cannot render.
|
|
182
179
|
*
|
|
183
180
|
* `hitl` STAYS despite the class's retirement (PRD v1.71: the human stage moved
|
|
@@ -204,23 +201,11 @@ export function isDeclaredClose(job) {
|
|
|
204
201
|
* `offer` and `needs` pass through untouched when a declaration carries them
|
|
205
202
|
* (v1's schema does not let one), so `checkMenu`'s derivation is unchanged.
|
|
206
203
|
*
|
|
207
|
-
* THE JUDGE TIER RIDES ALONG, and it rides as a STAMP for the same reason `offer`
|
|
208
|
-
* does. The tier that graded this close's calibration set is a CLOSE-level fact
|
|
209
|
-
* (`calibration.judgeModel`), and the stage that would buy a judge call is a STAGE;
|
|
210
|
-
* `runStage` is handed stages and never the declaration they came out of. Rather than
|
|
211
|
-
* plumb a second close-level channel down through every executor seam, the one place
|
|
212
|
-
* that already turns a declaration into stages carries it across — and it carries it
|
|
213
|
-
* from the SIGNED bytes, so a stage can never name a tier the signature does not.
|
|
214
|
-
* `runJudgedFloor` refuses a mismatch; the absence of a stamp is the SPEC gate's
|
|
215
|
-
* business (`validateCloseDecl` reds a set with no model), never a runtime fall-back.
|
|
216
204
|
* @param {any} closeDecl
|
|
217
205
|
* @returns {any[]|null} null when this is not a declaration
|
|
218
206
|
*/
|
|
219
207
|
export function declaredStages(closeDecl) {
|
|
220
208
|
if (!isObj(closeDecl) || !Array.isArray(closeDecl.stages)) return null;
|
|
221
|
-
const calibrationJudgeModel = isObj(closeDecl.calibration) && isNonEmptyString(closeDecl.calibration.judgeModel)
|
|
222
|
-
? closeDecl.calibration.judgeModel
|
|
223
|
-
: null;
|
|
224
209
|
return closeDecl.stages.map((s) => (isObj(s)
|
|
225
210
|
// RULING 5, stamped by the ARBITER rather than trusted from the artefact:
|
|
226
211
|
// a judged or human stage is `offer: false` BY LAW, so `checkMenu` can never
|
|
@@ -232,7 +217,6 @@ export function declaredStages(closeDecl) {
|
|
|
232
217
|
...s,
|
|
233
218
|
gapKeep: DECLARED_GAP_KEEP,
|
|
234
219
|
...(NEVER_OFFERED_KINDS.includes(s.kind) ? { offer: false } : {}),
|
|
235
|
-
...(s.kind === JUDGED_FLOOR_KIND && calibrationJudgeModel !== null ? { calibrationJudgeModel } : {}),
|
|
236
220
|
}
|
|
237
221
|
: s));
|
|
238
222
|
}
|
|
@@ -272,14 +256,14 @@ export function declaredStages(closeDecl) {
|
|
|
272
256
|
*
|
|
273
257
|
* @param {any} closeDecl
|
|
274
258
|
* @param {{at?: string, listing?: string[]|null, deferListing?: boolean,
|
|
275
|
-
* catalogue?: Record<string, any>, verdictType?: string|null,
|
|
259
|
+
* catalogue?: Record<string, any>, verdictType?: string|null, jobLines?: {n: number}[]|null,
|
|
276
260
|
* inputLabels?: string[]|null}} [opts]
|
|
277
261
|
* @returns {{ok: boolean, reds: Red[], closeDecl: any, grounded: boolean,
|
|
278
262
|
* scoped: {scoped: boolean, via: string|null},
|
|
279
263
|
* ceiling: {class: string, kind: string, stage: string|null, locked: boolean}|null}}
|
|
280
264
|
*/
|
|
281
265
|
export function validateCloseDecl(closeDecl, opts = {}) {
|
|
282
|
-
const { at = 'closeDecl', listing = null, catalogue, verdictType = null,
|
|
266
|
+
const { at = 'closeDecl', listing = null, catalogue, verdictType = null, jobLines = null, inputLabels = null } = opts;
|
|
283
267
|
const deferListing = opts.deferListing === true;
|
|
284
268
|
/** @type {Red[]} */
|
|
285
269
|
const reds = [];
|
|
@@ -321,6 +305,27 @@ export function validateCloseDecl(closeDecl, opts = {}) {
|
|
|
321
305
|
+ `land here); fields: ${CLOSE_DECL_FIELDS.join(', ')}`);
|
|
322
306
|
}
|
|
323
307
|
}
|
|
308
|
+
// the signed copy of the one check list: an array of rows with exactly the signed fields (no words), each in its closed menu
|
|
309
|
+
if (closeDecl.list !== undefined) {
|
|
310
|
+
if (!Array.isArray(closeDecl.list)) red('invalid-value', `${at}.list`, 'the one check list as an array of rows: { line, key, from, by, kind, state, rule?, part?, reason? }');
|
|
311
|
+
else {
|
|
312
|
+
closeDecl.list.forEach((/** @type {any} */ row, /** @type {number} */ i) => {
|
|
313
|
+
const w = `${at}.list[${i}]`;
|
|
314
|
+
if (!isObj(row)) { red('invalid-value', w, 'a row: { line, key, from, by, kind, state, rule?, part?, reason? }'); return; }
|
|
315
|
+
for (const k of Object.keys(row)) if (!SIGNED_ROW_FIELDS.includes(k)) red('unknown-field', `${w}.${k}`, `not a signed row field (the row's own words are never signed); fields: ${SIGNED_ROW_FIELDS.join(', ')}`);
|
|
316
|
+
if (!Number.isInteger(row.line) || row.line < 1) red('invalid-value', `${w}.line`, 'the job line number');
|
|
317
|
+
if (!isNonEmptyString(row.key)) red('invalid-value', `${w}.key`, 'the row key, a non-empty string');
|
|
318
|
+
if (!SIGNED_FROM.includes(row.from)) red('invalid-value', `${w}.from`, `menu: ${SIGNED_FROM.join('|')}`);
|
|
319
|
+
if (!SIGNED_BY.includes(row.by)) red('invalid-value', `${w}.by`, `menu: ${SIGNED_BY.join('|')}`);
|
|
320
|
+
if (!SIGNED_KINDS.includes(row.kind)) red('invalid-value', `${w}.kind`, `menu: ${SIGNED_KINDS.join('|')}`);
|
|
321
|
+
if (!SIGNED_STATES.includes(row.state)) red('invalid-value', `${w}.state`, `menu: ${SIGNED_STATES.join('|')}`);
|
|
322
|
+
if (row.rule !== undefined && !Number.isInteger(row.rule)) red('invalid-value', `${w}.rule`, 'the ~ rule number');
|
|
323
|
+
if (row.part !== undefined && !(isObj(row.part) && Number.isInteger(row.part.line) && Number.isInteger(row.part.part))) red('invalid-value', `${w}.part`, '{ line, part }: the job line and the index of the part that carries the row');
|
|
324
|
+
if (row.reason !== undefined && typeof row.reason !== 'string') red('invalid-value', `${w}.reason`, 'plain words');
|
|
325
|
+
if (row.facts !== undefined && !(Array.isArray(row.facts) && row.facts.every((/** @type {unknown} */ x) => typeof x === 'string'))) red('invalid-value', `${w}.facts`, 'the names of the facts the row built, an array of strings');
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
324
329
|
// PART 1a: a genre is bound to its language — code languages are TYPES, the rubric-files language is TEXT, and neither may
|
|
325
330
|
// wear the other's label (`lang` is checked just below; an unknown lang reds there)
|
|
326
331
|
if (!DECLARED_GENRES.includes(closeDecl.genre) || closeDecl.genre !== genreForLang(closeDecl.lang)) {
|
|
@@ -406,7 +411,6 @@ export function validateCloseDecl(closeDecl, opts = {}) {
|
|
|
406
411
|
...(deferListing ? { deferListing: true } : {}),
|
|
407
412
|
guards: classGuards({ verdictType: picked, lang: closeDecl.lang }),
|
|
408
413
|
verdictType: picked,
|
|
409
|
-
writeScope,
|
|
410
414
|
jobLines,
|
|
411
415
|
inputLabels,
|
|
412
416
|
envOwned: owned,
|
|
@@ -417,55 +421,6 @@ export function validateCloseDecl(closeDecl, opts = {}) {
|
|
|
417
421
|
});
|
|
418
422
|
for (const r of v.reds) reds.push({ ...r, path: r.path ? `${at}.${r.path}` : at });
|
|
419
423
|
|
|
420
|
-
// ── THE FROZEN CALIBRATION SET (softgreen module 4, design §4.4). It rides
|
|
421
|
-
// the closeDecl rather than a stage's params because it calibrates the RULER,
|
|
422
|
-
// not one stage's parameters — and because it is read BEFORE any stage runs.
|
|
423
|
-
//
|
|
424
|
-
// WHAT IS CHECKED HERE is that a stored set is LEGAL: exactly the signed size,
|
|
425
|
-
// both polarities present, itemized reds naming lines THIS close's card
|
|
426
|
-
// actually carries. WHAT IS NOT is whether the pipe grades it correctly — that
|
|
427
|
-
// is module 5's gate, it costs paid calls, and a validator cannot buy them.
|
|
428
|
-
//
|
|
429
|
-
// A set with NO judged stage to calibrate is its own red: the card lives on
|
|
430
|
-
// the stage, so an orphan set is graded against nothing and would validate
|
|
431
|
-
// clean forever. The reverse (a judged stage with no set) is deliberately NOT
|
|
432
|
-
// redded here — making the set MANDATORY is the signing gate's call, and
|
|
433
|
-
// module 5 owns it.
|
|
434
|
-
if (closeDecl.calibration !== undefined) {
|
|
435
|
-
const judged = judgedStages(closeDecl);
|
|
436
|
-
if (!isObj(closeDecl.calibration)) {
|
|
437
|
-
red('invalid-value', `${at}.calibration`, 'the frozen calibration set, as an object carrying `cases`');
|
|
438
|
-
} else if (judged.length !== 1) {
|
|
439
|
-
red('calibration-orphan', `${at}.calibration`, `this close carries a calibration set and ${judged.length} `
|
|
440
|
-
+ 'judged-floor stage(s). The set calibrates ONE judged ruler against ONE card — with no judged stage it is '
|
|
441
|
-
+ 'graded against nothing and would read clean forever, and with two there is no one card it belongs to',
|
|
442
|
-
{ judgedStages: judged.length });
|
|
443
|
-
} else {
|
|
444
|
-
for (const key of Object.keys(closeDecl.calibration)) {
|
|
445
|
-
if (!CALIBRATION_FIELDS.includes(key)) red('invalid-value', `${at}.calibration.${key}`, `a calibration set carries ${CALIBRATION_FIELDS.map((f) => `\`${f}\``).join(' and ')} and nothing else`);
|
|
446
|
-
}
|
|
447
|
-
// WHICH TIER GRADED THIS SET, and it is REQUIRED rather than optional. A
|
|
448
|
-
// stored set is only worth the judge that graded it (§4.2's safety argument
|
|
449
|
-
// is BA-20's haiku-4.5 injection evidence and nothing else), so a set with
|
|
450
|
-
// no model beside it is a set nobody can attribute — and the `CALIBRATION_FIELDS`
|
|
451
|
-
// docstring's promise that a bump forces recalibration has nothing to fire
|
|
452
|
-
// on. Required HERE and not at the stage, for the same reason the SET's own
|
|
453
|
-
// presence is the signing gate's call and not this validator's: this gate
|
|
454
|
-
// reads a stored artifact and says whether it is legal. The RUNTIME half —
|
|
455
|
-
// refusing to grade when the stored tier is not the tier this run would buy
|
|
456
|
-
// — is the judged stage's (`runJudgedFloor`), reached through the stamp
|
|
457
|
-
// `declaredStages` puts on the stage.
|
|
458
|
-
if (closeDecl.calibration.judgeModel === undefined) {
|
|
459
|
-
red('missing-required', `${at}.calibration.judgeModel`, 'the judge tier this set was GRADED by — a calibration '
|
|
460
|
-
+ 'nobody can attribute to a model is a floor nobody can tell apart from a bumped one');
|
|
461
|
-
} else if (!isNonEmptyString(closeDecl.calibration.judgeModel)) {
|
|
462
|
-
red('invalid-value', `${at}.calibration.judgeModel`, 'the judge tier this set was graded by, as a non-empty string');
|
|
463
|
-
}
|
|
464
|
-
const cv = validateCalibrationSet(closeDecl.calibration.cases, { card: judged[0]?.params?.card ?? null });
|
|
465
|
-
for (const r of cv.reds) reds.push({ ...r, path: r.path ? `${at}.${r.path}` : `${at}.calibration` });
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
424
|
const ok = reds.length === 0;
|
|
470
425
|
return {
|
|
471
426
|
ok,
|
|
@@ -573,17 +528,13 @@ function translate(r, redact) {
|
|
|
573
528
|
* @param {{timeoutMs?: number, cwd?: string, seedRef?: string,
|
|
574
529
|
* seedTrees?: any, gapCap?: number, maxBuffer?: number, baselineMode?: 'auto'|'worktree',
|
|
575
530
|
* humanRuling?: {decision: string, text?: string|null}|null,
|
|
576
|
-
*
|
|
577
|
-
* judgeModel?: string|null,
|
|
578
|
-
* onJudgeCost?: ((c: any) => void)|null,
|
|
579
|
-
* onRubricEvidence?: ((e: any) => void)|null,
|
|
580
|
-
* callBounds?: (() => {timeoutMs?: number, deadlineMs?: number})|null}} [opts]
|
|
531
|
+
* onRubricEvidence?: ((e: any) => void)|null}} [opts]
|
|
581
532
|
* @returns {Promise<any>}
|
|
582
533
|
*/
|
|
583
534
|
export async function runDeclaredStages(stages, redact = (s) => s, opts = {}) {
|
|
584
535
|
const {
|
|
585
536
|
timeoutMs, cwd, seedRef, seedTrees: shared, gapCap, maxBuffer, baselineMode, humanRuling = null,
|
|
586
|
-
|
|
537
|
+
onRubricEvidence = null,
|
|
587
538
|
} = opts;
|
|
588
539
|
if (!isNonEmptyString(cwd) || !isNonEmptyString(seedRef)) {
|
|
589
540
|
// Refuse rather than guess. A declared close measures against a SEED; a
|
|
@@ -614,27 +565,6 @@ export async function runDeclaredStages(stages, redact = (s) => s, opts = {}) {
|
|
|
614
565
|
// human stage reads the absence as "nobody has answered yet", which is the
|
|
615
566
|
// whole of what a pause means.
|
|
616
567
|
humanRuling,
|
|
617
|
-
// THE PAID SEAM, THE IDENTITY and THE METER, all operator territory and all
|
|
618
|
-
// absent on every mechanical close. A judged stage with no seam STOPS as a
|
|
619
|
-
// wiring gap rather than falling back to some other model (M1 owns no
|
|
620
|
-
// provider), and `judgeModel` is the seam's OTHER half (PRD item 32.1) —
|
|
621
|
-
// WHICH model the seam drives, resolved by the caller (`resolveJudge`,
|
|
622
|
-
// src/judged.js) and passed through untouched here, exactly as `judgeLoop`
|
|
623
|
-
// is. `runStage` checks the identity before the seam, so a judged stage with
|
|
624
|
-
// neither wired reports the identity gap, and one with only the seam missing
|
|
625
|
-
// still names the judge it would have graded with. Every locate call the
|
|
626
|
-
// seam buys is reported OUT through the meter so the run's ONE ledger can
|
|
627
|
-
// see it — a close has cost $0 until this kind, and a budget must fund the
|
|
628
|
-
// attempt PLUS its close.
|
|
629
|
-
judgeLoop,
|
|
630
|
-
judgeModel,
|
|
631
|
-
onJudgeCost,
|
|
632
|
-
// F152/PRD 30.4 — the SAME per-call time bounds every worker round already
|
|
633
|
-
// carries (`callBounds()`, src/planrun.js:1518), so the judged stage's own
|
|
634
|
-
// locate call cannot hang the process on a live silent endpoint. `null` is
|
|
635
|
-
// the honest absence (an adopter/test that wires no clock through), never a
|
|
636
|
-
// defaulted number invented here.
|
|
637
|
-
callBounds,
|
|
638
568
|
// REPORT-ONLY seam: what a rubric-step stage's cited checks read (bareguard `full.evidence`); the runner records it, nothing here reads it
|
|
639
569
|
onRubricEvidence,
|
|
640
570
|
seedTrees,
|
|
@@ -694,7 +624,7 @@ export async function runDeclaredStages(stages, redact = (s) => s, opts = {}) {
|
|
|
694
624
|
* recommend a top-up on a dying run — the one direction trend.js names as
|
|
695
625
|
* dangerous. F6's answer applies: unknown, never a number that means the
|
|
696
626
|
* opposite of what it says.
|
|
697
|
-
* - a
|
|
627
|
+
* - a rubric-step (no measurement) donates its distinct red COUNT, always 'down';
|
|
698
628
|
* - any other stage with no measurement at all donates nothing, for the same reason.
|
|
699
629
|
* The stage POSITION still travels either way, so "the run got further than it
|
|
700
630
|
* ever had" is readable on every declared close.
|
|
@@ -703,8 +633,8 @@ export async function runDeclaredStages(stages, redact = (s) => s, opts = {}) {
|
|
|
703
633
|
*/
|
|
704
634
|
function trendValueOf(stage, r) {
|
|
705
635
|
if (typeof r?.value !== 'number' || !Number.isFinite(r.value)) {
|
|
706
|
-
// a
|
|
707
|
-
// (
|
|
636
|
+
// a rubric-step has no measurement: its number is how many DISTINCT reds it itemizes
|
|
637
|
+
// (src/rubricstep.js `detail.redCount`), lower-is-better, compared to its best-so-far like any deterministic count
|
|
708
638
|
return Number.isInteger(r?.detail?.redCount) ? r.detail.redCount : null;
|
|
709
639
|
}
|
|
710
640
|
return stage?.params?.direction === 'lower-is-better' ? r.value : null;
|
package/src/destpoint.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// names a file to change, the line, the file (copied from that line) and the folder that holds it. Plain code then checks every claim (the line is a job line, the path
|
|
3
3
|
// stands in that line's own words, the file is in the repo's committed tree, the folder is a real parent of it) and that the file lies OUTSIDE the Destination. Only then is
|
|
4
4
|
// there ONE question, worded by code, answered yes or no like the fit check's "go on". A made-up file, a path the line does not hold or a malformed reply is no question.
|
|
5
|
-
// Failure is OPEN (a wrong question is the costly mistake): a call that does not finish asks nothing and drafting goes on. The call/book/retry pattern is src/
|
|
5
|
+
// Failure is OPEN (a wrong question is the costly mistake): a call that does not finish asks nothing and drafting goes on. The call/book/retry pattern is src/pagemap.js's `runPageMap`.
|
|
6
6
|
|
|
7
7
|
import { createRequire } from 'node:module';
|
|
8
8
|
import { priceOf, scrubRaw, tallyCalls, capStop, callCasualty } from './text.js';
|
|
@@ -81,8 +81,10 @@ export function decideDestPoint(text, { jobLines, files, destination }) {
|
|
|
81
81
|
|
|
82
82
|
/** the one question, worded by code @param {DestPoint} p @param {string} destination @returns {string} */
|
|
83
83
|
export const destQuestionText = (p, destination) => redactSecrets(
|
|
84
|
-
`Line ${p.line} needs ${p.file} changed, but Destination is ${destination.trim().replace(/\s*\n\s*/g, ', ')}, so the job could not change it. Set Destination to ${p.folder}
|
|
84
|
+
`Line ${p.line} needs ${p.file} changed, but Destination is ${destination.trim().replace(/\s*\n\s*/g, ', ')}, so the job could not change it. Set Destination to ${p.folder}?${DEST_ANSWER}`,
|
|
85
85
|
);
|
|
86
|
+
/** the answer words the question ends with (said once, here; the panel's question box shows the question without them and has the buttons instead) */
|
|
87
|
+
export const DEST_ANSWER = ' Type yes to set it, or no to keep it as it is.';
|
|
86
88
|
/** the answers (any case, a closing full stop allowed) @param {unknown} text @returns {'yes'|'no'|null} */
|
|
87
89
|
export const yesNoOf = (text) => {
|
|
88
90
|
const t = String(text ?? '').trim().replace(/\.$/, '').toLowerCase();
|
package/src/draftspend.js
CHANGED
|
@@ -280,6 +280,51 @@ export function readDraftChecks(dir) {
|
|
|
280
280
|
return out;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
/**
|
|
284
|
+
* The suggested checks code could not build, one plain sentence each (the last `draft-notbuilt` line of the log): the Audit's draft lines. `[]` when there are none.
|
|
285
|
+
* @param {string} dir
|
|
286
|
+
* @returns {{line: number, text: string}[]}
|
|
287
|
+
*/
|
|
288
|
+
export function readDraftNotBuilt(dir) {
|
|
289
|
+
/** @type {string} */
|
|
290
|
+
let text;
|
|
291
|
+
try { text = readFileSync(join(dir, DRAFT_LOG_FILE), 'utf8'); } catch { return []; }
|
|
292
|
+
/** @type {{line: number, text: string}[]} */
|
|
293
|
+
let out = [];
|
|
294
|
+
for (const line of text.split('\n')) {
|
|
295
|
+
if (!line.includes('"draft-notbuilt"')) continue;
|
|
296
|
+
try {
|
|
297
|
+
const ev = JSON.parse(line);
|
|
298
|
+
if (ev?.kind === 'draft-notbuilt' && Array.isArray(ev.rows)) out = ev.rows.filter((/** @type {any} */ c) => c && Number.isInteger(c.line) && typeof c.text === 'string');
|
|
299
|
+
} catch { /* a torn line */ }
|
|
300
|
+
}
|
|
301
|
+
return out;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The check list's rows as the drafting ended (draft log `ledger` rows of phase `final`, the last one per key): each row's own words, so the Job tab can name a
|
|
306
|
+
* Not checked row in the person's words. `null` when the session has no readable log or no final row (a CLI run, an imported run, a deleted session). Never throws.
|
|
307
|
+
* @param {string} dir
|
|
308
|
+
* @returns {{key: string, rowKind: string, words: string[], state: string}[]|null}
|
|
309
|
+
*/
|
|
310
|
+
export function readDraftLedger(dir) {
|
|
311
|
+
/** @type {string} */
|
|
312
|
+
let text;
|
|
313
|
+
try { text = readFileSync(join(dir, DRAFT_LOG_FILE), 'utf8'); } catch { return null; }
|
|
314
|
+
/** @type {Map<string, {key: string, rowKind: string, words: string[], state: string}>} */
|
|
315
|
+
const byKey = new Map();
|
|
316
|
+
for (const line of text.split('\n')) {
|
|
317
|
+
if (!line.includes('"ledger"')) continue;
|
|
318
|
+
try {
|
|
319
|
+
const ev = JSON.parse(line);
|
|
320
|
+
if (ev?.kind === 'ledger' && ev.phase === 'final' && typeof ev.key === 'string') {
|
|
321
|
+
byKey.set(ev.key, { key: ev.key, rowKind: String(ev.rowKind), words: Array.isArray(ev.words) ? ev.words.filter((/** @type {any} */ w) => typeof w === 'string' && w) : [], state: String(ev.state) });
|
|
322
|
+
}
|
|
323
|
+
} catch { /* a torn line */ }
|
|
324
|
+
}
|
|
325
|
+
return byKey.size ? [...byKey.values()] : null;
|
|
326
|
+
}
|
|
327
|
+
|
|
283
328
|
/**
|
|
284
329
|
* The DRAFTING PART of a run (hamr 2026-10-06, option A): the first part of the run's views, built from the session's
|
|
285
330
|
* drafting log. `null` when the run did not come out of a panel session, or the log carries no metered call (a Reuse
|
|
@@ -307,5 +352,6 @@ export function draftingPartFor(row, spine, opts = {}) {
|
|
|
307
352
|
draftSteps: steps,
|
|
308
353
|
draftLabel: readDraftLabel(dir),
|
|
309
354
|
draftChecks: readDraftChecks(dir),
|
|
355
|
+
draftNotBuilt: readDraftNotBuilt(dir),
|
|
310
356
|
};
|
|
311
357
|
}
|
package/src/facts.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// the check. The claim TEXT that bareguard's number scan reads is written by code from the values, never by the worker.
|
|
11
11
|
|
|
12
12
|
import { rubricVocabulary } from 'bareguard';
|
|
13
|
+
import { placeRuleProblem } from './placerule.js';
|
|
13
14
|
|
|
14
15
|
/** the shapes a fact may have (bareguard's value kinds, plus `phrase` = a presence decide) */
|
|
15
16
|
export const FACT_SHAPES = Object.freeze(['money', 'number', 'date', 'time', 'phrase', 'text']);
|
|
@@ -18,7 +19,7 @@ export const FACT_OPS = Object.freeze(['lt', 'lte', 'gt', 'gte', 'between']);
|
|
|
18
19
|
/** bareguard signs at most this many decides on one `cited` check */
|
|
19
20
|
export const MAX_FACTS = 10;
|
|
20
21
|
/** every field a fact may carry */
|
|
21
|
-
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal', 'lang', 'decimal']);
|
|
22
|
+
const FACT_FIELDS = Object.freeze(['name', 'shape', 'unit', 'currency', 'phrase', 'anchor', 'until', 'rule', 'aiProposal', 'lang', 'decimal', 'place']);
|
|
22
23
|
/** the languages whose month names bareguard 0.27 reads on a `date` fact (its `lang`), each with the name a person reads; absent `lang` = ISO YYYY-MM-DD only */
|
|
23
24
|
export const FACT_LANGS = Object.freeze({ en: 'English', de: 'German', fr: 'French', es: 'Spanish', it: 'Italian', pt: 'Portuguese', nl: 'Dutch' });
|
|
24
25
|
/** the decimal marks a number or money fact may sign (bareguard 0.27 `decimal`); absent = "." */
|
|
@@ -124,6 +125,10 @@ export function factShapeReds(part, w, red) {
|
|
|
124
125
|
if (!nonEmpty(f.phrase)) red('invalid-value', `${fw}.phrase`, 'the fixed words the quote must contain, copied from the input');
|
|
125
126
|
for (const k of ['anchor', 'until', 'rule']) if (has(k)) red('invalid-value', `${fw}.${k}`, 'a phrase is fixed words the quote must contain; it has no anchor, until or rule');
|
|
126
127
|
} else if (has('phrase')) red('invalid-value', `${fw}.phrase`, 'only a phrase fact carries phrase');
|
|
128
|
+
if (has('place')) {
|
|
129
|
+
const bad = f.shape === 'phrase' ? placeRuleProblem(f.place) : 'only a phrase fact carries a place rule';
|
|
130
|
+
if (bad !== null) red('invalid-value', `${fw}.place`, bad);
|
|
131
|
+
}
|
|
127
132
|
if (has('anchor') && !nonEmpty(f.anchor)) red('invalid-value', `${fw}.anchor`, 'a label copied VERBATIM from the input');
|
|
128
133
|
if (has('until') && !nonEmpty(f.until)) red('invalid-value', `${fw}.until`, 'a label copied VERBATIM from the input');
|
|
129
134
|
if (has('until') && !has('anchor') && f.shape !== 'phrase') red('invalid-value', `${fw}.until`, 'until needs an anchor');
|
|
@@ -257,6 +262,8 @@ export function ruleWords(f) {
|
|
|
257
262
|
* @returns {string}
|
|
258
263
|
*/
|
|
259
264
|
export function factSentence(f, source) {
|
|
265
|
+
// PLACE RULES: a check that reads WHERE the newest value sits, not what it is; the phrase shown is the signed drafting example (the value a run read is in its Audit)
|
|
266
|
+
if (f.shape === 'phrase' && isRec(f.place)) return `${f.place.kind === 'headingDateAfter' ? 'date' : 'version'} in the newest "${f.place.prefix}" heading (last read ${f.phrase})`;
|
|
260
267
|
/** @type {string[]} */
|
|
261
268
|
const bits = [];
|
|
262
269
|
if (f.shape === 'phrase') bits.push('phrase', `must say "${f.phrase}"`);
|
package/src/index.js
CHANGED
|
@@ -129,10 +129,6 @@ export {
|
|
|
129
129
|
// gate that reads a signer's answer (and refuses an empty one), and the seed
|
|
130
130
|
// exemption ruling 8 states.
|
|
131
131
|
HUMAN_DECISIONS, SEED_EXEMPT_KINDS, normalizeHumanRuling, resolveHumanRuling,
|
|
132
|
-
// SOFTGREEN module 2 — the judged stage's own arbiter-owned bounds. An adopter
|
|
133
|
-
// wiring `judgeProvider` needs both numbers to reason about what a judged close
|
|
134
|
-
// can cost: one paid call per artifact, at most one retry each.
|
|
135
|
-
JUDGE_ATTEMPTS, MAX_JUDGED_PATHS,
|
|
136
132
|
// SOFTGREEN module 8 — the REVIEW DOOR's vocabulary: the record type a run
|
|
137
133
|
// writes when it ends at the door, which terminals open one, which classes open
|
|
138
134
|
// one unasked, and the mechanical-only rule an `accept` re-proves against.
|
|
@@ -145,45 +141,9 @@ export {
|
|
|
145
141
|
// module 6's registry half, and refuses an expired door under the same 60-day TTL a
|
|
146
142
|
// hitl checkpoint keeps. It never returns, writes or implies a verdict.
|
|
147
143
|
export { answerReviewDoor } from './reviewdoor.js';
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
// model, and no library fall-back; the old pinned-model constant is gone), the rulebook a card SELECTS from,
|
|
152
|
-
// the card gate, and the two halves themselves so a calibration harness can
|
|
153
|
-
// grade the whole pipe without running a close.
|
|
154
|
-
// `defaultJudgeLoop` (src/judged.js) is the one spelling of how this repo drives a
|
|
155
|
-
// judge; the runner reaches it through `runPlan`'s `judgeProvider`. It is internal:
|
|
156
|
-
// the package root does not export it.
|
|
157
|
-
export {
|
|
158
|
-
resolveJudge, JUDGE_RULES, JUDGE_RULE_IDS,
|
|
159
|
-
runLocate, decide,
|
|
160
|
-
// SOFTGREEN module 4 — what a legal SIGNED calibration set is. The SIZE is
|
|
161
|
-
// hamr's own ruling and a size change is a spec-level threshold change;
|
|
162
|
-
// `expectedOf` is the ONE reduction of a `decide()` result to the shape a case
|
|
163
|
-
// stores, so a calibration harness compares one shape rather than two.
|
|
164
|
-
CALIBRATION_SIZE, validateCalibrationSet, expectedOf,
|
|
165
|
-
} from './judged.js';
|
|
166
|
-
// SOFTGREEN module 4 — the COMPILE. Q6 becomes the rubric card and Q7 becomes the
|
|
167
|
-
// frozen calibration set, both on the D5 shown-and-fixed path: the LLM proposes
|
|
168
|
-
// through `proposeJudgedArtifacts`, an integrating UI shows the proposal, the
|
|
169
|
-
// SIGNER's fix goes through `signJudgedArtifacts`, and `foldJudgedArtifacts`
|
|
170
|
-
// enumerates both into the closeDecl — where the spec hash covers them, so a card
|
|
171
|
-
// line or a case is a re-sign like every other spec edit.
|
|
172
|
-
export {
|
|
173
|
-
proposeJudgedArtifacts, signJudgedArtifacts, foldJudgedArtifacts,
|
|
174
|
-
} from './cardauthor.js';
|
|
175
|
-
// SOFTGREEN module 5 — THE CALIBRATION GATE. `runCalibration` grades the whole
|
|
176
|
-
// pipe (locate + decide) over the signed ten and the five arbiter-owned injection
|
|
177
|
-
// artifacts; `prepareSigning` runs it and refuses on anything short of all of
|
|
178
|
-
// them. Exported because an integrating UI has to be able to RUN and RENDER the
|
|
179
|
-
// gate — the graded rows are what a signer reads before giving a signature — and
|
|
180
|
-
// because the battery is evidence a reader may want to inspect rather than take
|
|
181
|
-
// on trust. `INJECTION_LOCATE_BATTERY` and `INJECTION_CARD` are ARBITER-OWNED
|
|
182
|
-
// constants: no signer authors them and nothing stores them in a spec.
|
|
183
|
-
export {
|
|
184
|
-
runCalibration,
|
|
185
|
-
INJECTION_LOCATE_BATTERY, CASUALTY_AXES,
|
|
186
|
-
} from './calibrate.js';
|
|
144
|
+
// WHICH model a job's judge names (PRD item 32.1: the spec's signed `judge` override, else the job's own worker model; no library fall-back). The old
|
|
145
|
+
// judge's engine (the locate call, the rulebook, `decide`, the calibration shape) is gone (hamr 2026-11-14).
|
|
146
|
+
export { resolveJudge } from './judged.js';
|
|
187
147
|
// M2 — what a declaration may SAY, and whether one said it legally. The
|
|
188
148
|
// catalogue and the genre are DATA an integrating UI renders (the kind menu, the
|
|
189
149
|
// guard batteries it must show the user under D5 and cannot let them remove).
|
package/src/interviewrun.js
CHANGED
|
@@ -101,10 +101,10 @@ import {
|
|
|
101
101
|
PLAIN_FOLDER_DEFERRED_FIELDS,
|
|
102
102
|
} from './authorjob.js';
|
|
103
103
|
import {
|
|
104
|
-
INPUTS_FIELD, JOB_BLOCK_HELP, destinationFieldFor, labelsFor,
|
|
104
|
+
INPUTS_FIELD, JOB_BLOCK_HELP, destinationFieldFor, labelsFor,
|
|
105
105
|
} from './authorflow.js';
|
|
106
106
|
import {
|
|
107
|
-
parseJobBlock, parseInputs, renderJobLines,
|
|
107
|
+
parseJobBlock, parseInputs, renderJobLines, signedJobLines, REPO_RUBRIC_WORDS,
|
|
108
108
|
} from './jobblock.js';
|
|
109
109
|
import { validateJob, validateBaseUrl, PROVIDERS } from './job.js';
|
|
110
110
|
import { resolveProvider, probeWarningLines, apiKeyProblem } from './providers.js';
|
|
@@ -391,6 +391,14 @@ export async function main(argv, deps = {}) {
|
|
|
391
391
|
// 'repo'), the same authoritative outcome `prepareSource`'s own walk
|
|
392
392
|
// produces for it — reported, never fought, below.
|
|
393
393
|
const IS_REPO = looksLikeRepoSource(SOURCE);
|
|
394
|
+
// hamr 2026-11-14: this door always takes a repo on line 1, and a repo job is Deterministic (a rubric on a repo is for a Tickets job, a panel flow).
|
|
395
|
+
// Refused before a single class question is asked.
|
|
396
|
+
if (VERDICT === 'soft-green' && IS_REPO) {
|
|
397
|
+
say('');
|
|
398
|
+
say(REPO_RUBRIC_WORDS);
|
|
399
|
+
say('Nothing was asked and nothing was written.');
|
|
400
|
+
throw new ExitSignal(1);
|
|
401
|
+
}
|
|
394
402
|
|
|
395
403
|
// ── LANGUAGE, DETECTED — never asked (PRD item 33 M3, ruling 3) ──────────────
|
|
396
404
|
// $0, no provider: reads the repo's own manifest, nearest wins, walking up to
|
|
@@ -577,13 +585,13 @@ export async function main(argv, deps = {}) {
|
|
|
577
585
|
|
|
578
586
|
// ── 3. the class's own frozen questions, one at a time ───────────────────────
|
|
579
587
|
// P7: "The job" is ONE multi-line answer — numbered lines with their `~` rules, parsed by `parseJobBlock` (the same
|
|
580
|
-
// parser the panel uses) and filed under key 1 as the numbered text the drafter reads. A
|
|
581
|
-
//
|
|
588
|
+
// parser the panel uses) and filed under key 1 as the numbered text the drafter reads. A `~ PASS:`/`~ FAIL:` line
|
|
589
|
+
// is refused by that parser (2026-11-14); the judge examples are gone.
|
|
582
590
|
/** @type {Record<string, string>} */
|
|
583
591
|
const answers = {};
|
|
584
592
|
/** @type {import('./jobblock.js').JobLine[]} */
|
|
585
593
|
let JOB_LINES = [];
|
|
586
|
-
const ASKED = REQUIRED
|
|
594
|
+
const ASKED = REQUIRED;
|
|
587
595
|
let asked = 0;
|
|
588
596
|
for (const n of ASKED) {
|
|
589
597
|
asked += 1;
|
|
@@ -600,14 +608,11 @@ export async function main(argv, deps = {}) {
|
|
|
600
608
|
'that one is required — every question in this class\'s set has to be answered before a close can be authored from it. Again:');
|
|
601
609
|
const parsed = parseJobBlock(raw);
|
|
602
610
|
if (!parsed.ok) { say(` ${parsed.error}`); continue; }
|
|
603
|
-
const misfit = jobBlockFitsCheck(parsed.lines, VERDICT === 'soft-green');
|
|
604
|
-
if (misfit) { say(` ${misfit}`); continue; }
|
|
605
611
|
JOB_LINES = parsed.lines;
|
|
606
612
|
answers[n] = renderJobLines(parsed.lines);
|
|
607
613
|
break;
|
|
608
614
|
}
|
|
609
615
|
}
|
|
610
|
-
if (VERDICT === 'soft-green') answers[SOFTGREEN_JUDGE_EXAMPLES_KEY] = renderExamples(JOB_LINES);
|
|
611
616
|
|
|
612
617
|
// ── 4. the OPERATOR's half of the spec — the part nothing authors for you ────
|
|
613
618
|
say('');
|
package/src/job.js
CHANGED
|
@@ -248,6 +248,25 @@ export function flowTypeOf(spec) {
|
|
|
248
248
|
return spec?.mcp ? 'tickets' : 'plain';
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/** hamr 2026-11-14 (rubric vs deterministic split, piece 6): the words for a job made with PASS/FAIL examples or the old judge, which are gone. Old runs are not repaired. */
|
|
252
|
+
export const OLD_JOB_WORDS = 'This job was made with PASS/FAIL examples or the old judge, which are gone. Draft it fresh.';
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Is this signed spec an OLD job: one that carries a `judged-floor` stage (the old judge) or a job line with a `PASS:` / `FAIL:` rule (the old examples)?
|
|
256
|
+
* ONE reader for every door that takes a signed spec back in (Reuse, a scheduled fire, an exported bundle).
|
|
257
|
+
* @param {Record<string, any>} spec @returns {string|null} the plain refusal, or null when the spec is not an old job
|
|
258
|
+
*/
|
|
259
|
+
export function oldJobWords(spec) {
|
|
260
|
+
/** @type {any[]} */
|
|
261
|
+
const stages = Array.isArray(spec?.closeDecl?.stages) ? spec.closeDecl.stages : [];
|
|
262
|
+
if (stages.some((st) => st && st.kind === 'judged-floor')) return OLD_JOB_WORDS;
|
|
263
|
+
/** @type {any[]} */
|
|
264
|
+
const lines = Array.isArray(spec?.jobLines) ? spec.jobLines : [];
|
|
265
|
+
const isExample = (/** @type {unknown} */ r) => typeof r === 'string' && /^(PASS|FAIL):/i.test(r.trim());
|
|
266
|
+
if (lines.some((l) => l && ((Array.isArray(l.rules) && l.rules.some(isExample)) || isExample(l.rule)))) return OLD_JOB_WORDS;
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
|
|
251
270
|
/** the shape of an MCP server or tool name in a job (the bridge names a tool `<server>_<tool>`) */
|
|
252
271
|
const MCP_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
253
272
|
|
|
@@ -905,7 +924,7 @@ function validatePlanShape(spec, red, reds) {
|
|
|
905
924
|
// class the user picked (PRD v1.57 §2), so the gate cannot check D5 without
|
|
906
925
|
// it. An unknown or locked class is refused there, on its own axis, beside
|
|
907
926
|
// the counted `request-red` above.
|
|
908
|
-
const cd = validateCloseDecl(spec.closeDecl, { at: 'closeDecl', deferListing: true, verdictType: spec.verdictType,
|
|
927
|
+
const cd = validateCloseDecl(spec.closeDecl, { at: 'closeDecl', deferListing: true, verdictType: spec.verdictType, jobLines: Array.isArray(spec.jobLines) ? spec.jobLines : null, inputLabels: inputLabelsOf(spec.inputs) });
|
|
909
928
|
for (const r of cd.reds) reds.push(r);
|
|
910
929
|
if (demanded !== undefined && !CLASS_BY_CLOSE.declared.includes(demanded)) {
|
|
911
930
|
// the same laundering guard as the close-type hierarchy, one level up: a
|
package/src/jobblock.js
CHANGED
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Both are pure and $0: a malformed block is a named red `{ok: false, error}`, never a throw and never a guess.
|
|
6
6
|
|
|
7
|
-
/** @typedef {{
|
|
8
|
-
/** @typedef {{n: number, text: string, rule: string, rules: string[], examples: JobExample[]}} JobLine one numbered job line; `rule` = its `~` lines joined with '; ' ('' when none), `rules` = those same `~` lines one by one (so an example's own '; ' survives) */
|
|
7
|
+
/** @typedef {{n: number, text: string, rule: string, rules: string[]}} JobLine one numbered job line; `rule` = its `~` lines joined with '; ' ('' when none), `rules` = those same `~` lines one by one */
|
|
9
8
|
/** @typedef {{n: number, label: string, value: string}} JobInput one numbered `label: value` input line */
|
|
10
9
|
|
|
10
|
+
/** hamr 2026-11-14: Rubric on a repo is allowed ONLY for a Tickets job; any other repo + rubric start is refused at $0 in these words */
|
|
11
|
+
export const REPO_RUBRIC_WORDS = 'A repo job uses a Deterministic check.';
|
|
12
|
+
|
|
11
13
|
/** the joiner for consecutive `~` lines (fwd's joinGuardrails) */
|
|
12
14
|
export const RULE_JOINER = '; ';
|
|
13
15
|
|
|
16
|
+
/** hamr 2026-11-14: a `~ PASS:` / `~ FAIL:` line is refused at $0; the check list (`~` rules, Drop and Add) covers what the examples did */
|
|
17
|
+
export const PASS_FAIL_GONE_WORDS = 'PASS/FAIL examples are gone \u2014 write what you want as a ~ rule.';
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Parse "The job" box. A plain line is a numbered job line (1, 2, 3...). A line starting `~` has no number and belongs
|
|
16
21
|
* to the numbered line above; consecutive `~` lines become ONE rule joined with `'; '`. A `~` line starting `PASS:` or
|
|
17
|
-
* `FAIL:` is
|
|
18
|
-
* ignored. A `~` before line 1 is a red.
|
|
22
|
+
* `FAIL:` is a red ({@link PASS_FAIL_GONE_WORDS}). Empty lines are ignored. A `~` before line 1 is a red.
|
|
19
23
|
* @param {unknown} text the box's raw text
|
|
20
24
|
* @returns {{ok: true, lines: JobLine[]}|{ok: false, error: string}}
|
|
21
25
|
*/
|
|
@@ -35,16 +39,12 @@ export function parseJobBlock(text) {
|
|
|
35
39
|
if (lines.length === 0) return { ok: false, error: `The job, line ${row}: a "~" line belongs to the numbered line above it, and there is none yet` };
|
|
36
40
|
const body = t.slice(1).trim();
|
|
37
41
|
if (body === '') continue;
|
|
42
|
+
if (/^(PASS|FAIL):/i.test(body)) return { ok: false, error: PASS_FAIL_GONE_WORDS };
|
|
38
43
|
rule.push(body);
|
|
39
|
-
const m = /^(PASS|FAIL):\s*(.*)$/i.exec(body);
|
|
40
|
-
if (m) {
|
|
41
|
-
if (m[2].trim() === '') return { ok: false, error: `The job, line ${row}: "${m[1].toUpperCase()}:" needs an example after it` };
|
|
42
|
-
lines[lines.length - 1].examples.push({ verdict: /** @type {'PASS'|'FAIL'} */ (m[1].toUpperCase()), text: m[2].trim() });
|
|
43
|
-
}
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
flush();
|
|
47
|
-
lines.push({ n: lines.length + 1, text: t, rule: '', rules: []
|
|
47
|
+
lines.push({ n: lines.length + 1, text: t, rule: '', rules: [] });
|
|
48
48
|
}
|
|
49
49
|
flush();
|
|
50
50
|
if (lines.length === 0) return { ok: false, error: 'The job is required' };
|
|
@@ -99,16 +99,6 @@ export function jobBoxText(lines) {
|
|
|
99
99
|
return lines.map((l) => [l.text, ...l.rules.map((r) => `~ ${r}`)].join('\n')).join('\n');
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* The PASS:/FAIL: examples the person wrote, each kept with its line number (answer 2 of a rubric interview — what the
|
|
104
|
-
* calibration compile reads). Empty string when there are none.
|
|
105
|
-
* @param {JobLine[]} lines
|
|
106
|
-
* @returns {string}
|
|
107
|
-
*/
|
|
108
|
-
export function renderExamples(lines) {
|
|
109
|
-
return lines.flatMap((l) => l.examples.map((e) => `line ${l.n} ${e.verdict}: ${e.text}`)).join('\n');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
102
|
/**
|
|
113
103
|
* The inputs as the drafter is told about them: "the person pointed at these inputs: N label path".
|
|
114
104
|
* @param {JobInput[]} inputs
|
|
@@ -119,32 +109,7 @@ export function renderInputs(inputs) {
|
|
|
119
109
|
}
|
|
120
110
|
|
|
121
111
|
/**
|
|
122
|
-
* The
|
|
123
|
-
* `FAIL:` example (the calibration compile reads them); a DETERMINISTIC job has no judge, so an example line would be
|
|
124
|
-
* silently dropped — a red instead.
|
|
125
|
-
* PART 1a (hamr's ruling P1=B, docs/product/ITEM33-BUILD.md "Addendum 2026-10-12"): the examples are required of a rubric
|
|
126
|
-
* job ONLY when it holds a judged part. A rubric job on the person's own local files holds none in this build (its
|
|
127
|
-
* parts are counted or checked against a quote), so the caller says `judged: false` and a block without examples fits.
|
|
128
|
-
* Examples written anyway are never a red there — they simply have no judge to read them yet.
|
|
129
|
-
* @param {JobLine[]} lines
|
|
130
|
-
* @param {boolean} rubric
|
|
131
|
-
* @param {{judged?: boolean}} [o] `judged` (default true): does this job hold a judged part, so that it needs examples?
|
|
132
|
-
* @returns {string|null} the plain red, or null when the block fits the Check type
|
|
133
|
-
*/
|
|
134
|
-
export function jobBlockFitsCheck(lines, rubric, { judged = true } = {}) {
|
|
135
|
-
const all = lines.flatMap((l) => l.examples.map((e) => ({ n: l.n, ...e })));
|
|
136
|
-
if (!rubric) {
|
|
137
|
-
return all.length ? `The job, line ${all[0].n}: PASS:/FAIL: examples are for a Rubric check — a Deterministic job has no judge to read them` : null;
|
|
138
|
-
}
|
|
139
|
-
if (judged && (!all.some((e) => e.verdict === 'PASS') || !all.some((e) => e.verdict === 'FAIL'))) {
|
|
140
|
-
return 'The job: a Rubric check needs at least one "~ PASS:" line and one "~ FAIL:" line under a job line';
|
|
141
|
-
}
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* The signed `jobLines` field from parsed lines: the person's own words, `{n, text, rule, rules}` (examples stay inside the
|
|
147
|
-
* rule text, where the person wrote them). `rules` is the same `~` lines as an array, BESIDE the joined `rule` (never
|
|
112
|
+
* The signed `jobLines` field from parsed lines: the person's own words, `{n, text, rule, rules}`. `rules` is the same `~` lines as an array, BESIDE the joined `rule` (never
|
|
148
113
|
* replacing it); it is omitted on a line with no `~` line, and an older spec lacks it entirely.
|
|
149
114
|
* @param {JobLine[]} lines
|
|
150
115
|
* @returns {{n: number, text: string, rule: string, rules?: string[]}[]}
|