bareloop 0.56.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +3 -3
- package/bareloop.context.md +75 -214
- package/package.json +2 -2
- package/src/authorflow.js +71 -136
- package/src/authoring.js +5 -124
- package/src/authorjob.js +125 -417
- package/src/authorreadout.js +105 -355
- package/src/authorrun.js +70 -234
- package/src/authorscout.js +9 -1
- package/src/blockasks.js +12 -17
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +297 -75
- package/src/checklist.js +1 -1
- package/src/checkpick.js +9 -5
- package/src/cli.js +3 -3
- package/src/declaredclose.js +45 -112
- package/src/destpoint.js +1 -1
- package/src/draftspend.js +20 -4
- package/src/fencepointcall.js +76 -0
- package/src/guarddescriptions.js +14 -0
- 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 +10 -348
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +7 -29
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +15 -4
- package/src/panel/authorsession.js +201 -167
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +43 -18
- package/src/panel/jobplan.js +54 -19
- package/src/panel/server.js +90 -69
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +15 -54
- package/src/planrun.js +4 -48
- package/src/promptregisters.js +7 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +34 -30
- package/src/reviewdoor.js +1 -1
- package/src/rowresults.js +69 -0
- package/src/rubricstep.js +136 -28
- package/src/run.js +2 -15
- package/src/stagewords.js +24 -0
- package/src/userrun.js +14 -111
- package/types/authorflow.d.ts +51 -137
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +14 -55
- package/types/authorreadout.d.ts +52 -80
- package/types/authorrun.d.ts +20 -0
- package/types/blockasks.d.ts +5 -11
- package/types/checkblock.d.ts +147 -28
- package/types/checklist.d.ts +2 -2
- package/types/checkpick.d.ts +5 -3
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +5 -33
- package/types/draftspend.d.ts +16 -2
- package/types/fencepointcall.d.ts +68 -0
- package/types/guarddescriptions.d.ts +7 -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 +4 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagemap.d.ts +2 -5
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +37 -5
- package/types/panel/jobplan.d.ts +15 -3
- package/types/panel/server.d.ts +46 -13
- 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/questionbox.d.ts +20 -6
- package/types/rowresults.d.ts +23 -0
- package/types/rubricstep.d.ts +43 -7
- package/types/run.d.ts +1 -20
- package/types/stagewords.d.ts +11 -0
- 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/types/jobblock.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parse "The job" box. A plain line is a numbered job line (1, 2, 3...). A line starting `~` has no number and belongs
|
|
3
3
|
* to the numbered line above; consecutive `~` lines become ONE rule joined with `'; '`. A `~` line starting `PASS:` or
|
|
4
|
-
* `FAIL:` is
|
|
5
|
-
* ignored. A `~` before line 1 is a red.
|
|
4
|
+
* `FAIL:` is a red ({@link PASS_FAIL_GONE_WORDS}). Empty lines are ignored. A `~` before line 1 is a red.
|
|
6
5
|
* @param {unknown} text the box's raw text
|
|
7
6
|
* @returns {{ok: true, lines: JobLine[]}|{ok: false, error: string}}
|
|
8
7
|
*/
|
|
@@ -44,13 +43,6 @@ export function jobBoxText(lines: {
|
|
|
44
43
|
text: string;
|
|
45
44
|
rules: string[];
|
|
46
45
|
}[]): string;
|
|
47
|
-
/**
|
|
48
|
-
* The PASS:/FAIL: examples the person wrote, each kept with its line number (answer 2 of a rubric interview — what the
|
|
49
|
-
* calibration compile reads). Empty string when there are none.
|
|
50
|
-
* @param {JobLine[]} lines
|
|
51
|
-
* @returns {string}
|
|
52
|
-
*/
|
|
53
|
-
export function renderExamples(lines: JobLine[]): string;
|
|
54
46
|
/**
|
|
55
47
|
* The inputs as the drafter is told about them: "the person pointed at these inputs: N label path".
|
|
56
48
|
* @param {JobInput[]} inputs
|
|
@@ -58,24 +50,7 @@ export function renderExamples(lines: JobLine[]): string;
|
|
|
58
50
|
*/
|
|
59
51
|
export function renderInputs(inputs: JobInput[]): string;
|
|
60
52
|
/**
|
|
61
|
-
* The
|
|
62
|
-
* `FAIL:` example (the calibration compile reads them); a DETERMINISTIC job has no judge, so an example line would be
|
|
63
|
-
* silently dropped — a red instead.
|
|
64
|
-
* PART 1a (hamr's ruling P1=B, docs/product/ITEM33-BUILD.md "Addendum 2026-10-12"): the examples are required of a rubric
|
|
65
|
-
* job ONLY when it holds a judged part. A rubric job on the person's own local files holds none in this build (its
|
|
66
|
-
* parts are counted or checked against a quote), so the caller says `judged: false` and a block without examples fits.
|
|
67
|
-
* Examples written anyway are never a red there — they simply have no judge to read them yet.
|
|
68
|
-
* @param {JobLine[]} lines
|
|
69
|
-
* @param {boolean} rubric
|
|
70
|
-
* @param {{judged?: boolean}} [o] `judged` (default true): does this job hold a judged part, so that it needs examples?
|
|
71
|
-
* @returns {string|null} the plain red, or null when the block fits the Check type
|
|
72
|
-
*/
|
|
73
|
-
export function jobBlockFitsCheck(lines: JobLine[], rubric: boolean, { judged }?: {
|
|
74
|
-
judged?: boolean;
|
|
75
|
-
}): string | null;
|
|
76
|
-
/**
|
|
77
|
-
* The signed `jobLines` field from parsed lines: the person's own words, `{n, text, rule, rules}` (examples stay inside the
|
|
78
|
-
* rule text, where the person wrote them). `rules` is the same `~` lines as an array, BESIDE the joined `rule` (never
|
|
53
|
+
* 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
|
|
79
54
|
* replacing it); it is omitted on a line with no `~` line, and an older spec lacks it entirely.
|
|
80
55
|
* @param {JobLine[]} lines
|
|
81
56
|
* @returns {{n: number, text: string, rule: string, rules?: string[]}[]}
|
|
@@ -86,27 +61,22 @@ export function signedJobLines(lines: JobLine[]): {
|
|
|
86
61
|
rule: string;
|
|
87
62
|
rules?: string[];
|
|
88
63
|
}[];
|
|
89
|
-
/** @typedef {{
|
|
90
|
-
/** @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) */
|
|
64
|
+
/** @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 */
|
|
91
65
|
/** @typedef {{n: number, label: string, value: string}} JobInput one numbered `label: value` input line */
|
|
66
|
+
/** 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 */
|
|
67
|
+
export const REPO_RUBRIC_WORDS: "A repo job uses a Deterministic check.";
|
|
92
68
|
/** the joiner for consecutive `~` lines (fwd's joinGuardrails) */
|
|
93
69
|
export const RULE_JOINER: "; ";
|
|
70
|
+
/** hamr 2026-11-14: a `~ PASS:` / `~ FAIL:` line is refused at $0; the check list (`~` rules, Drop and Add) covers what the examples did */
|
|
71
|
+
export const PASS_FAIL_GONE_WORDS: "PASS/FAIL examples are gone \u2014 write what you want as a ~ rule.";
|
|
94
72
|
/**
|
|
95
|
-
*
|
|
96
|
-
*/
|
|
97
|
-
export type JobExample = {
|
|
98
|
-
verdict: "PASS" | "FAIL";
|
|
99
|
-
text: string;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* one numbered job line; `rule` = its `~` lines joined with '; ' ('' when none), `rules` = those same `~` lines one by one (so an example's own '; ' survives)
|
|
73
|
+
* one numbered job line; `rule` = its `~` lines joined with '; ' ('' when none), `rules` = those same `~` lines one by one
|
|
103
74
|
*/
|
|
104
75
|
export type JobLine = {
|
|
105
76
|
n: number;
|
|
106
77
|
text: string;
|
|
107
78
|
rule: string;
|
|
108
79
|
rules: string[];
|
|
109
|
-
examples: JobExample[];
|
|
110
80
|
};
|
|
111
81
|
/**
|
|
112
82
|
* one numbered `label: value` input line
|
package/types/judged.d.ts
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* not set to one model or provider"* — and the shape he named: *"defaults to
|
|
6
|
-
* whatever llm is used and can be overriden"*.
|
|
7
|
-
*
|
|
8
|
-
* So, in precedence order:
|
|
9
|
-
* 1. `spec.judge` — an explicit, SIGNED `{provider, model}`. This is how a run
|
|
10
|
-
* pins a judge deliberately different from its worker (an independent
|
|
11
|
-
* reader, or a judge whose calibration a job wants to keep while the worker
|
|
12
|
-
* moves). It is a spec field the HUMAN signs, part of `jobSpecHash` like
|
|
13
|
-
* every other; the drafting agent cannot express it, because naming your
|
|
14
|
-
* own examiner is arbiter territory.
|
|
15
|
-
* 2. otherwise the job's OWN worker provider and model. A DeepSeek job judges
|
|
16
|
-
* on DeepSeek and needs no second account — which is the whole point: after
|
|
17
|
-
* item 31.4 a green job runs on its own key alone, and this is what lets a
|
|
18
|
-
* JUDGED one do the same.
|
|
19
|
-
*
|
|
20
|
-
* There is deliberately NO third fallback to a library-pinned model. A caller that cannot
|
|
21
|
-
* say which model will grade has not wired a judge, and the grading path stops
|
|
22
|
-
* as a wiring gap rather than grading under an identity nobody chose — the same
|
|
23
|
-
* answer an absent `judgeLoop` already gets. A silent default here would be the
|
|
24
|
-
* exact silent-ignore class that `endpointKey` and F149 exist to prevent, except
|
|
25
|
-
* pointed at the arbiter.
|
|
26
|
-
*
|
|
27
|
-
* SELF-GRADING is licensed by measurement, not by this function: the judge
|
|
28
|
-
* renders no verdict (it locates facts; `decide()` is deterministic), and the
|
|
29
|
-
* calibration gate — 10 cases, a 10-of-10 floor, no partial credit, cases that
|
|
30
|
-
* MUST fail — is exactly the instrument that catches a judge which cannot see
|
|
31
|
-
* failures. If a worker-family judge cannot pass its own calibration, that is
|
|
32
|
-
* the finding, and the gate refuses to sign.
|
|
33
|
-
*
|
|
2
|
+
* WHICH MODEL A JOB'S JUDGE NAMES (PRD item 32.1), in precedence order: `spec.judge`, an explicit SIGNED `{provider, model}` (a spec field the
|
|
3
|
+
* human signs, part of `jobSpecHash`; the drafting agent cannot express it), else the job's OWN worker provider and model. There is deliberately
|
|
4
|
+
* NO third fallback to a library-pinned model, and a malformed `judge` THROWS rather than quietly becoming the worker's.
|
|
34
5
|
* @param {{specJudge?: any, workerProvider?: string, workerModel?: string}} o
|
|
35
6
|
* @returns {{provider: string, model: string}}
|
|
36
7
|
*/
|
|
@@ -43,43 +14,12 @@ export function resolveJudge({ specJudge, workerProvider, workerModel }?: {
|
|
|
43
14
|
model: string;
|
|
44
15
|
};
|
|
45
16
|
/**
|
|
46
|
-
* `resolveJudge`
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* is about to sign, and again at the calibration gate that grades against
|
|
50
|
-
* that stamp — from a value that is not yet a validated spec (the operator's
|
|
51
|
-
* draft) the first time and is one (the assembled spec) the second. Two
|
|
52
|
-
* hand-spelled compositions of `resolveWorkerModel` + `resolveJudge` is
|
|
53
|
-
* exactly the kind of pair that drifts (PRD F45's "a rule with no detector is
|
|
54
|
-
* prose" applies to a rule spelled TWICE just as much as to one spelled
|
|
55
|
-
* nowhere) — this is the one spelling both calls make, and it mirrors the
|
|
56
|
-
* SAME composition `scripts/run-u.mjs` applies at launch time: the named
|
|
57
|
-
* provider's own `tiers.sonnet` defaults an absent model, and a signed
|
|
58
|
-
* `judge` override wins over the worker default.
|
|
59
|
-
*
|
|
60
|
-
* `source` is read for `provider`/`model`/`judge` only, so a draft and the
|
|
61
|
-
* spec `assembleSpec` folds it into resolve identically — `assembleSpec`
|
|
62
|
-
* spreads the draft into the spec untouched on those three fields — and any
|
|
63
|
-
* draft that goes on to validate and sign therefore stamps and grades under
|
|
64
|
-
* the exact same identity `scripts/run-u.mjs` will resolve at run time.
|
|
65
|
-
*
|
|
66
|
-
* `source.provider` absent, or unresolvable, or `source.judge` malformed all
|
|
67
|
-
* THROW here exactly as `resolveProvider`/`resolveJudge` already do on their
|
|
68
|
-
* own — a caller composing this from a pre-validation draft is expected to
|
|
69
|
-
* catch that and use a placeholder, because a draft that cannot resolve here
|
|
70
|
-
* is a draft `validateJob` reds a few lines later regardless, before anything
|
|
71
|
-
* gets signed under the placeholder.
|
|
72
|
-
*
|
|
73
|
-
* `resolveWorkerModelFn` is taken as a PARAMETER rather than imported — this
|
|
74
|
-
* module cannot import `./job.js` directly: `job.js` imports
|
|
75
|
-
* `./declaredclose.js`, which imports `resolveJudge` from THIS module, and a
|
|
76
|
-
* `judged.js` → `job.js` edge would close that into a cycle. `resolveProvider`
|
|
77
|
-
* has no such conflict (`./providers.js` imports nothing local) and is
|
|
78
|
-
* imported directly.
|
|
79
|
-
*
|
|
17
|
+
* `resolveJudge` for a draft or an assembled spec: the one spelling of the identity both the spec stamp and the workflow key use.
|
|
18
|
+
* `source` is read for `provider`/`model`/`judge` only. `resolveWorkerModelFn` is a PARAMETER (`resolveWorkerModel` from `./job.js`) because
|
|
19
|
+
* this module cannot import `./job.js` (it would close an import cycle). An absent or unresolvable provider, or a malformed `judge`, THROWS.
|
|
80
20
|
* @param {{provider?: string, model?: string, judge?: any}} source draft or spec
|
|
81
21
|
* @param {string} fallbackProviderName used only when `source.provider` is absent
|
|
82
|
-
* @param {(o: {specModel?: string, flagModel?: string, suppliedModel?: string}) => {model: string, source: string}} resolveWorkerModelFn
|
|
22
|
+
* @param {(o: {specModel?: string, flagModel?: string, suppliedModel?: string}) => {model: string, source: string}} resolveWorkerModelFn
|
|
83
23
|
* @returns {{provider: string, model: string}}
|
|
84
24
|
*/
|
|
85
25
|
export function resolveJobJudge(source: {
|
|
@@ -97,293 +37,3 @@ export function resolveJobJudge(source: {
|
|
|
97
37
|
provider: string;
|
|
98
38
|
model: string;
|
|
99
39
|
};
|
|
100
|
-
/**
|
|
101
|
-
* THE ONE ACCEPTANCE for "this quote points at the JSDoc block of this declaration":
|
|
102
|
-
* every non-empty line of `docQuote` is a line inside the block directly above the
|
|
103
|
-
* declaration. `has-doc`'s check and the calibration gate's injection facts check
|
|
104
|
-
* both call this, so the two can never disagree about what a good pointer is (F192).
|
|
105
|
-
* @param {string} text the artifact @param {string|null} declQuote @param {string} docQuote
|
|
106
|
-
* @returns {boolean}
|
|
107
|
-
*/
|
|
108
|
-
export function docQuoteInBlock(text: string, declQuote: string | null, docQuote: string): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* The rubric card: Q6's answer compiled into enumerated items, signed by the
|
|
111
|
-
* person and enumerated in the spec hash. `rule` selects from `JUDGE_RULES`;
|
|
112
|
-
* `text` is the signer's own words, carried so a red can be explained in them.
|
|
113
|
-
*
|
|
114
|
-
* Wherever a schema takes free text but only a closed set can satisfy it, hand
|
|
115
|
-
* over the enumerated set — so `rule` is a SELECT and `text` is the only free
|
|
116
|
-
* field, and it decides nothing.
|
|
117
|
-
* @param {any} card
|
|
118
|
-
* @returns {{ok: boolean, reds: string[]}}
|
|
119
|
-
*/
|
|
120
|
-
export function validateCard(card: any): {
|
|
121
|
-
ok: boolean;
|
|
122
|
-
reds: string[];
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* THE CALIBRATION SET's gate. Never throws on proposed input — every failure is a
|
|
126
|
-
* named red in the shipped `{ok, reds}` shape.
|
|
127
|
-
*
|
|
128
|
-
* A CASE is `{id, artifact, expect: {verdict, reds: [{rule, fn}]}}`:
|
|
129
|
-
* `artifact` is REAL TEXT — what LOCATE will actually be pointed at, never a
|
|
130
|
-
* description of it; `verdict` is what `decide()` must render; and `reds` is the
|
|
131
|
-
* ITEMIZED expectation, because the floor is *graded correctly WITH ITEMIZED
|
|
132
|
-
* REDS* — a pipe that reds the right case for the wrong reason has not been
|
|
133
|
-
* calibrated, it has been lucky. `rule` selects from the CARD's own lines (the
|
|
134
|
-
* §4.3 ceiling made mechanical: the judge only ever checks lines the card
|
|
135
|
-
* names) and `fn` is the address `decide()` itself reports.
|
|
136
|
-
*
|
|
137
|
-
* THE SIZE and THE POLARITY are separate reds on purpose: one is hamr's
|
|
138
|
-
* threshold, the other is *the test must be able to FAIL*. A set of ten that can
|
|
139
|
-
* only pass is exactly as unusable as a set of nine, and one red for both would
|
|
140
|
-
* send an operator to fix the wrong half.
|
|
141
|
-
*
|
|
142
|
-
* `card` is REQUIRED and its absence is a red rather than a skipped check — a
|
|
143
|
-
* validator handed no card would report a set it never examined against anything.
|
|
144
|
-
* @param {any} cases @param {{card?: any}} [o]
|
|
145
|
-
* @returns {{ok: boolean, reds: {code: string, path: string, detail: string, [k: string]: any}[]}}
|
|
146
|
-
*/
|
|
147
|
-
export function validateCalibrationSet(cases: any, { card }?: {
|
|
148
|
-
card?: any;
|
|
149
|
-
}): {
|
|
150
|
-
ok: boolean;
|
|
151
|
-
reds: {
|
|
152
|
-
code: string;
|
|
153
|
-
path: string;
|
|
154
|
-
detail: string;
|
|
155
|
-
[k: string]: any;
|
|
156
|
-
}[];
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* BOTH signed artifacts, judged independently and reported together. The card
|
|
160
|
-
* goes through `validateCard` rather than a second spelling of it.
|
|
161
|
-
* @param {{card: any, cases: any}} o
|
|
162
|
-
* @returns {{ok: boolean, reds: {code: string, path: string, detail: string, [k: string]: any}[]}}
|
|
163
|
-
*/
|
|
164
|
-
export function validateJudgedArtifacts({ card, cases }: {
|
|
165
|
-
card: any;
|
|
166
|
-
cases: any;
|
|
167
|
-
}): {
|
|
168
|
-
ok: boolean;
|
|
169
|
-
reds: {
|
|
170
|
-
code: string;
|
|
171
|
-
path: string;
|
|
172
|
-
detail: string;
|
|
173
|
-
[k: string]: any;
|
|
174
|
-
}[];
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* A `decide()` result reduced to the shape a case STORES. ONE spelling, so the
|
|
178
|
-
* expectation a signer signs and the reading module 5 takes off the live pipe are
|
|
179
|
-
* one shape read twice rather than two that can disagree.
|
|
180
|
-
*
|
|
181
|
-
* `why` and `quote` are deliberately dropped: both are the judge's prose about
|
|
182
|
-
* one emission, no signer can predict either, and pinning them would fail an
|
|
183
|
-
* honest pipe on wording. What survives is the ADDRESS — which card line, which
|
|
184
|
-
* function — which is what "itemized reds" means.
|
|
185
|
-
* @param {any} decision
|
|
186
|
-
* @returns {{verdict: string, reds: {rule: string, fn: string}[]}}
|
|
187
|
-
*/
|
|
188
|
-
export function expectedOf(decision: any): {
|
|
189
|
-
verdict: string;
|
|
190
|
-
reds: {
|
|
191
|
-
rule: string;
|
|
192
|
-
fn: string;
|
|
193
|
-
}[];
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* The SHAPE gate on a locate emission, and only the shape: is this the object
|
|
197
|
-
* the rest of the pipe can read at all? A shape miss is an ARTIFACT-RED — the
|
|
198
|
-
* emission is broken and the caller may buy another one.
|
|
199
|
-
*
|
|
200
|
-
* What is deliberately NOT here: per-rule field presence, and an empty function
|
|
201
|
-
* list. Both are well-formed emissions whose CONTENT is unusable, and content
|
|
202
|
-
* is `decide()`'s to red on (contract (a)) — routing them here would let a
|
|
203
|
-
* retry ladder spend money re-asking a model that answered perfectly clearly.
|
|
204
|
-
* It takes the facts and NOTHING else — no card. The shape of a locate emission
|
|
205
|
-
* is the same shape whatever the card asked for, and a second parameter nobody
|
|
206
|
-
* reads is a signature promising a coupling that does not exist.
|
|
207
|
-
* @param {any} facts
|
|
208
|
-
* @returns {{ok: boolean, reds: string[]}}
|
|
209
|
-
*/
|
|
210
|
-
export function validateFacts(facts: any): {
|
|
211
|
-
ok: boolean;
|
|
212
|
-
reds: string[];
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* The locate prompt for ONE card — the only derivation in this module, and it
|
|
216
|
-
* runs card → prompt, one hop, one direction. A rule the card did not name buys
|
|
217
|
-
* no prompt tokens and produces no facts nobody reads.
|
|
218
|
-
* @param {any} card @returns {string}
|
|
219
|
-
*/
|
|
220
|
-
export function locatePrompt(card: any): string;
|
|
221
|
-
/**
|
|
222
|
-
* ONE locate attempt. The caller owns the ladder — this function has no retry,
|
|
223
|
-
* no cap and no opinion about how many times it should be called, because a
|
|
224
|
-
* retry is a spend decision and spend decisions are the arbiter's.
|
|
225
|
-
*
|
|
226
|
-
* THE AXIS PRECEDENCE, and the order is load-bearing:
|
|
227
|
-
* 1. THE CALL FAILED → `provider-red`. A thrown or errored call has no
|
|
228
|
-
* knowable cost, so asking the meter about it would mislabel a transport
|
|
229
|
-
* casualty as a broken meter and send the operator to fix the wrong thing.
|
|
230
|
-
* 2. THE COST IS NULL → `pricing-red`. Checked BEFORE the emission is even
|
|
231
|
-
* looked at: a retry of an unpriced call buys more spend nobody can see,
|
|
232
|
-
* so this is the non-retryable stop and it outranks every retryable one.
|
|
233
|
-
* 3. TRUNCATED → `provider-red`, on its own field, never folded into a parse
|
|
234
|
-
* error. "The model was cut off" and "the model wrote nonsense" are two
|
|
235
|
-
* findings, and one field spelling both is how a reader confuses them.
|
|
236
|
-
* 4. UNPARSEABLE or SHAPE-BROKEN → `artifact-red`. No repair, ever.
|
|
237
|
-
*
|
|
238
|
-
* On every route out, red or clean, `onCost` fires exactly once with the honest
|
|
239
|
-
* read: a paid call that leaves no meter record is F12 wearing a judge's coat.
|
|
240
|
-
* @param {{artifactText: string, card: any, loopFactory: (o: {provider?: any, system: string}) => any,
|
|
241
|
-
* maxTokens?: number, attempt?: number, onCost?: (c: {costUsd: number|null, unpricedRounds: number, rateSource?: string|null}) => void,
|
|
242
|
-
* callBounds?: {timeoutMs?: number, deadlineMs?: number}}} o
|
|
243
|
-
* @returns {Promise<{ok: boolean, facts: any|null, red: {axis: string, detail: string}|null,
|
|
244
|
-
* costUsd: number|null, unpricedRounds: number, truncated: boolean, parseError: boolean,
|
|
245
|
-
* raw: ReturnType<typeof scrubRaw>}>}
|
|
246
|
-
*/
|
|
247
|
-
export function runLocate({ artifactText, card, loopFactory, maxTokens, attempt, onCost, callBounds, }: {
|
|
248
|
-
artifactText: string;
|
|
249
|
-
card: any;
|
|
250
|
-
loopFactory: (o: {
|
|
251
|
-
provider?: any;
|
|
252
|
-
system: string;
|
|
253
|
-
}) => any;
|
|
254
|
-
maxTokens?: number;
|
|
255
|
-
attempt?: number;
|
|
256
|
-
onCost?: (c: {
|
|
257
|
-
costUsd: number | null;
|
|
258
|
-
unpricedRounds: number;
|
|
259
|
-
rateSource?: string | null;
|
|
260
|
-
}) => void;
|
|
261
|
-
callBounds?: {
|
|
262
|
-
timeoutMs?: number;
|
|
263
|
-
deadlineMs?: number;
|
|
264
|
-
};
|
|
265
|
-
}): Promise<{
|
|
266
|
-
ok: boolean;
|
|
267
|
-
facts: any | null;
|
|
268
|
-
red: {
|
|
269
|
-
axis: string;
|
|
270
|
-
detail: string;
|
|
271
|
-
} | null;
|
|
272
|
-
costUsd: number | null;
|
|
273
|
-
unpricedRounds: number;
|
|
274
|
-
truncated: boolean;
|
|
275
|
-
parseError: boolean;
|
|
276
|
-
raw: ReturnType<typeof scrubRaw>;
|
|
277
|
-
}>;
|
|
278
|
-
/**
|
|
279
|
-
* Render the per-item verdicts over one locate result. PURE: same input, same
|
|
280
|
-
* output, forever — which is what makes a calibration set mean anything.
|
|
281
|
-
*
|
|
282
|
-
* FIRST-RED-WINS, in SIGNED CARD ORDER. Every item is still EVALUATED after the
|
|
283
|
-
* first red (calibration demands itemized reds, not a paragraph and not a short
|
|
284
|
-
* circuit); `firstRed` is the composed stage verdict's reason, and its
|
|
285
|
-
* stability comes from the card's own order rather than from whatever order the
|
|
286
|
-
* model happened to emit its functions in.
|
|
287
|
-
*
|
|
288
|
-
* `artifactText` is OPTIONAL and its absence is honest rather than lenient:
|
|
289
|
-
* with the artifact in hand every quote a rule consumes is verified to exist in
|
|
290
|
-
* it, and without it `decide()` simply does not make a claim it cannot support.
|
|
291
|
-
* Callers that HAVE the authoritative artifact (which is every real caller,
|
|
292
|
-
* since the same text was just judged) should always pass it.
|
|
293
|
-
* @param {any} facts a `runLocate` result's `facts`, or null
|
|
294
|
-
* @param {any} card
|
|
295
|
-
* @param {{artifactText?: string|null}} [opts]
|
|
296
|
-
* @returns {{verdict: 'pass'|'red', items: {rule: string, text: string, ok: boolean, reds: RuleRed[]}[],
|
|
297
|
-
* firstRed: string|null, reason: string|null}}
|
|
298
|
-
*/
|
|
299
|
-
export function decide(facts: any, card: any, { artifactText }?: {
|
|
300
|
-
artifactText?: string | null;
|
|
301
|
-
}): {
|
|
302
|
-
verdict: "pass" | "red";
|
|
303
|
-
items: {
|
|
304
|
-
rule: string;
|
|
305
|
-
text: string;
|
|
306
|
-
ok: boolean;
|
|
307
|
-
reds: RuleRed[];
|
|
308
|
-
}[];
|
|
309
|
-
firstRed: string | null;
|
|
310
|
-
reason: string | null;
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* The locate call's token ceiling. The POC's two real artifacts came back well
|
|
314
|
-
* inside 2000; this doubles that for headroom on a longer artifact, and the
|
|
315
|
-
* direction is fail-safe either way — a ceiling that binds produces a TRUNCATED
|
|
316
|
-
* emission, which is a red with its own field, never a silent partial pass. A
|
|
317
|
-
* caller may override it per call; it is a default, not a threshold.
|
|
318
|
-
*/
|
|
319
|
-
export const JUDGE_MAX_TOKENS: 4000;
|
|
320
|
-
/** the label every locate call is metered and persisted under — one spelling */
|
|
321
|
-
export const LOCATE_LABEL: "judged-locate";
|
|
322
|
-
/**
|
|
323
|
-
* The THREE axes a locate attempt can fail on, enumerated because the caller
|
|
324
|
-
* ROUTES on them and a route decided by reading prose is the class this
|
|
325
|
-
* programme keeps paying for. All three are shipped bareloop classes, borrowed
|
|
326
|
-
* with their existing meanings intact:
|
|
327
|
-
* - `pricing-red` the meter is broken. NOT retryable: a retry buys more
|
|
328
|
-
* spend nobody can see.
|
|
329
|
-
* - `provider-red` the call failed or was cut off. Retryable.
|
|
330
|
-
* - `artifact-red` the call succeeded and its emission is unusable.
|
|
331
|
-
* Retryable, under the CALLER's cap — this module runs one
|
|
332
|
-
* attempt and owns no ladder.
|
|
333
|
-
*/
|
|
334
|
-
export const LOCATE_AXES: Readonly<{
|
|
335
|
-
PRICING: "pricing-red";
|
|
336
|
-
PROVIDER: "provider-red";
|
|
337
|
-
ARTIFACT: "artifact-red";
|
|
338
|
-
}>;
|
|
339
|
-
/**
|
|
340
|
-
* Function words ONLY: articles, prepositions, conjunctions. No judgement words
|
|
341
|
-
* ("returns", "gets", "function"): a description that adds one of those has added
|
|
342
|
-
* something, and deciding whether it is MEANINGFUL is exactly what this rule
|
|
343
|
-
* refuses to do.
|
|
344
|
-
*/
|
|
345
|
-
export const SAYS_WHAT_STOPWORDS: readonly string[];
|
|
346
|
-
/**
|
|
347
|
-
* THE OWNED RULE TABLE. Frozen: the rulebook is the arbiter's, and a caller that
|
|
348
|
-
* could add a rule at runtime would be authoring the arbiter.
|
|
349
|
-
* `means` is the rule's plain-words reach: what it CAN check, and what it cannot. The case-proposal
|
|
350
|
-
* prompt renders it, so a proposed case never expects a red the rule cannot raise.
|
|
351
|
-
* @type {Readonly<Record<string, {id: string, means: string, ask: string, check: (fn: any, text: string|null) => RuleRed[]}>>}
|
|
352
|
-
*/
|
|
353
|
-
export const JUDGE_RULES: Readonly<Record<string, {
|
|
354
|
-
id: string;
|
|
355
|
-
means: string;
|
|
356
|
-
ask: string;
|
|
357
|
-
check: (fn: any, text: string | null) => RuleRed[];
|
|
358
|
-
}>>;
|
|
359
|
-
/** the enumerated set a card may name — handed over verbatim in every refusal */
|
|
360
|
-
export const JUDGE_RULE_IDS: readonly string[];
|
|
361
|
-
/**
|
|
362
|
-
* THE SIZE — hamr, 2026-08-18, verbatim: *"go build 10, we could double later"*.
|
|
363
|
-
*
|
|
364
|
-
* Not a number measurement found, and not one the agent may revisit: a size
|
|
365
|
-
* change is a spec-level threshold change and stays operator territory (the
|
|
366
|
-
* standing no-agent-threshold-picking rule). The second half of his sentence is
|
|
367
|
-
* part of the ruling — doubling later is explicitly allowed — which is why it is
|
|
368
|
-
* ONE constant read by the schema, the validator and the refusal alike.
|
|
369
|
-
*/
|
|
370
|
-
export const CALIBRATION_SIZE: 10;
|
|
371
|
-
/** the two verdicts a case may expect — `decide()`'s own closed set */
|
|
372
|
-
export const CASE_VERDICTS: readonly string[];
|
|
373
|
-
export function defaultJudgeLoop({ provider, system, rates, thinking }: {
|
|
374
|
-
provider: any;
|
|
375
|
-
system: string;
|
|
376
|
-
rates?: {
|
|
377
|
-
in: number;
|
|
378
|
-
out: number;
|
|
379
|
-
} | null;
|
|
380
|
-
thinking?: boolean;
|
|
381
|
-
}): {
|
|
382
|
-
run: (msgs: any[], tools: any[], opts?: any) => Promise<any>;
|
|
383
|
-
};
|
|
384
|
-
export type RuleRed = {
|
|
385
|
-
fn: string;
|
|
386
|
-
why: string;
|
|
387
|
-
quote: string | null;
|
|
388
|
-
};
|
|
389
|
-
import { scrubRaw } from './text.js';
|
package/types/kinds.d.ts
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The judged stages of a close declaration, and whether it has any — the ONE
|
|
3
|
-
* spelling of "does this close ask a model to render anything?".
|
|
4
|
-
*
|
|
5
|
-
* The comment above `JUDGED_FLOOR_KIND` says five literals is how the readers
|
|
6
|
-
* come to disagree, and by PRD item 31.4 there were SIX open-coded
|
|
7
|
-
* `stages.filter(s => s.kind === JUDGED_FLOOR_KIND)` across the tree
|
|
8
|
-
* (`src/authorjob.js` twice, `src/cardauthor.js`, `src/declaredclose.js`,
|
|
9
|
-
* `scripts/run-author.mjs`, `scripts/author-readout.mjs`). 31.4 needed a
|
|
10
|
-
* seventh, in the runner, to decide whether a judge KEY is demanded — and a
|
|
11
|
-
* seventh spelling deciding a REFUSAL is the drift `scripts/run-u.mjs`'s own
|
|
12
|
-
* judge-provider comment warns about ("a second reading of the declaration
|
|
13
|
-
* that can drift from the one the runner actually executes"). So there is one
|
|
14
|
-
* reading now, and every caller shares it.
|
|
15
|
-
*
|
|
16
|
-
* Defensive on shape ON PURPOSE: callers pass raw specs read off disk and
|
|
17
|
-
* half-built drafts, not validated declarations. An absent/!object `closeDecl`
|
|
18
|
-
* or `stages` is "no judged stages", never a throw — the close VALIDATOR is
|
|
19
|
-
* what rejects a malformed declaration, and this predicate answering a
|
|
20
|
-
* question about one is not the place to re-litigate it.
|
|
21
|
-
* @param {any} closeDecl a close declaration (or anything, including undefined)
|
|
22
|
-
* @returns {any[]} the judged-floor stages, in declaration order
|
|
23
|
-
*/
|
|
24
|
-
export function judgedStages(closeDecl: any): any[];
|
|
25
|
-
/**
|
|
26
|
-
* Does this close declaration judge — i.e. will a judge model be CALLED?
|
|
27
|
-
* The question `scripts/run-u.mjs` asks before demanding a judge key (PRD item
|
|
28
|
-
* 31.4): a job that never judges must run on its own provider's key alone.
|
|
29
|
-
* @param {any} closeDecl
|
|
30
|
-
* @returns {boolean}
|
|
31
|
-
*/
|
|
32
|
-
export function closeJudges(closeDecl: any): boolean;
|
|
33
1
|
/**
|
|
34
2
|
* Does this run end at a review door? The operator's flag WINS in both
|
|
35
3
|
* directions and is never inferred: `true` opens it for any class, `false` shuts
|
|
@@ -485,41 +453,11 @@ export const SIGNS: readonly number[];
|
|
|
485
453
|
* own live half by the suite, both directions: a kind the catalogue offers and
|
|
486
454
|
* this executor cannot run is a close that stops at runtime, and a kind this
|
|
487
455
|
* executor runs that the catalogue never names is a capability nothing can
|
|
488
|
-
* reach.
|
|
489
|
-
* catalogue unlock in ONE commit for exactly that reason. */
|
|
456
|
+
* reach. */
|
|
490
457
|
export const LIVE_KINDS: readonly string[];
|
|
491
|
-
/**
|
|
492
|
-
* The
|
|
493
|
-
*
|
|
494
|
-
* The POC measured a malformed emission roughly 1 in 6, which is exactly the
|
|
495
|
-
* shape a single retry buys down and a longer ladder buys nothing more of — each
|
|
496
|
-
* further attempt is another paid call against the same unchanged artifact and
|
|
497
|
-
* the same unchanged prompt. It is a CEILING the arbiter owns, never a knob a
|
|
498
|
-
* declaration can widen: a stage that could re-ask a model forever is a stage
|
|
499
|
-
* that can spend a budget without ever rendering a verdict.
|
|
500
|
-
*
|
|
501
|
-
* A `pricing-red` is never retried at all (see `runJudgedFloor`): a retry of an
|
|
502
|
-
* unpriced call only buys more spend nobody can see (F6).
|
|
503
|
-
*/
|
|
504
|
-
export const JUDGE_ATTEMPTS: 2;
|
|
505
|
-
/**
|
|
506
|
-
* The ceiling on how many artifacts ONE judged stage may buy a judgement of —
|
|
507
|
-
* the sibling of `MAX_TERMS` and `MAX_STAGES`, and here for the same reason: a
|
|
508
|
-
* runaway list is a bill, not a red. Enforced by the catalogue's validator
|
|
509
|
-
* before any token, so a declaration that names more is refused at the gate
|
|
510
|
-
* rather than discovered at the invoice.
|
|
511
|
-
*/
|
|
512
|
-
export const MAX_JUDGED_PATHS: 8;
|
|
513
|
-
/** RULING 8 — the stages the seed-verdict read (D12) must NOT run. A judged
|
|
514
|
-
* number at seed is unstable and a person at seed is an interview, not a
|
|
515
|
-
* measurement; their bar comes from calibration (soft-green) or from the person
|
|
516
|
-
* themselves (hitl), never from the seed. The skip is RECORDED by name rather
|
|
517
|
-
* than taken in silence (F59: absent is not empty), so `seedRead` still returns
|
|
458
|
+
/** RULING 8 — the stages the seed-verdict read (D12) must NOT run: a person at seed is an interview, not a measurement; their bar comes from the person
|
|
459
|
+
* themselves (hitl), never from the seed. The skip is RECORDED by name rather than taken in silence (F59: absent is not empty), so `seedRead` still returns
|
|
518
460
|
* one row per declared stage. */
|
|
519
|
-
/** the one kind a MODEL renders. Named once for the same reason `HUMAN_KIND` is:
|
|
520
|
-
* the authoring pipeline, the card, the catalogue and the close each key a
|
|
521
|
-
* decision on it, and five literals is how they come to disagree. */
|
|
522
|
-
export const JUDGED_FLOOR_KIND: "judged-floor";
|
|
523
461
|
export const SEED_EXEMPT_KINDS: readonly string[];
|
|
524
462
|
/** the one kind a PERSON renders — named once, because the runner keys three
|
|
525
463
|
* decisions on it (is there a door to answer, which stage paused, whose ruling
|
|
@@ -587,27 +525,6 @@ export type Red = {
|
|
|
587
525
|
* territory: a declaration parameterises kinds, never the contracts.
|
|
588
526
|
* `humanRuling` is the SIGNER's answer at a hitl pause, carried in from the
|
|
589
527
|
* runner — never authored, never defaulted, and absent on every ordinary run.
|
|
590
|
-
* `judgeLoop` is the PAID seam the judged stage runs its locate call through, and
|
|
591
|
-
* it is operator territory for the same reason the worker's provider is: this
|
|
592
|
-
* module owns no provider and never picks one. Absent is not a fall-back to some
|
|
593
|
-
* other model — the stage stops as a wiring gap, the same answer `runPlan` gives a
|
|
594
|
-
* native job with no native factory.
|
|
595
|
-
* `judgeModel` is the seam's other half (PRD item 32.1): WHICH model that loop
|
|
596
|
-
* drives, resolved by the runner (`resolveJudge`, src/judged.js — the spec's signed
|
|
597
|
-
* `judge` override, else the job's own worker model) rather than pinned in this
|
|
598
|
-
* library. It is required whenever `judgeLoop` is, and for the same reason: a
|
|
599
|
-
* verdict whose grader cannot be named is a floor nobody can attribute, and the
|
|
600
|
-
* signed calibration record has nothing to compare against. The two travel
|
|
601
|
-
* together or the stage stops.
|
|
602
|
-
* `onJudgeCost` is the METER, and it is the only reason a judged stage can be
|
|
603
|
-
* funded honestly: this executor cannot reach the run's ledger, so every locate
|
|
604
|
-
* call's cost is reported OUT through it, once per call, on every route including
|
|
605
|
-
* the red ones — a paid call that leaves no meter record is F12 in a judge's coat.
|
|
606
|
-
* `callBounds` is F152/PRD 30.4's per-call TIME bound, read fresh before every
|
|
607
|
-
* locate attempt — the same derivation the run's own worker rounds carry
|
|
608
|
-
* (`callBounds()`, src/planrun.js). Absent is the honest unbounded default:
|
|
609
|
-
* an adopter or test that wires no clock through behaves exactly as before
|
|
610
|
-
* this field existed.
|
|
611
528
|
* `onStage` is a REPORTING seam and nothing else: the seed read spawns a real
|
|
612
529
|
* toolchain per stage (a suite is the slow one) and a whole read is one opaque
|
|
613
530
|
* await, so the shell gets told as each stage lands. It decides nothing, it is
|
|
@@ -627,29 +544,12 @@ export type Ctx = {
|
|
|
627
544
|
decision: string;
|
|
628
545
|
text?: string | null;
|
|
629
546
|
} | null;
|
|
630
|
-
judgeLoop?: (o: {
|
|
631
|
-
system: string;
|
|
632
|
-
}) => any;
|
|
633
|
-
judgeModel?: string;
|
|
634
|
-
onJudgeCost?: (c: {
|
|
635
|
-
stage: string | null;
|
|
636
|
-
kind: string | null;
|
|
637
|
-
path: string;
|
|
638
|
-
attempt: number;
|
|
639
|
-
label: string;
|
|
640
|
-
model: string;
|
|
641
|
-
costUsd: number | null;
|
|
642
|
-
unpricedRounds: number;
|
|
643
|
-
}) => void;
|
|
644
|
-
callBounds?: () => {
|
|
645
|
-
timeoutMs?: number;
|
|
646
|
-
deadlineMs?: number;
|
|
647
|
-
};
|
|
648
547
|
onRubricEvidence?: (e: {
|
|
649
548
|
step: number;
|
|
650
549
|
evidence: any[];
|
|
651
550
|
evidenceTotal?: number;
|
|
652
551
|
}) => void;
|
|
552
|
+
list?: any[] | null;
|
|
653
553
|
onStage?: (row: {
|
|
654
554
|
stage: string | null;
|
|
655
555
|
kind: string | null;
|