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
package/src/authorjob.js
CHANGED
|
@@ -99,14 +99,11 @@
|
|
|
99
99
|
// in the stored declaration (forward-compat point 3), and the suite pins it.
|
|
100
100
|
|
|
101
101
|
import { jobSpecHash, validateJob } from './job.js';
|
|
102
|
-
import { seedAtHead, seedListing, seedRead as runSeedRead, makeSeedTrees
|
|
102
|
+
import { seedAtHead, seedListing, seedRead as runSeedRead, makeSeedTrees } from './kinds.js';
|
|
103
103
|
import { inputLabelsOf, readFrozenInputs, lineRules, cardOfClose } from './rubricstep.js';
|
|
104
104
|
import { proverOf } from './factwords.js';
|
|
105
105
|
// SOFTGREEN modules 4 and 5 — the compile the interview's Q6/Q7 answers land in,
|
|
106
106
|
// and the gate that decides whether the ruler they describe is a ruler.
|
|
107
|
-
import { proposeJudgedArtifacts, signJudgedArtifacts, foldJudgedArtifacts } from './cardauthor.js';
|
|
108
|
-
import { runCalibration } from './calibrate.js';
|
|
109
|
-
import { CALIBRATION_SIZE } from './judged.js';
|
|
110
107
|
import {
|
|
111
108
|
GENRE_LANGUAGES, RUBRIC_LANG, DECLARABLE_LANGUAGES, genreForLang, LOCKED_KINDS, TYPES_GENRE, VERDICT_CLASSES, LOCKED_CLASSES, LIVE_CLASSES,
|
|
112
109
|
UNLISTED_CLASSES, MENU_CLASSES,
|
|
@@ -116,13 +113,14 @@ import {
|
|
|
116
113
|
runConfirmTurn, LANGUAGE_PICK_FIELD, MAX_QUESTIONS,
|
|
117
114
|
} from './authorflow.js';
|
|
118
115
|
import { thinkingCallOptions, assertThinkingMode } from './thinking.js';
|
|
119
|
-
import { runFitCheck, fitQuestionText, notFoundList, isGoOn } from './fitcheck.js';
|
|
120
116
|
import { pageContentChars } from './pagefetch.js';
|
|
121
117
|
import { runAuthorScout, buildSeedListing, SCOUT_ATTEMPTS } from './authorscout.js';
|
|
122
118
|
import { runPageMap, tooManyAsksText } from './pagemap.js';
|
|
123
119
|
import { CheckBlock } from './checkblock.js';
|
|
124
120
|
import { questionsOfBlock, applyChoices } from './blockasks.js';
|
|
125
|
-
import {
|
|
121
|
+
import { askNotes } from './noteask.js';
|
|
122
|
+
import { renderJobLines } from './jobblock.js';
|
|
123
|
+
import { scopedRules, codeScope, plainWords, obviousCheck } from './checkpick.js';
|
|
126
124
|
import { matchRecord, entriesFromAnswers, KEPT_WORDS } from './pickrecord.js';
|
|
127
125
|
import { runCheckSuggest } from './checksuggest.js';
|
|
128
126
|
import { runLedgerSuggest, ledgerRecord } from './checklist.js';
|
|
@@ -429,25 +427,23 @@ function composerRefusal(reds) {
|
|
|
429
427
|
* one-genre-at-a-time law is untouched.
|
|
430
428
|
*
|
|
431
429
|
* @param {{answers: Record<string|number, any>, repoPath?: string|null, lang: string,
|
|
432
|
-
* jobLines?: {n: number, text: string}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
|
|
430
|
+
* jobLines?: {n: number, text: string, rule?: string, rules?: string[]}[]|null, inputs?: {n: number, label: string, value: string}[]|null,
|
|
433
431
|
* verdictType?: string|null,
|
|
434
432
|
* questions?: Record<string|number, string>|null, generate?: Function, provider?: any,
|
|
435
|
-
* seedRef?: string|null, scout?: any, listing?: any, ceilingUsd?: number|null,
|
|
433
|
+
* seedRef?: string|null, scout?: any, listing?: any, ceilingUsd?: number|null,
|
|
436
434
|
* rates?: {in: number, out: number}|null, draftThinking?: 'on'|'off',
|
|
437
435
|
* onPhase?: (phase: string, data?: any) => void,
|
|
438
436
|
* onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string}) => void,
|
|
439
|
-
* seedFn?: Function, scoutFn?: Function, listingFn?: Function, lookFn?: Function|null,
|
|
440
|
-
* fitAsk?: ((question: string) => Promise<string|null>)|null, onFit?: (fit: {state: string, asks: any[], notFound: any[]}) => void,
|
|
437
|
+
* seedFn?: Function, scoutFn?: Function, listingFn?: Function, lookFn?: Function|null,
|
|
441
438
|
* authorFn?: Function, authorOpts?: object, writeScope?: string[]|null,
|
|
442
|
-
* signerFix?: Function|any, proposeFn?: Function, compileOpts?: object,
|
|
443
439
|
* ask?: ((step: {kind: string, [k: string]: any}) => Promise<string|null>)|null,
|
|
444
440
|
* answerQuestions?: ((o: {questions: {line: number, question: string, rule?: number, source?: string, ask?: string, reading?: string, key?: string}[], dropped: {reason: string, raw: any}[], confirmed: any}) =>
|
|
445
441
|
* Promise<{jobLines: {n: number, text: string, rule?: string}[], answers: Record<string|number, any>, left?: {line: number, rule: number}[], picks?: any[], choices?: {key: string, choice: string, text?: string}[]}|null>)|null,
|
|
446
|
-
* pickGenerate?: Function|null, ledgerGenerate?: Function|null, editGenerate?: Function|null, carriedPicks?: any[]|null, carriedChoices?: any[]|null, onChoices?: (rec: any[]) => void, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
|
|
442
|
+
* pickGenerate?: Function|null, ledgerGenerate?: Function|null, noteFn?: Function|null, onJobLines?: ((jobLines: any[]) => void)|null, editGenerate?: Function|null, carriedPicks?: any[]|null, carriedChoices?: any[]|null, onChoices?: (rec: any[]) => void, onPicks?: (o: {entries: any[], kept: {line: number, rule: number, entry: any}[]}) => void,
|
|
447
443
|
* confirmGenerate?: Function|null, isRepo?: boolean,
|
|
448
444
|
* langResult?: {kind: string, candidates?: string[], [k: string]: any}|null}} o
|
|
449
445
|
* @returns {Promise<{ok: boolean, refusal: Refusal|null, verdictType: string|null,
|
|
450
|
-
* closeDecl: any, seedRef: string|null, authoring: any,
|
|
446
|
+
* closeDecl: any, seedRef: string|null, authoring: any, reds: Red[],
|
|
451
447
|
* stop: string|null, cost: any, interview: any, confirmed: any, picked?: {line: number, text: string}[], hasBuiltCheck?: boolean, notBuilt?: {line: number, text: string}[]}>}
|
|
452
448
|
*/
|
|
453
449
|
export async function authorCloseForJob({
|
|
@@ -466,11 +462,6 @@ export async function authorCloseForJob({
|
|
|
466
462
|
// `writeScope`, and this is what carries it into the composer prompt
|
|
467
463
|
// (`authorPrompt`'s `writeScopeBlock`) instead of letting it vanish.
|
|
468
464
|
writeScope = null,
|
|
469
|
-
// THE JUDGE IDENTITY (PRD item 32.1), required only on the path that actually
|
|
470
|
-
// composes a judged stage — the stored calibration set carries the judge that
|
|
471
|
-
// certified it, and there is no library pin to fall back to. Absent on a purely
|
|
472
|
-
// mechanical close is correct and costs nothing: that close never judges.
|
|
473
|
-
judgeModel = null,
|
|
474
465
|
// THE PROGRESS SEAMS. This composition is the pipeline's long silence — a real
|
|
475
466
|
// survey, a real declaration ladder, and a real toolchain per close stage — and
|
|
476
467
|
// it emitted nothing until it returned, so an operator watching a live run
|
|
@@ -482,9 +473,6 @@ export async function authorCloseForJob({
|
|
|
482
473
|
// PART 1c / IDEA A CORE - the look at a rubric job's inputs: the default is the page-word map (src/pagemap.js `runPageMap`, one paid AI
|
|
483
474
|
// call per page input, its words kept by code). `null` is an explicit "no look" (a test seam, like a caller-supplied `scout`).
|
|
484
475
|
lookFn = runPageMap,
|
|
485
|
-
// THE FIT CHECK (F243): one paid call BEFORE the look, rubric jobs only. It runs only when the caller supplies the answer seam `fitAsk` (the panel);
|
|
486
|
-
// `fitFn` null is an explicit "no check" (a test seam). With no `fitAsk` (the CLI door) it never runs.
|
|
487
|
-
fitFn = runFitCheck, fitAsk = null, onFit = () => {},
|
|
488
476
|
authorFn = authorClose, authorOpts = {},
|
|
489
477
|
// R10 (fwd am16): the model boundary of the check-suggestion call (a `makeLoopGenerate` bound to SUGGEST_SYSTEM). ABSENT = no pick path: nothing is suggested or asked and the
|
|
490
478
|
// drafted declaration is validated as it always was (a test seam, like `lookFn: null`).
|
|
@@ -492,17 +480,16 @@ export async function authorCloseForJob({
|
|
|
492
480
|
// the model boundary of the list call (a `makeLoopGenerate` bound to LEDGER_SYSTEM), rubric jobs only. ABSENT = the list is built from the look and the defaults with no suggestion call
|
|
493
481
|
// (a test seam, like `pickGenerate`); the CLI and the panel always bring it.
|
|
494
482
|
ledgerGenerate = null,
|
|
483
|
+
// 2026-11-14 (b): the note question (src/noteask.js), asked ONLY when a rubric line is facts-only; ABSENT = never asked (every older caller and test)
|
|
484
|
+
noteFn = null,
|
|
485
|
+
// one rule in, one rule out: called with the job lines rebuilt from the check list after an answer (the seam that shows the job text updates itself); ABSENT = nothing shows it
|
|
486
|
+
onJobLines = null,
|
|
495
487
|
// the row-edit turn's own model boundary (src/rowedit.js ROW_EDIT_SYSTEM); a test that replaces `generate` need not bring one
|
|
496
488
|
editGenerate = null,
|
|
497
489
|
// R10 (fwd am17/am18): the picks record of the draft this one follows (`readRecordFile`), and the seam that receives this draft's record + the picks it kept. ABSENT = every rule is asked.
|
|
498
490
|
carriedPicks = null, onPicks = () => {},
|
|
499
491
|
// hamr 2026-11-13 (N-2): the Drop/Add choices of the draft this one follows (the picks record file's `rowChoices`); a Revise keeps them, code still judges every one
|
|
500
492
|
carriedChoices = null, onChoices = () => {},
|
|
501
|
-
// SOFTGREEN modules 4+5. `signerFix` is the D5 seam: a function (or a value)
|
|
502
|
-
// carrying the SIGNER's corrected artifacts back. Absent means the proposal is
|
|
503
|
-
// signed as proposed, and `signJudgedArtifacts` records which of the two
|
|
504
|
-
// happened rather than leaving a reader to guess.
|
|
505
|
-
signerFix = null, proposeFn = proposeJudgedArtifacts, compileOpts = {},
|
|
506
493
|
// PRD item 33 M3 piece 4 — the confirm turn. ALL FOUR default to nothing so
|
|
507
494
|
// every existing caller runs byte-identical: `ask` absent means no confirm
|
|
508
495
|
// turn runs at all, exactly as before this piece existed.
|
|
@@ -532,7 +519,7 @@ export async function authorCloseForJob({
|
|
|
532
519
|
/** @type {any} */
|
|
533
520
|
const base = {
|
|
534
521
|
ok: false, refusal: null, verdictType: null, closeDecl: null, seedRef: null,
|
|
535
|
-
authoring: null,
|
|
522
|
+
authoring: null, reds: [], stop: null, cost: null, interview: null,
|
|
536
523
|
confirmed: null,
|
|
537
524
|
};
|
|
538
525
|
|
|
@@ -640,26 +627,6 @@ export async function authorCloseForJob({
|
|
|
640
627
|
// nothing to check a rule against. Plain words, before any model call.
|
|
641
628
|
survey = { state: 'ABSENT', reason: 'your input holds nothing to read (it is empty, or only the site\'s own header and menus) - nothing was asked and nothing was spent', cause: 'call-failed', budgetStop: null, calls: [], raws: [], facts: null };
|
|
642
629
|
} else if (frozen !== null && lookFn) {
|
|
643
|
-
if (fitAsk && fitFn) {
|
|
644
|
-
// F243: a page that does not show what the job asks for stops here, before the look spends. Failure is OPEN: an `absent` check
|
|
645
|
-
// (cut, unreadable twice, call failed, cap) asks nothing and drafting goes on; the answer is NOT a `~` rule and changes nothing in the job.
|
|
646
|
-
onPhase('fit-check', {});
|
|
647
|
-
const fitCallOptions = thinkingCallOptions(provider, draftThinking);
|
|
648
|
-
const fit = await fitFn({
|
|
649
|
-
jobLines, texts: frozen.texts, provider, ceilingUsd, onCall, ...(rates ? { rates } : {}),
|
|
650
|
-
...(Object.keys(fitCallOptions).length ? { callOptions: fitCallOptions } : {}),
|
|
651
|
-
});
|
|
652
|
-
onPhase('fit-check-done', { state: fit.state });
|
|
653
|
-
onFit({ state: fit.state, asks: fit.asks, notFound: fit.notFound });
|
|
654
|
-
if (fit.state === 'ask') {
|
|
655
|
-
const foundAsks = fit.asks.filter((/** @type {any} */ a) => !a.ignored && a.found).map((/** @type {any} */ a) => ({ line: a.line, ask: a.ask }));
|
|
656
|
-
const answer = await fitAsk(fitQuestionText({ found: foundAsks.length, foundAsks, total: fit.asks.filter((/** @type {any} */ a) => !a.ignored).length, notFound: fit.notFound }));
|
|
657
|
-
if (answer === null) return { ...base, interview, verdictType: picked, seedRef: seed, reds: [], stop: 'confirm-abandoned', cost: null };
|
|
658
|
-
if (!isGoOn(answer)) {
|
|
659
|
-
return { ...base, interview, verdictType: picked, seedRef: seed, reds: [{ code: 'fit-stopped', path: 'jobLines', detail: notFoundList(fit.notFound) }], stop: 'fit-stopped', cost: null };
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
630
|
onPhase('look', {});
|
|
664
631
|
const lookCallOptions = thinkingCallOptions(provider, draftThinking);
|
|
665
632
|
survey = await lookFn({
|
|
@@ -709,13 +676,10 @@ export async function authorCloseForJob({
|
|
|
709
676
|
/** the rules a count pick settles, as the record knows them (a scoped rule is a counting `~` rule code scopes in) */
|
|
710
677
|
const scoped = answerQuestions ? scopedRules(jobLines, { inputs, look }) : [];
|
|
711
678
|
const matched = matchRecord(Array.isArray(carriedPicks) ? carriedPicks : [], jobLines, scoped);
|
|
679
|
+
// a rule whose words already are its check is settled by the block as written (no ask, no suggestion call)
|
|
680
|
+
matched.askRules = matched.askRules.filter((r) => !obviousCheck(r.text));
|
|
712
681
|
carried = { kept: matched.kept };
|
|
713
|
-
block.carry({ picks: matched.picks, left: matched.left }
|
|
714
|
-
// a rule the record folded into another ask (a broken pair's partner) is neither asked nor given the old check: Not checked, in the pick path's own words
|
|
715
|
-
for (const r of scoped) {
|
|
716
|
-
const row = block.ruleRows(r.line).find((x) => x.rule === r.rule);
|
|
717
|
-
if (row && !matched.askRules.some((a) => a.line === r.line && a.rule === r.rule) && !row.pick && !row.cantAsked && !row.left && !row.parent) row.folded = true;
|
|
718
|
-
}
|
|
682
|
+
block.carry({ picks: matched.picks, left: matched.left });
|
|
719
683
|
block.reconcile();
|
|
720
684
|
// the pick call: one suggestion per counting rule the record did not keep; each kept suggestion is a `pick` edit
|
|
721
685
|
if (answerQuestions && pickGenerate && matched.askRules.length > 0) {
|
|
@@ -742,6 +706,8 @@ export async function authorCloseForJob({
|
|
|
742
706
|
block.applyDelta({ label: 'pre:ledger-suggest', pre: true, edits: adds });
|
|
743
707
|
block.reconcile();
|
|
744
708
|
}
|
|
709
|
+
// the note question: ONE call, only when a line is facts-only. The AI says yes/no per line; code decides (block.setNotes -> a `$` note row and a countable text part). A failed call leaves the line facts-only with a Not checked row.
|
|
710
|
+
survey.calls = [...(survey.calls ?? []), ...(await askNotes({ block, jobLines, noteFn, ceilingUsd, onCall, onPhase }))];
|
|
745
711
|
// a Revise keeps the last draft's Drop/Add choices (the suggestions exist now); code still judges every one when the list is reconciled
|
|
746
712
|
if (Array.isArray(carriedChoices)) { block.carryChoices(carriedChoices); onChoices(block.choicesRecord()); }
|
|
747
713
|
block.reconcile();
|
|
@@ -768,12 +734,19 @@ export async function authorCloseForJob({
|
|
|
768
734
|
answered.picks.push(...(Array.isArray(updated.picks) ? updated.picks : []));
|
|
769
735
|
answered.left.push(...(Array.isArray(updated.left) ? updated.left : []));
|
|
770
736
|
const refused = applyChoices(block, Array.isArray(updated.choices) ? updated.choices : []);
|
|
737
|
+
// one rule in, one rule out (hamr 2026-11-14): the list replaced each answered rule, so the job text is rebuilt FROM the list (its one owner) and handed back to the seam that shows it
|
|
738
|
+
const rebuilt = block.jobLinesView(jobLines);
|
|
739
|
+
jobLines = rebuilt;
|
|
740
|
+
interview.answers = { ...interview.answers, 1: renderJobLines(rebuilt) };
|
|
741
|
+
if (typeof onJobLines === 'function') onJobLines(rebuilt);
|
|
771
742
|
if (refused.length === 0) break;
|
|
772
743
|
}
|
|
773
744
|
// the record this draft hands on, written whether or not anything was asked (a draft that kept every pick still carries them forward): the picks it kept, as they were, and the picks just answered, keyed by words
|
|
774
745
|
if (scoped.length > 0) {
|
|
746
|
+
// the record keeps the FINAL words of each rule (an answer replaced the rule it was asked about), numbered on this card
|
|
747
|
+
const finalRules = jobLines.flatMap((l) => (l.rules ?? []).map((t, i) => ({ line: l.n, rule: i + 1, text: t })));
|
|
775
748
|
onPicks({
|
|
776
|
-
entries: [...carried.kept.map((k) => k.entry), ...entriesFromAnswers(jobLines,
|
|
749
|
+
entries: [...carried.kept.map((k) => k.entry), ...entriesFromAnswers(jobLines, finalRules, answered.picks, answered.left.filter((l) => scoped.some((r) => r.line === l.line && r.rule === l.rule)))],
|
|
777
750
|
kept: carried.kept.map((k) => ({ line: k.line, rule: k.rule, entry: k.entry })),
|
|
778
751
|
});
|
|
779
752
|
}
|
|
@@ -968,92 +941,6 @@ export async function authorCloseForJob({
|
|
|
968
941
|
: {}),
|
|
969
942
|
};
|
|
970
943
|
|
|
971
|
-
// ── THE TWO SIGNED ARTIFACTS (softgreen module 4, wired here by module 5) ──
|
|
972
|
-
//
|
|
973
|
-
// A close that judges needs a rubric card and a calibration set, and until now
|
|
974
|
-
// nothing in the pipeline called the compile — module 4 shipped the machinery
|
|
975
|
-
// and said so. This is the call: Q6 and Q7 go to the compiler VERBATIM, the
|
|
976
|
-
// proposal is SHOWN (`onPhase`, and the driver prints it), the SIGNER's fix is
|
|
977
|
-
// what is stored, and both land inside the spec where the hash covers them.
|
|
978
|
-
//
|
|
979
|
-
// KEYED OFF THE DECLARATION, never off the picked class: a soft-green close
|
|
980
|
-
// that composed no judged stage needs no card, and a judged stage is a judged
|
|
981
|
-
// stage whatever the radio said. One judged stage is the composition law
|
|
982
|
-
// (AT_MOST_ONCE_KINDS), so the fold's own throw is unreachable here — it stays
|
|
983
|
-
// as the caller-error guard it is.
|
|
984
|
-
/** @type {any} */
|
|
985
|
-
let judged = null;
|
|
986
|
-
if (closeJudges(closeDecl)) {
|
|
987
|
-
// ONE CEILING, ALL THREE PAID SEAMS. The declaration loop's own calls are
|
|
988
|
-
// ABSORBED before the compile is asked for, so the ceiling folds in prior
|
|
989
|
-
// spend and re-invoking a seam cannot silently widen it. `absorb` deliberately
|
|
990
|
-
// does not re-fire `onCall`, so nothing is reported twice.
|
|
991
|
-
const book = makeCostBook({ ceilingUsd, onCall });
|
|
992
|
-
book.absorb(authored.cost?.calls ?? []);
|
|
993
|
-
onPhase('rubric', { size: CALIBRATION_SIZE });
|
|
994
|
-
const proposed = await proposeFn({
|
|
995
|
-
answers: stageAnswers,
|
|
996
|
-
questions: questions ?? questionsFor(picked),
|
|
997
|
-
generate,
|
|
998
|
-
book,
|
|
999
|
-
...compileOpts,
|
|
1000
|
-
});
|
|
1001
|
-
onPhase('rubric-done', { ok: proposed.ok, stop: proposed.stop, attempts: proposed.attempts });
|
|
1002
|
-
if (!proposed.ok) {
|
|
1003
|
-
return {
|
|
1004
|
-
...base,
|
|
1005
|
-
verdictType: picked, seedRef: seed, authoring: authored, judged: { proposal: proposed, signed: null },
|
|
1006
|
-
reds: proposed.reds, stop: proposed.stop, cost: book.report(), interview,
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
// THE D5 MOMENT. `signerFix` is the seam a UI (or an operator's own editor)
|
|
1011
|
-
// hands the fixed artifacts back through; ABSENT is a legal answer and it is
|
|
1012
|
-
// recorded as one — `source: 'proposal'` says *nobody changed this*, which is
|
|
1013
|
-
// a different fact from *a person read it and changed nothing*.
|
|
1014
|
-
const fix = typeof signerFix === 'function' ? await signerFix(proposed.proposal) : signerFix;
|
|
1015
|
-
const signed = signJudgedArtifacts({ proposal: proposed.proposal, fix });
|
|
1016
|
-
judged = { proposal: proposed, signed, scrubbed: signed.scrubbed, source: signed.source };
|
|
1017
|
-
if (!signed.ok) {
|
|
1018
|
-
return {
|
|
1019
|
-
...base,
|
|
1020
|
-
verdictType: picked, seedRef: seed, authoring: authored, judged,
|
|
1021
|
-
reds: signed.reds, stop: 'rubric-invalid', cost: book.report(), interview,
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
// THE SCRUB, ANNOUNCED. A signer signs a hash over the STORED bytes, so bytes
|
|
1025
|
-
// the ONE inventory masked on the way in are said out loud rather than left
|
|
1026
|
-
// for them to notice — by PATH only, because echoing the matched string would
|
|
1027
|
-
// be the same leak one hop on.
|
|
1028
|
-
if (signed.scrubbed.length) onPhase('rubric-scrubbed', { paths: signed.scrubbed.map((s) => s.path) });
|
|
1029
|
-
// `cases` is an array on every ok path — `validateCalibrationSet` reds a
|
|
1030
|
-
// non-array before anything can be `ok` — and the narrowing is stated rather
|
|
1031
|
-
// than defaulted: `?? []` here would fold an EMPTY signed set into a close,
|
|
1032
|
-
// which is the one direction that must never be reachable.
|
|
1033
|
-
if (typeof judgeModel !== 'string' || judgeModel.trim() === '') {
|
|
1034
|
-
throw new Error('[authorjob] authorCloseForJob composed a JUDGED close and was given no judgeModel (PRD item '
|
|
1035
|
-
+ '32.1). The stored calibration set carries the judge that certified it, and a set stamped with a model '
|
|
1036
|
-
+ 'nobody named is exactly the unattributable floor that field exists to prevent.');
|
|
1037
|
-
}
|
|
1038
|
-
closeDecl = foldJudgedArtifacts(closeDecl, {
|
|
1039
|
-
card: signed.card, cases: /** @type {any[]} */ (signed.cases), judgeModel,
|
|
1040
|
-
});
|
|
1041
|
-
return {
|
|
1042
|
-
ok: true,
|
|
1043
|
-
refusal: null,
|
|
1044
|
-
verdictType: picked,
|
|
1045
|
-
closeDecl,
|
|
1046
|
-
seedRef: seed,
|
|
1047
|
-
authoring: authored,
|
|
1048
|
-
judged,
|
|
1049
|
-
reds: authored.reds,
|
|
1050
|
-
stop: authored.stop,
|
|
1051
|
-
cost: book.report(),
|
|
1052
|
-
interview,
|
|
1053
|
-
confirmed,
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
944
|
return {
|
|
1058
945
|
ok: true,
|
|
1059
946
|
refusal: null,
|
|
@@ -1061,7 +948,6 @@ export async function authorCloseForJob({
|
|
|
1061
948
|
closeDecl,
|
|
1062
949
|
seedRef: seed,
|
|
1063
950
|
authoring: authored,
|
|
1064
|
-
judged,
|
|
1065
951
|
// the checks the person picked, for the plan card's "You picked" rows (read from the block's rows)
|
|
1066
952
|
...(block ? { hasBuiltCheck: block.hasBuiltCheck() } : {}),
|
|
1067
953
|
// the suggestions code could not build, one plain sentence each: the Audit's draft lines, never the card (hamr 2026-11-13, F-b)
|
|
@@ -1211,184 +1097,6 @@ const scrubRed = (r) => /** @type {any} */ (Object.fromEntries(
|
|
|
1211
1097
|
Object.entries(r).map(([k, v]) => [k, typeof v === 'string' ? redactSecrets(v) : v]),
|
|
1212
1098
|
));
|
|
1213
1099
|
|
|
1214
|
-
/**
|
|
1215
|
-
* THE one spelling of "a passed calibration gate stands in for the seed red": the
|
|
1216
|
-
* close carries a judged stage AND the gate ran and passed. A failed or missing
|
|
1217
|
-
* calibration never satisfies it, and a close with no judged stage never reaches it.
|
|
1218
|
-
* @param {any[]} judged `judgedStages(closeDecl)` @param {any} calibration `gates.calibration`
|
|
1219
|
-
* @returns {boolean}
|
|
1220
|
-
*/
|
|
1221
|
-
export function seedProofIsCalibration(judged, calibration) {
|
|
1222
|
-
return judged.length > 0 && calibration?.ok === true;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
/**
|
|
1226
|
-
* GATE 4 — the calibration gate, and the only gate here that spends money.
|
|
1227
|
-
*
|
|
1228
|
-
* It answers ONE question: has this close's own ruler been shown to grade the
|
|
1229
|
-
* signer's own ten correctly, itemized, and to resist all five attack styles?
|
|
1230
|
-
* Anything else it learns — a missing set, an unwired judge, a dead call — is
|
|
1231
|
-
* reported under its own name and refuses, because every one of them leaves the
|
|
1232
|
-
* question unanswered and an unanswered calibration is not a passed one.
|
|
1233
|
-
*
|
|
1234
|
-
* THE CASUALTY SPLIT is the same one the judged stage runs (F45, contract (a)): a
|
|
1235
|
-
* provider failure, an unpriced call or an unparseable emission after the ladder
|
|
1236
|
-
* says NOTHING about the set. It refuses the signature — an ungraded ruler is
|
|
1237
|
-
* still ungraded — but it refuses under the TRANSPORT's name, so the operator is
|
|
1238
|
-
* sent to the socket or the meter and never to their own rubric.
|
|
1239
|
-
* AND IT MEETS THE ONE CEILING. This is the run's THIRD paid seam — the largest of
|
|
1240
|
-
* them, at up to `CALIBRATION_SIZE` locate calls plus a five-artifact battery, each
|
|
1241
|
-
* under its own retry ladder — and it used to run with no bound at all while the
|
|
1242
|
-
* scout and the declaration loop were both stopped by the operator's own number.
|
|
1243
|
-
* That is the advertised budget and the enforced budget being two different numbers.
|
|
1244
|
-
* The book is built HERE and PRIOR SPEND IS ABSORBED into it, so the ceiling folds in
|
|
1245
|
-
* what the earlier seams already spent and re-invoking a seam cannot silently widen
|
|
1246
|
-
* it; the gate reads it between calls and stops as a refusal that names money.
|
|
1247
|
-
* `judgeModel` is the RESOLVED judge identity (PRD item 32.1), required and with no
|
|
1248
|
-
* default: it is stamped onto the graded set and onto the calibration-missing record
|
|
1249
|
-
* alike, so both say which judge the close would have been certified by.
|
|
1250
|
-
* @param {{spec: any, judgedStages: any[], judgeLoop: Function|null, judgeModel: string,
|
|
1251
|
-
* onJudgeCost: ((c: any) => void)|null, calibrateFn: Function,
|
|
1252
|
-
* ceilingUsd: number|null, priorCalls: any[]}} o
|
|
1253
|
-
* @returns {Promise<{ok: boolean, record: any, reds: Red[], refusal: Refusal|null}>}
|
|
1254
|
-
*/
|
|
1255
|
-
async function calibrationGate({ spec, judgedStages, judgeLoop, judgeModel, onJudgeCost, calibrateFn, ceilingUsd, priorCalls }) {
|
|
1256
|
-
const cases = spec.closeDecl?.calibration?.cases ?? null;
|
|
1257
|
-
// ONE card, and it is the SIGNED one — the card the calibration is graded
|
|
1258
|
-
// against must be the card the close will RUN, or the gate certifies a ruler
|
|
1259
|
-
// nobody is going to use. `validateCloseDecl` has already refused a second
|
|
1260
|
-
// judged stage (AT_MOST_ONCE_KINDS), so there is exactly one here.
|
|
1261
|
-
const card = judgedStages[0]?.params?.card ?? null;
|
|
1262
|
-
|
|
1263
|
-
if (cases === null || cases === undefined) {
|
|
1264
|
-
const detail = `This close judges with a rubric card, and no calibration set is stored with it. The judged floor `
|
|
1265
|
-
+ `is only a floor once the whole pipe has graded ${CALIBRATION_SIZE} signed cases correctly — until then the `
|
|
1266
|
-
+ 'ruler is unmeasured, and an unmeasured ruler cannot be signed.';
|
|
1267
|
-
return {
|
|
1268
|
-
ok: false,
|
|
1269
|
-
record: { ok: false, stop: 'calibration-missing', judgeModel, required: CALIBRATION_SIZE },
|
|
1270
|
-
reds: [{ code: 'calibration-missing', path: 'closeDecl.calibration.cases', detail }],
|
|
1271
|
-
refusal: refuse({
|
|
1272
|
-
kind: 'decision-ready',
|
|
1273
|
-
verb: null,
|
|
1274
|
-
path: 'closeDecl.calibration',
|
|
1275
|
-
detail,
|
|
1276
|
-
options: [
|
|
1277
|
-
`author the calibration set from the interview's own Q7 answer (${CALIBRATION_SIZE} cases, mixed polarity) and re-sign`,
|
|
1278
|
-
'drop the judged stage and describe a job whose done is machine-checkable',
|
|
1279
|
-
'abandon the job',
|
|
1280
|
-
],
|
|
1281
|
-
}),
|
|
1282
|
-
};
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
// ONE CEILING, ALL THE PAID SEAMS (`authorCloseForJob` says the same words over
|
|
1286
|
-
// the compile). The book absorbs what the run has already spent, so what the gate
|
|
1287
|
-
// reads is the REMAINING balance and never a fresh allowance; `absorb` deliberately
|
|
1288
|
-
// does not re-fire a reporter, so nothing is counted twice downstream.
|
|
1289
|
-
const book = makeCostBook({ ceilingUsd });
|
|
1290
|
-
book.absorb(Array.isArray(priorCalls) ? priorCalls : []);
|
|
1291
|
-
const cal = await calibrateFn({
|
|
1292
|
-
cases,
|
|
1293
|
-
card,
|
|
1294
|
-
judgeLoop,
|
|
1295
|
-
judgeModel,
|
|
1296
|
-
// the gate's own calls join the same tally the ceiling is read against — a
|
|
1297
|
-
// ceiling that cannot see the spend it bounds is F45's blind detector in a
|
|
1298
|
-
// money coat. The caller's reporter fires with the call's whole record, after.
|
|
1299
|
-
onCost: (/** @type {any} */ c) => {
|
|
1300
|
-
book.absorb([{ label: c?.label ?? 'calibrate', costUsd: c?.costUsd ?? null, unpricedRounds: c?.unpricedRounds ?? 0 }]);
|
|
1301
|
-
if (typeof onJudgeCost === 'function') onJudgeCost(c);
|
|
1302
|
-
},
|
|
1303
|
-
capStop: () => book.capStop(),
|
|
1304
|
-
});
|
|
1305
|
-
|
|
1306
|
-
/** what the signing evidence KEEPS about this gate. The per-case artifacts are
|
|
1307
|
-
* deliberately not in it — they are already in the signed spec, and a second
|
|
1308
|
-
* copy in the evidence file is a second thing to keep in step. Each graded row's
|
|
1309
|
-
* `diag` (F192) keeps the judge's own facts and the decision's reds — scrubbed
|
|
1310
|
-
* and bounded quotes, never an artifact body — so a refusal reads from its own
|
|
1311
|
-
* record. What IS kept is
|
|
1312
|
-
* WHICH BYTES were certified (`cardHash`/`casesHash`/`setHash`) and BY WHICH
|
|
1313
|
-
* MODEL (`judgeModel`), which is what makes a judge-model bump detectable at
|
|
1314
|
-
* all. */
|
|
1315
|
-
const record = {
|
|
1316
|
-
ok: cal.ok,
|
|
1317
|
-
stop: cal.stop,
|
|
1318
|
-
judgeModel: cal.judgeModel,
|
|
1319
|
-
cardHash: cal.cardHash,
|
|
1320
|
-
casesHash: cal.casesHash,
|
|
1321
|
-
setHash: cal.setHash,
|
|
1322
|
-
graded: cal.graded,
|
|
1323
|
-
failures: cal.failures,
|
|
1324
|
-
injection: cal.injection,
|
|
1325
|
-
casualty: cal.casualty,
|
|
1326
|
-
costUsd: cal.costUsd,
|
|
1327
|
-
knownUsd: cal.knownUsd,
|
|
1328
|
-
spendComplete: cal.spendComplete,
|
|
1329
|
-
calls: cal.calls?.length ?? 0,
|
|
1330
|
-
};
|
|
1331
|
-
if (cal.ok) return { ok: true, record, reds: [], refusal: null };
|
|
1332
|
-
|
|
1333
|
-
const reds = cal.reds.map(scrubRed);
|
|
1334
|
-
const casualty = cal.casualty !== null && cal.casualty !== undefined;
|
|
1335
|
-
/** the OPERATOR's own governance stop, and it is neither a casualty nor a reading
|
|
1336
|
-
* of the close: the ceiling ran out mid-question, and what was graded before it
|
|
1337
|
-
* did says nothing either way about the rest of the set. */
|
|
1338
|
-
const budget = cal.stop === 'cap-halt' || cal.stop === 'pricing-red';
|
|
1339
|
-
const detail = budget
|
|
1340
|
-
? (cal.stop === 'cap-halt'
|
|
1341
|
-
? `The calibration gate ran out of CEILING before it could finish: ${cal.graded.length} of `
|
|
1342
|
-
+ `${Array.isArray(cases) ? cases.length : 0} case(s) were graded and the next call was never made. A `
|
|
1343
|
-
+ 'part-graded set is an ungraded ruler, so nothing is signable — and nothing here says the ruler is wrong.'
|
|
1344
|
-
: 'The calibration gate stopped on an UNPRICED call: with the run\'s total unknown the ceiling cannot be read '
|
|
1345
|
-
+ 'against it, and unpriced is never free (F6). Nothing here says anything about the set.')
|
|
1346
|
-
: casualty
|
|
1347
|
-
? `The calibration gate could not be RUN: the judge produced no usable facts for ${cal.casualty.kind} `
|
|
1348
|
-
+ `"${cal.casualty.at}" [${cal.casualty.axis}]. A broken judge is a casualty and never a verdict, so this says `
|
|
1349
|
-
+ 'nothing about the set — but an ungraded ruler is still an ungraded ruler, and it cannot be signed.'
|
|
1350
|
-
: cal.stop === 'no-judge'
|
|
1351
|
-
? `This close carries a judged stage and no judge seam was wired, so the ${CALIBRATION_SIZE}-case gate never ran. `
|
|
1352
|
-
+ 'An absent seam is a wiring gap, never a fall-back: a gate that grades nothing would certify every close.'
|
|
1353
|
-
: cal.stop === 'invalid-set'
|
|
1354
|
-
? 'The stored rubric card and calibration set do not compose into something gradeable, so the gate refused '
|
|
1355
|
-
+ 'before spending anything.'
|
|
1356
|
-
: `The whole pipe did not grade this close's own calibration set correctly: `
|
|
1357
|
-
+ `${cal.failures.length} of ${Array.isArray(cases) ? cases.length : 0} case(s) graded wrong`
|
|
1358
|
-
+ `${cal.injection.leaks.length ? ` and ${cal.injection.leaks.length} injection style(s) leaked` : ''}. `
|
|
1359
|
-
+ `The floor is ${CALIBRATION_SIZE}/${CALIBRATION_SIZE} with itemized reds and all styles resisting `
|
|
1360
|
-
+ '(hamr, 2026-08-18) — the fix for a miss is a new card line or a corrected case, and a re-sign.';
|
|
1361
|
-
|
|
1362
|
-
return {
|
|
1363
|
-
ok: false,
|
|
1364
|
-
record,
|
|
1365
|
-
reds,
|
|
1366
|
-
refusal: refuse({
|
|
1367
|
-
kind: 'decision-ready',
|
|
1368
|
-
verb: null,
|
|
1369
|
-
path: 'closeDecl.calibration',
|
|
1370
|
-
detail,
|
|
1371
|
-
options: budget
|
|
1372
|
-
? [
|
|
1373
|
-
'raise the authoring ceiling and re-run the gate — the $0 gates above are already passed',
|
|
1374
|
-
'run the gate unbounded (omit the ceiling) — that is a stated operator choice, never a default',
|
|
1375
|
-
'abandon the job',
|
|
1376
|
-
]
|
|
1377
|
-
: casualty || cal.stop === 'no-judge'
|
|
1378
|
-
? [
|
|
1379
|
-
'wire a judge provider pinned to the judged tier and re-run the gate',
|
|
1380
|
-
'wait out the provider and re-run — nothing about the close was judged here',
|
|
1381
|
-
'abandon the job',
|
|
1382
|
-
]
|
|
1383
|
-
: [
|
|
1384
|
-
'correct the card line or the case the pipe graded differently, and re-sign',
|
|
1385
|
-
'read the itemized rows above: a case the pipe reds for the WRONG reason is the card talking, not the judge',
|
|
1386
|
-
'abandon the job',
|
|
1387
|
-
],
|
|
1388
|
-
}),
|
|
1389
|
-
};
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
1100
|
/**
|
|
1393
1101
|
* D9, in code: *nothing JUDGES the close; three mechanical gates plus a
|
|
1394
1102
|
* signature.* No LLM validates another LLM's close, here or anywhere.
|
|
@@ -1402,23 +1110,7 @@ async function calibrationGate({ spec, judgedStages, judgeLoop, judgeModel, onJu
|
|
|
1402
1110
|
* A close with NO work stage red at seed has nothing to do and is refused
|
|
1403
1111
|
* decision-ready — gate-2 round 2's arm B died exactly there, on a mypy that
|
|
1404
1112
|
* scanned nothing and therefore read clean.
|
|
1405
|
-
*
|
|
1406
|
-
* `judged-floor` stage ONLY. The whole judged pipe runs over the signed ten
|
|
1407
|
-
* and the five arbiter-owned injection artifacts, and anything short of
|
|
1408
|
-
* 10/10 with itemized reds and 5/5 resisted is an unsignable close. It is
|
|
1409
|
-
* the ONE gate here that spends money, so it runs LAST — every free refusal
|
|
1410
|
-
* has already had its chance, and nobody pays to discover a broken
|
|
1411
|
-
* declaration.
|
|
1412
|
-
*
|
|
1413
|
-
* D9.3 AND THE JUDGED CLOSE (2026-08-18 second addendum, ruling 3; hamr: *"fix it now,
|
|
1414
|
-
* we are delivering softgreen, isn't that the whole point?"*; widened 2026-10-09 to mixed
|
|
1415
|
-
* closes, hamr: *"a rubric job should check if judge can judge (calibration) and judge
|
|
1416
|
-
* rules can apply properly to pass ... we can't close everything upfront"*). Gate 3
|
|
1417
|
-
* protects against a close that cannot fail. A judged stage SKIPS the seed read by ruling
|
|
1418
|
-
* 8, so it can never show red there. For ANY close carrying a judged stage (pure or
|
|
1419
|
-
* mixed with mechanical stages), a PASSED calibration gate plays the seed-red role
|
|
1420
|
-
* (`seedProofIsCalibration`). A close with NO judged stage is UNCHANGED: some work stage
|
|
1421
|
-
* must be red at the seed. A failed or missing calibration never satisfies it.
|
|
1113
|
+
* (There was a fourth, paid gate, the calibration gate of the old judge; it is gone with the old judge, 2026-11-14.)
|
|
1422
1114
|
*
|
|
1423
1115
|
* Gates 2 and 3 share ONE execution, and that is stated rather than hidden: at
|
|
1424
1116
|
* job creation the tree IS the seed, so "does every stage run against the real
|
|
@@ -1431,35 +1123,18 @@ async function calibrationGate({ spec, judgedStages, judgeLoop, judgeModel, onJu
|
|
|
1431
1123
|
* comes back is the resolved spec, its hash, and the evidence to sign against.
|
|
1432
1124
|
*
|
|
1433
1125
|
* @param {{spec: any, workdir: string, seedRef?: string|null, shellCapUsd?: number,
|
|
1434
|
-
* timeoutMs?: number, seedFn?: Function, listingFn?: Function, seedReadFn?: Function
|
|
1435
|
-
* judgeLoop?: Function|null, judgeModel?: string|null, onJudgeCost?: ((c: any) => void)|null,
|
|
1436
|
-
* calibrateFn?: Function, ceilingUsd?: number|null, priorCalls?: any[]}} o
|
|
1126
|
+
* timeoutMs?: number, seedFn?: Function, listingFn?: Function, seedReadFn?: Function}} o
|
|
1437
1127
|
* @returns {Promise<{ok: boolean, specHash: string|null, seedRef: string|null,
|
|
1438
1128
|
* gates: any, work: any[], guards: any[], stops: any[], reds: Red[], refusal: Refusal|null}>}
|
|
1439
1129
|
*/
|
|
1440
1130
|
export async function prepareSigning({
|
|
1441
1131
|
spec, workdir, seedRef = null, shellCapUsd, timeoutMs,
|
|
1442
1132
|
seedFn = seedAtHead, listingFn = seedListing, seedReadFn = runSeedRead,
|
|
1443
|
-
// THE PAID SEAM, and it is the operator's to wire — this module owns no
|
|
1444
|
-
// provider and picks none (the same contract `authorCloseForJob` keeps for the
|
|
1445
|
-
// drafting model). Absent is never a fall-back: a judged close whose gate could
|
|
1446
|
-
// not run is refused, not waved through. `judgeModel` is the seam's other half
|
|
1447
|
-
// (PRD item 32.1) — WHICH model that loop drives, resolved by the caller
|
|
1448
|
-
// (`resolveJudge`, src/judged.js). The two travel together: a gate that grades
|
|
1449
|
-
// without recording its judge certifies a floor nobody can attribute.
|
|
1450
|
-
judgeLoop = null, judgeModel = null, onJudgeCost = null, calibrateFn = runCalibration,
|
|
1451
|
-
// THE OPERATOR'S CEILING, and the spend it has already met. `null`/absent is
|
|
1452
|
-
// UNBOUNDED and is a stated choice, never a default invented here (the same
|
|
1453
|
-
// contract `authorCloseForJob` keeps). `priorCalls` is what the earlier paid
|
|
1454
|
-
// seams of this run already cost — a `makeCostBook().report().calls` list — and
|
|
1455
|
-
// it is ABSORBED so the gate reads the remaining balance rather than opening a
|
|
1456
|
-
// fresh allowance under the same number.
|
|
1457
|
-
ceilingUsd = null, priorCalls = [],
|
|
1458
1133
|
}) {
|
|
1459
1134
|
/** @type {any} */
|
|
1460
1135
|
const base = {
|
|
1461
1136
|
ok: false, specHash: null, seedRef: null, work: [], guards: [], stops: [], reds: [], refusal: null,
|
|
1462
|
-
gates: { declaration: null, precheck: null, seedVerdict: null
|
|
1137
|
+
gates: { declaration: null, precheck: null, seedVerdict: null },
|
|
1463
1138
|
};
|
|
1464
1139
|
|
|
1465
1140
|
// ── gate 1a: the spec itself. A declared close that is not on a plan-shape
|
|
@@ -1514,7 +1189,7 @@ export async function prepareSigning({
|
|
|
1514
1189
|
}
|
|
1515
1190
|
// the class rides from the SPEC (PRD v1.57 §2) — gate 1a already refused a spec
|
|
1516
1191
|
// whose class is unknown or locked, so this is the class D5's battery hangs off
|
|
1517
|
-
const dv = validateCloseDecl(spec.closeDecl, { at: 'closeDecl', listing: listed.files, verdictType: spec.verdictType,
|
|
1192
|
+
const dv = validateCloseDecl(spec.closeDecl, { at: 'closeDecl', listing: listed.files, verdictType: spec.verdictType, jobLines: Array.isArray(spec.jobLines) ? spec.jobLines : null, inputLabels: inputLabelsOf(spec.inputs) });
|
|
1518
1193
|
// the grounded gate's reds quote BOTH untrusted sources — the declaration, and
|
|
1519
1194
|
// the seed listing itself (the listing rule names what really sits beside an
|
|
1520
1195
|
// invented path). The listing half is a channel gate 1a structurally cannot
|
|
@@ -1562,7 +1237,7 @@ export async function prepareSigning({
|
|
|
1562
1237
|
};
|
|
1563
1238
|
if (stops.length) {
|
|
1564
1239
|
// M2: a rubric job's readout never uses the code-job wording ("install, build and test commands")
|
|
1565
|
-
const rubricJob = (Array.isArray(spec.closeDecl?.stages) ? spec.closeDecl.stages : []).some((/** @type {any} */ st) => st &&
|
|
1240
|
+
const rubricJob = (Array.isArray(spec.closeDecl?.stages) ? spec.closeDecl.stages : []).some((/** @type {any} */ st) => st && st.kind === 'rubric-step');
|
|
1566
1241
|
const reds = stops.map((s) => ({
|
|
1567
1242
|
code: 'broken-close',
|
|
1568
1243
|
...(rubricJob ? { rubricJob: true } : {}),
|
|
@@ -1598,49 +1273,12 @@ export async function prepareSigning({
|
|
|
1598
1273
|
workRed: workRed.map((r) => r.stage),
|
|
1599
1274
|
};
|
|
1600
1275
|
|
|
1601
|
-
// ── gate 4: THE CALIBRATION GATE (softgreen module 5). The ONLY paid gate, and
|
|
1602
|
-
// it runs LAST for exactly that reason: every $0 refusal above has already had
|
|
1603
|
-
// its chance, so a broken declaration or a stage that cannot run is found for
|
|
1604
|
-
// free. MANDATORY for any close carrying a judged-floor stage — module 4's
|
|
1605
|
-
// validator checks a stored set for LEGALITY only and deliberately allows a
|
|
1606
|
-
// judged stage with no set at all, because making it mandatory is a signing
|
|
1607
|
-
// decision and this is the signing gate.
|
|
1608
|
-
const judged = judgedStages(spec.closeDecl);
|
|
1609
|
-
if (judged.length) {
|
|
1610
|
-
if (judgeLoop !== null && (typeof judgeModel !== 'string' || judgeModel.trim() === '')) {
|
|
1611
|
-
throw new Error('[authorjob] prepareSigning was wired a judgeLoop with no judgeModel (PRD item 32.1). The two '
|
|
1612
|
-
+ 'halves of the judge seam travel together: the graded set is stamped with the judge that certified it, and '
|
|
1613
|
-
+ 'there is no library pin to fall back to.');
|
|
1614
|
-
}
|
|
1615
|
-
const cal = await calibrationGate({
|
|
1616
|
-
spec, judgedStages: judged, judgeLoop, judgeModel: /** @type {string} */ (judgeModel),
|
|
1617
|
-
onJudgeCost, calibrateFn, ceilingUsd, priorCalls,
|
|
1618
|
-
});
|
|
1619
|
-
base.gates.calibration = cal.record;
|
|
1620
|
-
if (!cal.ok) return { ...base, work, guards, reds: cal.reds, refusal: cal.refusal };
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
1276
|
// D9.3 — nothing red at seed means nothing to do. Round 2's arm B read GREEN
|
|
1624
1277
|
// with value 0 because mypy died on an unrelated broken fixture and scanned
|
|
1625
1278
|
// nothing: an instrument scanning nothing reads clean, which is F6's shape at
|
|
1626
1279
|
// the close-authoring layer, and this gate is what refuses it BEFORE a
|
|
1627
1280
|
// signature rather than after a paid run.
|
|
1628
|
-
|
|
1629
|
-
// THE JUDGED ROUTE (ruling 3, widened 2026-10-09 by hamr: "a rubric job should
|
|
1630
|
-
// check if judge can judge (calibration) and judge rules can apply properly to
|
|
1631
|
-
// pass ... we can't close everything upfront"). A close carrying ANY judged stage
|
|
1632
|
-
// has a work-bearing stage that ruling 8 exempts from the seed read, so the seed
|
|
1633
|
-
// cannot show it red — not because it measures nothing, but because it is not
|
|
1634
|
-
// measured there. Its proof of failability is the calibration gate, which has
|
|
1635
|
-
// just run and passed (a failed one returned above), and which contains signed
|
|
1636
|
-
// cases the pipe must RED as well as ones it must pass. That holds for a PURE
|
|
1637
|
-
// judged close and a MIXED one alike; a close with NO judged stage takes the
|
|
1638
|
-
// original path unchanged (some work stage must be red at the seed).
|
|
1639
|
-
if (workRed.length === 0 && seedProofIsCalibration(judged, base.gates.calibration)) {
|
|
1640
|
-
// said out loud in the record: this close passed gate 3 on a DIFFERENT proof,
|
|
1641
|
-
// and a reader must never have to infer which one from an empty workRed list
|
|
1642
|
-
base.gates.seedVerdict.satisfiedBy = 'calibration';
|
|
1643
|
-
} else if (!workRed.length) {
|
|
1281
|
+
if (!workRed.length) {
|
|
1644
1282
|
return {
|
|
1645
1283
|
...base,
|
|
1646
1284
|
work,
|