taskflow-core 0.1.4 → 0.1.5

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.
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Scoring gates (`score`) — deterministic, composable output scorers.
3
+ *
4
+ * A `gate` phase may declare `score`: a list of zero-token deterministic
5
+ * scorers (exact-match, contains, regex, json-schema, length-range,
6
+ * code-compiles) evaluated against a target string, combined via
7
+ * `all`/`any`/`weighted` against a threshold. When the deterministic
8
+ * combination passes, the gate auto-passes with NO LLM call (mirroring the
9
+ * `eval` fast-path); when it fails, control falls to the optional `llm-judge`
10
+ * (`score.judge`) or the gate's regular `task`.
11
+ *
12
+ * This module is the PURE half (mirrors contract.ts): shape validation,
13
+ * the 5 string scorers, combination, and report formatting. The impure
14
+ * `code-compiles` scorer (spawns a compiler) lives in scorer-runtime.ts and
15
+ * is dispatched by the runtime — never imported here.
16
+ */
17
+ export declare const SCORER_TYPES: readonly ["exact-match", "contains", "regex", "json-schema", "length-range", "code-compiles"];
18
+ export type ScorerType = (typeof SCORER_TYPES)[number];
19
+ export declare const SCORE_COMBINE_MODES: readonly ["all", "any", "weighted"];
20
+ export type ScoreCombineMode = (typeof SCORE_COMBINE_MODES)[number];
21
+ /** Default weighted-combine threshold (used when `score.threshold` is omitted). */
22
+ export declare const SCORE_DEFAULT_THRESHOLD = 0.5;
23
+ /** Languages the code-compiles scorer can check (see scorer-runtime.ts). */
24
+ export declare const CODE_COMPILES_LANGUAGES: readonly ["javascript", "typescript"];
25
+ export interface Scorer {
26
+ type: ScorerType;
27
+ /** Result label; defaults to `<type>-<index>`. */
28
+ name?: string;
29
+ /** [exact-match|contains] The string to compare/find. */
30
+ value?: string;
31
+ /** [regex] JS RegExp source. An invalid pattern fails the scorer (with detail). */
32
+ pattern?: string;
33
+ /** [regex] Invert the match result. */
34
+ negate?: boolean;
35
+ /** [json-schema] An `expect`-style contract for the parsed target. */
36
+ schema?: unknown;
37
+ /** [length-range] Inclusive bounds on target length (chars). */
38
+ min?: number;
39
+ max?: number;
40
+ /** [code-compiles] Which compiler to run. */
41
+ language?: (typeof CODE_COMPILES_LANGUAGES)[number];
42
+ }
43
+ export interface ScorerResult {
44
+ name: string;
45
+ type: ScorerType;
46
+ passed: boolean;
47
+ /** 0 or 1 for deterministic scorers; the judge's [0,1] score when present. */
48
+ score: number;
49
+ detail?: string;
50
+ }
51
+ /** The `score` field's shape (validated by scorerShapeErrors, not TypeBox —
52
+ * keeps diagnostics precise and the surface documented in one place). */
53
+ export interface ScoreConfig {
54
+ /** Interpolation ref for the scored string. Default: "{previous.output}". */
55
+ target?: string;
56
+ scorers: Scorer[];
57
+ combine?: ScoreCombineMode;
58
+ /** [weighted] Aligned to scorers (+1 trailing judge weight when judge present). */
59
+ weights?: number[];
60
+ /** [weighted] Combined score cutoff in (0, 1]. Default 0.5. */
61
+ threshold?: number;
62
+ /** Optional LLM-as-judge fallback, run only when the deterministics fail. */
63
+ judge?: {
64
+ agent?: string;
65
+ task: string;
66
+ };
67
+ }
68
+ /**
69
+ * Statically check an author-written `score` value. Returns human-readable
70
+ * shape errors ([] = valid). Total: never throws on arbitrary JSON-valid
71
+ * input. Mirrors contractShapeErrors (the `expect` validator).
72
+ */
73
+ export declare function scorerShapeErrors(score: unknown, path?: string): string[];
74
+ /** Default result label for a scorer. */
75
+ export declare function scorerName(s: Scorer, index: number): string;
76
+ /**
77
+ * Evaluate one PURE scorer against the target string. Total: never throws —
78
+ * an invalid configuration (e.g. a bad regex) fails the scorer with a detail.
79
+ * `code-compiles` is NOT handled here (impure — see scorer-runtime.ts).
80
+ */
81
+ export declare function evaluatePureScorer(scorer: Scorer, index: number, target: string): ScorerResult;
82
+ /**
83
+ * Combine deterministic scorer results per the combine mode. `judgeWeight`
84
+ * (weighted mode, judge configured but NOT yet run) enlarges the denominator
85
+ * so the deterministic-only combination is a LOWER BOUND: when it already
86
+ * clears the threshold, the judge's score could not change the outcome and
87
+ * the gate may auto-pass without spending judge tokens.
88
+ */
89
+ export declare function combineScores(results: ScorerResult[], combine: ScoreCombineMode, weights?: number[], threshold?: number, judgeWeight?: number): {
90
+ combined: number;
91
+ passed: boolean;
92
+ };
93
+ /** Fold a completed judge result into a weighted combination (judge = last weight). */
94
+ export declare function combineWithJudge(results: ScorerResult[], weights: number[] | undefined, threshold: number, judgeScore: number): {
95
+ combined: number;
96
+ passed: boolean;
97
+ };
98
+ /** Human-readable scorer report — appended to the judge/gate prompt so the
99
+ * LLM sees exactly which deterministic checks failed and why. */
100
+ export declare function formatScorerReport(results: ScorerResult[], combined: number, threshold?: number): string;
101
+ /** The structured score result stored as the gate's `ps.json` — reachable
102
+ * downstream via `{steps.<gate>.json.combined}` / `...json.results.0.passed`. */
103
+ export declare function scoreResultJSON(results: ScorerResult[], combined: number, verdict: "pass" | "block", threshold?: number, judge?: {
104
+ score: number;
105
+ reason?: string;
106
+ }): Record<string, unknown>;
107
+ /**
108
+ * Parse an LLM judge's output into a score + verdict. Accepts JSON
109
+ * ({score: 0..1, verdict?, reason?}), bare {verdict}, or a text
110
+ * `SCORE: 0.x` / `VERDICT: PASS|BLOCK` marker. Fail-open per the project
111
+ * invariant: unparseable output PASSES with score 1 (ambiguity must not
112
+ * block the flow — same stance as parseGateVerdict).
113
+ */
114
+ export declare function parseJudgeOutput(output: string): {
115
+ score: number;
116
+ verdict: "pass" | "block";
117
+ reason?: string;
118
+ parsed: boolean;
119
+ };
120
+ //# sourceMappingURL=scorers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorers.d.ts","sourceRoot":"","sources":["../src/scorers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,eAAO,MAAM,YAAY,+FAAgG,CAAC;AAC1H,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,mBAAmB,qCAAsC,CAAC;AACvE,MAAM,MAAM,gBAAgB,GA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AA;CAAE,GACxC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CAChB,CA2BA"}
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Scoring gates (`score`) — deterministic, composable output scorers.
3
+ *
4
+ * A `gate` phase may declare `score`: a list of zero-token deterministic
5
+ * scorers (exact-match, contains, regex, json-schema, length-range,
6
+ * code-compiles) evaluated against a target string, combined via
7
+ * `all`/`any`/`weighted` against a threshold. When the deterministic
8
+ * combination passes, the gate auto-passes with NO LLM call (mirroring the
9
+ * `eval` fast-path); when it fails, control falls to the optional `llm-judge`
10
+ * (`score.judge`) or the gate's regular `task`.
11
+ *
12
+ * This module is the PURE half (mirrors contract.ts): shape validation,
13
+ * the 5 string scorers, combination, and report formatting. The impure
14
+ * `code-compiles` scorer (spawns a compiler) lives in scorer-runtime.ts and
15
+ * is dispatched by the runtime — never imported here.
16
+ */
17
+ import { contractShapeErrors, contractViolations } from "./contract.js";
18
+ import { safeParse } from "./interpolate.js";
19
+ export const SCORER_TYPES = ["exact-match", "contains", "regex", "json-schema", "length-range", "code-compiles"];
20
+ export const SCORE_COMBINE_MODES = ["all", "any", "weighted"];
21
+ /** Default weighted-combine threshold (used when `score.threshold` is omitted). */
22
+ export const SCORE_DEFAULT_THRESHOLD = 0.5;
23
+ /** Languages the code-compiles scorer can check (see scorer-runtime.ts). */
24
+ export const CODE_COMPILES_LANGUAGES = ["javascript", "typescript"];
25
+ /** Fields every scorer may carry, plus the per-type applicable ones. A field
26
+ * set on a scorer whose type ignores it is a shape error — silently dropping
27
+ * `{type:"contains", negate:true}` would let the author believe negation
28
+ * happened. */
29
+ const SCORER_COMMON_KEYS = ["type", "name"];
30
+ const SCORER_TYPE_KEYS = {
31
+ "exact-match": ["value"],
32
+ contains: ["value"],
33
+ regex: ["pattern", "negate"],
34
+ "json-schema": ["schema"],
35
+ "length-range": ["min", "max"],
36
+ "code-compiles": ["language"],
37
+ };
38
+ function isPlainObject(v) {
39
+ return typeof v === "object" && v !== null && !Array.isArray(v);
40
+ }
41
+ /**
42
+ * Statically check an author-written `score` value. Returns human-readable
43
+ * shape errors ([] = valid). Total: never throws on arbitrary JSON-valid
44
+ * input. Mirrors contractShapeErrors (the `expect` validator).
45
+ */
46
+ export function scorerShapeErrors(score, path = "score") {
47
+ if (!isPlainObject(score))
48
+ return [`${path}: must be an object ({scorers: [...], combine?, threshold?, judge?})`];
49
+ const errors = [];
50
+ if (score.target !== undefined && typeof score.target !== "string")
51
+ errors.push(`${path}.target: must be a string interpolation ref (e.g. "{steps.gen.output}")`);
52
+ if (!Array.isArray(score.scorers) || score.scorers.length === 0) {
53
+ errors.push(`${path}.scorers: must be a non-empty array of scorers`);
54
+ return errors; // scorer-dependent checks below would be noise
55
+ }
56
+ score.scorers.forEach((s, i) => {
57
+ const p = `${path}.scorers[${i}]`;
58
+ if (!isPlainObject(s)) {
59
+ errors.push(`${p}: must be an object with a 'type'`);
60
+ return;
61
+ }
62
+ const t = s.type;
63
+ if (typeof t !== "string" || !SCORER_TYPES.includes(t)) {
64
+ errors.push(`${p}.type: must be one of ${SCORER_TYPES.join("|")}`);
65
+ return;
66
+ }
67
+ // Reject fields the scorer's type ignores (and unknown fields outright).
68
+ const allowed = new Set([...SCORER_COMMON_KEYS, ...SCORER_TYPE_KEYS[t]]);
69
+ for (const k of Object.keys(s)) {
70
+ if (!allowed.has(k))
71
+ errors.push(`${p}.${k}: not applicable to '${t}' scorers (allowed: ${[...allowed].join(", ")})`);
72
+ }
73
+ if (s.name !== undefined && typeof s.name !== "string")
74
+ errors.push(`${p}.name: must be a string`);
75
+ if ((t === "exact-match" || t === "contains") && typeof s.value !== "string")
76
+ errors.push(`${p}.value: required string for '${t}'`);
77
+ if (t === "regex") {
78
+ if (typeof s.pattern !== "string")
79
+ errors.push(`${p}.pattern: required string for 'regex'`);
80
+ if (s.negate !== undefined && typeof s.negate !== "boolean")
81
+ errors.push(`${p}.negate: must be a boolean`);
82
+ }
83
+ if (t === "json-schema") {
84
+ if (s.schema === undefined)
85
+ errors.push(`${p}.schema: required for 'json-schema'`);
86
+ else
87
+ errors.push(...contractShapeErrors(s.schema, `${p}.schema`));
88
+ }
89
+ if (t === "length-range") {
90
+ if (s.min === undefined && s.max === undefined)
91
+ errors.push(`${p}: 'length-range' requires 'min' and/or 'max'`);
92
+ if (s.min !== undefined && (typeof s.min !== "number" || s.min < 0))
93
+ errors.push(`${p}.min: must be a number >= 0`);
94
+ if (s.max !== undefined && (typeof s.max !== "number" || s.max < 0))
95
+ errors.push(`${p}.max: must be a number >= 0`);
96
+ if (typeof s.min === "number" && typeof s.max === "number" && s.min > s.max)
97
+ errors.push(`${p}: min (${s.min}) must be <= max (${s.max})`);
98
+ }
99
+ if (t === "code-compiles") {
100
+ if (typeof s.language !== "string" || !CODE_COMPILES_LANGUAGES.includes(s.language))
101
+ errors.push(`${p}.language: must be one of ${CODE_COMPILES_LANGUAGES.join("|")}`);
102
+ }
103
+ });
104
+ const combine = score.combine ?? "all";
105
+ if (typeof combine !== "string" || !SCORE_COMBINE_MODES.includes(combine)) {
106
+ errors.push(`${path}.combine: must be one of ${SCORE_COMBINE_MODES.join("|")}`);
107
+ }
108
+ else if (combine === "weighted") {
109
+ const judgeCount = isPlainObject(score.judge) ? 1 : 0;
110
+ const expected = score.scorers.length + judgeCount;
111
+ if (!Array.isArray(score.weights)) {
112
+ errors.push(`${path}.weights: required array for combine:"weighted" (${expected} entries${judgeCount ? " — last one is the judge's weight" : ""})`);
113
+ }
114
+ else {
115
+ if (score.weights.length !== expected)
116
+ errors.push(`${path}.weights: expected ${expected} entries (scorers${judgeCount ? " + judge" : ""}), got ${score.weights.length}`);
117
+ score.weights.forEach((w, i) => {
118
+ if (typeof w !== "number" || !Number.isFinite(w) || w <= 0)
119
+ errors.push(`${path}.weights[${i}]: must be a number > 0`);
120
+ });
121
+ }
122
+ if (score.threshold !== undefined && (typeof score.threshold !== "number" || !(score.threshold > 0) || score.threshold > 1))
123
+ errors.push(`${path}.threshold: must be a number in (0, 1]`);
124
+ }
125
+ else {
126
+ if (score.weights !== undefined)
127
+ errors.push(`${path}.weights: only valid with combine:"weighted"`);
128
+ if (score.threshold !== undefined)
129
+ errors.push(`${path}.threshold: only valid with combine:"weighted"`);
130
+ }
131
+ if (score.judge !== undefined) {
132
+ if (!isPlainObject(score.judge))
133
+ errors.push(`${path}.judge: must be an object ({agent?, task})`);
134
+ else {
135
+ if (typeof score.judge.task !== "string" || !score.judge.task.trim())
136
+ errors.push(`${path}.judge.task: required non-empty string`);
137
+ if (score.judge.agent !== undefined && typeof score.judge.agent !== "string")
138
+ errors.push(`${path}.judge.agent: must be a string agent name`);
139
+ }
140
+ }
141
+ for (const k of Object.keys(score)) {
142
+ if (!["target", "scorers", "combine", "weights", "threshold", "judge"].includes(k))
143
+ errors.push(`${path}.${k}: unknown score keyword (supported: target, scorers, combine, weights, threshold, judge)`);
144
+ }
145
+ return errors;
146
+ }
147
+ /** Default result label for a scorer. */
148
+ export function scorerName(s, index) {
149
+ return typeof s.name === "string" && s.name.trim() ? s.name.trim() : `${s.type}-${index}`;
150
+ }
151
+ /**
152
+ * Evaluate one PURE scorer against the target string. Total: never throws —
153
+ * an invalid configuration (e.g. a bad regex) fails the scorer with a detail.
154
+ * `code-compiles` is NOT handled here (impure — see scorer-runtime.ts).
155
+ */
156
+ export function evaluatePureScorer(scorer, index, target) {
157
+ const name = scorerName(scorer, index);
158
+ const mk = (passed, detail) => ({
159
+ name,
160
+ type: scorer.type,
161
+ passed,
162
+ score: passed ? 1 : 0,
163
+ detail,
164
+ });
165
+ switch (scorer.type) {
166
+ case "exact-match": {
167
+ const passed = target === (scorer.value ?? "");
168
+ return mk(passed, passed ? undefined : `target (${target.length} chars) !== value (${(scorer.value ?? "").length} chars)`);
169
+ }
170
+ case "contains": {
171
+ const passed = target.includes(scorer.value ?? "");
172
+ return mk(passed, passed ? undefined : `target does not contain ${JSON.stringify(truncate(scorer.value ?? "", 80))}`);
173
+ }
174
+ case "regex": {
175
+ let re;
176
+ try {
177
+ re = new RegExp(scorer.pattern ?? "");
178
+ }
179
+ catch (e) {
180
+ return mk(false, `invalid pattern: ${e instanceof Error ? e.message : String(e)}`);
181
+ }
182
+ const matched = re.test(target);
183
+ const passed = scorer.negate === true ? !matched : matched;
184
+ return mk(passed, passed ? undefined : `/${scorer.pattern}/ ${scorer.negate ? "matched (negated)" : "did not match"}`);
185
+ }
186
+ case "json-schema": {
187
+ // Same lenient parse as the `expect` contract path (fence-extraction
188
+ // included) so a json-schema scorer and an expect contract agree on
189
+ // what "the JSON output" is.
190
+ const parsed = safeParse(target);
191
+ if (parsed === undefined)
192
+ return mk(false, "target is not valid JSON");
193
+ const violations = contractViolations(parsed, scorer.schema);
194
+ return mk(violations.length === 0, violations.length ? violations.join("; ") : undefined);
195
+ }
196
+ case "length-range": {
197
+ const len = target.length;
198
+ const min = typeof scorer.min === "number" ? scorer.min : 0;
199
+ const max = typeof scorer.max === "number" ? scorer.max : Infinity;
200
+ const passed = len >= min && len <= max;
201
+ return mk(passed, passed ? undefined : `length ${len} outside [${min}, ${max === Infinity ? "∞" : max}]`);
202
+ }
203
+ case "code-compiles":
204
+ // Dispatched by the runtime to scorer-runtime.ts; reaching here means
205
+ // the dispatch was missed — fail visibly rather than fake a pass.
206
+ return mk(false, "code-compiles must be evaluated by the runtime (impure scorer)");
207
+ default:
208
+ return mk(false, `unknown scorer type '${scorer.type}'`);
209
+ }
210
+ }
211
+ /**
212
+ * Combine deterministic scorer results per the combine mode. `judgeWeight`
213
+ * (weighted mode, judge configured but NOT yet run) enlarges the denominator
214
+ * so the deterministic-only combination is a LOWER BOUND: when it already
215
+ * clears the threshold, the judge's score could not change the outcome and
216
+ * the gate may auto-pass without spending judge tokens.
217
+ */
218
+ export function combineScores(results, combine, weights, threshold = SCORE_DEFAULT_THRESHOLD, judgeWeight = 0) {
219
+ if (results.length === 0)
220
+ return { combined: 0, passed: false };
221
+ if (combine === "any") {
222
+ const passed = results.some((r) => r.passed);
223
+ return { combined: passed ? 1 : 0, passed };
224
+ }
225
+ if (combine === "weighted") {
226
+ const w = Array.isArray(weights) && weights.length >= results.length ? weights : results.map(() => 1);
227
+ let sum = 0;
228
+ let total = judgeWeight;
229
+ for (let i = 0; i < results.length; i++) {
230
+ const wi = typeof w[i] === "number" && w[i] > 0 ? w[i] : 1;
231
+ sum += results[i].score * wi;
232
+ total += wi;
233
+ }
234
+ const combined = total > 0 ? sum / total : 0;
235
+ return { combined, passed: combined >= threshold };
236
+ }
237
+ // "all" (default)
238
+ const passed = results.every((r) => r.passed);
239
+ return { combined: passed ? 1 : 0, passed };
240
+ }
241
+ /** Fold a completed judge result into a weighted combination (judge = last weight). */
242
+ export function combineWithJudge(results, weights, threshold, judgeScore) {
243
+ const w = Array.isArray(weights) && weights.length === results.length + 1 ? weights : [...results.map(() => 1), 1];
244
+ let sum = 0;
245
+ let total = 0;
246
+ for (let i = 0; i < results.length; i++) {
247
+ sum += results[i].score * w[i];
248
+ total += w[i];
249
+ }
250
+ const jw = w[results.length];
251
+ sum += Math.max(0, Math.min(1, judgeScore)) * jw;
252
+ total += jw;
253
+ const combined = total > 0 ? sum / total : 0;
254
+ return { combined, passed: combined >= threshold };
255
+ }
256
+ /** Human-readable scorer report — appended to the judge/gate prompt so the
257
+ * LLM sees exactly which deterministic checks failed and why. */
258
+ export function formatScorerReport(results, combined, threshold) {
259
+ const lines = results.map((r) => `- [${r.passed ? "PASS" : "FAIL"}] ${r.name} (${r.type})${r.detail ? `: ${r.detail}` : ""}`);
260
+ const summary = threshold !== undefined
261
+ ? `Combined score: ${combined.toFixed(3)} (threshold ${threshold})`
262
+ : `Combined score: ${combined.toFixed(3)}`;
263
+ return `## Deterministic scorer report\n${lines.join("\n")}\n${summary}`;
264
+ }
265
+ /** The structured score result stored as the gate's `ps.json` — reachable
266
+ * downstream via `{steps.<gate>.json.combined}` / `...json.results.0.passed`. */
267
+ export function scoreResultJSON(results, combined, verdict, threshold, judge) {
268
+ const out = { verdict, combined, results };
269
+ if (threshold !== undefined)
270
+ out.threshold = threshold;
271
+ if (judge)
272
+ out.judge = judge;
273
+ return out;
274
+ }
275
+ /**
276
+ * Parse an LLM judge's output into a score + verdict. Accepts JSON
277
+ * ({score: 0..1, verdict?, reason?}), bare {verdict}, or a text
278
+ * `SCORE: 0.x` / `VERDICT: PASS|BLOCK` marker. Fail-open per the project
279
+ * invariant: unparseable output PASSES with score 1 (ambiguity must not
280
+ * block the flow — same stance as parseGateVerdict).
281
+ */
282
+ export function parseJudgeOutput(output) {
283
+ const clamp = (n) => Math.max(0, Math.min(1, n));
284
+ const json = safeParse(output);
285
+ if (json && typeof json === "object" && !Array.isArray(json)) {
286
+ const o = json;
287
+ const reason = typeof o.reason === "string" && o.reason.trim() ? o.reason.trim() : undefined;
288
+ const rawScore = typeof o.score === "number" ? o.score : typeof o.score === "string" ? Number(o.score) : NaN;
289
+ const hasScore = Number.isFinite(rawScore);
290
+ if (typeof o.verdict === "string") {
291
+ const block = /block|fail|stop|reject|halt/i.test(o.verdict);
292
+ return { score: hasScore ? clamp(rawScore) : block ? 0 : 1, verdict: block ? "block" : "pass", reason, parsed: true };
293
+ }
294
+ if (hasScore) {
295
+ const s = clamp(rawScore);
296
+ return { score: s, verdict: s >= 0.5 ? "pass" : "block", reason, parsed: true };
297
+ }
298
+ }
299
+ const scoreMatches = [...output.matchAll(/SCORE\s*[:=]\s*([01](?:\.\d+)?)/gi)];
300
+ const verdictMatches = [...output.matchAll(/VERDICT\s*[:=]\s*(PASS|BLOCK|FAIL|STOP|OK|REJECT|HALT)/gi)];
301
+ if (scoreMatches.length || verdictMatches.length) {
302
+ const s = scoreMatches.length ? clamp(Number(scoreMatches[scoreMatches.length - 1][1])) : undefined;
303
+ const v = verdictMatches.length ? verdictMatches[verdictMatches.length - 1][1].toUpperCase() : undefined;
304
+ const blocked = v !== undefined ? !(v === "PASS" || v === "OK") : (s ?? 1) < 0.5;
305
+ return { score: s ?? (blocked ? 0 : 1), verdict: blocked ? "block" : "pass", parsed: true };
306
+ }
307
+ // Fail-open: ambiguous judge output must not block the flow.
308
+ return { score: 1, verdict: "pass", reason: "unparseable judge output (fail-open pass)", parsed: false };
309
+ }
310
+ function truncate(s, n) {
311
+ return s.length <= n ? s : `${s.slice(0, n)}…`;
312
+ }
313
+ //# sourceMappingURL=scorers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorers.js","sourceRoot":"","sources":["../src/scorers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,CAAU,CAAC;AAG1H,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAU,CAAC;AAGvE,mFAAmF;AACnF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,YAAY,EAAE,YAAY,CAAU,CAAC;AA6C7E;;;gBAGgB;AAChB,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AACrD,MAAM,gBAAgB,GAA0C;IAC/D,aAAa,EAAE,CAAC,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,OAAO,CAAC;IACnB,KAAK,EAAE,CAAC,SAAS,EAAE,QAAQ,CAA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AC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACzG,MAAM,OAAO,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QACjF,OAAO,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7F,CAAC;IACD,6DAA6D;IAC7D,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,2CAA2C,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC1G,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAE,CAAS;IACrC,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;AAChD,CAAC"}
package/dist/store.d.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  import type { Taskflow } from "./schema.ts";
17
17
  import type { UsageStats } from "./usage.ts";
18
18
  import type { DeclaredDeps } from "./flowir/meta.ts";
19
+ import type { ScorerResult } from "./scorers.ts";
19
20
  export interface SavedFlow {
20
21
  name: string;
21
22
  scope: "user" | "project";
@@ -53,7 +54,20 @@ export interface PhaseState {
53
54
  gate?: {
54
55
  verdict: "pass" | "block";
55
56
  reason?: string;
57
+ /** Deterministic scorer results (score gates only). Present whenever the
58
+ * gate declared `score` and the scorers actually ran. `combined` is the
59
+ * [0,1] combined score; `threshold` echoes the configured cutoff. */
60
+ scores?: {
61
+ results: ScorerResult[];
62
+ combined: number;
63
+ threshold?: number;
64
+ };
56
65
  };
66
+ /** True when this phase declared `idempotent: false` (irreversible side
67
+ * effects). Such a phase is never cached (in any scope) and transient
68
+ * provider errors are not auto-retried. De facto mutually exclusive with
69
+ * `cacheHit` (caching is disabled for side-effecting phases). */
70
+ sideEffect?: true;
57
71
  /** Total subagent attempts incl. retries (when > calls, a retry happened). */
58
72
  attempts?: number;
59
73
  /** True when the phase's `timeout` cap expired and the subagent was aborted.
@@ -69,10 +83,19 @@ export interface PhaseState {
69
83
  note?: string;
70
84
  auto?: boolean;
71
85
  };
72
- /** Loop iteration accounting (loop phases only). */
86
+ /** Loop iteration accounting (loop phases only). `reflexion` is the last
87
+ * failure summary injected into an iteration (audit trail for reflexion loops).
88
+ * `failures` records each failed iteration's (sanitized) error — useful when a
89
+ * reflexion loop continues past failures and only the terminal one would
90
+ * otherwise survive in `error`. Bounded (most-recent kept). */
73
91
  loop?: {
74
92
  iterations: number;
75
93
  stop: "until" | "converged" | "maxIterations" | "failed" | "aborted";
94
+ reflexion?: string;
95
+ failures?: Array<{
96
+ iteration: number;
97
+ error: string;
98
+ }>;
76
99
  };
77
100
  /** Tournament outcome (tournament phases only). */
78
101
  tournament?: {
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,G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