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/rubricstep.js
CHANGED
|
@@ -669,7 +669,8 @@ export function checkRubricParts(stages, { inputLabels = null, red, picks = null
|
|
|
669
669
|
return;
|
|
670
670
|
}
|
|
671
671
|
// keep-both: a fact line may carry a countable part only when it IS one of the person's recorded picks (an offered check, its `rules`, the same line, the same words)
|
|
672
|
-
const
|
|
672
|
+
const isNote = factLine && isDefaultNote(part, step);
|
|
673
|
+
const isPick = isNote || factLine && Array.isArray(picks) && picks.some((x) => isRec(x) && x.line === step && sameJson(x.part, part)) && OFFERED.includes(part.check) && Array.isArray(part.rules);
|
|
673
674
|
if (factLine && !isPick) {
|
|
674
675
|
red('rubric-fact-text', w, `line ${line}: '${said}' counts or quotes free text, but this line lists facts and has no text. Say it as a fact (a shape and a rule) or remove it. Nothing spent.`, { line: step, stage: label });
|
|
675
676
|
return;
|
|
@@ -828,6 +829,9 @@ export function holdsManyBounds(shape, text) {
|
|
|
828
829
|
return false;
|
|
829
830
|
}
|
|
830
831
|
|
|
832
|
+
/** the plain reason a rule's amount is in a currency the page fact does not use; `readLimit` gives it and the check list reads it, one spelling */
|
|
833
|
+
export const WHY_OTHER_CURRENCY = 'the amount is in another currency than the page fact';
|
|
834
|
+
|
|
831
835
|
/**
|
|
832
836
|
* The limit the person's own words give a fact of this shape: `{reading}` or `{why}` (a plain reason; the rule then stays Not checked).
|
|
833
837
|
* @param {string} shape money or time @param {string} text the `~` rule's words @param {any} [fact] the look fact (its currency and unit lists must fit)
|
|
@@ -850,7 +854,7 @@ export function readLimit(shape, text, fact = {}) {
|
|
|
850
854
|
if (/\b(?:not|never|outside|except|without)\b/i.test(t)) return { why: 'a negated limit (not, except, without) is not read' };
|
|
851
855
|
const amts = [...t.matchAll(AMOUNT_ALL_RE)];
|
|
852
856
|
if (!amts.length) return { why: 'no amount with a currency sign or word in the rule' };
|
|
853
|
-
for (const a of amts) if (!currencyFits(a[0], fact)) return { why:
|
|
857
|
+
for (const a of amts) if (!currencyFits(a[0], fact)) return { why: WHY_OTHER_CURRENCY };
|
|
854
858
|
if (holdsManyBounds('money', t)) return { why: 'more than one amount in the rule' };
|
|
855
859
|
const b = MONEY_BETWEEN_RE.exec(t);
|
|
856
860
|
if (b) { const lo = num(b[1], b[2]), hi = num(b[3], b[4]); return lo < hi ? { reading: { op: 'between', lo, hi } } : { why: 'a range whose end is not above its start is not read' }; }
|
|
@@ -864,7 +868,7 @@ export function readLimit(shape, text, fact = {}) {
|
|
|
864
868
|
}
|
|
865
869
|
|
|
866
870
|
/** the words a list row of kind `$cited` / `$numbers` carries no text for */
|
|
867
|
-
const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input', numbers: 'every number matches a quote' });
|
|
871
|
+
const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input', numbers: 'every number matches a quote', note: 'the note' });
|
|
868
872
|
|
|
869
873
|
/**
|
|
870
874
|
* A check-list row named in the person's plain words: `phrase "### Fixed"`. The words are the draft log's; with none, the text after the key's kind prefix (`L1.phrase.### fixed`).
|
|
@@ -874,7 +878,7 @@ const DEFAULT_ROW_WORDS = Object.freeze({ cited: 'every claim quotes its input',
|
|
|
874
878
|
*/
|
|
875
879
|
export function listRowName(kind, key, words) {
|
|
876
880
|
const k = typeof kind === 'string' && kind ? kind : 'check';
|
|
877
|
-
if (k === 'cited' || k === 'numbers') return DEFAULT_ROW_WORDS[k];
|
|
881
|
+
if (k === 'cited' || k === 'numbers' || k === 'note') return DEFAULT_ROW_WORDS[k];
|
|
878
882
|
const tail = key.replace(/^L\d+\.(?:[^.]*\.)?/, '').trim();
|
|
879
883
|
const w = Array.isArray(words) && words.length ? words : [tail || key];
|
|
880
884
|
return `${k} ${w.map((x) => `"${x}"`).join(', ')}`;
|
|
@@ -950,7 +954,7 @@ export function partSentence(part) {
|
|
|
950
954
|
case 'maxLines': return `the text is at most ${n(part.value, 'line')}`;
|
|
951
955
|
case 'sections': return `the text has the section(s): ${list(part.names)}`;
|
|
952
956
|
case 'sectionWords': return `each section (${list(part.names)}) is about ${part.wordsPerSection} words`;
|
|
953
|
-
case 'nonEmpty': return 'the text is not empty';
|
|
957
|
+
case 'nonEmpty': return /^line \d+ writes a note — the note must be there$/.test(String(part.text)) ? String(part.text) : 'the text is not empty';
|
|
954
958
|
case 'listItems': return `the text has exactly ${n(part.value, 'list item')}`;
|
|
955
959
|
case 'maxListItems': return `the text has at most ${n(part.value, 'list item')}`;
|
|
956
960
|
case 'minListItems': return `the text has at least ${n(part.value, 'list item')}`;
|
|
@@ -968,6 +972,22 @@ export function partSentence(part) {
|
|
|
968
972
|
/** the words of the default cited check code adds to a text line of a one-input job (the one list's `$` row); the card reads a part with exactly these words as `[default]` @param {string} label @returns {string} */
|
|
969
973
|
export const defaultCitedText = (label) => `every claim is backed by a quote copied from "${label}"`;
|
|
970
974
|
|
|
975
|
+
/** the words of the default note check code adds to a facts line that also asks for written words (the one list's `$` row, build 2026-11-14 (b)); the card reads a part with exactly these words as `[default]` @param {number} n the job line @returns {string} */
|
|
976
|
+
export const defaultNoteText = (n) => `line ${n} writes a note — the note must be there`;
|
|
977
|
+
/** is this part the default note check of line `n`? */
|
|
978
|
+
const isDefaultNote = (/** @type {any} */ p, /** @type {number} */ n) => isRec(p) && p.class === 'countable' && p.check === 'nonEmpty' && p.text === defaultNoteText(n);
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Does the signed close really put a text-present check on job line `n`'s step file? (ONE reader, derived from the close: the protections list and the brief never claim it otherwise.)
|
|
982
|
+
* A facts line has no text check unless a countable part (a pick, or the default note) sits beside its facts; a line with no stage has none.
|
|
983
|
+
* @param {any} closeDecl @param {number} n @returns {boolean}
|
|
984
|
+
*/
|
|
985
|
+
export function lineCarriesText(closeDecl, n) {
|
|
986
|
+
const stages = isRec(closeDecl) && Array.isArray(closeDecl.stages) ? closeDecl.stages : [];
|
|
987
|
+
return stages.some((/** @type {any} */ st) => isRec(st) && st.kind === 'rubric-step' && isRec(st.params) && st.params.step === n && Array.isArray(st.params.parts)
|
|
988
|
+
&& !(factPartOf(st.params) && !st.params.parts.some((/** @type {any} */ x) => isRec(x) && x.class === 'countable')));
|
|
989
|
+
}
|
|
990
|
+
|
|
971
991
|
/**
|
|
972
992
|
* The checks a signed close actually runs, per job line, in plain code-written sentences: one per countable part of every
|
|
973
993
|
* rubric-step stage. This is the ONE reader both the plan card and the sign-time invariant use.
|
|
@@ -994,7 +1014,7 @@ export function checksOfClose(closeDecl) {
|
|
|
994
1014
|
? st.params.parts.flatMap((/** @type {any} */ p, /** @type {number} */ pi) => {
|
|
995
1015
|
if (!isRec(p) || (p.class !== 'countable' && p.class !== 'fact')) return [];
|
|
996
1016
|
/** @type {'agent'|'you'|'default'} */
|
|
997
|
-
const by = p.check === 'numbersFromFacts' || (p.check === 'cited' && p.text === defaultCitedText(p.source)) ? 'default' : record.some((/** @type {any} */ x) => isRec(x) && x.line === st.params.step && sameJson(x.part, p)) ? 'you' : 'agent';
|
|
1017
|
+
const by = p.check === 'numbersFromFacts' || isDefaultNote(p, st.params.step) || (p.check === 'cited' && p.text === defaultCitedText(p.source)) ? 'default' : record.some((/** @type {any} */ x) => isRec(x) && x.line === st.params.step && sameJson(x.part, p)) ? 'you' : 'agent';
|
|
998
1018
|
// a fact part is one plan row per fact (and one for its count): the person signs the rows, the close runs the same list
|
|
999
1019
|
if (p.class !== 'fact') return [{ line: st.params.step, text: partSentence(p), by }];
|
|
1000
1020
|
const facts = Array.isArray(p.facts) ? p.facts : [];
|
package/src/run.js
CHANGED
|
@@ -100,19 +100,6 @@ async function primitiveSmoke(workdir) {
|
|
|
100
100
|
* (`ratesFor`, src/providerrows.js — USD per 1K tokens), resolved once by the door and handed to every
|
|
101
101
|
* worker/planner Loop as bare-agent's `rates` (rounds then read `rateSource:'caller'`). Absent = the
|
|
102
102
|
* built-in guess, exactly as before. A Loop-driven provider only: a native session reports its own cost.
|
|
103
|
-
* @param {{in: number, out: number}|null} [opts.judgeRates] the same, for the judge's own key row
|
|
104
|
-
* @param {string|null} [opts.judgeModel] SOFTGREEN — WHICH model the judge provider drives
|
|
105
|
-
* (PRD item 32.1), resolved by the CALLER (`resolveJudge`, src/judged.js) and passed
|
|
106
|
-
* through untouched. Travels with `judgeProvider`; absent, a judged stage stops as a
|
|
107
|
-
* wiring gap rather than grading under an identity nobody named.
|
|
108
|
-
* @param {any} [opts.judgeProvider] SOFTGREEN — the provider a JUDGED close stage runs its
|
|
109
|
-
* locate call through, built by the CALLER from the RESOLVED judge identity (PRD item
|
|
110
|
-
* 32.1: `resolveJudge`/`resolveJobJudge`, src/judged.js — the spec's signed `judge`
|
|
111
|
-
* override, else the job's own worker provider and model), never pinned. Forwarded to the plan
|
|
112
|
-
* flow. It is its own seam and not `provider`/`providerFor`, because the judge tier is
|
|
113
|
-
* never a step knob and never agent-selectable; absent, a judged stage instrument-stops as
|
|
114
|
-
* a wiring gap rather than grading on whatever binding happened to be at hand. Its spend
|
|
115
|
-
* lands on this ledger as `judge-round` (see `ACCOUNTED_ROUND_TYPES`).
|
|
116
103
|
* @param {Record<string, string>|null} [opts.placeValues] PLACE RULES (src/placerule.js): the values this run's start read for the spec's place-rule facts, by key. Bound
|
|
117
104
|
* as those facts' phrases on the run's own in-memory copy AFTER the approval check and the `job-start` record, so the hash checked and the hash recorded stay the
|
|
118
105
|
* SIGNED one and the signed spec is never changed; the planner and the close read the copy. Absent = the signed words.
|
|
@@ -285,7 +272,7 @@ async function primitiveSmoke(workdir) {
|
|
|
285
272
|
* deliberately NOT in the resumable/checkpoint set (`src/reuse.js`) — an
|
|
286
273
|
* unknown in-flight state is not a known-safe resume point.
|
|
287
274
|
*/
|
|
288
|
-
export async function runJob(rawSpec, { approvals, workdir, provider, nativeProvider, providerFor,
|
|
275
|
+
export async function runJob(rawSpec, { approvals, workdir, provider, nativeProvider, providerFor, rates = null, emit, capRuns = 3, strikeLimit, shellCapUsd = 2, closeTimeoutMs, closeDir = null, layerRoot = false, readShim = false, scout = true, bridge = null, draftSpentUsd = 0, draftSpendComplete = true, priorSpentUsd = 0, priorSpendComplete = true, priorWallMs = 0, resumeSeed = null, resumeGrades = [], resumeReplans = null, resumeBranch = null, humanRuling = null, heldRuling = null, reviewDoor = null, doorRerun = null, resumable = true, stopFile = null, learnHints = null, ticketRecord = null, ticketUnsure = null, prRecord = null, placeValues = null, placeRead = null }) {
|
|
289
276
|
// THE READ SHIM's ARM, resolved at the door — the FIRST thing this entry does,
|
|
290
277
|
// before the ledger, before the approval gate, before a byte of the spec is read.
|
|
291
278
|
// An unrecognised spelling throws here at zero cost instead of being coerced by
|
|
@@ -559,7 +546,7 @@ export async function runJob(rawSpec, { approvals, workdir, provider, nativeProv
|
|
|
559
546
|
// accounts it natively (F12) and the job-end money contract is unchanged.
|
|
560
547
|
{
|
|
561
548
|
const outcome = await runPlan(job, {
|
|
562
|
-
workdir, provider, nativeProvider, providerFor,
|
|
549
|
+
workdir, provider, nativeProvider, providerFor, rates, emit: meter, capRuns, ...(strikeLimit !== undefined ? { strikeLimit } : {}), closeTimeoutMs, closeDir, layerRoot, readShim, scout, bridge, priorWallMs: chainWallMs, resumeSeed, resumeGrades, resumeReplans, resumeBranch, humanRuling, heldRuling, reviewDoor, doorRerun, priorSpentUsd: chainFoldUsd, resumable, stopFile, learnHints,
|
|
563
550
|
// hamr's ruling 2026-09-28 — ONE cap covers drafting + run: the run's
|
|
564
551
|
// enforced ceiling is the signed `budgetUsd` (unchanged, still in the
|
|
565
552
|
// spec hash) MINUS whatever drafting already spent on this job before
|
package/src/userrun.js
CHANGED
|
@@ -32,7 +32,7 @@ import { commitWork, removeWorktree, removePrRef } from './worktree.js';
|
|
|
32
32
|
import { moveFile } from './movefile.js';
|
|
33
33
|
import { runJob } from './run.js';
|
|
34
34
|
import { moneyWithDraft } from './replay.js';
|
|
35
|
-
import { jobSpecHash, resolveWorkerModel, validateJob, workflowKey, flowTypeOf } from './job.js';
|
|
35
|
+
import { jobSpecHash, resolveWorkerModel, validateJob, workflowKey, flowTypeOf, oldJobWords } from './job.js';
|
|
36
36
|
import { ticketNumberOf, TICKET_NUMBER_WORDS } from './ticketshape.js';
|
|
37
37
|
import { freezeRepoTicket } from './ticketrepo.js';
|
|
38
38
|
import { newestUnrunTicket } from './ticketnext.js';
|
|
@@ -54,25 +54,12 @@ import { readSourceManifest, frontDoorFromManifest, proveDestination, copyOut, r
|
|
|
54
54
|
import { scanSecrets, redactSecrets } from './validate.js';
|
|
55
55
|
import { runBehaviour, formatBehaviour } from './behaviour.js';
|
|
56
56
|
// the three doors' SEMANTICS live in the library; this script surfaces them
|
|
57
|
-
import { normalizeHumanRuling, resolveHumanRuling
|
|
58
|
-
// SOFTGREEN — the judged stage's PINNED tier. The constant is the library's; a
|
|
59
|
-
// spelling here would be a second pin that can drift from the one the gate calibrated.
|
|
60
|
-
import { resolveJudge } from './judged.js';
|
|
57
|
+
import { normalizeHumanRuling, resolveHumanRuling } from './kinds.js';
|
|
61
58
|
// --resume reads the halted run's own spine back through the SAME reader the reuse
|
|
62
59
|
// path uses (never a second one) and keeps its patient the way it left it.
|
|
63
60
|
import { readResume, resumeTreeGate, checkpointAgeGate, writeRunGreenRow, CHECKPOINT_OUTCOMES, PAUSE_TTL_MS } from './reuse.js';
|
|
64
|
-
// PRD item 28's provider factory (src/providers.js): the WORKER provider's
|
|
65
|
-
//
|
|
66
|
-
// Settings row, src/providerrows.js) — one seam instead
|
|
67
|
-
// of an `if (provider === …)` scattered across this script. PRD item 32.2
|
|
68
|
-
// moved the JUDGE onto this SAME factory: it used to be separately pinned
|
|
69
|
-
// below to a hardcoded Anthropic constructor at the judged tier because the
|
|
70
|
-
// judge could only ever be Claude — now that its identity is RESOLVED
|
|
71
|
-
// (`resolveJudge`, imported above) rather than pinned, building it through a
|
|
72
|
-
// second bespoke constructor would be a second seam for the same job the
|
|
73
|
-
// worker's already goes through. `tests/reviewdoor-u.test.js` greps this
|
|
74
|
-
// file's own source to prove THIS runner actually wires the resolved judge
|
|
75
|
-
// through `makeProvider` into `runJob` (not just that the library can).
|
|
61
|
+
// PRD item 28's provider factory (src/providers.js): the WORKER provider's ctor/param-gating come from here (its key variable and price come from the
|
|
62
|
+
// Settings row, src/providerrows.js) — one seam instead of an `if (provider === …)` scattered across this script.
|
|
76
63
|
import { resolveProvider, makeProvider, probeWarningLines, apiKeyProblem } from './providers.js';
|
|
77
64
|
import { loadRegistry, quarantinesCredit } from './bridges.js';
|
|
78
65
|
import { HITL_PAUSE } from './declaredclose.js';
|
|
@@ -92,7 +79,7 @@ import { claimRun, monthlyRefusalText, legSpend, chainSpend } from './monthly.js
|
|
|
92
79
|
import { ConfigError } from './config.js';
|
|
93
80
|
import { learnAtRunEnd, handedHints, releaseRun } from './learnstore.js';
|
|
94
81
|
import { commandFor } from './invoke.js';
|
|
95
|
-
import {
|
|
82
|
+
import { keyNameFor, keyValueOf, priceReadout, ratesFor, ratesOfLine, resolveWorker, rowsForHome, REFUSE_NAME_MODEL } from './providerrows.js';
|
|
96
83
|
// the banner's wall arithmetic, extracted so it is reachable by a test (F83): the
|
|
97
84
|
// end-of-run readout sits past the approval gate, so nothing could ever drive it here
|
|
98
85
|
import { wallLine, doomedResume, deathAtOf, evidencePackage, doorLines, resumeAtLines, reviewDoorPackage, runDoorLines, tokensLine, doorTimingRedLines } from './u-readout.js';
|
|
@@ -247,7 +234,6 @@ class ExitSignal extends Error {
|
|
|
247
234
|
* check entirely, the same shape `src/cli.js`'s `main(argv, deps)` uses.
|
|
248
235
|
* @property {(tier: string) => any} [providerFor]
|
|
249
236
|
* @property {(url: string) => Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>} [fetchUrl] PART 1c - a test seam: how a web input is read at run start (production: barebrowse)
|
|
250
|
-
* @property {any} [judgeProvider]
|
|
251
237
|
* @property {typeof newestUnrunTicket} [newestUnrunTicket] R6 - a test seam: how a Tickets run that names no `--ticket` finds the newest unrun ticket (production: the real look, src/ticketnext.js)
|
|
252
238
|
* @property {string} [mcpConfig] R6 - a test seam: the MCP config file that look reads (production: the person's own, found by src/mcpsources.js)
|
|
253
239
|
* @property {string} [runlistHome] F196 — a test seam for `appendRun`'s
|
|
@@ -529,9 +515,7 @@ async function execute(ctx) {
|
|
|
529
515
|
// MODEL (build-list #3, hamr's GO 2026-08-30): the signed spec's `model`, if
|
|
530
516
|
// present, wins outright; a --model flag naming a DIFFERENT id is refused
|
|
531
517
|
// (never silently overridden) — resolveWorkerModel is the one decision, pure
|
|
532
|
-
// and tested apart from this script.
|
|
533
|
-
// (`resolveJudge`, below the key block): it defaults to this same resolved
|
|
534
|
-
// worker model and a signed `judge` override wins over it.
|
|
518
|
+
// and tested apart from this script.
|
|
535
519
|
// There is no default model: a spec or flag that names none dies below with
|
|
536
520
|
// REFUSE_NAME_MODEL (the model is one ticked in Settings). `spec.provider` is not validateJob'd until
|
|
537
521
|
// runJob below, so an unrecognized value dies here with the same operator-
|
|
@@ -1032,7 +1016,7 @@ async function execute(ctx) {
|
|
|
1032
1016
|
// the key from. Resolved ONCE here, at $0, before the preview, the monthly claim and any worktree or
|
|
1033
1017
|
// spine, then handed down as data (`runJob`'s `rates`) — nothing deep in the run re-reads config. A bad
|
|
1034
1018
|
// price refuses here; it never falls back to the built-in guess. No price set = `null` = no `rates` key
|
|
1035
|
-
// passed anywhere, byte-identical to before.
|
|
1019
|
+
// passed anywhere, byte-identical to before.
|
|
1036
1020
|
const keyCfg = cfgOn ? rowsForHome(cfgHome, env) : [];
|
|
1037
1021
|
/** @type {ReturnType<typeof ratesFor>} */
|
|
1038
1022
|
let workerPrice = null;
|
|
@@ -1453,50 +1437,9 @@ async function execute(ctx) {
|
|
|
1453
1437
|
// so there is one place saying which row reads which variable) and is
|
|
1454
1438
|
// ALWAYS required — the worker always runs.
|
|
1455
1439
|
//
|
|
1456
|
-
//
|
|
1457
|
-
// (`closeJudges`, src/kinds.js — the ONE reading of that question), and since
|
|
1458
|
-
// PRD item 32 the judge is no longer pinned to Anthropic: its identity is
|
|
1459
|
-
// RESOLVED below, and its key follows that resolved provider's own env var with
|
|
1460
|
-
// `JUDGE_API_KEY` as a role-named override in front. One variable used to do two
|
|
1461
|
-
// jobs (worker key for an anthropic-api job AND judge key for every job), which
|
|
1462
|
-
// was confusing while the judge was pinned and would be a plain lie now that it
|
|
1463
|
-
// is not.
|
|
1464
|
-
//
|
|
1465
|
-
// A green anthropic-api job's behaviour is byte-identical to before: its
|
|
1466
|
-
// worker key IS `ANTHROPIC_API_KEY`, demanded as ever.
|
|
1467
|
-
const JUDGES = closeJudges(spec.closeDecl);
|
|
1468
|
-
// WHICH MODEL GRADES THIS JOB (PRD item 32.1). Resolved, never pinned: the
|
|
1469
|
-
// spec's signed `judge: {provider, model}` if it names one, else this job's own
|
|
1470
|
-
// worker provider and model — so a DeepSeek or Gemini job judges on its own
|
|
1471
|
-
// provider and needs no second account. `resolveJudge` throws on a malformed
|
|
1472
|
-
// override rather than quietly falling back to the worker's; the spec validator
|
|
1473
|
-
// has already redded that shape, so reaching the throw means a caller skipped
|
|
1474
|
-
// validation. Resolved UNCONDITIONALLY (needs no key) — `judge.model` rides
|
|
1475
|
-
// into runJob below whether this leg constructs a real judge provider or not.
|
|
1476
|
-
const judge = resolveJudge({ specJudge: spec.judge, workerProvider: spec.provider, workerModel: MODEL });
|
|
1477
|
-
const judgeEntry = resolveProvider(judge.provider);
|
|
1478
|
-
// …and the judge's price, from the judge MODEL's row (`judgeRatesFor`): on the worker's endpoint when the
|
|
1479
|
-
// judge is the same provider (falling back to the worker's price when the model names no row), else the
|
|
1480
|
-
// row for the judge's own provider. Only a judging close ever calls it, so only then can its row refuse the run.
|
|
1481
|
-
/** @type {ReturnType<typeof ratesFor>} */
|
|
1482
|
-
let judgePrice = null;
|
|
1483
|
-
if (JUDGES) {
|
|
1484
|
-
try {
|
|
1485
|
-
judgePrice = judgeRatesFor(judge, spec.provider, baseUrl, workerPrice, keyCfg);
|
|
1486
|
-
} catch (e) {
|
|
1487
|
-
if (!(e instanceof ConfigError)) throw e;
|
|
1488
|
-
err(`${e.message} — refusing to start rather than guess a price. Nothing spent.`);
|
|
1489
|
-
throw new ExitSignal(2);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
/** the row the judge's key (and endpoint) comes from: the worker's own row when the judge shares its provider, else the judge provider's row */
|
|
1493
|
-
const judgeRow = judgeRowFor(keyCfg, judge, spec.provider, W && W.ok ? W.row : null);
|
|
1494
|
-
// undefined, not null: both come straight off `env[...]` lookups below, which
|
|
1495
|
-
// (like process.env) never produce null for a missing key.
|
|
1440
|
+
// hamr 2026-11-14: there is no judge key any more — the old judge is gone, and a rubric job grades on the check list with no model call.
|
|
1496
1441
|
/** @type {string|undefined} */
|
|
1497
1442
|
let workerApiKey;
|
|
1498
|
-
/** @type {string|undefined} */
|
|
1499
|
-
let judgeApiKey;
|
|
1500
1443
|
// TEST SEAM (constraint: `deps.provider` skips the real-key check entirely,
|
|
1501
1444
|
// the same shape src/bundlerun.js's door uses) — a caller that hands in
|
|
1502
1445
|
// its own provider IS the run, so nothing here needs a real secret.
|
|
@@ -1504,8 +1447,7 @@ async function execute(ctx) {
|
|
|
1504
1447
|
// P4b — the Settings row (keys file line) whose API shape + Base URL match this spec
|
|
1505
1448
|
// supplies the key VARIABLE, standing in for the provider's built-in one; no matching
|
|
1506
1449
|
// row = the built-in. Names only — values come from the
|
|
1507
|
-
// env / keys file.
|
|
1508
|
-
// (the same rule that gives it the worker's baseUrl below).
|
|
1450
|
+
// env / keys file.
|
|
1509
1451
|
refuseWorker();
|
|
1510
1452
|
const workerKeyName = /** @type {NonNullable<typeof W> & {ok: true}} */ (W).row.envName;
|
|
1511
1453
|
// A job's worker key is its Settings row's own variable — there is no built-in name.
|
|
@@ -1517,29 +1459,6 @@ async function execute(ctx) {
|
|
|
1517
1459
|
// door, before any provider is constructed; never echo the value.
|
|
1518
1460
|
const workerKeyProblem = apiKeyProblem(workerApiKey);
|
|
1519
1461
|
if (workerKeyProblem) { err(`${workerKeyName} ${workerKeyProblem} — refusing rather than crashing mid-call (never trimmed or repaired; fix the value at its source)`); throw new ExitSignal(2); }
|
|
1520
|
-
// The judge's KEY follows the RESOLVED judge provider's own env var, with
|
|
1521
|
-
// `JUDGE_API_KEY` as a role-named override in front of it (PRD item 32.3). The
|
|
1522
|
-
// override matters most in the case this item exists for: a job whose worker and
|
|
1523
|
-
// judge are the SAME provider but different accounts, and the anthropic case
|
|
1524
|
-
// where one variable used to do two jobs.
|
|
1525
|
-
judgeApiKey = env.JUDGE_API_KEY ?? keyValueOf(env, judgeRow?.envName);
|
|
1526
|
-
if (JUDGES && !judgeApiKey) {
|
|
1527
|
-
err(`This job's close JUDGES (${judgedStages(spec.closeDecl).length} judged stage(s)) and its judge is ${judge.model} on ${judge.provider}${spec.judge ? ' (signed override)' : " (this job's own worker model — no `judge` override signed)"}.`);
|
|
1528
|
-
err(`Neither JUDGE_API_KEY nor ${judgeRow?.envName ?? `a key row for ${judge.provider}`} is set — secrets load from the environment, never the tree.`);
|
|
1529
|
-
err('Refused at $0, BEFORE the worker spends anything: a judged run that discovers this at the close has paid for a verdict it cannot render.');
|
|
1530
|
-
throw new ExitSignal(2);
|
|
1531
|
-
}
|
|
1532
|
-
// F181 — same door, second shape: a judge key that IS present can still be
|
|
1533
|
-
// malformed (line break/control char/stray whitespace). Checked only when
|
|
1534
|
-
// JUDGES (the key is only required then); never echoes the value.
|
|
1535
|
-
if (JUDGES) {
|
|
1536
|
-
const judgeKeyProblem = apiKeyProblem(/** @type {string} */ (judgeApiKey));
|
|
1537
|
-
if (judgeKeyProblem) {
|
|
1538
|
-
const judgeEnvName = env.JUDGE_API_KEY ? 'JUDGE_API_KEY' : (judgeRow?.envName ?? judge.provider);
|
|
1539
|
-
err(`${judgeEnvName} ${judgeKeyProblem} — refusing rather than crashing mid-call (never trimmed or repaired; fix the value at its source)`);
|
|
1540
|
-
throw new ExitSignal(2);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
1462
|
}
|
|
1544
1463
|
|
|
1545
1464
|
// THE MONTHLY $ LIMIT (PANEL-BUILD.md P4a; hamr 2026-09-30: "whoever runs first claims the limit and
|
|
@@ -1813,31 +1732,12 @@ async function execute(ctx) {
|
|
|
1813
1732
|
// construction never runs (a scripted provider IS the run).
|
|
1814
1733
|
let provider = deps.provider;
|
|
1815
1734
|
let providerFor = deps.providerFor;
|
|
1816
|
-
let judgeProvider = deps.judgeProvider ?? null;
|
|
1817
1735
|
if (!provider) {
|
|
1818
1736
|
const legacyMaxTokens = W && W.ok ? W.row.legacyMaxTokens : false;
|
|
1819
1737
|
provider = makeProvider(spec.provider, { apiKey: /** @type {string} */ (workerApiKey), model: MODEL, baseUrl, legacyMaxTokens });
|
|
1820
1738
|
// P: the per-step model factory. The ONLY tier a plan may name is the schema token `sonnet` (STEP_MODELS, src/plan.js — a
|
|
1821
1739
|
// documented schema token, not a model id); it means THIS job's worker model, so every step's provider is the one above.
|
|
1822
1740
|
providerFor = () => provider;
|
|
1823
|
-
// SOFTGREEN — the JUDGED stage's own provider. Since PRD item 32.1 its identity is
|
|
1824
|
-
// RESOLVED (`judge` above), not pinned: the spec's signed `judge` override, else this
|
|
1825
|
-
// job's own worker model. It is still never a step knob and never agent-selectable —
|
|
1826
|
-
// naming your own examiner is arbiter territory, and `judge` is a field the HUMAN
|
|
1827
|
-
// signs into the hash. The `baseUrl` rides along only when the judge is the same
|
|
1828
|
-
// provider as the worker: a spec's `baseUrl` is the WORKER's endpoint, and pointing a
|
|
1829
|
-
// different vendor's client at it would be the silent-misconfiguration class
|
|
1830
|
-
// `endpointKey` exists to prevent. Built only when `judgeApiKey` is present (PRD item
|
|
1831
|
-
// 31.4 — the judge's key is demanded only when a judge is CALLED, so this construction
|
|
1832
|
-
// is conditional on purpose, not unconditional): `runPlan` reads it only when a stage
|
|
1833
|
-
// is `judged-floor`, and the alternative (deriving "does this close judge?" here) is a
|
|
1834
|
-
// second reading of the declaration that can drift from the one the runner actually
|
|
1835
|
-
// executes. Absent, a judged stage instrument-STOPS as a wiring gap, which is what
|
|
1836
|
-
// every live softgreen run would have done: run-author wired this seam and this
|
|
1837
|
-
// runner never did.
|
|
1838
|
-
judgeProvider = judgeApiKey
|
|
1839
|
-
? makeProvider(judge.provider, { apiKey: /** @type {string} */ (judgeApiKey), model: judge.model, baseUrl: judge.provider === spec.provider ? baseUrl : (judgeRow && judgeRow.baseUrl.trim() !== '' ? judgeRow.baseUrl.trim() : undefined), legacyMaxTokens: judgeRow ? judgeRow.legacyMaxTokens : false })
|
|
1840
|
-
: null;
|
|
1841
1741
|
}
|
|
1842
1742
|
|
|
1843
1743
|
const started = Date.now();
|
|
@@ -2076,9 +1976,9 @@ async function execute(ctx) {
|
|
|
2076
1976
|
// used (never a second `makeSpine(spineFile)` here: two independent
|
|
2077
1977
|
// emitters against one file would both start their seq counter at 0 and
|
|
2078
1978
|
// collide the moment either one had already written a record).
|
|
2079
|
-
approvals, workdir: wd, provider, providerFor,
|
|
1979
|
+
approvals, workdir: wd, provider, providerFor,
|
|
2080
1980
|
// the customer's own price per key row (USD per 1K), or null = the built-in guess as before
|
|
2081
|
-
rates: workerPrice?.rates ?? null,
|
|
1981
|
+
rates: workerPrice?.rates ?? null, emit,
|
|
2082
1982
|
// F133 (run mtqwmb9l) — `closeTimeoutMs` is deliberately NOT passed here.
|
|
2083
1983
|
// `RESOLVED_CLOSE_TIMEOUT_MS` above exists only to size the outside
|
|
2084
1984
|
// watchdog before it spawns; feeding it back into `runJob` used to make
|
|
@@ -2764,6 +2664,9 @@ export async function main(argv, deps = {}) {
|
|
|
2764
2664
|
try { spec = JSON.parse(/** @type {string} */ (raw)); } catch (e) {
|
|
2765
2665
|
die(`--spec ${specPath} is not readable JSON (${e.message}) — a spec nobody can parse is a spec nobody signed`);
|
|
2766
2666
|
}
|
|
2667
|
+
// hamr 2026-11-14: a job made with PASS/FAIL examples or the old judge refuses in plain words, ahead of every other check
|
|
2668
|
+
const oldJob = oldJobWords(spec);
|
|
2669
|
+
if (oldJob) die(`--spec ${specPath}: ${oldJob} Nothing spent.`);
|
|
2767
2670
|
// validateJob'd HERE, at $0, before a single filesystem lookup for the
|
|
2768
2671
|
// source manifest or a single line of the preview prints — a `--job` row's
|
|
2769
2672
|
// spec is developer-authored and reaches this same check inside `runJob`
|
package/types/authorflow.d.ts
CHANGED
|
@@ -67,16 +67,19 @@ export function labelsFor(verdictType: string): Record<string | number, string>;
|
|
|
67
67
|
* close — one source, never a second hand-typed list — rendered through the
|
|
68
68
|
* frozen line in {@link GUARD_DESCRIPTIONS}, plus the write fence (a real,
|
|
69
69
|
* signed fence — {@link writeScopeBlock}'s own subject) when one is set.
|
|
70
|
-
*
|
|
70
|
+
* A rubric line's file is listed as carrying text ONLY when the close really puts a text-present check on it ({@link lineCarriesText}, derived from `closeDecl`; one owner): a facts-only line
|
|
71
|
+
* (results and no note) is listed without it, and with no close to read nothing is claimed about text.
|
|
72
|
+
* @param {{verdictType: string, lang: string, writeScope?: string[]|null, jobLines?: {n: number}[]|null, closeDecl?: any}} o
|
|
71
73
|
* @returns {string[]}
|
|
72
74
|
*/
|
|
73
|
-
export function confirmProtections({ verdictType, lang, writeScope, jobLines }: {
|
|
75
|
+
export function confirmProtections({ verdictType, lang, writeScope, jobLines, closeDecl }: {
|
|
74
76
|
verdictType: string;
|
|
75
77
|
lang: string;
|
|
76
78
|
writeScope?: string[] | null;
|
|
77
79
|
jobLines?: {
|
|
78
80
|
n: number;
|
|
79
81
|
}[] | null;
|
|
82
|
+
closeDecl?: any;
|
|
80
83
|
}): string[];
|
|
81
84
|
/**
|
|
82
85
|
* The mechanical seam between the catalogue and the schema, read BOTH ways: a
|
|
@@ -1260,7 +1263,7 @@ export const INPUTS_FIELD: Readonly<{
|
|
|
1260
1263
|
label: "Inputs";
|
|
1261
1264
|
prompt: string;
|
|
1262
1265
|
}>;
|
|
1263
|
-
/** P7: how to write "The job" (printed under its question by the CLI; the panel's box shows the same in its
|
|
1266
|
+
/** P7: how to write "The job" (printed under its question by the CLI; the panel's box shows the same in its placeholder). */
|
|
1264
1267
|
export const JOB_BLOCK_HELP: readonly string[];
|
|
1265
1268
|
/** Destination's wording when Source resolved to a git repo: the answer IS the
|
|
1266
1269
|
* signed `writeScope` fence (ITEM33-BUILD.md M3 ruling 2). */
|
|
@@ -1319,28 +1322,13 @@ export const GREEN_QUESTIONS: Readonly<{
|
|
|
1319
1322
|
export const FIELD_LABELS: Readonly<{
|
|
1320
1323
|
1: "The job";
|
|
1321
1324
|
}>;
|
|
1322
|
-
/**
|
|
1323
|
-
* `cardauthor.js` reads the SAME number this module files the answer under,
|
|
1324
|
-
* rather than a second, hand-typed "6"/"7". */
|
|
1325
|
-
export const SOFTGREEN_JUDGE_EXAMPLES_KEY: number;
|
|
1326
|
-
/** The Judge Examples question — the signed table's own Holds text, verbatim
|
|
1327
|
-
* ("one pass, one fail, and why"), not the old worded Q7 ("Give one example
|
|
1328
|
-
* you'd pass and one you'd fail, and say why."). Exported so `cardauthor.js`'s
|
|
1329
|
-
* prompt and this module's own `SOFTGREEN_QUESTIONS` render the identical
|
|
1330
|
-
* string; its label ("Judge examples") lives in `SOFTGREEN_FIELD_LABELS`. */
|
|
1331
|
-
export const JUDGE_EXAMPLES_QUESTION: "the PASS: and FAIL: examples the person wrote under their job lines, each with its line number";
|
|
1332
|
-
/** {@link FIELD_LABELS} plus Judge Examples' own label, for the soft-green set. */
|
|
1325
|
+
/** {@link FIELD_LABELS} for the soft-green set: the same one label (the judge examples are gone). */
|
|
1333
1326
|
export const SOFTGREEN_FIELD_LABELS: Readonly<{
|
|
1334
1327
|
1: "The job";
|
|
1335
1328
|
}>;
|
|
1336
1329
|
/**
|
|
1337
|
-
* THE SOFTGREEN SET — the green
|
|
1338
|
-
*
|
|
1339
|
-
* pair in the person's own words, which module 4 (`cardauthor.js`) compiles
|
|
1340
|
-
* into the signed rubric card and the frozen calibration set. It rides in
|
|
1341
|
-
* `answers` and reaches the composer verbatim through the prompt's interview
|
|
1342
|
-
* block, exactly as every other free-text answer does — this module derives
|
|
1343
|
-
* nothing from it.
|
|
1330
|
+
* THE SOFTGREEN SET — the green set again: a rubric job's whole job is the numbered lines of "The job" (its `~` rules
|
|
1331
|
+
* become the check list); the PASS/FAIL judge examples are gone (hamr 2026-11-14).
|
|
1344
1332
|
*/
|
|
1345
1333
|
export const SOFTGREEN_QUESTIONS: Readonly<{
|
|
1346
1334
|
1: "the job, as numbered lines — each line may carry the rules (~) the person wrote under it";
|
|
@@ -1632,43 +1620,6 @@ export const PARAM_SCHEMAS: Readonly<{
|
|
|
1632
1620
|
requireNonEmpty: {
|
|
1633
1621
|
const: boolean;
|
|
1634
1622
|
};
|
|
1635
|
-
card: {
|
|
1636
|
-
type: string;
|
|
1637
|
-
description: string;
|
|
1638
|
-
properties: {
|
|
1639
|
-
items: {
|
|
1640
|
-
type: string;
|
|
1641
|
-
minItems: number;
|
|
1642
|
-
items: {
|
|
1643
|
-
type: string;
|
|
1644
|
-
properties: {
|
|
1645
|
-
rule: {
|
|
1646
|
-
enum: string[];
|
|
1647
|
-
description: string;
|
|
1648
|
-
};
|
|
1649
|
-
text: {
|
|
1650
|
-
type: string;
|
|
1651
|
-
minLength: number;
|
|
1652
|
-
description: string;
|
|
1653
|
-
};
|
|
1654
|
-
};
|
|
1655
|
-
required: string[];
|
|
1656
|
-
additionalProperties: boolean;
|
|
1657
|
-
};
|
|
1658
|
-
};
|
|
1659
|
-
};
|
|
1660
|
-
required: string[];
|
|
1661
|
-
additionalProperties: boolean;
|
|
1662
|
-
};
|
|
1663
|
-
paths: {
|
|
1664
|
-
type: string;
|
|
1665
|
-
minItems: number;
|
|
1666
|
-
maxItems: number;
|
|
1667
|
-
items: {
|
|
1668
|
-
type: string;
|
|
1669
|
-
};
|
|
1670
|
-
description: string;
|
|
1671
|
-
};
|
|
1672
1623
|
step: {
|
|
1673
1624
|
type: string;
|
|
1674
1625
|
minimum: number;
|
package/types/authoring.d.ts
CHANGED
|
@@ -238,16 +238,6 @@ export function ungroundedGenreEnv(lang: string, recorded: Record<string, string
|
|
|
238
238
|
element: string;
|
|
239
239
|
resolved: string;
|
|
240
240
|
}[];
|
|
241
|
-
/**
|
|
242
|
-
* Which of a judged stage's paths lie OUTSIDE the job's write fence? One owner of the rule "a check must be
|
|
243
|
-
* free to edit every file it can report on", called from every door that validates a declaration. It uses
|
|
244
|
-
* the shipped fence spelling (`globToPrefix`, the same containment reading plan.js's `insideFence` has) and
|
|
245
|
-
* returns `[]` when there is no fence to compare against or the paths are not a string list (shape is the
|
|
246
|
-
* schema walk's business).
|
|
247
|
-
* @param {unknown} paths @param {string[]|null|undefined} writeScope
|
|
248
|
-
* @returns {string[]}
|
|
249
|
-
*/
|
|
250
|
-
export function judgedOutsideFence(paths: unknown, writeScope: string[] | null | undefined): string[];
|
|
251
241
|
/**
|
|
252
242
|
* Validate an authored close DECLARATION. Never throws on model output — every
|
|
253
243
|
* failure is a named red, in the shipped `{ok, reds, <parsed>}` shape, and the
|
|
@@ -285,13 +275,11 @@ export function judgedOutsideFence(paths: unknown, writeScope: string[] | null |
|
|
|
285
275
|
* @param {{catalogue?: Record<string, KindSpec>, listing?: string[]|null,
|
|
286
276
|
* guards?: {name: string, kind: string, params: Record<string, any>, fill: string[]}[]|null,
|
|
287
277
|
* envOwned?: string[]|null, envInjected?: Record<string, string>|null, deferListing?: boolean,
|
|
288
|
-
* verdictType?: string|null,
|
|
278
|
+
* verdictType?: string|null, jobLines?: {n: number}[]|null, inputLabels?: string[]|null}} [opts]
|
|
289
279
|
* `inputLabels` — the labels of the person's inputs (Part 1a). Present, a rubric-step `cited` part must name one of them.
|
|
290
280
|
* `jobLines` — the person's numbered job lines (P7). Present, every stage must name the line it serves and every
|
|
291
281
|
* line needs a stage or a refusal ({@link checkJobLines}); absent (every spec that predates the job block), the
|
|
292
282
|
* rule is not run.
|
|
293
|
-
* `writeScope` — the job's signed write fence. Every path a judged stage judges must sit inside it
|
|
294
|
-
* ({@link judgedOutsideFence}); absent, the rule is not run (the plain-folder deferral has no fence).
|
|
295
283
|
* `listing` — repo-relative paths at the seed (`git ls-tree -r --name-only`).
|
|
296
284
|
* `guards` — the picked class's injected guards (`classGuards`).
|
|
297
285
|
* `verdictType` — the class the USER picked (`VERDICT_CLASSES`).
|
|
@@ -318,7 +306,6 @@ export function validateDeclaration(declaration: any, opts?: {
|
|
|
318
306
|
envInjected?: Record<string, string> | null;
|
|
319
307
|
deferListing?: boolean;
|
|
320
308
|
verdictType?: string | null;
|
|
321
|
-
writeScope?: string[] | null;
|
|
322
309
|
jobLines?: {
|
|
323
310
|
n: number;
|
|
324
311
|
}[] | null;
|